diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d1974f233307..f6f578153304 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,18 +5,16 @@ # For the full docs on CODEOWNERS, see: # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners -# Disable everything on working feature branch. - # Metrics owners -# /cobalt/browser/metrics/ @joeltine -# /components/metrics/ @joeltine -# /tools/metrics/ @joeltine +/cobalt/browser/metrics/ @joeltine +/components/metrics/ @joeltine +/tools/metrics/ @joeltine -# Temporary monitoring for merges to Chromium upstreams -# /base/ @andrewsavage1 @youtube/cobalt-3p-repository-owners -# /build/ @andrewsavage1 @youtube/cobalt-3p-repository-owners -# /crypto/ @andrewsavage1 @youtube/cobalt-3p-repository-owners -# /net/ @andrewsavage1 @youtube/cobalt-3p-repository-owners -# /third_party/abseil-cpp/ @andrewsavage1 @youtube/cobalt-3p-repository-owners -# /third_party/modp_b64/ @andrewsavage1 @youtube/cobalt-3p-repository-owners -# /url/ @andrewsavage1 @youtube/cobalt-3p-repository-owners +# Monitoring for merges to Chromium upstreams +/base/ @youtube/cobalt-3p-repository-owners +/build/ @youtube/cobalt-3p-repository-owners +/crypto/ @youtube/cobalt-3p-repository-owners +/net/ @youtube/cobalt-3p-repository-owners +/third_party/abseil-cpp/ @youtube/cobalt-3p-repository-owners +/third_party/modp_b64/ @youtube/cobalt-3p-repository-owners +/url/ @youtube/cobalt-3p-repository-owners diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d5e1c15b2bac..71b6278e1de0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -74,6 +74,7 @@ jobs: github.event.label.name == 'runtest' || github.event.label.name == 'on_device' ) + timeout-minutes: 10 steps: - id: checkout uses: kaidokert/checkout@v3.5.999 @@ -148,6 +149,7 @@ jobs: runs-on: [self-hosted, linux-runner] permissions: packages: write + timeout-minutes: 30 steps: - name: Checkout files uses: kaidokert/checkout@v3.5.999 @@ -184,6 +186,7 @@ jobs: permissions: packages: write runs-on: [self-hosted, linux-runner] + timeout-minutes: 30 steps: - name: Checkout files uses: kaidokert/checkout@v3.5.999 @@ -231,6 +234,7 @@ jobs: # However, dind container ends up having / folder mounted on overlay # filesystem, whereas /__w which contains Cobalt source code is on tmpfs. TMPDIR: /__w/_temp + timeout-minutes: 60 steps: - name: Checkout uses: kaidokert/checkout@v3.5.999 @@ -367,6 +371,7 @@ jobs: HOME: /root COBALT_EVERGREEN_LOADER: ${{needs.initialize.outputs.evergreen_loader}} MODULAR_BUILD: ${{ inputs.modular && 1 || 0 }} + timeout-minutes: 90 steps: - name: Checkout uses: kaidokert/checkout@v3.5.999 diff --git a/.github/workflows/main_win.yaml b/.github/workflows/main_win.yaml index 146424bc2b74..d3ac0cfcb17e 100644 --- a/.github/workflows/main_win.yaml +++ b/.github/workflows/main_win.yaml @@ -61,6 +61,7 @@ jobs: github.event.label.name == 'runtest' || github.event.label.name == 'on_device' ) + timeout-minutes: 10 steps: - id: Checkout uses: kaidokert/checkout@v3.5.999 # Temporary version @@ -133,6 +134,7 @@ jobs: permissions: packages: write runs-on: windows-2019 + timeout-minutes: 120 steps: - name: Checkout files uses: kaidokert/checkout@v3.5.999 @@ -167,6 +169,7 @@ jobs: platform: ${{ fromJson(needs.initialize.outputs.platforms) }} include: ${{ fromJson(needs.initialize.outputs.includes) }} config: [devel, debug, qa, gold] + timeout-minutes: 90 steps: - name: Checkout uses: kaidokert/checkout@v3.5.999 @@ -204,6 +207,7 @@ jobs: include: ${{ fromJson(needs.initialize.outputs.includes) }} env: MODULAR_BUILD: ${{ inputs.modular && 1 || 0 }} + timeout-minutes: 90 steps: - name: Checkout uses: kaidokert/checkout@v3.5.999 diff --git a/.github/workflows/pytest_25.lts.1+.yaml b/.github/workflows/pytest_25.lts.1+.yaml index 0951c7d8cbfb..87b4b58d306a 100644 --- a/.github/workflows/pytest_25.lts.1+.yaml +++ b/.github/workflows/pytest_25.lts.1+.yaml @@ -20,6 +20,7 @@ jobs: python-version: ['3.8', '3.11'] fail-fast: false runs-on: ${{ matrix.os }} + timeout-minutes: 15 steps: - name: Checkout uses: kaidokert/checkout@v3.5.999 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e59aa7ec0bb..03d2ae3c11d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,6 @@ files: | .github| cobalt| docker| - glimp| internal| precommit_hooks| starboard| @@ -25,8 +24,8 @@ exclude: | (?x)^( ( cobalt/updater| - glimp/include| internal/kokoro/third-party| + internal/starboard/shared/glimp/include| internal/starboard/shared/playstation/glimp/shaders| )/ | @@ -147,7 +146,7 @@ repos: cobalt/websocket/| components/crx_file/| content/| - glimp/| + internal/starboard/shared/glimp/| nb/| starboard/android/apk/gradlew| starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaDrmBridge.java$| diff --git a/base/BUILD.gn b/base/BUILD.gn index e430269b480b..4e7f2a028b15 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -102,8 +102,8 @@ if (is_apple) { } # Determines whether libevent should be dep. -dep_libevent = - !is_fuchsia && !is_win && !is_mac && !is_nacl && !use_cobalt_customizations +dep_libevent = !is_fuchsia && !is_win && !is_mac && !is_nacl + && !use_cobalt_customizations # Determines whether message_pump_libevent should be used. use_libevent = dep_libevent && !is_ios @@ -1459,7 +1459,7 @@ component("base") { } # Fuchsia. - if (is_fuchsia && !is_starboard) { + if (is_fuchsia) { sources += [ "base_paths_fuchsia.cc", "debug/debugger_fuchsia.cc", @@ -2368,9 +2368,9 @@ component("base") { } if (!is_starboard) { - if ((is_posix && !is_apple && !is_android) || is_fuchsia) { - sources += [ "profiler/stack_sampler_posix.cc" ] - } + if ((is_posix && !is_apple && !is_android) || is_fuchsia) { + sources += [ "profiler/stack_sampler_posix.cc" ] + } } if ((is_posix && !is_apple && !is_android && !is_chromeos) || is_fuchsia || is_starboard) { @@ -2764,9 +2764,6 @@ component("i18n") { "i18n/streaming_utf8_validator.h", "i18n/string_compare.cc", "i18n/string_compare.h", - - # "i18n/string_search.cc", - # "i18n/string_search.h", "i18n/time_formatting.cc", "i18n/time_formatting.h", "i18n/timezone.cc", @@ -2776,10 +2773,6 @@ component("i18n") { "i18n/utf8_validator_tables.h", ] defines = [ "BASE_I18N_IMPLEMENTATION" ] - defines += [ - "U_COMMON_IMPLEMENTATION", - "UCONFIG_NO_CONVERSION=0", - ] configs += [ "//build/config/compiler:wexit_time_destructors" ] public_deps = [ "//third_party/ced", @@ -2802,8 +2795,8 @@ component("i18n") { configs -= [ "//starboard/build/config:size" ] configs += [ "//starboard/build/config:speed" ] } else { - configs -= [ "//build/config/compiler:default_optimization" ] - configs += [ "//build/config/compiler:optimize_max" ] + configs -= [ "//build/config/compiler:default_optimization" ] + configs += [ "//build/config/compiler:optimize_max" ] } } @@ -2820,82 +2813,82 @@ component("i18n") { } if (!is_starboard) { - test("base_perftests") { - sources = [ - "hash/hash_perftest.cc", - "message_loop/message_pump_perftest.cc", - "observer_list_perftest.cc", - "rand_util_perftest.cc", - "strings/string_util_perftest.cc", - "substring_set_matcher/substring_set_matcher_perftest.cc", - "task/job_perftest.cc", - "task/sequence_manager/sequence_manager_perftest.cc", - "task/thread_pool/thread_pool_perftest.cc", - "threading/counter_perftest.cc", - "threading/thread_local_storage_perftest.cc", - - # "test/run_all_unittests.cc", - "json/json_perftest.cc", - "synchronization/lock_perftest.cc", - "synchronization/waitable_event_perftest.cc", - "threading/thread_perftest.cc", - ] - - deps = [ - ":base", - ":debugging_buildflags", - "//base/test:test_support", - "//base/test:test_support_perf", - "//testing/gtest", - "//testing/perf", - ] +test("base_perftests") { + sources = [ + "hash/hash_perftest.cc", + "message_loop/message_pump_perftest.cc", + "observer_list_perftest.cc", + "rand_util_perftest.cc", + "strings/string_util_perftest.cc", + "substring_set_matcher/substring_set_matcher_perftest.cc", + "task/job_perftest.cc", + "task/sequence_manager/sequence_manager_perftest.cc", + "task/thread_pool/thread_pool_perftest.cc", + "threading/counter_perftest.cc", + "threading/thread_local_storage_perftest.cc", + + # "test/run_all_unittests.cc", + "json/json_perftest.cc", + "synchronization/lock_perftest.cc", + "synchronization/waitable_event_perftest.cc", + "threading/thread_perftest.cc", + ] - if (use_partition_alloc) { - sources += [ - "allocator/partition_allocator/partition_alloc_perftest.cc", - "allocator/partition_allocator/partition_lock_perftest.cc", - ] - deps += [ ":partition_alloc_test_support" ] - } + deps = [ + ":base", + ":debugging_buildflags", + "//base/test:test_support", + "//base/test:test_support_perf", + "//testing/gtest", + "//testing/perf", + ] - data_deps = [ - # Needed for isolate script to execute. - "//testing:run_perf_test", + if (use_partition_alloc) { + sources += [ + "allocator/partition_allocator/partition_alloc_perftest.cc", + "allocator/partition_allocator/partition_lock_perftest.cc", ] + deps += [ ":partition_alloc_test_support" ] + } - if (is_android) { - deps += [ "//testing/android/native_test:native_test_native_code" ] - shard_timeout = 600 - } + data_deps = [ + # Needed for isolate script to execute. + "//testing:run_perf_test", + ] - if (is_fuchsia) { - # Run these performance tests against the actual system. - run_as_chromium_system_test = true - } + if (is_android) { + deps += [ "//testing/android/native_test:native_test_native_code" ] + shard_timeout = 600 + } - if (!is_official_build) { - # The extra data tables required by stack traces are turned off for official - # build, only do stack trace perftest for unofficial build - sources += [ "debug/stack_trace_perftest.cc" ] - } + if (is_fuchsia) { + # Run these performance tests against the actual system. + run_as_chromium_system_test = true + } - if (build_allocation_stack_trace_recorder) { - sources += [ "debug/allocation_trace_perftest.cc" ] - } + if (!is_official_build) { + # The extra data tables required by stack traces are turned off for official + # build, only do stack trace perftest for unofficial build + sources += [ "debug/stack_trace_perftest.cc" ] } - test("base_i18n_perftests") { - sources = [ "i18n/streaming_utf8_validator_perftest.cc" ] - deps = [ - ":base", - ":i18n", - "//base/test:test_support", - "//base/test:test_support_perf", - "//testing/gtest", - ] + if (build_allocation_stack_trace_recorder) { + sources += [ "debug/allocation_trace_perftest.cc" ] } } +test("base_i18n_perftests") { + sources = [ "i18n/streaming_utf8_validator_perftest.cc" ] + deps = [ + ":base", + ":i18n", + "//base/test:test_support", + "//base/test:test_support_perf", + "//testing/gtest", + ] +} +} + if (!is_ios && !use_cobalt_customizations) { executable("build_utf8_validator_tables") { sources = [ "i18n/build_utf8_validator_tables.cc" ] @@ -3019,35 +3012,35 @@ source_set("base_stack_sampling_profiler_test_util") { } copy("base_unittests_bundle_data") { - testonly = true + testonly = true if (is_starboard) { install_content = true } - sources = [ - "//tools/metrics/histograms/enums.xml", - "test/data/file_util/binary_file.bin", - "test/data/file_util/binary_file_diff.bin", - "test/data/file_util/binary_file_same.bin", - "test/data/file_util/blank_line.txt", - "test/data/file_util/blank_line_crlf.txt", - "test/data/file_util/crlf.txt", - "test/data/file_util/different.txt", - "test/data/file_util/different_first.txt", - "test/data/file_util/different_last.txt", - "test/data/file_util/empty1.txt", - "test/data/file_util/empty2.txt", - "test/data/file_util/first1.txt", - "test/data/file_util/first2.txt", - "test/data/file_util/original.txt", - "test/data/file_util/same.txt", - "test/data/file_util/same_length.txt", - "test/data/file_util/shortened.txt", - "test/data/json/bom_feff.json", - "test/data/pe_image_reader/signed.exe", - "test/data/serializer_nested_test.json", - "test/data/serializer_test.json", - "test/data/serializer_test_nowhitespace.json", - ] + sources = [ + "//tools/metrics/histograms/enums.xml", + "test/data/file_util/binary_file.bin", + "test/data/file_util/binary_file_diff.bin", + "test/data/file_util/binary_file_same.bin", + "test/data/file_util/blank_line.txt", + "test/data/file_util/blank_line_crlf.txt", + "test/data/file_util/crlf.txt", + "test/data/file_util/different.txt", + "test/data/file_util/different_first.txt", + "test/data/file_util/different_last.txt", + "test/data/file_util/empty1.txt", + "test/data/file_util/empty2.txt", + "test/data/file_util/first1.txt", + "test/data/file_util/first2.txt", + "test/data/file_util/original.txt", + "test/data/file_util/same.txt", + "test/data/file_util/same_length.txt", + "test/data/file_util/shortened.txt", + "test/data/json/bom_feff.json", + "test/data/pe_image_reader/signed.exe", + "test/data/serializer_nested_test.json", + "test/data/serializer_test.json", + "test/data/serializer_test_nowhitespace.json", + ] if (is_starboard) { outputs = [ "$sb_static_contents_output_data_dir/test/base/{{source_target_relative}}" ] } else { @@ -3647,13 +3640,7 @@ test("base_unittests") { "//third_party/modp_b64", ] - defines = [ "U_COMMON_IMPLEMENTATION" ] - data_deps = [ - # "//base/test:immediate_crash_test_helper", - # "//base/test:test_child_process", - # "//base/test:test_shared_library", - # "//testing/buildbot/filters:base_unittests_filters", ] if (is_android && enable_chrome_android_internal) { @@ -3665,16 +3652,15 @@ test("base_unittests") { } if (is_apple && !is_starboard) { + public_deps = [ ":base_unittests_bundle_data" ] + deps += [ ":base_unittests_arc" ] } - public_deps = [ ":base_unittests_bundle_data" ] - if (is_starboard){ data_deps += [ ":base_unittests_bundle_data", "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", ] } @@ -3763,6 +3749,7 @@ test("base_unittests") { "debug/proc_maps_linux_unittest.cc", "files/scoped_file_linux_unittest.cc", ] + if (!!use_cobalt_customizations && !is_nacl) { deps += [ ":stack_canary_linux_unittests" ] } diff --git a/base/METADATA b/base/METADATA index f0db31eb09a8..3d9342e0e79e 100644 --- a/base/METADATA +++ b/base/METADATA @@ -3,11 +3,19 @@ description: "Subtree at base." third_party { - url { - type: GIT - value: "https://chromium.googlesource.com/chromium/src" + identifier { + type: "ChromiumVersion" + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html + } + identifier { + type: "Git" + value: "https://chromium.googlesource.com/chromium/src.git" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" + } + identifier { + type: "UpstreamSubdir" + value: "base" } - version: "114.0.5735.331" last_upgrade_date { year: 2023 month: 9 diff --git a/base/allocator/dispatcher/tls_unittest.cc b/base/allocator/dispatcher/tls_unittest.cc index a2d9ed2097c6..ccbe08a7da7e 100644 --- a/base/allocator/dispatcher/tls_unittest.cc +++ b/base/allocator/dispatcher/tls_unittest.cc @@ -7,7 +7,6 @@ #if USE_LOCAL_TLS_EMULATION() #include #include -#include #include #include #include @@ -586,4 +585,4 @@ TEST_F(BasePThreadTLSSystemDeathTest, VerifyDeathIfTearDownWithoutSetup) { #endif } // namespace base::allocator::dispatcher -#endif // USE_LOCAL_TLS_EMULATION() +#endif // USE_LOCAL_TLS_EMULATION() \ No newline at end of file diff --git a/base/allocator/partition_allocator/partition_alloc.gni b/base/allocator/partition_allocator/partition_alloc.gni index cfcfbee68605..e6835a8917d5 100644 --- a/base/allocator/partition_allocator/partition_alloc.gni +++ b/base/allocator/partition_allocator/partition_alloc.gni @@ -20,8 +20,7 @@ if (is_nacl) { } else if (current_cpu == "x86" || current_cpu == "arm") { has_64_bit_pointers = false } else { - has_64_bit_pointers = true - # assert(false, "Unknown CPU: $current_cpu") + assert(false, "Unknown CPU: $current_cpu") } if (use_partition_alloc_as_malloc_default) { diff --git a/base/allocator/partition_allocator/partition_alloc_base/rand_util_posix.cc b/base/allocator/partition_allocator/partition_alloc_base/rand_util_posix.cc index c18416ca732b..6019bbc715c3 100644 --- a/base/allocator/partition_allocator/partition_alloc_base/rand_util_posix.cc +++ b/base/allocator/partition_allocator/partition_alloc_base/rand_util_posix.cc @@ -69,8 +69,7 @@ namespace partition_alloc::internal::base { // (https://chromium-review.googlesource.com/c/chromium/src/+/1545096) and land // it or some form of it. void RandBytes(void* output, size_t output_length) { -// TODO(b/298237462): Clean this up for Cobalt or don't use PA. -#if 0 +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // We have to call `getrandom` via Linux Syscall Support, rather than through // the libc wrapper, because we might not have an up-to-date libc (e.g. on // some bots). diff --git a/base/allocator/partition_allocator/partition_alloc_unittest.cc b/base/allocator/partition_allocator/partition_alloc_unittest.cc index df4ba51bb44f..9a0db5559e02 100644 --- a/base/allocator/partition_allocator/partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/partition_alloc_unittest.cc @@ -97,7 +97,7 @@ bool IsLargeMemoryDevice() { } bool SetAddressSpaceLimit() { -#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) || 1 +#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) // 32 bits => address space is limited already. return true; #elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) @@ -125,7 +125,7 @@ bool SetAddressSpaceLimit() { } bool ClearAddressSpaceLimit() { -#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) || 1 +#if !defined(ARCH_CPU_64_BITS) || !BUILDFLAG(IS_POSIX) return true; #elif BUILDFLAG(IS_POSIX) struct rlimit limit; @@ -622,7 +622,7 @@ void FreeFullSlotSpan(PartitionRoot* root, EXPECT_TRUE(slot_span->is_empty()); } -#if 0// BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) bool CheckPageInCore(void* ptr, bool in_core) { unsigned char ret = 0; EXPECT_EQ(0, mincore(ptr, SystemPageSize(), &ret)); diff --git a/base/android/jni_generator/AndroidManifest.xml b/base/android/jni_generator/AndroidManifest.xml index 6be3fe332fed..8fd983c53c57 100644 --- a/base/android/jni_generator/AndroidManifest.xml +++ b/base/android/jni_generator/AndroidManifest.xml @@ -7,7 +7,6 @@ - diff --git a/base/base_paths.cc b/base/base_paths.cc index 50728b2f6ce3..456b21c91f2b 100644 --- a/base/base_paths.cc +++ b/base/base_paths.cc @@ -42,7 +42,7 @@ bool PathProvider(int key, FilePath* result) { #endif // !BUILDFLAG(IS_FUCHSIA) case DIR_TEST_DATA: { FilePath test_data_path; - if (!PathService::Get(DIR_MODULE, &test_data_path)) + if (!PathService::Get(DIR_SRC_TEST_DATA_ROOT, &test_data_path)) return false; test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base")); test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test")); diff --git a/base/bits.h b/base/bits.h index 4b6521d24b81..f2d2caa1d6c8 100644 --- a/base/bits.h +++ b/base/bits.h @@ -182,11 +182,6 @@ ALWAYS_INLINE constexpr // use `Log2Floor` and add 1 to the result. // // TODO(pkasting): When C++20 is available, replace with std::bit_xxx(). -#if defined(COBALT_PENDING_CLEAN_UP) && defined(COMPILER_MSVC) -#define FUNCTION_SPECIFIER ALWAYS_INLINE -#else -#define FUNCTION_SPECIFIER constexpr -#endif ALWAYS_INLINE int Log2Floor(uint32_t n) { return 31 - CountLeadingZeroBits(n); } @@ -198,7 +193,6 @@ ALWAYS_INLINE int Log2Ceiling(uint32_t n) { // why the statement below starts with (n ? 32 : -1). return (n ? 32 : -1) - CountLeadingZeroBits(n - 1); } -#undef FUNCTION_SPECIFIER // Returns a value of type T with a single bit set in the left-most position. // Can be used instead of manually shifting a 1 to the left. diff --git a/base/check_is_test_unittest.cc b/base/check_is_test_unittest.cc index fb2ef765b222..3f7fa36ca5b9 100644 --- a/base/check_is_test_unittest.cc +++ b/base/check_is_test_unittest.cc @@ -5,13 +5,11 @@ #include "base/check_is_test.h" #include "testing/gtest/include/gtest/gtest.h" -#include "base/test/allow_check_is_test_for_testing.h" // Note: `base::AllowCheckIsTestForTesting` is being called in // `base/test/launcher/unit_test_launcher.cc` before this test is run. // // Thus, `CHECK_IS_TEST()` will succeed. TEST(CheckIsTest, Usage) { - base::test::AllowCheckIsTestForTesting(); CHECK_IS_TEST(); } diff --git a/base/debug/stack_trace_unittest.cc b/base/debug/stack_trace_unittest.cc index a6a343416814..74793e5e4e56 100644 --- a/base/debug/stack_trace_unittest.cc +++ b/base/debug/stack_trace_unittest.cc @@ -4,7 +4,6 @@ #include -#include #include #include #include @@ -276,9 +275,6 @@ NOINLINE static std::unique_ptr CopyCurrentStackAndRewritePointers( reinterpret_cast(__builtin_frame_address(0)); uintptr_t original_stack_end = GetStackEnd(); size_t stack_size = original_stack_end - reinterpret_cast(fp); - // On some platforms, stack_size overflows due to the reinterpret_cast. - const size_t max_stack_size = 102400; - stack_size = std::min(stack_size, max_stack_size); auto buffer = std::make_unique(stack_size); *out_fp = reinterpret_cast( CopyFunction::CopyStackContentsAndRewritePointers( diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc index e9b72609bf3f..3899113db394 100644 --- a/base/feature_list_unittest.cc +++ b/base/feature_list_unittest.cc @@ -626,7 +626,7 @@ TEST_F(FeatureListTest, UninitializedInstance_IsEnabledReturnsFalse) { } #if !defined(STARBOARD) -TEST_F(FeatureListTest, DISABLED_StoreAndRetrieveFeaturesFromSharedMemory) { +TEST_F(FeatureListTest, StoreAndRetrieveFeaturesFromSharedMemory) { std::unique_ptr feature_list(new base::FeatureList); // Create some overrides. @@ -659,7 +659,7 @@ TEST_F(FeatureListTest, DISABLED_StoreAndRetrieveFeaturesFromSharedMemory) { kFeatureOnByDefaultName, FeatureList::OVERRIDE_DISABLE_FEATURE)); } -TEST_F(FeatureListTest, DISABLED_StoreAndRetrieveAssociatedFeaturesFromSharedMemory) { +TEST_F(FeatureListTest, StoreAndRetrieveAssociatedFeaturesFromSharedMemory) { std::unique_ptr feature_list(new base::FeatureList); // Create some overrides. diff --git a/base/files/file.cc b/base/files/file.cc index 9d3c38c77438..aa4e59563d78 100644 --- a/base/files/file.cc +++ b/base/files/file.cc @@ -17,7 +17,6 @@ #include "build/build_config.h" #if defined(STARBOARD) -#include "starboard/common/log.h" #include "starboard/types.h" #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) #include diff --git a/base/files/file_starboard.cc b/base/files/file_starboard.cc index 1e1439be9887..86d5f21b2971 100644 --- a/base/files/file_starboard.cc +++ b/base/files/file_starboard.cc @@ -23,7 +23,6 @@ #include "base/notreached.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_restrictions.h" -#include "starboard/common/log.h" #include "starboard/common/metrics/stats_tracker.h" #include "starboard/file.h" diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc index bad10c57981b..e81663c65984 100644 --- a/base/files/file_unittest.cc +++ b/base/files/file_unittest.cc @@ -894,4 +894,4 @@ TEST(FileDeathTest, InvalidFlags) { }, "FLAG_WIN_NO_EXECUTE"); } -#endif // BUILDFLAG(IS_WIN) +#endif // BUILDFLAG(IS_WIN) \ No newline at end of file diff --git a/base/files/file_util.h b/base/files/file_util.h index de3c1737fd44..c47f00265f41 100644 --- a/base/files/file_util.h +++ b/base/files/file_util.h @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc index e0e11b661224..f769fe99e31b 100644 --- a/base/files/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -4018,7 +4018,7 @@ TEST_F(FileUtilTest, ReadStreamToString_ZeroLengthFile) { EXPECT_EQ(contents, random_data); } } -#endif // BUILDFLAG(IS_POSIX) +#endif TEST_F(FileUtilTest, ReadStreamToStringWithMaxSize) { ScopedFILE stream( diff --git a/base/functional/callback_tags.h b/base/functional/callback_tags.h index 98f1d994cda1..e359a547d320 100644 --- a/base/functional/callback_tags.h +++ b/base/functional/callback_tags.h @@ -24,7 +24,7 @@ struct DoNothingCallbackTag { struct WithBoundArguments { std::tuple bound_args; - constexpr explicit WithBoundArguments(BoundArgs&&... args) + constexpr explicit WithBoundArguments(BoundArgs... args) : bound_args(std::forward(args)...) {} }; }; diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc index 98969183eb90..376012e189e4 100644 --- a/base/i18n/time_formatting.cc +++ b/base/i18n/time_formatting.cc @@ -260,7 +260,11 @@ std::u16string DateIntervalFormat(const Time& begin_time, UErrorCode status = U_ZERO_ERROR; std::unique_ptr formatter( +#if defined(USE_HACKY_COBALT_CHANGES) icu::DateIntervalFormat::createInstance(icu::UnicodeString(DateFormatToString(format)), +#else + icu::DateIntervalFormat::createInstance(DateFormatToString(format), +#endif status)); icu::FieldPosition pos = 0; diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc index 9fa0c7edb000..d1853f853f18 100644 --- a/base/metrics/field_trial.cc +++ b/base/metrics/field_trial.cc @@ -1046,6 +1046,7 @@ FieldTrialList* FieldTrialList::BackupInstanceForTesting() { void FieldTrialList::RestoreInstanceForTesting(FieldTrialList* instance) { global_ = instance; } + #ifdef COBALT_PENDING_CLEAN_UP // TODO(b/298237462): Try to enable the below code. #elif !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) diff --git a/base/metrics/histogram_macros_local.h b/base/metrics/histogram_macros_local.h index 6a574f7f5f7f..2a2f29f9c290 100644 --- a/base/metrics/histogram_macros_local.h +++ b/base/metrics/histogram_macros_local.h @@ -16,6 +16,7 @@ // Enumeration histograms. // // For usage details, see the equivalents in histogram_macros.h. + #define CR_GET_ARG(arg) arg #define LOCAL_HISTOGRAM_ENUMERATION(name, ...) \ CR_GET_ARG(INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \ diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc index 13a847e41d54..c4976fd425e4 100644 --- a/base/metrics/persistent_memory_allocator.cc +++ b/base/metrics/persistent_memory_allocator.cc @@ -5,7 +5,6 @@ #include "base/metrics/persistent_memory_allocator.h" #include -#include #include @@ -1036,7 +1035,6 @@ void LocalPersistentMemoryAllocator::DeallocateLocalMemory(void* memory, } DCHECK_EQ(MEM_VIRTUAL, type); - #if defined(STARBOARD) #elif BUILDFLAG(IS_WIN) BOOL success = ::VirtualFree(memory, 0, MEM_DECOMMIT); @@ -1075,8 +1073,8 @@ bool WritableSharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( } #endif // !defined(STARBOARD) - //----- ReadOnlySharedPersistentMemoryAllocator -------------------------------- + #if !defined(STARBOARD) ReadOnlySharedPersistentMemoryAllocator:: ReadOnlySharedPersistentMemoryAllocator( @@ -1100,7 +1098,6 @@ bool ReadOnlySharedPersistentMemoryAllocator::IsSharedMemoryAcceptable( const base::ReadOnlySharedMemoryMapping& memory) { return IsMemoryAcceptable(memory.memory(), memory.size(), 0, true); } - #endif // !defined(STARBOARD) #if !BUILDFLAG(IS_NACL) diff --git a/base/metrics/persistent_memory_allocator.h b/base/metrics/persistent_memory_allocator.h index 7572e04cc26c..f3e94cf78789 100644 --- a/base/metrics/persistent_memory_allocator.h +++ b/base/metrics/persistent_memory_allocator.h @@ -743,6 +743,7 @@ class BASE_EXPORT LocalPersistentMemoryAllocator static void DeallocateLocalMemory(void* memory, size_t size, MemoryType type); }; + #if !defined(STARBOARD) // This allocator takes a writable shared memory mapping object and performs // allocation from it. The allocator takes ownership of the mapping object. @@ -799,7 +800,6 @@ class BASE_EXPORT ReadOnlySharedPersistentMemoryAllocator private: base::ReadOnlySharedMemoryMapping shared_memory_; }; - #endif // !defined(STARBOARD) // NACL doesn't support any kind of file access in build. diff --git a/base/metrics/persistent_memory_allocator_unittest.cc b/base/metrics/persistent_memory_allocator_unittest.cc index 482238906e24..4d66a1c200af 100644 --- a/base/metrics/persistent_memory_allocator_unittest.cc +++ b/base/metrics/persistent_memory_allocator_unittest.cc @@ -723,7 +723,6 @@ TEST(SharedPersistentMemoryAllocatorTest, CreationTest) { EXPECT_EQ(0, data[2]); EXPECT_EQ(0, data[3]); } - #endif // !defined(STARBOARD) // TODO: b/316198056 - Re-enable this test once base/net have been updated. diff --git a/base/path_service.cc b/base/path_service.cc index e0ec4b1fa017..050f8caf0125 100644 --- a/base/path_service.cc +++ b/base/path_service.cc @@ -206,14 +206,15 @@ bool PathService::Get(int key, FilePath* result) { DCHECK_GT(key, PATH_START); // Special case the current directory because it can never be cached. - if (key == DIR_CURRENT) { + if (key == DIR_CURRENT) #if defined(STARBOARD) + { NOTREACHED() << "DIR_CURRENT not supported in Starboard."; return false; + } #else return GetCurrentDirectory(result); #endif - } Provider* provider = nullptr; { diff --git a/base/process/process_starboard.cc b/base/process/process_starboard.cc index b9275534b84b..709ad047474b 100644 --- a/base/process/process_starboard.cc +++ b/base/process/process_starboard.cc @@ -16,23 +16,20 @@ #include "base/process/process.h" #include "base/process/process_handle.h" - -namespace { -base::ProcessId kStarboardFakeProcessId = 1; -} +#include "starboard/common/process.h" namespace base { ProcessId GetProcId(ProcessHandle) { - return kStarboardFakeProcessId; + return starboard::kStarboardFakeProcessId; } ProcessId GetParentProcessId(ProcessHandle) { - return kStarboardFakeProcessId; + return starboard::kStarboardFakeProcessId; } ProcessId GetCurrentProcId() { - return kStarboardFakeProcessId; + return starboard::kStarboardFakeProcessId; } ProcessHandle GetCurrentProcessHandle() { diff --git a/base/profiler/stack_copier_suspend_unittest.cc b/base/profiler/stack_copier_suspend_unittest.cc index 825241506634..e51e57dffc54 100644 --- a/base/profiler/stack_copier_suspend_unittest.cc +++ b/base/profiler/stack_copier_suspend_unittest.cc @@ -64,6 +64,9 @@ class TestSuspendableThreadDelegate : public SuspendableThreadDelegate { RegisterContextStackPointer(thread_context) = reinterpret_cast(&(*fake_stack_)[0]); RegisterContextInstructionPointer(thread_context) = +/* Cobalt + reinterpret_cast((*fake_stack_)[0]); +Cobalt */ static_cast((*fake_stack_)[0]); return true; } diff --git a/base/security_unittest.cc b/base/security_unittest.cc index c35c1ab770f8..6faad637362b 100644 --- a/base/security_unittest.cc +++ b/base/security_unittest.cc @@ -64,8 +64,8 @@ void OverflowTestsSoftExpectTrue(bool overflow_detected) { } } -#if BUILDFLAG(IS_APPLE) || defined(ADDRESS_SANITIZER) || \ - defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ +#if BUILDFLAG(IS_APPLE) || defined(ADDRESS_SANITIZER) || \ + defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ BUILDFLAG(IS_HWASAN) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \ SB_IS(EVERGREEN) #define MAYBE_NewOverflow DISABLED_NewOverflow diff --git a/base/sequence_token.cc b/base/sequence_token.cc index 72ad382069da..b0a003f29268 100644 --- a/base/sequence_token.cc +++ b/base/sequence_token.cc @@ -198,8 +198,7 @@ ScopedSetSequenceTokenForCurrentThread::ScopedSetSequenceTokenForCurrentThread( task_token_resetter_(¤t_task_token, [] { DCHECK(!current_task_token.IsValid()); return TaskToken::Create(); - }()) { -} + }()) {} #endif #if defined(STARBOARD) diff --git a/base/system/sys_info_unittest.cc b/base/system/sys_info_unittest.cc index b0fab7779080..1f8cbbc747bb 100644 --- a/base/system/sys_info_unittest.cc +++ b/base/system/sys_info_unittest.cc @@ -270,7 +270,7 @@ TEST_F(SysInfoTest, GetHardwareInfo) { #if defined(STARBOARD) true; #elif BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_WIN) || \ - BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) \ + BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) false; #else true; diff --git a/base/task/scoped_set_task_priority_for_current_thread.cc b/base/task/scoped_set_task_priority_for_current_thread.cc index 4d21e6c09d86..c52d561ef8b7 100644 --- a/base/task/scoped_set_task_priority_for_current_thread.cc +++ b/base/task/scoped_set_task_priority_for_current_thread.cc @@ -74,8 +74,7 @@ ScopedSetTaskPriorityForCurrentThread::ScopedSetTaskPriorityForCurrentThread( #else : resetter_(&task_priority_for_current_thread, priority, - TaskPriority::USER_BLOCKING) { -} + TaskPriority::USER_BLOCKING) {} #endif #if defined(STARBOARD) diff --git a/base/task/sequence_manager/hierarchical_timing_wheel.h b/base/task/sequence_manager/hierarchical_timing_wheel.h index e92b120211d3..9a1504bf71da 100644 --- a/base/task/sequence_manager/hierarchical_timing_wheel.h +++ b/base/task/sequence_manager/hierarchical_timing_wheel.h @@ -350,6 +350,9 @@ class HierarchicalTimingWheel { private: bool IsHeap(size_t hierarchy_index) { +/* Cobalt + return hierarchy_index == 0 or hierarchy_index == TotalWheels + 1; +Cobalt */ return hierarchy_index == 0 || hierarchy_index == TotalWheels + 1; } diff --git a/base/task/sequence_manager/sequence_manager_impl.cc b/base/task/sequence_manager/sequence_manager_impl.cc index 7dfebafb3c99..15b96bde3bcc 100644 --- a/base/task/sequence_manager/sequence_manager_impl.cc +++ b/base/task/sequence_manager/sequence_manager_impl.cc @@ -367,7 +367,7 @@ void SequenceManagerImpl::BindToMessagePump(std::unique_ptr pump) { } #endif - // On iOS and Starboard attach to the native loop when there is one. + // On iOS attach to the native loop when there is one. #if BUILDFLAG(IS_IOS) || defined(STARBOARD) if (settings_.message_loop_type == MessagePumpType::UI) { controller_->AttachToMessagePump(); diff --git a/base/task/thread_pool/task_tracker.cc b/base/task/thread_pool/task_tracker.cc index 91e494b146b6..de4b05989722 100644 --- a/base/task/thread_pool/task_tracker.cc +++ b/base/task/thread_pool/task_tracker.cc @@ -340,11 +340,10 @@ bool TaskTracker::WillPostTask(Task* task, // A non BLOCK_SHUTDOWN task is allowed to be posted iff shutdown hasn't // started and the task is not delayed. if (shutdown_behavior != TaskShutdownBehavior::BLOCK_SHUTDOWN || - !task->delayed_run_time.is_null() || #if defined(STARBOARD) - GetFizzleBlockShutdownTasks()) { + !task->delayed_run_time.is_null() || GetFizzleBlockShutdownTasks()) { #else - fizzle_block_shutdown_tasks) { + !task->delayed_run_time.is_null() || fizzle_block_shutdown_tasks) { #endif return false; } diff --git a/base/task/thread_pool/test_utils.cc b/base/task/thread_pool/test_utils.cc index 7ef28bab96dd..e163e750f28b 100644 --- a/base/task/thread_pool/test_utils.cc +++ b/base/task/thread_pool/test_utils.cc @@ -265,12 +265,24 @@ MockJobTask::~MockJobTask() = default; MockJobTask::MockJobTask( base::RepeatingCallback worker_task, size_t num_tasks_to_run) +/* Cobalt + : worker_task_(std::move(worker_task)), + remaining_num_tasks_to_run_(num_tasks_to_run) {} +Cobalt */ : task_(std::move(worker_task)), remaining_num_tasks_to_run_(num_tasks_to_run) { CHECK(!absl::get(task_).is_null()); } MockJobTask::MockJobTask(base::OnceClosure worker_task) +/* Cobalt + : worker_task_(base::BindRepeating( + [](base::OnceClosure&& worker_task, JobDelegate*) mutable { + std::move(worker_task).Run(); + }, + base::Passed(std::move(worker_task)))), + remaining_num_tasks_to_run_(1) {} +Cobalt */ : task_(std::move(worker_task)), remaining_num_tasks_to_run_(1) { CHECK(!absl::get(task_).is_null()); } @@ -298,6 +310,11 @@ size_t MockJobTask::GetMaxConcurrency(size_t /* worker_count */) const { } void MockJobTask::Run(JobDelegate* delegate) { +/* Cobalt + worker_task_.Run(delegate); + size_t before = remaining_num_tasks_to_run_.fetch_sub(1); + DCHECK_GT(before, 0U); +Cobalt */ absl::visit( base::Overloaded{ [](OnceClosure& closure) { std::move(closure).Run(); }, diff --git a/base/task/thread_pool/test_utils.h b/base/task/thread_pool/test_utils.h index 49f75213deb0..7437835ba317 100644 --- a/base/task/thread_pool/test_utils.h +++ b/base/task/thread_pool/test_utils.h @@ -98,6 +98,11 @@ class MockJobTask : public base::RefCountedThreadSafe { // Updates the remaining number of time |worker_task| runs to // |num_tasks_to_run|. +/* Cobalt + void SetNumTasksToRun(size_t num_tasks_to_run) { + remaining_num_tasks_to_run_ = num_tasks_to_run; + } +Cobalt */ void SetNumTasksToRun(size_t num_tasks_to_run); size_t GetMaxConcurrency(size_t worker_count) const; @@ -113,6 +118,9 @@ class MockJobTask : public base::RefCountedThreadSafe { ~MockJobTask(); +/* Cobalt + base::RepeatingCallback worker_task_; +Cobalt */ absl::variant> task_; std::atomic_size_t remaining_num_tasks_to_run_; }; diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn index 70323e405994..9130082a9a5b 100644 --- a/base/test/BUILD.gn +++ b/base/test/BUILD.gn @@ -413,8 +413,6 @@ shared_library("immediate_crash_test_helper") { if (!use_cobalt_customizations) { # This shared library is dynamically loaded by NativeLibrary unittests. shared_library("test_shared_library") { - install_target = false - build_loader = false testonly = true sources = [ "test_shared_library.cc" ] diff --git a/base/test/run_all_unittests.cc b/base/test/run_all_unittests.cc index e9ef642942b6..c3aa04995d6a 100644 --- a/base/test/run_all_unittests.cc +++ b/base/test/run_all_unittests.cc @@ -11,11 +11,13 @@ #if defined(STARBOARD) +#include "base/test/allow_check_is_test_for_testing.h" #include "starboard/client_porting/wrap_main/wrap_main.h" int TestSuiteRun(int argc, char** argv) { base::AtExitManager exit_manager; + base::test::AllowCheckIsTestForTesting(); return base::TestSuite(argc, argv).Run(); } diff --git a/base/third_party/double_conversion/LICENSE b/base/third_party/double_conversion/LICENSE new file mode 100644 index 000000000000..933718a9ef9d --- /dev/null +++ b/base/third_party/double_conversion/LICENSE @@ -0,0 +1,26 @@ +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/base/third_party/symbolize/LICENSE b/base/third_party/symbolize/LICENSE new file mode 100644 index 000000000000..433a3d1512c7 --- /dev/null +++ b/base/third_party/symbolize/LICENSE @@ -0,0 +1,28 @@ +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/base/time/time_now_starboard.cc b/base/time/time_now_starboard.cc index 2339fd362f09..6c6fd1023c59 100644 --- a/base/time/time_now_starboard.cc +++ b/base/time/time_now_starboard.cc @@ -19,7 +19,6 @@ #include "base/time/time_override.h" #include "build/build_config.h" -#include "starboard/common/log.h" #include "starboard/common/time.h" #include "starboard/types.h" diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc index d1d190fcbf2b..7bc6b8861700 100644 --- a/base/time/time_unittest.cc +++ b/base/time/time_unittest.cc @@ -5,7 +5,6 @@ #include "base/time/time.h" #include - #include #include @@ -15,6 +14,7 @@ #include "base/check_op.h" #include "base/compiler_specific.h" #include "base/environment.h" +#include "base/logging.h" #include "base/test/gtest_util.h" #include "base/threading/platform_thread.h" #include "base/time/time_override.h" @@ -1047,6 +1047,7 @@ TEST_F(TimeTest, Explode_Y10KCompliance) { // A very long time ago. {Time::Min(), Time::Exploded{-290677, 12, 4, 23, 19, 59, 5, 224}}, #endif + // Before/On/After 1 Jan 1601. {make_time(-kHalfYearInMicros), Time::Exploded{1600, 7, 1, 3, 0, 0, 0, 0}}, @@ -1092,6 +1093,7 @@ TEST_F(TimeTest, Explode_Y10KCompliance) { Time::Exploded{287396, 10, 3, 12, 8, 59, 0, 992}}, {make_time(kIcuMaxMicrosOffset + kHalfYearInMicros), Time::Exploded{287397, 4, 3, 12, 8, 59, 0, 992}}, + #if !defined(STARBOARD) // A very long time from now. {Time::Max(), Time::Exploded{293878, 1, 4, 10, 4, 0, 54, 775}}, @@ -1486,7 +1488,7 @@ ThreadTicks ThreadTicksOverride::now_ticks_; #endif TEST(ThreadTicks, MAYBE_NowOverride) { if (starboard::CurrentMonotonicThreadTime() == 0) { - SB_LOG(INFO) << "Time thread now not supported. Test skipped."; + LOG(INFO) << "Time thread now not supported. Test skipped."; return; } diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc index 5eb56ce6abf6..762e0d4ff1fb 100644 --- a/base/trace_event/trace_log.cc +++ b/base/trace_event/trace_log.cc @@ -98,11 +98,11 @@ const size_t kTraceEventVectorBigBufferChunks = 512000000 / kTraceBufferChunkSize; static_assert( kTraceEventVectorBigBufferChunks <= TraceBufferChunk::kMaxChunkIndex, - "Too many big buffer chunks"); + "Too many big buffer chunks"); const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; static_assert( kTraceEventVectorBufferChunks <= TraceBufferChunk::kMaxChunkIndex, - "Too many vector buffer chunks"); + "Too many vector buffer chunks"); const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. @@ -1671,9 +1671,9 @@ bool TraceLog::ShouldAddAfterUpdatingState( if (!*category_group_enabled) return false; - // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when - // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> - // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... + // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when + // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> + // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... #if defined(STARBOARD) bool thread_is_in_trace_event = GetThreadIsInTraceEvent(); #endif @@ -2034,9 +2034,9 @@ void TraceLog::UpdateTraceEventDurationExplicit( if (!*category_group_enabled) return; - // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when - // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> - // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... + // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when + // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> + // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... #if defined(STARBOARD) bool thread_is_in_trace_event = GetThreadIsInTraceEvent(); #endif diff --git a/base/values.h b/base/values.h index ed29743a0234..c8a30d63eeff 100644 --- a/base/values.h +++ b/base/values.h @@ -432,6 +432,9 @@ class BASE_EXPORT GSL_OWNER Value { Value* Set(StringPiece key, Value&& value) &; Value* Set(StringPiece key, bool value) &; template +/* Cobalt + Value* Set(StringPiece, const T*) = delete; +Cobalt */ Value* Set(StringPiece, const T*) & = delete; Value* Set(StringPiece key, int value) &; Value* Set(StringPiece key, double value) &; @@ -668,6 +671,9 @@ class BASE_EXPORT GSL_OWNER Value { void Append(Value&& value) &; void Append(bool value) &; template +/* Cobalt + void Append(const T*) = delete; +Cobalt */ void Append(const T*) & = delete; void Append(int value) &; void Append(double value) &; diff --git a/cobalt/audio/audio_destination_node.cc b/cobalt/audio/audio_destination_node.cc index 9c1c5fa1eee1..24cc4211c639 100644 --- a/cobalt/audio/audio_destination_node.cc +++ b/cobalt/audio/audio_destination_node.cc @@ -14,6 +14,7 @@ #include "cobalt/audio/audio_destination_node.h" +#include "base/logging.h" #include "cobalt/audio/audio_context.h" namespace cobalt { @@ -59,7 +60,7 @@ void AudioDestinationNode::OnInputNodeConnected() { if (!audio_device_) { audio_device_.reset( new AudioDevice(static_cast(channel_count(NULL)), this)); - SB_LOG(INFO) << "Created audio device " << audio_device_.get() << '.'; + LOG(INFO) << "Created audio device " << audio_device_.get() << '.'; context()->PreventGarbageCollection(); } delete_audio_device_ = false; @@ -79,8 +80,8 @@ void AudioDestinationNode::FillAudioBus(bool all_consumed, AudioBus* audio_bus, bool all_finished = true; Input(0)->FillAudioBus(audio_bus, silence, &all_finished); if (all_consumed && all_finished) { - SB_LOG(INFO) << "Schedule to destroy audio device " << audio_device_.get() - << '.'; + LOG(INFO) << "Schedule to destroy audio device " << audio_device_.get() + << '.'; delete_audio_device_ = true; task_runner_->PostTask(FROM_HERE, base::Bind(&AudioDestinationNode::DestroyAudioDevice, @@ -94,7 +95,7 @@ void AudioDestinationNode::DestroyAudioDevice() { return; } if (delete_audio_device_) { - SB_LOG(INFO) << "Destroying audio device " << audio_device_.get() << '.'; + LOG(INFO) << "Destroying audio device " << audio_device_.get() << '.'; audio_device_.reset(); context()->AllowGarbageCollection(); delete_audio_device_ = false; diff --git a/cobalt/audio/audio_file_reader_wav.cc b/cobalt/audio/audio_file_reader_wav.cc index ea8aa97f3e76..d5534cbff587 100644 --- a/cobalt/audio/audio_file_reader_wav.cc +++ b/cobalt/audio/audio_file_reader_wav.cc @@ -213,12 +213,12 @@ void AudioFileReaderWAV::ParseWAV_data(const uint8* data, size_t offset, #if SB_IS(LITTLE_ENDIAN) if ((!is_src_sample_in_float && sample_type_ == kSampleTypeInt16) || (is_src_sample_in_float && sample_type_ == kSampleTypeFloat32)) { - SB_LOG(INFO) << "Copying " << size << " bytes of wav data."; + LOG(INFO) << "Copying " << size << " bytes of wav data."; memcpy(audio_bus_->interleaved_data(), data + offset, size); } else if (!is_src_sample_in_float && sample_type_ == kSampleTypeFloat32) { // Convert from int16 to float32 - SB_LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ - << " samples from int16 to float32."; + LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ + << " samples from int16 to float32."; const int16* src_samples = reinterpret_cast(data + offset); float* dest_samples = reinterpret_cast(audio_bus_->interleaved_data()); @@ -230,8 +230,8 @@ void AudioFileReaderWAV::ParseWAV_data(const uint8* data, size_t offset, } } else { // Convert from float32 to int16 - SB_LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ - << " samples from float32 to int16."; + LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ + << " samples from float32 to int16."; const float* src_samples = reinterpret_cast(data + offset); int16* dest_samples = reinterpret_cast(audio_bus_->interleaved_data()); @@ -244,8 +244,8 @@ void AudioFileReaderWAV::ParseWAV_data(const uint8* data, size_t offset, } #else // SB_IS(LITTLE_ENDIAN) if (!is_src_sample_in_float && sample_type_ == kSampleTypeInt16) { - SB_LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ - << " int16 samples from little endian to big endian."; + LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ + << " int16 samples from little endian to big endian."; const uint8_t* src_samples = data + offset; int16* dest_samples = reinterpret_cast(audio_bus_->interleaved_data()); @@ -255,8 +255,8 @@ void AudioFileReaderWAV::ParseWAV_data(const uint8* data, size_t offset, ++dest_samples; } } else if (is_src_sample_in_float && sample_type_ == kSampleTypeFloat32) { - SB_LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ - << " float32 samples from little endian to big endian."; + LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ + << " float32 samples from little endian to big endian."; const uint8_t* src_samples = data + offset; float* dest_samples = reinterpret_cast(audio_bus_->interleaved_data()); @@ -268,8 +268,8 @@ void AudioFileReaderWAV::ParseWAV_data(const uint8* data, size_t offset, } } else if (!is_src_sample_in_float && sample_type_ == kSampleTypeFloat32) { // Convert from int16 to float32 - SB_LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ - << " int16 samples in little endian to float32 in big endian."; + LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ + << " int16 samples in little endian to float32 in big endian."; const uint8_t* src_samples = data + offset; float* dest_samples = reinterpret_cast(audio_bus_->interleaved_data()); @@ -281,8 +281,8 @@ void AudioFileReaderWAV::ParseWAV_data(const uint8* data, size_t offset, } } else { // Convert from float32 to int16 - SB_LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ - << " float32 samples in little endian to int16 in big endian."; + LOG(INFO) << "Converting " << number_of_frames_ * number_of_channels_ + << " float32 samples in little endian to int16 in big endian."; const uint8_t* src_samples = data + offset; int16* dest_samples = reinterpret_cast(audio_bus_->interleaved_data()); diff --git a/cobalt/base/BUILD.gn b/cobalt/base/BUILD.gn index 28f956e3c916..8395cf012d65 100644 --- a/cobalt/base/BUILD.gn +++ b/cobalt/base/BUILD.gn @@ -127,8 +127,5 @@ target(gtest_target_type, "base_test") { "//testing/gmock", "//testing/gtest", ] - data_deps = [ - "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", - ] + data_deps = [ "//cobalt/network:copy_ssl_certificates" ] } diff --git a/cobalt/base/localized_strings.cc b/cobalt/base/localized_strings.cc index 05b41e06ad51..c07abb3911b1 100644 --- a/cobalt/base/localized_strings.cc +++ b/cobalt/base/localized_strings.cc @@ -21,7 +21,6 @@ #include "base/logging.h" #include "base/optional.h" #include "starboard/common/file.h" -#include "starboard/common/log.h" #include "starboard/system.h" #include "starboard/types.h" @@ -114,7 +113,7 @@ bool LocalizedStrings::LoadSingleString(const std::string& message) { // A single message is a key/value pair with separator. size_t separator_pos = message.find(';'); if (separator_pos == std::string::npos) { - SB_DLOG(ERROR) << "No separator found in: " << message; + DLOG(ERROR) << "No separator found in: " << message; return false; } diff --git a/cobalt/base/log_message_handler.cc b/cobalt/base/log_message_handler.cc index 64a942ec60b1..5cd0c5c17d40 100644 --- a/cobalt/base/log_message_handler.cc +++ b/cobalt/base/log_message_handler.cc @@ -14,9 +14,8 @@ #include "cobalt/base/log_message_handler.h" -#include - #include "base/threading/thread_restrictions.h" +#include "starboard/thread.h" namespace base { @@ -68,14 +67,14 @@ bool LogMessageHandler::OnLogMessage(int severity, const char* file, int line, } // Ignore recursive calls. - static pthread_t logging_thread = 0; - if (pthread_equal(logging_thread, pthread_self())) { + static SbThreadId logging_thread = kSbThreadInvalidId; + if (logging_thread == SbThreadGetId()) { return false; } LogMessageHandler* instance = GetInstance(); AutoLock auto_lock(instance->lock_); - logging_thread = pthread_self(); + logging_thread = SbThreadGetId(); bool suppress = instance->suppress_log_output_; for (CallbackMap::const_iterator it = instance->callbacks_.begin(); @@ -85,7 +84,7 @@ bool LogMessageHandler::OnLogMessage(int severity, const char* file, int line, } } - logging_thread = 0; + logging_thread = kSbThreadInvalidId; return suppress; } diff --git a/cobalt/bindings/testing/date_bindings_test.cc b/cobalt/bindings/testing/date_bindings_test.cc index 00048e2743ee..86683eedfdf1 100644 --- a/cobalt/bindings/testing/date_bindings_test.cc +++ b/cobalt/bindings/testing/date_bindings_test.cc @@ -17,7 +17,6 @@ #include "cobalt/bindings/testing/bindings_test_base.h" #include "cobalt/bindings/testing/interface_with_date.h" #include "starboard/client_porting/eztime/eztime.h" -#include "starboard/common/time.h" #include "starboard/time_zone.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -79,7 +78,7 @@ TEST_F(DateBindingsTest, PosixEpoch) { EvaluateScript("Date.now();", &result); auto js_now_ms = std::stoll(result); auto posix_now_ms = - starboard::CurrentPosixTime() / base::Time::kMicrosecondsPerMillisecond; + (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds(); EXPECT_LT(std::abs(posix_now_ms - js_now_ms), 1000); } @@ -91,8 +90,8 @@ TEST_F(DateBindingsTest, StarboardTimeZone) { EvaluateScript("new Date().toString();", &result); base::Time now = base::Time::Now(); - SB_LOG(INFO) << "JavaScript Date now is : " << result; - SB_LOG(INFO) << "and base::Time is: " << now; + LOG(INFO) << "JavaScript Date now is : " << result; + LOG(INFO) << "and base::Time is: " << now; base::Time::Exploded exploded; now.LocalExplode(&exploded); @@ -106,8 +105,8 @@ TEST_F(DateBindingsTest, StarboardTimeZone) { } TEST_F(DateBindingsTest, TimezoneOffset) { - EzTimeT ezttnow = static_cast(starboard::CurrentPosixTime() / - base::Time::kMicrosecondsPerSecond); + EzTimeT ezttnow = static_cast( + (base::Time::Now() - base::Time::UnixEpoch()).InSeconds()); EzTimeExploded ez_exploded_local; EzTimeTExplodeLocal(&ezttnow, &ez_exploded_local); // ez_exploded_local is already local time, use UTC method to convert to diff --git a/cobalt/black_box_tests/black_box_tests.py b/cobalt/black_box_tests/black_box_tests.py index 5e2843e81fdc..2b77b4d48ba2 100755 --- a/cobalt/black_box_tests/black_box_tests.py +++ b/cobalt/black_box_tests/black_box_tests.py @@ -69,7 +69,8 @@ 'default_site_can_load', 'disable_eval_with_csp', 'h5vcc_storage_write_verify_test', - 'h5vcc_watchdog_api_test', + # TODO(b/346882263): Disabled, it's suddenly flaky + # 'h5vcc_watchdog_api_test', 'http_cache', 'javascript_profiler', 'persistent_cookie', @@ -250,8 +251,11 @@ def __init__(self, args): self.proxy_port = args.proxy_port or str( self.GetUnusedPort([_server_binding_address])) proxy_address = args.proxy_address or _server_binding_address - _launcher_params.target_params.append( - f'--proxy={proxy_address}:{self.proxy_port}') + proxy_url = f'{proxy_address}:{self.proxy_port}' + _launcher_params.target_params.append(f'--proxy={proxy_url}') + + _launcher_params.target_params.append( + '--unsafely-treat-insecure-origin-as-secure=*web-platform.test') self.device_ips = args.device_ips diff --git a/cobalt/browser/BUILD.gn b/cobalt/browser/BUILD.gn index ce25455a9f47..8453de994bd8 100644 --- a/cobalt/browser/BUILD.gn +++ b/cobalt/browser/BUILD.gn @@ -58,10 +58,7 @@ target(final_executable_type, "cobalt") { "//cobalt/css_parser", "//net", ] - data_deps = [ - "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", - ] + data_deps = [ "//cobalt/network:copy_ssl_certificates" ] if (cobalt_font_package == "empty") { data_deps += [ "//cobalt/content/fonts:copy_font_data" ] } else { diff --git a/cobalt/browser/application.cc b/cobalt/browser/application.cc index 367d239ff367..40e462781979 100644 --- a/cobalt/browser/application.cc +++ b/cobalt/browser/application.cc @@ -1517,10 +1517,18 @@ void Application::InitMetrics() { metrics::CobaltMetricsServicesManager::GetInstance(); // Before initializing metrics manager, set any persisted settings like if // it's enabled or upload interval. - bool is_metrics_enabled = persistent_settings_->GetPersistentSettingAsBool( - metrics::kMetricEnabledSettingName, false); - auto metric_event_interval = persistent_settings_->GetPersistentSettingAsInt( - metrics::kMetricEventIntervalSettingName, 300); + bool is_metrics_enabled; + { + base::Value value; + persistent_settings_->Get(metrics::kMetricEnabledSettingName, &value); + is_metrics_enabled = value.GetIfBool().value_or(false); + } + int metric_event_interval; + { + base::Value value; + persistent_settings_->Get(metrics::kMetricEventIntervalSettingName, &value); + metric_event_interval = value.GetIfInt().value_or(300); + } metrics_services_manager_->SetEventDispatcher(&event_dispatcher_); metrics_services_manager_->SetUploadInterval(metric_event_interval); metrics_services_manager_->ToggleMetricsEnabled(is_metrics_enabled); diff --git a/cobalt/browser/browser_module.cc b/cobalt/browser/browser_module.cc index 5e5c7da3cdfc..85823a5f5c6e 100644 --- a/cobalt/browser/browser_module.cc +++ b/cobalt/browser/browser_module.cc @@ -60,8 +60,6 @@ #include "cobalt/web/csp_delegate_factory.h" #include "cobalt/web/navigator_ua_data.h" #include "starboard/atomic.h" -#include "starboard/common/string.h" -#include "starboard/common/time.h" #include "starboard/configuration.h" #include "starboard/extension/graphics.h" #include "starboard/system.h" @@ -89,7 +87,7 @@ NonTrivialGlobalVariables::NonTrivialGlobalVariables() { SbAtomicNoBarrier_Exchange64( last_render_timestamp, static_cast( - starboard::PosixTimeToWindowsTime(starboard::CurrentPosixTime()))); + base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds(); } base::LazyInstance::DestructorAtExit @@ -793,7 +791,7 @@ void BrowserModule::OnLoad() { web_module_loaded_.Signal(); - options_.persistent_settings->ValidatePersistentSettings(); + options_.persistent_settings->Validate(); ValidateCacheBackendSettings(); } @@ -1714,7 +1712,7 @@ void BrowserModule::OnPollForRenderTimeout(const GURL& url) { kRenderTimeoutErrorPercentage * (UINT64_MAX / 100)) { OnError(url, std::string("Rendering Timeout")); } else { - SB_DLOG(INFO) << "Received OnRenderTimeout, ignoring by random chance."; + DLOG(INFO) << "Received OnRenderTimeout, ignoring by random chance."; } } else { timeout_polling_thread_.task_runner()->PostDelayedTask( diff --git a/cobalt/browser/loader_app_metrics.cc b/cobalt/browser/loader_app_metrics.cc index fcff39305fe6..cee78353f713 100644 --- a/cobalt/browser/loader_app_metrics.cc +++ b/cobalt/browser/loader_app_metrics.cc @@ -103,6 +103,13 @@ void RecordLoaderAppMetrics( RecordLoaderAppTimeMetrics(metrics_extension); RecordLoaderAppSpaceMetrics(metrics_extension); } + if (metrics_extension->version >= 3) { + base::UmaHistogramEnumeration( + "Cobalt.LoaderApp.SlotSelectionStatus", + metrics_extension->GetSlotSelectionStatus()); + LOG(INFO) << "Recorded sample for " + << "Cobalt.LoaderApp.SlotSelectionStatus"; + } } } diff --git a/cobalt/browser/memory_settings/calculations_test.cc b/cobalt/browser/memory_settings/calculations_test.cc index 502321e19352..f5e978455c6b 100644 --- a/cobalt/browser/memory_settings/calculations_test.cc +++ b/cobalt/browser/memory_settings/calculations_test.cc @@ -21,7 +21,6 @@ #include "cobalt/browser/memory_settings/constants.h" #include "cobalt/browser/memory_settings/test_common.h" #include "cobalt/browser/switches.h" -#include "starboard/common/log.h" #include "starboard/memory.h" #include "starboard/system.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/cobalt/browser/memory_settings/pretty_print.cc b/cobalt/browser/memory_settings/pretty_print.cc index 1f657e954e5a..cc3ce9836819 100644 --- a/cobalt/browser/memory_settings/pretty_print.cc +++ b/cobalt/browser/memory_settings/pretty_print.cc @@ -23,8 +23,6 @@ #include "base/strings/string_split.h" #include "cobalt/browser/memory_settings/memory_settings.h" #include "cobalt/browser/memory_settings/table_printer.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" namespace cobalt { namespace browser { diff --git a/cobalt/browser/memory_settings/pretty_print_test.cc b/cobalt/browser/memory_settings/pretty_print_test.cc index d8bba3c0da3d..61630fa80de3 100644 --- a/cobalt/browser/memory_settings/pretty_print_test.cc +++ b/cobalt/browser/memory_settings/pretty_print_test.cc @@ -23,10 +23,10 @@ #include #include "base/command_line.h" +#include "base/logging.h" #include "cobalt/browser/memory_settings/memory_settings.h" #include "cobalt/browser/memory_settings/test_common.h" #include "cobalt/browser/switches.h" -#include "starboard/common/log.h" #include "starboard/memory.h" #include "starboard/string.h" #include "starboard/system.h" @@ -46,7 +46,7 @@ bool HasTokensInOrder(const std::string& value, EXPECT_NE(position, std::string::npos); EXPECT_GE(position, current_position); if (position == std::string::npos) { - SB_DLOG(INFO) << "Token \"" << token << "\" not found in order."; + DLOG(INFO) << "Token \"" << token << "\" not found in order."; return false; } current_position = position + strlen(token); diff --git a/cobalt/browser/memory_settings/table_printer.cc b/cobalt/browser/memory_settings/table_printer.cc index 70276e511e99..fa5ebff0004f 100644 --- a/cobalt/browser/memory_settings/table_printer.cc +++ b/cobalt/browser/memory_settings/table_printer.cc @@ -22,7 +22,6 @@ #include #include "base/logging.h" -#include "starboard/common/log.h" namespace cobalt { namespace browser { diff --git a/cobalt/browser/memory_settings/table_printer_test.cc b/cobalt/browser/memory_settings/table_printer_test.cc index 8c01b4dccaa4..d31349603ca4 100644 --- a/cobalt/browser/memory_settings/table_printer_test.cc +++ b/cobalt/browser/memory_settings/table_printer_test.cc @@ -16,7 +16,7 @@ #include "cobalt/browser/memory_settings/table_printer.h" -#include "starboard/common/log.h" +#include "base/logging.h" #include "starboard/string.h" #include "testing/gtest/include/gtest/gtest.h" @@ -46,7 +46,7 @@ bool HasTokensInOrder(const std::string& value, EXPECT_NE(position, std::string::npos); EXPECT_GE(position, current_position); if (position == std::string::npos) { - SB_DLOG(INFO) << "Token \"" << token << "\" not found in order."; + DLOG(INFO) << "Token \"" << token << "\" not found in order."; return false; } current_position = position + strlen(token); diff --git a/cobalt/browser/suspend_fuzzer.cc b/cobalt/browser/suspend_fuzzer.cc index c3bb35830007..97a6247247ce 100644 --- a/cobalt/browser/suspend_fuzzer.cc +++ b/cobalt/browser/suspend_fuzzer.cc @@ -14,6 +14,7 @@ #include "cobalt/browser/suspend_fuzzer.h" +#include "base/logging.h" #include "base/threading/thread_task_runner_handle.h" namespace cobalt { @@ -47,11 +48,11 @@ void SuspendFuzzer::DoStep() { DCHECK(base::SequencedTaskRunner::GetCurrentDefault() == thread_.task_runner()); if (step_type_ == kShouldRequestFreeze) { - SB_DLOG(INFO) << "suspend_fuzzer: Requesting freeze."; + DLOG(INFO) << "suspend_fuzzer: Requesting freeze."; SbSystemRequestFreeze(); step_type_ = kShouldRequestFocus; } else if (step_type_ == kShouldRequestFocus) { - SB_DLOG(INFO) << "suspend_fuzzer: Requesting focus."; + DLOG(INFO) << "suspend_fuzzer: Requesting focus."; SbSystemRequestFocus(); step_type_ = kShouldRequestFocus; } else { diff --git a/cobalt/browser/system_platform_error_handler.cc b/cobalt/browser/system_platform_error_handler.cc index 71e03d33b433..949dbc1413bc 100644 --- a/cobalt/browser/system_platform_error_handler.cc +++ b/cobalt/browser/system_platform_error_handler.cc @@ -38,7 +38,7 @@ void SystemPlatformErrorHandler::RaiseSystemPlatformError( // for all active errors. When this object is destroyed, all dangling data // will be released. { - starboard::ScopedLock lock(mutex_); + base::AutoLock lock(mutex_); // Delete any consumed callback data. for (size_t i = 0; i < callback_data_.size();) { @@ -62,7 +62,7 @@ void SystemPlatformErrorHandler::HandleSystemPlatformErrorResponse( callback_data->callback.Run(response); { - starboard::ScopedLock lock(*(callback_data->mutex)); + base::AutoLock lock(*(callback_data->mutex)); callback_data->callback.Reset(); } } diff --git a/cobalt/browser/system_platform_error_handler.h b/cobalt/browser/system_platform_error_handler.h index aefb8f0baef9..908838af5765 100644 --- a/cobalt/browser/system_platform_error_handler.h +++ b/cobalt/browser/system_platform_error_handler.h @@ -19,7 +19,7 @@ #include #include "base/callback.h" -#include "starboard/common/mutex.h" +#include "base/synchronization/lock.h" #include "starboard/system.h" namespace cobalt { @@ -46,7 +46,7 @@ class SystemPlatformErrorHandler { private: // This specifies the user data passed to the error response callback. struct CallbackData { - starboard::Mutex* mutex; + base::Lock* mutex; SystemPlatformErrorCallback callback; }; @@ -54,7 +54,7 @@ class SystemPlatformErrorHandler { static void HandleSystemPlatformErrorResponse( SbSystemPlatformErrorResponse response, void* user_data); - starboard::Mutex mutex_; + base::Lock mutex_; std::vector> callback_data_; }; diff --git a/cobalt/browser/user_agent_platform_info.cc b/cobalt/browser/user_agent_platform_info.cc index 0284aa625a48..294ba1bce032 100644 --- a/cobalt/browser/user_agent_platform_info.cc +++ b/cobalt/browser/user_agent_platform_info.cc @@ -25,8 +25,6 @@ #include "cobalt/script/javascript_engine.h" #include "cobalt/version.h" #include "cobalt_build_id.h" // NOLINT(build/include_subdir) -#include "starboard/common/log.h" -#include "starboard/common/string.h" #include "starboard/common/system_property.h" #include "starboard/extension/platform_info.h" #if SB_IS(EVERGREEN) diff --git a/cobalt/browser/user_agent_string.cc b/cobalt/browser/user_agent_string.cc index 65bcf8413cc9..4db2e02c89ad 100644 --- a/cobalt/browser/user_agent_string.cc +++ b/cobalt/browser/user_agent_string.cc @@ -23,8 +23,6 @@ #include "base/command_line.h" #include "base/strings/stringprintf.h" #include "cobalt/browser/switches.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" #include "starboard/log.h" #include "starboard/system.h" diff --git a/cobalt/browser/web_module.cc b/cobalt/browser/web_module.cc index 7713adf1eae7..448aab92412b 100644 --- a/cobalt/browser/web_module.cc +++ b/cobalt/browser/web_module.cc @@ -80,7 +80,6 @@ #include "cobalt/web/event.h" #include "cobalt/web/url.h" #include "starboard/accessibility.h" -#include "starboard/common/log.h" #include "starboard/gles.h" #if defined(ENABLE_DEBUGGER) @@ -452,7 +451,7 @@ class WebModule::Impl { // Used to avoid a deadlock when running |Impl::Pause| while waiting for the // web debugger to connect. - starboard::atomic_bool* waiting_for_web_debugger_; + std::atomic_bool* waiting_for_web_debugger_; // Interface to report behaviour relevant to the web debugger. debug::backend::DebuggerHooksImpl debugger_hooks_; diff --git a/cobalt/browser/web_module.h b/cobalt/browser/web_module.h index 179e12a8d096..82aa422acd7d 100644 --- a/cobalt/browser/web_module.h +++ b/cobalt/browser/web_module.h @@ -15,6 +15,7 @@ #ifndef COBALT_BROWSER_WEB_MODULE_H_ #define COBALT_BROWSER_WEB_MODULE_H_ +#include #include #include #include @@ -424,7 +425,7 @@ class WebModule : public base::CurrentThread::DestructionObserver, int dom_max_element_depth, float layout_refresh_rate, const scoped_refptr& ui_nav_root, #if defined(ENABLE_DEBUGGER) - starboard::atomic_bool* waiting_for_web_debugger, + std::atomic_bool* waiting_for_web_debugger, #endif // defined(ENABLE_DEBUGGER) base::WaitableEvent* synchronous_loader_interrupt, const Options& options) @@ -464,7 +465,7 @@ class WebModule : public base::CurrentThread::DestructionObserver, float layout_refresh_rate; scoped_refptr ui_nav_root; #if defined(ENABLE_DEBUGGER) - starboard::atomic_bool* waiting_for_web_debugger; + std::atomic_bool* waiting_for_web_debugger; #endif // defined(ENABLE_DEBUGGER) base::WaitableEvent* synchronous_loader_interrupt; Options options; @@ -503,7 +504,7 @@ class WebModule : public base::CurrentThread::DestructionObserver, #if defined(ENABLE_DEBUGGER) // Used to avoid a deadlock when running |Blur| while waiting for the web // debugger to connect. Initializes to false. - starboard::atomic_bool waiting_for_web_debugger_; + std::atomic_bool waiting_for_web_debugger_; #endif // defined(ENABLE_DEBUGGER) // This event is used to interrupt the loader when JavaScript is loaded diff --git a/cobalt/css_parser/trivial_string_piece.h b/cobalt/css_parser/trivial_string_piece.h index eb491ebbbc5b..ba51d44c4277 100644 --- a/cobalt/css_parser/trivial_string_piece.h +++ b/cobalt/css_parser/trivial_string_piece.h @@ -16,11 +16,11 @@ #define COBALT_CSS_PARSER_TRIVIAL_STRING_PIECE_H_ #include +#include #include #include #include "base/logging.h" -#include "starboard/common/string.h" namespace cobalt { namespace css_parser { diff --git a/cobalt/cssom/translate_function.cc b/cobalt/cssom/translate_function.cc index a018a9a96951..26e87b88e6a9 100644 --- a/cobalt/cssom/translate_function.cc +++ b/cobalt/cssom/translate_function.cc @@ -67,7 +67,8 @@ scoped_refptr TranslateFunction::offset_as_calc() const { float TranslateFunction::length_component_in_pixels() const { switch (offset_type()) { case kLength: - DCHECK_EQ(kPixelsUnit, offset_as_length()->unit()); + // TODO(b/345814494): Consider re-enabling the DCHECK_EQ() below. + // DCHECK_EQ(kPixelsUnit, offset_as_length()->unit()); return offset_as_length()->value(); case kPercentage: return 0.0f; diff --git a/cobalt/debug/backend/tracing_controller.cc b/cobalt/debug/backend/tracing_controller.cc index dd4c954cd993..93aec696e937 100644 --- a/cobalt/debug/backend/tracing_controller.cc +++ b/cobalt/debug/backend/tracing_controller.cc @@ -23,7 +23,6 @@ #include "base/trace_event/trace_event.h" #include "base/values.h" #include "cobalt/script/script_debugger.h" -#include "starboard/common/string.h" namespace cobalt { namespace debug { diff --git a/cobalt/dom/html_element.cc b/cobalt/dom/html_element.cc index 58b124b988bb..1d9d335c8f14 100644 --- a/cobalt/dom/html_element.cc +++ b/cobalt/dom/html_element.cc @@ -65,7 +65,6 @@ #include "cobalt/loader/resource_cache.h" #include "cobalt/math/clamp.h" #include "cobalt/web/csp_delegate.h" -#include "starboard/common/time.h" #include "third_party/icu/source/common/unicode/uchar.h" #include "third_party/icu/source/common/unicode/utf8.h" @@ -94,7 +93,10 @@ const char* kPerformanceResourceTimingInitiatorType = "img"; void UiNavCallbackHelper(scoped_refptr task_runner, base::Callback callback) { task_runner->PostTask( - FROM_HERE, base::Bind(callback, starboard::CurrentMonotonicTime())); + FROM_HERE, + base::Bind( + callback, + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds())); } struct NonTrivialStaticFields { @@ -1498,7 +1500,8 @@ void HTMLElement::UpdateUiNavigationFocus() { // Focus call for this HTMLElement as a result of OnUiNavBlur / OnUiNavFocus // callbacks that result from initiating the UI navigation focus change. if (node_document()->TrySetUiNavFocusElement( - html_element, starboard::CurrentMonotonicTime())) { + html_element, + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds())) { html_element->ui_nav_item_->Focus(); } break; @@ -2300,7 +2303,8 @@ void HTMLElement::ReleaseUiNavigationItem() { node_document()->set_ui_nav_needs_layout(true); if (node_document()->ui_nav_focus_element() == this) { if (node_document()->TrySetUiNavFocusElement( - nullptr, starboard::CurrentMonotonicTime())) { + nullptr, (base::TimeTicks::Now() - base::TimeTicks()) + .InMicroseconds())) { ui_nav_item_->UnfocusAll(); } } diff --git a/cobalt/dom/html_link_element.cc b/cobalt/dom/html_link_element.cc index 70dbca13bf7e..04bc36c24a98 100644 --- a/cobalt/dom/html_link_element.cc +++ b/cobalt/dom/html_link_element.cc @@ -32,7 +32,6 @@ #include "cobalt/dom/window.h" #include "cobalt/network/disk_cache/resource_type.h" #include "cobalt/web/csp_delegate.h" -#include "starboard/common/time.h" #include "url/gurl.h" namespace cobalt { @@ -319,11 +318,13 @@ void HTMLLinkElement::OnSplashscreenLoaded(Document* document, void HTMLLinkElement::OnStylesheetLoaded(Document* document, const std::string& content) { - auto before_parse_micros = starboard::CurrentMonotonicTime(); + auto before_parse_micros = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); scoped_refptr css_style_sheet = document->html_element_context()->css_parser()->ParseStyleSheet( content, base::SourceLocation(href(), 1, 1)); - auto after_parse_micros = starboard::CurrentMonotonicTime(); + auto after_parse_micros = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); auto css_kb = content.length() / 1000; // Only measure non-trivial CSS sizes and ignore non-HTTP schemes (e.g., // file://), which are primarily used for debug purposes. diff --git a/cobalt/dom/html_style_element.cc b/cobalt/dom/html_style_element.cc index cfeb76d91ef6..2dd705f06865 100644 --- a/cobalt/dom/html_style_element.cc +++ b/cobalt/dom/html_style_element.cc @@ -22,7 +22,6 @@ #include "cobalt/dom/document.h" #include "cobalt/dom/html_element_context.h" #include "cobalt/web/csp_delegate.h" -#include "starboard/common/time.h" namespace cobalt { namespace dom { @@ -92,11 +91,13 @@ void HTMLStyleElement::Process() { const std::string& text = content.value_or(base::EmptyString()); if (bypass_csp || csp_delegate->AllowInline(web::CspDelegate::kStyle, inline_style_location_, text)) { - auto before_parse_micros = starboard::CurrentMonotonicTime(); + auto before_parse_micros = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); scoped_refptr css_style_sheet = document->html_element_context()->css_parser()->ParseStyleSheet( text, inline_style_location_); - auto after_parse_micros = starboard::CurrentMonotonicTime(); + auto after_parse_micros = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); auto css_kb = text.length() / 1000; // Only measure non-trivial css sizes and inlined HTML style elements. if (css_kb > 0 && diff --git a/cobalt/dom/lottie_player.cc b/cobalt/dom/lottie_player.cc index 3a9325821f95..6ef278166650 100644 --- a/cobalt/dom/lottie_player.cc +++ b/cobalt/dom/lottie_player.cc @@ -22,6 +22,7 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "cobalt/base/polymorphic_downcast.h" +#include "cobalt/dom/base64.h" #include "cobalt/dom/document.h" #include "cobalt/dom/dom_settings.h" #include "cobalt/dom/html_element_context.h" @@ -34,6 +35,17 @@ namespace cobalt { namespace dom { +namespace { +bool isBase64Encoded(const std::string& url) { + size_t pos = url.find(','); + if (pos != std::string::npos) { + std::string beforeComma = url.substr(0, pos); + return beforeComma.find("base64") != std::string::npos; + } + return false; +} +} // namespace + using render_tree::LottieAnimation; const char LottiePlayer::kTagName[] = "lottie-player"; @@ -298,9 +310,20 @@ void LottiePlayer::UpdateAnimationData() { return; } + // Force base64 encoding of plain/raw inputs, to ensure no URL escaping + // occurs. + GURL resource_url = selected_source; + if (selected_source.SchemeIs("data") && !isBase64Encoded(src)) { + base::Optional encoded = + ForgivingBase64Encode(src.substr(src.find(',') + 1)); + if (encoded) { + resource_url = GURL(std::string("data:text/json;base64,") + *encoded); + } + } + auto image_cache = node_document()->html_element_context()->image_cache(); - cached_image_ = image_cache->GetOrCreateCachedResource(selected_source, - loader::Origin()); + cached_image_ = + image_cache->GetOrCreateCachedResource(resource_url, loader::Origin()); if (cached_image_->TryGetResource()) { PreventGarbageCollectionUntilEventIsDispatched(base::Tokens::load()); diff --git a/cobalt/dom/on_screen_keyboard_test.cc b/cobalt/dom/on_screen_keyboard_test.cc index d2ce2a380661..d0ef8aa28aaf 100644 --- a/cobalt/dom/on_screen_keyboard_test.cc +++ b/cobalt/dom/on_screen_keyboard_test.cc @@ -15,6 +15,7 @@ #include #include +#include "base/logging.h" #include "cobalt/base/tokens.h" #include "cobalt/bindings/testing/utils.h" #include "cobalt/browser/on_screen_keyboard_extension_bridge.h" @@ -203,7 +204,7 @@ class OnScreenKeyboardTest : public testing::TestWithJavaScript { bool SkipLocale() { bool skipTests = !browser::OnScreenKeyboardExtensionBridge::IsSupported(); if (skipTests) { - SB_LOG(INFO) << "On screen keyboard not supported. Test skipped."; + LOG(INFO) << "On screen keyboard not supported. Test skipped."; } return skipTests; } diff --git a/cobalt/dom/performance_lifecycle_timing.cc b/cobalt/dom/performance_lifecycle_timing.cc index 779e69af1535..14d7f7753180 100644 --- a/cobalt/dom/performance_lifecycle_timing.cc +++ b/cobalt/dom/performance_lifecycle_timing.cc @@ -16,7 +16,6 @@ #include "cobalt/dom/performance_lifecycle_timing.h" #include "cobalt/dom/performance.h" -#include "starboard/common/time.h" namespace cobalt { namespace dom { @@ -45,8 +44,8 @@ DOMHighResTimeStamp ConvertMonotonicTimestampToDOMHiResTimeStamp( const DOMHighResTimeStamp time_origin, int64_t monotonic_time) { // Current delta from Windows epoch. int64_t time_delta = - starboard::PosixTimeToWindowsTime(starboard::CurrentPosixTime()) - - starboard::CurrentMonotonicTime(); + base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds() - + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); base::Time base_time = base::Time::FromDeltaSinceWindowsEpoch( base::TimeDelta::FromMicroseconds(time_delta + monotonic_time)); return ClampTimeStampMinimumResolution( diff --git a/cobalt/dom/serialized_algorithm_runner.h b/cobalt/dom/serialized_algorithm_runner.h index 3173f4cec73b..c09caea2a8e4 100644 --- a/cobalt/dom/serialized_algorithm_runner.h +++ b/cobalt/dom/serialized_algorithm_runner.h @@ -26,12 +26,11 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/single_thread_task_runner.h" +#include "base/synchronization/lock.h" #include "base/task/sequenced_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" -#include "starboard/common/mutex.h" -#include "starboard/common/time.h" namespace cobalt { namespace dom { @@ -86,21 +85,22 @@ class SerializedAlgorithmRunner { // due to nested calls. class ScopedLockWhenRequired { public: - ScopedLockWhenRequired(bool synchronization_required, - const starboard::Mutex& mutex) + ScopedLockWhenRequired(bool synchronization_required, base::Lock& mutex) : synchronization_required_(synchronization_required), mutex_(mutex) { if (synchronization_required_) { // Crash if we are trying to re-acquire again on the same thread. - CHECK(!pthread_equal(acquired_thread_id_, pthread_self())); + CHECK_NE(acquired_thread_id_, SbThreadGetId()); - int64_t start_usec = starboard::CurrentMonotonicTime(); + + int64_t start_usec = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); int64_t wait_interval_usec = 1 * base::Time::kMicrosecondsPerMillisecond; constexpr int64_t kMaxWaitIntervalUsec = 16 * base::Time::kMicrosecondsPerMillisecond; // 16ms. for (;;) { - if (mutex_.AcquireTry()) { + if (mutex_.Try()) { break; } usleep(static_cast(wait_interval_usec)); @@ -109,24 +109,26 @@ class SerializedAlgorithmRunner { wait_interval_usec = std::min(wait_interval_usec * 2, kMaxWaitIntervalUsec); // Crash if we've been waiting for too long (1 second). - CHECK_LT(starboard::CurrentMonotonicTime() - start_usec, - 1 * base::Time::kMicrosecondsPerSecond); + CHECK_LT( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() - + start_usec, + 1 * base::Time::kMicrosecondsPerSecond); } - acquired_thread_id_ = pthread_self(); + acquired_thread_id_ = SbThreadGetId(); } } ~ScopedLockWhenRequired() { if (synchronization_required_) { - CHECK(pthread_equal(acquired_thread_id_, pthread_self())); - acquired_thread_id_ = 0; + CHECK_EQ(acquired_thread_id_, SbThreadGetId()); + acquired_thread_id_ = kSbThreadInvalidId; mutex_.Release(); } } private: const bool synchronization_required_; - const starboard::Mutex& mutex_; - pthread_t acquired_thread_id_ = 0; + base::Lock& mutex_; + SbThreadId acquired_thread_id_ = kSbThreadInvalidId; }; Handle(bool synchronization_required, @@ -135,7 +137,7 @@ class SerializedAlgorithmRunner { // The |mutex_| is necessary for algorithm runners operate on multiple // threads as `Abort()` can be called from any thread. const bool synchronization_required_; - starboard::Mutex mutex_; + base::Lock mutex_; std::unique_ptr algorithm_; bool aborted_ = false; bool finished_ = false; diff --git a/cobalt/dom/source_buffer.cc b/cobalt/dom/source_buffer.cc index 3907a696f9f5..d92b0f6bef80 100644 --- a/cobalt/dom/source_buffer.cc +++ b/cobalt/dom/source_buffer.cc @@ -1,5 +1,19 @@ +// Modifications Copyright 2017 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /* - * Copyright (C) 2013 Google Inc. All Rights Reserved. + * Copyright (C) 2024 The Cobalt Authors. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -11,7 +25,7 @@ * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. - * * Neither the name of Google Inc. nor the names of its + * * Neither the name of The Cobalt Authors. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * @@ -28,20 +42,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// Modifications Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - #include "cobalt/dom/source_buffer.h" #include @@ -238,7 +238,7 @@ scoped_refptr SourceBuffer::buffered( double SourceBuffer::timestamp_offset( script::ExceptionState* exception_state) const { - starboard::ScopedLock scoped_lock(timestamp_offset_mutex_); + base::AutoLock scoped_lock(timestamp_offset_mutex_); return timestamp_offset_; } @@ -680,7 +680,7 @@ void SourceBuffer::OnAlgorithmFinalized() { } void SourceBuffer::UpdateTimestampOffset(base::TimeDelta timestamp_offset) { - starboard::ScopedLock scoped_lock(timestamp_offset_mutex_); + base::AutoLock scoped_lock(timestamp_offset_mutex_); // The check avoids overwriting |timestamp_offset_| when there is a small // difference between its float and its int64_t representation . if (DoubleToTimeDelta(timestamp_offset_) != timestamp_offset) { diff --git a/cobalt/dom/source_buffer.h b/cobalt/dom/source_buffer.h index 4bfe074beef5..b9422897c3c9 100644 --- a/cobalt/dom/source_buffer.h +++ b/cobalt/dom/source_buffer.h @@ -1,5 +1,19 @@ +// Modifications Copyright 2017 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /* - * Copyright (C) 2013 Google Inc. All Rights Reserved. + * Copyright (C) 2024 The Cobalt Authors. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -11,7 +25,7 @@ * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. - * * Neither the name of Google Inc. nor the names of its + * * Neither the name of The Cobalt Authors. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * @@ -28,20 +42,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// Modifications Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - #ifndef COBALT_DOM_SOURCE_BUFFER_H_ #define COBALT_DOM_SOURCE_BUFFER_H_ @@ -54,6 +54,7 @@ #include "base/memory/ref_counted.h" #include "base/optional.h" #include "base/single_thread_task_runner.h" +#include "base/synchronization/lock.h" #include "base/task/sequenced_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/timer/timer.h" @@ -74,7 +75,6 @@ #include "cobalt/web/event_target.h" #include "media/base/media_tracks.h" #include "media/filters/chunk_demuxer.h" -#include "starboard/common/mutex.h" namespace cobalt { namespace dom { @@ -211,7 +211,7 @@ class SourceBuffer : public web::EventTarget { SourceBufferAppendMode mode_ = kSourceBufferAppendModeSegments; - starboard::Mutex timestamp_offset_mutex_; + mutable base::Lock timestamp_offset_mutex_; double timestamp_offset_ = 0; scoped_refptr::Handle> diff --git a/cobalt/dom/source_buffer_metrics.cc b/cobalt/dom/source_buffer_metrics.cc index a8f9e209fd6c..3587cd537457 100644 --- a/cobalt/dom/source_buffer_metrics.cc +++ b/cobalt/dom/source_buffer_metrics.cc @@ -22,7 +22,6 @@ #include "cobalt/base/statistics.h" #include "starboard/common/once.h" #include "starboard/common/string.h" -#include "starboard/common/time.h" #include "starboard/types.h" namespace cobalt { @@ -79,7 +78,8 @@ void SourceBufferMetrics::StartTracking(SourceBufferMetricsAction action) { wall_start_time_ = clock_->NowTicks(); #if !defined(COBALT_BUILD_TYPE_GOLD) - thread_start_time_ = starboard::CurrentMonotonicThreadTime(); + thread_start_time_ = + (base::ThreadTicks::Now() - base::ThreadTicks()).InMicroseconds(); #endif // !defined(COBALT_BUILD_TYPE_GOLD) } @@ -101,7 +101,8 @@ void SourceBufferMetrics::EndTracking(SourceBufferMetricsAction action, #if !defined(COBALT_BUILD_TYPE_GOLD) int64_t thread_duration = - starboard::CurrentMonotonicThreadTime() - thread_start_time_; + (base::ThreadTicks::Now() - base::ThreadTicks()).InMicroseconds() - + thread_start_time_; total_wall_time_ += wall_duration.InMicroseconds(); total_thread_time_ += thread_duration; diff --git a/cobalt/dom/track_base.h b/cobalt/dom/track_base.h index 9b0a1776d371..77043fe8e47f 100644 --- a/cobalt/dom/track_base.h +++ b/cobalt/dom/track_base.h @@ -20,7 +20,6 @@ #include "base/memory/weak_ptr.h" #include "cobalt/dom/html_media_element.h" #include "cobalt/script/wrappable.h" -#include "starboard/common/string.h" namespace cobalt { namespace dom { diff --git a/cobalt/encoding/BUILD.gn b/cobalt/encoding/BUILD.gn index 2636b6e64096..9264b7650dbe 100644 --- a/cobalt/encoding/BUILD.gn +++ b/cobalt/encoding/BUILD.gn @@ -53,8 +53,5 @@ target(gtest_target_type, "text_encoding_test") { "//testing/gtest", ] - data_deps = [ - "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", - ] + data_deps = [ "//cobalt/network:copy_ssl_certificates" ] } diff --git a/cobalt/h5vcc/dial/dial_http_response.cc b/cobalt/h5vcc/dial/dial_http_response.cc index 6ab27274dfa1..325c150eb609 100644 --- a/cobalt/h5vcc/dial/dial_http_response.cc +++ b/cobalt/h5vcc/dial/dial_http_response.cc @@ -38,11 +38,9 @@ void DialHttpResponse::AddHeader(const std::string& header, std::unique_ptr DialHttpResponse::ToHttpServerResponseInfo() { if (!info_) { - info_.reset(new net::HttpServerResponseInfo()); + info_.reset( + new net::HttpServerResponseInfo(net::HttpStatusCode(response_code_))); } -#ifndef COBALT_PENDING_CLEAN_UP - info_->status_code() = net::HttpStatusCode(response_code_); -#endif info_->SetBody(body_, mime_type_); return std::move(info_); } diff --git a/cobalt/h5vcc/h5vcc_metrics.cc b/cobalt/h5vcc/h5vcc_metrics.cc index 0b22b176983c..04846ca5cb12 100644 --- a/cobalt/h5vcc/h5vcc_metrics.cc +++ b/cobalt/h5vcc/h5vcc_metrics.cc @@ -119,9 +119,8 @@ script::HandlePromiseVoid H5vccMetrics::Disable( void H5vccMetrics::ToggleMetricsEnabled(bool is_enabled, base::OnceClosure done_callback) { - persistent_settings_->SetPersistentSetting( - browser::metrics::kMetricEnabledSettingName, - std::make_unique(is_enabled)); + persistent_settings_->Set(browser::metrics::kMetricEnabledSettingName, + base::Value(is_enabled)); browser::metrics::CobaltMetricsServicesManager::GetInstance() ->ToggleMetricsEnabled(is_enabled, std::move(done_callback)); } @@ -132,9 +131,8 @@ bool H5vccMetrics::IsEnabled() { } void H5vccMetrics::SetMetricEventInterval(uint32_t interval_seconds) { - persistent_settings_->SetPersistentSetting( - browser::metrics::kMetricEventIntervalSettingName, - std::make_unique(static_cast(interval_seconds))); + persistent_settings_->Set(browser::metrics::kMetricEventIntervalSettingName, + base::Value(static_cast(interval_seconds))); browser::metrics::CobaltMetricsServicesManager::GetInstance() ->SetUploadInterval(interval_seconds); } diff --git a/cobalt/h5vcc/h5vcc_platform_service.cc b/cobalt/h5vcc/h5vcc_platform_service.cc index 96be634e0848..04dd050e3761 100644 --- a/cobalt/h5vcc/h5vcc_platform_service.cc +++ b/cobalt/h5vcc/h5vcc_platform_service.cc @@ -17,11 +17,11 @@ #include #include +#include "base/logging.h" #include "base/threading/thread_task_runner_handle.h" #include "cobalt/base/polymorphic_downcast.h" #include "cobalt/web/context.h" #include "cobalt/web/environment_settings.h" -#include "starboard/common/string.h" #include "starboard/configuration.h" namespace cobalt { @@ -42,7 +42,7 @@ scoped_refptr H5vccPlatformService::Open( static_cast( SbSystemGetExtension(kCobaltExtensionPlatformServiceName)); if (!platform_service_api) { - SB_DLOG(WARNING) << "PlatformService is not implemented on this platform."; + DLOG(WARNING) << "PlatformService is not implemented on this platform."; return NULL; } scoped_refptr service = new H5vccPlatformService( diff --git a/cobalt/h5vcc/h5vcc_settings.cc b/cobalt/h5vcc/h5vcc_settings.cc index 59d76c863024..03f068947167 100644 --- a/cobalt/h5vcc/h5vcc_settings.cc +++ b/cobalt/h5vcc/h5vcc_settings.cc @@ -84,9 +84,8 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const { if (!persistent_settings_) { return false; } else { - persistent_settings_->SetPersistentSetting( - network::kQuicEnabledPersistentSettingsKey, - std::make_unique(value.AsType() != 0)); + persistent_settings_->Set(network::kQuicEnabledPersistentSettingsKey, + base::Value(value.AsType() != 0)); // Tell NetworkModule (if exists) to re-query persistent settings. if (network_module_) { network_module_->SetEnableQuicFromPersistentSettings(); @@ -107,16 +106,16 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const { void H5vccSettings::SetPersistentSettingAsInt(const std::string& key, int value) const { if (persistent_settings_) { - persistent_settings_->SetPersistentSetting( - key, std::make_unique(value)); + persistent_settings_->Set(key, base::Value(value)); } } int H5vccSettings::GetPersistentSettingAsInt(const std::string& key, int default_setting) const { if (persistent_settings_) { - return persistent_settings_->GetPersistentSettingAsInt(key, - default_setting); + base::Value value; + persistent_settings_->Get(key, &value); + return value.GetIfInt().value_or(default_setting); } return default_setting; } diff --git a/cobalt/h5vcc/h5vcc_storage.cc b/cobalt/h5vcc/h5vcc_storage.cc index 9b88ae9dcc2f..fdd660e0ff67 100644 --- a/cobalt/h5vcc/h5vcc_storage.cc +++ b/cobalt/h5vcc/h5vcc_storage.cc @@ -372,9 +372,9 @@ H5vccStorageResourceTypeQuotaBytesDictionary H5vccStorage::GetQuota() { } void H5vccStorage::EnableCache() { - persistent_settings_->SetPersistentSetting( + persistent_settings_->Set( network::disk_cache::kCacheEnabledPersistentSettingsKey, - std::make_unique(true)); + base::Value(true)); network::disk_cache::settings::SetCacheEnabled(true); @@ -384,9 +384,9 @@ void H5vccStorage::EnableCache() { } void H5vccStorage::DisableCache() { - persistent_settings_->SetPersistentSetting( + persistent_settings_->Set( network::disk_cache::kCacheEnabledPersistentSettingsKey, - std::make_unique(false)); + base::Value(false)); network::disk_cache::settings::SetCacheEnabled(false); diff --git a/cobalt/input/input_poller_impl.cc b/cobalt/input/input_poller_impl.cc index 9fd9242f8adc..edbe75c4d7f4 100644 --- a/cobalt/input/input_poller_impl.cc +++ b/cobalt/input/input_poller_impl.cc @@ -32,13 +32,13 @@ InputPollerImpl::InputPollerImpl() : InputPoller() { } bool InputPollerImpl::IsPressed(SbKey keycode) { - starboard::ScopedLock lock(input_mutex_); + base::AutoLock lock(input_mutex_); return pressed_keys_.find(keycode) != pressed_keys_.end(); } float InputPollerImpl::AnalogInput(SbKey analog_input_id) { - starboard::ScopedLock lock(input_mutex_); + base::AutoLock lock(input_mutex_); KeyOffsetMap::const_iterator found = key_offset_map_.find(analog_input_id); if (found == key_offset_map_.end()) { @@ -50,7 +50,7 @@ float InputPollerImpl::AnalogInput(SbKey analog_input_id) { void InputPollerImpl::UpdateInputEvent( const system_window::InputEvent* input_event) { - starboard::ScopedLock lock(input_mutex_); + base::AutoLock lock(input_mutex_); switch (input_event->type()) { case system_window::InputEvent::kKeyDown: diff --git a/cobalt/input/input_poller_impl.h b/cobalt/input/input_poller_impl.h index c003c1a18bb8..62f168afa3bd 100644 --- a/cobalt/input/input_poller_impl.h +++ b/cobalt/input/input_poller_impl.h @@ -21,9 +21,9 @@ #include "base/containers/hash_tables.h" #include "base/containers/small_map.h" +#include "base/synchronization/lock.h" #include "cobalt/input/input_poller.h" #include "cobalt/system_window/input_event.h" -#include "starboard/common/mutex.h" #include "starboard/input.h" #include "starboard/window.h" @@ -44,7 +44,7 @@ class InputPollerImpl : public InputPoller { private: typedef base::small_map, 8> KeyOffsetMap; - starboard::Mutex input_mutex_; + base::Lock input_mutex_; base::hash_set pressed_keys_; KeyOffsetMap key_offset_map_; }; diff --git a/cobalt/js_profiler/profiler.cc b/cobalt/js_profiler/profiler.cc index bf3f8e9ce5bb..5918386038b6 100644 --- a/cobalt/js_profiler/profiler.cc +++ b/cobalt/js_profiler/profiler.cc @@ -56,7 +56,7 @@ Profiler::Profiler(script::EnvironmentSettings* settings, } sample_interval_ = effective_sample_interval_ms; - SB_LOG(INFO) << "[PROFILER] START " + profiler_id_; + LOG(INFO) << "[PROFILER] START " + profiler_id_; auto status = profiler_group_->ProfilerStart( this, settings, v8::CpuProfilingOptions(v8::kLeafNodeLineNumbers, @@ -95,7 +95,7 @@ void Profiler::DispatchSampleBufferFullEvent() { Profiler::ProfilerTracePromise Profiler::Stop( script::EnvironmentSettings* environment_settings) { - SB_LOG(INFO) << "[PROFILER] STOPPING " + profiler_id_; + LOG(INFO) << "[PROFILER] STOPPING " + profiler_id_; script::HandlePromiseWrappable promise = web::get_script_value_factory(environment_settings) ->CreateInterfacePromise>(); @@ -123,7 +123,7 @@ void Profiler::PerformStop( ProfilerGroup* profiler_group, std::unique_ptr promise_reference, base::TimeTicks time_origin, std::string profiler_id) { - SB_LOG(INFO) << "[PROFILER] STOPPED " + profiler_id_; + LOG(INFO) << "[PROFILER] STOPPED " + profiler_id_; auto trace = profiler_group->ProfilerStop(this); scoped_refptr result(new ProfilerTraceWrapper(trace)); promise_reference->value().Resolve(result); diff --git a/cobalt/layout_tests/BUILD.gn b/cobalt/layout_tests/BUILD.gn index 328176dc2c06..0d21a344036d 100644 --- a/cobalt/layout_tests/BUILD.gn +++ b/cobalt/layout_tests/BUILD.gn @@ -67,7 +67,6 @@ target(gtest_target_type, "layout_tests") { data_deps = [ "//cobalt/layout_tests/testdata:layout_copy_test_data", "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", ] if (cobalt_font_package == "empty") { data_deps += [ "//cobalt/content/fonts:copy_font_data" ] diff --git a/cobalt/layout_tests/testdata/BUILD.gn b/cobalt/layout_tests/testdata/BUILD.gn index 494c69298f19..cf1d066f705b 100644 --- a/cobalt/layout_tests/testdata/BUILD.gn +++ b/cobalt/layout_tests/testdata/BUILD.gn @@ -1674,6 +1674,8 @@ copy("layout_copy_test_data") { "lottie-player/layout_tests.txt", "lottie-player/lottie-background-attribute-expected.png", "lottie-player/lottie-background-attribute.html", + "lottie-player/lottie-data-urls-expected.png", + "lottie-player/lottie-data-urls.html", "lottie-player/lottie-playback-events-expected.png", "lottie-player/lottie-playback-events.html", "text-shaping/combining-character-sequences-should-be-handled-properly-expected.png", diff --git a/cobalt/layout_tests/testdata/lottie-player/layout_tests.txt b/cobalt/layout_tests/testdata/lottie-player/layout_tests.txt index 74d75b7273bb..3ad07e364154 100644 --- a/cobalt/layout_tests/testdata/lottie-player/layout_tests.txt +++ b/cobalt/layout_tests/testdata/lottie-player/layout_tests.txt @@ -1,3 +1,3 @@ -# TODO(b/330747689): re-enable lottie tests globally. -# lottie-background-attribute -# lottie-playback-events +lottie-background-attribute +lottie-data-urls +lottie-playback-events diff --git a/cobalt/layout_tests/testdata/lottie-player/lottie-data-urls-expected.png b/cobalt/layout_tests/testdata/lottie-player/lottie-data-urls-expected.png new file mode 100644 index 000000000000..e8e12d7195df Binary files /dev/null and b/cobalt/layout_tests/testdata/lottie-player/lottie-data-urls-expected.png differ diff --git a/cobalt/layout_tests/testdata/lottie-player/lottie-data-urls.html b/cobalt/layout_tests/testdata/lottie-player/lottie-data-urls.html new file mode 100644 index 000000000000..77331601ec1d --- /dev/null +++ b/cobalt/layout_tests/testdata/lottie-player/lottie-data-urls.html @@ -0,0 +1,33 @@ + + + + + + + + +
+ +
+
+ +
+ + + diff --git a/cobalt/loader/BUILD.gn b/cobalt/loader/BUILD.gn index 8eb9a84f7423..71de9267190b 100644 --- a/cobalt/loader/BUILD.gn +++ b/cobalt/loader/BUILD.gn @@ -114,7 +114,7 @@ static_library("loader") { "//cobalt/renderer/test/png_utils", "//cobalt/web", "//net", - "//third_party/libjpeg-turbo:libjpeg", + "//third_party/libjpeg_turbo:libjpeg", "//third_party/libpng", "//third_party/libwebp", "//third_party/protobuf:protobuf_lite", diff --git a/cobalt/loader/cors_preflight.cc b/cobalt/loader/cors_preflight.cc index 01d8104e2f02..46172a83de95 100644 --- a/cobalt/loader/cors_preflight.cc +++ b/cobalt/loader/cors_preflight.cc @@ -27,7 +27,6 @@ #include "base/strings/string_util.h" #include "net/base/net_errors.h" #include "net/http/http_util.h" -#include "starboard/common/string.h" namespace cobalt { namespace loader { diff --git a/cobalt/loader/cors_preflight_cache.h b/cobalt/loader/cors_preflight_cache.h index 4f5bcfc4ec30..8821786217f1 100644 --- a/cobalt/loader/cors_preflight_cache.h +++ b/cobalt/loader/cors_preflight_cache.h @@ -29,7 +29,6 @@ #include "base/time/time.h" #include "cobalt/network/custom/url_fetcher.h" #include "net/http/http_request_headers.h" -#include "starboard/common/string.h" #include "url/gurl.h" namespace cobalt { diff --git a/cobalt/loader/fetcher_cache.cc b/cobalt/loader/fetcher_cache.cc index 6cce36aa6000..d797c2757c15 100644 --- a/cobalt/loader/fetcher_cache.cc +++ b/cobalt/loader/fetcher_cache.cc @@ -249,7 +249,7 @@ FetcherCache::FetcherCache(const char* name, size_t capacity) FetcherCache::~FetcherCache() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - CHECK(pthread_equal(thread_id_, pthread_self())); + CHECK_EQ(thread_id_, SbThreadGetId()); CHECK(destroy_soon_called_); while (!cache_entries_.empty()) { @@ -273,7 +273,7 @@ Loader::FetcherCreator FetcherCache::GetFetcherCreator( void FetcherCache::NotifyResourceRequested(const std::string& url) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - CHECK(pthread_equal(thread_id_, pthread_self())); + CHECK_EQ(thread_id_, SbThreadGetId()); auto iter = cache_entries_.find(url); if (iter != cache_entries_.end()) { @@ -301,7 +301,7 @@ std::unique_ptr FetcherCache::CreateCachedFetcher( #if !defined(COBALT_BUILD_TYPE_GOLD) CHECK(!destroy_soon_called_); #endif // !defined(COBALT_BUILD_TYPE_GOLD) - CHECK(pthread_equal(thread_id_, pthread_self())); + CHECK_EQ(thread_id_, SbThreadGetId()); auto iterator = cache_entries_.find(url.spec()); if (iterator != cache_entries_.end()) { @@ -330,8 +330,7 @@ void FetcherCache::OnFetchSuccess( #if !defined(COBALT_BUILD_TYPE_GOLD) CHECK(!destroy_soon_called_); #endif // !defined(COBALT_BUILD_TYPE_GOLD) - - CHECK(pthread_equal(thread_id_, pthread_self())); + CHECK_EQ(thread_id_, SbThreadGetId()); if (data.capacity() > capacity_) { return; diff --git a/cobalt/loader/fetcher_cache.h b/cobalt/loader/fetcher_cache.h index 9a432ddc4315..bf86887e84e2 100644 --- a/cobalt/loader/fetcher_cache.h +++ b/cobalt/loader/fetcher_cache.h @@ -15,8 +15,6 @@ #ifndef COBALT_LOADER_FETCHER_CACHE_H_ #define COBALT_LOADER_FETCHER_CACHE_H_ -#include - #include #include #include @@ -46,12 +44,12 @@ class FetcherCache : public base::RefCountedThreadSafe { void NotifyResourceRequested(const std::string& url); size_t size() const { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - CHECK(pthread_equal(thread_id_, pthread_self())); + CHECK_EQ(thread_id_, SbThreadGetId()); return total_size_; } size_t capacity() const { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - CHECK(pthread_equal(thread_id_, pthread_self())); + CHECK_EQ(thread_id_, SbThreadGetId()); return capacity_; } @@ -77,7 +75,7 @@ class FetcherCache : public base::RefCountedThreadSafe { // TODO(b/270993319): For debugging cache integrity issues in production only, // remove after identifying the root cause. - const pthread_t thread_id_ = pthread_self(); + const SbThreadId thread_id_ = SbThreadGetId(); std::atomic_bool destroy_soon_called_{false}; const size_t capacity_; diff --git a/cobalt/loader/image/animated_image_tracker.cc b/cobalt/loader/image/animated_image_tracker.cc index adda7dcfef56..04625d22f4cf 100644 --- a/cobalt/loader/image/animated_image_tracker.cc +++ b/cobalt/loader/image/animated_image_tracker.cc @@ -48,8 +48,8 @@ AnimatedImageTracker::AnimatedImageTracker( options.priority = animated_image_decode_thread_priority; animated_image_decode_thread_.StartWithOptions(options); #else - animated_image_decode_thread_.StartWithOptions(base::Thread::Options( - base::MessagePumpType::DEFAULT, 0 /* default stack size */)); + animated_image_decode_thread_.StartWithOptions( + base::Thread::Options(animated_image_decode_thread_priority)); #endif } diff --git a/cobalt/loader/image/jpeg_image_decoder.cc b/cobalt/loader/image/jpeg_image_decoder.cc index 9355188d9c09..fb2b4fbae184 100644 --- a/cobalt/loader/image/jpeg_image_decoder.cc +++ b/cobalt/loader/image/jpeg_image_decoder.cc @@ -20,7 +20,7 @@ #include "base/logging.h" #include "base/trace_event/trace_event.h" #include "cobalt/base/console_log.h" -#include "third_party/libjpeg-turbo/jpegint.h" +#include "third_party/libjpeg_turbo/jpegint.h" namespace cobalt { namespace loader { diff --git a/cobalt/loader/image/jpeg_image_decoder.h b/cobalt/loader/image/jpeg_image_decoder.h index aa08822ed912..6ca8a25fa16d 100644 --- a/cobalt/loader/image/jpeg_image_decoder.h +++ b/cobalt/loader/image/jpeg_image_decoder.h @@ -27,7 +27,7 @@ // Inhibit C++ name-mangling for libjpeg functions. extern "C" { -#include "third_party/libjpeg-turbo/jpeglib.h" +#include "third_party/libjpeg_turbo/jpeglib.h" } namespace cobalt { diff --git a/cobalt/loader/image/png_image_decoder.cc b/cobalt/loader/image/png_image_decoder.cc index 95e2405e795d..4fcb31d1bcc1 100644 --- a/cobalt/loader/image/png_image_decoder.cc +++ b/cobalt/loader/image/png_image_decoder.cc @@ -51,7 +51,7 @@ uint32 FixPointUnsignedMultiply(uint32 fixed, uint32 alpha) { // static void DecodingFailed(png_structp png, png_const_charp) { DLOG(WARNING) << "Decoding failed."; - longjmp(png->jmpbuf, 1); + longjmp(png_jmpbuf(png), 1); } // static @@ -99,7 +99,7 @@ size_t PNGImageDecoder::DecodeChunkInternal(const uint8* data, size_t size) { MSVC_PUSH_DISABLE_WARNING(4611); // warning C4611: interaction between '_setjmp' and C++ object destruction is // non-portable. - if (setjmp(png_->jmpbuf)) { + if (setjmp(png_jmpbuf(png_))) { // image data is empty. DLOG(WARNING) << "Decoder encounters an error."; set_state(kError); @@ -181,7 +181,7 @@ void PNGImageDecoder::HeaderAvailableCallback() { DLOG(WARNING) << "Large PNG with width: " << width << ", height: " << height; set_state(kError); - longjmp(png_->jmpbuf, 1); + longjmp(png_jmpbuf(png_), 1); return; } @@ -251,7 +251,7 @@ void PNGImageDecoder::HeaderAvailableCallback() { if (!interlace_buffer_) { DLOG(WARNING) << "Allocate interlace buffer failed."; set_state(kError); - longjmp(png_->jmpbuf, 1); + longjmp(png_jmpbuf(png_), 1); return; } } @@ -261,7 +261,7 @@ void PNGImageDecoder::HeaderAvailableCallback() { has_alpha_); if (!decoded_image_data_) { set_state(kError); - longjmp(png_->jmpbuf, 1); + longjmp(png_jmpbuf(png_), 1); return; } diff --git a/cobalt/loader/net_fetcher.h b/cobalt/loader/net_fetcher.h index f2b1e4dde08a..e159ebfd5038 100644 --- a/cobalt/loader/net_fetcher.h +++ b/cobalt/loader/net_fetcher.h @@ -15,6 +15,7 @@ #ifndef COBALT_LOADER_NET_FETCHER_H_ #define COBALT_LOADER_NET_FETCHER_H_ +#include #include #include @@ -132,7 +133,7 @@ class NetFetcher : public Fetcher, scoped_refptr const task_runner_; bool skip_fetch_intercept_; - starboard::atomic_bool will_destroy_current_task_runner_; + std::atomic_bool will_destroy_current_task_runner_; bool main_resource_; DISALLOW_COPY_AND_ASSIGN(NetFetcher); diff --git a/cobalt/loader/script_loader_factory.cc b/cobalt/loader/script_loader_factory.cc index 0f52c35affaf..7a199df0e275 100644 --- a/cobalt/loader/script_loader_factory.cc +++ b/cobalt/loader/script_loader_factory.cc @@ -24,14 +24,6 @@ namespace cobalt { namespace loader { -namespace { - -// The ResourceLoader thread uses the default stack size, which is requested -// by passing in 0 for its stack size. -const size_t kLoadThreadStackSize = 0; - -} // namespace - ScriptLoaderFactory::ScriptLoaderFactory( const char* name, FetcherFactory* fetcher_factory, base::ThreadType loader_thread_priority) @@ -44,8 +36,7 @@ ScriptLoaderFactory::ScriptLoaderFactory( options.priority = loader_thread_priority; load_thread_.StartWithOptions(options); #else - load_thread_.StartWithOptions(base::Thread::Options( - base::MessagePumpType::DEFAULT, kLoadThreadStackSize)); + load_thread_.StartWithOptions(base::Thread::Options(loader_thread_priority)); #endif } diff --git a/cobalt/media/base/metrics_provider.cc b/cobalt/media/base/metrics_provider.cc index 4c270608998d..bee61cbf2649 100644 --- a/cobalt/media/base/metrics_provider.cc +++ b/cobalt/media/base/metrics_provider.cc @@ -22,44 +22,42 @@ namespace cobalt { namespace media { -using starboard::ScopedLock; - MediaMetricsProvider::~MediaMetricsProvider() { ReportPipelineUMA(); } void MediaMetricsProvider::OnError(const PipelineStatus status) { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); uma_info_.last_pipeline_status = status; } void MediaMetricsProvider::SetHasAudio(AudioCodec audio_codec) { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); uma_info_.audio_codec = audio_codec; uma_info_.has_audio = true; } void MediaMetricsProvider::SetHasVideo(VideoCodec video_codec) { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); uma_info_.video_codec = video_codec; uma_info_.has_video = true; } void MediaMetricsProvider::SetHasPlayed() { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); uma_info_.has_ever_played = true; } void MediaMetricsProvider::SetHaveEnough() { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); uma_info_.has_reached_have_enough = true; } void MediaMetricsProvider::SetIsEME() { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); uma_info_.is_eme = true; } void MediaMetricsProvider::ReportPipelineUMA() { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); if (uma_info_.has_video && uma_info_.has_audio) { base::UmaHistogramExactLinear( GetUMANameForAVStream(uma_info_), uma_info_.last_pipeline_status.code(), @@ -110,14 +108,14 @@ std::string MediaMetricsProvider::GetUMANameForAVStream( void MediaMetricsProvider::StartTrackingAction(MediaAction action) { DCHECK(!IsActionCurrentlyTracked(action)); - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); tracked_actions_start_times_[action] = clock_->NowTicks(); } void MediaMetricsProvider::EndTrackingAction(MediaAction action) { DCHECK(IsActionCurrentlyTracked(action)); - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); auto duration = clock_->NowTicks() - tracked_actions_start_times_[action]; ReportActionLatencyUMA(action, duration); @@ -125,7 +123,7 @@ void MediaMetricsProvider::EndTrackingAction(MediaAction action) { } bool MediaMetricsProvider::IsActionCurrentlyTracked(MediaAction action) { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); return tracked_actions_start_times_.find(action) != tracked_actions_start_times_.end(); } @@ -161,5 +159,7 @@ void MediaMetricsProvider::ReportActionLatencyUMA( } } +void MediaMetricsProvider::Reset() { tracked_actions_start_times_.clear(); } + } // namespace media } // namespace cobalt diff --git a/cobalt/media/base/metrics_provider.h b/cobalt/media/base/metrics_provider.h index a056dd0c40d5..4ac3e8718c1e 100644 --- a/cobalt/media/base/metrics_provider.h +++ b/cobalt/media/base/metrics_provider.h @@ -19,6 +19,7 @@ #include #include "base/containers/small_map.h" +#include "base/synchronization/lock.h" #include "base/time/default_tick_clock.h" #include "base/time/tick_clock.h" #include "base/time/time.h" @@ -27,7 +28,6 @@ #include "media/base/pipeline_status.h" #include "media/base/timestamp_constants.h" #include "media/base/video_codecs.h" -#include "starboard/common/mutex.h" #include "starboard/types.h" namespace cobalt { @@ -85,6 +85,8 @@ class MediaMetricsProvider { void EndTrackingAction(MediaAction action); bool IsActionCurrentlyTracked(MediaAction action); + void Reset(); + private: std::string GetUMANameForAVStream(const PipelineInfo& player_info) const; @@ -100,7 +102,7 @@ class MediaMetricsProvider { // UMA pipeline packaged data PipelineInfo uma_info_; - starboard::Mutex mutex_; + base::Lock mutex_; }; } // namespace media diff --git a/cobalt/media/base/sbplayer_pipeline.cc b/cobalt/media/base/sbplayer_pipeline.cc index 4d1998e016f7..c4db7f5425ae 100644 --- a/cobalt/media/base/sbplayer_pipeline.cc +++ b/cobalt/media/base/sbplayer_pipeline.cc @@ -34,6 +34,7 @@ namespace cobalt { namespace media { namespace { +using ::media::AudioCodec; using ::media::AudioDecoderConfig; using ::media::DecoderBuffer; using ::media::Demuxer; @@ -46,6 +47,16 @@ using ::starboard::GetMediaAudioConnectorName; static const int kRetryDelayAtSuspendInMilliseconds = 100; +// In the OnNeedData(), it attempts to write one more audio access +// unit than the audio write duration. Specifically, the check +// |time_ahead_of_playback_for_preroll| > |adjusted_write_duration_for_preroll| +// is used to skip audio writing, using '>' instead of '>='. +// Since the calculated write duration during preroll may align exactly +// with the audio write duration, the current check can fail, leading to an +// additional call to SbPlayerWriteSamples(). By writing an extra guard audio +// buffer, this extra write during preroll can be eliminated. +const int kPrerollGuardAudioBuffer = 1; + unsigned int g_pipeline_identifier_counter = 0; #if SB_API_VERSION >= 15 @@ -97,6 +108,25 @@ TimeDelta AdjustWriteDurationForPlaybackRate(TimeDelta write_duration, return write_duration * playback_rate; } +// The function returns the default frames per DecoderBuffer. +// +// The number of frames is used to estimate the number of samples per write for +// audio preroll according to |audio_write_duration_|. +int GetDefaultAudioFramesPerBuffer(AudioCodec codec) { + switch (codec) { + case AudioCodec::kOpus: + return 960; + case AudioCodec::kAAC: + return 1024; + case AudioCodec::kAC3: + case AudioCodec::kEAC3: + return 1536; + default: + NOTREACHED(); + return 1; + } +} + } // namespace SbPlayerPipeline::SbPlayerPipeline( @@ -1051,6 +1081,8 @@ void SbPlayerPipeline::OnDemuxerStreamRead( for (const auto& buffer : buffers) { playback_statistics_.OnAudioAU(buffer); if (!buffer->end_of_stream()) { + last_audio_sample_interval_ = + buffer->timestamp() - timestamp_of_last_written_audio_; timestamp_of_last_written_audio_ = buffer->timestamp(); } } @@ -1101,10 +1133,22 @@ void SbPlayerPipeline::OnNeedData(DemuxerStream::Type type, // after the player has received enough audio for preroll, taking into // account that our estimate of playback time might be behind by // |kMediaTimeCheckInterval|. - if (!is_video_eos_written_ && - timestamp_of_last_written_audio_ - seek_time_ > - AdjustWriteDurationForPlaybackRate( - audio_write_duration_for_preroll_, playback_rate_)) { + TimeDelta time_ahead_of_playback_for_preroll = + timestamp_of_last_written_audio_ - seek_time_; + auto adjusted_write_duration_for_preroll = + AdjustWriteDurationForPlaybackRate(audio_write_duration_for_preroll_, + playback_rate_); + // Note when Cobalt uses multiple samples per write, GetDefaultMaxBuffers() + // returns the exact number of samples computed by + // |time_ahead_of_playback_for_preroll| and + // |adjusted_write_duration_for_preroll|. The guard number + // kPrerollGuardAudioBuffer is used to ensure Cobalt can do one initial + // write for audio preroll, as preroll condition requires that + // |time_ahead_of_playback_for_preroll| > + // |adjusted_write_duration_for_preroll|. + int estimated_max_buffers = max_buffers; + if (!is_video_eos_written_ && time_ahead_of_playback_for_preroll > + adjusted_write_duration_for_preroll) { // The estimated time ahead of playback may be negative if no audio has // been written. TimeDelta time_ahead_of_playback = @@ -1120,7 +1164,28 @@ void SbPlayerPipeline::OnNeedData(DemuxerStream::Type type, audio_read_delayed_ = true; return; } + if (allow_batched_sample_write_ && + !time_ahead_of_playback.is_negative()) { + estimated_max_buffers = GetEstimatedMaxBuffers(adjusted_write_duration, + time_ahead_of_playback, + false /* is_preroll */); + } + } else if (allow_batched_sample_write_) { + if (!time_ahead_of_playback_for_preroll.is_negative()) { + estimated_max_buffers = GetEstimatedMaxBuffers( + adjusted_write_duration_for_preroll, + time_ahead_of_playback_for_preroll, true /* is_preroll */); + last_estimated_max_buffers_for_preroll_ = std::max( + estimated_max_buffers, last_estimated_max_buffers_for_preroll_); + } else { + estimated_max_buffers = last_estimated_max_buffers_for_preroll_; + } } + // When Cobalt uses multiple samples per write, this ensures that + // |max_buffers| is at most |max_number_of_buffers_to_write|. + // |max_buffers| is in the range of [1, |max_number_of_buffers_to_write|], + // where the lower bound 1 is guarded by GetEstimatedMaxBuffers(). + max_buffers = std::min(max_buffers, estimated_max_buffers); audio_read_delayed_ = false; audio_read_in_progress_ = true; @@ -1137,6 +1202,67 @@ void SbPlayerPipeline::OnNeedData(DemuxerStream::Type type, type, max_buffers)); } +int SbPlayerPipeline::GetDefaultMaxBuffers(AudioCodec codec, + TimeDelta duration_to_write, + bool is_preroll) { + // Return default maximum samples per write to speed up the initial sample + // write, including guard number of samples per write for audio preroll. + // The guard number kPrerollGuardAudioBuffer is used to ensure Cobalt + // can do one initial write for audio preroll. + int default_max_buffers = static_cast( + std::ceil(duration_to_write.InSecondsF() * + audio_stream_->audio_decoder_config().samples_per_second() / + GetDefaultAudioFramesPerBuffer(codec))); + if (is_preroll) { + default_max_buffers += kPrerollGuardAudioBuffer; + } + DCHECK_GT(default_max_buffers, 0); + return default_max_buffers; +} + +int SbPlayerPipeline::GetEstimatedMaxBuffers(TimeDelta write_duration, + TimeDelta time_ahead_of_playback, + bool is_preroll) { + DCHECK_GE(time_ahead_of_playback.InMicroseconds(), 0); + + int estimated_max_buffers = 1; + if (!allow_batched_sample_write_ || + write_duration <= time_ahead_of_playback) { + return estimated_max_buffers; + } + + TimeDelta duration_to_write = write_duration - time_ahead_of_playback; + DCHECK_GT(duration_to_write.InMicroseconds(), 0); + switch (audio_stream_->audio_decoder_config().codec()) { + case AudioCodec::kOpus: + case AudioCodec::kAAC: + case AudioCodec::kAC3: + case AudioCodec::kEAC3: + if (last_audio_sample_interval_.is_zero()) { + estimated_max_buffers = + GetDefaultMaxBuffers(audio_stream_->audio_decoder_config().codec(), + duration_to_write, is_preroll); + break; + } + // TODO(b/41486346): Support multiple samples per write on the format IAMF. + case AudioCodec::kIAMF: + default: + if (!last_audio_sample_interval_.is_zero()) { + DCHECK_GT(last_audio_sample_interval_.InMicroseconds(), 0); + estimated_max_buffers = + duration_to_write.InMillisecondsRoundedUp() / + last_audio_sample_interval_.InMilliseconds() + + 1; + } + } + DCHECK_GT(estimated_max_buffers, 0); + // Return 1 if |estimated_max_buffers| is non-positive. This ensures + // in corner cases, |estimated_max_buffers| falls back to 1. + // The maximum number samples of write should be guarded by + // SbPlayerGetMaximumNumberOfSamplesPerWrite() in OnNeedData(). + return estimated_max_buffers > 0 ? estimated_max_buffers : 1; +} + void SbPlayerPipeline::OnPlayerStatus(SbPlayerState state) { DCHECK(task_runner_->RunsTasksInCurrentSequence()); diff --git a/cobalt/media/base/sbplayer_pipeline.h b/cobalt/media/base/sbplayer_pipeline.h index e3117bcb7fa8..e59493aae5c3 100644 --- a/cobalt/media/base/sbplayer_pipeline.h +++ b/cobalt/media/base/sbplayer_pipeline.h @@ -203,6 +203,11 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline, void SetReadInProgress(::media::DemuxerStream::Type type, bool in_progress); bool GetReadInProgress(::media::DemuxerStream::Type type) const; + int GetDefaultMaxBuffers(AudioCodec codec, TimeDelta duration_to_write, + bool is_preroll); + int GetEstimatedMaxBuffers(TimeDelta write_duration, + TimeDelta time_ahead_of_playback, bool is_preroll); + // An identifier string for the pipeline, used in CVal to identify multiple // pipelines. const std::string pipeline_identifier_; @@ -345,6 +350,8 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline, // Indicates if video end of stream has been written into the underlying // player. bool is_video_eos_written_ = false; + TimeDelta last_audio_sample_interval_ = TimeDelta::FromMicroseconds(0); + int last_estimated_max_buffers_for_preroll_ = 1; // Last media time reported by GetMediaTime(). base::CVal last_media_time_; diff --git a/cobalt/media/bidirectional_fit_reuse_allocator.cc b/cobalt/media/bidirectional_fit_reuse_allocator.cc index 8f505db230ea..cfb9a13775e8 100644 --- a/cobalt/media/bidirectional_fit_reuse_allocator.cc +++ b/cobalt/media/bidirectional_fit_reuse_allocator.cc @@ -16,7 +16,7 @@ #include -#include "starboard/common/log.h" +#include "base/logging.h" #include "starboard/common/pointer_arithmetic.h" #include "starboard/types.h" @@ -38,7 +38,7 @@ BidirectionalFitReuseAllocator::FindFreeBlock(std::size_t size, FreeBlockSet::iterator begin, FreeBlockSet::iterator end, bool* allocate_from_front) { - SB_DCHECK(allocate_from_front); + DCHECK(allocate_from_front); *allocate_from_front = size > small_allocation_threshold_; diff --git a/cobalt/media/decoder_buffer_allocator.cc b/cobalt/media/decoder_buffer_allocator.cc index 1feeefec0901..802d5634843c 100644 --- a/cobalt/media/decoder_buffer_allocator.cc +++ b/cobalt/media/decoder_buffer_allocator.cc @@ -30,8 +30,6 @@ namespace media { namespace { -using starboard::ScopedLock; - const bool kEnableAllocationLog = false; const size_t kAllocationRecordGranularity = 512 * 1024; @@ -59,7 +57,7 @@ DecoderBufferAllocator::DecoderBufferAllocator() return; } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); EnsureReuseAllocatorIsCreated(); Allocator::Set(this); } @@ -71,7 +69,7 @@ DecoderBufferAllocator::~DecoderBufferAllocator() { return; } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); if (reuse_allocator_) { DCHECK_EQ(reuse_allocator_->GetAllocated(), 0); @@ -84,7 +82,7 @@ void DecoderBufferAllocator::Suspend() { return; } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); if (reuse_allocator_ && reuse_allocator_->GetAllocated() == 0) { DLOG(INFO) << "Freed " << reuse_allocator_->GetCapacity() @@ -98,7 +96,7 @@ void DecoderBufferAllocator::Resume() { return; } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); EnsureReuseAllocatorIsCreated(); } @@ -111,7 +109,7 @@ void* DecoderBufferAllocator::Allocate(size_t size, size_t alignment) { return p; } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); EnsureReuseAllocatorIsCreated(); @@ -135,7 +133,7 @@ void DecoderBufferAllocator::Free(void* p, size_t size) { return; } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); DCHECK(reuse_allocator_); @@ -202,7 +200,7 @@ size_t DecoderBufferAllocator::GetAllocatedMemory() const { if (!using_memory_pool_) { return sbmemory_bytes_used_.load(); } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); return reuse_allocator_ ? reuse_allocator_->GetAllocated() : 0; } @@ -210,12 +208,12 @@ size_t DecoderBufferAllocator::GetCurrentMemoryCapacity() const { if (!using_memory_pool_) { return sbmemory_bytes_used_.load(); } - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); return reuse_allocator_ ? reuse_allocator_->GetCapacity() : 0; } size_t DecoderBufferAllocator::GetMaximumMemoryCapacity() const { - ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); if (reuse_allocator_) { return std::max(reuse_allocator_->max_capacity(), @@ -225,8 +223,6 @@ size_t DecoderBufferAllocator::GetMaximumMemoryCapacity() const { } void DecoderBufferAllocator::EnsureReuseAllocatorIsCreated() { - mutex_.DCheckAcquired(); - if (reuse_allocator_) { return; } diff --git a/cobalt/media/decoder_buffer_allocator.h b/cobalt/media/decoder_buffer_allocator.h index 16afc8d3560e..c1dfd85cca4c 100644 --- a/cobalt/media/decoder_buffer_allocator.h +++ b/cobalt/media/decoder_buffer_allocator.h @@ -15,9 +15,11 @@ #ifndef COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_ #define COBALT_MEDIA_DECODER_BUFFER_ALLOCATOR_H_ +#include #include #include "base/compiler_specific.h" +#include "base/synchronization/lock.h" #include "base/time/time.h" #include "cobalt/media/bidirectional_fit_reuse_allocator.h" #include "cobalt/media/decoder_buffer_memory_info.h" @@ -25,7 +27,6 @@ #include "media/base/decoder_buffer.h" #include "media/base/video_decoder_config.h" #include "starboard/common/atomic.h" -#include "starboard/common/mutex.h" #include "starboard/media.h" namespace cobalt { @@ -68,14 +69,14 @@ class DecoderBufferAllocator : public ::media::DecoderBuffer::Allocator, const int initial_capacity_; const int allocation_unit_; - starboard::Mutex mutex_; + mutable base::Lock mutex_; StarboardMemoryAllocator fallback_allocator_; std::unique_ptr reuse_allocator_; int max_buffer_capacity_ = 0; // Monitor memory allocation and use when |using_memory_pool_| is false - starboard::atomic_int32_t sbmemory_bytes_used_; + std::atomic_int32_t sbmemory_bytes_used_; }; } // namespace media diff --git a/cobalt/media/file_data_source_test.cc b/cobalt/media/file_data_source_test.cc index f387192dd773..4967df6f6a84 100644 --- a/cobalt/media/file_data_source_test.cc +++ b/cobalt/media/file_data_source_test.cc @@ -19,14 +19,13 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/test/task_environment.h" -#include "starboard/common/log.h" #include "testing/gtest/include/gtest/gtest.h" namespace cobalt { namespace media { void OnReadFinished(int* bytes_read_out, int bytes_read_in) { - SB_CHECK(bytes_read_out); + CHECK(bytes_read_out); *bytes_read_out = bytes_read_in; } diff --git a/cobalt/media/media_module.cc b/cobalt/media/media_module.cc index 1a238a1a89b3..c01a3533a9c7 100644 --- a/cobalt/media/media_module.cc +++ b/cobalt/media/media_module.cc @@ -23,10 +23,11 @@ #include "base/callback.h" #include "base/logging.h" #include "base/strings/string_split.h" +#include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" #include "cobalt/media/base/format_support_query_metrics.h" #include "media/base/mime_util.h" -#include "starboard/common/string.h" +#include "starboard/extension/media_settings.h" #include "starboard/media.h" #include "starboard/window.h" @@ -218,6 +219,19 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) { << (value ? "true" : "false"); return true; } + } else if (name == "AsyncReleaseMediaCodecBridge") { + const StarboardExtensionMediaSettingsApi* media_settings_api = + static_cast( + SbSystemGetExtension(kStarboardExtensionMediaSettingsName)); + if (media_settings_api && + strcmp(media_settings_api->name, + kStarboardExtensionMediaSettingsName) == 0 && + media_settings_api->version >= 1) { + media_settings_api->EnableAsyncReleaseMediaCodecBridge(value); + LOG(INFO) << "Set AsyncReleaseMediaCodecBridge to " + << (value ? "true" : "false"); + return true; + } } return false; @@ -243,7 +257,7 @@ std::unique_ptr MediaModule::CreateWebMediaPlayer( } void MediaModule::Suspend() { - starboard::ScopedLock scoped_lock(players_lock_); + base::AutoLock scoped_lock(players_lock_); suspended_ = true; @@ -261,7 +275,7 @@ void MediaModule::Suspend() { } void MediaModule::Resume(render_tree::ResourceProvider* resource_provider) { - starboard::ScopedLock scoped_lock(players_lock_); + base::AutoLock scoped_lock(players_lock_); resource_provider_ = resource_provider; @@ -284,7 +298,7 @@ void MediaModule::Resume(render_tree::ResourceProvider* resource_provider) { } void MediaModule::RegisterPlayer(WebMediaPlayer* player) { - starboard::ScopedLock scoped_lock(players_lock_); + base::AutoLock scoped_lock(players_lock_); DCHECK(players_.find(player) == players_.end()); players_.insert(std::make_pair(player, false)); @@ -295,7 +309,7 @@ void MediaModule::RegisterPlayer(WebMediaPlayer* player) { } void MediaModule::UnregisterPlayer(WebMediaPlayer* player) { - starboard::ScopedLock scoped_lock(players_lock_); + base::AutoLock scoped_lock(players_lock_); DCHECK(players_.find(player) != players_.end()); players_.erase(players_.find(player)); @@ -303,7 +317,7 @@ void MediaModule::UnregisterPlayer(WebMediaPlayer* player) { void MediaModule::EnumerateWebMediaPlayers( const EnumeratePlayersCB& enumerate_callback) const { - starboard::ScopedLock scoped_lock(players_lock_); + base::AutoLock scoped_lock(players_lock_); for (Players::const_iterator iter = players_.begin(); iter != players_.end(); ++iter) { diff --git a/cobalt/media/media_module.h b/cobalt/media/media_module.h index 766f2955892f..4dfa48c79a89 100644 --- a/cobalt/media/media_module.h +++ b/cobalt/media/media_module.h @@ -24,6 +24,7 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/optional.h" +#include "base/synchronization/lock.h" #include "base/time/time.h" #include "cobalt/math/size.h" #include "cobalt/media/base/sbplayer_interface.h" @@ -36,7 +37,6 @@ #include "cobalt/render_tree/resource_provider.h" #include "cobalt/system_window/system_window.h" #include "media/base/media_log.h" -#include "starboard/common/mutex.h" #include "starboard/player.h" namespace cobalt { @@ -118,7 +118,7 @@ class MediaModule : public WebMediaPlayerFactory, ::media::MediaLog media_log_; // Protect access to the list of players. - starboard::Mutex players_lock_; + mutable base::Lock players_lock_; Players players_; bool suspended_ = false; diff --git a/cobalt/media/player/web_media_player_impl.cc b/cobalt/media/player/web_media_player_impl.cc index caf64d2fd6e1..0ecfefe83745 100644 --- a/cobalt/media/player/web_media_player_impl.cc +++ b/cobalt/media/player/web_media_player_impl.cc @@ -343,6 +343,7 @@ void WebMediaPlayerImpl::Seek(double seconds) { #endif // defined(COBALT_SKIP_SEEK_REQUEST_NEAR_END) if (state_.starting || state_.seeking) { + media_metrics_provider_.Reset(); state_.pending_seek = true; state_.pending_seek_seconds = seconds; if (chunk_demuxer_) { @@ -534,6 +535,7 @@ double WebMediaPlayerImpl::GetMaxTimeSeekable() const { void WebMediaPlayerImpl::Suspend() { pipeline_->Suspend(); } void WebMediaPlayerImpl::Resume(PipelineWindow window) { + media_metrics_provider_.Reset(); if (!window_ && window) { is_resuming_from_background_mode_ = true; } diff --git a/cobalt/media/sandbox/format_guesstimator.cc b/cobalt/media/sandbox/format_guesstimator.cc index 5a9fe6074979..36972f4b512b 100644 --- a/cobalt/media/sandbox/format_guesstimator.cc +++ b/cobalt/media/sandbox/format_guesstimator.cc @@ -19,6 +19,7 @@ #include #include "base/bind.h" +#include "base/logging.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/strings/string_split.h" @@ -36,8 +37,6 @@ #include "media/filters/chunk_demuxer.h" #include "net/base/filename_util.h" #include "net/base/url_util.h" -#include "starboard/common/file.h" -#include "starboard/common/string.h" #include "starboard/memory.h" #include "starboard/types.h" #include "ui/gfx/geometry/size.h" @@ -153,7 +152,7 @@ FormatGuesstimator::FormatGuesstimator(const std::string& path_or_url, bool is_from_root = !path_or_url.empty() && path_or_url[0] == '/'; auto path_from_root = (is_from_root ? "" : "/") + path_or_url; progressive_url_ = GURL("file://" + path_from_root); - SB_LOG(INFO) << progressive_url_.spec(); + LOG(INFO) << progressive_url_.spec(); mime_type_ = "video/mp4; codecs=\"avc1.640028, mp4a.40.2\""; } } diff --git a/cobalt/media/sandbox/fuzzer_app.cc b/cobalt/media/sandbox/fuzzer_app.cc index 49ea02b4946f..53e3402d5728 100644 --- a/cobalt/media/sandbox/fuzzer_app.cc +++ b/cobalt/media/sandbox/fuzzer_app.cc @@ -18,7 +18,6 @@ #include "base/files/file_util.h" #include "base/logging.h" -#include "starboard/common/string.h" #include "starboard/configuration_constants.h" #include "starboard/directory.h" diff --git a/cobalt/media/sandbox/media2_sandbox.cc b/cobalt/media/sandbox/media2_sandbox.cc index 20c52f783428..1333209b649b 100644 --- a/cobalt/media/sandbox/media2_sandbox.cc +++ b/cobalt/media/sandbox/media2_sandbox.cc @@ -29,7 +29,6 @@ #include "cobalt/media/decoder_buffer_allocator.h" #include "media/base/media_log.h" #include "media/filters/chunk_demuxer.h" -#include "starboard/common/string.h" #include "starboard/event.h" namespace cobalt { diff --git a/cobalt/media/sandbox/web_media_player_sandbox.cc b/cobalt/media/sandbox/web_media_player_sandbox.cc index 600e47566103..71cefdbd106b 100644 --- a/cobalt/media/sandbox/web_media_player_sandbox.cc +++ b/cobalt/media/sandbox/web_media_player_sandbox.cc @@ -21,6 +21,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/compiler_specific.h" +#include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/path_service.h" #include "base/task/sequenced_task_runner.h" @@ -120,7 +121,7 @@ class Application { media_sandbox_.GetMediaModule()); if (!guesstimator1.is_valid()) { - SB_LOG(ERROR) << "Invalid path or url: " << argv[argc - 1]; + LOG(ERROR) << "Invalid path or url: " << argv[argc - 1]; // Fall off to PrintUsage() and terminate. } else if (guesstimator1.is_progressive()) { InitializeProgressivePlayback(guesstimator1); @@ -129,14 +130,14 @@ class Application { InitializeAdaptivePlayback(guesstimator1); return; } else if (guesstimator1.is_audio() && guesstimator2.is_audio()) { - SB_LOG(ERROR) << "Failed to play because both " << argv[argc - 1] - << " and " << argv[argc - 2] - << " are audio streams, check usage for more details."; + LOG(ERROR) << "Failed to play because both " << argv[argc - 1] + << " and " << argv[argc - 2] + << " are audio streams, check usage for more details."; // Fall off to PrintUsage() and terminate. } else if (!guesstimator1.is_audio() && !guesstimator2.is_audio()) { - SB_LOG(ERROR) << "Failed to play because both " << argv[argc - 1] - << " and " << argv[argc - 2] - << " are video streams, check usage for more details."; + LOG(ERROR) << "Failed to play because both " << argv[argc - 1] + << " and " << argv[argc - 2] + << " are video streams, check usage for more details."; // Fall off to PrintUsage() and terminate. } else if (guesstimator1.is_audio()) { InitializeAdaptivePlayback(guesstimator1, guesstimator2); diff --git a/cobalt/media_capture/encoders/audio_encoder.cc b/cobalt/media_capture/encoders/audio_encoder.cc index c6051a9a18bd..65f37667049f 100644 --- a/cobalt/media_capture/encoders/audio_encoder.cc +++ b/cobalt/media_capture/encoders/audio_encoder.cc @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 The Cobalt Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ namespace media_capture { namespace encoders { void AudioEncoder::AddListener(AudioEncoder::Listener* listener) { - starboard::ScopedLock lock(listeners_mutex_); + base::AutoLock lock(listeners_mutex_); if (std::find(listeners_.begin(), listeners_.end(), listener) != listeners_.end()) { return; @@ -30,14 +30,14 @@ void AudioEncoder::AddListener(AudioEncoder::Listener* listener) { } void AudioEncoder::RemoveListener(AudioEncoder::Listener* listener) { - starboard::ScopedLock lock(listeners_mutex_); + base::AutoLock lock(listeners_mutex_); listeners_.erase(std::remove(listeners_.begin(), listeners_.end(), listener), listeners_.end()); } void AudioEncoder::PushDataToAllListeners(const uint8* data, size_t data_size, base::TimeTicks timecode) { - starboard::ScopedLock lock(listeners_mutex_); + base::AutoLock lock(listeners_mutex_); for (AudioEncoder::Listener* listener : listeners_) { listener->OnEncodedDataAvailable(data, data_size, timecode); } diff --git a/cobalt/media_capture/encoders/audio_encoder.h b/cobalt/media_capture/encoders/audio_encoder.h index 0efe09b585c8..2efcc6e10483 100644 --- a/cobalt/media_capture/encoders/audio_encoder.h +++ b/cobalt/media_capture/encoders/audio_encoder.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 The Cobalt Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,10 +19,10 @@ #include "base/basictypes.h" #include "base/strings/string_piece.h" +#include "base/synchronization/lock.h" #include "base/time/time.h" #include "cobalt/media/base/audio_bus.h" #include "cobalt/media_stream/audio_parameters.h" -#include "starboard/common/mutex.h" namespace cobalt { @@ -74,7 +74,7 @@ class AudioEncoder { AudioEncoder(const AudioEncoder&) = delete; AudioEncoder& operator=(AudioEncoder&) = delete; - starboard::Mutex listeners_mutex_; + base::Lock listeners_mutex_; std::vector listeners_; }; diff --git a/cobalt/media_capture/media_devices.cc b/cobalt/media_capture/media_devices.cc index 0747eebb9139..6d8cf0af3e03 100644 --- a/cobalt/media_capture/media_devices.cc +++ b/cobalt/media_capture/media_devices.cc @@ -31,7 +31,6 @@ #include "cobalt/web/dom_exception.h" #include "cobalt/web/environment_settings.h" #include "cobalt/web/environment_settings_helper.h" -#include "starboard/common/string.h" namespace cobalt { namespace media_capture { diff --git a/cobalt/media_session/media_session.h b/cobalt/media_session/media_session.h index ec9598fb3dc4..33d7b6dfd8b8 100644 --- a/cobalt/media_session/media_session.h +++ b/cobalt/media_session/media_session.h @@ -31,7 +31,6 @@ #include "cobalt/script/callback_function.h" #include "cobalt/script/script_value.h" #include "cobalt/script/wrappable.h" -#include "starboard/common/time.h" namespace cobalt { namespace media_session { @@ -97,7 +96,7 @@ class MediaSession : public script::Wrappable { // Returns a time representing right now - may be overridden for testing. virtual int64_t GetMonotonicNow() const { - return starboard::CurrentMonotonicTime(); + return (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); } ActionMap action_map_; diff --git a/cobalt/media_session/media_session_client.cc b/cobalt/media_session/media_session_client.cc index ad93e31de6af..5babc10a60c6 100644 --- a/cobalt/media_session/media_session_client.cc +++ b/cobalt/media_session/media_session_client.cc @@ -22,7 +22,6 @@ #include "base/logging.h" #include "cobalt/media_session/media_image.h" #include "cobalt/script/sequence.h" -#include "starboard/common/time.h" namespace cobalt { namespace media_session { @@ -70,7 +69,8 @@ void GuessMediaPositionState(MediaSessionState* session_state, position_state.set_position((*guess_player)->GetCurrentTime()); *session_state = MediaSessionState( - session_state->metadata(), starboard::CurrentMonotonicTime(), + session_state->metadata(), + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(), position_state, session_state->actual_playback_state(), session_state->available_actions()); } diff --git a/cobalt/media_session/media_session_state.h b/cobalt/media_session/media_session_state.h index 09b48aa57a08..bcab1565a1e4 100644 --- a/cobalt/media_session/media_session_state.h +++ b/cobalt/media_session/media_session_state.h @@ -23,7 +23,6 @@ #include "cobalt/media_session/media_position_state.h" #include "cobalt/media_session/media_session_action.h" #include "cobalt/media_session/media_session_playback_state.h" -#include "starboard/common/time.h" namespace cobalt { namespace media_session { @@ -61,11 +60,12 @@ class MediaSessionState { // https://wicg.github.io/mediasession/#current-playback-position // Returns the position int64_t current_playback_position() const { - return GetCurrentPlaybackPosition(starboard::CurrentMonotonicTime()); + return GetCurrentPlaybackPosition( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds()); } // Returns the position of the current playback, given the current time. - // This may be used for testing without calling |CurrentMonotonicTime|. + // This may be used for testing without calling |base::TimeTicks::Now|. int64_t GetCurrentPlaybackPosition(int64_t monotonic_now) const; // Returns a coefficient of the current playback rate. e.g. 1.0 is normal diff --git a/cobalt/media_session/media_session_test.cc b/cobalt/media_session/media_session_test.cc index ba3f56d9730f..a672f69a2592 100644 --- a/cobalt/media_session/media_session_test.cc +++ b/cobalt/media_session/media_session_test.cc @@ -29,7 +29,6 @@ #include "cobalt/script/script_value.h" #include "cobalt/script/testing/fake_script_value.h" #include "cobalt/script/wrappable.h" -#include "starboard/common/time.h" #include "starboard/extension/media_session.h" #include "starboard/thread.h" #include "testing/gmock/include/gmock/gmock.h" diff --git a/cobalt/media_stream/media_stream_track.h b/cobalt/media_stream/media_stream_track.h index 4dce9bd78b08..b833f08a473f 100644 --- a/cobalt/media_stream/media_stream_track.h +++ b/cobalt/media_stream/media_stream_track.h @@ -17,10 +17,10 @@ #include "base/callback.h" #include "base/strings/string_piece.h" +#include "base/synchronization/lock.h" #include "cobalt/media_stream/media_track_settings.h" #include "cobalt/script/environment_settings.h" #include "cobalt/web/event_target.h" -#include "starboard/common/mutex.h" namespace cobalt { namespace media_stream { @@ -39,7 +39,7 @@ class MediaStreamTrack : public web::EventTarget { // Function exposed to JavaScript via IDL. const MediaTrackSettings& GetSettings() const { - starboard::ScopedLock lock(settings_mutex_); + base::AutoLock lock(settings_mutex_); return settings_; } @@ -52,7 +52,7 @@ class MediaStreamTrack : public web::EventTarget { media_stream::MediaStreamTrack::ReadyState new_state) = 0; void SetMediaTrackSettings(const MediaTrackSettings& new_settings) { - starboard::ScopedLock lock(settings_mutex_); + base::AutoLock lock(settings_mutex_); settings_ = new_settings; } @@ -62,7 +62,7 @@ class MediaStreamTrack : public web::EventTarget { MediaStreamTrack(const MediaStreamTrack&) = delete; MediaStreamTrack& operator=(const MediaStreamTrack&) = delete; - starboard::Mutex settings_mutex_; + mutable base::Lock settings_mutex_; MediaTrackSettings settings_; }; diff --git a/cobalt/network/cookie_jar_impl.cc b/cobalt/network/cookie_jar_impl.cc index 62e1b952445b..7bc427ceb935 100644 --- a/cobalt/network/cookie_jar_impl.cc +++ b/cobalt/network/cookie_jar_impl.cc @@ -78,6 +78,10 @@ void CookieJarImpl::SetCookie(const GURL& origin, origin, cookie_line, /*creation_time=*/base::Time::Now(), /*server_time=*/absl::nullopt, /*cookie_partition_key=*/absl::nullopt); + if (!cookie) { + DLOG(ERROR) << "Invalid cookie, won't be set: " << cookie_line; + return; + } network_task_runner_->PostTask( FROM_HERE, base::BindOnce(&net::CookieStore::SetCanonicalCookieAsync, base::Unretained(cookie_store_), diff --git a/cobalt/network/custom/url_fetcher_core.cc b/cobalt/network/custom/url_fetcher_core.cc index 6cebf8565548..b10656ed6834 100644 --- a/cobalt/network/custom/url_fetcher_core.cc +++ b/cobalt/network/custom/url_fetcher_core.cc @@ -30,7 +30,6 @@ #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_throttler_manager.h" -#include "starboard/common/time.h" #include "starboard/types.h" #include "url/origin.h" @@ -546,13 +545,14 @@ void URLFetcherCore::OnReadCompleted(URLRequest* request, int bytes_read) { #if defined(STARBOARD) // Prime it to the current time so it is only called after the loop, or every // time when the loop takes |kInformDownloadProgressIntervalUsec|. - int64_t download_progress_informed_at = starboard::CurrentMonotonicTime(); + int64_t download_progress_informed_at = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); bool did_read_after_inform_download_progress = false; while (bytes_read > 0) { current_response_bytes_ += bytes_read; did_read_after_inform_download_progress = true; - auto now = starboard::CurrentMonotonicTime(); + auto now = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); if (now - download_progress_informed_at > kInformDownloadProgressIntervalUsec) { InformDelegateDownloadProgress(); diff --git a/cobalt/network/disk_cache/resource_type.cc b/cobalt/network/disk_cache/resource_type.cc index fe2ae4fb1377..2fd5103d67c5 100644 --- a/cobalt/network/disk_cache/resource_type.cc +++ b/cobalt/network/disk_cache/resource_type.cc @@ -14,6 +14,8 @@ #include "cobalt/network/disk_cache/resource_type.h" +#include + #include "base/logging.h" namespace cobalt { @@ -85,27 +87,24 @@ namespace settings { namespace { -starboard::atomic_int32_t other_quota = - starboard::atomic_int32_t(defaults::GetQuota(kOther)); -starboard::atomic_int32_t html_quota = - starboard::atomic_int32_t(defaults::GetQuota(kHTML)); -starboard::atomic_int32_t css_quota = - starboard::atomic_int32_t(defaults::GetQuota(kCSS)); -starboard::atomic_int32_t image_quota = - starboard::atomic_int32_t(defaults::GetQuota(kImage)); -starboard::atomic_int32_t font_quota = - starboard::atomic_int32_t(defaults::GetQuota(kFont)); -starboard::atomic_int32_t splash_screen_quota = - starboard::atomic_int32_t(defaults::GetQuota(kSplashScreen)); -starboard::atomic_int32_t uncompiled_script_quota = - starboard::atomic_int32_t(defaults::GetQuota(kUncompiledScript)); -starboard::atomic_int32_t compiled_script_quota = - starboard::atomic_int32_t(defaults::GetQuota(kCompiledScript)); -starboard::atomic_int32_t cache_api_quota = - starboard::atomic_int32_t(defaults::GetQuota(kCacheApi)); -starboard::atomic_int32_t service_worker_script_quota = - starboard::atomic_int32_t(defaults::GetQuota(kServiceWorkerScript)); -starboard::atomic_bool cache_enabled = starboard::atomic_bool(true); +std::atomic_int32_t other_quota = + std::atomic_int32_t(defaults::GetQuota(kOther)); +std::atomic_int32_t html_quota = std::atomic_int32_t(defaults::GetQuota(kHTML)); +std::atomic_int32_t css_quota = std::atomic_int32_t(defaults::GetQuota(kCSS)); +std::atomic_int32_t image_quota = + std::atomic_int32_t(defaults::GetQuota(kImage)); +std::atomic_int32_t font_quota = std::atomic_int32_t(defaults::GetQuota(kFont)); +std::atomic_int32_t splash_screen_quota = + std::atomic_int32_t(defaults::GetQuota(kSplashScreen)); +std::atomic_int32_t uncompiled_script_quota = + std::atomic_int32_t(defaults::GetQuota(kUncompiledScript)); +std::atomic_int32_t compiled_script_quota = + std::atomic_int32_t(defaults::GetQuota(kCompiledScript)); +std::atomic_int32_t cache_api_quota = + std::atomic_int32_t(defaults::GetQuota(kCacheApi)); +std::atomic_int32_t service_worker_script_quota = + std::atomic_int32_t(defaults::GetQuota(kServiceWorkerScript)); +std::atomic_bool cache_enabled = std::atomic_bool(true); } // namespace diff --git a/cobalt/network/net_log_constants.cc b/cobalt/network/net_log_constants.cc index fdfbcc9b95ae..4c681b23461c 100644 --- a/cobalt/network/net_log_constants.cc +++ b/cobalt/network/net_log_constants.cc @@ -72,49 +72,37 @@ std::unique_ptr NetLogConstants::GetConstants() { // Add a dictionary with information about the relationship between load flag // enums and their symbolic names. { - std::unique_ptr dict(new base::Value::Dict()); + base::Value::Dict dict; -#define LOAD_FLAG(label, value) dict->Set(#label, static_cast(value)); +#define LOAD_FLAG(label, value) dict.Set(#label, static_cast(value)); #include "net/base/load_flags_list.h" #undef LOAD_FLAG -#ifdef REGULAR_UPSTREAM_CODE constants_dict->Set("loadFlag", std::move(dict)); -#else - constants_dict->Set("loadFlag", base::Value::Dict()); -#endif } // Add a dictionary with information about the relationship between load state // enums and their symbolic names. { - std::unique_ptr dict(new base::Value::Dict()); + base::Value::Dict dict; -#define LOAD_STATE(label, value) dict->Set(#label, static_cast(value)); +#define LOAD_STATE(label, value) dict.Set(#label, static_cast(value)); #include "net/base/load_states_list.h" #undef LOAD_STATE -#ifdef REGULAR_UPSTREAM_CODE constants_dict->Set("loadState", std::move(dict)); -#else - constants_dict->Set("loadState", base::Value::Dict()); -#endif } // Add information on the relationship between net error codes and their // symbolic names. { - std::unique_ptr dict(new base::Value::Dict()); + base::Value::Dict dict; -#define NET_ERROR(label, value) dict->Set(#label, static_cast(value)); +#define NET_ERROR(label, value) dict.Set(#label, static_cast(value)); #include "net/base/net_error_list.h" #undef NET_ERROR -#ifdef REGULAR_UPSTREAM_CODE constants_dict->Set("netError", std::move(dict)); -#else - constants_dict->Set("netError", base::Value::Dict()); -#endif } // Information about the relationship between event phase enums and their diff --git a/cobalt/network/network_module.cc b/cobalt/network/network_module.cc index de6b98cc9849..e7213f63dfa7 100644 --- a/cobalt/network/network_module.cc +++ b/cobalt/network/network_module.cc @@ -109,8 +109,10 @@ void NetworkModule::SetProxy(const std::string& custom_proxy_rules) { void NetworkModule::SetEnableQuicFromPersistentSettings() { // Called on initialization and when the persistent setting is changed. if (options_.persistent_settings != nullptr) { - bool enable_quic = options_.persistent_settings->GetPersistentSettingAsBool( - kQuicEnabledPersistentSettingsKey, false); + base::Value value; + options_.persistent_settings->Get(kQuicEnabledPersistentSettingsKey, + &value); + bool enable_quic = value.GetIfBool().value_or(false); task_runner()->PostTask( FROM_HERE, base::Bind(&URLRequestContext::SetEnableQuic, diff --git a/cobalt/network/url_request_context.cc b/cobalt/network/url_request_context.cc index ed047d13e58c..20f57a4771a6 100644 --- a/cobalt/network/url_request_context.cc +++ b/cobalt/network/url_request_context.cc @@ -51,6 +51,7 @@ #include "net/proxy_resolution/configured_proxy_resolution_service.h" #include "net/proxy_resolution/proxy_config.h" #include "net/proxy_resolution/proxy_resolution_service.h" +#include "net/quic/quic_context.h" #include "net/ssl/ssl_config_service.h" #include "net/ssl/ssl_config_service_defaults.h" #include "starboard/common/murmurhash2.h" @@ -71,9 +72,10 @@ void LoadDiskCacheQuotaSettings( disk_cache::ResourceType resource_type = (disk_cache::ResourceType)i; std::string directory = disk_cache::defaults::GetSubdirectory(resource_type); - uint32_t bucket_size = - static_cast(settings->GetPersistentSettingAsDouble( - directory, disk_cache::defaults::GetQuota(resource_type))); + base::Value value; + settings->Get(directory, &value); + uint32_t bucket_size = static_cast(value.GetIfDouble().value_or( + disk_cache::defaults::GetQuota(resource_type))); quotas[resource_type] = bucket_size; total_size += bucket_size; } @@ -93,9 +95,7 @@ void LoadDiskCacheQuotaSettings( disk_cache::settings::SetQuota(resource_type, default_quota); std::string directory = disk_cache::defaults::GetSubdirectory(resource_type); - settings->SetPersistentSetting( - directory, - std::make_unique(static_cast(default_quota))); + settings->Set(directory, base::Value(static_cast(default_quota))); } } @@ -204,13 +204,12 @@ URLRequestContext::URLRequestContext( new ProxyConfigService(proxy_config)), net::NetLog::Get(), /*quick_check_enabled=*/true)); + auto quic_context = std::make_unique(); + quic_context->params()->supported_versions = + quic::ParsedQuicVersionVector{quic::ParsedQuicVersion::Q046()}; + url_request_context_builder->set_quic_context(std::move(quic_context)); + #if !defined(QUIC_DISABLED_FOR_STARBOARD) -#ifndef COBALT_PENDING_CLEAN_UP - // TODO: Confirm this is not needed. - // ack decimation significantly increases download bandwidth on low-end - // android devices. - SetQuicFlag(&FLAGS_quic_reloadable_flag_quic_enable_ack_decimation, true); -#endif bool quic_enabled = configuration::Configuration::GetInstance()->CobaltEnableQuic(); if (quic_enabled) { @@ -289,9 +288,10 @@ URLRequestContext::URLRequestContext( /* max_bytes */ max_cache_bytes, url_request_context)); http_cache->set_can_disable_by_mime_type(true); if (persistent_settings != nullptr) { - auto cache_enabled = - persistent_settings->GetPersistentSettingAsBool( - disk_cache::kCacheEnabledPersistentSettingsKey, true); + base::Value value; + persistent_settings->Get( + disk_cache::kCacheEnabledPersistentSettingsKey, &value); + auto cache_enabled = value.GetIfBool().value_or(true); disk_cache::settings::SetCacheEnabled(cache_enabled); if (!cache_enabled) { http_cache->set_mode(net::HttpCache::Mode::DISABLE); @@ -344,13 +344,12 @@ void URLRequestContext::OnQuicToggle(const std::string& message) { void URLRequestContext::UpdateCacheSizeSetting(disk_cache::ResourceType type, uint32_t bytes) { CHECK(cache_persistent_settings_); - cache_persistent_settings_->SetPersistentSetting( - disk_cache::defaults::GetSubdirectory(type), - std::make_unique(static_cast(bytes))); + cache_persistent_settings_->Set(disk_cache::defaults::GetSubdirectory(type), + base::Value(static_cast(bytes))); } void URLRequestContext::ValidateCachePersistentSettings() { - cache_persistent_settings_->ValidatePersistentSettings(); + cache_persistent_settings_->Validate(); } void URLRequestContext::AssociateKeyWithResourceType( diff --git a/cobalt/overlay_info/overlay_info_registry.cc b/cobalt/overlay_info/overlay_info_registry.cc index 59163ca77a58..ca1df8d46d3e 100644 --- a/cobalt/overlay_info/overlay_info_registry.cc +++ b/cobalt/overlay_info/overlay_info_registry.cc @@ -14,10 +14,11 @@ #include "cobalt/overlay_info/overlay_info_registry.h" +#include + #include "base/logging.h" #include "base/memory/singleton.h" -#include "starboard/common/mutex.h" -#include "starboard/common/string.h" +#include "base/synchronization/lock.h" namespace cobalt { namespace overlay_info { @@ -46,7 +47,7 @@ class OverlayInfoRegistryImpl { friend struct base::DefaultSingletonTraits; bool enabled_ = true; - starboard::Mutex mutex_; + base::Lock mutex_; std::string infos_; }; @@ -58,7 +59,7 @@ OverlayInfoRegistryImpl* OverlayInfoRegistryImpl::GetInstance() { } void OverlayInfoRegistryImpl::Disable() { - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); enabled_ = false; infos_.clear(); } @@ -83,7 +84,7 @@ void OverlayInfoRegistryImpl::Register(const char* category, const char* data) { void OverlayInfoRegistryImpl::RetrieveAndClear(std::string* infos) { DCHECK(infos); - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); if (enabled_) { infos->swap(infos_); infos_.clear(); diff --git a/cobalt/persistent_storage/persistent_settings.cc b/cobalt/persistent_storage/persistent_settings.cc index ada6424385bb..ce943eae9760 100644 --- a/cobalt/persistent_storage/persistent_settings.cc +++ b/cobalt/persistent_storage/persistent_settings.cc @@ -18,11 +18,9 @@ #include #include "base/bind.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "cobalt/base/task_runner_util.h" -#include "components/prefs/json_pref_store.h" -#include "starboard/common/file.h" -#include "starboard/common/log.h" #include "starboard/configuration_constants.h" #include "starboard/system.h" @@ -30,7 +28,8 @@ namespace cobalt { namespace persistent_storage { void PersistentSettings::WillDestroyCurrentMessageLoop() { - // Clear all member variables allocated from the thread. + if (!pref_store_) return; + base::AutoLock auto_lock(pref_store_lock_); pref_store_.reset(); } @@ -42,15 +41,14 @@ PersistentSettings::PersistentSettings(const std::string& file_name) std::vector storage_dir(kSbFileMaxPath, 0); SbSystemGetPath(kSbSystemPathCacheDirectory, storage_dir.data(), kSbFileMaxPath); - persistent_settings_file_ = - std::string(storage_dir.data()) + kSbFileSepString + file_name; - LOG(INFO) << "Persistent settings file path: " << persistent_settings_file_; - - task_runner()->PostTask(FROM_HERE, - base::Bind(&PersistentSettings::InitializePrefStore, - base::Unretained(this))); - pref_store_initialized_.Wait(); - destruction_observer_added_.Wait(); + file_path_ = + base::FilePath(std::string(storage_dir.data())).Append(file_name); + DLOG(INFO) << "Persistent settings file path: " << file_path_; + + Run(FROM_HERE, + base::Bind(&PersistentSettings::InitializePrefStore, + base::Unretained(this)), + /*blocking=*/true); } PersistentSettings::~PersistentSettings() { @@ -58,183 +56,128 @@ PersistentSettings::~PersistentSettings() { DCHECK(thread_.IsRunning()); // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); + Fence(FROM_HERE); thread_.Stop(); } void PersistentSettings::InitializePrefStore() { - DCHECK_EQ(base::SequencedTaskRunner::GetCurrentDefault(), task_runner()); + DCHECK(task_runner()->RunsTasksInCurrentSequence()); // Register as a destruction observer to shut down the thread once all // pending tasks have been executed and the task runner is about to be // destroyed. This allows us to safely stop the thread, drain the task queue, // then destroy the internal components before the task runner is reset. // No posted tasks will be executed once the thread is stopped. base::CurrentThread::Get()->AddDestructionObserver(this); + // Read preferences into memory. - { - base::AutoLock auto_lock(pref_store_lock_); - pref_store_ = base::MakeRefCounted( - base::FilePath(persistent_settings_file_)); - pref_store_->ReadPrefs(); - persistent_settings_ = pref_store_->GetValues(); - pref_store_initialized_.Signal(); - } - // Remove settings file and do not allow writes to the file until the - // |ValidatePersistentSettings()| is called. - starboard::SbFileDeleteRecursive(persistent_settings_file_.c_str(), true); - destruction_observer_added_.Signal(); -} + pref_store_ = base::MakeRefCounted(file_path_); + pref_store_->ReadPrefs(); -void PersistentSettings::ValidatePersistentSettings(bool blocking) { - task_runner()->PostTask( - FROM_HERE, - base::BindOnce(&PersistentSettings::ValidatePersistentSettingsHelper, - base::Unretained(this), blocking)); + // Remove settings file and do not allow writes to the file until |Validate()| + // is called. + base::DeleteFile(file_path_); } -void PersistentSettings::ValidatePersistentSettingsHelper(bool blocking) { - DCHECK_EQ(base::SequencedTaskRunner::GetCurrentDefault(), task_runner()); - if (!validated_initial_settings_) { - base::AutoLock auto_lock(pref_store_lock_); - validated_initial_settings_ = true; - CommitPendingWrite(blocking); +void PersistentSettings::Validate() { + if (validated_initial_settings_) return; + if (!task_runner()->RunsTasksInCurrentSequence()) { + Run(FROM_HERE, + base::BindOnce(&PersistentSettings::Validate, base::Unretained(this))); + return; + } + validated_initial_settings_ = true; + // Report a dummy value as "dirty", so that commit actually writes + pref_store_->ReportValueChanged("", 0); + pref_store_->CommitPendingWrite(); +} + +void PersistentSettings::Get(const std::string& key, base::Value* value) const { + if (!pref_store_) return; + if (!task_runner()->RunsTasksInCurrentSequence()) { + Run(FROM_HERE, + base::BindOnce(&PersistentSettings::Get, base::Unretained(this), key, + value), + /*blocking=*/true); + return; } -} - -bool PersistentSettings::GetPersistentSettingAsBool(const std::string& key, - bool default_setting) { - // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); base::AutoLock auto_lock(pref_store_lock_); - absl::optional result = persistent_settings_.FindBool(key); - return result.value_or(default_setting); + const base::Value* pref_value = nullptr; + pref_store_->GetValue(key, &pref_value); + *value = std::move(pref_value ? pref_value->Clone() : base::Value()); } -int PersistentSettings::GetPersistentSettingAsInt(const std::string& key, - int default_setting) { - // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); - base::AutoLock auto_lock(pref_store_lock_); - absl::optional result = persistent_settings_.FindInt(key); - return result.value_or(default_setting); +WriteablePrefStore::PrefWriteFlags PersistentSettings::GetPrefWriteFlags() + const { + return validated_initial_settings_ + ? WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS + : WriteablePrefStore::LOSSY_PREF_WRITE_FLAG; } -double PersistentSettings::GetPersistentSettingAsDouble( - const std::string& key, double default_setting) { - // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); - base::AutoLock auto_lock(pref_store_lock_); - absl::optional result = persistent_settings_.FindDouble(key); - return result.value_or(default_setting); -} -std::string PersistentSettings::GetPersistentSettingAsString( - const std::string& key, const std::string& default_setting) { - // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); +void PersistentSettings::Set(const std::string& key, base::Value value) { + if (!pref_store_) return; + if (!task_runner()->RunsTasksInCurrentSequence()) { + Run(FROM_HERE, + base::BindOnce(&PersistentSettings::Set, base::Unretained(this), key, + std::move(value))); + return; + } base::AutoLock auto_lock(pref_store_lock_); - const std::string* result = persistent_settings_.FindString(key); - if (result) return *result; - return default_setting; + pref_store_->SetValue(key, std::move(value), GetPrefWriteFlags()); + if (validated_initial_settings_) pref_store_->CommitPendingWrite(); } -std::vector PersistentSettings::GetPersistentSettingAsList( - const std::string& key) { - // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); - base::AutoLock auto_lock(pref_store_lock_); - const base::Value::List* result = persistent_settings_.FindList(key); - std::vector values; - if (result) { - for (const auto& value : *result) { - values.emplace_back(value.Clone()); - } +void PersistentSettings::Remove(const std::string& key) { + if (!pref_store_) return; + if (!task_runner()->RunsTasksInCurrentSequence()) { + Run(FROM_HERE, base::BindOnce(&PersistentSettings::Remove, + base::Unretained(this), key)); + return; } - return values; -} - -base::flat_map> -PersistentSettings::GetPersistentSettingAsDictionary(const std::string& key) { - // Wait for all previously posted tasks to finish. - base::task_runner_util::WaitForFence(thread_.task_runner(), FROM_HERE); base::AutoLock auto_lock(pref_store_lock_); - base::Value::Dict* result = persistent_settings_.FindDict(key); - base::flat_map> dict; - if (result) { - for (base::Value::Dict::iterator it = result->begin(); it != result->end(); - ++it) { - dict.insert(std::make_pair( - it->first, base::Value::ToUniquePtrValue(std::move(it->second)))); - } - return dict; - } - return dict; -} - -void PersistentSettings::SetPersistentSetting( - const std::string& key, std::unique_ptr value, bool blocking) { - task_runner()->PostTask( - FROM_HERE, - base::BindOnce(&PersistentSettings::SetPersistentSettingHelper, - base::Unretained(this), key, std::move(value), blocking)); + pref_store_->RemoveValue(key, GetPrefWriteFlags()); + if (validated_initial_settings_) pref_store_->CommitPendingWrite(); } -void PersistentSettings::SetPersistentSettingHelper( - const std::string& key, std::unique_ptr value, bool blocking) { - DCHECK_EQ(base::SequencedTaskRunner::GetCurrentDefault(), task_runner()); - base::AutoLock auto_lock(pref_store_lock_); - pref_store_->SetValue(key, base::Value::FromUniquePtrValue(std::move(value)), - WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); - persistent_settings_ = pref_store_->GetValues(); - if (validated_initial_settings_) { - CommitPendingWrite(blocking); +void PersistentSettings::RemoveAll() { + if (!pref_store_) return; + if (!task_runner()->RunsTasksInCurrentSequence()) { + Run(FROM_HERE, + base::BindOnce(&PersistentSettings::RemoveAll, base::Unretained(this))); + return; } -} - -void PersistentSettings::RemovePersistentSetting(const std::string& key, - bool blocking) { - task_runner()->PostTask( - FROM_HERE, - base::BindOnce(&PersistentSettings::RemovePersistentSettingHelper, - base::Unretained(this), key, blocking)); -} - -void PersistentSettings::RemovePersistentSettingHelper(const std::string& key, - bool blocking) { - DCHECK_EQ(base::SequencedTaskRunner::GetCurrentDefault(), task_runner()); base::AutoLock auto_lock(pref_store_lock_); - pref_store_->RemoveValue(key, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); - persistent_settings_ = pref_store_->GetValues(); - if (validated_initial_settings_) { - CommitPendingWrite(blocking); - } + base::DeleteFile(file_path_); + pref_store_->ReadPrefs(); } -void PersistentSettings::DeletePersistentSettings() { - task_runner()->PostTask( - FROM_HERE, - base::BindOnce(&PersistentSettings::DeletePersistentSettingsHelper, - base::Unretained(this))); +void PersistentSettings::WaitForPendingFileWrite() { + if (!pref_store_) return; + base::WaitableEvent done; + Run(FROM_HERE, base::BindOnce(&JsonPrefStore::CommitPendingWrite, + pref_store_->AsWeakPtr(), base::OnceClosure(), + base::BindOnce(&base::WaitableEvent::Signal, + base::Unretained(&done)))); + done.Wait(); } -void PersistentSettings::DeletePersistentSettingsHelper() { - DCHECK_EQ(base::SequencedTaskRunner::GetCurrentDefault(), task_runner()); - base::AutoLock auto_lock(pref_store_lock_); - starboard::SbFileDeleteRecursive(persistent_settings_file_.c_str(), true); - pref_store_->ReadPrefs(); - persistent_settings_ = pref_store_->GetValues(); +void PersistentSettings::Fence(const base::Location& location) { + Run(location, base::OnceClosure(), /*blocking=*/true); } -void PersistentSettings::CommitPendingWrite(bool blocking) { - if (blocking) { - base::WaitableEvent written; - pref_store_->CommitPendingWrite( - base::OnceClosure(), - base::BindOnce(&base::WaitableEvent::Signal, Unretained(&written))); - written.Wait(); - } else { - pref_store_->CommitPendingWrite(); - } +void PersistentSettings::Run(const base::Location& location, + base::OnceClosure task, bool blocking) const { + DCHECK(!task_runner()->RunsTasksInCurrentSequence()); + std::unique_ptr done; + if (blocking) done.reset(new base::WaitableEvent()); + task_runner()->PostTask( + location, base::BindOnce( + [](base::OnceClosure task, base::WaitableEvent* done) { + if (task) std::move(task).Run(); + if (done) done->Signal(); + }, + std::move(task), done.get())); + if (done) done->Wait(); } } // namespace persistent_storage diff --git a/cobalt/persistent_storage/persistent_settings.h b/cobalt/persistent_storage/persistent_settings.h index 010254b3d31c..a2b15948dc33 100644 --- a/cobalt/persistent_storage/persistent_settings.h +++ b/cobalt/persistent_storage/persistent_settings.h @@ -22,6 +22,7 @@ #include "base/bind_helpers.h" #include "base/containers/flat_map.h" +#include "base/files/file_path.h" #include "base/functional/callback_forward.h" #include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" @@ -29,9 +30,14 @@ #include "base/task/sequenced_task_runner.h" #include "base/threading/thread.h" #include "base/values.h" -#include "components/prefs/persistent_pref_store.h" +#include "components/prefs/json_pref_store.h" namespace cobalt { + +namespace watchdog { +class WatchdogTest; +} + namespace persistent_storage { // PersistentSettings manages Cobalt settings that persist from one application @@ -40,71 +46,54 @@ namespace persistent_storage { // PersistentSettings uses JsonPrefStore for most of its functionality. // JsonPrefStore maintains thread safety by requiring that all access occurs on // the Sequence that created it. -class PersistentSettings : public base::CurrentThread::DestructionObserver { +class PersistentSettings : public base::CurrentThread::DestructionObserver, + public base::SupportsWeakPtr { public: explicit PersistentSettings(const std::string& file_name); ~PersistentSettings(); - // The task runner this object is running on. - base::SequencedTaskRunner* task_runner() const { - return thread_.task_runner(); - } - - // From base::CurrentThread::DestructionObserver. + // base::CurrentThread::DestructionObserver void WillDestroyCurrentMessageLoop() override; // Validates persistent settings by restoring the file on successful start up. - void ValidatePersistentSettings(bool blocking = false); - - // Getters and Setters for persistent settings. - bool GetPersistentSettingAsBool(const std::string& key, bool default_setting); - - int GetPersistentSettingAsInt(const std::string& key, int default_setting); - - double GetPersistentSettingAsDouble(const std::string& key, - double default_setting); - - std::string GetPersistentSettingAsString(const std::string& key, - const std::string& default_setting); + void Validate(); - std::vector GetPersistentSettingAsList(const std::string& key); + void Get(const std::string& key, base::Value* value) const; - base::flat_map> - GetPersistentSettingAsDictionary(const std::string& key); + void Set(const std::string& key, base::Value value); - void SetPersistentSetting(const std::string& key, - std::unique_ptr value, - bool blocking = false); + void Remove(const std::string& key); - void RemovePersistentSetting(const std::string& key, bool blocking = false); - - void DeletePersistentSettings(); + void RemoveAll(); private: - // Called by the constructor to initialize pref_store_ from - // the dedicated thread_ as a JSONPrefStore. + friend class PersistentSettingTest; + friend class cobalt::watchdog::WatchdogTest; + void InitializePrefStore(); - void ValidatePersistentSettingsHelper(bool blocking); + WriteablePrefStore::PrefWriteFlags GetPrefWriteFlags() const; - void SetPersistentSettingHelper(const std::string& key, - std::unique_ptr value, - bool blocking); + void CommitPendingWrite(); - void RemovePersistentSettingHelper(const std::string& key, bool blocking); + void Run(const base::Location& location, base::OnceClosure closure, + bool blocking = false) const; - void DeletePersistentSettingsHelper(); + void Fence(const base::Location& location); - void CommitPendingWrite(bool blocking); + // The task runner this object is running on. + base::SequencedTaskRunner* task_runner() const { + return thread_.task_runner(); + } + + void WaitForPendingFileWrite(); // Persistent settings file path. - std::string persistent_settings_file_; + base::FilePath file_path_; // PrefStore used for persistent settings. - scoped_refptr pref_store_; - - // Persistent settings dictionary. - base::Value::Dict persistent_settings_; + scoped_refptr pref_store_; + mutable base::Lock pref_store_lock_; // The thread created and owned by PersistentSettings. All pref_store_ // methods must be called from this thread. @@ -113,21 +102,6 @@ class PersistentSettings : public base::CurrentThread::DestructionObserver { // Flag indicating whether or not initial persistent settings have been // validated. bool validated_initial_settings_; - - // This event is used to signal when Initialize has been called and - // pref_store_ mutations can now occur. - base::WaitableEvent pref_store_initialized_ = { - base::WaitableEvent::ResetPolicy::MANUAL, - base::WaitableEvent::InitialState::NOT_SIGNALED}; - - // This event is used to signal when the destruction observers have been - // added to the task runner. This is then used in Stop() to ensure that - // processing doesn't continue until the thread is cleanly shutdown. - base::WaitableEvent destruction_observer_added_ = { - base::WaitableEvent::ResetPolicy::MANUAL, - base::WaitableEvent::InitialState::NOT_SIGNALED}; - - base::Lock pref_store_lock_; }; } // namespace persistent_storage diff --git a/cobalt/persistent_storage/persistent_settings_test.cc b/cobalt/persistent_storage/persistent_settings_test.cc index d653c9233f7e..ad05d125fcfa 100644 --- a/cobalt/persistent_storage/persistent_settings_test.cc +++ b/cobalt/persistent_storage/persistent_settings_test.cc @@ -20,7 +20,6 @@ #include "base/test/task_environment.h" #include "base/values.h" #include "starboard/common/file.h" -#include "starboard/common/log.h" #include "starboard/configuration_constants.h" #include "testing/gtest/include/gtest/gtest.h" @@ -48,307 +47,114 @@ class PersistentSettingTest : public testing::Test { void SetUp() final { starboard::SbFileDeleteRecursive(persistent_settings_file_.c_str(), true); + persistent_settings_ = + std::make_unique(kPersistentSettingsJson); } void TearDown() final { starboard::SbFileDeleteRecursive(persistent_settings_file_.c_str(), true); } + void Fence(const base::Location& location) { + persistent_settings_->Fence(location); + } + + void WaitForPendingFileWrite() { + persistent_settings_->WaitForPendingFileWrite(); + } + base::test::TaskEnvironment scoped_task_environment_; std::string persistent_settings_file_; + std::unique_ptr persistent_settings_; }; -TEST_F(PersistentSettingTest, GetDefaultBool) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - // does not exist - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); - - // exists but invalid - persistent_settings->SetPersistentSetting("key", - std::make_unique(4.2)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); -} - -TEST_F(PersistentSettingTest, GetSetBool) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - persistent_settings->SetPersistentSetting( - "key", std::make_unique(true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(false)); - EXPECT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); -} - -TEST_F(PersistentSettingTest, GetDefaultInt) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - // does not exist - ASSERT_EQ(-1, persistent_settings->GetPersistentSettingAsInt("key", -1)); - ASSERT_EQ(0, persistent_settings->GetPersistentSettingAsInt("key", 0)); - ASSERT_EQ(42, persistent_settings->GetPersistentSettingAsInt("key", 42)); - - // exists but invalid - persistent_settings->SetPersistentSetting("key", - std::make_unique(4.2)); - EXPECT_EQ(8, persistent_settings->GetPersistentSettingAsInt("key", 8)); -} - -TEST_F(PersistentSettingTest, GetSetInt) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - persistent_settings->SetPersistentSetting("key", - std::make_unique(-1)); - EXPECT_EQ(-1, persistent_settings->GetPersistentSettingAsInt("key", 8)); - persistent_settings->SetPersistentSetting("key", - std::make_unique(0)); - EXPECT_EQ(0, persistent_settings->GetPersistentSettingAsInt("key", 8)); - persistent_settings->SetPersistentSetting("key", - std::make_unique(42)); - EXPECT_EQ(42, persistent_settings->GetPersistentSettingAsInt("key", 8)); -} - -TEST_F(PersistentSettingTest, GetDefaultDouble) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - // does not exist - ASSERT_EQ(-1.1, - persistent_settings->GetPersistentSettingAsDouble("key", -1.1)); - ASSERT_EQ(0.1, persistent_settings->GetPersistentSettingAsDouble("key", 0.1)); - ASSERT_EQ(42.1, - persistent_settings->GetPersistentSettingAsDouble("key", 42.1)); - - // exists but invalid - persistent_settings->SetPersistentSetting( - "key", std::make_unique(true)); - EXPECT_EQ(8.1, persistent_settings->GetPersistentSettingAsDouble("key", 8.1)); -} - -TEST_F(PersistentSettingTest, GetSetDouble) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - persistent_settings->SetPersistentSetting( - "key", std::make_unique(-1.1)); - EXPECT_EQ(-1.1, - persistent_settings->GetPersistentSettingAsDouble("key", 8.1)); - persistent_settings->SetPersistentSetting("key", - std::make_unique(0.1)); - EXPECT_EQ(0.1, persistent_settings->GetPersistentSettingAsDouble("key", 8.1)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(42.1)); - EXPECT_EQ(42.1, - persistent_settings->GetPersistentSettingAsDouble("key", 8.1)); -} - -TEST_F(PersistentSettingTest, GetDefaultString) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - // does not exist - ASSERT_EQ("", persistent_settings->GetPersistentSettingAsString("key", "")); - ASSERT_EQ("hello there", persistent_settings->GetPersistentSettingAsString( - "key", "hello there")); - ASSERT_EQ("42", - persistent_settings->GetPersistentSettingAsString("key", "42")); - ASSERT_EQ("\n", - persistent_settings->GetPersistentSettingAsString("key", "\n")); - ASSERT_EQ("\\n", - persistent_settings->GetPersistentSettingAsString("key", "\\n")); - - // exists but invalid - persistent_settings->SetPersistentSetting("key", - std::make_unique(4.2)); - EXPECT_EQ("hello", - persistent_settings->GetPersistentSettingAsString("key", "hello")); -} - -TEST_F(PersistentSettingTest, GetSetString) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - persistent_settings->SetPersistentSetting("key", - std::make_unique("")); - EXPECT_EQ("", - persistent_settings->GetPersistentSettingAsString("key", "hello")); - persistent_settings->SetPersistentSetting( - "key", std::make_unique("hello there")); - EXPECT_EQ("hello there", - persistent_settings->GetPersistentSettingAsString("key", "hello")); - persistent_settings->SetPersistentSetting( - "key", std::make_unique("42")); - EXPECT_EQ("42", - persistent_settings->GetPersistentSettingAsString("key", "hello")); - persistent_settings->SetPersistentSetting( - "key", std::make_unique("\n")); - EXPECT_EQ("\n", - persistent_settings->GetPersistentSettingAsString("key", "hello")); - persistent_settings->SetPersistentSetting( - "key", std::make_unique("\\n")); - EXPECT_EQ("\\n", - persistent_settings->GetPersistentSettingAsString("key", "hello")); -} - -TEST_F(PersistentSettingTest, GetSetList) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - base::Value list(base::Value::Type::LIST); - list.GetList().Append("hello"); - persistent_settings->SetPersistentSetting( - "key", base::Value::ToUniquePtrValue(list.Clone())); - auto test_list = persistent_settings->GetPersistentSettingAsList("key"); - EXPECT_FALSE(test_list.empty()); - EXPECT_EQ(1, test_list.size()); - EXPECT_TRUE(test_list[0].is_string()); - EXPECT_EQ("hello", test_list[0].GetString()); - - list.GetList().Append("there"); - persistent_settings->SetPersistentSetting( - "key", base::Value::ToUniquePtrValue(list.Clone())); - test_list = persistent_settings->GetPersistentSettingAsList("key"); - EXPECT_FALSE(test_list.empty()); - EXPECT_EQ(2, test_list.size()); - EXPECT_TRUE(test_list[0].is_string()); - EXPECT_EQ("hello", test_list[0].GetString()); - EXPECT_TRUE(test_list[1].is_string()); - EXPECT_EQ("there", test_list[1].GetString()); - - list.GetList().Append(42); - persistent_settings->SetPersistentSetting( - "key", base::Value::ToUniquePtrValue(list.Clone())); - test_list = persistent_settings->GetPersistentSettingAsList("key"); - EXPECT_FALSE(test_list.empty()); - EXPECT_EQ(3, test_list.size()); - EXPECT_TRUE(test_list[0].is_string()); - EXPECT_EQ("hello", test_list[0].GetString()); - EXPECT_TRUE(test_list[1].is_string()); - EXPECT_EQ("there", test_list[1].GetString()); - EXPECT_TRUE(test_list[2].is_int()); - EXPECT_EQ(42, test_list[2].GetInt()); -} - -TEST_F(PersistentSettingTest, GetSetDictionary) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - base::Value dict(base::Value::Type::DICT); - dict.GetDict().Set("key_string", "hello"); - persistent_settings->SetPersistentSetting( - "key", base::Value::ToUniquePtrValue(dict.Clone())); - auto test_dict = persistent_settings->GetPersistentSettingAsDictionary("key"); - EXPECT_FALSE(test_dict.empty()); - EXPECT_EQ(1, test_dict.size()); - EXPECT_TRUE(test_dict["key_string"]->is_string()); - EXPECT_EQ("hello", test_dict["key_string"]->GetString()); - - dict.GetDict().Set("key_int", 42); - persistent_settings->SetPersistentSetting( - "key", base::Value::ToUniquePtrValue(dict.Clone())); - test_dict = persistent_settings->GetPersistentSettingAsDictionary("key"); - EXPECT_FALSE(test_dict.empty()); - EXPECT_EQ(2, test_dict.size()); - EXPECT_TRUE(test_dict["key_string"]->is_string()); - EXPECT_EQ("hello", test_dict["key_string"]->GetString()); - EXPECT_TRUE(test_dict["key_int"]->is_int()); - EXPECT_EQ(42, test_dict["key_int"]->GetInt()); - - dict.GetDict().Set("http://127.0.0.1:45019/", "Dictionary URL Key Works!"); - persistent_settings->SetPersistentSetting( - "key", base::Value::ToUniquePtrValue(dict.Clone())); - test_dict = persistent_settings->GetPersistentSettingAsDictionary("key"); - EXPECT_FALSE(test_dict.empty()); - EXPECT_EQ(3, test_dict.size()); - EXPECT_TRUE(test_dict["key_string"]->is_string()); - EXPECT_EQ("hello", test_dict["key_string"]->GetString()); - EXPECT_TRUE(test_dict["key_int"]->is_int()); - EXPECT_EQ(42, test_dict["key_int"]->GetInt()); - EXPECT_TRUE(test_dict["http://127.0.0.1:45019/"]->is_string()); - EXPECT_EQ("Dictionary URL Key Works!", - test_dict["http://127.0.0.1:45019/"]->GetString()); +TEST_F(PersistentSettingTest, Set) { + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_TRUE(value.is_none()); + } + persistent_settings_->Set("key", base::Value(4.2)); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_EQ(4.2, value.GetIfDouble().value_or(0)); + } } -TEST_F(PersistentSettingTest, RemoveSetting) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->RemovePersistentSetting("key"); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); +TEST_F(PersistentSettingTest, Remove) { + persistent_settings_->Set("key", base::Value(true)); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_EQ(true, value.GetIfBool().value_or(false)); + } + persistent_settings_->Remove("key"); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_TRUE(value.is_none()); + } } -TEST_F(PersistentSettingTest, DeleteSettings) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->DeletePersistentSettings(); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); +TEST_F(PersistentSettingTest, RemoveAll) { + persistent_settings_->Set("key", base::Value(true)); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_EQ(true, value.GetIfBool().value_or(false)); + } + persistent_settings_->RemoveAll(); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_TRUE(value.is_none()); + } } -TEST_F(PersistentSettingTest, InvalidSettings) { - auto persistent_settings = - std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(true), true); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", false)); +TEST_F(PersistentSettingTest, PersistValidatedSettings) { + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_TRUE(value.is_none()); + } + persistent_settings_->Set("key", base::Value(true)); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_EQ(true, value.GetIfBool().value_or(false)); + } - persistent_settings = + persistent_settings_ = std::make_unique(kPersistentSettingsJson); - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(false), true); - EXPECT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); + persistent_settings_->Validate(); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_TRUE(value.is_none()); + } + persistent_settings_->Set("key", base::Value(true)); + Fence(FROM_HERE); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_EQ(true, value.GetIfBool().value_or(false)); + } + WaitForPendingFileWrite(); - persistent_settings = + persistent_settings_ = std::make_unique(kPersistentSettingsJson); - persistent_settings->ValidatePersistentSettings(); - ASSERT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool("key", false)); - persistent_settings->SetPersistentSetting( - "key", std::make_unique(true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", true)); - EXPECT_TRUE(persistent_settings->GetPersistentSettingAsBool("key", false)); + { + base::Value value; + persistent_settings_->Get("key", &value); + EXPECT_EQ(true, value.GetIfBool().value_or(false)); + } } } // namespace persistent_storage diff --git a/cobalt/renderer/backend/egl/graphics_system.cc b/cobalt/renderer/backend/egl/graphics_system.cc index 07444ade6cee..664750c924b8 100644 --- a/cobalt/renderer/backend/egl/graphics_system.cc +++ b/cobalt/renderer/backend/egl/graphics_system.cc @@ -28,7 +28,7 @@ #include "cobalt/renderer/backend/egl/texture.h" #include "cobalt/renderer/backend/egl/utils.h" #if defined(ENABLE_GLIMP_TRACING) -#include "glimp/tracing/tracing.h" // nogncheck +#include "internal/starboard/shared/glimp/tracing/tracing.h" #endif #include "cobalt/renderer/egl_and_gles.h" diff --git a/cobalt/renderer/backend/graphics_system_test.cc b/cobalt/renderer/backend/graphics_system_test.cc index 0100fc9fb4e4..0823b720f8de 100644 --- a/cobalt/renderer/backend/graphics_system_test.cc +++ b/cobalt/renderer/backend/graphics_system_test.cc @@ -17,11 +17,11 @@ #include #include +#include "base/logging.h" #include "base/optional.h" #include "base/time/time.h" #include "cobalt/renderer/backend/default_graphics_system.h" #include "cobalt/renderer/backend/graphics_context.h" -#include "starboard/common/time.h" #include "starboard/log.h" #include "testing/gtest/include/gtest/gtest.h" @@ -44,17 +44,18 @@ TEST(GraphicsSystemTest, FLAKY_GraphicsSystemCanBeInitializedOften) { graphics_system = CreateDefaultGraphicsSystem(); graphics_system.reset(); - int64_t start = starboard::CurrentMonotonicTime(); + int64_t start = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); for (int i = 0; i < kReferenceCount; ++i) { graphics_system = CreateDefaultGraphicsSystem(); graphics_system.reset(); } int64_t time_per_initialization_usec = - (starboard::CurrentMonotonicTime() - start) / kReferenceCount; - SB_LOG(INFO) << "Measured duration " - << time_per_initialization_usec / - base::Time::kMicrosecondsPerMillisecond - << "ms per initialization."; + ((base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() - start) / + kReferenceCount; + LOG(INFO) << "Measured duration " + << time_per_initialization_usec / + base::Time::kMicrosecondsPerMillisecond + << "ms per initialization."; // Graphics system initializations should not take more than the maximum of // 250ms or three times as long as the time we just measured. @@ -62,15 +63,15 @@ TEST(GraphicsSystemTest, FLAKY_GraphicsSystemCanBeInitializedOften) { std::max(3 * time_per_initialization_usec, 250 * base::Time::kMicrosecondsPerMillisecond); - int64_t last = starboard::CurrentMonotonicTime(); + int64_t last = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); for (int i = 0; i < 20; ++i) { graphics_system = CreateDefaultGraphicsSystem(); graphics_system.reset(); - int64_t now = starboard::CurrentMonotonicTime(); + int64_t now = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); int64_t elapsed_time_usec = now - last; - SB_LOG(INFO) << "Test duration " - << elapsed_time_usec / base::Time::kMicrosecondsPerMillisecond - << "ms."; + LOG(INFO) << "Test duration " + << elapsed_time_usec / base::Time::kMicrosecondsPerMillisecond + << "ms."; ASSERT_LT(elapsed_time_usec, maximum_time_usec_per_initialization); last = now; } @@ -89,7 +90,7 @@ TEST(GraphicsSystemTest, FLAKY_GraphicsContextCanBeInitializedOften) { graphics_context.reset(); graphics_system.reset(); - int64_t start = starboard::CurrentMonotonicTime(); + int64_t start = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); for (int i = 0; i < kReferenceCount; ++i) { graphics_system = CreateDefaultGraphicsSystem(); graphics_context = graphics_system->CreateGraphicsContext(); @@ -99,11 +100,12 @@ TEST(GraphicsSystemTest, FLAKY_GraphicsContextCanBeInitializedOften) { } int64_t time_per_initialization_usec = base::Time::kMicrosecondsPerMillisecond + - (starboard::CurrentMonotonicTime() - start) / kReferenceCount; - SB_LOG(INFO) << "Measured duration " - << time_per_initialization_usec / - base::Time::kMicrosecondsPerMillisecond - << "ms per initialization."; + ((base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() - start) / + kReferenceCount; + LOG(INFO) << "Measured duration " + << time_per_initialization_usec / + base::Time::kMicrosecondsPerMillisecond + << "ms per initialization."; // Graphics system and context initializations should not take more than the // maximum of 250ms or three times as long as the time we just measured. @@ -111,7 +113,7 @@ TEST(GraphicsSystemTest, FLAKY_GraphicsContextCanBeInitializedOften) { std::max(3 * time_per_initialization_usec, 250 * base::Time::kMicrosecondsPerMillisecond); - int64_t last = starboard::CurrentMonotonicTime(); + int64_t last = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); for (int i = 0; i < 20; ++i) { graphics_system = CreateDefaultGraphicsSystem(); graphics_context = graphics_system->CreateGraphicsContext(); @@ -119,11 +121,11 @@ TEST(GraphicsSystemTest, FLAKY_GraphicsContextCanBeInitializedOften) { graphics_context.reset(); graphics_system.reset(); - int64_t now = starboard::CurrentMonotonicTime(); + int64_t now = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); int64_t elapsed_time_usec = now - last; - SB_LOG(INFO) << "Test duration " - << elapsed_time_usec / base::Time::kMicrosecondsPerMillisecond - << "ms."; + LOG(INFO) << "Test duration " + << elapsed_time_usec / base::Time::kMicrosecondsPerMillisecond + << "ms."; ASSERT_LT(elapsed_time_usec, maximum_time_usec_per_initialization); last = now; } diff --git a/cobalt/renderer/egl_and_gles.h b/cobalt/renderer/egl_and_gles.h index fdf1839138f3..345979fbe365 100644 --- a/cobalt/renderer/egl_and_gles.h +++ b/cobalt/renderer/egl_and_gles.h @@ -16,7 +16,6 @@ #define COBALT_RENDERER_EGL_AND_GLES_H_ #include "base/logging.h" -#include "starboard/common/log.h" #include "starboard/configuration.h" #include "starboard/egl.h" #include "starboard/gles.h" diff --git a/cobalt/renderer/get_default_rasterizer_for_platform.cc b/cobalt/renderer/get_default_rasterizer_for_platform.cc index 863a1da06119..2b5573c66efc 100644 --- a/cobalt/renderer/get_default_rasterizer_for_platform.cc +++ b/cobalt/renderer/get_default_rasterizer_for_platform.cc @@ -16,6 +16,7 @@ #include +#include "base/logging.h" #include "cobalt/configuration/configuration.h" #include "cobalt/renderer/backend/graphics_context.h" #include "cobalt/renderer/rasterizer/egl/hardware_rasterizer.h" @@ -87,7 +88,7 @@ RasterizerInfo GetDefaultRasterizerForPlatform() { return {"skia", base::Bind(&CreateSkiaHardwareRasterizer)}; } } else { - SB_LOG(ERROR) << "GLES2 must be available."; + LOG(ERROR) << "GLES2 must be available."; SB_DCHECK(false); return {}; } diff --git a/cobalt/renderer/rasterizer/egl/draw_rect_linear_gradient.cc b/cobalt/renderer/rasterizer/egl/draw_rect_linear_gradient.cc index d638f0e2cd48..ab50f8dff066 100644 --- a/cobalt/renderer/rasterizer/egl/draw_rect_linear_gradient.cc +++ b/cobalt/renderer/rasterizer/egl/draw_rect_linear_gradient.cc @@ -20,7 +20,6 @@ #include "cobalt/renderer/backend/egl/utils.h" #include "cobalt/renderer/egl_and_gles.h" #include "egl/generated_shader_impl.h" -#include "starboard/common/log.h" #include "starboard/configuration.h" #include "starboard/memory.h" diff --git a/cobalt/renderer/rasterizer/pixel_test.cc b/cobalt/renderer/rasterizer/pixel_test.cc index bce79298d369..6015de828fe3 100644 --- a/cobalt/renderer/rasterizer/pixel_test.cc +++ b/cobalt/renderer/rasterizer/pixel_test.cc @@ -19,6 +19,7 @@ #include "base/files/file_path.h" #include "base/i18n/char_iterator.h" #include "base/i18n/icu_string_conversions.h" +#include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/path_service.h" #include "cobalt/base/unicode/character.h" @@ -4040,7 +4041,7 @@ scoped_refptr CreateMapToMeshTestRenderTree( TEST_F(PixelTest, MapToMeshRGBTest) { if (!IsMapToMeshEnabled()) { - SB_LOG(INFO) << "Map to mesh not supported. Test skipped."; + LOG(INFO) << "Map to mesh not supported. Test skipped."; return; } diff --git a/cobalt/renderer/rasterizer/skia/BUILD.gn b/cobalt/renderer/rasterizer/skia/BUILD.gn index 11146dfec974..34df6bcd0359 100644 --- a/cobalt/renderer/rasterizer/skia/BUILD.gn +++ b/cobalt/renderer/rasterizer/skia/BUILD.gn @@ -48,7 +48,7 @@ static_library("common") { "//cobalt/math", "//cobalt/render_tree", "//cobalt/renderer/rasterizer/skia/skia", - "//third_party/harfbuzz-ng", + "//third_party:freetype_harfbuzz", "//third_party/icu:icuuc", "//third_party/ots", ] diff --git a/cobalt/renderer/rasterizer/skia/harfbuzz_font.h b/cobalt/renderer/rasterizer/skia/harfbuzz_font.h index 770dbbfa1b8e..efaf789c9d8f 100644 --- a/cobalt/renderer/rasterizer/skia/harfbuzz_font.h +++ b/cobalt/renderer/rasterizer/skia/harfbuzz_font.h @@ -18,7 +18,7 @@ #include #include "cobalt/renderer/rasterizer/skia/font.h" -#include "third_party/harfbuzz-ng/src/hb.h" +#include "third_party/harfbuzz-ng/src/src/hb.h" #include "third_party/skia/include/core/SkTypeface.h" namespace cobalt { diff --git a/cobalt/renderer/rasterizer/skia/skia/BUILD.gn b/cobalt/renderer/rasterizer/skia/skia/BUILD.gn index d381670f3a23..13c7828f568b 100644 --- a/cobalt/renderer/rasterizer/skia/skia/BUILD.gn +++ b/cobalt/renderer/rasterizer/skia/skia/BUILD.gn @@ -119,7 +119,7 @@ skia_common("skia_library") { ":skia_library_no_asan", "//base", "//starboard/common", - "//third_party/freetype", + "//third_party:freetype_harfbuzz", "//third_party/libpng", "//third_party/skia/third_party/skcms", "//third_party/zlib", @@ -167,7 +167,7 @@ skia_common("skia") { "//cobalt/renderer:renderer_headers_only", "//starboard:starboard_headers_only", "//starboard/common", - "//third_party/freetype", + "//third_party:freetype_harfbuzz", "//third_party/libxml", ] diff --git a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc index cb5bf0a641a4..d5cec3ec14cd 100644 --- a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc +++ b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontMgr_cobalt.cc @@ -24,6 +24,7 @@ #include "SkTSearch.h" #include "base/base_switches.h" #include "base/command_line.h" +#include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/trace_event/trace_event.h" #include "cobalt/base/language.h" @@ -397,8 +398,8 @@ void SkFontMgr_Cobalt::BuildNameToFamilyMap( std::make_pair(family_info.names[j].c_str(), new_family.get())); } else { is_duplicate_font = true; - SB_LOG(WARNING) << "Duplicate Font name: \"" - << family_info.names[j].c_str() << "\""; + LOG(WARNING) << "Duplicate Font name: \"" + << family_info.names[j].c_str() << "\""; } } } @@ -438,8 +439,8 @@ void SkFontMgr_Cobalt::BuildNameToFamilyMap( is_duplicate_font_face = true; const std::string font_face_name_type = i == 0 ? "Full Font" : "Postscript"; - SB_LOG(WARNING) << "Duplicate " << font_face_name_type << " name: \"" - << font_face_name << "\""; + LOG(WARNING) << "Duplicate " << font_face_name_type << " name: \"" + << font_face_name << "\""; } } } diff --git a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc index ebfb60d861d1..9f57139bb0ce 100644 --- a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc +++ b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkFontStyleSet_cobalt.cc @@ -24,7 +24,6 @@ #include "base/trace_event/trace_event.h" #include "cobalt/renderer/rasterizer/skia/skia/src/ports/SkFreeType_cobalt.h" #include "cobalt/renderer/rasterizer/skia/skia/src/ports/SkTypeface_cobalt.h" -#include "starboard/common/string.h" #include "third_party/skia/src/utils/SkOSPath.h" namespace { diff --git a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkTime_cobalt.cc b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkTime_cobalt.cc index 1e11ae0bbbf7..1ac140e2884b 100644 --- a/cobalt/renderer/rasterizer/skia/skia/src/ports/SkTime_cobalt.cc +++ b/cobalt/renderer/rasterizer/skia/skia/src/ports/SkTime_cobalt.cc @@ -16,7 +16,6 @@ #include "SkTime.h" #include "SkTypes.h" #include "base/time/time.h" -#include "starboard/common/time.h" // Taken from SkTime.cpp. void SkTime::DateTime::toISO8601(SkString* dst) const { @@ -52,6 +51,6 @@ void SkTime::GetDateTime(DateTime* dt) { } double SkTime::GetNSecs() { - return starboard::CurrentMonotonicTime() * + return (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() * base::Time::kNanosecondsPerMicrosecond; } diff --git a/cobalt/renderer/rasterizer/skia/skottie_animation.cc b/cobalt/renderer/rasterizer/skia/skottie_animation.cc index 2d954ee6c540..e7ef16e92bd7 100644 --- a/cobalt/renderer/rasterizer/skia/skottie_animation.cc +++ b/cobalt/renderer/rasterizer/skia/skottie_animation.cc @@ -27,6 +27,11 @@ SkottieAnimation::SkottieAnimation(const char* data, size_t length) ResetRenderCache(); skottie::Animation::Builder builder; skottie_animation_ = builder.make(data, length); + DCHECK(skottie_animation_); + if (!skottie_animation_) { + LOG(ERROR) << "Lottie animation failed to load!"; + return; + } animation_size_ = math::Size(skottie_animation_->size().width(), skottie_animation_->size().height()); json_size_in_bytes_ = builder.getStats().fJsonSize; @@ -34,6 +39,8 @@ SkottieAnimation::SkottieAnimation(const char* data, size_t length) void SkottieAnimation::SetAnimationTimeInternal( base::TimeDelta animate_function_time) { + if (!skottie_animation_) return; + // Seeking to a particular frame takes precedence over normal playback. // Check whether "seek()" has been called but has yet to occur. if (seek_counter_ != properties_.seek_counter) { @@ -134,10 +141,12 @@ void SkottieAnimation::SetAnimationTimeInternal( void SkottieAnimation::UpdateRenderCache(SkCanvas* render_target, const math::SizeF& size) { DCHECK(render_target); + DCHECK(skottie_animation_); if (cached_animation_time_ == last_updated_animation_time_) { // The render cache is already up-to-date. return; } + if (!skottie_animation_) return; cached_animation_time_ = last_updated_animation_time_; SkRect bounding_rect = SkRect::MakeWH(size.width(), size.height()); @@ -149,11 +158,13 @@ void SkottieAnimation::UpdateRenderCache(SkCanvas* render_target, void SkottieAnimation::UpdateAnimationFrameAndAnimateFunctionTimes( base::TimeDelta current_animation_time, base::TimeDelta current_animate_function_time) { + DCHECK(skottie_animation_); last_updated_animate_function_time_ = current_animate_function_time; if (current_animation_time == last_updated_animation_time_) { return; } + if (!skottie_animation_) return; // Dispatch a frame event every time a new frame is entered, and if the // animation is not complete. diff --git a/cobalt/renderer/rasterizer/skia/text_shaper.h b/cobalt/renderer/rasterizer/skia/text_shaper.h index bc2cbb96e95c..4508013da2cc 100644 --- a/cobalt/renderer/rasterizer/skia/text_shaper.h +++ b/cobalt/renderer/rasterizer/skia/text_shaper.h @@ -27,8 +27,8 @@ #include "cobalt/renderer/rasterizer/skia/font.h" #include "cobalt/renderer/rasterizer/skia/glyph_buffer.h" #include "cobalt/renderer/rasterizer/skia/harfbuzz_font.h" -#include "third_party/harfbuzz-ng/src/hb-icu.h" -#include "third_party/harfbuzz-ng/src/hb.h" +#include "third_party/harfbuzz-ng/src/src/hb-icu.h" +#include "third_party/harfbuzz-ng/src/src/hb.h" #include "third_party/icu/source/common/unicode/uscript.h" #include "third_party/skia/include/core/SkTextBlob.h" diff --git a/cobalt/renderer/test/jpeg_utils/BUILD.gn b/cobalt/renderer/test/jpeg_utils/BUILD.gn index da714b7e19c6..6f8b3efc33a6 100644 --- a/cobalt/renderer/test/jpeg_utils/BUILD.gn +++ b/cobalt/renderer/test/jpeg_utils/BUILD.gn @@ -20,6 +20,6 @@ static_library("jpeg_utils") { deps = [ "//base", - "//third_party/libjpeg-turbo:libjpeg", + "//third_party/libjpeg_turbo:libjpeg", ] } diff --git a/cobalt/renderer/test/jpeg_utils/jpeg_encode.cc b/cobalt/renderer/test/jpeg_utils/jpeg_encode.cc index 968b829114c2..e44ba9114e2d 100644 --- a/cobalt/renderer/test/jpeg_utils/jpeg_encode.cc +++ b/cobalt/renderer/test/jpeg_utils/jpeg_encode.cc @@ -21,7 +21,7 @@ #include "base/trace_event/trace_event.h" #include "starboard/memory.h" -#include "third_party/libjpeg-turbo/turbojpeg.h" +#include "third_party/libjpeg_turbo/turbojpeg.h" namespace cobalt { namespace renderer { diff --git a/cobalt/renderer/test/png_utils/png_decode.cc b/cobalt/renderer/test/png_utils/png_decode.cc index 69d597369cbf..9ae38172e2e6 100644 --- a/cobalt/renderer/test/png_utils/png_decode.cc +++ b/cobalt/renderer/test/png_utils/png_decode.cc @@ -129,7 +129,7 @@ PNGFileReadContext::PNGFileReadContext(const base::FilePath& file_path, // will not be called. This is fine though, since we abort upon errors here. // If alternative behavior is desired, custom error and warning handler // functions can be passed into the png_create_read_struct() call above. - if (setjmp(png_->jmpbuf)) { + if (setjmp(png_jmpbuf(png_))) { LOG(FATAL) << "libpng returned error reading " << file_path.value(); } diff --git a/cobalt/renderer/test/png_utils/png_encode.cc b/cobalt/renderer/test/png_utils/png_encode.cc index 3b4d58b13d03..87a6003ef540 100644 --- a/cobalt/renderer/test/png_utils/png_encode.cc +++ b/cobalt/renderer/test/png_utils/png_encode.cc @@ -81,7 +81,7 @@ std::unique_ptr EncodeRGBAToBuffer(const uint8_t* pixel_data, // if error encountered png will call longjmp(), so we set up a setjmp() here // with a failed assert to indicate an error in one of the png functions. // yo libpng, 1980 called, they want their longjmp() back.... - if (setjmp(png->jmpbuf)) { + if (setjmp(png_jmpbuf(png))) { png_destroy_write_struct(&png, &info); NOTREACHED() << "libpng encountered an error during processing."; return std::unique_ptr(); diff --git a/cobalt/script/v8c/helpers.h b/cobalt/script/v8c/helpers.h index 2529039d3989..68604ee2d212 100644 --- a/cobalt/script/v8c/helpers.h +++ b/cobalt/script/v8c/helpers.h @@ -17,7 +17,6 @@ #include -#include "starboard/common/string.h" #include "v8/include/v8.h" // Utility functions that are primarily utility V8 wrappers, and aren't diff --git a/cobalt/script/v8c/v8c_engine.cc b/cobalt/script/v8c/v8c_engine.cc index 0bc11637903b..2caa5fa61be2 100644 --- a/cobalt/script/v8c/v8c_engine.cc +++ b/cobalt/script/v8c/v8c_engine.cc @@ -25,7 +25,6 @@ #include "cobalt/configuration/configuration.h" #include "cobalt/script/v8c/isolate_fellowship.h" #include "cobalt/script/v8c/v8c_global_environment.h" -#include "starboard/common/once.h" namespace cobalt { namespace script { diff --git a/cobalt/site/docs/development/setup-raspi.md b/cobalt/site/docs/development/setup-raspi.md index 7cbdad23c734..c737e197dcfb 100644 --- a/cobalt/site/docs/development/setup-raspi.md +++ b/cobalt/site/docs/development/setup-raspi.md @@ -86,13 +86,13 @@ Raspberry Pi. following command: ``` - $ cobalt/build/gn.py -p raspi-2 + $ cobalt/build/gn.py -p raspi-2 -C devel ``` 1. Compile the code from the `cobalt/` directory: ``` - $ ninja -C out/raspi-2_debug cobalt + $ ninja -C out/raspi-2_devel cobalt_install ``` 1. Run the following command to install your Cobalt binary (and content) @@ -100,7 +100,7 @@ Raspberry Pi. ``` $ rsync -avzLPh --exclude="obj*" --exclude="gen/" \ - $COBALT_SRC/out/raspi-2_debug pi@$RASPI_ADDR:~/ + $COBALT_SRC/out/raspi-2_devel pi@$RASPI_ADDR:~/ ``` The `rsyncs` get somewhat faster after the first time, as `rsync` is good at @@ -112,8 +112,8 @@ Raspberry Pi. ``` $ ssh pi@$RASPI_ADDR - $ cd raspi-2_debug - $ ./cobalt + $ cd raspi-2_devel/install/cobalt_loader + $ ./cobalt_loader ``` With this approach, you can just hit `[CTRL-C]` to close Cobalt. If you diff --git a/cobalt/site/docs/gen/cobalt/doc/voice_search.md b/cobalt/site/docs/gen/cobalt/doc/voice_search.md index c8bfcc43ea7e..e0eabb7eb428 100644 --- a/cobalt/site/docs/gen/cobalt/doc/voice_search.md +++ b/cobalt/site/docs/gen/cobalt/doc/voice_search.md @@ -26,15 +26,15 @@ on the SbMicrophone API as detailed above. In `starboard/linux/shared/soft_mic_platform_service.cc` there is an example stub implementation of the SoftMicPlatformService. Platforms can optionally -implement this [CobaltPlatformService](https://cobalt.dev/gen/cobalt/doc/\ -platform_services.html) to specify if they support the `soft mic` and/or `hard mic` -for voice search. The `soft mic` refers to the software activation of the microphone -for voice search through the UI microphone button on the Youtube Web Application -search page. The `hard mic` refers to hardware button activation of the microphone -for voice search. Platforms can also specify the optional `micGesture`. This -specifies the type of UI prompt the YouTube Web Application should display to guide -the user to start voice search. The options include an empty or `null` value for no -prompt, `"TAP"` for tap the `soft mic` and/or `hard mic` to start voice search, or +implement this [CobaltPlatformService](platform_services.md) to specify if they +support the `soft mic` and/or `hard mic` for voice search. The `soft mic` refers +to the software activation of the microphone for voice search through the UI +microphone button on the Youtube Web Application search page. The `hard mic` +refers to hardware button activation of the microphone for voice search. +Platforms can also specify the optional `micGesture`. This specifies the type of +UI prompt the YouTube Web Application should display to guide the user to start +voice search. The options include an empty or `null` value for no prompt, +`"TAP"` for tap the `soft mic` and/or `hard mic` to start voice search, or `"HOLD"` for hold the `soft mic` and/or the `hard mic` to start voice search. The Web Application messages to the platform will be singular strings, encoded with diff --git a/cobalt/site/docs/gen/starboard/build/doc/migrating_gyp_to_gn.md b/cobalt/site/docs/gen/starboard/build/doc/migrating_gyp_to_gn.md index c0758069251e..c0e46b5bdb05 100644 --- a/cobalt/site/docs/gen/starboard/build/doc/migrating_gyp_to_gn.md +++ b/cobalt/site/docs/gen/starboard/build/doc/migrating_gyp_to_gn.md @@ -266,8 +266,8 @@ This [document](./gn_migrate_stub_to_platform.md) outlines a step by step process for converting the stub platform's GN files to GN files that will be able to be built for your platform. -[cobalt_porting_guide]: https://cobalt.dev/starboard/porting.html -[dev_setup_linux]: https://cobalt.dev/development/setup-linux.html +[cobalt_porting_guide]: https://developers.google.com/youtube/cobalt/docs/starboard/porting +[dev_setup_linux]: https://developers.google.com/youtube/cobalt/docs/development/setup-linux [gn_check_tool]: https://cobalt.googlesource.com/third_party/gn/+/refs/heads/main/docs/reference.md#cmd_check [gn_doc_home]: https://cobalt.googlesource.com/third_party/gn/+/refs/heads/main/docs [gn_format_tool]: https://cobalt.googlesource.com/third_party/gn/+/refs/heads/main/docs/reference.md#cmd_format diff --git a/cobalt/site/docs/gen/starboard/doc/c99.md b/cobalt/site/docs/gen/starboard/doc/c99.md index 5fb5f90d6b1e..0378393248e8 100644 --- a/cobalt/site/docs/gen/starboard/doc/c99.md +++ b/cobalt/site/docs/gen/starboard/doc/c99.md @@ -36,30 +36,38 @@ deprecated and eventually removed. ### * acos * acosf +* acosh * asin * asinf +* asinh * atan * atan2 * atan2f * atanf +* atanh * cbrt * cbrtf * ceil * ceilf * cos * cosf +* cosh * div * erf * erff * exp * expf +* exp2 * exp2f * fabs +* fabsf * floor * floorf +* fmaf * fmod * fmodf * frexp +* ilogbf * isfinite * isnan * labs @@ -80,17 +88,23 @@ deprecated and eventually removed. * nextafterf * pow * powf +* remainder * round * roundf * scalbn * sin * sinf +* sinh * sqrt * sqrtf * tan * tanf +* tanh * trunc * truncf +### +* sscanf +* vsscanf ### * abs * atoi @@ -134,3 +148,11 @@ deprecated and eventually removed. * wmemmove * wmemset * wcsncmp +* snprintf +* sprintf +* vfwprintf +* vsnprintf +* vswprintf +* ferror +* fputwc +* fwide diff --git a/cobalt/site/docs/gen/starboard/doc/crash_handlers.md b/cobalt/site/docs/gen/starboard/doc/crash_handlers.md index d7dac077d2f5..b23b29471dd6 100644 --- a/cobalt/site/docs/gen/starboard/doc/crash_handlers.md +++ b/cobalt/site/docs/gen/starboard/doc/crash_handlers.md @@ -35,7 +35,7 @@ const void* SbSystemGetExtension(const char* name) { } ``` -3. Calling the `third_party::crashpad::wrapper::InstallCrashpadHandler(bool start_at_crash)` hook +3. Calling the `third_party::crashpad::wrapper::InstallCrashpadHandler()` hook directly after installing system crash handlers. On linux, for example, this could look like: @@ -47,7 +47,8 @@ int main(int argc, char** argv) { starboard::shared::signal::InstallCrashSignalHandlers(); starboard::shared::signal::InstallSuspendSignalHandlers(); - third_party::crashpad::wrapper::InstallCrashpadHandler(true); + std::string ca_certificates_path = starboard::common::GetCACertificatesPath(); + third_party::crashpad::wrapper::InstallCrashpadHandler(ca_certificates_path); int result = application.Run(argc, argv); ... diff --git a/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_lite.md b/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_lite.md index 55b54e2ea46c..6072f212bfcb 100644 --- a/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_lite.md +++ b/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_lite.md @@ -100,7 +100,6 @@ Cobalt Evergreen currently supports the following Target Architectures: -* `x86_32` * `x86_64` * `armv7 32` * `armv8 64` diff --git a/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_overview.md b/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_overview.md index 7b8a8de9cb33..9ff357ee7b94 100644 --- a/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_overview.md +++ b/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_overview.md @@ -147,9 +147,9 @@ Evergreen: for more details. * `kSbMemoryMapProtectExec` * Ensures mapped memory can be executed -* `#define SB_CAN_MAP_EXECUTABLE_MEMORY 1` +* Set `kSbCanMapExecutableMemory` to `true` * Specifies that the platform can map executable memory - * Defined in `configuration_public.h` + * Defined in `configuration_constants.h` Only if necessary, create a customized SABI configuration for your architecture. Note, we do not anticipate that you will need to make a new configuration for @@ -306,8 +306,8 @@ instructions available [here](cobalt_evergreen_reference_port_raspi2.md). 1. Build the `crashpad_database_util` target and deploy it onto the device. ``` -$ cobalt/build/gn.py -p -c qa -$ ninja -C out/_qa crashpad_database_util +$ gn gen out/_qa --args='target_platform="" build_type="qa"' +$ ninja -C out/_qa native_target/crashpad_database_util ``` 2. Remove the existing state for crashpad as it throttles uploads to 1 per hour: ``` @@ -609,9 +609,6 @@ behavior can be easily configured on a per-app basis with simple command-line fl The configurable options for Cobalt Updater configuration are: * `--evergreen_lite` *Use the System Image version of Cobalt under Slot_0 and turn off the updater for the specified application.* -* `--disable_updater_module` *Stay on the current version of Cobalt that might be the - system image or an installed update, and turn off the updater for the - specified application.* Each app’s Cobalt Updater will perform an independent, regular check for new Cobalt Evergreen updates. Note that all apps will share the same set of slots, @@ -640,7 +637,7 @@ existing slot. In this case, `APP_1` and `APP_2` are now using the same Cobalt binaries in SLOT_2. If `APP_3` has not been launched, not run through a regular Cobalt Updater -check, or launched with the `--evergreen_lite`/`--disable_updater_module` flag, +check, or launched with the `--evergreen_lite` flag, it stays with its current configuration. #### AFTER COBALT UPDATE @@ -667,15 +664,14 @@ loader_app --url="" loader_app --url="" -# Only APP_1 gets Evergreen Updates, APP_2 disables the updater and uses an alternate splash screen, APP_3 uses +# APP_1 gets Evergreen Updates, APP_2 uses an alternate splash screen, APP_3 uses # the system image and disables the updater [APP_1] (Cobalt Updater ENABLED) -[APP_2] (Cobalt Updater DISABLED) +[APP_2] (Cobalt Updater ENABLED) [APP_3] (System Image loaded, Cobalt Updater DISABLED) loader_app --url="" -loader_app --url="" --disable_updater_module \ ---fallback_splash_screen_url="//app_2_splash_screen.html" +loader_app --url="" --fallback_splash_screen_url="//app_2_splash_screen.html" loader_app --url="" --evergreen_lite diff --git a/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_reference_port_raspi2.md b/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_reference_port_raspi2.md index 2bfc1e3b34dd..b9c3d45260a4 100644 --- a/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_reference_port_raspi2.md +++ b/cobalt/site/docs/gen/starboard/doc/evergreen/cobalt_evergreen_reference_port_raspi2.md @@ -5,9 +5,8 @@ Book: /youtube/cobalt/_book.yaml ## Requirements -* Raspberry Pi 2 (image configured per - [instructions](https://cobalt.dev/development/setup-raspi.html) on - cobalt.dev) +* Raspberry Pi environment setup per + [instructions](https://developers.google.com/youtube/cobalt/docs/development/setup-raspi). ## Build instructions diff --git a/cobalt/site/docs/gen/starboard/doc/resources/starboard_16_posix.png b/cobalt/site/docs/gen/starboard/doc/resources/starboard_16_posix.png new file mode 100644 index 000000000000..0d4034b1ab45 Binary files /dev/null and b/cobalt/site/docs/gen/starboard/doc/resources/starboard_16_posix.png differ diff --git a/cobalt/site/docs/gen/starboard/doc/starboard_16_posix.md b/cobalt/site/docs/gen/starboard/doc/starboard_16_posix.md new file mode 100644 index 000000000000..a16d195e32aa --- /dev/null +++ b/cobalt/site/docs/gen/starboard/doc/starboard_16_posix.md @@ -0,0 +1,342 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard 16 POSIX APIs + + +## Background +Updating existing Chromium components in the Cobalt repository or +bringing new ones requires porting to Starboard. This Starboardization process +takes a lot of time, however the majority of the APIs +involved in the porting are well established POSIX APIs with duplicates in +Starboard e.g: `malloc()` - `SbMemoryAllocate()`, +`socket()` - `SbSocketCreate()`, `open()` - `SbFileOpen()`, +`opendir()` - `SbDirectoryOpen()`, `pthread_mutex_create()` - `SbMutexCreate()` + etc... + +## Deprecated Starboard APIs +Starting with Starboard 16 the POSIX equivalent Starboard APIs were +deprecated and removed, and the standard POSIX APIs are used instead: + +### Memory Management +Removed: + +``` +SbMemoryAllocate +SbMemoryAllocateAligned +SbMemoryAllocateAlignedUnchecked +SbMemoryAllocateNoReport +SbMemoryAllocateUnchecked +SbMemoryDeallocate +SbMemoryDeallocateAligned +SbMemoryDeallocateNoReport +SbMemoryFlush +SbMemoryFree +SbMemoryFreeAligned +SbMemoryMap +SbMemoryProtect +SbMemoryReallocate +SbMemoryReallocateUnchecked +SbMemoryUnmap +``` + +Supported POSIX equivalents: + +``` +calloc +free +malloc +posix_memalign +realloc +mmap +munmap +mprotect +msync +``` + + +### Concurrency +Removed: + +``` +SbConditionVariableBroadcast +SbConditionVariableDestroy +SbConditionVariableCreate +SbConditionVariableSignal +SbConditionVariableWait +SbConditionVariableWaitTimed +SbMutexAcquire +SbMutexAcquireTry +SbMutexCreate +SbMutexDestroy +SbMutexRelease +SbThreadCreate +SbThreadCreateLocalKey +SbThreadDestroyLocalKey +SbThreadDetach +SbThreadGetCurrent +SbThreadGetLocalValue +SbThreadGetName +SbThreadIsEqual +SbThreadJoin +SbThreadSetLocalValue +SbThreadSetName +SbThreadSleep +SbThreadYield +SbOnce +``` + +Supported POSIX equivalents: + +``` +pthread_attr_init +pthread_attr_destroy +pthread_attr_getdetachstate +pthread_attr_getstacksize +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_getclock +pthread_condattr_init +pthread_condattr_setclock +pthread_create +pthread_detach +pthread_equal +pthread_join +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_unlock +pthread_mutex_trylock +pthread_once +pthread_self +pthread_getspecific +pthread_key_create +pthread_key_delete +pthread_setspecific +pthread_setname_np +pthread_getname_np +sched_yield +usleep +``` + +### I/O, sockets, files, directories +Removed: + +``` +SbDirectoryCanOpen +SbDirectoryClose +SbDirectoryCreate +SbDirectoryGetNext +SbDirectoryOpen +SbFileCanOpen +SbFileClose +SbFileDelete +SbFileExists +SbFileFlush +SbFileGetInfo +SbFileGetPathInfo +SbFileModeStringToFlags +SbFileOpen +SbFileRead +SbFileSeek +SbFileTruncate +SbFileWrite +SbSocketAccept +SbSocketBind +SbSocketClearLastError +SbSocketConnect +SbSocketCreate +SbSocketDestroy +SbSocketFreeResolution +SbSocketGetInterfaceAddress +SbSocketGetLastError +SbSocketGetLocalAddress +SbSocketIsConnected +SbSocketIsConnectedAndIdle +SbSocketIsIpv6Supported +SbSocketJoinMulticastGroup +SbSocketListen +SbSocketReceiveFrom +SbSocketResolve +SbSocketSendTo +SbSocketSetBroadcast +SbSocketSetReceiveBufferSize +SbSocketSetReuseAddress +SbSocketSetSendBufferSize +SbSocketSetTcpKeepAlive +SbSocketSetTcpNoDelay +SbSocketSetTcpWindowScaling +``` + +Supported POSIX equivalents: + +``` +accept +close +bind +connect +freeifaddrs +freeaddrinfo +fstat +fsync +ftruncate +getifaddrs +getaddrinfo +inet_ntop +listen +lseek +mkdir +read +recv +recvfrom +rmdir +setsockopt +send +sendto +stat +socket +unlink +write + +``` + +### Strings +Removed: + +``` +SbStringCompareNoCase +SbStringCompareNoCaseN +SbStringDuplicate +SbStringScan +SbStringFormat +SbStringFormatWide +``` + +Supported POSIX equivalents: +``` +strdup +strcasecmp +strncasecmp +vfwprintf +vsnprintf +vsscanf +``` + +### Time +Removed: + +``` +SbTimeGetMonotonicNow +SbTimeGetMonotonicThreadNow +SbTimeGetNow +SbTimeIsTimeThreadNowSupported +``` + +Supported POSIX equivalents: + +``` +clock_gettime +gettimeofday +gmtime_r +time +``` +### Evergreen integration +![Evergreen Architecture](resources/starboard_16_posix.png) + +#### POSIX ABI headers (musl_types) +The POSIX standard doesn't provide an ABI specification. There is guidance +around type definitions, but the actual memory representation is left +to the platform implementation. For example the `clock_gettime(CLOCK_MONOTONIC, &ts)` uses +various constants (e.g. CLOCK_MONOTONIC) to define which system clock to query +and a `struct timespec` pointer to populate the time data. The struct has 2 +members, but the POSIX standard does not explicitly require that these members +be a specific number of bytes (e.g. the type long may be 4 or 8 bytes), +nor the padding/layout of the members in the struct +(e.g. a compiler is allowed to add additional padding). + +The Starboard 16 POSIX ABI is defined by a combination of existing +[third_party/musl](../../third_party/musl) types and values and new types +and values added under [third_party/musl/src/starboard](../../third_party/musl/src/starboard). +All of the types have a concrete stable ABI defined per CPU architecture. + +#### POSIX wrapper impl +The musl ABI types are translated to the native POSIX types in the +POSIX wrapper implementation. +The actual implementation, which assumes a native POSIX support is +implemented in `starboard/shared/modular`. For example +[starboard/shared/modular/starboard_layer_posix_time_abi_wrappers.h](../shared/modular/starboard_layer_posix_time_abi_wrappers.h), +[starboard/shared/modular/starboard_layer_posix_time_abi_wrappers.cc](../shared/modular/starboard_layer_posix_time_abi_wrappers.cc). + +If the provided implementation doesn't work out of the box +partners can fix it and adjust for their own internal platform. If the +fix is applicable to other POSIX implementations they can upstream the change +to the Cobalt project. + +#### Exported Symbols Map +The Exported Symbols Map is part of the Evergreen loader and provides all the unresolved +external symbols required by the Coabalt Core binary. The map is defined as +`std::map` and all the Starboard and POSIX symbols are +registered there. The implementation resides in +[starboard/elf_loader/exported_symbols.cc](../elf_loader/exported_symbols.cc). +For POSIX APIs a wrapper function is used whenever a translation +from `musl` types to platform POSIX types is needed e.g. + +``` +map_["clock_gettime"] = reinterpret_cast(&__abi_wrap_clock_gettime); +``` +The symbol may be registered directly without a wrapper if there is no need +for any translation or ajustements of the API e.g. +``` +REGISTER_SYMBOL(malloc); +``` + +### Verification +A test suite [starboard/nplb/posix_compliance](../nplb/posix_compliance) is added to `nplb` +to verify the POSIX APIs specification and to enforce uniformity across all platforms. + +The `elf_loader_sandbox` binary can be used to run tests in Evergreen mode. + +The `elf_loader_sandbox` is run using two command line switches: +`--evergreen_library` and `--evergreen_content`. These switches are the path to +the shared library to be run and the path to that shared library's content. +These paths should be *relative to the content of the elf_loader_sandbox*. + +For example, if we wanted to run the `nplb` set of tests and had the following +directory tree, + +``` +.../elf_loader_sandbox +.../content/app/nplb/lib/libnplb.so +.../content/app/nplb/content +``` + +we would use the following command to run `nplb`: + +``` +.../elf_loader_sandbox --evergreen_library=app/nplb/lib/libnplb.so + --evergreen_content=app/nplb/content +``` + +To build the `nplb` tests for Evergreen use the following commands. +The first of which builds the test using the Evergreen toolchain and +the second builds `elf_loader_sandbox` using the partner's toolchain: + +``` + +ninja -C out/evergreen-arm-softfp_devel/ nplb_install +ninja -C out/${PLATFORM}_devel/ elf_loader_sandbox_install + +``` + + +### Backwards compatibility with Starboard 14 and Starboard 15 +For older Starboard Versions e.g. 14 and 15 an emulation layer was provided through +the `third_party/musl` library. This should be completely transparent to +partner's integrations. diff --git a/cobalt/site/docs/gen/starboard/doc/style.md b/cobalt/site/docs/gen/starboard/doc/style.md index 84c55f19efb3..22998a5babe0 100644 --- a/cobalt/site/docs/gen/starboard/doc/style.md +++ b/cobalt/site/docs/gen/starboard/doc/style.md @@ -123,9 +123,6 @@ the guidelines follow thusly as follows. casting the handle back and forth to the pointer type. * If a word in the name of a type is redundant with the module name, it is omitted. - * A monotonic time type in the Time module is `SbTimeMonotonic`, not - ~~`SbMonotonicTime`, `SbTimeMonotonicTime`, or - `SbTimeMonotonicSbTime`~~. ### Functions @@ -191,10 +188,8 @@ namespace at the starboard repository root. * After the `k`, all constants have `Sb`, the Starboard namespace. * `kSb` * After `kSb`, all constants then have the module name. - * `kSbTime` * `kSbFile` * After `kSb` comes the rest of the name of the constant. - * `kSbTimeMillisecond` * `kSbFileInvalid` * Enum entries are prefixed with the full name of the enum. * The enum `SbSystemDeviceType` contains entries like @@ -238,14 +233,6 @@ namespace at the starboard repository root. ### Implementations - * Each API implementation should attempt to minimize other platform - assumptions, and should therefore use Starboard APIs to accomplish - platform-specific work unless directly related to the platform functionality - being implemented. - * For example, `SbFile` can use POSIX file I/O, because that what it is - abstracting, but it should use `SbMemoryAllocate` for any memory - allocations, because it might be used with a variety of `SbMemory` - implementations. * Whenever possible, each shared function implementation should be implemented in an individual file so as to maximize the chances of reuse between implementations. diff --git a/cobalt/site/docs/gen/starboard/doc/versioning.md b/cobalt/site/docs/gen/starboard/doc/versioning.md index b33e73bcbc10..02afb2f75d99 100644 --- a/cobalt/site/docs/gen/starboard/doc/versioning.md +++ b/cobalt/site/docs/gen/starboard/doc/versioning.md @@ -59,8 +59,6 @@ error at compilation time. Generally Starboard applications will not support all versions of the Starboard API indefinitely. Starboard application owners may increment the minimum required Starboard version at their discretion. -TBD: Timelines and communication around when an upcoming Cobalt release will -require porters to implement a newer version of Starboard. ## Using new Starboard APIs from Starboard Applications @@ -72,170 +70,11 @@ new functionality in Starboard applications if this evaluates to false. ## Adding and using new Starboard APIs -### The "Experimental" Starboard Version - -At any given time, exactly one version of Starboard will be denoted as the -"experimental" version, as defined by the `SB_EXPERIMENTAL_API_VERSION` macro in -`starboard/configuration.h`. It is generally not recommended to declare support -for this version. Any Starboard APIs defined in the experimental version are -subject to change and API requirements could be added, removed, or changed at -any time. - -### The "Release Candidate" Starboard Version - -At any given time, zero or more versions of Starboard will be denoted as the -"release candidate" version, as defined by the -`SB_RELEASE_CANDIDATE_API_VERSION` macro in `starboard/configuration.h`. The -"release candidate" version is a set of API changes that have been considered -and tested together. It is reasonable to port against this version, it has gone -through some stabilization and may become frozen as it currently is. But, be -aware that it is possible that minor incompatible changes may be made to this -version if an unexpected situation arises. `SB_RELEASE_CANDIDATE_API_VERSION` is -not defined if there is no "release candidate" version. Every API version -greater than `SB_RELEASE_CANDIDATE_API_VERSION` but less than `SB_EXPERIMENTAL_API_VERSION` is also considered a release candidate. ### "Frozen" Starboard versions -All Starboard versions that are less than the experimental and release candidate -versions are considered frozen. Any Starboard APIs in a frozen version MUST not -change. - -### Version Numbers, and how They Interrelate Numerically - -``` -frozen < release-candidate < experimental < future -``` - -As mentioned previously, a release candidate version may or may not exist at any -given time. When there is a release candate version, it follows the invariant -above. - -### Life of a Starboard API - -New Starboard APIs should be defined in the experimental version. - -When introducing a new Starboard API (or modifying an existing one), a new -feature version define should be created within the "Experimental Feature -Defines" section of `starboard/configuration.h`, and set to -`SB_EXPERIMENTAL_API_VERSION`. A well written comment should be added in front -of the feature define that describes exactly what is introduced by the feature. -In the comment, all new/modified/removed symbols should be identified, and all -modified header files should be named. - -For example, - -``` -// in starboard/configuration.h - -#define SB_EXPERIMENTAL_API_VERSION 7 - -#undef SB_RELEASE_CANDIDATE_API_VERSION - -// --- Experimental Feature Defines ------------------------------------------ - -... - -// Introduce a new API in starboard/screensaver.h, which declares the following -// functions for managing the platform's screensaver settings: -// SbScreensaverDisableScreensaver() -// SbScreensaverEnableScreensaver() -// Additionally, a new event, kSbEventTypeScreensaverStarted, is introduced in -// starboard/event.h. -#define SB_SCREENSAVER_FEATURE_API_VERSION SB_EXPERIMENTAL_API_VERSION - -// Introduce a new API in starboard/new_functionality.h which declares the -// function SbNewFunctionality(). -#define SB_MY_NEW_FEATURE_API_VERSION SB_EXPERIMENTAL_API_VERSION - -// Introduce another new API in starboard/still_in_development.h which -// declares the function SbStillInDevelopment(). -#define SB_MY_OTHER_NEW_FEATURE_API_VERSION SB_EXPERIMENTAL_API_VERSION -``` - -When declaring the new interface, the following syntax should be used: - -``` -// starboard/new_functionality.h -#if SB_API_VERSION >= SB_MY_NEW_FEATURE_API_VERSION -void SbNewFunctionality(); -#endif -``` - -Starboard application features that use a new API must have a similar check: - -``` -// cobalt/new_feature.cc -#if SB_API_VERSION >= SB_MY_NEW_FEATURE_API_VERSION -void DoSomethingCool() { - SbNewFunctionality(); -} -#endif -``` - -When promoting the experimental API version to be the release candidate API -version, the previously undefined `SB_RELEASE_CANDIDATE_API_VERSION` is set to -the current value of `SB_EXPERIMENTAL_API_VERSION`, and -`SB_EXPERIMENTAL_API_VERSION` is then incremented by one. As a result, -`SB_RELEASE_CANDIDATE_API_VERSION` on the master branch should always either be -undefined, or `SB_EXPERIMENTAL_API_VERSION - 1`. - -One or more features are then moved from `SB_EXPERIMENTAL_API_VERSION` to -`SB_RELEASE_CANDIDATE_API_VERSION`, and into the "Release Candidate Feature -Defines" section of `starboard/configuration.h`. Some features may be left in -experimental if they are not ready for release. The documentation comments of -these features should be moved into the (newly created) section for the -corresponding version in [starboard/CHANGELOG.md](../CHANGELOG.md). - -``` -// in starboard/configuration.h - -#define SB_EXPERIMENTAL_API_VERSION 8 - -#define SB_RELEASE_CANDIDATE_API_VERSION 7 - -// --- Experimental Feature Defines ------------------------------------------ - -// Introduce another new API in starboard/still_in_development.h which -// declares the function SbStillInDevelopment(). -#define SB_MY_OTHER_NEW_FEATURE_API_VERSION SB_EXPERIMENTAL_API_VERSION - -// --- Release Candidate Features Defines ------------------------------------ - -#define SB_MY_NEW_FEATURE_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION - -``` - -When a release candidate branch is promoted to a full release, these new -Starboard APIs will be irrevocably frozen to the value of -`SB_RELEASE_CANDIDATE_API_VERSION`, and the release candidate version will be -undefined. Additionally, the feature defines should be removed. - -``` -// starboard/new_functionality.h -#if SB_API_VERSION >= 7 -void SbNewFunctionality(); -#endif - -// starboard/other_new_functionality.h -#if SB_API_VERSION >= SB_MY_OTHER_NEW_FEATURE_API_VERSION -void SbStillInDevelopment(); -#endif - -// starboard/configuration.h -#define SB_EXPERIMENTAL_API_VERSION 8 -#undef SB_RELEASE_CANDIDATE_API_VERSION - -// cobalt/new_feature.cc -#if SB_API_VERSION >= 7 -void DoSomethingCool() { - SbNewFunctionality(); -} -#endif -``` - -Whoever increments the experimental version must ensure that stubs and reference -platforms declare support for the new experimental version through their -respective `SB_API_VERSION` macros. +All Starboard versions that are less than the `SB_MAXIMUM_API_VERSION` version +are considered frozen. Any Starboard APIs in a frozen version MUST not change. ### Communicating Starboard API changes to porters diff --git a/cobalt/site/docs/reference/starboard/gn-configuration.md b/cobalt/site/docs/reference/starboard/gn-configuration.md index f3e517354ca5..a93fae0df15d 100644 --- a/cobalt/site/docs/reference/starboard/gn-configuration.md +++ b/cobalt/site/docs/reference/starboard/gn-configuration.md @@ -13,7 +13,7 @@ Book: /youtube/cobalt/_book.yaml | **`enable_in_app_dial`**

Enables or disables the DIAL server that runs inside Cobalt. Note: Only enable if there's no system-wide DIAL support.

The default value is `false`. | | **`executable_configs`**

Target-specific configurations for executable targets.

The default value is `[]`. | | **`final_executable_type`**

The target type for executable targets. Allows changing the target type on platforms where the native code may require an additional packaging step (ex. Android).

The default value is `"executable"`. | -| **`gl_type`**

The source of EGL and GLES headers and libraries. Valid values (case and everything sensitive!):
  • none - No EGL + GLES implementation is available on this platform.
  • system_gles2 - Use the system implementation of EGL + GLES2. The headers and libraries must be on the system include and link paths.
  • glimp - Cobalt's own EGL + GLES2 implementation. This requires a valid Glimp implementation for the platform.
  • angle - A DirectX-to-OpenGL adaptation layer. This requires a valid ANGLE implementation for the platform.

    The default value is `"system_gles2"`. | +| **`gl_type`**

    The source of EGL and GLES headers and libraries. Valid values (case and everything sensitive!):
    • system_gles2 - Use the system implementation of EGL + GLES2. The headers and libraries must be on the system include and link paths.
    • glimp - Cobalt's own EGL + GLES2 implementation. This requires a valid Glimp implementation for the platform.
    • angle - A DirectX-to-OpenGL adaptation layer. This requires a valid ANGLE implementation for the platform.

      The default value is `"system_gles2"`. | | **`gtest_target_type`**

      The target type for test targets. Allows changing the target type on platforms where the native code may require an additional packaging step (ex. Android).

      The default value is `"executable"`. | | **`has_platform_targets`**

      Whether the platform has platform-specific targets to depend on.

      The default value is `false`. | | **`install_target_path`**

      The path to the gni file containing the install_target template which defines how the build should produce the install/ directory.

      The default value is `"//starboard/build/install/no_install.gni"`. | @@ -26,11 +26,13 @@ Book: /youtube/cobalt/_book.yaml | **`sb_api_version`**

      The Starboard API version of the current build configuration. The default value is meant to be overridden by a Starboard ABI file.

      The default value is `16`. | | **`sb_enable_benchmark`**

      Used to enable benchmarks.

      The default value is `false`. | | **`sb_enable_cpp17_audit`**

      Enables an NPLB audit of C++17 support.

      The default value is `true`. | +| **`sb_enable_cpp20_audit`**

      Enables an NPLB audit of C++20 support.

      The default value is `true`. | | **`sb_enable_lib`**

      Enables embedding Cobalt as a shared library within another app. This requires a 'lib' starboard implementation for the corresponding platform.

      The default value is `false`. | | **`sb_enable_opus_sse`**

      Enables optimizations on SSE compatible platforms.

      The default value is `true`. | | **`sb_evergreen_compatible_package`**

      Whether to generate the whole package containing both Loader app and Cobalt core on the Evergreen compatible platform.

      The default value is `false`. | | **`sb_evergreen_compatible_use_libunwind`**

      Whether to use the libunwind library on Evergreen compatible platform.

      The default value is `false`. | | **`sb_filter_based_player`**

      Used to indicate that the player is filter based.

      The default value is `true`. | +| **`sb_has_unused_symbol_issue`**

      Set this to true if the modular toolchain linker doesn't strip all unused symbols and nplb fails to link.

      The default value is `false`. | | **`sb_is_evergreen`**

      Whether this is an Evergreen build.

      The default value is `false`. | | **`sb_is_evergreen_compatible`**

      Whether this is an Evergreen compatible platform. A compatible platform can run the elf_loader and launch the Evergreen build.

      The default value is `false`. | | **`sb_libevent_method`**

      The event polling mechanism available on this platform to support libevent. Platforms may redefine to 'poll' if necessary. Other mechanisms, e.g. devpoll, kqueue, select, are not yet supported.

      The default value is `"epoll"`. | diff --git a/cobalt/site/docs/reference/starboard/modules/13/byte_swap.md b/cobalt/site/docs/reference/starboard/modules/13/byte_swap.md deleted file mode 100644 index 72dc9327ed1e..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/byte_swap.md +++ /dev/null @@ -1,75 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `byte_swap.h` - -Specifies functions for swapping byte order. These functions are used to deal -with endianness when performing I/O. - -## Functions - -### SbByteSwapS16 - -Unconditionally swaps the byte order in signed 16-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -int16_t SbByteSwapS16(int16_t value) -``` - -### SbByteSwapS32 - -Unconditionally swaps the byte order in signed 32-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -int32_t SbByteSwapS32(int32_t value) -``` - -### SbByteSwapS64 - -Unconditionally swaps the byte order in signed 64-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -int64_t SbByteSwapS64(int64_t value) -``` - -### SbByteSwapU16 - -Unconditionally swaps the byte order in unsigned 16-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -uint16_t SbByteSwapU16(uint16_t value) -``` - -### SbByteSwapU32 - -Unconditionally swaps the byte order in unsigned 32-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -uint32_t SbByteSwapU32(uint32_t value) -``` - -### SbByteSwapU64 - -Unconditionally swaps the byte order in unsigned 64-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -uint64_t SbByteSwapU64(uint64_t value) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/condition_variable.md b/cobalt/site/docs/reference/starboard/modules/13/condition_variable.md deleted file mode 100644 index 2d8f30b5fdce..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/condition_variable.md +++ /dev/null @@ -1,140 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `condition_variable.h` - -Defines an interface for condition variables. - -## Macros - -### SB_CONDITION_VARIABLE_MAX_SIZE - -Max size of the SbConditionVariable type. - -## Enums - -### SbConditionVariableResult - -Enumeration of possible results from waiting on a condvar. - -#### Values - -* `kSbConditionVariableSignaled` - - The wait completed because the condition variable was signaled. -* `kSbConditionVariableTimedOut` - - The wait completed because it timed out, and was not signaled. -* `kSbConditionVariableFailed` - - The wait failed, either because a parameter wasn't valid, or the condition - variable has already been destroyed, or something similar. - -## Typedefs - -### SbConditionVariable - -An opaque handle to a condition variable type with reserved memory buffer of -size SB_CONDITION_VARIABLE_MAX_SIZE and aligned at void pointer type. - -#### Definition - -``` -typedef union SbConditionVariable SbConditionVariable -``` - -## Functions - -### SbConditionVariableBroadcast - -Broadcasts to all current waiters of `condition` to stop waiting. This function -wakes all of the threads waiting on `condition` while SbConditionVariableSignal -wakes a single thread. - -`condition`: The condition that should no longer be waited for. - -#### Declaration - -``` -bool SbConditionVariableBroadcast(SbConditionVariable *condition) -``` - -### SbConditionVariableCreate - -Creates a new condition variable to work with `opt_mutex`, which may be null, -placing the newly created condition variable in `out_condition`. - -The return value indicates whether the condition variable could be created. - -#### Declaration - -``` -bool SbConditionVariableCreate(SbConditionVariable *out_condition, SbMutex *opt_mutex) -``` - -### SbConditionVariableDestroy - -Destroys the specified SbConditionVariable . The return value indicates whether -the destruction was successful. The behavior is undefined if other threads are -currently waiting on this condition variable. - -`condition`: The SbConditionVariable to be destroyed. This invalidates the -condition variable. - -#### Declaration - -``` -bool SbConditionVariableDestroy(SbConditionVariable *condition) -``` - -### SbConditionVariableIsSignaled - -Returns whether the given result is a success. - -#### Declaration - -``` -static bool SbConditionVariableIsSignaled(SbConditionVariableResult result) -``` - -### SbConditionVariableSignal - -Signals the next waiter of `condition` to stop waiting. This function wakes a -single thread waiting on `condition` while SbConditionVariableBroadcast wakes -all threads waiting on it. - -`condition`: The condition that the waiter should stop waiting for. - -#### Declaration - -``` -bool SbConditionVariableSignal(SbConditionVariable *condition) -``` - -### SbConditionVariableWait - -Waits for `condition`, releasing the held lock `mutex`, blocking indefinitely, -and returning the result. Behavior is undefined if `mutex` is not held. - -#### Declaration - -``` -SbConditionVariableResult SbConditionVariableWait(SbConditionVariable *condition, SbMutex *mutex) -``` - -### SbConditionVariableWaitTimed - -Waits for `condition`, releasing the held lock `mutex`, blocking up to -`timeout_duration`, and returning the acquisition result. Behavior is undefined -if `mutex` is not held. - -`timeout_duration`: The maximum amount of time that function should wait for -`condition`. If the `timeout_duration` value is less than or equal to zero, the -function returns as quickly as possible with a kSbConditionVariableTimedOut -result. - -#### Declaration - -``` -SbConditionVariableResult SbConditionVariableWaitTimed(SbConditionVariable *condition, SbMutex *mutex, SbTime timeout_duration) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/image.md b/cobalt/site/docs/reference/starboard/modules/13/image.md deleted file mode 100644 index 945938a09903..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/image.md +++ /dev/null @@ -1,77 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `image.h` - -API for hardware accelerated image decoding. This module allows for the client -to feed in raw, encoded data to be decoded directly into an SbDecodeTarget. It -also provides an interface for the client to query what combinations of encoded -image formats and SbDecodeTargetFormats are supported or not. - -All functions in this module are safe to call from any thread at any point in -time. - -## SbImageIsDecodeSupported and SbImageDecode Example - -``` -SbDecodeTargetProvider* provider = GetProviderFromSomewhere(); -void* data = GetCompressedJPEGFromSomewhere(); -int data_size = GetCompressedJPEGSizeFromSomewhere(); -const char* mime_type = "image/jpeg"; -SbDecodeTargetFormat format = kSbDecodeTargetFormat1PlaneRGBA; - -if (!SbImageIsDecodeSupported(mime_type, format)) { - return; -} - -SbDecodeTarget result_target = SbImageDecode(provider, data, data_size, - mime_type, format); -``` - -## Functions - -### SbImageDecode - -Attempt to decode encoded `mime_type` image data `data` of size `data_size` into -an SbDecodeTarget of SbDecodeFormatType `format`, possibly using -SbDecodeTargetProvider `provider`, if it is non-null. Thus, four following -scenarios regarding the provider may happen: - -1. The provider is required by the `SbImageDecode` implementation and no - provider is given. The implementation should gracefully fail by immediately - returning kSbDecodeTargetInvalid. - -1. The provider is required and is passed in. The implementation will proceed - forward, using the SbDecodeTarget from the provider. - -1. The provider is not required and is passed in. The provider will NOT be - called, and the implementation will proceed to decoding however it desires. - -1. The provider is not required and is not passed in. The implementation will - proceed forward. The `data` pointer must not be NULL. The `mime_type` string - must not be NULL. Thus, it is NOT safe for clients of this API to assume - that the `provider` it passes in will be called. Finally, if the decode - succeeds, a new SbDecodeTarget will be allocated. If `mime_type` image - decoding for the requested format is not supported or the decode fails, - kSbDecodeTargetInvalid will be returned, with any intermediate allocations - being cleaned up in the implementation. - -#### Declaration - -``` -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider *context_provider, void *data, int data_size, const char *mime_type, SbDecodeTargetFormat format) -``` - -### SbImageIsDecodeSupported - -Whether the current platform supports hardware accelerated decoding an image of -mime type `mime_type` into SbDecodeTargetFormat `format`. The `mime_type` must -not be NULL. The result of this function must not change over the course of the -program, which means that the results of this function may be cached -indefinitely. - -#### Declaration - -``` -bool SbImageIsDecodeSupported(const char *mime_type, SbDecodeTargetFormat format) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/memory.md b/cobalt/site/docs/reference/starboard/modules/13/memory.md deleted file mode 100644 index 0c404e36ea30..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/memory.md +++ /dev/null @@ -1,345 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `memory.h` - -Defines functions for memory allocation, alignment, copying, and comparing. - -## Porters - -All of the "Unchecked" and "Free" functions must be implemented, but they should -not be called directly. The Starboard platform wraps them with extra accounting -under certain circumstances. - -## Porters and Application Developers - -Nobody should call the "Checked", "Unchecked" or "Free" functions directly -because that evades Starboard's memory tracking. In both port implementations -and Starboard client application code, you should always call SbMemoryAllocate -and SbMemoryDeallocate rather than SbMemoryAllocateUnchecked and SbMemoryFree. - -* The "checked" functions are SbMemoryAllocateChecked(), - SbMemoryReallocateChecked(), and SbMemoryAllocateAlignedChecked(). - -* The "unchecked" functions are SbMemoryAllocateUnchecked(), - SbMemoryReallocateUnchecked(), and SbMemoryAllocateAlignedUnchecked(). - -* The "free" functions are SbMemoryFree() and SbMemoryFreeAligned(). - -## Enums - -### SbMemoryMapFlags - -The bitwise OR of these flags should be passed to SbMemoryMap to indicate how -the mapped memory can be used. - -#### Values - -* `kSbMemoryMapProtectReserved` - - No flags set: Reserves virtual address space. SbMemoryProtect() can later - make it accessible. -* `kSbMemoryMapProtectRead` -* `kSbMemoryMapProtectWrite` -* `kSbMemoryMapProtectExec` -* `kSbMemoryMapProtectReadWrite` - -## Functions - -### SbMemoryAllocate - -Allocates and returns a chunk of memory of at least `size` bytes. This function -should be called from the client codebase. It is intended to be a drop-in -replacement for `malloc`. - -Note that this function returns `NULL` if it is unable to allocate the memory. - -`size`: The amount of memory to be allocated. If `size` is 0, the function may -return `NULL` or it may return a unique pointer value that can be passed to -SbMemoryDeallocate. - -#### Declaration - -``` -void* SbMemoryAllocate(size_t size) -``` - -### SbMemoryAllocateAligned - -Allocates and returns a chunk of memory of at least `size` bytes, aligned to -`alignment`. This function should be called from the client codebase. It is -meant to be a drop-in replacement for `memalign`. - -The function returns `NULL` if it cannot allocate the memory. In addition, the -function's behavior is undefined if `alignment` is not a power of two. - -`alignment`: The way that data is arranged and accessed in memory. The value -must be a power of two. `size`: The size of the memory to be allocated. If -`size` is `0`, the function may return `NULL` or it may return a unique aligned -pointer value that can be passed to SbMemoryDeallocateAligned. - -#### Declaration - -``` -void* SbMemoryAllocateAligned(size_t alignment, size_t size) -``` - -### SbMemoryAllocateAlignedChecked - -Same as SbMemoryAllocateAlignedUnchecked, but will abort() in the case of an -allocation failure. - -DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateAlignedChecked(size_t alignment, size_t size) -``` - -### SbMemoryAllocateAlignedUnchecked - -This is the implementation of SbMemoryAllocateAligned that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateAlignedUnchecked(size_t alignment, size_t size) -``` - -### SbMemoryAllocateChecked - -Same as SbMemoryAllocateUnchecked, but will abort() in the case of an allocation -failure. - -DO NOT CALL. Call SbMemoryAllocate(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateChecked(size_t size) -``` - -### SbMemoryAllocateNoReport - -DEPRECATED: Same as SbMemoryAllocate(). - -#### Declaration - -``` -void* SbMemoryAllocateNoReport(size_t size) -``` - -### SbMemoryAllocateUnchecked - -This is the implementation of SbMemoryAllocate that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryAllocate(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateUnchecked(size_t size) -``` - -### SbMemoryCalloc - -A wrapper that implements a drop-in replacement for `calloc`, which is used in -some packages. - -#### Declaration - -``` -static void* SbMemoryCalloc(size_t count, size_t size) -``` - -### SbMemoryDeallocate - -Frees a previously allocated chunk of memory. If `memory` is NULL, then the -operation is a no-op. This function should be called from the client codebase. -It is meant to be a drop-in replacement for `free`. - -`memory`: The chunk of memory to be freed. - -#### Declaration - -``` -void SbMemoryDeallocate(void *memory) -``` - -### SbMemoryDeallocateAligned - -`memory`: The chunk of memory to be freed. If `memory` is NULL, then the -function is a no-op. - -#### Declaration - -``` -void SbMemoryDeallocateAligned(void *memory) -``` - -### SbMemoryDeallocateNoReport - -DEPRECATED: Same as SbMemoryDeallocate() - -#### Declaration - -``` -void SbMemoryDeallocateNoReport(void *memory) -``` - -### SbMemoryFlush - -Flushes any data in the given virtual address range that is cached locally in -the current processor core to physical memory, ensuring that data and -instruction caches are cleared. This is required to be called on executable -memory that has been written to and might be executed in the future. - -#### Declaration - -``` -void SbMemoryFlush(void *virtual_address, int64_t size_bytes) -``` - -### SbMemoryFree - -This is the implementation of SbMemoryDeallocate that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryDeallocate(...) instead. - -#### Declaration - -``` -void SbMemoryFree(void *memory) -``` - -### SbMemoryFreeAligned - -This is the implementation of SbMemoryFreeAligned that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryDeallocateAligned(...) instead. - -#### Declaration - -``` -void SbMemoryFreeAligned(void *memory) -``` - -### SbMemoryGetStackBounds - -Gets the stack bounds for the current thread. - -`out_high`: The highest addressable byte + 1 for the current thread. `out_low`: -The lowest addressable byte for the current thread. - -#### Declaration - -``` -void SbMemoryGetStackBounds(void **out_high, void **out_low) -``` - -### SbMemoryMap - -Allocates `size_bytes` worth of physical memory pages and maps them into an -available virtual region. This function returns `SB_MEMORY_MAP_FAILED` on -failure. `NULL` is a valid return value. - -`size_bytes`: The amount of physical memory pages to be allocated. `flags`: The -bitwise OR of the protection flags for the mapped memory as specified in -`SbMemoryMapFlags`. Allocating executable memory is not allowed and will fail. -If executable memory is needed, map non-executable memory first and then switch -access to executable using SbMemoryProtect. When kSbMemoryMapProtectReserved is -used, the address space will not be accessible and, if possible, the platform -should not count it against any memory budget. `name`: A value that appears in -the debugger on some platforms. The value can be up to 32 bytes. - -#### Declaration - -``` -void* SbMemoryMap(int64_t size_bytes, int flags, const char *name) -``` - -### SbMemoryProtect - -Change the protection of `size_bytes` of memory regions, starting from -`virtual_address`, to `flags`, returning `true` on success. - -#### Declaration - -``` -bool SbMemoryProtect(void *virtual_address, int64_t size_bytes, int flags) -``` - -### SbMemoryReallocate - -Attempts to resize `memory` to be at least `size` bytes, without touching the -contents of memory. - -* If the function cannot perform the fast resize, it allocates a new chunk of - memory, copies the contents over, and frees the previous chunk, returning a - pointer to the new chunk. - -* If the function cannot perform the slow resize, it returns `NULL`, leaving - the given memory chunk unchanged. - -This function should be called from the client codebase. It is meant to be a -drop-in replacement for `realloc`. - -`memory`: The chunk of memory to be resized. `memory` may be NULL, in which case -it behaves exactly like SbMemoryAllocateUnchecked. `size`: The size to which -`memory` will be resized. If `size` is `0`, the function may return `NULL` or it -may return a unique pointer value that can be passed to SbMemoryDeallocate. - -#### Declaration - -``` -void* SbMemoryReallocate(void *memory, size_t size) -``` - -### SbMemoryReallocateChecked - -Same as SbMemoryReallocateUnchecked, but will abort() in the case of an -allocation failure. - -DO NOT CALL. Call SbMemoryReallocate(...) instead. - -#### Declaration - -``` -void* SbMemoryReallocateChecked(void *memory, size_t size) -``` - -### SbMemoryReallocateUnchecked - -This is the implementation of SbMemoryReallocate that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryReallocate(...) instead. - -#### Declaration - -``` -void* SbMemoryReallocateUnchecked(void *memory, size_t size) -``` - -### SbMemoryUnmap - -Unmap `size_bytes` of physical pages starting from `virtual_address`, returning -`true` on success. After this function completes, [virtual_address, -virtual_address + size_bytes) will not be read/writable. This function can unmap -multiple contiguous regions that were mapped with separate calls to -SbMemoryMap(). For example, if one call to `SbMemoryMap(0x1000)` returns -`(void*)0xA000`, and another call to `SbMemoryMap(0x1000)` returns -`(void*)0xB000`, `SbMemoryUnmap(0xA000, 0x2000)` should free both regions. - -#### Declaration - -``` -bool SbMemoryUnmap(void *virtual_address, int64_t size_bytes) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/memory_reporter.md b/cobalt/site/docs/reference/starboard/modules/13/memory_reporter.md deleted file mode 100644 index 505d2a7d0347..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/memory_reporter.md +++ /dev/null @@ -1,106 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `memory_reporter.h` - -DEPRECATED: Provides an interface for memory reporting. - -## Typedefs - -### SbMemoryReporterOnAlloc - -A function to report a memory allocation from SbMemoryAllocate(). Note that -operator new calls SbMemoryAllocate which will delegate to this callback. - -#### Definition - -``` -typedef void(* SbMemoryReporterOnAlloc) (void *context, const void *memory, size_t size) -``` - -### SbMemoryReporterOnDealloc - -A function to report a memory deallocation from SbMemoryDeallcoate(). Note that -operator delete calls SbMemoryDeallocate which will delegate to this callback. - -#### Definition - -``` -typedef void(* SbMemoryReporterOnDealloc) (void *context, const void *memory) -``` - -### SbMemoryReporterOnMapMemory - -A function to report a memory mapping from SbMemoryMap(). - -#### Definition - -``` -typedef void(* SbMemoryReporterOnMapMemory) (void *context, const void *memory, size_t size) -``` - -### SbMemoryReporterOnUnMapMemory - -A function to report a memory unmapping from SbMemoryUnmap(). - -#### Definition - -``` -typedef void(* SbMemoryReporterOnUnMapMemory) (void *context, const void *memory, size_t size) -``` - -## Structs - -### SbMemoryReporter - -SbMemoryReporter allows memory reporting via user-supplied functions. The void* -context is passed to every call back. It's strongly recommended that C-Style -struct initialization is used so that the arguments can be typed check by the -compiler. For example, SbMemoryReporter mem_reporter = { MallocCallback, .... -context }; - -#### Members - -* `SbMemoryReporterOnAlloc on_alloc_cb` - - Callback to report allocations. -* `SbMemoryReporterOnDealloc on_dealloc_cb` - - Callback to report deallocations. -* `SbMemoryReporterOnMapMemory on_mapmem_cb` - - Callback to report memory map. -* `SbMemoryReporterOnUnMapMemory on_unmapmem_cb` - - Callback to report memory unmap. -* `void * context` - - Optional, is passed to callbacks as first argument. - -## Functions - -### SbMemorySetReporter - -Sets the MemoryReporter. Any previous memory reporter is unset. No lifetime -management is done internally on input pointer. - -NOTE: This module is unused starting with Starboard 15 and will be removed in -the future. - -Returns true if the memory reporter was set with no errors. If an error was -reported then check the log for why it failed. - -Note that other than a thread-barrier-write of the input pointer, there is no -thread safety guarantees with this function due to performance considerations. -It's recommended that this be called once during the lifetime of the program, or -not at all. Do not delete the supplied pointer, ever. Example (Good): -SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter); -... SbMemorySetReporter(NULL); // allow value to leak. Example (Bad): -SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter); -... SbMemorySetReporter(NULL); delete mem_reporter; // May crash. - -#### Declaration - -``` -bool SbMemorySetReporter(struct SbMemoryReporter *tracker) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/mutex.md b/cobalt/site/docs/reference/starboard/modules/13/mutex.md deleted file mode 100644 index 82ff8500ab8d..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/mutex.md +++ /dev/null @@ -1,127 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `mutex.h` - -Defines a mutually exclusive lock that can be used to coordinate with other -threads. - -## Macros - -### SB_MUTEX_MAX_SIZE - -Max size of the SbMutex type. - -## Enums - -### SbMutexResult - -Enumeration of possible results from acquiring a mutex. - -#### Values - -* `kSbMutexAcquired` - - The mutex was acquired successfully. -* `kSbMutexBusy` - - The mutex was not acquired because it was held by someone else. -* `kSbMutexDestroyed` - - The mutex has already been destroyed. - -## Typedefs - -### SbMutex - -An opaque handle to a mutex type with reserved memory buffer of size -SB_MUTEX_MAX_SIZE and aligned at void pointer type. - -#### Definition - -``` -typedef union SbMutex SbMutex -``` - -## Functions - -### SbMutexAcquire - -Acquires `mutex`, blocking indefinitely. The return value identifies the -acquisition result. SbMutexes are not reentrant, so a recursive acquisition -blocks forever. - -`mutex`: The mutex to be acquired. - -#### Declaration - -``` -SbMutexResult SbMutexAcquire(SbMutex *mutex) -``` - -### SbMutexAcquireTry - -Acquires `mutex`, without blocking. The return value identifies the acquisition -result. SbMutexes are not reentrant, so a recursive acquisition has undefined -behavior. - -`mutex`: The mutex to be acquired. - -#### Declaration - -``` -SbMutexResult SbMutexAcquireTry(SbMutex *mutex) -``` - -### SbMutexCreate - -Creates a new mutex. The return value indicates whether the function was able to -create a new mutex. - -`out_mutex`: The handle to the newly created mutex. - -#### Declaration - -``` -bool SbMutexCreate(SbMutex *out_mutex) -``` - -### SbMutexDestroy - -Destroys a mutex. The return value indicates whether the destruction was -successful. Destroying a locked mutex results in undefined behavior. - -`mutex`: The mutex to be invalidated. - -#### Declaration - -``` -bool SbMutexDestroy(SbMutex *mutex) -``` - -### SbMutexIsSuccess - -Indicates whether the given result is a success. A value of `true` indicates -that the mutex was acquired. - -`result`: The result being checked. - -#### Declaration - -``` -static bool SbMutexIsSuccess(SbMutexResult result) -``` - -### SbMutexRelease - -Releases `mutex` held by the current thread. The return value indicates whether -the release was successful. Releases should always be successful if `mutex` is -held by the current thread. - -`mutex`: The mutex to be released. - -#### Declaration - -``` -bool SbMutexRelease(SbMutex *mutex) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/once.md b/cobalt/site/docs/reference/starboard/modules/13/once.md deleted file mode 100644 index d77302467f8b..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/once.md +++ /dev/null @@ -1,57 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `once.h` - -Onces represent initializations that should only ever happen once per process, -in a thread-safe way. - -## Macros - -### SB_ONCE_MAX_SIZE - -Max size of the SbOnceControl type. - -## Typedefs - -### SbOnceControl - -An opaque handle to a once control type with reserved memory buffer of size -SB_ONCE_MAX_SIZE and aligned at void pointer type. - -#### Definition - -``` -typedef union SbOnceControl SbOnceControl -``` - -### SbOnceInitRoutine - -Function pointer type for methods that can be called via the SbOnce() system. - -#### Definition - -``` -typedef void(* SbOnceInitRoutine) (void) -``` - -## Functions - -### SbOnce - -Thread-safely runs `init_routine` only once. - -* If this `once_control` has not run a function yet, this function runs - `init_routine` in a thread-safe way and then returns `true`. - -* If SbOnce() was called with `once_control` before, the function returns - `true` immediately. - -* If `once_control` or `init_routine` is invalid, the function returns - `false`. - -#### Declaration - -``` -bool SbOnce(SbOnceControl *once_control, SbOnceInitRoutine init_routine) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/player.md b/cobalt/site/docs/reference/starboard/modules/13/player.md deleted file mode 100644 index 0dab908addc8..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/player.md +++ /dev/null @@ -1,475 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `player.h` - -Defines an interface for controlling playback of media elementary streams. - -## Macros - -### SB_PLAYER_INITIAL_TICKET - -The value of the initial ticket held by the player before the first seek. The -player will use this ticket value to make the first call to SbPlayerStatusFunc -with kSbPlayerStateInitialized. - -### SB_PLAYER_NO_DURATION - -The value to pass into SbPlayerCreate's `duration_pts` argument for cases where -the duration is unknown, such as for live streams. - -### kSbPlayerInvalid - -Well-defined value for an invalid player. - -## Enums - -### SbPlayerDecoderState - -An indicator of whether the decoder can accept more samples. - -#### Values - -* `kSbPlayerDecoderStateNeedsData` - - The decoder is asking for one more sample. - -### SbPlayerSampleSideDataType - -Identify the type of side data accompanied with `SbPlayerSampleInfo`, as side -data may come from multiple sources. - -#### Values - -* `kMatroskaBlockAdditional` - - The side data comes from the BlockAdditional data in the Matroska/Webm - container, as specified in [https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39](https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39)9) andnd [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional)l) - . The first 8 bytes of the data contains the value of BlockAddID in big - endian format, followed by the content of BlockAdditional. - -### SbPlayerState - -An indicator of the general playback state. - -#### Values - -* `kSbPlayerStateInitialized` - - The player has just been initialized. It is expecting an SbPlayerSeek() call - to enter the prerolling state. -* `kSbPlayerStatePrerolling` - - The player is prerolling, collecting enough data to fill the pipeline before - presentation starts. After the first preroll is completed, there should - always be a video frame to render, even if the player goes back to - Prerolling after a Seek. -* `kSbPlayerStatePresenting` - - The player is presenting media, and it is either paused or actively playing - in real-time. Note that the implementation should use this state to signal - that the preroll has been finished. -* `kSbPlayerStateEndOfStream` - - The player is presenting media, but it is paused at the end of the stream. -* `kSbPlayerStateDestroyed` - - The player has been destroyed, and will send no more callbacks. - -## Typedefs - -### SbPlayer - -An opaque handle to an implementation-private structure representing a player. - -#### Definition - -``` -typedef struct SbPlayerPrivate* SbPlayer -``` - -### SbPlayerDeallocateSampleFunc - -Callback to free the given sample buffer data. When more than one buffer are -sent in SbPlayerWriteSample(), the implementation only has to call this callback -with `sample_buffer` points to the first buffer. - -#### Definition - -``` -typedef void(* SbPlayerDeallocateSampleFunc) (SbPlayer player, void *context, const void *sample_buffer) -``` - -### SbPlayerDecoderStatusFunc - -Callback for decoder status updates, called in response to a call to -SbPlayerSeek() or SbPlayerWriteSample(). This callback will never be called -until at least one call to SbPlayerSeek has occurred. `ticket` will be set to -the ticket passed into the last received call to SbPlayerSeek() at the time this -callback was dispatched. This is to distinguish status callbacks for -interrupting seeks. These callbacks will happen on a different thread than the -calling thread, and it is not valid to call SbPlayer functions from within this -callback. After an update with kSbPlayerDecoderStateNeedsData, the user of the -player will make at most one call to SbPlayerWriteSample() or -SbPlayerWriteEndOfStream(). The player implementation should update the decoder -status again after such call to notify its user to continue writing more frames. - -#### Definition - -``` -typedef void(* SbPlayerDecoderStatusFunc) (SbPlayer player, void *context, SbMediaType type, SbPlayerDecoderState state, int ticket) -``` - -### SbPlayerErrorFunc - -Callback for player errors, that may set a `message`. `error`: indicates the -error code. `message`: provides specific informative diagnostic message about -the error condition encountered. It is ok for the message to be an empty string -or NULL if no information is available. - -#### Definition - -``` -typedef void(* SbPlayerErrorFunc) (SbPlayer player, void *context, SbPlayerError error, const char *message) -``` - -### SbPlayerStatusFunc - -Callback for player status updates. These callbacks will happen on a different -thread than the calling thread, and it is not valid to call SbPlayer functions -from within this callback. - -#### Definition - -``` -typedef void(* SbPlayerStatusFunc) (SbPlayer player, void *context, SbPlayerState state, int ticket) -``` - -## Structs - -### SbPlayerCreationParam - -The playback related parameters to pass into SbPlayerCreate() and -SbPlayerGetPreferredOutputMode(). - -#### Members - -* `SbDrmSystem drm_system` - - Provides an appropriate DRM system if the media stream has encrypted - portions. It will be `kSbDrmSystemInvalid` if the stream does not have - encrypted portions. -* `SbMediaAudioSampleInfo audio_sample_info` - - Contains a populated SbMediaAudioSampleInfo if `audio_sample_info.codec` - isn't `kSbMediaAudioCodecNone`. When `audio_sample_info.codec` is - `kSbMediaAudioCodecNone`, the video doesn't have an audio track. -* `SbMediaVideoSampleInfo video_sample_info` - - Contains a populated SbMediaVideoSampleInfo if `video_sample_info.codec` - isn't `kSbMediaVideoCodecNone`. When `video_sample_info.codec` is - `kSbMediaVideoCodecNone`, the video is audio only. -* `SbPlayerOutputMode output_mode` - - Selects how the decoded video frames will be output. For example, - `kSbPlayerOutputModePunchOut` indicates that the decoded video frames will - be output to a background video layer by the platform, and - `kSbPlayerOutputDecodeToTexture` indicates that the decoded video frames - should be made available for the application to pull via calls to - SbPlayerGetCurrentFrame(). - -### SbPlayerInfo2 - -Information about the current media playback state. - -#### Members - -* `SbTime current_media_timestamp` - - The position of the playback head, as precisely as possible, in - microseconds. -* `SbTime duration` - - The known duration of the currently playing media stream, in microseconds. -* `SbTime start_date` - - The result of getStartDate for the currently playing media stream, in - microseconds since the epoch of January 1, 1601 UTC. -* `int frame_width` - - The width of the currently displayed frame, in pixels, or 0 if not provided - by this player. -* `int frame_height` - - The height of the currently displayed frame, in pixels, or 0 if not provided - by this player. -* `bool is_paused` - - Whether playback is currently paused. -* `double volume` - - The current player volume in [0, 1]. -* `int total_video_frames` - - The number of video frames sent to the player since the creation of the - player. -* `int dropped_video_frames` - - The number of video frames decoded but not displayed since the creation of - the player. -* `int corrupted_video_frames` - - The number of video frames that failed to be decoded since the creation of - the player. -* `double playback_rate` - - The rate of playback. The video is played back in a speed that is - proportional to this. By default it is 1.0 which indicates that the playback - is at normal speed. When it is greater than one, the video is played in a - faster than normal speed. When it is less than one, the video is played in a - slower than normal speed. Negative speeds are not supported. - -### SbPlayerSampleInfo - -Information about the samples to be written into SbPlayerWriteSamples(). - -#### Members - -* `SbMediaType type` -* `const void * buffer` - - Points to the buffer containing the sample data. -* `int buffer_size` - - Size of the data pointed to by `buffer`. -* `SbTime timestamp` - - The timestamp of the sample in SbTime. -* `SbPlayerSampleSideData* side_data` - - Points to an array of side data for the input, when available. -* `int side_data_count` - - The number of side data pointed by `side_data`. It should be set to 0 if - there is no side data for the input. -* `SbMediaAudioSampleInfo audio_sample_info` - - Information about an audio sample. This value can only be used when `type` - is kSbMediaTypeAudio. -* `SbMediaVideoSampleInfo video_sample_info` - - Information about a video sample. This value can only be used when `type` is - kSbMediaTypeVideo. -* `union SbPlayerSampleInfo::@0 @1` -* `constSbDrmSampleInfo* drm_info` - - The DRM system related info for the media sample. This value is required for - encrypted samples. Otherwise, it must be `NULL`. - -### SbPlayerSampleSideData - -Side data accompanied with `SbPlayerSampleInfo`, it can be arbitrary binary data -coming from multiple sources. - -#### Members - -* `SbPlayerSampleSideDataType type` -* `const uint8_t * data` - - `data` will remain valid until SbPlayerDeallocateSampleFunc() is called on - the `SbPlayerSampleInfo::buffer` the data is associated with. -* `size_t size` - - The size of the data pointed by `data`, in bytes. - -## Functions - -### SbPlayerDestroy - -Destroys `player`, freeing all associated resources. - -* Upon calling this method, there should be one call to the player status - callback (i.e. `player_status_func` used in the creation of the player) - which indicates the player is destroyed. Note, the callback has to be in- - flight when SbPlayerDestroyed is called. - -* No more other callbacks should be issued after this function returns. - -* It is not allowed to pass `player` into any other `SbPlayer` function once - SbPlayerDestroy has been called on that player. `player`: The player to be - destroyed. Must not be `kSbPlayerInvalid`. - -#### Declaration - -``` -void SbPlayerDestroy(SbPlayer player) -``` - -### SbPlayerGetCurrentFrame - -Given a player created with the kSbPlayerOutputModeDecodeToTexture output mode, -it will return a SbDecodeTarget representing the current frame to be rasterized. -On GLES systems, this function must be called on a thread with an EGLContext -current, and specifically the EGLContext that will be used to eventually render -the frame. If this function is called with a `player` object that was created -with an output mode other than kSbPlayerOutputModeDecodeToTexture, -kSbDecodeTargetInvalid is returned. - -`player` must not be `kSbPlayerInvalid`. - -#### Declaration - -``` -SbDecodeTarget SbPlayerGetCurrentFrame(SbPlayer player) -``` - -### SbPlayerGetMaximumNumberOfSamplesPerWrite - -Writes a single sample of the given media type to `player`'s input stream. Its -data may be passed in via more than one buffers. The lifetime of -`sample_buffers`, `sample_buffer_sizes`, `video_sample_info`, and -`sample_drm_info` (as well as member `subsample_mapping` contained inside it) -are not guaranteed past the call to SbPlayerWriteSample. That means that before -returning, the implementation must synchronously copy any information it wants -to retain from those structures. - -`player`: The player for which the number is retrieved. `sample_type`: The type -of sample for which the number is retrieved. See the `SbMediaType` enum in -media.h. - -#### Declaration - -``` -int SbPlayerGetMaximumNumberOfSamplesPerWrite(SbPlayer player, SbMediaType sample_type) -``` - -### SbPlayerGetPreferredOutputMode - -Returns the preferred output mode of the implementation when a video described -by `creation_param` is played. It is assumed that it is okay to call -SbPlayerCreate() with the same video described by `creation_param`, with its -`output_mode` member replaced by the returned output mode. When the caller has -no preference on the output mode, it will set `creation_param->output_mode` to -`kSbPlayerOutputModeInvalid`, and the implementation can return its preferred -output mode based on the information contained in `creation_param`. The caller -can also set `creation_param->output_mode` to its preferred output mode, and the -implementation should return the same output mode if it is supported, otherwise -the implementation should return an output mode that it is supported, as if -`creation_param->output_mode` is set to `kSbPlayerOutputModeInvalid` prior to -the call. Note that it is not the responsibility of this function to verify -whether the video described by `creation_param` can be played on the platform, -and the implementation should try its best effort to return a valid output mode. -`creation_param` must not be NULL. - -#### Declaration - -``` -SbPlayerOutputMode SbPlayerGetPreferredOutputMode(const SbPlayerCreationParam *creation_param) -``` - -### SbPlayerIsValid - -Returns whether the given player handle is valid. - -#### Declaration - -``` -static bool SbPlayerIsValid(SbPlayer player) -``` - -### SbPlayerSetBounds - -Sets the player bounds to the given graphics plane coordinates. The changes do -not take effect until the next graphics frame buffer swap. The default bounds -for a player is the full screen. This function is only relevant when the -`player` is created with the kSbPlayerOutputModePunchOut output mode, and if -this is not the case then this function call can be ignored. - -This function is called on every graphics frame that changes the video bounds. -For example, if the video bounds are being animated, then this will be called at -up to 60 Hz. Since the function could be called up to once per frame, -implementors should take care to avoid related performance concerns with such -frequent calls. - -`player`: The player that is being resized. Must not be `kSbPlayerInvalid`. -`z_index`: The z-index of the player. When the bounds of multiple players are -overlapped, the one with larger z-index will be rendered on top of the ones with -smaller z-index. `x`: The x-coordinate of the upper-left corner of the player. -`y`: The y-coordinate of the upper-left corner of the player. `width`: The width -of the player, in pixels. `height`: The height of the player, in pixels. - -#### Declaration - -``` -void SbPlayerSetBounds(SbPlayer player, int z_index, int x, int y, int width, int height) -``` - -### SbPlayerSetPlaybackRate - -Set the playback rate of the `player`. `rate` is default to 1.0 which indicates -the playback is at its original speed. A `rate` greater than one will make the -playback faster than its original speed. For example, when `rate` is 2, the -video will be played at twice the speed as its original speed. A `rate` less -than 1.0 will make the playback slower than its original speed. When `rate` is -0, the playback will be paused. The function returns true when the playback rate -is set to `playback_rate` or to a rate that is close to `playback_rate` which -the implementation supports. It returns false when the playback rate is -unchanged, this can happen when `playback_rate` is negative or if it is too high -to support. - -`player` must not be `kSbPlayerInvalid`. - -#### Declaration - -``` -bool SbPlayerSetPlaybackRate(SbPlayer player, double playback_rate) -``` - -### SbPlayerSetVolume - -Sets the player's volume. - -`player`: The player in which the volume is being adjusted. Must not be -`kSbPlayerInvalid`. `volume`: The new player volume. The value must be between -`0.0` and `1.0`, inclusive. A value of `0.0` means that the audio should be -muted, and a value of `1.0` means that it should be played at full volume. - -#### Declaration - -``` -void SbPlayerSetVolume(SbPlayer player, double volume) -``` - -### SbPlayerWriteEndOfStream - -Writes a marker to `player`'s input stream of `stream_type` indicating that -there are no more samples for that media type for the remainder of this media -stream. This marker is invalidated, along with the rest of the stream's -contents, after a call to SbPlayerSeek. - -`player`: The player to which the marker is written. `stream_type`: The type of -stream for which the marker is written. - -#### Declaration - -``` -void SbPlayerWriteEndOfStream(SbPlayer player, SbMediaType stream_type) -``` - -### SbPlayerWriteSample2 - -`sample_type`: The type of sample being written. See the `SbMediaType` enum in -media.h. `sample_infos`: A pointer to an array of SbPlayerSampleInfo with -`number_of_sample_infos` elements, each holds the data for an sample, i.e. a -sequence of whole NAL Units for video, or a complete audio frame. `sample_infos` -cannot be assumed to live past the call into SbPlayerWriteSamples(), so it must -be copied if its content will be used after SbPlayerWriteSamples() returns. -`number_of_sample_infos`: Specify the number of samples contained inside -`sample_infos`. It has to be at least one, and less than the return value of -SbPlayerGetMaximumNumberOfSamplesPerWrite(). - -#### Declaration - -``` -void SbPlayerWriteSample2(SbPlayer player, SbMediaType sample_type, const SbPlayerSampleInfo *sample_infos, int number_of_sample_infos) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/storage.md b/cobalt/site/docs/reference/starboard/modules/13/storage.md deleted file mode 100644 index f20016113be1..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/storage.md +++ /dev/null @@ -1,158 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `storage.h` - -Defines a Storage API. This is a simple, all-at-once BLOB storage and retrieval -API that is intended for robust long-term storage. Some platforms have different -mechanisms for this kind of storage, so this API exists to allow a client -application to access this kind of storage. - -Note that there can be only one storage record and, thus, a maximum of one open -storage record can exist. Attempting to open a second record will result in -undefined behavior. - -These APIs are NOT expected to be thread-safe, so either call them from a single -thread, or perform proper synchronization around all calls. - -## Macros - -### kSbStorageInvalidRecord - -Well-defined value for an invalid storage record handle. - -## Typedefs - -### SbStorageRecord - -A handle to an open storage record. - -#### Definition - -``` -typedef SbStorageRecordPrivate* SbStorageRecord -``` - -## Functions - -### SbStorageCloseRecord - -Closes `record`, synchronously ensuring that all written data is flushed. This -function performs blocking I/O on the calling thread. - -The return value indicates whether the operation succeeded. Storage writes -should be as atomic as possible, so the record should either be fully written or -deleted (or, even better, untouched). - -`record`: The storage record to close. `record` is invalid after this point, and -subsequent calls referring to `record` will fail. - -#### Declaration - -``` -bool SbStorageCloseRecord(SbStorageRecord record) -``` - -### SbStorageDeleteRecord - -Deletes the `SbStorageRecord` for `user` named `name`. The return value -indicates whether the record existed and was successfully deleted. If the record -did not exist or could not be deleted, the function returns `false`. - -If `name` is NULL, deletes the default storage record for the user, like what -would have been deleted with the previous version of SbStorageDeleteRecord. - -This function must not be called while the user's storage record is open. This -function performs blocking I/O on the calling thread. - -`user`: The user for whom the record will be deleted. `name`: The filesystem- -safe name of the record to open. - -#### Declaration - -``` -bool SbStorageDeleteRecord(SbUser user, const char *name) -``` - -### SbStorageGetRecordSize - -Returns the size of `record`, or `-1` if there is an error. This function -performs blocking I/O on the calling thread. - -`record`: The record to retrieve the size of. - -#### Declaration - -``` -int64_t SbStorageGetRecordSize(SbStorageRecord record) -``` - -### SbStorageIsValidRecord - -Returns whether the given storage record handle is valid. - -#### Declaration - -``` -static bool SbStorageIsValidRecord(SbStorageRecord record) -``` - -### SbStorageOpenRecord - -Opens and returns the SbStorageRecord for `user` named `name`, blocking I/O on -the calling thread until the open is completed. If `user` is not a valid -`SbUser`, the function returns `kSbStorageInvalidRecord`. Will return an -`SbStorageRecord` of size zero if the record does not yet exist. Opening an -already-open `SbStorageRecord` has undefined behavior. - -If `name` is NULL, opens the default storage record for the user, like what -would have been saved with the previous version of SbStorageOpenRecord. - -`user`: The user for which the storage record will be opened. `name`: The -filesystem-safe name of the record to open. - -#### Declaration - -``` -SbStorageRecord SbStorageOpenRecord(SbUser user, const char *name) -``` - -### SbStorageReadRecord - -Reads up to `data_size` bytes from `record`, starting at the beginning of the -record. The function returns the actual number of bytes read, which must be <= -`data_size`. The function returns `-1` in the event of an error. This function -makes a best-effort to read the entire record, and it performs blocking I/O on -the calling thread until the entire record is read or an error is encountered. - -`record`: The record to be read. `out_data`: The data read from the record. -`data_size`: The amount of data, in bytes, to read. - -#### Declaration - -``` -int64_t SbStorageReadRecord(SbStorageRecord record, char *out_data, int64_t data_size) -``` - -### SbStorageWriteRecord - -Replaces the data in `record` with `data_size` bytes from `data`. This function -always deletes any previous data in that record. The return value indicates -whether the write succeeded. This function makes a best-effort to write the -entire record, and it may perform blocking I/O on the calling thread until the -entire record is written or an error is encountered. - -While `SbStorageWriteRecord()` may defer the persistence, -`SbStorageReadRecord()` is expected to work as expected immediately afterwards, -even without a call to `SbStorageCloseRecord()`. The data should be persisted -after a short time, even if there is an unexpected process termination before -`SbStorageCloseRecord()` is called. - -`record`: The record to be written to. `data`: The data to write to the record. -`data_size`: The amount of `data`, in bytes, to write to the record. - -#### Declaration - -``` -bool SbStorageWriteRecord(SbStorageRecord record, const char *data, int64_t data_size) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/string.md b/cobalt/site/docs/reference/starboard/modules/13/string.md deleted file mode 100644 index 3fed809df461..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/string.md +++ /dev/null @@ -1,174 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `string.h` - -Defines functions for interacting with c-style strings. - -## Functions - -### SbStringCompareNoCase - -Compares two strings, ignoring differences in case. The return value is: - -* `< 0` if `string1` is ASCII-betically lower than `string2`. - -* `0` if the two strings are equal. - -* `> 0` if `string1` is ASCII-betically higher than `string2`. - -This function is meant to be a drop-in replacement for `strcasecmp`. - -`string1`: The first string to compare. `string2`: The second string to compare. - -#### Declaration - -``` -int SbStringCompareNoCase(const char *string1, const char *string2) -``` - -### SbStringCompareNoCaseN - -Compares the first `count` characters of two strings, ignoring differences in -case. The return value is: - -* `< 0` if `string1` is ASCII-betically lower than `string2`. - -* `0` if the two strings are equal. - -* `> 0` if `string1` is ASCII-betically higher than `string2`. - -This function is meant to be a drop-in replacement for `strncasecmp`. - -`string1`: The first string to compare. `string2`: The second string to compare. -`count`: The number of characters to compare. - -#### Declaration - -``` -int SbStringCompareNoCaseN(const char *string1, const char *string2, size_t count) -``` - -### SbStringDuplicate - -Copies `source` into a buffer that is allocated by this function and that can be -freed with SbMemoryDeallocate. This function is meant to be a drop-in -replacement for `strdup`. - -`source`: The string to be copied. - -#### Declaration - -``` -char* SbStringDuplicate(const char *source) -``` - -### SbStringFormat - -Produces a string formatted with `format` and `arguments`, placing as much of -the result that will fit into `out_buffer`. The return value specifies the -number of characters that the format would produce if `buffer_size` were -infinite. - -This function is meant to be a drop-in replacement for `vsnprintf`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `arguments`: Variable arguments used in the string. - -#### Declaration - -``` -int SbStringFormat(char *out_buffer, size_t buffer_size, const char *format, va_list arguments) SB_PRINTF_FORMAT(3 -``` - -### SbStringFormatF - -An inline wrapper of SbStringFormat that converts from ellipsis to va_args. This -function is meant to be a drop-in replacement for `snprintf`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `...`: Arguments used in the string. - -#### Declaration - -``` -int static int static int SbStringFormatF(char *out_buffer, size_t buffer_size, const char *format,...) SB_PRINTF_FORMAT(3 -``` - -### SbStringFormatUnsafeF - -An inline wrapper of SbStringFormat that is meant to be a drop-in replacement -for the unsafe but commonly used `sprintf`. - -`out_buffer`: The location where the formatted string is stored. `format`: A -string that specifies how the data should be formatted. `...`: Arguments used in -the string. - -#### Declaration - -``` -static int static int SbStringFormatUnsafeF(char *out_buffer, const char *format,...) SB_PRINTF_FORMAT(2 -``` - -### SbStringFormatWide - -This function is identical to SbStringFormat, but is for wide characters. It is -meant to be a drop-in replacement for `vswprintf`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `arguments`: Variable arguments used in the string. - -#### Declaration - -``` -int SbStringFormatWide(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format, va_list arguments) -``` - -### SbStringFormatWideF - -An inline wrapper of SbStringFormatWide that converts from ellipsis to -`va_args`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `...`: Arguments used in the string. - -#### Declaration - -``` -static int SbStringFormatWideF(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format,...) -``` - -### SbStringScan - -Scans `buffer` for `pattern`, placing the extracted values in `arguments`. The -return value specifies the number of successfully matched items, which may be -`0`. - -This function is meant to be a drop-in replacement for `vsscanf`. - -`buffer`: The string to scan for the pattern. `pattern`: The string to search -for in `buffer`. `arguments`: Values matching `pattern` that were extracted from -`buffer`. - -#### Declaration - -``` -int SbStringScan(const char *buffer, const char *pattern, va_list arguments) -``` - -### SbStringScanF - -An inline wrapper of SbStringScan that converts from ellipsis to `va_args`. This -function is meant to be a drop-in replacement for `sscanf`. `buffer`: The string -to scan for the pattern. `pattern`: The string to search for in `buffer`. `...`: -Values matching `pattern` that were extracted from `buffer`. - -#### Declaration - -``` -static int SbStringScanF(const char *buffer, const char *pattern,...) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/thread.md b/cobalt/site/docs/reference/starboard/modules/13/thread.md deleted file mode 100644 index 56c7898a12b4..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/thread.md +++ /dev/null @@ -1,533 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `thread.h` - -Defines functionality related to thread creation and cleanup. - -## Macros - -### kSbThreadContextInvalid - -Well-defined value for an invalid thread context. - -### kSbThreadInvalidId - -Well-defined constant value to mean "no thread ID." - -### kSbThreadLocalKeyInvalid - -Well-defined constant value to mean "no thread local key." - -### kSbThreadNoAffinity - -Well-defined constant value to mean "no affinity." - -### kSbThreadSamplerInvalid - -Well-defined value for an invalid thread sampler. - -## Enums - -### SbThreadPriority - -A spectrum of thread priorities. Platforms map them appropriately to their own -priority system. Note that scheduling is platform-specific, and what these -priorities mean, if they mean anything at all, is also platform-specific. - -In particular, several of these priority values can map to the same priority on -a given platform. The only guarantee is that each lower priority should be -treated less-than-or-equal-to a higher priority. - -#### Values - -* `kSbThreadPriorityLowest` - - The lowest thread priority available on the current platform. -* `kSbThreadPriorityLow` - - A lower-than-normal thread priority, if available on the current platform. -* `kSbThreadPriorityNormal` - - Really, what is normal? You should spend time pondering that question more - than you consider less-important things, but less than you think about more- - important things. -* `kSbThreadPriorityHigh` - - A higher-than-normal thread priority, if available on the current platform. -* `kSbThreadPriorityHighest` - - The highest thread priority available on the current platform that isn't - considered "real-time" or "time-critical," if those terms have any meaning - on the current platform. -* `kSbThreadPriorityRealTime` - - If the platform provides any kind of real-time or time-critical scheduling, - this priority will request that treatment. Real-time scheduling generally - means that the thread will have more consistency in scheduling than non- - real-time scheduled threads, often by being more deterministic in how - threads run in relation to each other. But exactly how being real-time - affects the thread scheduling is platform-specific. - - For platforms where that is not offered, or otherwise not meaningful, this - will just be the highest priority available in the platform's scheme, which - may be the same as kSbThreadPriorityHighest. -* `kSbThreadNoPriority` - - Well-defined constant value to mean "no priority." This means to use the - default priority assignment method of that platform. This may mean to - inherit the priority of the spawning thread, or it may mean a specific - default priority, or it may mean something else, depending on the platform. - -## Typedefs - -### SbThread - -An opaque handle to a thread type. - -#### Definition - -``` -typedef void* SbThread -``` - -### SbThreadAffinity - -Type for thread core affinity. This generally will be a single cpu (or core or -hyperthread) identifier. Some platforms may not support affinity, and some may -have specific rules about how it must be used. - -#### Definition - -``` -typedef int32_t SbThreadAffinity -``` - -### SbThreadContext - -A handle to the context of a frozen thread. - -#### Definition - -``` -typedef SbThreadContextPrivate* SbThreadContext -``` - -### SbThreadEntryPoint - -Function pointer type for SbThreadCreate. `context` is a pointer-sized bit of -data passed in from the calling thread. - -#### Definition - -``` -typedef void*(* SbThreadEntryPoint) (void *context) -``` - -### SbThreadId - -An ID type that is unique per thread. - -#### Definition - -``` -typedef int32_t SbThreadId -``` - -### SbThreadLocalDestructor - -Function pointer type for Thread-Local destructors. - -#### Definition - -``` -typedef void(* SbThreadLocalDestructor) (void *value) -``` - -### SbThreadLocalKey - -A handle to a thread-local key. - -#### Definition - -``` -typedef SbThreadLocalKeyPrivate* SbThreadLocalKey -``` - -### SbThreadSampler - -A handle to a thread sampler. - -#### Definition - -``` -typedef SbThreadSamplerPrivate* SbThreadSampler -``` - -## Functions - -### SbThreadContextGetPointer - -Gets the specified pointer-type `property` from the specified `context`. Returns -`true` if successful and `out_value` has been modified, otherwise returns -`false` and `out_value` is not modified. - -#### Declaration - -``` -bool SbThreadContextGetPointer(SbThreadContext context, SbThreadContextProperty property, void **out_value) -``` - -### SbThreadContextIsValid - -Returns whether the given thread context is valid. - -#### Declaration - -``` -static bool SbThreadContextIsValid(SbThreadContext context) -``` - -### SbThreadCreate - -Creates a new thread, which starts immediately. - -* If the function succeeds, the return value is a handle to the newly created - thread. - -* If the function fails, the return value is `kSbThreadInvalid`. - -`stack_size`: The amount of memory reserved for the thread. Set the value to `0` -to indicate that the default stack size should be used. `priority`: The thread's -priority. This value can be set to `kSbThreadNoPriority` to use the platform's -default priority. As examples, it could be set to a fixed, standard priority or -to a priority inherited from the thread that is calling SbThreadCreate(), or to -something else. `affinity`: The thread's affinity. This value can be set to -`kSbThreadNoAffinity` to use the platform's default affinity. `joinable`: -Indicates whether the thread can be joined (`true`) or should start out -"detached" (`false`). Note that for joinable threads, when you are done with the -thread handle, you must call `SbThreadJoin` to release system resources -associated with the thread. This is not necessary for detached threads, but -detached threads cannot be joined. `name`: A name used to identify the thread. -This value is used mainly for debugging, it can be `NULL`, and it might not be -used in production builds. `entry_point`: A pointer to a function that will be -executed on the newly created thread. `context`: This value will be passed to -the `entry_point` function. - -#### Declaration - -``` -SbThread SbThreadCreate(int64_t stack_size, SbThreadPriority priority, SbThreadAffinity affinity, bool joinable, const char *name, SbThreadEntryPoint entry_point, void *context) -``` - -### SbThreadCreateLocalKey - -Creates and returns a new, unique key for thread local data. If the function -does not succeed, the function returns `kSbThreadLocalKeyInvalid`. - -If `destructor` is specified, it will be called in the owning thread, and only -in the owning thread, when the thread exits. In that case, it is called on the -local value associated with the key in the current thread as long as the local -value is not NULL. - -`destructor`: A pointer to a function. The value may be NULL if no clean up is -needed. - -#### Declaration - -``` -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) -``` - -### SbThreadDestroyLocalKey - -Destroys thread local data for the specified key. The function is a no-op if the -key is invalid (kSbThreadLocalKeyInvalid`) or has already been destroyed. This -function does NOT call the destructor on any stored values. - -`key`: The key for which to destroy thread local data. - -#### Declaration - -``` -void SbThreadDestroyLocalKey(SbThreadLocalKey key) -``` - -### SbThreadDetach - -Detaches `thread`, which prevents it from being joined. This is sort of like a -non-blocking join. This function is a no-op if the thread is already detached or -if the thread is already being joined by another thread. - -`thread`: The thread to be detached. - -#### Declaration - -``` -void SbThreadDetach(SbThread thread) -``` - -### SbThreadGetCurrent - -Returns the handle of the currently executing thread. - -#### Declaration - -``` -SbThread SbThreadGetCurrent() -``` - -### SbThreadGetId - -Returns the Thread ID of the currently executing thread. - -#### Declaration - -``` -SbThreadId SbThreadGetId() -``` - -### SbThreadGetLocalValue - -Returns the pointer-sized value for `key` in the currently executing thread's -local storage. Returns `NULL` if key is `kSbThreadLocalKeyInvalid` or if the key -has already been destroyed. - -`key`: The key for which to return the value. - -#### Declaration - -``` -void* SbThreadGetLocalValue(SbThreadLocalKey key) -``` - -### SbThreadGetName - -Returns the debug name of the currently executing thread. - -#### Declaration - -``` -void SbThreadGetName(char *buffer, int buffer_size) -``` - -### SbThreadIsCurrent - -Returns whether `thread` is the current thread. - -`thread`: The thread to check. - -#### Declaration - -``` -static bool SbThreadIsCurrent(SbThread thread) -``` - -### SbThreadIsEqual - -Indicates whether `thread1` and `thread2` refer to the same thread. - -`thread1`: The first thread to compare. `thread2`: The second thread to compare. - -#### Declaration - -``` -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) -``` - -### SbThreadIsValid - -Returns whether the given thread handle is valid. - -#### Declaration - -``` -static bool SbThreadIsValid(SbThread thread) -``` - -### SbThreadIsValidAffinity - -Returns whether the given thread affinity is valid. - -#### Declaration - -``` -static bool SbThreadIsValidAffinity(SbThreadAffinity affinity) -``` - -### SbThreadIsValidId - -Returns whether the given thread ID is valid. - -#### Declaration - -``` -static bool SbThreadIsValidId(SbThreadId id) -``` - -### SbThreadIsValidLocalKey - -Returns whether the given thread local variable key is valid. - -#### Declaration - -``` -static bool SbThreadIsValidLocalKey(SbThreadLocalKey key) -``` - -### SbThreadIsValidPriority - -Returns whether the given thread priority is valid. - -#### Declaration - -``` -static bool SbThreadIsValidPriority(SbThreadPriority priority) -``` - -### SbThreadJoin - -Joins the thread on which this function is called with joinable `thread`. This -function blocks the caller until the designated thread exits, and then cleans up -that thread's resources. The cleanup process essentially detaches thread. - -The return value is `true` if the function is successful and `false` if `thread` -is invalid or detached. - -Each joinable thread can only be joined once and must be joined to be fully -cleaned up. Once SbThreadJoin is called, the thread behaves as if it were -detached to all threads other than the joining thread. - -`thread`: The thread to which the current thread will be joined. The `thread` -must have been created with SbThreadCreate. `out_return`: If this is not `NULL`, -then the SbThreadJoin function populates it with the return value of the -thread's `main` function. - -#### Declaration - -``` -bool SbThreadJoin(SbThread thread, void **out_return) -``` - -### SbThreadSamplerCreate - -Creates a new thread sampler for the specified `thread`. - -If successful, this function returns the newly created handle. If unsuccessful, -this function returns `kSbThreadSamplerInvalid`. - -#### Declaration - -``` -SbThreadSampler SbThreadSamplerCreate(SbThread thread) -``` - -### SbThreadSamplerDestroy - -Destroys the `sampler` and frees whatever resources it was using. - -#### Declaration - -``` -void SbThreadSamplerDestroy(SbThreadSampler sampler) -``` - -### SbThreadSamplerFreeze - -Suspends execution of the thread that `sampler` was created for. - -If successful, this function returns a `SbThreadContext` for the frozen thread, -from which properties may be read while the thread remains frozen. If -unsuccessful, this function returns `kSbThreadContextInvalid`. - -#### Declaration - -``` -SbThreadContext SbThreadSamplerFreeze(SbThreadSampler sampler) -``` - -### SbThreadSamplerIsSupported - -Whether the current platform supports thread sampling. The result of this -function must not change over the course of the program, which means that the -results of this function may be cached indefinitely. If this returns false, -`SbThreadSamplerCreate` will return an invalid sampler. - -#### Declaration - -``` -bool SbThreadSamplerIsSupported() -``` - -### SbThreadSamplerIsValid - -Returns whether the given thread sampler is valid. - -#### Declaration - -``` -static bool SbThreadSamplerIsValid(SbThreadSampler sampler) -``` - -### SbThreadSamplerThaw - -Resumes execution of the thread that `sampler` was created for. This invalidates -the context returned from `SbThreadSamplerFreeze`. - -#### Declaration - -``` -bool SbThreadSamplerThaw(SbThreadSampler sampler) -``` - -### SbThreadSetLocalValue - -Sets the pointer-sized value for `key` in the currently executing thread's local -storage. The return value indicates whether `key` is valid and has not already -been destroyed. - -`key`: The key for which to set the key value. `value`: The new pointer-sized -key value. - -#### Declaration - -``` -bool SbThreadSetLocalValue(SbThreadLocalKey key, void *value) -``` - -### SbThreadSetName - -Sets the debug name of the currently executing thread by copying the specified -name string. - -`name`: The name to assign to the thread. - -#### Declaration - -``` -void SbThreadSetName(const char *name) -``` - -### SbThreadSleep - -Sleeps the currently executing thread. - -`duration`: The minimum amount of time, in microseconds, that the currently -executing thread should sleep. The function is a no-op if this value is negative -or `0`. - -#### Declaration - -``` -void SbThreadSleep(SbTime duration) -``` - -### SbThreadYield - -Yields the currently executing thread, so another thread has a chance to run. - -#### Declaration - -``` -void SbThreadYield() -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/time.md b/cobalt/site/docs/reference/starboard/modules/13/time.md deleted file mode 100644 index a6228cc0de6c..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/time.md +++ /dev/null @@ -1,152 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `time.h` - -Provides access to system time and timers. - -## Macros - -### kSbTimeDay - -One day in SbTime units (microseconds). - -### kSbTimeHour - -One hour in SbTime units (microseconds). - -### kSbTimeMax - -The maximum value of an SbTime. - -### kSbTimeMillisecond - -One millisecond in SbTime units (microseconds). - -### kSbTimeMinute - -One minute in SbTime units (microseconds). - -### kSbTimeNanosecondsPerMicrosecond - -How many nanoseconds in one SbTime unit (microseconds). - -### kSbTimeSecond - -One second in SbTime units (microseconds). - -### kSbTimeToPosixDelta - -A term that can be added to an SbTime to convert it into the number of -microseconds since the POSIX epoch. - -## Typedefs - -### SbTime - -The number of microseconds since the epoch of January 1, 1601 UTC, or the number -of microseconds between two times. Always microseconds, ALWAYS UTC. - -#### Definition - -``` -typedef int64_t SbTime -``` - -### SbTimeMonotonic - -A number of microseconds from some point. The main property of this time is that -it increases monotonically. It should also be as high-resolution a timer as we -can get on a platform. So, it is good for measuring the time between two calls -without worrying about a system clock adjustment. It's not good for getting the -wall clock time. - -#### Definition - -``` -typedef int64_t SbTimeMonotonic -``` - -## Functions - -### SbTimeFromPosix - -Converts microseconds from the POSIX epoch into an `SbTime`. - -`time`: A time that measures the number of microseconds since January 1, 1970, -00:00:00, UTC. - -#### Declaration - -``` -static SbTime SbTimeFromPosix(int64_t time) -``` - -### SbTimeGetMonotonicNow - -Gets a monotonically increasing time representing right now. - -#### Declaration - -``` -SbTimeMonotonic SbTimeGetMonotonicNow() -``` - -### SbTimeGetMonotonicThreadNow - -Gets a monotonically increasing time representing how long the current thread -has been in the executing state (i.e. not pre-empted nor waiting on an event). -This is not necessarily total time and is intended to allow measuring thread -execution time between two timestamps. If this is not available then -SbTimeGetMonotonicNow() should be used. - -#### Declaration - -``` -SbTimeMonotonic SbTimeGetMonotonicThreadNow() -``` - -### SbTimeGetNow - -Gets the current system time as an `SbTime`. - -#### Declaration - -``` -SbTime SbTimeGetNow() -``` - -### SbTimeIsTimeThreadNowSupported - -Returns whether the current platform supports time thread now - -#### Declaration - -``` -bool SbTimeIsTimeThreadNowSupported() -``` - -### SbTimeNarrow - -Safely narrows a number from a more precise unit to a less precise one. This -function rounds negative values toward negative infinity. - -#### Declaration - -``` -static int64_t SbTimeNarrow(int64_t time, int64_t divisor) -``` - -### SbTimeToPosix - -Converts `SbTime` into microseconds from the POSIX epoch. - -`time`: A time that is either measured in microseconds since the epoch of -January 1, 1601, UTC, or that measures the number of microseconds between two -times. - -#### Declaration - -``` -static int64_t SbTimeToPosix(SbTime time) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/time_zone.md b/cobalt/site/docs/reference/starboard/modules/13/time_zone.md deleted file mode 100644 index 74d48172d63e..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/time_zone.md +++ /dev/null @@ -1,47 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `time_zone.h` - -Provides access to the system time zone information. - -## Typedefs - -### SbTimeZone - -The number of minutes west of the Greenwich Prime Meridian, NOT including -Daylight Savings Time adjustments. - -For example: PST/PDT is 480 minutes (28800 seconds, 8 hours). - -#### Definition - -``` -typedef int SbTimeZone -``` - -## Functions - -### SbTimeZoneGetCurrent - -Gets the system's current SbTimeZone in minutes. - -#### Declaration - -``` -SbTimeZone SbTimeZoneGetCurrent() -``` - -### SbTimeZoneGetName - -Gets a string representation of the current timezone. Note that the string -representation can either be standard or daylight saving time. The output can be -of the form: 1) A three-letter abbreviation such as "PST" or "PDT" (preferred). -2) A time zone identifier such as "America/Los_Angeles" 3) An un-abbreviated -name such as "Pacific Standard Time". - -#### Declaration - -``` -const char* SbTimeZoneGetName() -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/ui_navigation.md b/cobalt/site/docs/reference/starboard/modules/13/ui_navigation.md deleted file mode 100644 index cb4176713005..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/ui_navigation.md +++ /dev/null @@ -1,322 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `ui_navigation.h` - -API to allow applications to take advantage of the platform's native UI engine. -This is mainly to drive the animation of visual elements and to signal which of -those elements have focus. The implementation should not render any visual -elements; instead, it will be used to guide the app in where these elements -should be drawn. - -When the application creates the user interface, it will create SbUiNavItems for -interactable elements. Additionally, the app must specify the position and size -of these navigation items. As the app's user interface changes, it will create -and destroy navigation items as appropriate. - -For each render frame, the app will query the local transform for each -SbUiNavItem in case the native UI engine moves individual items in response to -user interaction. If the navigation item is a container, then the content offset -will also be queried to determine the placement of its content items. - -## Macros - -### kSbUiNavItemInvalid - -Well-defined value for an invalid navigation item. - -## Enums - -### SbUiNavItemType - -Navigation items may be one of the following types. This must be specified upon -item creation and may not change during the item's lifespan. - -#### Values - -* `kSbUiNavItemTypeFocus` - - This is a single focusable item. -* `kSbUiNavItemTypeContainer` - - This is a container of navigation items which can also be containers - themselves or focusable items. Containers themselves cannot be focused. - -## Typedefs - -### SbUiNavItem - -An opaque handle to an implementation-private structure representing a -navigation item. - -#### Definition - -``` -typedef struct SbUiNavItemPrivate* SbUiNavItem -``` - -## Structs - -### SbUiNavCallbacks - -This structure specifies all the callbacks which the platform UI engine should -invoke for various interaction events on navigation items. These callbacks may -be invoked from any thread at any frequency. The `callback_context` is the value -that was passed on creation of the relevant SbUiNavItem. - -#### Members - -* `void(*onblur)(SbUiNavItem item, void *callback_context)` - - Invoke when an item has lost focus. This is only used with focus items. -* `void(*onfocus)(SbUiNavItem item, void *callback_context)` - - Invoke when an item has gained focus. This is only used with focus items. -* `void(*onscroll)(SbUiNavItem item, void *callback_context)` - - Invoke when an item's content offset is changed. This is only used with - container items. - -### SbUiNavInterface - -This structure declares the interface to the UI navigation implementation. All -function pointers must be specified if the platform supports UI navigation. - -#### Members - -* `SbUiNavItem(*create_item)(SbUiNavItemType type, const SbUiNavCallbacks - *callbacks, void *callback_context)` - - Create a new navigation item. When the user interacts with this item the - appropriate SbUiNavCallbacks function will be invoked with the provided - `callback_context`. An item is not interactable until it is enabled. -* `void(*destroy_item)(SbUiNavItem item)` - - Destroy the given navigation item. If this is a content of another item, - then it will first be unregistered. Additionally, if this item contains - other items, then those will be unregistered as well, but they will not be - automatically destroyed. -* `void(*set_focus)(SbUiNavItem item)` - - This is used to manually force focus on a navigation item of type - kSbUiNavItemTypeFocus. Any previously focused navigation item should receive - the blur event. If the item is not transitively a content of the root item, - then this does nothing. - - Specifying kSbUiNavItemInvalid should remove focus from the UI navigation - system. -* `void(*set_item_enabled)(SbUiNavItem item, bool enabled)` - - This is used to enable or disable user interaction with the specified - navigation item. All navigation items are disabled when created, and they - must be explicitly enabled to allow user interaction. If a container is - disabled, then all of its contents are not interactable even though they - remain enabled. If `enabled` is false, it must be guaranteed that once this - function returns, no callbacks associated with this item will be invoked - until the item is re-enabled. -* `void(*set_item_dir)(SbUiNavItem item, SbUiNavItemDir dir)` - - This specifies directionality for container items. Containers within - containers do not inherit directionality. Directionality must be specified - for each container explicitly. - - This should work even if `item` is disabled. -* `void(*set_item_focus_duration)(SbUiNavItem item, float seconds)` - - Set the minimum amount of time the focus item should remain focused once it - becomes focused. This may be used to make important focus items harder to - navigate over. Focus may still be moved before `seconds` has elapsed by - using the set_focus() function. By default, item focus duration is 0 - seconds. -* `void(*set_item_size)(SbUiNavItem item, float width, float height)` - - Set the interactable size of the specified navigation item. By default, an - item's size is (0,0). -* `void(*set_item_transform)(SbUiNavItem item, const SbUiNavMatrix2x3 - *transform)` - - Set the transform for the navigation item and its contents if the item is a - container. This specifies the placement of the item's center within its - container. The transform origin is the center of the item. Distance is - measured in pixels with the origin being the top-left of the item's - container. By default, an item's transform is identity. -* `bool(*get_item_focus_transform)(SbUiNavItem item, SbUiNavMatrix4 - *out_transform)` - - Retrieve the focus transform matrix for the navigation item. The UI engine - may translate, rotate, and/or tilt focus items to reflect user interaction. - This transform should be multiplied with the item's transform to get its - position inside its container. The transform origin is the center of the - item. Return false if the item position should not be changed (i.e. the - transform should be treated as identity). -* `bool(*get_item_focus_vector)(SbUiNavItem item, float *out_x, float *out_y)` - - Retrieve a vector representing the focus location within a focused item. - This is used to provide feedback about user input that is too small to - result in a focus change. If there is no focus vector for the navigation - item, then return false and leave `out_x` and `out_y` unchanged. Otherwise, - return true and set the output values in the range of [-1, +1] with (out_x, - out_y) of (-1, -1) being the top-left corner of the navigation item and (0, - 0) being the center. -* `void(*set_item_container_window)(SbUiNavItem item, SbWindow window)` - - This attaches the given navigation item (which must be a container) to the - specified window. Navigation items are only interactable if they are - transitively attached to a window. - - The native UI engine should never change this navigation item's content - offset. It is assumed to be used as a proxy for the system window. - - A navigation item may only have a SbUiNavItem or SbWindow as its direct - container. The navigation item hierarchy is established using - set_item_container_item() with the root container attached to a SbWindow - using set_item_container_window() to enable interaction with all enabled - items in the hierarchy. - - If `item` is already registered with a different window, then this will - unregister it from that window then attach it to the given `window`. It is - an error to register more than one navigation item with any given window. If - `window` is kSbWindowInvalid, then this will unregister the `item` from its - current window if any. Upon destruction of `item` or `window`, the `item` is - automatically unregistered from the `window`. -* `void(*set_item_container_item)(SbUiNavItem item, SbUiNavItem container)` - - A container navigation item may contain other navigation items. However, it - is an error to have circular containment or for `container` to not be of - type kSbUiNavItemTypeContainer. If `item` already has a different container, - then this first serves that connection. If `container` is - kSbUiNavItemInvalid, then this removes `item` from its current container. - Upon destruction of `item` or `container`, the `item` is automatically - removed from the `container`. - - The position of items within a container are specified relative to the - container's position. The position of these content items are further - modified by the container's "content offset". - - For example, consider item A with position (5,5) and content offset (0,0). - Given item B with position (10,10) is registered as a content of item A. - - 1) Item B should be drawn at position (15,15). - - 2) If item A's content offset is changed to (10,0), then item B should be - drawn at position (5,15). - - Essentially, content items should be drawn at: [container position] + - [content position] - [container content offset] - - Content items may overlap within a container. This can cause obscured items - to be unfocusable. The only rule that needs to be followed is that contents - which are focus items can obscure other contents which are containers, but - not vice versa. The caller must ensure that content focus items do not - overlap other content focus items and content container items do not overlap - other content container items. -* `void(*set_item_content_offset)(SbUiNavItem item, float content_offset_x, - float content_offset_y)` - - Set the current content offset for the given container. This may be used to - force scrolling to make certain content items visible. A container item's - content offset helps determine where its content items should be drawn. - Essentially, a content item should be drawn at: [container position] + - [content position] - [container content offset] If `item` is not a - container, then this does nothing. By default, the content offset is (0,0). - - This should update the values returned by get_item_content_offset() even if - the `item` is disabled. -* `void(*get_item_content_offset)(SbUiNavItem item, float - *out_content_offset_x, float *out_content_offset_y)` - - Retrieve the current content offset for the navigation item. If `item` is - not a container, then the content offset is (0,0). - - The native UI engine should not change the content offset of a container - unless one of its contents (possibly recursively) is focused. This is to - allow seamlessly disabling then re-enabling focus items without having their - containers change offsets. -* `void(*do_batch_update)(void(*update_function)(void *), void *context)` - - Call `update_function` with `context` to perform a series of UI navigation - changes atomically before returning. - -### SbUiNavItemDir - -Navigation items of type kSbUiNavItemTypeContainer have directionality. If -directionality is not specified for a container, it should default to left-to- -right and top-to-bottom. - -``` -/// For left-to-right, content offset x = 0 shows the leftmost content. -/// |<--Container Size-->| -/// +--------------------+--------------------+--------------------+ -/// | Not selectable. | Selectable. | Selectable. | -/// | Offscreen. | Onscreen. | Offscreen. | -/// | Negative position. | Positive position. | Positive position. | -/// +--------------------+--------------------+--------------------+ -/// ^ -/// Content Offset X = 0. -/// -/// For right-to-left, content offset x = 0 shows the rightmost content. -/// |<--Container Size-->| -/// +--------------------+--------------------+--------------------+ -/// | Selectable. | Selectable. | Not selectable. | -/// | Offscreen. | Onscreen. | Offscreen. | -/// | Negative position. | Positive position. | Positive position. | -/// +--------------------+--------------------+--------------------+ -/// ^ -/// Content Offset X = 0. -``` - -``` - Top-to-bottom is similar to left-to-right, but for the Y position. - Bottom-to-top is similar to right-to-left, but for the Y position. -``` - -#### Members - -* `bool is_left_to_right` -* `bool is_top_to_bottom` - -### SbUiNavMatrix2x3 - -This represents a 2x3 transform matrix in row-major order. - -``` -/// | a b tx | -/// | c d ty | -``` - -#### Members - -* `float m` - -### SbUiNavMatrix4 - -This represents a 4x4 transform matrix in row-major order. - -#### Members - -* `float m` - -## Functions - -### SbUiNavGetInterface - -Retrieve the platform's UI navigation implementation. If the platform does not -provide one, then return false without modifying `out_interface`. Otherwise, -initialize all members of `out_interface` and return true. The `out_interface` -pointer must not be NULL. - -#### Declaration - -``` -bool SbUiNavGetInterface(SbUiNavInterface *out_interface) -``` - -### SbUiNavItemIsValid - -Returns whether the given navigation item handle is valid. - -#### Declaration - -``` -static bool SbUiNavItemIsValid(SbUiNavItem item) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/user.md b/cobalt/site/docs/reference/starboard/modules/13/user.md deleted file mode 100644 index 309b939d066e..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/user.md +++ /dev/null @@ -1,133 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `user.h` - -Defines a user management API. This module defines functions only for managing -signed-in users. Platforms that do not have users must still implement this API, -always reporting a single user that is current and signed in. - -These APIs are NOT expected to be thread-safe, so either call them from a single -thread, or perform proper synchronization around all calls. - -## Macros - -### kSbUserInvalid - -Well-defined value for an invalid user. - -## Enums - -### SbUserPropertyId - -A set of string properties that can be queried on a user. - -#### Values - -* `kSbUserPropertyAvatarUrl` - - The URL to the avatar for a user. Avatars are not provided on all platforms. -* `kSbUserPropertyHomeDirectory` - - The path to a user's home directory, if supported on this platform. -* `kSbUserPropertyUserName` - - The username of a user, which may be the same as the User ID, or it may be - friendlier. -* `kSbUserPropertyUserId` - - A unique user ID of a user. - -## Typedefs - -### SbUser - -A handle to a user. - -#### Definition - -``` -typedef SbUserPrivate* SbUser -``` - -## Functions - -### SbUserGetCurrent - -Gets the current primary user, if one exists. This is the user that is -determined, in a platform-specific way, to be the primary user controlling the -application. For example, the determination might be made because that user -launched the app, though it should be made using whatever criteria are -appropriate for the platform. - -It is expected that there will be a unique SbUser per signed-in user, and that -the referenced objects will persist for the lifetime of the app. - -#### Declaration - -``` -SbUser SbUserGetCurrent() -``` - -### SbUserGetProperty - -Retrieves the value of `property_id` for `user` and places it in `out_value`. -The function returns: - -* `true` if the property value is retrieved successfully - -* `false` if `user` is invalid; if `property_id` isn't recognized, supported, - or set for `user`; or if `value_size` is too small. - -`user`: The user for which property size data is being retrieved. `property_id`: -The property for which the data is requested. `out_value`: The retrieved -property value. `value_size`: The size of the retrieved property value. - -#### Declaration - -``` -bool SbUserGetProperty(SbUser user, SbUserPropertyId property_id, char *out_value, int value_size) -``` - -### SbUserGetPropertySize - -Returns the size of the value of `property_id` for `user`, INCLUDING the -terminating null character. The function returns `0` if `user` is invalid or if -`property_id` is not recognized, supported, or set for the user. - -`user`: The user for which property size data is being retrieved. `property_id`: -The property for which the data is requested. - -#### Declaration - -``` -int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id) -``` - -### SbUserGetSignedIn - -Gets a list of up to `users_size` signed-in users and places the results in -`out_users`. The return value identifies the actual number of signed-in users, -which may be greater or less than `users_size`. - -It is expected that there will be a unique `SbUser` per signed-in user and that -the referenced objects will persist for the lifetime of the app. - -`out_users`: Handles for the retrieved users. `users_size`: The maximum number -of signed-in users to retrieve. - -#### Declaration - -``` -int SbUserGetSignedIn(SbUser *out_users, int users_size) -``` - -### SbUserIsValid - -Returns whether the given user handle is valid. - -#### Declaration - -``` -static bool SbUserIsValid(SbUser user) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/window.md b/cobalt/site/docs/reference/starboard/modules/13/window.md deleted file mode 100644 index acea84d4c7d0..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/13/window.md +++ /dev/null @@ -1,330 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `window.h` - -Provides functionality to handle Window creation and management. - -## Macros - -### kSbEventOnScreenKeyboardInvalidTicket - -System-triggered OnScreenKeyboard events have ticket value -kSbEventOnScreenKeyboardInvalidTicket. - -### kSbWindowInvalid - -Well-defined value for an invalid window handle. - -## Typedefs - -### SbWindow - -A handle to a window. - -#### Definition - -``` -typedef SbWindowPrivate* SbWindow -``` - -## Structs - -### SbWindowOptions - -Options that can be requested at window creation time. - -#### Members - -* `SbWindowSize size` - - The requested size of the new window. The value of `video_pixel_ratio` will - not be used or looked at. -* `bool windowed` - - Whether the new window should be windowed or not. If not, the requested size - is really the requested resolution. -* `const char * name` - - The name of the window to create. - -### SbWindowRect - -Defines a rectangle via a point `(x, y)` and a size `(width, height)`. This -structure is used as output for SbWindowGetOnScreenKeyboardBoundingRect. - -#### Members - -* `float x` -* `float y` -* `float width` -* `float height` - -### SbWindowSize - -The size of a window in graphics rendering coordinates. The width and height of -a window should correspond to the size of the graphics surface used for drawing -that would be created to back that window. - -#### Members - -* `int width` - - The width of the window in graphics pixels. -* `int height` - - The height of the window in graphics pixels. -* `float video_pixel_ratio` - - The ratio of video pixels to graphics pixels. This ratio must be applied - equally to width and height, meaning the aspect ratio is maintained. - - A value of 1.0f means the video resolution is the same as the graphics - resolution. This is the most common case. - - Values greater than 1.0f mean that the video resolution is higher (denser, - larger) than the graphics resolution. This is a common case as devices often - have more video decoding capabilities than graphics rendering capabilities - (or memory, etc...). - - Values less than 1.0f mean that the maximum video resolution is smaller than - the graphics resolution. - - A value of 0.0f means the ratio could not be determined, it should be - assumed to be the same as the graphics resolution (i.e. 1.0f). - -## Functions - -### SbWindowBlurOnScreenKeyboard - -Blur the on screen keyboard. Fire kSbEventTypeOnScreenKeyboardBlurred. -kSbEventTypeOnScreenKeyboardBlurred has data `ticket`. Calling -SbWindowBlurOnScreenKeyboard() when the keyboard is already blurred is -permitted. Calling SbWindowBlurOnScreenKeyboard while the on screen keyboard is -not showing does nothing and does not fire any event. - -#### Declaration - -``` -void SbWindowBlurOnScreenKeyboard(SbWindow window, int ticket) -``` - -### SbWindowCreate - -Creates and returns a new system window with the given `options`, which may be -`NULL`. The function returns `kSbWindowInvalid` if it cannot create the -requested `SbWindow` due to policy, unsatisfiable options, or any other reason. - -If `options` are not specified, this function uses all defaults, which must work -on every platform. In general, it defaults to creating a fullscreen window at -the highest 16:9 resolution possible. If the platform does not support -fullscreen windows, then it creates a normal, windowed window. - -Some devices are fullscreen-only, including many production targets for -Starboard. In those cases, only one SbWindow may be created, and it must be -fullscreen. Additionally, in those cases, the requested size will actually be -the requested resolution. - -An SbWindow must be created to receive window-based events, like input events, -even on fullscreen-only devices. These events are dispatched to the Starboard -entry point. - -`options`: Options that specify parameters for the window being created. - -#### Declaration - -``` -SbWindow SbWindowCreate(const SbWindowOptions *options) -``` - -### SbWindowDestroy - -Destroys `window`, reclaiming associated resources. - -`window`: The `SbWindow` to destroy. - -#### Declaration - -``` -bool SbWindowDestroy(SbWindow window) -``` - -### SbWindowFocusOnScreenKeyboard - -Focus the on screen keyboard. Fire kSbEventTypeOnScreenKeyboardFocused. -kSbEventTypeOnScreenKeyboardFocused has data `ticket`. Calling -SbWindowFocusOnScreenKeyboard() when the keyboard is already focused is -permitted. Calling SbWindowFocusOnScreenKeyboard while the on screen keyboard is -not showing does nothing and does not fire any event. - -#### Declaration - -``` -void SbWindowFocusOnScreenKeyboard(SbWindow window, int ticket) -``` - -### SbWindowGetDiagonalSizeInInches - -Gets the size of the diagonal between two opposing screen corners. - -A return value of 0 means that starboard does not know what the screen diagonal -is. - -#### Declaration - -``` -float SbWindowGetDiagonalSizeInInches(SbWindow window) -``` - -### SbWindowGetOnScreenKeyboardBoundingRect - -Get the rectangle of the on screen keyboard in screen pixel coordinates. Return -`true` if successful. Return `false` if the on screen keyboard is not showing. -If the function returns `false`, then `rect` will not have been modified. - -#### Declaration - -``` -bool SbWindowGetOnScreenKeyboardBoundingRect(SbWindow window, SbWindowRect *bounding_rect) -``` - -### SbWindowGetPlatformHandle - -Gets the platform-specific handle for `window`, which can be passed as an -EGLNativeWindowType to initialize EGL/GLES. This return value is entirely -platform-specific, so there are no constraints about expected ranges. - -`window`: The SbWindow to retrieve the platform handle for. - -#### Declaration - -``` -void* SbWindowGetPlatformHandle(SbWindow window) -``` - -### SbWindowGetSize - -Retrieves the dimensions of `window` and sets `size` accordingly. This function -returns `true` if it completes successfully. If the function returns `false`, -then `size` will not have been modified. - -`window`: The SbWindow to retrieve the size of. `size`: The retrieved size. - -#### Declaration - -``` -bool SbWindowGetSize(SbWindow window, SbWindowSize *size) -``` - -### SbWindowHideOnScreenKeyboard - -Hide the on screen keyboard. Fire kSbEventTypeWindowSizeChange and -kSbEventTypeOnScreenKeyboardHidden if necessary. -kSbEventTypeOnScreenKeyboardHidden has data `ticket`. Calling -SbWindowHideOnScreenKeyboard() when the keyboard is already hidden is permitted. - -#### Declaration - -``` -void SbWindowHideOnScreenKeyboard(SbWindow window, int ticket) -``` - -### SbWindowIsOnScreenKeyboardShown - -Determine if the on screen keyboard is shown. - -#### Declaration - -``` -bool SbWindowIsOnScreenKeyboardShown(SbWindow window) -``` - -### SbWindowIsValid - -Returns whether the given window handle is valid. - -#### Declaration - -``` -static bool SbWindowIsValid(SbWindow window) -``` - -### SbWindowOnScreenKeyboardIsSupported - -Return whether the current platform supports an on screen keyboard - -#### Declaration - -``` -bool SbWindowOnScreenKeyboardIsSupported() -``` - -### SbWindowOnScreenKeyboardSuggestionsSupported - -Determine if the on screen keyboard has suggestions implemented. If this returns -false, then calling SbWindowUpdateOnScreenKeyboardSuggestions() will be -undefined. - -#### Declaration - -``` -bool SbWindowOnScreenKeyboardSuggestionsSupported(SbWindow window) -``` - -### SbWindowSetDefaultOptions - -Sets the default options for system windows. - -`options`: The option values to use as default values. This object must not be -`NULL`. - -#### Declaration - -``` -void SbWindowSetDefaultOptions(SbWindowOptions *options) -``` - -### SbWindowSetOnScreenKeyboardKeepFocus - -Notify the system that `keepFocus` has been set for the OnScreenKeyboard. -`keepFocus` true indicates that the user may not navigate focus off of the -OnScreenKeyboard via input; focus may only be moved via events sent by the app. -`keepFocus` false indicates that the user may navigate focus off of the -OnScreenKeyboard via input. `keepFocus` is initialized to false in the -OnScreenKeyboard constructor. - -#### Declaration - -``` -void SbWindowSetOnScreenKeyboardKeepFocus(SbWindow window, bool keep_focus) -``` - -### SbWindowShowOnScreenKeyboard - -Show the on screen keyboard and populate the input with text `input_text`. Fire -kSbEventTypeWindowSizeChange and kSbEventTypeOnScreenKeyboardShown if necessary. -kSbEventTypeOnScreenKeyboardShown has data `ticket`. The passed in `input_text` -will never be NULL, but may be an empty string. Calling -SbWindowShowOnScreenKeyboard() when the keyboard is already shown is permitted, -and the input will be replaced with `input_text`. Showing the on screen keyboard -does not give it focus. - -#### Declaration - -``` -void SbWindowShowOnScreenKeyboard(SbWindow window, const char *input_text, int ticket) -``` - -### SbWindowUpdateOnScreenKeyboardSuggestions - -Update the on screen keyboard custom suggestions. Fire -kSbEventTypeOnScreenKeyboardSuggestionsUpdated. -kSbEventTypeOnScreenKeyboardSuggestionsUpdated has data `ticket`. The -suggestions should remain up-to-date when the keyboard is shown after being -hidden. - -#### Declaration - -``` -void SbWindowUpdateOnScreenKeyboardSuggestions(SbWindow window, const char *suggestions[], int num_suggestions, int ticket) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/14/condition_variable.md b/cobalt/site/docs/reference/starboard/modules/14/condition_variable.md index 2d8f30b5fdce..cd91fec6a95a 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/condition_variable.md +++ b/cobalt/site/docs/reference/starboard/modules/14/condition_variable.md @@ -40,7 +40,7 @@ size SB_CONDITION_VARIABLE_MAX_SIZE and aligned at void pointer type. #### Definition ``` -typedef union SbConditionVariable SbConditionVariable +typedef union SbConditionVariable SbConditionVariable ``` ## Functions @@ -129,12 +129,12 @@ Waits for `condition`, releasing the held lock `mutex`, blocking up to if `mutex` is not held. `timeout_duration`: The maximum amount of time that function should wait for -`condition`. If the `timeout_duration` value is less than or equal to zero, the -function returns as quickly as possible with a kSbConditionVariableTimedOut -result. +`condition`, in microseconds. If the `timeout_duration` value is less than or +equal to zero, the function returns as quickly as possible with a +kSbConditionVariableTimedOut result. #### Declaration ``` -SbConditionVariableResult SbConditionVariableWaitTimed(SbConditionVariable *condition, SbMutex *mutex, SbTime timeout_duration) +SbConditionVariableResult SbConditionVariableWaitTimed(SbConditionVariable *condition, SbMutex *mutex, int64_t timeout_duration) ``` diff --git a/cobalt/site/docs/reference/starboard/modules/14/configuration.md b/cobalt/site/docs/reference/starboard/modules/14/configuration.md index d0ba3c7196f8..fa3e15a4e160 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/configuration.md +++ b/cobalt/site/docs/reference/starboard/modules/14/configuration.md @@ -53,12 +53,6 @@ will trigger a compiler warning when referenced. SB_DEPRECATED_EXTERNAL(...) annotates the function as deprecated for external clients, but not deprecated for starboard. -### SB_EXPERIMENTAL_API_VERSION - -The API version that is currently open for changes, and therefore is not stable -or frozen. Production-oriented ports should avoid declaring that they implement -the experimental Starboard API version. - ### SB_FUNCTION Whether we use **PRETTY_FUNCTION** PRETTY_FUNCTION or **FUNCTION** FUNCTION for @@ -71,14 +65,10 @@ header available. ### SB_HAS_64_BIT_ATOMICS -Whether the current platform has 64-bit atomic operations. - -### SB_HAS_GLES2 - -Specifies whether this platform has a performant OpenGL ES 2 implementation, -which allows client applications to use GL rendering paths. Derived from the gyp -variable `gl_type` gl_type which indicates what kind of GL implementation is -available. +SB_C_FORCE_INLINE annotation for forcing a C function to be inlined. +SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. +SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. Whether +the current platform has 64-bit atomic operations. ### SB_HAS_QUIRK(SB_FEATURE) @@ -99,7 +89,7 @@ Macro for hinting that an expression is likely to be true. ### SB_MAXIMUM_API_VERSION The maximum API version allowed by this version of the Starboard headers, -inclusive. +inclusive. The API version is not stable and is open for changes. ### SB_MINIMUM_API_VERSION @@ -111,11 +101,6 @@ inclusive. Macro to annotate a function as noreturn, which signals to the compiler that the function cannot return. -### SB_OVERRIDE - -Declares a function as overriding a virtual function on compilers that support -it. - ### SB_PREFERRED_RGBA_BYTE_ORDER_RGBA An enumeration of values for the kSbPreferredByteOrder configuration variable. @@ -136,7 +121,7 @@ base/compiler_specific.h) Include the platform-specific configuration. This macro is set by GN in starboard/build/config/BUILD.gn and passed in on the command line for all -targets and all configurations.Makes a pointer-typed parameter restricted so +targets and all configurations. Makes a pointer-typed parameter restricted so that the compiler can make certain optimizations because it knows the pointers are unique. diff --git a/cobalt/site/docs/reference/starboard/modules/14/cpu_features.md b/cobalt/site/docs/reference/starboard/modules/14/cpu_features.md index e2aa35f2bb1a..523089cd4c5d 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/cpu_features.md +++ b/cobalt/site/docs/reference/starboard/modules/14/cpu_features.md @@ -98,7 +98,7 @@ Book: /youtube/cobalt/_book.yaml SDIV and UDIV hardware division in ARM mode. * `bool has_aes` - ###### Arm 64 feature flags + ##### Arm 64 feature flags AES instructions. * `bool has_crc32` diff --git a/cobalt/site/docs/reference/starboard/modules/14/decode_target.md b/cobalt/site/docs/reference/starboard/modules/14/decode_target.md index 1e98db5db54d..a354dda6ed01 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/decode_target.md +++ b/cobalt/site/docs/reference/starboard/modules/14/decode_target.md @@ -12,7 +12,7 @@ data. This allows the application to allocate fast graphics memory, and have decoding done directly into this memory, avoiding unnecessary memory copies, and also avoiding pushing data between CPU and GPU memory unnecessarily. -## SbDecodeTargetFormat +* SbDecodeTargetFormat SbDecodeTargets support several different formats that can be used to decode into and render from. Some formats may be easier to decode into, and others may @@ -21,7 +21,7 @@ the SbDecodeTargetFormat passed into it, or the decode will produce an error. Each decoder provides a way to check if a given SbDecodeTargetFormat is supported by that decoder. -## SbDecodeTargetGraphicsContextProvider +* SbDecodeTargetGraphicsContextProvider Some components may need to acquire SbDecodeTargets compatible with a certain rendering context, which may need to be created on a particular thread. The @@ -33,51 +33,7 @@ to run arbitrary code on the application's renderer thread with the renderer's EGLContext held current. This may be useful if your SbDecodeTarget creation code needs to execute GLES commands like, for example, glGenTextures(). -The primary usage is likely to be the the SbPlayer implementation on some -platforms. - -## SbDecodeTarget Example - -Let's say that we are an application and we would like to use the interface -defined in starboard/image.h to decode an imaginary "image/foo" image type. - -First, the application should enumerate which SbDecodeTargetFormats are -supported by that decoder. - -``` -SbDecodeTargetFormat kPreferredFormats[] = { - kSbDecodeTargetFormat3PlaneYUVI420, - kSbDecodeTargetFormat1PlaneRGBA, - kSbDecodeTargetFormat1PlaneBGRA, -}; - -SbDecodeTargetFormat format = kSbDecodeTargetFormatInvalid; -for (int i = 0; i < SB_ARRAY_SIZE_INT(kPreferredFormats); ++i) { - if (SbImageIsDecodeSupported("image/foo", kPreferredFormats[i])) { - format = kPreferredFormats[i]; - break; - } -} - -``` - -Now that the application has a format, it can create a decode target that it -will use to decode the .foo file into. Let's assume format is -kSbDecodeTargetFormat1PlaneRGBA, that we are on an EGL/GLES2 platform. Also, we -won't do any error checking, to keep things even simpler. - -``` -SbDecodeTarget target = SbImageDecode( - context_provider, encoded_foo_data, encoded_foo_data_size, - "image/foo", format); - -// If the decode works, you can get the texture out and render it. -SbDecodeTargetInfo info; -memset(&info, 0, sizeof(info)); -SbDecodeTargetGetInfo(target, &info); -GLuint texture = - info.planes[kSbDecodeTargetPlaneRGBA].texture; -``` +The primary usage is likely to be the SbPlayer implementation on some platforms. ## Macros @@ -127,9 +83,9 @@ premultiplied unless otherwise explicitly specified. A decoder target format consisting of a single plane with pixels laid out in the format UYVY. Since there are two Y values per sample, but only one U value and only one V value, horizontally the Y resolution is twice the size - of both the U and V resolutions. Vertically, they Y, U and V all have the - same resolution. This is a YUV 422 format. When using this format with GL - platforms, it is expected that the underlying texture will be set to the + of both the U and V resolutions. Vertically, the Y, U, and V planes all have + the same resolution. This is a YUV 422 format. When using this format with + GL platforms, it is expected that the underlying texture will be set to the GL_RGBA format, and the width of the texture will be equal to the number of UYVY tuples per row (e.g. the u/v width resolution). Content region left/right should be specified in u/v width resolution. @@ -207,8 +163,7 @@ information about the graphics context that will be used to render SbDecodeTargets. Some Starboard implementations may need to have references to some graphics objects when creating/destroying resources used by SbDecodeTarget. References to SbDecodeTargetGraphicsContextProvider objects should be provided -to all Starboard functions that might create SbDecodeTargets (e.g. -SbImageDecode()). +to all Starboard functions that might create SbDecodeTargets. #### Members @@ -216,12 +171,12 @@ SbImageDecode()). A reference to the EGLDisplay object that hosts the EGLContext that will be used to render any produced SbDecodeTargets. Note that it has the type - `void*` in order to avoid #including the EGL header files here. + `void*` in order to avoid including the EGL header files here. * `void * egl_context` The EGLContext object that will be used to render any produced SbDecodeTargets. Note that it has the type `void*` in order to avoid - #including the EGL header files here. + including the EGL header files here. * `SbDecodeTargetGlesContextRunner gles_context_runner` The `gles_context_runner` function pointer is passed in from the application @@ -264,7 +219,7 @@ This can be queried via calls to SbDecodeTargetGetInfo(). * `SbDecodeTargetInfoPlane planes` The image planes (e.g. kSbDecodeTargetPlaneRGBA, or {kSbDecodeTargetPlaneY, - kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV} associated with this decode + kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV}) associated with this decode target. ### SbDecodeTargetInfoContentRegion @@ -368,8 +323,7 @@ static bool SbDecodeTargetIsValid(SbDecodeTarget handle) Returns ownership of `decode_target` to the Starboard implementation. This function will likely result in the destruction of the SbDecodeTarget and all its associated surfaces, though in some cases, platforms may simply adjust a -reference count. In the case where SB_HAS(GLES2), this function must be called -on a thread with the context +reference count. This function must be called on a thread with the context. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/14/drm.md b/cobalt/site/docs/reference/starboard/modules/14/drm.md index f42e43bf3db7..7317fda307ff 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/drm.md +++ b/cobalt/site/docs/reference/starboard/modules/14/drm.md @@ -29,7 +29,7 @@ Encryption scheme of the input sample, as defined in ISO/IEC 23001 part 7. ### SbDrmKeyStatus -Status of a particular media key. [https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus](https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus) +Status of a particular media key. [https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus](https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus) #### Values @@ -67,8 +67,9 @@ The status of session related operations. Used by * `kSbDrmStatusQuotaExceededError` * `kSbDrmStatusUnknownError` - The following error can be used when the error status cannot be mapped to - one of the above errors. + The kSbDrmStatusUnknownError can be used when the error status cannot be + mapped to one of the rest errors. New error codes (if needed) should be + added before kSbDrmStatusUnknownError. ## Typedefs @@ -85,7 +86,7 @@ typedef void(* SbDrmServerCertificateUpdatedFunc) (SbDrmSystem drm_system, void ### SbDrmSessionClosedFunc -A callback for signalling that a session has been closed by the SbDrmSystem +A callback for signalling that a session has been closed by the SbDrmSystem. #### Definition @@ -96,8 +97,15 @@ typedef void(* SbDrmSessionClosedFunc) (SbDrmSystem drm_system, void *context, c ### SbDrmSessionKeyStatusesChangedFunc A callback for notifications that the status of one or more keys in a session -has been changed. All keys of the session and their new status will be passed -along. Any keys not in the list is considered as deleted. +has been changed. A pointer to an array of all keys `key_ids` of the session and +their new status will be passed along. Any keys not in the list are considered +as deleted. + +`number_of_keys` is the number of keys. + +`key_ids` is a pointer to an array of keys. + +`key_statuses` is a pointer of a vector contains the status of each key. #### Definition @@ -119,6 +127,7 @@ context that was passed into the call to SbDrmCreateSystem(). `error_message` may contain an optional error message when `status` isn't `kSbDrmStatusSuccess` to provide more details about the error. It may be NULL if `status` is `kSbDrmStatusSuccess` or if no error message can be provided. + `ticket` will be the same ticket that was passed to SbDrmGenerateSessionUpdateRequest() or `kSbDrmTicketInvalid` if the update request was generated by the DRM system. @@ -246,6 +255,50 @@ Clear any internal states/resources related to the specified `session_id`. void SbDrmCloseSession(SbDrmSystem drm_system, const void *session_id, int session_id_size) ``` +### SbDrmCreateSystem + +Creates a new DRM system that can be used when constructing an SbPlayer or an +SbDecoder. + +This function returns `kSbDrmSystemInvalid` if `key_system` is unsupported. + +Also see the documentation of SbDrmGenerateSessionUpdateRequest() and +SbDrmUpdateSession() for more details. + +`key_system`: The DRM key system to be created. The value should be in the form +of "com.example.somesystem". All letters in the value should be lowercase and +will be matched exactly with known DRM key systems of the platform. Note the key +system will be matched case sensitive. For more details, refer to [https://w3c.github.io/encrypted-media/#dfn-key-system-s](https://w3c.github.io/encrypted-media/#dfn-key-system-s) + +`context`: A value passed when any of this function's callback parameters are +called. + +`update_request_callback`: A function that is called every time after +SbDrmGenerateSessionUpdateRequest() is called. + +`session_updated_callback`: A function that is called every time after +SbDrmUpdateSession() is called. + +`key_statuses_changed_callback`: A function that can be called to indicate that +key statuses have changed. + +`server_certificate_updated_callback`: A function that is called to report +whether the server certificate has been successfully updated. It is called once +and only once. It is possible that the callback is called before the function +returns. + +`session_closed_callback`: A function that can be called to indicate that a +session has closed. If `NULL` is passed for any of the callbacks +(`update_request_callback`, `session_updated_callback`, +`key_statuses_changed_callback`, `server_certificate_updated_callback`, or +`session_closed_callback`), then `kSbDrmSystemInvalid` must be returned. + +#### Declaration + +``` +SbDrmSystem SbDrmCreateSystem(const char *key_system, void *context, SbDrmSessionUpdateRequestFunc update_request_callback, SbDrmSessionUpdatedFunc session_updated_callback, SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, SbDrmServerCertificateUpdatedFunc server_certificate_updated_callback, SbDrmSessionClosedFunc session_closed_callback) +``` + ### SbDrmDestroySystem Destroys `drm_system`, which implicitly removes all keys installed in it and @@ -292,9 +345,12 @@ establish ticket uniqueness, issuing multiple requests with the same ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must not be used. `type`: The case-sensitive type of the session update request payload. Must not -be NULL. `initialization_data`: The data for which the session update request -payload is created. Must not be NULL. `initialization_data_size`: The size of -the session update request payload. +be NULL. + +`initialization_data`: The data for which the session update request payload is +created. Must not be NULL. + +`initialization_data_size`: The size of the session update request payload. #### Declaration @@ -375,14 +431,18 @@ a previous call is called. Note that this function should only be called after `SbDrmIsServerCertificateUpdatable` is called first and returned true. `drm_system`: The DRM system whose server certificate is being updated. Must not -be `kSbDrmSystemInvalid`. `ticket`: The opaque ID that allows to distinguish -callbacks from multiple concurrent calls to SbDrmUpdateServerCertificate(), -which will be passed to `server_certificate_updated_callback` as-is. It is the -responsibility of the caller to establish ticket uniqueness, issuing multiple -requests with the same ticket may result in undefined behavior. The value -`kSbDrmTicketInvalid` must not be used. `certificate`: Pointer to the server -certificate data. Must not be NULL. `certificate_size`: Size of the server -certificate data. +be `kSbDrmSystemInvalid`. + +`ticket`: The opaque ID that allows to distinguish callbacks from multiple +concurrent calls to SbDrmUpdateServerCertificate(), which will be passed to +`server_certificate_updated_callback` as-is. It is the responsibility of the +caller to establish ticket uniqueness, issuing multiple requests with the same +ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must +not be used. + +`certificate`: Pointer to the server certificate data. Must not be NULL. + +`certificate_size`: Size of the server certificate data. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/14/event.md b/cobalt/site/docs/reference/starboard/modules/14/event.md index 256d418b45e0..bc2b7ad34ea7 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/event.md +++ b/cobalt/site/docs/reference/starboard/modules/14/event.md @@ -313,7 +313,7 @@ Structure representing a Starboard event and its data. #### Members * `SbEventType type` -* `SbTimeMonotonic timestamp` +* `int64_t timestamp` * `void * data` ### SbEventStartData @@ -399,5 +399,5 @@ of microseconds to wait before calling the `callback` function. Set `delay` to #### Declaration ``` -SbEventId SbEventSchedule(SbEventCallback callback, void *context, SbTime delay) +SbEventId SbEventSchedule(SbEventCallback callback, void *context, int64_t delay) ``` diff --git a/cobalt/site/docs/reference/starboard/modules/14/file.md b/cobalt/site/docs/reference/starboard/modules/14/file.md index 103af475ace1..b79900e7a507 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/file.md +++ b/cobalt/site/docs/reference/starboard/modules/14/file.md @@ -124,15 +124,15 @@ Used to hold information about a file. * `bool is_symbolic_link` Whether the file corresponds to a symbolic link. -* `SbTime last_modified` +* `int64_t last_modified` - The last modified time of a file. -* `SbTime last_accessed` + The last modified time of a file - microseconds since Windows epoch UTC. +* `int64_t last_accessed` - The last accessed time of a file. -* `SbTime creation_time` + The last accessed time of a file - microseconds since Windows epoch UTC. +* `int64_t creation_time` - The creation time of a file. + The creation time of a file - microseconds since Windows epoch UTC. ## Functions diff --git a/cobalt/site/docs/reference/starboard/modules/14/image.md b/cobalt/site/docs/reference/starboard/modules/14/image.md index 945938a09903..98d3c5a61a84 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/image.md +++ b/cobalt/site/docs/reference/starboard/modules/14/image.md @@ -26,6 +26,7 @@ if (!SbImageIsDecodeSupported(mime_type, format)) { SbDecodeTarget result_target = SbImageDecode(provider, data, data_size, mime_type, format); + ``` ## Functions diff --git a/cobalt/site/docs/reference/starboard/modules/14/media.md b/cobalt/site/docs/reference/starboard/modules/14/media.md index 732868607939..d7aa3406dc48 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/media.md +++ b/cobalt/site/docs/reference/starboard/modules/14/media.md @@ -180,7 +180,7 @@ output. The type of audio connector. Will be the empty `kSbMediaAudioConnectorNone` if this device cannot provide this information. -* `SbTime latency` +* `int64_t latency` The expected latency of audio over this output, in microseconds, or `0` if this device cannot provide this information. @@ -236,14 +236,13 @@ Audio-specific configuration field. The `WAVEFORMATEX` structure is specified at The size, in bytes, of the audio_specific_config. * `const void * audio_specific_config` - The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1: [http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF](http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF) + The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1. ### SbMediaColorMetadata HDR (High Dynamic Range) Metadata common for HDR10 and WebM/VP9-based HDR formats, together with the ColorSpace. HDR reproduces a greater dynamic range of -luminosity than is possible with standard digital imaging. See the Consumer -Electronics Association press release: [https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx](https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx) +luminosity than is possible with standard digital imaging. #### Members @@ -433,10 +432,12 @@ Note that neither `mime` nor `key_system` can be NULL. This function returns `mime`: The mime information of the media in the form of `video/webm` or `video/mp4; codecs="avc1.42001E"`. It may include arbitrary parameters like "codecs", "channels", etc. Note that the "codecs" parameter may contain more -than one codec, delimited by comma. `key_system`: A lowercase value in the form -of "com.example.somesystem" as suggested by [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system)) that can +than one codec, delimited by comma. + +`key_system`: A lowercase value in the form of "com.example.somesystem", and can be matched exactly with known DRM key systems of the platform. When `key_system` is an empty string, the return value is an indication for non-encrypted media. +For more detail, refer to [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system) An implementation may choose to support `key_system` with extra attributes, separated by ';', like `com.example.somesystem; attribute_name1="value1"; @@ -448,23 +449,21 @@ attributes, it has to support all attributes defined by the Starboard version the implementation uses. An implementation should ignore any unknown attributes, and make a decision solely based on the key system and the known attributes. For example, if an implementation supports "com.widevine.alpha", it should also -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when -`key_system` is `com.widevine.alpha; invalid_attribute="invalid_value"`. -Currently the only attribute has to be supported is `encryptionscheme`. It -reflects the value passed to `encryptionScheme` encryptionScheme of -MediaKeySystemMediaCapability, as defined in [https://wicg.github.io/encrypted-media-encryption-scheme/,](https://wicg.github.io/encrypted-media-encryption-scheme/,),) which can take value "cenc", "cbcs", or "cbcs-1-9". Empty string is -not a valid value for `encryptionscheme` and the implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when +return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; +invalid_attribute="invalid_value"`. Currently the only attribute has to be +supported is `encryptionscheme`. It reflects the value passed to +`encryptionScheme` of MediaKeySystemMediaCapability. It can take value "cenc", +"cbcs", or "cbcs-1-9". Empty string is not a valid value for `encryptionscheme` +and the implementation should return `kSbMediaSupportTypeNotSupported` when `encryptionscheme` is set to "". The implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported for unknown -values of known attributes. For example, if an implementation supports -"encryptionscheme" with value "cenc", "cbcs", or "cbcs-1-9", then it should -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when +`kSbMediaSupportTypeNotSupported` for unknown values of known attributes. For +example, if an implementation supports "encryptionscheme" with value "cenc", +"cbcs", or "cbcs-1-9", then it should return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; encryptionscheme="cenc"`, and return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when -`key_system` is `com.widevine.alpha; encryptionscheme="invalid"`. If an -implementation supports key system with attributes on one key system, it has to -support key system with attributes on all key systems supported. +`kSbMediaSupportTypeNotSupported` when `key_system` is `com.widevine.alpha; +encryptionscheme="invalid"`. If an implementation supports key system with +attributes on one key system, it has to support key system with attributes on +all key systems supported. For more detail, refer to [https://wicg.github.io/encrypted-media-encryption-scheme](https://wicg.github.io/encrypted-media-encryption-scheme) #### Declaration @@ -534,7 +533,7 @@ When the media stack needs more memory to store media buffers, it will allocate extra memory in units returned by SbMediaGetBufferAllocationUnit. This can return 0, in which case the media stack will allocate extra memory on demand. When SbMediaGetInitialBufferCapacity and this function both return 0, the media -stack will allocate individual buffers directly using SbMemory functions. +stack will allocate individual buffers directly using malloc functions. #### Declaration @@ -544,19 +543,19 @@ int SbMediaGetBufferAllocationUnit() ### SbMediaGetBufferGarbageCollectionDurationThreshold -Specifies the duration threshold of media source garbage collection. When the -accumulated duration in a source buffer exceeds this value, the media source -implementation will try to eject existing buffers from the cache. This is -usually triggered when the video being played has a simple content and the -encoded data is small. In such case this can limit how much is allocated for the -book keeping data of the media buffers and avoid OOM of system heap. This should -return 170 seconds for most of the platforms. But it can be further reduced on -systems with extremely low memory. +Specifies the duration threshold of media source garbage collection in +microseconds. When the accumulated duration in a source buffer exceeds this +value, the media source implementation will try to eject existing buffers from +the cache. This is usually triggered when the video being played has a simple +content and the encoded data is small. In such case this can limit how much is +allocated for the book keeping data of the media buffers and avoid OOM of system +heap. This should return 170 seconds for most of the platforms. But it can be +further reduced on systems with extremely low memory. #### Declaration ``` -SbTime SbMediaGetBufferGarbageCollectionDurationThreshold() +int64_t SbMediaGetBufferGarbageCollectionDurationThreshold() ``` ### SbMediaGetBufferPadding @@ -575,10 +574,10 @@ int SbMediaGetBufferPadding() Returns SbMediaBufferStorageType of type `SbMediaStorageTypeMemory` or `SbMediaStorageTypeFile`. For memory storage, the media buffers will be stored -in main memory allocated by SbMemory functions. For file storage, the media +in main memory allocated by malloc functions. For file storage, the media buffers will be stored in a temporary file in the system cache folder acquired by calling SbSystemGetPath() with "kSbSystemPathCacheDirectory". Note that when -its value is "file" the media stack will still allocate memory to cache the the +its value is "file" the media stack will still allocate memory to cache the buffers in use. #### Declaration @@ -610,10 +609,14 @@ allocation of media buffers may only fail when there is not enough memory in the system to fulfill the request, under which case the app will be terminated as under other OOM situations. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -628,10 +631,14 @@ resolution of such videos shouldn't go beyond 1080p. Its value should be less than the sum of SbMediaGetAudioBufferBudget and 'SbMediaGetVideoBufferBudget(..., 1920, 1080, ...) but not less than 8 MB. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -647,10 +654,14 @@ being used by video buffers but will also make app less likely to re-download video data. Note that the app may experience significant difficulty if this value is too low. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -678,7 +689,7 @@ bool SbMediaIsBufferPoolAllocateOnDemand() ### SbMediaIsBufferUsingMemoryPool If SbMediaGetBufferUsingMemoryPool returns true, it indicates that media buffer -pools should be allocated on demand, as opposed to using SbMemory* functions. +pools should be allocated on demand, as opposed to using malloc functions. #### Declaration @@ -691,15 +702,15 @@ bool SbMediaIsBufferUsingMemoryPool() Communicate to the platform how far past `current_playback_position` the app will write audio samples. The app will write all samples between `current_playback_position` and `current_playback_position` + `duration`, as -soon as they are available. The app may sometimes write more samples than that, -but the app only guarantees to write `duration` past `current_playback_position` -in general. The platform is responsible for guaranteeing that when only -`duration` audio samples are written at a time, no playback issues occur (such -as transient or indefinite hanging). The platform may assume `duration` >= 0.5 -seconds. +soon as they are available (during is in microseconds). The app may sometimes +write more samples than that, but the app only guarantees to write `duration` +past `current_playback_position` in general. The platform is responsible for +guaranteeing that when only `duration` audio samples are written at a time, no +playback issues occur (such as transient or indefinite hanging). The platform +may assume `duration` >= 0.5 seconds. #### Declaration ``` -void SbMediaSetAudioWriteDuration(SbTime duration) +void SbMediaSetAudioWriteDuration(int64_t duration) ``` diff --git a/cobalt/site/docs/reference/starboard/modules/14/mutex.md b/cobalt/site/docs/reference/starboard/modules/14/mutex.md index 82ff8500ab8d..55f9c01e9adc 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/mutex.md +++ b/cobalt/site/docs/reference/starboard/modules/14/mutex.md @@ -40,7 +40,7 @@ SB_MUTEX_MAX_SIZE and aligned at void pointer type. #### Definition ``` -typedef union SbMutex SbMutex +typedef union SbMutex SbMutex ``` ## Functions diff --git a/cobalt/site/docs/reference/starboard/modules/14/once.md b/cobalt/site/docs/reference/starboard/modules/14/once.md index d77302467f8b..1c1f21932f06 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/once.md +++ b/cobalt/site/docs/reference/starboard/modules/14/once.md @@ -22,7 +22,7 @@ SB_ONCE_MAX_SIZE and aligned at void pointer type. #### Definition ``` -typedef union SbOnceControl SbOnceControl +typedef union SbOnceControl SbOnceControl ``` ### SbOnceInitRoutine diff --git a/cobalt/site/docs/reference/starboard/modules/14/player.md b/cobalt/site/docs/reference/starboard/modules/14/player.md index 0dab908addc8..c008c6cf67be 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/player.md +++ b/cobalt/site/docs/reference/starboard/modules/14/player.md @@ -44,9 +44,12 @@ data may come from multiple sources. * `kMatroskaBlockAdditional` The side data comes from the BlockAdditional data in the Matroska/Webm - container, as specified in [https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39](https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39)9) andnd [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional)l) - . The first 8 bytes of the data contains the value of BlockAddID in big - endian format, followed by the content of BlockAdditional. + container. The first 8 bytes of the data contains the value of BlockAddID in + big endian format, followed by the content of BlockAdditional. See: + + [https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03](https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03) + + [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional) ### SbPlayerState @@ -122,10 +125,13 @@ typedef void(* SbPlayerDecoderStatusFunc) (SbPlayer player, void *context, SbMed ### SbPlayerErrorFunc -Callback for player errors, that may set a `message`. `error`: indicates the -error code. `message`: provides specific informative diagnostic message about -the error condition encountered. It is ok for the message to be an empty string -or NULL if no information is available. +Callback for player errors, that may set a `message`. + +`error`: indicates the error code. + +`message`: provides specific informative diagnostic message about the error +condition encountered. It is ok for the message to be an empty string or NULL if +no information is available. #### Definition @@ -184,14 +190,14 @@ Information about the current media playback state. #### Members -* `SbTime current_media_timestamp` +* `int64_t current_media_timestamp` The position of the playback head, as precisely as possible, in microseconds. -* `SbTime duration` +* `int64_t duration` The known duration of the currently playing media stream, in microseconds. -* `SbTime start_date` +* `int64_t start_date` The result of getStartDate for the currently playing media stream, in microseconds since the epoch of January 1, 1601 UTC. @@ -242,9 +248,9 @@ Information about the samples to be written into SbPlayerWriteSamples(). * `int buffer_size` Size of the data pointed to by `buffer`. -* `SbTime timestamp` +* `int64_t timestamp` - The timestamp of the sample in SbTime. + The timestamp of the sample in microseconds since Windows epoch UTC. * `SbPlayerSampleSideData* side_data` Points to an array of side data for the input, when available. @@ -284,20 +290,123 @@ coming from multiple sources. ## Functions +### SbPlayerCreate + +Creates a player that will be displayed on `window` for the specified +`video_codec` and `audio_codec`, acquiring all resources needed to operate it, +and returning an opaque handle to it. The expectation is that a new player will +be created and destroyed for every playback. + +This function returns the created player. Note the following: + +* The associated decoder of the returned player should be assumed to not be in + `kSbPlayerDecoderStateNeedsData` until SbPlayerSeek() has been called on it. + +* It is expected either that the thread that calls SbPlayerCreate is the same + thread that calls the other `SbPlayer` functions for that player, or that + there is a mutex guarding calls into each `SbPlayer` instance. + +* If there is a platform limitation on how many players can coexist + simultaneously, then calls made to this function that attempt to exceed that + limit must return `kSbPlayerInvalid`. Multiple calls to SbPlayerCreate must + not cause a crash. + +`window`: The window that will display the player. `window` can be +`kSbWindowInvalid` for platforms where video is only displayed on a particular +window that the underlying implementation already has access to. + +`video_codec`: The video codec used for the player. If `video_codec` is +`kSbMediaVideoCodecNone`, the player is an audio-only player. If `video_codec` +is any other value, the player is an audio/video decoder. This can be set to +`kSbMediaVideoCodecNone` to play a video with only an audio track. + +`audio_codec`: The audio codec used for the player. The caller must provide a +populated `audio_sample_info` if audio codec is `kSbMediaAudioCodecAac`. Can be +set to `kSbMediaAudioCodecNone` to play a video without any audio track. In such +case `audio_sample_info` must be NULL. + +`drm_system`: If the media stream has encrypted portions, then this parameter +provides an appropriate DRM system, created with `SbDrmCreateSystem()`. If the +stream does not have encrypted portions, then `drm_system` may be +`kSbDrmSystemInvalid`. + +`audio_sample_info`: Note that the caller must provide a populated +`audio_sample_info` if the audio codec is `kSbMediaAudioCodecAac`. Otherwise, +`audio_sample_info` can be NULL. See media.h for the format of the +`SbMediaAudioSampleInfo` struct. + +Note that `audio_specific_config` is a pointer and the content it points to is +no longer valid after this function returns. The implementation has to make a +copy of the content if it is needed after the function returns. + +`max_video_capabilities`: This string communicates the max video capabilities +required to the platform. The web app will not provide a video stream exceeding +the maximums described by this parameter. Allows the platform to optimize +playback pipeline for low quality video streams if it knows that it will never +adapt to higher quality streams. The string uses the same format as the string +passed in to SbMediaCanPlayMimeAndKeySystem(), for example, when it is set to +"width=1920; height=1080; framerate=15;", the video will never adapt to +resolution higher than 1920x1080 or frame per second higher than 15 fps. When +the maximums are unknown, this will be set to NULL. + +`sample_deallocator_func`: If not `NULL`, the player calls this function on an +internal thread to free the sample buffers passed into SbPlayerWriteSample(). + +`decoder_status_func`: If not `NULL`, the decoder calls this function on an +internal thread to provide an update on the decoder's status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_status_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the playback status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_error_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the error status. This callback is +responsible for setting the media error message. + +`context`: This is passed to all callbacks and is generally used to point at a +class or struct that contains state associated with the player. + +`output_mode`: Selects how the decoded video frames will be output. For example, +kSbPlayerOutputModePunchOut indicates that the decoded video frames will be +output to a background video layer by the platform, and +kSbPlayerOutputDecodeToTexture indicates that the decoded video frames should be +made available for the application to pull via calls to +SbPlayerGetCurrentFrame(). + +`provider`: Only present in Starboard version 3 and up. If not `NULL`, then when +output_mode == kSbPlayerOutputModeDecodeToTexture, the player MAY use the +provider to create SbDecodeTargets on the renderer thread. A provider may not +always be needed by the player, but if it is needed, and the provider is not +given, the player will fail by returning `kSbPlayerInvalid`. + +If `NULL` is passed to any of the callbacks (`sample_deallocator_func`, +`decoder_status_func`, `player_status_func`, or `player_error_func` if it +applies), then `kSbPlayerInvalid` must be returned. + +#### Declaration + +``` +SbPlayer SbPlayerCreate(SbWindow window, const SbPlayerCreationParam *creation_param, SbPlayerDeallocateSampleFunc sample_deallocate_func, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void *context, SbDecodeTargetGraphicsContextProvider *context_provider) +``` + ### SbPlayerDestroy Destroys `player`, freeing all associated resources. * Upon calling this method, there should be one call to the player status callback (i.e. `player_status_func` used in the creation of the player) - which indicates the player is destroyed. Note, the callback has to be in- - flight when SbPlayerDestroyed is called. + which indicates the player is destroyed. Note, the callback has to be + inflight when SbPlayerDestroyed is called. * No more other callbacks should be issued after this function returns. * It is not allowed to pass `player` into any other `SbPlayer` function once - SbPlayerDestroy has been called on that player. `player`: The player to be - destroyed. Must not be `kSbPlayerInvalid`. + SbPlayerDestroy has been called on that player. + +`player`: The player to be destroyed. Must not be `kSbPlayerInvalid`. #### Declaration @@ -323,19 +432,36 @@ kSbDecodeTargetInvalid is returned. SbDecodeTarget SbPlayerGetCurrentFrame(SbPlayer player) ``` +### SbPlayerGetInfo2 + +Gets a snapshot of the current player state and writes it to `out_player_info`. +This function may be called very frequently and is expected to be inexpensive. + +`player`: The player about which information is being retrieved. Must not be +`kSbPlayerInvalid`. + +`out_player_info`: The information retrieved for the player. + +#### Declaration + +``` +void SbPlayerGetInfo2(SbPlayer player, SbPlayerInfo2 *out_player_info2) +``` + ### SbPlayerGetMaximumNumberOfSamplesPerWrite -Writes a single sample of the given media type to `player`'s input stream. Its -data may be passed in via more than one buffers. The lifetime of -`sample_buffers`, `sample_buffer_sizes`, `video_sample_info`, and -`sample_drm_info` (as well as member `subsample_mapping` contained inside it) -are not guaranteed past the call to SbPlayerWriteSample. That means that before -returning, the implementation must synchronously copy any information it wants -to retain from those structures. +Returns the maximum number of samples that can be written in a single call to +SbPlayerWriteSamples(). Returning a value greater than one can improve +performance by allowing SbPlayerWriteSamples() to write multiple samples in one +call. -`player`: The player for which the number is retrieved. `sample_type`: The type -of sample for which the number is retrieved. See the `SbMediaType` enum in -media.h. +Note that this feature is currently disabled in Cobalt where +SbPlayerWriteSamples() will always be called with one sample. + +`player`: The player for which the number is retrieved. + +`sample_type`: The type of sample for which the number is retrieved. See the +`SbMediaType` enum in media.h. #### Declaration @@ -377,6 +503,45 @@ Returns whether the given player handle is valid. static bool SbPlayerIsValid(SbPlayer player) ``` +### SbPlayerSeek2 + +Tells the player to freeze playback (if playback has already started), reset or +flush the decoder pipeline, and go back to the Prerolling state. The player +should restart playback once it can display the frame at `seek_to_timestamp`, or +the closest it can get. (Some players can only seek to I-Frames, for example.) + +* Seek must be called before samples are sent when starting playback for the + first time, or the client never receives the + `kSbPlayerDecoderStateNeedsData` signal. + +* A call to seek may interrupt another seek. + +* After this function is called, the client should not send any more audio or + video samples until `SbPlayerDecoderStatusFunc` is called back with + `kSbPlayerDecoderStateNeedsData` for each required media type. + `SbPlayerDecoderStatusFunc` is the `decoder_status_func` callback function + that was specified when the player was created (SbPlayerCreate). + +`player`: The SbPlayer in which the seek operation is being performed. Must not +be `kSbPlayerInvalid`. + +`seek_to_timestamp`: The frame at which playback should begin. + +`ticket`: A user-supplied unique ID to be passed to all subsequent +`SbPlayerDecoderStatusFunc` calls. (That is the `decoder_status_func` callback +function specified when calling SbPlayerCreate.) + +The `ticket` value is used to filter calls that may have been in flight when +SbPlayerSeek was called. To be very specific, once SbPlayerSeek has been called +with ticket X, a client should ignore all `SbPlayerDecoderStatusFunc` calls that +do not pass in ticket X. + +#### Declaration + +``` +void SbPlayerSeek2(SbPlayer player, int64_t seek_to_timestamp, int ticket) +``` + ### SbPlayerSetBounds Sets the player bounds to the given graphics plane coordinates. The changes do @@ -392,11 +557,18 @@ implementors should take care to avoid related performance concerns with such frequent calls. `player`: The player that is being resized. Must not be `kSbPlayerInvalid`. + `z_index`: The z-index of the player. When the bounds of multiple players are overlapped, the one with larger z-index will be rendered on top of the ones with -smaller z-index. `x`: The x-coordinate of the upper-left corner of the player. -`y`: The y-coordinate of the upper-left corner of the player. `width`: The width -of the player, in pixels. `height`: The height of the player, in pixels. +smaller z-index. + +`x`: The x-coordinate of the upper-left corner of the player. + +`y`: The y-coordinate of the upper-left corner of the player. + +`width`: The width of the player, in pixels. + +`height`: The height of the player, in pixels. #### Declaration @@ -430,9 +602,11 @@ bool SbPlayerSetPlaybackRate(SbPlayer player, double playback_rate) Sets the player's volume. `player`: The player in which the volume is being adjusted. Must not be -`kSbPlayerInvalid`. `volume`: The new player volume. The value must be between -`0.0` and `1.0`, inclusive. A value of `0.0` means that the audio should be -muted, and a value of `1.0` means that it should be played at full volume. +`kSbPlayerInvalid`. + +`volume`: The new player volume. The value must be between `0.0` and `1.0`, +inclusive. A value of `0.0` means that the audio should be muted, and a value of +`1.0` means that it should be played at full volume. #### Declaration @@ -447,8 +621,9 @@ there are no more samples for that media type for the remainder of this media stream. This marker is invalidated, along with the rest of the stream's contents, after a call to SbPlayerSeek. -`player`: The player to which the marker is written. `stream_type`: The type of -stream for which the marker is written. +`player`: The player to which the marker is written. + +`stream_type`: The type of stream for which the marker is written. #### Declaration @@ -458,14 +633,29 @@ void SbPlayerWriteEndOfStream(SbPlayer player, SbMediaType stream_type) ### SbPlayerWriteSample2 +Writes samples of the given media type to `player`'s input stream. The lifetime +of `sample_infos`, and the members of its elements like `buffer`, +`video_sample_info`, and `drm_info` (as well as member `subsample_mapping` +contained inside it) are not guaranteed past the call to SbPlayerWriteSamples(). +That means that before returning, the implementation must synchronously copy any +information it wants to retain from those structures. + +SbPlayerWriteSamples() allows writing of multiple samples in one call. + +`player`: The player to which the sample is written. Must not be +`kSbPlayerInvalid`. + `sample_type`: The type of sample being written. See the `SbMediaType` enum in -media.h. `sample_infos`: A pointer to an array of SbPlayerSampleInfo with +media.h. + +`sample_infos`: A pointer to an array of SbPlayerSampleInfo with `number_of_sample_infos` elements, each holds the data for an sample, i.e. a sequence of whole NAL Units for video, or a complete audio frame. `sample_infos` cannot be assumed to live past the call into SbPlayerWriteSamples(), so it must be copied if its content will be used after SbPlayerWriteSamples() returns. + `number_of_sample_infos`: Specify the number of samples contained inside -`sample_infos`. It has to be at least one, and less than the return value of +`sample_infos`. It has to be at least one, and at most the return value of SbPlayerGetMaximumNumberOfSamplesPerWrite(). #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/14/socket.md b/cobalt/site/docs/reference/starboard/modules/14/socket.md index 744c04e3847d..beeab4fddb6e 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/socket.md +++ b/cobalt/site/docs/reference/starboard/modules/14/socket.md @@ -540,15 +540,15 @@ Sets the `SO_KEEPALIVE`, or equivalent, option to `value` on `socket`. The return value indicates whether the option was actually set. `socket`: The SbSocket for which the option is set. `value`: If set to `true`, -then `period` specifies the minimum time (SbTime) is always in microseconds) -between keep-alive packets. If set to `false`, `period` is ignored. `period`: -The time between keep-alive packets. This value is only relevant if `value` is -`true`. +then `period` specifies the minimum time in microseconds between keep-alive +packets. If set to `false`, `period` is ignored. `period`: The time in +microseconds between keep-alive packets. This value is only relevant if `value` +is `true`. #### Declaration ``` -bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, SbTime period) +bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, int64_t period) ``` ### SbSocketSetTcpNoDelay diff --git a/cobalt/site/docs/reference/starboard/modules/14/socket_waiter.md b/cobalt/site/docs/reference/starboard/modules/14/socket_waiter.md index f1c6bd8b9f2f..8632f88a5f12 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/socket_waiter.md +++ b/cobalt/site/docs/reference/starboard/modules/14/socket_waiter.md @@ -202,15 +202,15 @@ SbSocketWaiterWakeUp() it not called by that time. The return value indicates the reason that the socket waiter exited. This function should only be called on the thread that waits on this waiter. -`duration`: The minimum amount of time after which the socket waiter should exit -if it is not woken up before then. As with SbThreadSleep() (see thread.h), this -function may wait longer than `duration`, such as if the timeout expires while a -callback is being fired. +`duration`: The minimum amount of time in microseconds after which the socket +waiter should exit if it is not woken up before then. As with SbThreadSleep() +(see thread.h), this function may wait longer than `duration`, such as if the +timeout expires while a callback is being fired. #### Declaration ``` -SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, SbTime duration) +SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, int64_t duration) ``` ### SbSocketWaiterWakeUp diff --git a/cobalt/site/docs/reference/starboard/modules/14/string.md b/cobalt/site/docs/reference/starboard/modules/14/string.md index 3fed809df461..fc8d82ae38ea 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/string.md +++ b/cobalt/site/docs/reference/starboard/modules/14/string.md @@ -127,21 +127,6 @@ be formatted. `arguments`: Variable arguments used in the string. int SbStringFormatWide(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format, va_list arguments) ``` -### SbStringFormatWideF - -An inline wrapper of SbStringFormatWide that converts from ellipsis to -`va_args`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `...`: Arguments used in the string. - -#### Declaration - -``` -static int SbStringFormatWideF(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format,...) -``` - ### SbStringScan Scans `buffer` for `pattern`, placing the extracted values in `arguments`. The diff --git a/cobalt/site/docs/reference/starboard/modules/14/thread.md b/cobalt/site/docs/reference/starboard/modules/14/thread.md index 56c7898a12b4..c988516192a4 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/thread.md +++ b/cobalt/site/docs/reference/starboard/modules/14/thread.md @@ -519,7 +519,7 @@ or `0`. #### Declaration ``` -void SbThreadSleep(SbTime duration) +void SbThreadSleep(int64_t duration) ``` ### SbThreadYield diff --git a/cobalt/site/docs/reference/starboard/modules/14/time_zone.md b/cobalt/site/docs/reference/starboard/modules/14/time_zone.md index 74d48172d63e..baad3759ac4b 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/time_zone.md +++ b/cobalt/site/docs/reference/starboard/modules/14/time_zone.md @@ -12,7 +12,7 @@ Provides access to the system time zone information. The number of minutes west of the Greenwich Prime Meridian, NOT including Daylight Savings Time adjustments. -For example: PST/PDT is 480 minutes (28800 seconds, 8 hours). +For example: America/Los_Angeles is 480 minutes (28800 seconds, 8 hours). #### Definition @@ -34,11 +34,11 @@ SbTimeZone SbTimeZoneGetCurrent() ### SbTimeZoneGetName -Gets a string representation of the current timezone. Note that the string -representation can either be standard or daylight saving time. The output can be -of the form: 1) A three-letter abbreviation such as "PST" or "PDT" (preferred). -2) A time zone identifier such as "America/Los_Angeles" 3) An un-abbreviated -name such as "Pacific Standard Time". +Gets a string representation of the current timezone. The format should be in +the IANA format [https://data.iana.org/time-zones/theory.html#naming](https://data.iana.org/time-zones/theory.html#naming)) . +Names normally have the form AREA/LOCATION, where AREA is a continent or ocean, +and LOCATION is a specific location within the area. Typical names are +'Africa/Cairo', 'America/New_York', and 'Pacific/Honolulu'. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/14/ui_navigation.md b/cobalt/site/docs/reference/starboard/modules/14/ui_navigation.md index cb4176713005..fa178d7689ce 100644 --- a/cobalt/site/docs/reference/starboard/modules/14/ui_navigation.md +++ b/cobalt/site/docs/reference/starboard/modules/14/ui_navigation.md @@ -268,6 +268,7 @@ right and top-to-bottom. ``` Top-to-bottom is similar to left-to-right, but for the Y position. Bottom-to-top is similar to right-to-left, but for the Y position. + ``` #### Members diff --git a/cobalt/site/docs/reference/starboard/modules/15/condition_variable.md b/cobalt/site/docs/reference/starboard/modules/15/condition_variable.md index 2d8f30b5fdce..cd91fec6a95a 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/condition_variable.md +++ b/cobalt/site/docs/reference/starboard/modules/15/condition_variable.md @@ -40,7 +40,7 @@ size SB_CONDITION_VARIABLE_MAX_SIZE and aligned at void pointer type. #### Definition ``` -typedef union SbConditionVariable SbConditionVariable +typedef union SbConditionVariable SbConditionVariable ``` ## Functions @@ -129,12 +129,12 @@ Waits for `condition`, releasing the held lock `mutex`, blocking up to if `mutex` is not held. `timeout_duration`: The maximum amount of time that function should wait for -`condition`. If the `timeout_duration` value is less than or equal to zero, the -function returns as quickly as possible with a kSbConditionVariableTimedOut -result. +`condition`, in microseconds. If the `timeout_duration` value is less than or +equal to zero, the function returns as quickly as possible with a +kSbConditionVariableTimedOut result. #### Declaration ``` -SbConditionVariableResult SbConditionVariableWaitTimed(SbConditionVariable *condition, SbMutex *mutex, SbTime timeout_duration) +SbConditionVariableResult SbConditionVariableWaitTimed(SbConditionVariable *condition, SbMutex *mutex, int64_t timeout_duration) ``` diff --git a/cobalt/site/docs/reference/starboard/modules/15/configuration.md b/cobalt/site/docs/reference/starboard/modules/15/configuration.md index d0ba3c7196f8..fa3e15a4e160 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/configuration.md +++ b/cobalt/site/docs/reference/starboard/modules/15/configuration.md @@ -53,12 +53,6 @@ will trigger a compiler warning when referenced. SB_DEPRECATED_EXTERNAL(...) annotates the function as deprecated for external clients, but not deprecated for starboard. -### SB_EXPERIMENTAL_API_VERSION - -The API version that is currently open for changes, and therefore is not stable -or frozen. Production-oriented ports should avoid declaring that they implement -the experimental Starboard API version. - ### SB_FUNCTION Whether we use **PRETTY_FUNCTION** PRETTY_FUNCTION or **FUNCTION** FUNCTION for @@ -71,14 +65,10 @@ header available. ### SB_HAS_64_BIT_ATOMICS -Whether the current platform has 64-bit atomic operations. - -### SB_HAS_GLES2 - -Specifies whether this platform has a performant OpenGL ES 2 implementation, -which allows client applications to use GL rendering paths. Derived from the gyp -variable `gl_type` gl_type which indicates what kind of GL implementation is -available. +SB_C_FORCE_INLINE annotation for forcing a C function to be inlined. +SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. +SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. Whether +the current platform has 64-bit atomic operations. ### SB_HAS_QUIRK(SB_FEATURE) @@ -99,7 +89,7 @@ Macro for hinting that an expression is likely to be true. ### SB_MAXIMUM_API_VERSION The maximum API version allowed by this version of the Starboard headers, -inclusive. +inclusive. The API version is not stable and is open for changes. ### SB_MINIMUM_API_VERSION @@ -111,11 +101,6 @@ inclusive. Macro to annotate a function as noreturn, which signals to the compiler that the function cannot return. -### SB_OVERRIDE - -Declares a function as overriding a virtual function on compilers that support -it. - ### SB_PREFERRED_RGBA_BYTE_ORDER_RGBA An enumeration of values for the kSbPreferredByteOrder configuration variable. @@ -136,7 +121,7 @@ base/compiler_specific.h) Include the platform-specific configuration. This macro is set by GN in starboard/build/config/BUILD.gn and passed in on the command line for all -targets and all configurations.Makes a pointer-typed parameter restricted so +targets and all configurations. Makes a pointer-typed parameter restricted so that the compiler can make certain optimizations because it knows the pointers are unique. diff --git a/cobalt/site/docs/reference/starboard/modules/15/cpu_features.md b/cobalt/site/docs/reference/starboard/modules/15/cpu_features.md index e2aa35f2bb1a..523089cd4c5d 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/cpu_features.md +++ b/cobalt/site/docs/reference/starboard/modules/15/cpu_features.md @@ -98,7 +98,7 @@ Book: /youtube/cobalt/_book.yaml SDIV and UDIV hardware division in ARM mode. * `bool has_aes` - ###### Arm 64 feature flags + ##### Arm 64 feature flags AES instructions. * `bool has_crc32` diff --git a/cobalt/site/docs/reference/starboard/modules/15/decode_target.md b/cobalt/site/docs/reference/starboard/modules/15/decode_target.md index 1e98db5db54d..a354dda6ed01 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/decode_target.md +++ b/cobalt/site/docs/reference/starboard/modules/15/decode_target.md @@ -12,7 +12,7 @@ data. This allows the application to allocate fast graphics memory, and have decoding done directly into this memory, avoiding unnecessary memory copies, and also avoiding pushing data between CPU and GPU memory unnecessarily. -## SbDecodeTargetFormat +* SbDecodeTargetFormat SbDecodeTargets support several different formats that can be used to decode into and render from. Some formats may be easier to decode into, and others may @@ -21,7 +21,7 @@ the SbDecodeTargetFormat passed into it, or the decode will produce an error. Each decoder provides a way to check if a given SbDecodeTargetFormat is supported by that decoder. -## SbDecodeTargetGraphicsContextProvider +* SbDecodeTargetGraphicsContextProvider Some components may need to acquire SbDecodeTargets compatible with a certain rendering context, which may need to be created on a particular thread. The @@ -33,51 +33,7 @@ to run arbitrary code on the application's renderer thread with the renderer's EGLContext held current. This may be useful if your SbDecodeTarget creation code needs to execute GLES commands like, for example, glGenTextures(). -The primary usage is likely to be the the SbPlayer implementation on some -platforms. - -## SbDecodeTarget Example - -Let's say that we are an application and we would like to use the interface -defined in starboard/image.h to decode an imaginary "image/foo" image type. - -First, the application should enumerate which SbDecodeTargetFormats are -supported by that decoder. - -``` -SbDecodeTargetFormat kPreferredFormats[] = { - kSbDecodeTargetFormat3PlaneYUVI420, - kSbDecodeTargetFormat1PlaneRGBA, - kSbDecodeTargetFormat1PlaneBGRA, -}; - -SbDecodeTargetFormat format = kSbDecodeTargetFormatInvalid; -for (int i = 0; i < SB_ARRAY_SIZE_INT(kPreferredFormats); ++i) { - if (SbImageIsDecodeSupported("image/foo", kPreferredFormats[i])) { - format = kPreferredFormats[i]; - break; - } -} - -``` - -Now that the application has a format, it can create a decode target that it -will use to decode the .foo file into. Let's assume format is -kSbDecodeTargetFormat1PlaneRGBA, that we are on an EGL/GLES2 platform. Also, we -won't do any error checking, to keep things even simpler. - -``` -SbDecodeTarget target = SbImageDecode( - context_provider, encoded_foo_data, encoded_foo_data_size, - "image/foo", format); - -// If the decode works, you can get the texture out and render it. -SbDecodeTargetInfo info; -memset(&info, 0, sizeof(info)); -SbDecodeTargetGetInfo(target, &info); -GLuint texture = - info.planes[kSbDecodeTargetPlaneRGBA].texture; -``` +The primary usage is likely to be the SbPlayer implementation on some platforms. ## Macros @@ -127,9 +83,9 @@ premultiplied unless otherwise explicitly specified. A decoder target format consisting of a single plane with pixels laid out in the format UYVY. Since there are two Y values per sample, but only one U value and only one V value, horizontally the Y resolution is twice the size - of both the U and V resolutions. Vertically, they Y, U and V all have the - same resolution. This is a YUV 422 format. When using this format with GL - platforms, it is expected that the underlying texture will be set to the + of both the U and V resolutions. Vertically, the Y, U, and V planes all have + the same resolution. This is a YUV 422 format. When using this format with + GL platforms, it is expected that the underlying texture will be set to the GL_RGBA format, and the width of the texture will be equal to the number of UYVY tuples per row (e.g. the u/v width resolution). Content region left/right should be specified in u/v width resolution. @@ -207,8 +163,7 @@ information about the graphics context that will be used to render SbDecodeTargets. Some Starboard implementations may need to have references to some graphics objects when creating/destroying resources used by SbDecodeTarget. References to SbDecodeTargetGraphicsContextProvider objects should be provided -to all Starboard functions that might create SbDecodeTargets (e.g. -SbImageDecode()). +to all Starboard functions that might create SbDecodeTargets. #### Members @@ -216,12 +171,12 @@ SbImageDecode()). A reference to the EGLDisplay object that hosts the EGLContext that will be used to render any produced SbDecodeTargets. Note that it has the type - `void*` in order to avoid #including the EGL header files here. + `void*` in order to avoid including the EGL header files here. * `void * egl_context` The EGLContext object that will be used to render any produced SbDecodeTargets. Note that it has the type `void*` in order to avoid - #including the EGL header files here. + including the EGL header files here. * `SbDecodeTargetGlesContextRunner gles_context_runner` The `gles_context_runner` function pointer is passed in from the application @@ -264,7 +219,7 @@ This can be queried via calls to SbDecodeTargetGetInfo(). * `SbDecodeTargetInfoPlane planes` The image planes (e.g. kSbDecodeTargetPlaneRGBA, or {kSbDecodeTargetPlaneY, - kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV} associated with this decode + kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV}) associated with this decode target. ### SbDecodeTargetInfoContentRegion @@ -368,8 +323,7 @@ static bool SbDecodeTargetIsValid(SbDecodeTarget handle) Returns ownership of `decode_target` to the Starboard implementation. This function will likely result in the destruction of the SbDecodeTarget and all its associated surfaces, though in some cases, platforms may simply adjust a -reference count. In the case where SB_HAS(GLES2), this function must be called -on a thread with the context +reference count. This function must be called on a thread with the context. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/15/drm.md b/cobalt/site/docs/reference/starboard/modules/15/drm.md index f42e43bf3db7..7317fda307ff 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/drm.md +++ b/cobalt/site/docs/reference/starboard/modules/15/drm.md @@ -29,7 +29,7 @@ Encryption scheme of the input sample, as defined in ISO/IEC 23001 part 7. ### SbDrmKeyStatus -Status of a particular media key. [https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus](https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus) +Status of a particular media key. [https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus](https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus) #### Values @@ -67,8 +67,9 @@ The status of session related operations. Used by * `kSbDrmStatusQuotaExceededError` * `kSbDrmStatusUnknownError` - The following error can be used when the error status cannot be mapped to - one of the above errors. + The kSbDrmStatusUnknownError can be used when the error status cannot be + mapped to one of the rest errors. New error codes (if needed) should be + added before kSbDrmStatusUnknownError. ## Typedefs @@ -85,7 +86,7 @@ typedef void(* SbDrmServerCertificateUpdatedFunc) (SbDrmSystem drm_system, void ### SbDrmSessionClosedFunc -A callback for signalling that a session has been closed by the SbDrmSystem +A callback for signalling that a session has been closed by the SbDrmSystem. #### Definition @@ -96,8 +97,15 @@ typedef void(* SbDrmSessionClosedFunc) (SbDrmSystem drm_system, void *context, c ### SbDrmSessionKeyStatusesChangedFunc A callback for notifications that the status of one or more keys in a session -has been changed. All keys of the session and their new status will be passed -along. Any keys not in the list is considered as deleted. +has been changed. A pointer to an array of all keys `key_ids` of the session and +their new status will be passed along. Any keys not in the list are considered +as deleted. + +`number_of_keys` is the number of keys. + +`key_ids` is a pointer to an array of keys. + +`key_statuses` is a pointer of a vector contains the status of each key. #### Definition @@ -119,6 +127,7 @@ context that was passed into the call to SbDrmCreateSystem(). `error_message` may contain an optional error message when `status` isn't `kSbDrmStatusSuccess` to provide more details about the error. It may be NULL if `status` is `kSbDrmStatusSuccess` or if no error message can be provided. + `ticket` will be the same ticket that was passed to SbDrmGenerateSessionUpdateRequest() or `kSbDrmTicketInvalid` if the update request was generated by the DRM system. @@ -246,6 +255,50 @@ Clear any internal states/resources related to the specified `session_id`. void SbDrmCloseSession(SbDrmSystem drm_system, const void *session_id, int session_id_size) ``` +### SbDrmCreateSystem + +Creates a new DRM system that can be used when constructing an SbPlayer or an +SbDecoder. + +This function returns `kSbDrmSystemInvalid` if `key_system` is unsupported. + +Also see the documentation of SbDrmGenerateSessionUpdateRequest() and +SbDrmUpdateSession() for more details. + +`key_system`: The DRM key system to be created. The value should be in the form +of "com.example.somesystem". All letters in the value should be lowercase and +will be matched exactly with known DRM key systems of the platform. Note the key +system will be matched case sensitive. For more details, refer to [https://w3c.github.io/encrypted-media/#dfn-key-system-s](https://w3c.github.io/encrypted-media/#dfn-key-system-s) + +`context`: A value passed when any of this function's callback parameters are +called. + +`update_request_callback`: A function that is called every time after +SbDrmGenerateSessionUpdateRequest() is called. + +`session_updated_callback`: A function that is called every time after +SbDrmUpdateSession() is called. + +`key_statuses_changed_callback`: A function that can be called to indicate that +key statuses have changed. + +`server_certificate_updated_callback`: A function that is called to report +whether the server certificate has been successfully updated. It is called once +and only once. It is possible that the callback is called before the function +returns. + +`session_closed_callback`: A function that can be called to indicate that a +session has closed. If `NULL` is passed for any of the callbacks +(`update_request_callback`, `session_updated_callback`, +`key_statuses_changed_callback`, `server_certificate_updated_callback`, or +`session_closed_callback`), then `kSbDrmSystemInvalid` must be returned. + +#### Declaration + +``` +SbDrmSystem SbDrmCreateSystem(const char *key_system, void *context, SbDrmSessionUpdateRequestFunc update_request_callback, SbDrmSessionUpdatedFunc session_updated_callback, SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, SbDrmServerCertificateUpdatedFunc server_certificate_updated_callback, SbDrmSessionClosedFunc session_closed_callback) +``` + ### SbDrmDestroySystem Destroys `drm_system`, which implicitly removes all keys installed in it and @@ -292,9 +345,12 @@ establish ticket uniqueness, issuing multiple requests with the same ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must not be used. `type`: The case-sensitive type of the session update request payload. Must not -be NULL. `initialization_data`: The data for which the session update request -payload is created. Must not be NULL. `initialization_data_size`: The size of -the session update request payload. +be NULL. + +`initialization_data`: The data for which the session update request payload is +created. Must not be NULL. + +`initialization_data_size`: The size of the session update request payload. #### Declaration @@ -375,14 +431,18 @@ a previous call is called. Note that this function should only be called after `SbDrmIsServerCertificateUpdatable` is called first and returned true. `drm_system`: The DRM system whose server certificate is being updated. Must not -be `kSbDrmSystemInvalid`. `ticket`: The opaque ID that allows to distinguish -callbacks from multiple concurrent calls to SbDrmUpdateServerCertificate(), -which will be passed to `server_certificate_updated_callback` as-is. It is the -responsibility of the caller to establish ticket uniqueness, issuing multiple -requests with the same ticket may result in undefined behavior. The value -`kSbDrmTicketInvalid` must not be used. `certificate`: Pointer to the server -certificate data. Must not be NULL. `certificate_size`: Size of the server -certificate data. +be `kSbDrmSystemInvalid`. + +`ticket`: The opaque ID that allows to distinguish callbacks from multiple +concurrent calls to SbDrmUpdateServerCertificate(), which will be passed to +`server_certificate_updated_callback` as-is. It is the responsibility of the +caller to establish ticket uniqueness, issuing multiple requests with the same +ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must +not be used. + +`certificate`: Pointer to the server certificate data. Must not be NULL. + +`certificate_size`: Size of the server certificate data. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/15/event.md b/cobalt/site/docs/reference/starboard/modules/15/event.md index fdfa85670d1e..8276ce9ef129 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/event.md +++ b/cobalt/site/docs/reference/starboard/modules/15/event.md @@ -313,7 +313,7 @@ Structure representing a Starboard event and its data. #### Members * `SbEventType type` -* `SbTimeMonotonic timestamp` +* `int64_t timestamp` * `void * data` ### SbEventStartData @@ -399,7 +399,7 @@ of microseconds to wait before calling the `callback` function. Set `delay` to #### Declaration ``` -SbEventId SbEventSchedule(SbEventCallback callback, void *context, SbTime delay) +SbEventId SbEventSchedule(SbEventCallback callback, void *context, int64_t delay) ``` ### SbRunStarboardMain diff --git a/cobalt/site/docs/reference/starboard/modules/15/file.md b/cobalt/site/docs/reference/starboard/modules/15/file.md index 103af475ace1..b79900e7a507 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/file.md +++ b/cobalt/site/docs/reference/starboard/modules/15/file.md @@ -124,15 +124,15 @@ Used to hold information about a file. * `bool is_symbolic_link` Whether the file corresponds to a symbolic link. -* `SbTime last_modified` +* `int64_t last_modified` - The last modified time of a file. -* `SbTime last_accessed` + The last modified time of a file - microseconds since Windows epoch UTC. +* `int64_t last_accessed` - The last accessed time of a file. -* `SbTime creation_time` + The last accessed time of a file - microseconds since Windows epoch UTC. +* `int64_t creation_time` - The creation time of a file. + The creation time of a file - microseconds since Windows epoch UTC. ## Functions diff --git a/cobalt/site/docs/reference/starboard/modules/15/image.md b/cobalt/site/docs/reference/starboard/modules/15/image.md index 945938a09903..98d3c5a61a84 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/image.md +++ b/cobalt/site/docs/reference/starboard/modules/15/image.md @@ -26,6 +26,7 @@ if (!SbImageIsDecodeSupported(mime_type, format)) { SbDecodeTarget result_target = SbImageDecode(provider, data, data_size, mime_type, format); + ``` ## Functions diff --git a/cobalt/site/docs/reference/starboard/modules/15/media.md b/cobalt/site/docs/reference/starboard/modules/15/media.md index 42871c2abda4..e515ae3514fe 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/media.md +++ b/cobalt/site/docs/reference/starboard/modules/15/media.md @@ -187,7 +187,7 @@ output. The type of audio connector. Will be `kSbMediaAudioConnectorUnknown` if this device cannot provide this information. -* `SbTime latency` +* `int64_t latency` The expected latency of audio over this output, in microseconds, or `0` if this device cannot provide this information. @@ -209,8 +209,8 @@ The set of information required by the decoder or player for each audio sample. * `SbMediaAudioStreamInfo stream_info` The set of information of the video stream associated with this sample. -* `SbTime discarded_duration_from_front` -* `SbTime discarded_duration_from_back` +* `int64_t discarded_duration_from_front` +* `int64_t discarded_duration_from_back` ### SbMediaAudioStreamInfo @@ -240,14 +240,13 @@ The set of information required by the decoder or player for each audio stream. The size, in bytes, of the audio_specific_config. * `const void * audio_specific_config` - The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1: [http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF](http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF) + The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1. ### SbMediaColorMetadata HDR (High Dynamic Range) Metadata common for HDR10 and WebM/VP9-based HDR formats, together with the ColorSpace. HDR reproduces a greater dynamic range of -luminosity than is possible with standard digital imaging. See the Consumer -Electronics Association press release: [https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx](https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx) +luminosity than is possible with standard digital imaging. #### Members @@ -447,10 +446,12 @@ Note that neither `mime` nor `key_system` can be NULL. This function returns `mime`: The mime information of the media in the form of `video/webm` or `video/mp4; codecs="avc1.42001E"`. It may include arbitrary parameters like "codecs", "channels", etc. Note that the "codecs" parameter may contain more -than one codec, delimited by comma. `key_system`: A lowercase value in the form -of "com.example.somesystem" as suggested by [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system)) that can +than one codec, delimited by comma. + +`key_system`: A lowercase value in the form of "com.example.somesystem", and can be matched exactly with known DRM key systems of the platform. When `key_system` is an empty string, the return value is an indication for non-encrypted media. +For more detail, refer to [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system) An implementation may choose to support `key_system` with extra attributes, separated by ';', like `com.example.somesystem; attribute_name1="value1"; @@ -462,23 +463,21 @@ attributes, it has to support all attributes defined by the Starboard version the implementation uses. An implementation should ignore any unknown attributes, and make a decision solely based on the key system and the known attributes. For example, if an implementation supports "com.widevine.alpha", it should also -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when -`key_system` is `com.widevine.alpha; invalid_attribute="invalid_value"`. -Currently the only attribute has to be supported is `encryptionscheme`. It -reflects the value passed to `encryptionScheme` encryptionScheme of -MediaKeySystemMediaCapability, as defined in [https://wicg.github.io/encrypted-media-encryption-scheme/,](https://wicg.github.io/encrypted-media-encryption-scheme/,),) which can take value "cenc", "cbcs", or "cbcs-1-9". Empty string is -not a valid value for `encryptionscheme` and the implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when +return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; +invalid_attribute="invalid_value"`. Currently the only attribute has to be +supported is `encryptionscheme`. It reflects the value passed to +`encryptionScheme` of MediaKeySystemMediaCapability. It can take value "cenc", +"cbcs", or "cbcs-1-9". Empty string is not a valid value for `encryptionscheme` +and the implementation should return `kSbMediaSupportTypeNotSupported` when `encryptionscheme` is set to "". The implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported for unknown -values of known attributes. For example, if an implementation supports -"encryptionscheme" with value "cenc", "cbcs", or "cbcs-1-9", then it should -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when +`kSbMediaSupportTypeNotSupported` for unknown values of known attributes. For +example, if an implementation supports "encryptionscheme" with value "cenc", +"cbcs", or "cbcs-1-9", then it should return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; encryptionscheme="cenc"`, and return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when -`key_system` is `com.widevine.alpha; encryptionscheme="invalid"`. If an -implementation supports key system with attributes on one key system, it has to -support key system with attributes on all key systems supported. +`kSbMediaSupportTypeNotSupported` when `key_system` is `com.widevine.alpha; +encryptionscheme="invalid"`. If an implementation supports key system with +attributes on one key system, it has to support key system with attributes on +all key systems supported. For more detail, refer to [https://wicg.github.io/encrypted-media-encryption-scheme](https://wicg.github.io/encrypted-media-encryption-scheme) #### Declaration @@ -548,7 +547,7 @@ When the media stack needs more memory to store media buffers, it will allocate extra memory in units returned by SbMediaGetBufferAllocationUnit. This can return 0, in which case the media stack will allocate extra memory on demand. When SbMediaGetInitialBufferCapacity and this function both return 0, the media -stack will allocate individual buffers directly using SbMemory functions. +stack will allocate individual buffers directly using malloc functions. #### Declaration @@ -558,19 +557,19 @@ int SbMediaGetBufferAllocationUnit() ### SbMediaGetBufferGarbageCollectionDurationThreshold -Specifies the duration threshold of media source garbage collection. When the -accumulated duration in a source buffer exceeds this value, the media source -implementation will try to eject existing buffers from the cache. This is -usually triggered when the video being played has a simple content and the -encoded data is small. In such case this can limit how much is allocated for the -book keeping data of the media buffers and avoid OOM of system heap. This should -return 170 seconds for most of the platforms. But it can be further reduced on -systems with extremely low memory. +Specifies the duration threshold of media source garbage collection in +microseconds. When the accumulated duration in a source buffer exceeds this +value, the media source implementation will try to eject existing buffers from +the cache. This is usually triggered when the video being played has a simple +content and the encoded data is small. In such case this can limit how much is +allocated for the book keeping data of the media buffers and avoid OOM of system +heap. This should return 170 seconds for most of the platforms. But it can be +further reduced on systems with extremely low memory. #### Declaration ``` -SbTime SbMediaGetBufferGarbageCollectionDurationThreshold() +int64_t SbMediaGetBufferGarbageCollectionDurationThreshold() ``` ### SbMediaGetBufferPadding @@ -589,7 +588,7 @@ int SbMediaGetBufferPadding() Returns SbMediaBufferStorageType of type `SbMediaStorageTypeMemory` or `SbMediaStorageTypeFile`. For memory storage, the media buffers will be stored -in main memory allocated by SbMemory functions. For file storage, the media +in main memory allocated by malloc functions. For file storage, the media buffers will be stored in a temporary file in the system cache folder acquired by calling SbSystemGetPath() with "kSbSystemPathCacheDirectory". Note that when its value is "file" the media stack will still allocate memory to cache the @@ -624,10 +623,14 @@ allocation of media buffers may only fail when there is not enough memory in the system to fulfill the request, under which case the app will be terminated as under other OOM situations. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -642,10 +645,14 @@ resolution of such videos shouldn't go beyond 1080p. Its value should be less than the sum of SbMediaGetAudioBufferBudget and 'SbMediaGetVideoBufferBudget(..., 1920, 1080, ...) but not less than 8 MB. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -661,10 +668,14 @@ being used by video buffers but will also make app less likely to re-download video data. Note that the app may experience significant difficulty if this value is too low. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -692,7 +703,7 @@ bool SbMediaIsBufferPoolAllocateOnDemand() ### SbMediaIsBufferUsingMemoryPool If SbMediaGetBufferUsingMemoryPool returns true, it indicates that media buffer -pools should be allocated on demand, as opposed to using SbMemory* functions. +pools should be allocated on demand, as opposed to using malloc functions. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/15/memory_reporter.md b/cobalt/site/docs/reference/starboard/modules/15/memory_reporter.md deleted file mode 100644 index 5e49693e70bc..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/15/memory_reporter.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -layout: doc -title: "Starboard Module Reference: memory_reporter.h" ---- - -DEPRECATED: Provides an interface for memory reporting. - -## Typedefs ## - -### SbMemoryReporterOnAlloc ### - -A function to report a memory allocation from SbMemoryAllocate(). Note that -operator new calls SbMemoryAllocate which will delegate to this callback. - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnAlloc) (void *context, const void *memory, size_t size) -``` - -### SbMemoryReporterOnDealloc ### - -A function to report a memory deallocation from SbMemoryDeallcoate(). Note that -operator delete calls SbMemoryDeallocate which will delegate to this callback. - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnDealloc) (void *context, const void *memory) -``` - -### SbMemoryReporterOnMapMemory ### - -A function to report a memory mapping from SbMemoryMap(). - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnMapMemory) (void *context, const void *memory, size_t size) -``` - -### SbMemoryReporterOnUnMapMemory ### - -A function to report a memory unmapping from SbMemoryUnmap(). - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnUnMapMemory) (void *context, const void *memory, size_t size) -``` - -## Structs ## - -### SbMemoryReporter ### - -SbMemoryReporter allows memory reporting via user-supplied functions. The void* -context is passed to every call back. It's strongly recommended that C-Style -struct initialization is used so that the arguments can be typed check by the -compiler. For example, SbMemoryReporter mem_reporter = { MallocCallback, .... -context }; - -#### Members #### - -* `SbMemoryReporterOnAlloc on_alloc_cb` - - Callback to report allocations. -* `SbMemoryReporterOnDealloc on_dealloc_cb` - - Callback to report deallocations. -* `SbMemoryReporterOnMapMemory on_mapmem_cb` - - Callback to report memory map. -* `SbMemoryReporterOnUnMapMemory on_unmapmem_cb` - - Callback to report memory unmap. -* `void * context` - - Optional, is passed to callbacks as first argument. - -## Functions ## - -### SbMemorySetReporter ### - -Sets the MemoryReporter. Any previous memory reporter is unset. No lifetime -management is done internally on input pointer. - -NOTE: This module is unused starting with Starboard 15 and will be removed in -the future. - -Returns true if the memory reporter was set with no errors. If an error was -reported then check the log for why it failed. - -Note that other than a thread-barrier-write of the input pointer, there is no -thread safety guarantees with this function due to performance considerations. -It's recommended that this be called once during the lifetime of the program, or -not at all. Do not delete the supplied pointer, ever. Example (Good): -SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter); -... SbMemorySetReporter(NULL); // allow value to leak. Example (Bad): -SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter); -... SbMemorySetReporter(NULL); delete mem_reporter; // May crash. - -#### Declaration #### - -``` -bool SbMemorySetReporter(struct SbMemoryReporter *tracker) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/15/mutex.md b/cobalt/site/docs/reference/starboard/modules/15/mutex.md index 82ff8500ab8d..55f9c01e9adc 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/mutex.md +++ b/cobalt/site/docs/reference/starboard/modules/15/mutex.md @@ -40,7 +40,7 @@ SB_MUTEX_MAX_SIZE and aligned at void pointer type. #### Definition ``` -typedef union SbMutex SbMutex +typedef union SbMutex SbMutex ``` ## Functions diff --git a/cobalt/site/docs/reference/starboard/modules/15/once.md b/cobalt/site/docs/reference/starboard/modules/15/once.md index d77302467f8b..1c1f21932f06 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/once.md +++ b/cobalt/site/docs/reference/starboard/modules/15/once.md @@ -22,7 +22,7 @@ SB_ONCE_MAX_SIZE and aligned at void pointer type. #### Definition ``` -typedef union SbOnceControl SbOnceControl +typedef union SbOnceControl SbOnceControl ``` ### SbOnceInitRoutine diff --git a/cobalt/site/docs/reference/starboard/modules/15/player.md b/cobalt/site/docs/reference/starboard/modules/15/player.md index 0382642a35fe..efbb73e3b2a4 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/player.md +++ b/cobalt/site/docs/reference/starboard/modules/15/player.md @@ -52,9 +52,12 @@ data may come from multiple sources. * `kMatroskaBlockAdditional` The side data comes from the BlockAdditional data in the Matroska/Webm - container, as specified in [https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39](https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39)9) andnd [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional)l) - . The first 8 bytes of the data contains the value of BlockAddID in big - endian format, followed by the content of BlockAdditional. + container. The first 8 bytes of the data contains the value of BlockAddID in + big endian format, followed by the content of BlockAdditional. See: + + [https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03](https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03) + + [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional) ### SbPlayerState @@ -130,10 +133,13 @@ typedef void(* SbPlayerDecoderStatusFunc) (SbPlayer player, void *context, SbMed ### SbPlayerErrorFunc -Callback for player errors, that may set a `message`. `error`: indicates the -error code. `message`: provides specific informative diagnostic message about -the error condition encountered. It is ok for the message to be an empty string -or NULL if no information is available. +Callback for player errors, that may set a `message`. + +`error`: indicates the error code. + +`message`: provides specific informative diagnostic message about the error +condition encountered. It is ok for the message to be an empty string or NULL if +no information is available. #### Definition @@ -192,14 +198,14 @@ Information about the current media playback state. #### Members -* `SbTime current_media_timestamp` +* `int64_t current_media_timestamp` The position of the playback head, as precisely as possible, in microseconds. -* `SbTime duration` +* `int64_t duration` The known duration of the currently playing media stream, in microseconds. -* `SbTime start_date` +* `int64_t start_date` The result of getStartDate for the currently playing media stream, in microseconds since the epoch of January 1, 1601 UTC. @@ -250,9 +256,9 @@ Information about the samples to be written into SbPlayerWriteSamples(). * `int buffer_size` Size of the data pointed to by `buffer`. -* `SbTime timestamp` +* `int64_t timestamp` - The timestamp of the sample in SbTime. + The timestamp of the sample in microseconds since Windows epoch UTC. * `SbPlayerSampleSideData* side_data` Points to an array of side data for the input, when available. @@ -292,20 +298,123 @@ coming from multiple sources. ## Functions +### SbPlayerCreate + +Creates a player that will be displayed on `window` for the specified +`video_codec` and `audio_codec`, acquiring all resources needed to operate it, +and returning an opaque handle to it. The expectation is that a new player will +be created and destroyed for every playback. + +This function returns the created player. Note the following: + +* The associated decoder of the returned player should be assumed to not be in + `kSbPlayerDecoderStateNeedsData` until SbPlayerSeek() has been called on it. + +* It is expected either that the thread that calls SbPlayerCreate is the same + thread that calls the other `SbPlayer` functions for that player, or that + there is a mutex guarding calls into each `SbPlayer` instance. + +* If there is a platform limitation on how many players can coexist + simultaneously, then calls made to this function that attempt to exceed that + limit must return `kSbPlayerInvalid`. Multiple calls to SbPlayerCreate must + not cause a crash. + +`window`: The window that will display the player. `window` can be +`kSbWindowInvalid` for platforms where video is only displayed on a particular +window that the underlying implementation already has access to. + +`video_codec`: The video codec used for the player. If `video_codec` is +`kSbMediaVideoCodecNone`, the player is an audio-only player. If `video_codec` +is any other value, the player is an audio/video decoder. This can be set to +`kSbMediaVideoCodecNone` to play a video with only an audio track. + +`audio_codec`: The audio codec used for the player. The caller must provide a +populated `audio_sample_info` if audio codec is `kSbMediaAudioCodecAac`. Can be +set to `kSbMediaAudioCodecNone` to play a video without any audio track. In such +case `audio_sample_info` must be NULL. + +`drm_system`: If the media stream has encrypted portions, then this parameter +provides an appropriate DRM system, created with `SbDrmCreateSystem()`. If the +stream does not have encrypted portions, then `drm_system` may be +`kSbDrmSystemInvalid`. + +`audio_sample_info`: Note that the caller must provide a populated +`audio_sample_info` if the audio codec is `kSbMediaAudioCodecAac`. Otherwise, +`audio_sample_info` can be NULL. See media.h for the format of the +`SbMediaAudioSampleInfo` struct. + +Note that `audio_specific_config` is a pointer and the content it points to is +no longer valid after this function returns. The implementation has to make a +copy of the content if it is needed after the function returns. + +`max_video_capabilities`: This string communicates the max video capabilities +required to the platform. The web app will not provide a video stream exceeding +the maximums described by this parameter. Allows the platform to optimize +playback pipeline for low quality video streams if it knows that it will never +adapt to higher quality streams. The string uses the same format as the string +passed in to SbMediaCanPlayMimeAndKeySystem(), for example, when it is set to +"width=1920; height=1080; framerate=15;", the video will never adapt to +resolution higher than 1920x1080 or frame per second higher than 15 fps. When +the maximums are unknown, this will be set to NULL. + +`sample_deallocator_func`: If not `NULL`, the player calls this function on an +internal thread to free the sample buffers passed into SbPlayerWriteSample(). + +`decoder_status_func`: If not `NULL`, the decoder calls this function on an +internal thread to provide an update on the decoder's status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_status_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the playback status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_error_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the error status. This callback is +responsible for setting the media error message. + +`context`: This is passed to all callbacks and is generally used to point at a +class or struct that contains state associated with the player. + +`output_mode`: Selects how the decoded video frames will be output. For example, +kSbPlayerOutputModePunchOut indicates that the decoded video frames will be +output to a background video layer by the platform, and +kSbPlayerOutputDecodeToTexture indicates that the decoded video frames should be +made available for the application to pull via calls to +SbPlayerGetCurrentFrame(). + +`provider`: Only present in Starboard version 3 and up. If not `NULL`, then when +output_mode == kSbPlayerOutputModeDecodeToTexture, the player MAY use the +provider to create SbDecodeTargets on the renderer thread. A provider may not +always be needed by the player, but if it is needed, and the provider is not +given, the player will fail by returning `kSbPlayerInvalid`. + +If `NULL` is passed to any of the callbacks (`sample_deallocator_func`, +`decoder_status_func`, `player_status_func`, or `player_error_func` if it +applies), then `kSbPlayerInvalid` must be returned. + +#### Declaration + +``` +SbPlayer SbPlayerCreate(SbWindow window, const SbPlayerCreationParam *creation_param, SbPlayerDeallocateSampleFunc sample_deallocate_func, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void *context, SbDecodeTargetGraphicsContextProvider *context_provider) +``` + ### SbPlayerDestroy Destroys `player`, freeing all associated resources. * Upon calling this method, there should be one call to the player status callback (i.e. `player_status_func` used in the creation of the player) - which indicates the player is destroyed. Note, the callback has to be in- - flight when SbPlayerDestroyed is called. + which indicates the player is destroyed. Note, the callback has to be + inflight when SbPlayerDestroyed is called. * No more other callbacks should be issued after this function returns. * It is not allowed to pass `player` into any other `SbPlayer` function once - SbPlayerDestroy has been called on that player. `player`: The player to be - destroyed. Must not be `kSbPlayerInvalid`. + SbPlayerDestroy has been called on that player. + +`player`: The player to be destroyed. Must not be `kSbPlayerInvalid`. #### Declaration @@ -326,50 +435,50 @@ audio output configurations other than the ones already returned. The app will use the information returned to determine audio related behaviors, like: -Audio Write Duration: Audio write duration is how far past the current playback -position the app will write audio samples. The app will write all samples -between `current_playback_position` and `current_playback_position` + -`audio_write_duration`, as soon as they are available. - -`audio_write_duration` will be to `kSbPlayerWriteDurationLocal` -kSbPlayerWriteDurationLocal when all audio configurations linked to `player` is -local, or if there isn't any audio output. It will be set to -`kSbPlayerWriteDurationRemote` kSbPlayerWriteDurationRemote for remote or -wireless audio outputs, i.e. one of `kSbMediaAudioConnectorBluetooth` -kSbMediaAudioConnectorBluetooth or `kSbMediaAudioConnectorRemote*` -kSbMediaAudioConnectorRemote* . - -The app only guarantees to write `audio_write_duration` past -`current_playback_position`, but the app is free to write more samples than -that. So the platform shouldn't rely on this for flow control. The platform -should achieve flow control by sending `kSbPlayerDecoderStateNeedsData` -kSbPlayerDecoderStateNeedsData less frequently. - -The platform is responsible for guaranteeing that when only -`audio_write_duration` audio samples are written at a time, no playback issues -occur (such as transient or indefinite hanging). +* Audio Write Duration: Audio write duration is how far past the current + playback position the app will write audio samples. The app will write all + samples between `current_playback_position` and `current_playback_position` + + `audio_write_duration`, as soon as they are available. + +* `audio_write_duration` will be to `kSbPlayerWriteDurationLocal` when all + audio configurations linked to `player` is local, or if there isn't any + audio output. It will be set to `kSbPlayerWriteDurationRemote` for remote or + wireless audio outputs, i.e. one of `kSbMediaAudioConnectorBluetooth` or + `kSbMediaAudioConnectorRemote*`. + +* The app only guarantees to write `audio_write_duration` past + `current_playback_position`, but the app is free to write more samples than + that. So the platform shouldn't rely on this for flow control. The platform + should achieve flow control by sending `kSbPlayerDecoderStateNeedsData` less + frequently. + +* The platform is responsible for guaranteeing that when only + `audio_write_duration` audio samples are written at a time, no playback + issues occur (such as transient or indefinite hanging). The audio configurations should be available as soon as possible, and they have -to be available when the `player` is at `kSbPlayerStatePresenting` -kSbPlayerStatePresenting , unless the audio codec is `kSbMediaAudioCodecNone` or -there's no written audio inputs. +to be available when the `player` is at `kSbPlayerStatePresenting`, unless the +audio codec is `kSbMediaAudioCodecNone` or there's no written audio inputs. -The app will set `audio_write_duration` to `kSbPlayerWriteDurationLocal` -kSbPlayerWriteDurationLocal when the audio configuration isn't available (i.e. -the function returns false when index is 0). The platform has to make the audio -configuration available immediately after the SbPlayer is created, if it expects -the app to treat the platform as using wireless audio outputs. +The app will set `audio_write_duration` to `kSbPlayerWriteDurationLocal` when +the audio configuration isn't available (i.e. the function returns false when +index is 0). The platform has to make the audio configuration available +immediately after the SbPlayer is created, if it expects the app to treat the +platform as using wireless audio outputs. Once at least one audio configurations are returned, the return values and their orders shouldn't change during the life time of `player`. The platform may -inform the app of any changes by sending `kSbPlayerErrorCapabilityChanged` -kSbPlayerErrorCapabilityChanged to request a playback restart. +inform the app of any changes by sending `kSbPlayerErrorCapabilityChanged` to +request a playback restart. `player`: The player about which information is being retrieved. Must not be -`kSbPlayerInvalid`. `index`: The index of the audio output configuration. Must -be greater than or equal to 0. `out_audio_configuration`: The information about -the audio output, refer to `SbMediaAudioConfiguration` for more details. Must -not be NULL. +`kSbPlayerInvalid`. + +`index`: The index of the audio output configuration. Must be greater than or +equal to 0. + +`out_audio_configuration`: The information about the audio output, refer to +`SbMediaAudioConfiguration` for more details. Must not be NULL. #### Declaration @@ -395,19 +504,36 @@ kSbDecodeTargetInvalid is returned. SbDecodeTarget SbPlayerGetCurrentFrame(SbPlayer player) ``` +### SbPlayerGetInfo + +Gets a snapshot of the current player state and writes it to `out_player_info`. +This function may be called very frequently and is expected to be inexpensive. + +`player`: The player about which information is being retrieved. Must not be +`kSbPlayerInvalid`. + +`out_player_info`: The information retrieved for the player. + +#### Declaration + +``` +void SbPlayerGetInfo(SbPlayer player, SbPlayerInfo *out_player_info) +``` + ### SbPlayerGetMaximumNumberOfSamplesPerWrite -Writes a single sample of the given media type to `player`'s input stream. Its -data may be passed in via more than one buffers. The lifetime of -`sample_buffers`, `sample_buffer_sizes`, `video_sample_info`, and -`sample_drm_info` (as well as member `subsample_mapping` contained inside it) -are not guaranteed past the call to SbPlayerWriteSample. That means that before -returning, the implementation must synchronously copy any information it wants -to retain from those structures. +Returns the maximum number of samples that can be written in a single call to +SbPlayerWriteSamples(). Returning a value greater than one can improve +performance by allowing SbPlayerWriteSamples() to write multiple samples in one +call. -`player`: The player for which the number is retrieved. `sample_type`: The type -of sample for which the number is retrieved. See the `SbMediaType` enum in -media.h. +Note that this feature is currently disabled in Cobalt where +SbPlayerWriteSamples() will always be called with one sample. + +`player`: The player for which the number is retrieved. + +`sample_type`: The type of sample for which the number is retrieved. See the +`SbMediaType` enum in media.h. #### Declaration @@ -449,6 +575,45 @@ Returns whether the given player handle is valid. static bool SbPlayerIsValid(SbPlayer player) ``` +### SbPlayerSeek + +Tells the player to freeze playback (if playback has already started), reset or +flush the decoder pipeline, and go back to the Prerolling state. The player +should restart playback once it can display the frame at `seek_to_timestamp`, or +the closest it can get. (Some players can only seek to I-Frames, for example.) + +* Seek must be called before samples are sent when starting playback for the + first time, or the client never receives the + `kSbPlayerDecoderStateNeedsData` signal. + +* A call to seek may interrupt another seek. + +* After this function is called, the client should not send any more audio or + video samples until `SbPlayerDecoderStatusFunc` is called back with + `kSbPlayerDecoderStateNeedsData` for each required media type. + `SbPlayerDecoderStatusFunc` is the `decoder_status_func` callback function + that was specified when the player was created (SbPlayerCreate). + +`player`: The SbPlayer in which the seek operation is being performed. Must not +be `kSbPlayerInvalid`. + +`seek_to_timestamp`: The frame at which playback should begin. + +`ticket`: A user-supplied unique ID to be passed to all subsequent +`SbPlayerDecoderStatusFunc` calls. (That is the `decoder_status_func` callback +function specified when calling SbPlayerCreate.) + +The `ticket` value is used to filter calls that may have been in flight when +SbPlayerSeek was called. To be very specific, once SbPlayerSeek has been called +with ticket X, a client should ignore all `SbPlayerDecoderStatusFunc` calls that +do not pass in ticket X. + +#### Declaration + +``` +void SbPlayerSeek(SbPlayer player, int64_t seek_to_timestamp, int ticket) +``` + ### SbPlayerSetBounds Sets the player bounds to the given graphics plane coordinates. The changes do @@ -464,11 +629,18 @@ implementors should take care to avoid related performance concerns with such frequent calls. `player`: The player that is being resized. Must not be `kSbPlayerInvalid`. + `z_index`: The z-index of the player. When the bounds of multiple players are overlapped, the one with larger z-index will be rendered on top of the ones with -smaller z-index. `x`: The x-coordinate of the upper-left corner of the player. -`y`: The y-coordinate of the upper-left corner of the player. `width`: The width -of the player, in pixels. `height`: The height of the player, in pixels. +smaller z-index. + +`x`: The x-coordinate of the upper-left corner of the player. + +`y`: The y-coordinate of the upper-left corner of the player. + +`width`: The width of the player, in pixels. + +`height`: The height of the player, in pixels. #### Declaration @@ -502,9 +674,11 @@ bool SbPlayerSetPlaybackRate(SbPlayer player, double playback_rate) Sets the player's volume. `player`: The player in which the volume is being adjusted. Must not be -`kSbPlayerInvalid`. `volume`: The new player volume. The value must be between -`0.0` and `1.0`, inclusive. A value of `0.0` means that the audio should be -muted, and a value of `1.0` means that it should be played at full volume. +`kSbPlayerInvalid`. + +`volume`: The new player volume. The value must be between `0.0` and `1.0`, +inclusive. A value of `0.0` means that the audio should be muted, and a value of +`1.0` means that it should be played at full volume. #### Declaration @@ -519,8 +693,9 @@ there are no more samples for that media type for the remainder of this media stream. This marker is invalidated, along with the rest of the stream's contents, after a call to SbPlayerSeek. -`player`: The player to which the marker is written. `stream_type`: The type of -stream for which the marker is written. +`player`: The player to which the marker is written. + +`stream_type`: The type of stream for which the marker is written. #### Declaration @@ -530,14 +705,29 @@ void SbPlayerWriteEndOfStream(SbPlayer player, SbMediaType stream_type) ### SbPlayerWriteSamples +Writes samples of the given media type to `player`'s input stream. The lifetime +of `sample_infos`, and the members of its elements like `buffer`, +`video_sample_info`, and `drm_info` (as well as member `subsample_mapping` +contained inside it) are not guaranteed past the call to SbPlayerWriteSamples(). +That means that before returning, the implementation must synchronously copy any +information it wants to retain from those structures. + +SbPlayerWriteSamples() allows writing of multiple samples in one call. + +`player`: The player to which the sample is written. Must not be +`kSbPlayerInvalid`. + `sample_type`: The type of sample being written. See the `SbMediaType` enum in -media.h. `sample_infos`: A pointer to an array of SbPlayerSampleInfo with +media.h. + +`sample_infos`: A pointer to an array of SbPlayerSampleInfo with `number_of_sample_infos` elements, each holds the data for an sample, i.e. a sequence of whole NAL Units for video, or a complete audio frame. `sample_infos` cannot be assumed to live past the call into SbPlayerWriteSamples(), so it must be copied if its content will be used after SbPlayerWriteSamples() returns. + `number_of_sample_infos`: Specify the number of samples contained inside -`sample_infos`. It has to be at least one, and less than the return value of +`sample_infos`. It has to be at least one, and at most the return value of SbPlayerGetMaximumNumberOfSamplesPerWrite(). #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/15/socket.md b/cobalt/site/docs/reference/starboard/modules/15/socket.md index 744c04e3847d..beeab4fddb6e 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/socket.md +++ b/cobalt/site/docs/reference/starboard/modules/15/socket.md @@ -540,15 +540,15 @@ Sets the `SO_KEEPALIVE`, or equivalent, option to `value` on `socket`. The return value indicates whether the option was actually set. `socket`: The SbSocket for which the option is set. `value`: If set to `true`, -then `period` specifies the minimum time (SbTime) is always in microseconds) -between keep-alive packets. If set to `false`, `period` is ignored. `period`: -The time between keep-alive packets. This value is only relevant if `value` is -`true`. +then `period` specifies the minimum time in microseconds between keep-alive +packets. If set to `false`, `period` is ignored. `period`: The time in +microseconds between keep-alive packets. This value is only relevant if `value` +is `true`. #### Declaration ``` -bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, SbTime period) +bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, int64_t period) ``` ### SbSocketSetTcpNoDelay diff --git a/cobalt/site/docs/reference/starboard/modules/15/socket_waiter.md b/cobalt/site/docs/reference/starboard/modules/15/socket_waiter.md index f1c6bd8b9f2f..8632f88a5f12 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/socket_waiter.md +++ b/cobalt/site/docs/reference/starboard/modules/15/socket_waiter.md @@ -202,15 +202,15 @@ SbSocketWaiterWakeUp() it not called by that time. The return value indicates the reason that the socket waiter exited. This function should only be called on the thread that waits on this waiter. -`duration`: The minimum amount of time after which the socket waiter should exit -if it is not woken up before then. As with SbThreadSleep() (see thread.h), this -function may wait longer than `duration`, such as if the timeout expires while a -callback is being fired. +`duration`: The minimum amount of time in microseconds after which the socket +waiter should exit if it is not woken up before then. As with SbThreadSleep() +(see thread.h), this function may wait longer than `duration`, such as if the +timeout expires while a callback is being fired. #### Declaration ``` -SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, SbTime duration) +SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, int64_t duration) ``` ### SbSocketWaiterWakeUp diff --git a/cobalt/site/docs/reference/starboard/modules/15/string.md b/cobalt/site/docs/reference/starboard/modules/15/string.md index 3fed809df461..fc8d82ae38ea 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/string.md +++ b/cobalt/site/docs/reference/starboard/modules/15/string.md @@ -127,21 +127,6 @@ be formatted. `arguments`: Variable arguments used in the string. int SbStringFormatWide(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format, va_list arguments) ``` -### SbStringFormatWideF - -An inline wrapper of SbStringFormatWide that converts from ellipsis to -`va_args`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `...`: Arguments used in the string. - -#### Declaration - -``` -static int SbStringFormatWideF(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format,...) -``` - ### SbStringScan Scans `buffer` for `pattern`, placing the extracted values in `arguments`. The diff --git a/cobalt/site/docs/reference/starboard/modules/15/thread.md b/cobalt/site/docs/reference/starboard/modules/15/thread.md index 56c7898a12b4..c988516192a4 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/thread.md +++ b/cobalt/site/docs/reference/starboard/modules/15/thread.md @@ -519,7 +519,7 @@ or `0`. #### Declaration ``` -void SbThreadSleep(SbTime duration) +void SbThreadSleep(int64_t duration) ``` ### SbThreadYield diff --git a/cobalt/site/docs/reference/starboard/modules/15/time_zone.md b/cobalt/site/docs/reference/starboard/modules/15/time_zone.md index 74d48172d63e..baad3759ac4b 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/time_zone.md +++ b/cobalt/site/docs/reference/starboard/modules/15/time_zone.md @@ -12,7 +12,7 @@ Provides access to the system time zone information. The number of minutes west of the Greenwich Prime Meridian, NOT including Daylight Savings Time adjustments. -For example: PST/PDT is 480 minutes (28800 seconds, 8 hours). +For example: America/Los_Angeles is 480 minutes (28800 seconds, 8 hours). #### Definition @@ -34,11 +34,11 @@ SbTimeZone SbTimeZoneGetCurrent() ### SbTimeZoneGetName -Gets a string representation of the current timezone. Note that the string -representation can either be standard or daylight saving time. The output can be -of the form: 1) A three-letter abbreviation such as "PST" or "PDT" (preferred). -2) A time zone identifier such as "America/Los_Angeles" 3) An un-abbreviated -name such as "Pacific Standard Time". +Gets a string representation of the current timezone. The format should be in +the IANA format [https://data.iana.org/time-zones/theory.html#naming](https://data.iana.org/time-zones/theory.html#naming)) . +Names normally have the form AREA/LOCATION, where AREA is a continent or ocean, +and LOCATION is a specific location within the area. Typical names are +'Africa/Cairo', 'America/New_York', and 'Pacific/Honolulu'. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/15/ui_navigation.md b/cobalt/site/docs/reference/starboard/modules/15/ui_navigation.md index cb4176713005..fa178d7689ce 100644 --- a/cobalt/site/docs/reference/starboard/modules/15/ui_navigation.md +++ b/cobalt/site/docs/reference/starboard/modules/15/ui_navigation.md @@ -268,6 +268,7 @@ right and top-to-bottom. ``` Top-to-bottom is similar to left-to-right, but for the Y position. Bottom-to-top is similar to right-to-left, but for the Y position. + ``` #### Members diff --git a/cobalt/site/docs/reference/starboard/modules/13/accessibility.md b/cobalt/site/docs/reference/starboard/modules/16/accessibility.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/accessibility.md rename to cobalt/site/docs/reference/starboard/modules/16/accessibility.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/atomic.md b/cobalt/site/docs/reference/starboard/modules/16/atomic.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/atomic.md rename to cobalt/site/docs/reference/starboard/modules/16/atomic.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/audio_sink.md b/cobalt/site/docs/reference/starboard/modules/16/audio_sink.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/audio_sink.md rename to cobalt/site/docs/reference/starboard/modules/16/audio_sink.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/configuration.md b/cobalt/site/docs/reference/starboard/modules/16/configuration.md similarity index 86% rename from cobalt/site/docs/reference/starboard/modules/13/configuration.md rename to cobalt/site/docs/reference/starboard/modules/16/configuration.md index d0ba3c7196f8..3ff1bef8b49c 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/configuration.md +++ b/cobalt/site/docs/reference/starboard/modules/16/configuration.md @@ -53,11 +53,10 @@ will trigger a compiler warning when referenced. SB_DEPRECATED_EXTERNAL(...) annotates the function as deprecated for external clients, but not deprecated for starboard. -### SB_EXPERIMENTAL_API_VERSION +### SB_EXPORT_PLATFORM -The API version that is currently open for changes, and therefore is not stable -or frozen. Production-oriented ports should avoid declaring that they implement -the experimental Starboard API version. +SB_C_FORCE_INLINE annotation for forcing a C function to be inlined. +SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. ### SB_FUNCTION @@ -73,17 +72,14 @@ header available. Whether the current platform has 64-bit atomic operations. -### SB_HAS_GLES2 - -Specifies whether this platform has a performant OpenGL ES 2 implementation, -which allows client applications to use GL rendering paths. Derived from the gyp -variable `gl_type` gl_type which indicates what kind of GL implementation is -available. - ### SB_HAS_QUIRK(SB_FEATURE) Determines at compile-time whether this platform has a quirk. +### SB_IMPORT_PLATFORM + +SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. + ### SB_INT64_C(x) Declare numeric literals of signed 64-bit type. @@ -99,7 +95,7 @@ Macro for hinting that an expression is likely to be true. ### SB_MAXIMUM_API_VERSION The maximum API version allowed by this version of the Starboard headers, -inclusive. +inclusive. The API version is not stable and is open for changes. ### SB_MINIMUM_API_VERSION @@ -111,11 +107,6 @@ inclusive. Macro to annotate a function as noreturn, which signals to the compiler that the function cannot return. -### SB_OVERRIDE - -Declares a function as overriding a virtual function on compilers that support -it. - ### SB_PREFERRED_RGBA_BYTE_ORDER_RGBA An enumeration of values for the kSbPreferredByteOrder configuration variable. @@ -136,7 +127,7 @@ base/compiler_specific.h) Include the platform-specific configuration. This macro is set by GN in starboard/build/config/BUILD.gn and passed in on the command line for all -targets and all configurations.Makes a pointer-typed parameter restricted so +targets and all configurations. Makes a pointer-typed parameter restricted so that the compiler can make certain optimizations because it knows the pointers are unique. diff --git a/cobalt/site/docs/reference/starboard/modules/13/configuration_constants.md b/cobalt/site/docs/reference/starboard/modules/16/configuration_constants.md similarity index 93% rename from cobalt/site/docs/reference/starboard/modules/13/configuration_constants.md rename to cobalt/site/docs/reference/starboard/modules/16/configuration_constants.md index 012754b623bd..3866aab20c5f 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/configuration_constants.md +++ b/cobalt/site/docs/reference/starboard/modules/16/configuration_constants.md @@ -9,6 +9,15 @@ runtime decisions based on per platform configurations. ## Variables +### kHasPartialAudioFramesSupport + +Platform can support partial audio frames + +### kSbCanMapExecutableMemory + +Whether this platform can map executable memory. This is required for platforms +that want to JIT. + ### kSbDefaultMmapThreshold Determines the threshold of allocation size that should be done with mmap (if @@ -50,10 +59,6 @@ component separator character. The string form of SB_FILE_SEP_CHAR. -### kSbHasAc3Audio - -Allow ac3 and ec3 support - ### kSbHasMediaWebmVp9Support Specifies whether this platform has webm/vp9 support. This should be set to non- @@ -67,6 +72,10 @@ Whether the current platform supports thread priorities. Determines the alignment that allocations should have on this platform. +### kSbMaxSystemPathCacheDirectorySize + +The maximum size the cache directory is allowed to use in bytes. + ### kSbMaxThreadLocalKeys The maximum number of thread local storage keys supported by this platform. This @@ -139,7 +148,3 @@ The string form of SB_PATH_SEP_CHAR. Specifies the preferred byte order of color channels in a pixel. Refer to starboard/configuration.h for the possible values. EGL/GLES platforms should generally prefer a byte order of RGBA, regardless of endianness. - -### kSbUserMaxSignedIn - -The maximum number of users that can be signed in at the same time. diff --git a/cobalt/site/docs/reference/starboard/modules/13/cpu_features.md b/cobalt/site/docs/reference/starboard/modules/16/cpu_features.md similarity index 99% rename from cobalt/site/docs/reference/starboard/modules/13/cpu_features.md rename to cobalt/site/docs/reference/starboard/modules/16/cpu_features.md index e2aa35f2bb1a..523089cd4c5d 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/cpu_features.md +++ b/cobalt/site/docs/reference/starboard/modules/16/cpu_features.md @@ -98,7 +98,7 @@ Book: /youtube/cobalt/_book.yaml SDIV and UDIV hardware division in ARM mode. * `bool has_aes` - ###### Arm 64 feature flags + ##### Arm 64 feature flags AES instructions. * `bool has_crc32` diff --git a/cobalt/site/docs/reference/starboard/modules/13/decode_target.md b/cobalt/site/docs/reference/starboard/modules/16/decode_target.md similarity index 84% rename from cobalt/site/docs/reference/starboard/modules/13/decode_target.md rename to cobalt/site/docs/reference/starboard/modules/16/decode_target.md index 2794d9ddfbe2..a354dda6ed01 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/decode_target.md +++ b/cobalt/site/docs/reference/starboard/modules/16/decode_target.md @@ -12,7 +12,7 @@ data. This allows the application to allocate fast graphics memory, and have decoding done directly into this memory, avoiding unnecessary memory copies, and also avoiding pushing data between CPU and GPU memory unnecessarily. -## SbDecodeTargetFormat +* SbDecodeTargetFormat SbDecodeTargets support several different formats that can be used to decode into and render from. Some formats may be easier to decode into, and others may @@ -21,7 +21,7 @@ the SbDecodeTargetFormat passed into it, or the decode will produce an error. Each decoder provides a way to check if a given SbDecodeTargetFormat is supported by that decoder. -## SbDecodeTargetGraphicsContextProvider +* SbDecodeTargetGraphicsContextProvider Some components may need to acquire SbDecodeTargets compatible with a certain rendering context, which may need to be created on a particular thread. The @@ -33,51 +33,7 @@ to run arbitrary code on the application's renderer thread with the renderer's EGLContext held current. This may be useful if your SbDecodeTarget creation code needs to execute GLES commands like, for example, glGenTextures(). -The primary usage is likely to be the the SbPlayer implementation on some -platforms. - -## SbDecodeTarget Example - -Let's say that we are an application and we would like to use the interface -defined in starboard/image.h to decode an imaginary "image/foo" image type. - -First, the application should enumerate which SbDecodeTargetFormats are -supported by that decoder. - -``` -SbDecodeTargetFormat kPreferredFormats[] = { - kSbDecodeTargetFormat3PlaneYUVI420, - kSbDecodeTargetFormat1PlaneRGBA, - kSbDecodeTargetFormat1PlaneBGRA, -}; - -SbDecodeTargetFormat format = kSbDecodeTargetFormatInvalid; -for (int i = 0; i < SB_ARRAY_SIZE_INT(kPreferredFormats); ++i) { - if (SbImageIsDecodeSupported("image/foo", kPreferredFormats[i])) { - format = kPreferredFormats[i]; - break; - } -} - -``` - -Now that the application has a format, it can create a decode target that it -will use to decode the .foo file into. Let's assume format is -kSbDecodeTargetFormat1PlaneRGBA, that we are on an EGL/GLES2 platform. Also, we -won't do any error checking, to keep things even simpler. - -``` -SbDecodeTarget target = SbImageDecode( - context_provider, encoded_foo_data, encoded_foo_data_size, - "image/foo", format); - -// If the decode works, you can get the texture out and render it. -SbDecodeTargetInfo info; -memset(&info, 0, sizeof(info)); -SbDecodeTargetGetInfo(target, &info); -GLuint texture = - info.planes[kSbDecodeTargetPlaneRGBA].texture; -``` +The primary usage is likely to be the SbPlayer implementation on some platforms. ## Macros @@ -117,14 +73,19 @@ premultiplied unless otherwise explicitly specified. A decoder target format consisting of 10bit Y, U, and V planes, in that order. Each pixel is stored in 16 bits. +* `kSbDecodeTargetFormat3Plane10BitYUVI420Compact` + + A decoder target format consisting of 10bit Y, U, and V planes, in that + order. The plane data is stored in a compact format. Every three 10-bit + pixels are packed into 32 bits. * `kSbDecodeTargetFormat1PlaneUYVY` A decoder target format consisting of a single plane with pixels laid out in the format UYVY. Since there are two Y values per sample, but only one U value and only one V value, horizontally the Y resolution is twice the size - of both the U and V resolutions. Vertically, they Y, U and V all have the - same resolution. This is a YUV 422 format. When using this format with GL - platforms, it is expected that the underlying texture will be set to the + of both the U and V resolutions. Vertically, the Y, U, and V planes all have + the same resolution. This is a YUV 422 format. When using this format with + GL platforms, it is expected that the underlying texture will be set to the GL_RGBA format, and the width of the texture will be equal to the number of UYVY tuples per row (e.g. the u/v width resolution). Content region left/right should be specified in u/v width resolution. @@ -202,8 +163,7 @@ information about the graphics context that will be used to render SbDecodeTargets. Some Starboard implementations may need to have references to some graphics objects when creating/destroying resources used by SbDecodeTarget. References to SbDecodeTargetGraphicsContextProvider objects should be provided -to all Starboard functions that might create SbDecodeTargets (e.g. -SbImageDecode()). +to all Starboard functions that might create SbDecodeTargets. #### Members @@ -211,12 +171,12 @@ SbImageDecode()). A reference to the EGLDisplay object that hosts the EGLContext that will be used to render any produced SbDecodeTargets. Note that it has the type - `void*` in order to avoid #including the EGL header files here. + `void*` in order to avoid including the EGL header files here. * `void * egl_context` The EGLContext object that will be used to render any produced SbDecodeTargets. Note that it has the type `void*` in order to avoid - #including the EGL header files here. + including the EGL header files here. * `SbDecodeTargetGlesContextRunner gles_context_runner` The `gles_context_runner` function pointer is passed in from the application @@ -259,7 +219,7 @@ This can be queried via calls to SbDecodeTargetGetInfo(). * `SbDecodeTargetInfoPlane planes` The image planes (e.g. kSbDecodeTargetPlaneRGBA, or {kSbDecodeTargetPlaneY, - kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV} associated with this decode + kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV}) associated with this decode target. ### SbDecodeTargetInfoContentRegion @@ -363,8 +323,7 @@ static bool SbDecodeTargetIsValid(SbDecodeTarget handle) Returns ownership of `decode_target` to the Starboard implementation. This function will likely result in the destruction of the SbDecodeTarget and all its associated surfaces, though in some cases, platforms may simply adjust a -reference count. In the case where SB_HAS(GLES2), this function must be called -on a thread with the context +reference count. This function must be called on a thread with the context. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/13/directory.md b/cobalt/site/docs/reference/starboard/modules/16/directory.md similarity index 80% rename from cobalt/site/docs/reference/starboard/modules/13/directory.md rename to cobalt/site/docs/reference/starboard/modules/16/directory.md index 6f845f6567a9..9d16dbc1aac3 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/directory.md +++ b/cobalt/site/docs/reference/starboard/modules/16/directory.md @@ -25,18 +25,6 @@ typedef struct SbDirectoryPrivate* SbDirectory ## Functions -### SbDirectoryCanOpen - -Indicates whether SbDirectoryOpen is allowed for the given `path`. - -`path`: The path to be checked. - -#### Declaration - -``` -bool SbDirectoryCanOpen(const char *path) -``` - ### SbDirectoryClose Closes an open directory stream handle. The return value indicates whether the @@ -50,20 +38,6 @@ directory was closed successfully. bool SbDirectoryClose(SbDirectory directory) ``` -### SbDirectoryCreate - -Creates the directory `path`, assuming the parent directory already exists. This -function returns `true` if the directory now exists (even if it existed before) -and returns `false` if the directory does not exist. - -`path`: The path to be created. - -#### Declaration - -``` -bool SbDirectoryCreate(const char *path) -``` - ### SbDirectoryGetNext Populates `out_entry` with the next entry in the specified directory stream, and diff --git a/cobalt/site/docs/reference/starboard/modules/13/drm.md b/cobalt/site/docs/reference/starboard/modules/16/drm.md similarity index 78% rename from cobalt/site/docs/reference/starboard/modules/13/drm.md rename to cobalt/site/docs/reference/starboard/modules/16/drm.md index f42e43bf3db7..7317fda307ff 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/drm.md +++ b/cobalt/site/docs/reference/starboard/modules/16/drm.md @@ -29,7 +29,7 @@ Encryption scheme of the input sample, as defined in ISO/IEC 23001 part 7. ### SbDrmKeyStatus -Status of a particular media key. [https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus](https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus) +Status of a particular media key. [https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus](https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus) #### Values @@ -67,8 +67,9 @@ The status of session related operations. Used by * `kSbDrmStatusQuotaExceededError` * `kSbDrmStatusUnknownError` - The following error can be used when the error status cannot be mapped to - one of the above errors. + The kSbDrmStatusUnknownError can be used when the error status cannot be + mapped to one of the rest errors. New error codes (if needed) should be + added before kSbDrmStatusUnknownError. ## Typedefs @@ -85,7 +86,7 @@ typedef void(* SbDrmServerCertificateUpdatedFunc) (SbDrmSystem drm_system, void ### SbDrmSessionClosedFunc -A callback for signalling that a session has been closed by the SbDrmSystem +A callback for signalling that a session has been closed by the SbDrmSystem. #### Definition @@ -96,8 +97,15 @@ typedef void(* SbDrmSessionClosedFunc) (SbDrmSystem drm_system, void *context, c ### SbDrmSessionKeyStatusesChangedFunc A callback for notifications that the status of one or more keys in a session -has been changed. All keys of the session and their new status will be passed -along. Any keys not in the list is considered as deleted. +has been changed. A pointer to an array of all keys `key_ids` of the session and +their new status will be passed along. Any keys not in the list are considered +as deleted. + +`number_of_keys` is the number of keys. + +`key_ids` is a pointer to an array of keys. + +`key_statuses` is a pointer of a vector contains the status of each key. #### Definition @@ -119,6 +127,7 @@ context that was passed into the call to SbDrmCreateSystem(). `error_message` may contain an optional error message when `status` isn't `kSbDrmStatusSuccess` to provide more details about the error. It may be NULL if `status` is `kSbDrmStatusSuccess` or if no error message can be provided. + `ticket` will be the same ticket that was passed to SbDrmGenerateSessionUpdateRequest() or `kSbDrmTicketInvalid` if the update request was generated by the DRM system. @@ -246,6 +255,50 @@ Clear any internal states/resources related to the specified `session_id`. void SbDrmCloseSession(SbDrmSystem drm_system, const void *session_id, int session_id_size) ``` +### SbDrmCreateSystem + +Creates a new DRM system that can be used when constructing an SbPlayer or an +SbDecoder. + +This function returns `kSbDrmSystemInvalid` if `key_system` is unsupported. + +Also see the documentation of SbDrmGenerateSessionUpdateRequest() and +SbDrmUpdateSession() for more details. + +`key_system`: The DRM key system to be created. The value should be in the form +of "com.example.somesystem". All letters in the value should be lowercase and +will be matched exactly with known DRM key systems of the platform. Note the key +system will be matched case sensitive. For more details, refer to [https://w3c.github.io/encrypted-media/#dfn-key-system-s](https://w3c.github.io/encrypted-media/#dfn-key-system-s) + +`context`: A value passed when any of this function's callback parameters are +called. + +`update_request_callback`: A function that is called every time after +SbDrmGenerateSessionUpdateRequest() is called. + +`session_updated_callback`: A function that is called every time after +SbDrmUpdateSession() is called. + +`key_statuses_changed_callback`: A function that can be called to indicate that +key statuses have changed. + +`server_certificate_updated_callback`: A function that is called to report +whether the server certificate has been successfully updated. It is called once +and only once. It is possible that the callback is called before the function +returns. + +`session_closed_callback`: A function that can be called to indicate that a +session has closed. If `NULL` is passed for any of the callbacks +(`update_request_callback`, `session_updated_callback`, +`key_statuses_changed_callback`, `server_certificate_updated_callback`, or +`session_closed_callback`), then `kSbDrmSystemInvalid` must be returned. + +#### Declaration + +``` +SbDrmSystem SbDrmCreateSystem(const char *key_system, void *context, SbDrmSessionUpdateRequestFunc update_request_callback, SbDrmSessionUpdatedFunc session_updated_callback, SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, SbDrmServerCertificateUpdatedFunc server_certificate_updated_callback, SbDrmSessionClosedFunc session_closed_callback) +``` + ### SbDrmDestroySystem Destroys `drm_system`, which implicitly removes all keys installed in it and @@ -292,9 +345,12 @@ establish ticket uniqueness, issuing multiple requests with the same ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must not be used. `type`: The case-sensitive type of the session update request payload. Must not -be NULL. `initialization_data`: The data for which the session update request -payload is created. Must not be NULL. `initialization_data_size`: The size of -the session update request payload. +be NULL. + +`initialization_data`: The data for which the session update request payload is +created. Must not be NULL. + +`initialization_data_size`: The size of the session update request payload. #### Declaration @@ -375,14 +431,18 @@ a previous call is called. Note that this function should only be called after `SbDrmIsServerCertificateUpdatable` is called first and returned true. `drm_system`: The DRM system whose server certificate is being updated. Must not -be `kSbDrmSystemInvalid`. `ticket`: The opaque ID that allows to distinguish -callbacks from multiple concurrent calls to SbDrmUpdateServerCertificate(), -which will be passed to `server_certificate_updated_callback` as-is. It is the -responsibility of the caller to establish ticket uniqueness, issuing multiple -requests with the same ticket may result in undefined behavior. The value -`kSbDrmTicketInvalid` must not be used. `certificate`: Pointer to the server -certificate data. Must not be NULL. `certificate_size`: Size of the server -certificate data. +be `kSbDrmSystemInvalid`. + +`ticket`: The opaque ID that allows to distinguish callbacks from multiple +concurrent calls to SbDrmUpdateServerCertificate(), which will be passed to +`server_certificate_updated_callback` as-is. It is the responsibility of the +caller to establish ticket uniqueness, issuing multiple requests with the same +ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must +not be used. + +`certificate`: Pointer to the server certificate data. Must not be NULL. + +`certificate_size`: Size of the server certificate data. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/13/egl.md b/cobalt/site/docs/reference/starboard/modules/16/egl.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/egl.md rename to cobalt/site/docs/reference/starboard/modules/16/egl.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/event.md b/cobalt/site/docs/reference/starboard/modules/16/event.md similarity index 95% rename from cobalt/site/docs/reference/starboard/modules/13/event.md rename to cobalt/site/docs/reference/starboard/modules/16/event.md index 256d418b45e0..25a7aabc2373 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/event.md +++ b/cobalt/site/docs/reference/starboard/modules/16/event.md @@ -236,16 +236,9 @@ the type of the value pointed to by that data argument, if any. triggered by the application have tickets passed in via SbWindowBlurOnScreenKeyboard. System-triggered events have ticket value kSbEventOnScreenKeyboardInvalidTicket. -* `kSbEventTypeOnScreenKeyboardSuggestionsUpdated` - - The platform has updated the on screen keyboard suggestions. This event is - triggered by the system or by the application's OnScreenKeyboard update - suggestions method. The event has int data representing a ticket. The ticket - is used by the application to mark individual calls to the update - suggestions method as successfully completed. Events triggered by the - application have tickets passed in via - SbWindowUpdateOnScreenKeyboardSuggestions. System-triggered events have - ticket value kSbEventOnScreenKeyboardInvalidTicket. +* `kSbEventTypeReserved1` + + Reserved for deprecated events. * `kSbEventTypeAccessibilityCaptionSettingsChanged` One or more of the fields returned by SbAccessibilityGetCaptionSettings has @@ -313,7 +306,7 @@ Structure representing a Starboard event and its data. #### Members * `SbEventType type` -* `SbTimeMonotonic timestamp` +* `int64_t timestamp` * `void * data` ### SbEventStartData @@ -372,7 +365,7 @@ just dispatch it over to another thread. #### Declaration ``` -SB_IMPORT void SbEventHandle(const SbEvent *event) +SB_EXPORT_PLATFORM void SbEventHandle(const SbEvent *event) ``` ### SbEventIsIdValid @@ -399,5 +392,16 @@ of microseconds to wait before calling the `callback` function. Set `delay` to #### Declaration ``` -SbEventId SbEventSchedule(SbEventCallback callback, void *context, SbTime delay) +SbEventId SbEventSchedule(SbEventCallback callback, void *context, int64_t delay) +``` + +### SbRunStarboardMain + +Serves as the entry point in the Starboard library for running the Starboard +event loop with the application event handler. + +#### Declaration + +``` +int SbRunStarboardMain(int argc, char **argv, SbEventHandleCallback callback) ``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/export.md b/cobalt/site/docs/reference/starboard/modules/16/export.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/export.md rename to cobalt/site/docs/reference/starboard/modules/16/export.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/file.md b/cobalt/site/docs/reference/starboard/modules/16/file.md similarity index 96% rename from cobalt/site/docs/reference/starboard/modules/13/file.md rename to cobalt/site/docs/reference/starboard/modules/16/file.md index 103af475ace1..f4acdaa2e812 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/file.md +++ b/cobalt/site/docs/reference/starboard/modules/16/file.md @@ -124,15 +124,15 @@ Used to hold information about a file. * `bool is_symbolic_link` Whether the file corresponds to a symbolic link. -* `SbTime last_modified` +* `int64_t last_modified` - The last modified time of a file. -* `SbTime last_accessed` + The last modified time of a file - microseconds since Windows epoch UTC. +* `int64_t last_accessed` - The last accessed time of a file. -* `SbTime creation_time` + The last accessed time of a file - microseconds since Windows epoch UTC. +* `int64_t creation_time` - The creation time of a file. + The creation time of a file - microseconds since Windows epoch UTC. ## Functions @@ -192,18 +192,6 @@ fails if the file in question is being held open. bool SbFileDelete(const char *path) ``` -### SbFileExists - -Indicates whether a file or directory exists at `path`. - -`path`: The absolute path of the file or directory being checked. - -#### Declaration - -``` -bool SbFileExists(const char *path) -``` - ### SbFileFlush Flushes the write buffer to `file`. Data written via SbFileWrite is not diff --git a/cobalt/site/docs/reference/starboard/modules/13/gles.md b/cobalt/site/docs/reference/starboard/modules/16/gles.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/gles.md rename to cobalt/site/docs/reference/starboard/modules/16/gles.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/input.md b/cobalt/site/docs/reference/starboard/modules/16/input.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/input.md rename to cobalt/site/docs/reference/starboard/modules/16/input.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/key.md b/cobalt/site/docs/reference/starboard/modules/16/key.md similarity index 99% rename from cobalt/site/docs/reference/starboard/modules/13/key.md rename to cobalt/site/docs/reference/starboard/modules/16/key.md index dd7712fd81bb..ed87e531f4fc 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/key.md +++ b/cobalt/site/docs/reference/starboard/modules/16/key.md @@ -196,6 +196,7 @@ virtual key codes documented at: [https://msdn.microsoft.com/en-us/library/windo * `kSbKeyGreen` * `kSbKeyYellow` * `kSbKeyBlue` +* `kSbKeyRecord` * `kSbKeyChannelUp` * `kSbKeyChannelDown` * `kSbKeySubtitle` diff --git a/cobalt/site/docs/reference/starboard/modules/13/log.md b/cobalt/site/docs/reference/starboard/modules/16/log.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/log.md rename to cobalt/site/docs/reference/starboard/modules/16/log.md diff --git a/cobalt/site/docs/reference/starboard/modules/13/media.md b/cobalt/site/docs/reference/starboard/modules/16/media.md similarity index 75% rename from cobalt/site/docs/reference/starboard/modules/13/media.md rename to cobalt/site/docs/reference/starboard/modules/16/media.md index acf95ee1ef9a..49186b116ac8 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/media.md +++ b/cobalt/site/docs/reference/starboard/modules/16/media.md @@ -30,6 +30,10 @@ Types of audio elementary streams that can be supported. * `kSbMediaAudioCodecEac3` * `kSbMediaAudioCodecOpus` * `kSbMediaAudioCodecVorbis` +* `kSbMediaAudioCodecMp3` +* `kSbMediaAudioCodecFlac` +* `kSbMediaAudioCodecPcm` +* `kSbMediaAudioCodecIamf` ### SbMediaAudioCodingType @@ -55,11 +59,20 @@ Possible audio connector types. #### Values -* `kSbMediaAudioConnectorNone` +* `kSbMediaAudioConnectorUnknown` * `kSbMediaAudioConnectorAnalog` * `kSbMediaAudioConnectorBluetooth` +* `kSbMediaAudioConnectorBuiltIn` * `kSbMediaAudioConnectorHdmi` -* `kSbMediaAudioConnectorNetwork` +* `kSbMediaAudioConnectorRemoteWired` + + A wired remote audio output, like a remote speaker via Ethernet. +* `kSbMediaAudioConnectorRemoteWireless` + + A wireless remote audio output, like a remote speaker via Wi-Fi. +* `kSbMediaAudioConnectorRemoteOther` + + A remote audio output cannot be classified into other existing types. * `kSbMediaAudioConnectorSpdif` * `kSbMediaAudioConnectorUsb` @@ -170,14 +183,11 @@ output. #### Members -* `int index` - - The platform-defined index of the associated audio output. * `SbMediaAudioConnector connector` - The type of audio connector. Will be the empty `kSbMediaAudioConnectorNone` - if this device cannot provide this information. -* `SbTime latency` + The type of audio connector. Will be `kSbMediaAudioConnectorUnknown` if this + device cannot provide this information. +* `int64_t latency` The expected latency of audio over this output, in microseconds, or `0` if this device cannot provide this information. @@ -192,13 +202,19 @@ output. ### SbMediaAudioSampleInfo -An audio sample info, which is a description of a given audio sample. This acts -as a set of instructions to the audio decoder. +The set of information required by the decoder or player for each audio sample. + +#### Members + +* `SbMediaAudioStreamInfo stream_info` -The audio sample info consists of information found in the `WAVEFORMATEX` -structure, as well as other information for the audio decoder, including the -Audio-specific configuration field. The `WAVEFORMATEX` structure is specified at -[http://msdn.microsoft.com/en-us/library/dd390970(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/dd390970(v=vs.85).aspx)x) . + The set of information of the video stream associated with this sample. +* `int64_t discarded_duration_from_front` +* `int64_t discarded_duration_from_back` + +### SbMediaAudioStreamInfo + +The set of information required by the decoder or player for each audio stream. #### Members @@ -210,21 +226,12 @@ Audio-specific configuration field. The `WAVEFORMATEX` structure is specified at The mime of the audio stream when `codec` isn't kSbMediaAudioCodecNone. It may point to an empty string if the mime is not available, and it can only be set to NULL when `codec` is kSbMediaAudioCodecNone. -* `uint16_t format_tag` - - The waveform-audio format type code. * `uint16_t number_of_channels` The number of audio channels in this format. `1` for mono, `2` for stereo. * `uint32_t samples_per_second` The sampling rate. -* `uint32_t average_bytes_per_second` - - The number of bytes per second expected with this format. -* `uint16_t block_alignment` - - Byte block alignment, e.g., 4. * `uint16_t bits_per_sample` The bit depth for the stream this represents, e.g. `8` or `16`. @@ -233,14 +240,13 @@ Audio-specific configuration field. The `WAVEFORMATEX` structure is specified at The size, in bytes, of the audio_specific_config. * `const void * audio_specific_config` - The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1: [http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF](http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF) + The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1. ### SbMediaColorMetadata HDR (High Dynamic Range) Metadata common for HDR10 and WebM/VP9-based HDR formats, together with the ColorSpace. HDR reproduces a greater dynamic range of -luminosity than is possible with standard digital imaging. See the Consumer -Electronics Association press release: [https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx](https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx) +luminosity than is possible with standard digital imaging. #### Members @@ -373,6 +379,20 @@ The set of information required by the decoder or player for each video sample. #### Members +* `SbMediaVideoStreamInfo stream_info` + + The set of information of the video stream associated with this sample. +* `bool is_key_frame` + + Indicates whether the associated sample is a key frame (I-frame). Avc video + key frames must always start with SPS and PPS NAL units. + +### SbMediaVideoStreamInfo + +The set of information required by the decoder or player for each video stream. + +#### Members + * `SbMediaVideoCodec codec` The video codec of this sample. @@ -393,10 +413,6 @@ The set of information required by the decoder or player for each video sample. second higher than 15 fps. When the maximums are unknown, this will be set to an empty string. It can only be set to NULL when `codec` is kSbMediaVideoCodecNone. -* `bool is_key_frame` - - Indicates whether the associated sample is a key frame (I-frame). Video key - frames must always start with SPS and PPS NAL units. * `int frame_width` The frame width of this sample, in pixels. Also could be parsed from the @@ -430,10 +446,12 @@ Note that neither `mime` nor `key_system` can be NULL. This function returns `mime`: The mime information of the media in the form of `video/webm` or `video/mp4; codecs="avc1.42001E"`. It may include arbitrary parameters like "codecs", "channels", etc. Note that the "codecs" parameter may contain more -than one codec, delimited by comma. `key_system`: A lowercase value in the form -of "com.example.somesystem" as suggested by [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system)) that can +than one codec, delimited by comma. + +`key_system`: A lowercase value in the form of "com.example.somesystem", and can be matched exactly with known DRM key systems of the platform. When `key_system` is an empty string, the return value is an indication for non-encrypted media. +For more detail, refer to [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system) An implementation may choose to support `key_system` with extra attributes, separated by ';', like `com.example.somesystem; attribute_name1="value1"; @@ -445,23 +463,21 @@ attributes, it has to support all attributes defined by the Starboard version the implementation uses. An implementation should ignore any unknown attributes, and make a decision solely based on the key system and the known attributes. For example, if an implementation supports "com.widevine.alpha", it should also -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when -`key_system` is `com.widevine.alpha; invalid_attribute="invalid_value"`. -Currently the only attribute has to be supported is `encryptionscheme`. It -reflects the value passed to `encryptionScheme` encryptionScheme of -MediaKeySystemMediaCapability, as defined in [https://wicg.github.io/encrypted-media-encryption-scheme/,](https://wicg.github.io/encrypted-media-encryption-scheme/,),) which can take value "cenc", "cbcs", or "cbcs-1-9". Empty string is -not a valid value for `encryptionscheme` and the implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when +return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; +invalid_attribute="invalid_value"`. Currently the only attribute has to be +supported is `encryptionscheme`. It reflects the value passed to +`encryptionScheme` of MediaKeySystemMediaCapability. It can take value "cenc", +"cbcs", or "cbcs-1-9". Empty string is not a valid value for `encryptionscheme` +and the implementation should return `kSbMediaSupportTypeNotSupported` when `encryptionscheme` is set to "". The implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported for unknown -values of known attributes. For example, if an implementation supports -"encryptionscheme" with value "cenc", "cbcs", or "cbcs-1-9", then it should -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when +`kSbMediaSupportTypeNotSupported` for unknown values of known attributes. For +example, if an implementation supports "encryptionscheme" with value "cenc", +"cbcs", or "cbcs-1-9", then it should return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; encryptionscheme="cenc"`, and return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when -`key_system` is `com.widevine.alpha; encryptionscheme="invalid"`. If an -implementation supports key system with attributes on one key system, it has to -support key system with attributes on all key systems supported. +`kSbMediaSupportTypeNotSupported` when `key_system` is `com.widevine.alpha; +encryptionscheme="invalid"`. If an implementation supports key system with +attributes on one key system, it has to support key system with attributes on +all key systems supported. For more detail, refer to [https://wicg.github.io/encrypted-media-encryption-scheme](https://wicg.github.io/encrypted-media-encryption-scheme) #### Declaration @@ -514,25 +530,15 @@ least stereo. int SbMediaGetAudioOutputCount() ``` -### SbMediaGetBufferAlignment - -The media buffer will be allocated using the returned alignment. Set this to a -larger value may increase the memory consumption of media buffers.`type`: the -media type of the stream (audio or video). - -#### Declaration - -``` -int SbMediaGetBufferAlignment(SbMediaType type) -``` - ### SbMediaGetBufferAllocationUnit -When the media stack needs more memory to store media buffers, it will allocate -extra memory in units returned by SbMediaGetBufferAllocationUnit. This can -return 0, in which case the media stack will allocate extra memory on demand. -When SbMediaGetInitialBufferCapacity and this function both return 0, the media -stack will allocate individual buffers directly using SbMemory functions. +The media buffer will be allocated using the returned alignment. Set this to a +larger value may increase the memory consumption of media buffers. When the +media stack needs more memory to store media buffers, it will allocate extra +memory in units returned by SbMediaGetBufferAllocationUnit. This can return 0, +in which case the media stack will allocate extra memory on demand. When +SbMediaGetInitialBufferCapacity and this function both return 0, the media stack +will allocate individual buffers directly using malloc functions. #### Declaration @@ -542,47 +548,31 @@ int SbMediaGetBufferAllocationUnit() ### SbMediaGetBufferGarbageCollectionDurationThreshold -Specifies the duration threshold of media source garbage collection. When the -accumulated duration in a source buffer exceeds this value, the media source -implementation will try to eject existing buffers from the cache. This is -usually triggered when the video being played has a simple content and the -encoded data is small. In such case this can limit how much is allocated for the -book keeping data of the media buffers and avoid OOM of system heap. This should -return 170 seconds for most of the platforms. But it can be further reduced on -systems with extremely low memory. +Specifies the duration threshold of media source garbage collection in +microseconds. When the accumulated duration in a source buffer exceeds this +value, the media source implementation will try to eject existing buffers from +the cache. This is usually triggered when the video being played has a simple +content and the encoded data is small. In such case this can limit how much is +allocated for the book keeping data of the media buffers and avoid OOM of system +heap. This should return 170 seconds for most of the platforms. But it can be +further reduced on systems with extremely low memory. #### Declaration ``` -SbTime SbMediaGetBufferGarbageCollectionDurationThreshold() +int64_t SbMediaGetBufferGarbageCollectionDurationThreshold() ``` ### SbMediaGetBufferPadding Extra bytes allocated at the end of a media buffer to ensure that the buffer can be use optimally by specific instructions like SIMD. Set to 0 to remove any -padding.`type`: the media type of the stream (audio or video). - -#### Declaration - -``` -int SbMediaGetBufferPadding(SbMediaType type) -``` - -### SbMediaGetBufferStorageType - -Returns SbMediaBufferStorageType of type `SbMediaStorageTypeMemory` or -`SbMediaStorageTypeFile`. For memory storage, the media buffers will be stored -in main memory allocated by SbMemory functions. For file storage, the media -buffers will be stored in a temporary file in the system cache folder acquired -by calling SbSystemGetPath() with "kSbSystemPathCacheDirectory". Note that when -its value is "file" the media stack will still allocate memory to cache the the -buffers in use. +padding. #### Declaration ``` -SbMediaBufferStorageType SbMediaGetBufferStorageType() +int SbMediaGetBufferPadding() ``` ### SbMediaGetInitialBufferCapacity @@ -608,10 +598,14 @@ allocation of media buffers may only fail when there is not enough memory in the system to fulfill the request, under which case the app will be terminated as under other OOM situations. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -626,10 +620,14 @@ resolution of such videos shouldn't go beyond 1080p. Its value should be less than the sum of SbMediaGetAudioBufferBudget and 'SbMediaGetVideoBufferBudget(..., 1920, 1080, ...) but not less than 8 MB. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -645,10 +643,14 @@ being used by video buffers but will also make app less likely to re-download video data. Note that the app may experience significant difficulty if this value is too low. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -676,28 +678,10 @@ bool SbMediaIsBufferPoolAllocateOnDemand() ### SbMediaIsBufferUsingMemoryPool If SbMediaGetBufferUsingMemoryPool returns true, it indicates that media buffer -pools should be allocated on demand, as opposed to using SbMemory* functions. +pools should be allocated on demand, as opposed to using malloc functions. #### Declaration ``` bool SbMediaIsBufferUsingMemoryPool() ``` - -### SbMediaSetAudioWriteDuration - -Communicate to the platform how far past `current_playback_position` the app -will write audio samples. The app will write all samples between -`current_playback_position` and `current_playback_position` + `duration`, as -soon as they are available. The app may sometimes write more samples than that, -but the app only guarantees to write `duration` past `current_playback_position` -in general. The platform is responsible for guaranteeing that when only -`duration` audio samples are written at a time, no playback issues occur (such -as transient or indefinite hanging). The platform may assume `duration` >= 0.5 -seconds. - -#### Declaration - -``` -void SbMediaSetAudioWriteDuration(SbTime duration) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/16/memory.md b/cobalt/site/docs/reference/starboard/modules/16/memory.md new file mode 100644 index 000000000000..65a36ff69f89 --- /dev/null +++ b/cobalt/site/docs/reference/starboard/modules/16/memory.md @@ -0,0 +1,45 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard Module Reference: `memory.h` + +Defines functions for memory allocation, alignment, copying, and comparing. + +## Porters + +All of the "Unchecked" and "Free" functions must be implemented, but they should +not be called directly. The Starboard platform wraps them with extra accounting +under certain circumstances. + +## Porters and Application Developers + +Nobody should call the "Checked", "Unchecked" or "Free" functions directly +because that evades Starboard's memory tracking. In both port implementations +and Starboard client application code, you should always call SbMemoryAllocate +and SbMemoryDeallocate rather than SbMemoryAllocateUnchecked and SbMemoryFree. + +* The "checked" functions are SbMemoryAllocateChecked(), + SbMemoryReallocateChecked(), and SbMemoryAllocateAlignedChecked(). + +* The "unchecked" functions are SbMemoryAllocateUnchecked(), + SbMemoryReallocateUnchecked(), and SbMemoryAllocateAlignedUnchecked(). + +* The "free" functions are SbMemoryFree() and SbMemoryFreeAligned(). + +## Enums + +### SbMemoryMapFlags + +The bitwise OR of these flags should be passed to SbMemoryMap to indicate how +the mapped memory can be used. + +#### Values + +* `kSbMemoryMapProtectReserved` + + No flags set: Reserves virtual address space. SbMemoryProtect() can later + make it accessible. +* `kSbMemoryMapProtectRead` +* `kSbMemoryMapProtectWrite` +* `kSbMemoryMapProtectExec` +* `kSbMemoryMapProtectReadWrite` diff --git a/cobalt/site/docs/reference/starboard/modules/13/microphone.md b/cobalt/site/docs/reference/starboard/modules/16/microphone.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/microphone.md rename to cobalt/site/docs/reference/starboard/modules/16/microphone.md diff --git a/cobalt/site/docs/reference/starboard/modules/16/player.md b/cobalt/site/docs/reference/starboard/modules/16/player.md new file mode 100644 index 000000000000..efbb73e3b2a4 --- /dev/null +++ b/cobalt/site/docs/reference/starboard/modules/16/player.md @@ -0,0 +1,737 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard Module Reference: `player.h` + +Defines an interface for controlling playback of media elementary streams. + +## Macros + +### SB_PLAYER_INITIAL_TICKET + +The value of the initial ticket held by the player before the first seek. The +player will use this ticket value to make the first call to SbPlayerStatusFunc +with kSbPlayerStateInitialized. + +### SB_PLAYER_NO_DURATION + +The value to pass into SbPlayerCreate's `duration_pts` argument for cases where +the duration is unknown, such as for live streams. + +### kSbPlayerInvalid + +Well-defined value for an invalid player. + +### kSbPlayerWriteDurationLocal + +The audio write duration when all the audio connectors are local. + +### kSbPlayerWriteDurationRemote + +The audio write duration when at least one of the audio connectors are remote. + +## Enums + +### SbPlayerDecoderState + +An indicator of whether the decoder can accept more samples. + +#### Values + +* `kSbPlayerDecoderStateNeedsData` + + The decoder is asking for one more sample. + +### SbPlayerSampleSideDataType + +Identify the type of side data accompanied with `SbPlayerSampleInfo`, as side +data may come from multiple sources. + +#### Values + +* `kMatroskaBlockAdditional` + + The side data comes from the BlockAdditional data in the Matroska/Webm + container. The first 8 bytes of the data contains the value of BlockAddID in + big endian format, followed by the content of BlockAdditional. See: + + [https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03](https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03) + + [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional) + +### SbPlayerState + +An indicator of the general playback state. + +#### Values + +* `kSbPlayerStateInitialized` + + The player has just been initialized. It is expecting an SbPlayerSeek() call + to enter the prerolling state. +* `kSbPlayerStatePrerolling` + + The player is prerolling, collecting enough data to fill the pipeline before + presentation starts. After the first preroll is completed, there should + always be a video frame to render, even if the player goes back to + Prerolling after a Seek. +* `kSbPlayerStatePresenting` + + The player is presenting media, and it is either paused or actively playing + in real-time. Note that the implementation should use this state to signal + that the preroll has been finished. +* `kSbPlayerStateEndOfStream` + + The player is presenting media, but it is paused at the end of the stream. +* `kSbPlayerStateDestroyed` + + The player has been destroyed, and will send no more callbacks. + +## Typedefs + +### SbPlayer + +An opaque handle to an implementation-private structure representing a player. + +#### Definition + +``` +typedef struct SbPlayerPrivate* SbPlayer +``` + +### SbPlayerDeallocateSampleFunc + +Callback to free the given sample buffer data. When more than one buffer are +sent in SbPlayerWriteSample(), the implementation only has to call this callback +with `sample_buffer` points to the first buffer. + +#### Definition + +``` +typedef void(* SbPlayerDeallocateSampleFunc) (SbPlayer player, void *context, const void *sample_buffer) +``` + +### SbPlayerDecoderStatusFunc + +Callback for decoder status updates, called in response to a call to +SbPlayerSeek() or SbPlayerWriteSample(). This callback will never be called +until at least one call to SbPlayerSeek has occurred. `ticket` will be set to +the ticket passed into the last received call to SbPlayerSeek() at the time this +callback was dispatched. This is to distinguish status callbacks for +interrupting seeks. These callbacks will happen on a different thread than the +calling thread, and it is not valid to call SbPlayer functions from within this +callback. After an update with kSbPlayerDecoderStateNeedsData, the user of the +player will make at most one call to SbPlayerWriteSample() or +SbPlayerWriteEndOfStream(). The player implementation should update the decoder +status again after such call to notify its user to continue writing more frames. + +#### Definition + +``` +typedef void(* SbPlayerDecoderStatusFunc) (SbPlayer player, void *context, SbMediaType type, SbPlayerDecoderState state, int ticket) +``` + +### SbPlayerErrorFunc + +Callback for player errors, that may set a `message`. + +`error`: indicates the error code. + +`message`: provides specific informative diagnostic message about the error +condition encountered. It is ok for the message to be an empty string or NULL if +no information is available. + +#### Definition + +``` +typedef void(* SbPlayerErrorFunc) (SbPlayer player, void *context, SbPlayerError error, const char *message) +``` + +### SbPlayerStatusFunc + +Callback for player status updates. These callbacks will happen on a different +thread than the calling thread, and it is not valid to call SbPlayer functions +from within this callback. + +#### Definition + +``` +typedef void(* SbPlayerStatusFunc) (SbPlayer player, void *context, SbPlayerState state, int ticket) +``` + +## Structs + +### SbPlayerCreationParam + +The playback related parameters to pass into SbPlayerCreate() and +SbPlayerGetPreferredOutputMode(). + +#### Members + +* `SbDrmSystem drm_system` + + Provides an appropriate DRM system if the media stream has encrypted + portions. It will be `kSbDrmSystemInvalid` if the stream does not have + encrypted portions. +* `SbMediaAudioStreamInfo audio_stream_info` + + Contains a populated SbMediaAudioStreamInfo if `audio_stream_info.codec` + isn't `kSbMediaAudioCodecNone`. When `audio_stream_info.codec` is + `kSbMediaAudioCodecNone`, the video doesn't have an audio track. +* `SbMediaVideoStreamInfo video_stream_info` + + Contains a populated SbMediaVideoStreamInfo if `video_stream_info.codec` + isn't `kSbMediaVideoCodecNone`. When `video_stream_info.codec` is + `kSbMediaVideoCodecNone`, the video is audio only. +* `SbPlayerOutputMode output_mode` + + Selects how the decoded video frames will be output. For example, + `kSbPlayerOutputModePunchOut` indicates that the decoded video frames will + be output to a background video layer by the platform, and + `kSbPlayerOutputDecodeToTexture` indicates that the decoded video frames + should be made available for the application to pull via calls to + SbPlayerGetCurrentFrame(). + +### SbPlayerInfo + +Information about the current media playback state. + +#### Members + +* `int64_t current_media_timestamp` + + The position of the playback head, as precisely as possible, in + microseconds. +* `int64_t duration` + + The known duration of the currently playing media stream, in microseconds. +* `int64_t start_date` + + The result of getStartDate for the currently playing media stream, in + microseconds since the epoch of January 1, 1601 UTC. +* `int frame_width` + + The width of the currently displayed frame, in pixels, or 0 if not provided + by this player. +* `int frame_height` + + The height of the currently displayed frame, in pixels, or 0 if not provided + by this player. +* `bool is_paused` + + Whether playback is currently paused. +* `double volume` + + The current player volume in [0, 1]. +* `int total_video_frames` + + The number of video frames sent to the player since the creation of the + player. +* `int dropped_video_frames` + + The number of video frames decoded but not displayed since the creation of + the player. +* `int corrupted_video_frames` + + The number of video frames that failed to be decoded since the creation of + the player. +* `double playback_rate` + + The rate of playback. The video is played back in a speed that is + proportional to this. By default it is 1.0 which indicates that the playback + is at normal speed. When it is greater than one, the video is played in a + faster than normal speed. When it is less than one, the video is played in a + slower than normal speed. Negative speeds are not supported. + +### SbPlayerSampleInfo + +Information about the samples to be written into SbPlayerWriteSamples(). + +#### Members + +* `SbMediaType type` +* `const void * buffer` + + Points to the buffer containing the sample data. +* `int buffer_size` + + Size of the data pointed to by `buffer`. +* `int64_t timestamp` + + The timestamp of the sample in microseconds since Windows epoch UTC. +* `SbPlayerSampleSideData* side_data` + + Points to an array of side data for the input, when available. +* `int side_data_count` + + The number of side data pointed by `side_data`. It should be set to 0 if + there is no side data for the input. +* `SbMediaAudioSampleInfo audio_sample_info` + + Information about an audio sample. This value can only be used when `type` + is kSbMediaTypeAudio. +* `SbMediaVideoSampleInfo video_sample_info` + + Information about a video sample. This value can only be used when `type` is + kSbMediaTypeVideo. +* `union SbPlayerSampleInfo::@0 @1` +* `constSbDrmSampleInfo* drm_info` + + The DRM system related info for the media sample. This value is required for + encrypted samples. Otherwise, it must be `NULL`. + +### SbPlayerSampleSideData + +Side data accompanied with `SbPlayerSampleInfo`, it can be arbitrary binary data +coming from multiple sources. + +#### Members + +* `SbPlayerSampleSideDataType type` +* `const uint8_t * data` + + `data` will remain valid until SbPlayerDeallocateSampleFunc() is called on + the `SbPlayerSampleInfo::buffer` the data is associated with. +* `size_t size` + + The size of the data pointed by `data`, in bytes. + +## Functions + +### SbPlayerCreate + +Creates a player that will be displayed on `window` for the specified +`video_codec` and `audio_codec`, acquiring all resources needed to operate it, +and returning an opaque handle to it. The expectation is that a new player will +be created and destroyed for every playback. + +This function returns the created player. Note the following: + +* The associated decoder of the returned player should be assumed to not be in + `kSbPlayerDecoderStateNeedsData` until SbPlayerSeek() has been called on it. + +* It is expected either that the thread that calls SbPlayerCreate is the same + thread that calls the other `SbPlayer` functions for that player, or that + there is a mutex guarding calls into each `SbPlayer` instance. + +* If there is a platform limitation on how many players can coexist + simultaneously, then calls made to this function that attempt to exceed that + limit must return `kSbPlayerInvalid`. Multiple calls to SbPlayerCreate must + not cause a crash. + +`window`: The window that will display the player. `window` can be +`kSbWindowInvalid` for platforms where video is only displayed on a particular +window that the underlying implementation already has access to. + +`video_codec`: The video codec used for the player. If `video_codec` is +`kSbMediaVideoCodecNone`, the player is an audio-only player. If `video_codec` +is any other value, the player is an audio/video decoder. This can be set to +`kSbMediaVideoCodecNone` to play a video with only an audio track. + +`audio_codec`: The audio codec used for the player. The caller must provide a +populated `audio_sample_info` if audio codec is `kSbMediaAudioCodecAac`. Can be +set to `kSbMediaAudioCodecNone` to play a video without any audio track. In such +case `audio_sample_info` must be NULL. + +`drm_system`: If the media stream has encrypted portions, then this parameter +provides an appropriate DRM system, created with `SbDrmCreateSystem()`. If the +stream does not have encrypted portions, then `drm_system` may be +`kSbDrmSystemInvalid`. + +`audio_sample_info`: Note that the caller must provide a populated +`audio_sample_info` if the audio codec is `kSbMediaAudioCodecAac`. Otherwise, +`audio_sample_info` can be NULL. See media.h for the format of the +`SbMediaAudioSampleInfo` struct. + +Note that `audio_specific_config` is a pointer and the content it points to is +no longer valid after this function returns. The implementation has to make a +copy of the content if it is needed after the function returns. + +`max_video_capabilities`: This string communicates the max video capabilities +required to the platform. The web app will not provide a video stream exceeding +the maximums described by this parameter. Allows the platform to optimize +playback pipeline for low quality video streams if it knows that it will never +adapt to higher quality streams. The string uses the same format as the string +passed in to SbMediaCanPlayMimeAndKeySystem(), for example, when it is set to +"width=1920; height=1080; framerate=15;", the video will never adapt to +resolution higher than 1920x1080 or frame per second higher than 15 fps. When +the maximums are unknown, this will be set to NULL. + +`sample_deallocator_func`: If not `NULL`, the player calls this function on an +internal thread to free the sample buffers passed into SbPlayerWriteSample(). + +`decoder_status_func`: If not `NULL`, the decoder calls this function on an +internal thread to provide an update on the decoder's status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_status_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the playback status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_error_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the error status. This callback is +responsible for setting the media error message. + +`context`: This is passed to all callbacks and is generally used to point at a +class or struct that contains state associated with the player. + +`output_mode`: Selects how the decoded video frames will be output. For example, +kSbPlayerOutputModePunchOut indicates that the decoded video frames will be +output to a background video layer by the platform, and +kSbPlayerOutputDecodeToTexture indicates that the decoded video frames should be +made available for the application to pull via calls to +SbPlayerGetCurrentFrame(). + +`provider`: Only present in Starboard version 3 and up. If not `NULL`, then when +output_mode == kSbPlayerOutputModeDecodeToTexture, the player MAY use the +provider to create SbDecodeTargets on the renderer thread. A provider may not +always be needed by the player, but if it is needed, and the provider is not +given, the player will fail by returning `kSbPlayerInvalid`. + +If `NULL` is passed to any of the callbacks (`sample_deallocator_func`, +`decoder_status_func`, `player_status_func`, or `player_error_func` if it +applies), then `kSbPlayerInvalid` must be returned. + +#### Declaration + +``` +SbPlayer SbPlayerCreate(SbWindow window, const SbPlayerCreationParam *creation_param, SbPlayerDeallocateSampleFunc sample_deallocate_func, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void *context, SbDecodeTargetGraphicsContextProvider *context_provider) +``` + +### SbPlayerDestroy + +Destroys `player`, freeing all associated resources. + +* Upon calling this method, there should be one call to the player status + callback (i.e. `player_status_func` used in the creation of the player) + which indicates the player is destroyed. Note, the callback has to be + inflight when SbPlayerDestroyed is called. + +* No more other callbacks should be issued after this function returns. + +* It is not allowed to pass `player` into any other `SbPlayer` function once + SbPlayerDestroy has been called on that player. + +`player`: The player to be destroyed. Must not be `kSbPlayerInvalid`. + +#### Declaration + +``` +void SbPlayerDestroy(SbPlayer player) +``` + +### SbPlayerGetAudioConfiguration + +Returns the audio configurations used by `player`. + +Returns true when `out_audio_configuration` is filled with the information of +the configuration of the audio output devices used by `player`. Returns false +for `index` 0 to indicate that there is no audio output for this `player`. +Returns false for `index` greater than 0 to indicate that there are no more +audio output configurations other than the ones already returned. + +The app will use the information returned to determine audio related behaviors, +like: + +* Audio Write Duration: Audio write duration is how far past the current + playback position the app will write audio samples. The app will write all + samples between `current_playback_position` and `current_playback_position` + + `audio_write_duration`, as soon as they are available. + +* `audio_write_duration` will be to `kSbPlayerWriteDurationLocal` when all + audio configurations linked to `player` is local, or if there isn't any + audio output. It will be set to `kSbPlayerWriteDurationRemote` for remote or + wireless audio outputs, i.e. one of `kSbMediaAudioConnectorBluetooth` or + `kSbMediaAudioConnectorRemote*`. + +* The app only guarantees to write `audio_write_duration` past + `current_playback_position`, but the app is free to write more samples than + that. So the platform shouldn't rely on this for flow control. The platform + should achieve flow control by sending `kSbPlayerDecoderStateNeedsData` less + frequently. + +* The platform is responsible for guaranteeing that when only + `audio_write_duration` audio samples are written at a time, no playback + issues occur (such as transient or indefinite hanging). + +The audio configurations should be available as soon as possible, and they have +to be available when the `player` is at `kSbPlayerStatePresenting`, unless the +audio codec is `kSbMediaAudioCodecNone` or there's no written audio inputs. + +The app will set `audio_write_duration` to `kSbPlayerWriteDurationLocal` when +the audio configuration isn't available (i.e. the function returns false when +index is 0). The platform has to make the audio configuration available +immediately after the SbPlayer is created, if it expects the app to treat the +platform as using wireless audio outputs. + +Once at least one audio configurations are returned, the return values and their +orders shouldn't change during the life time of `player`. The platform may +inform the app of any changes by sending `kSbPlayerErrorCapabilityChanged` to +request a playback restart. + +`player`: The player about which information is being retrieved. Must not be +`kSbPlayerInvalid`. + +`index`: The index of the audio output configuration. Must be greater than or +equal to 0. + +`out_audio_configuration`: The information about the audio output, refer to +`SbMediaAudioConfiguration` for more details. Must not be NULL. + +#### Declaration + +``` +bool SbPlayerGetAudioConfiguration(SbPlayer player, int index, SbMediaAudioConfiguration *out_audio_configuration) +``` + +### SbPlayerGetCurrentFrame + +Given a player created with the kSbPlayerOutputModeDecodeToTexture output mode, +it will return a SbDecodeTarget representing the current frame to be rasterized. +On GLES systems, this function must be called on a thread with an EGLContext +current, and specifically the EGLContext that will be used to eventually render +the frame. If this function is called with a `player` object that was created +with an output mode other than kSbPlayerOutputModeDecodeToTexture, +kSbDecodeTargetInvalid is returned. + +`player` must not be `kSbPlayerInvalid`. + +#### Declaration + +``` +SbDecodeTarget SbPlayerGetCurrentFrame(SbPlayer player) +``` + +### SbPlayerGetInfo + +Gets a snapshot of the current player state and writes it to `out_player_info`. +This function may be called very frequently and is expected to be inexpensive. + +`player`: The player about which information is being retrieved. Must not be +`kSbPlayerInvalid`. + +`out_player_info`: The information retrieved for the player. + +#### Declaration + +``` +void SbPlayerGetInfo(SbPlayer player, SbPlayerInfo *out_player_info) +``` + +### SbPlayerGetMaximumNumberOfSamplesPerWrite + +Returns the maximum number of samples that can be written in a single call to +SbPlayerWriteSamples(). Returning a value greater than one can improve +performance by allowing SbPlayerWriteSamples() to write multiple samples in one +call. + +Note that this feature is currently disabled in Cobalt where +SbPlayerWriteSamples() will always be called with one sample. + +`player`: The player for which the number is retrieved. + +`sample_type`: The type of sample for which the number is retrieved. See the +`SbMediaType` enum in media.h. + +#### Declaration + +``` +int SbPlayerGetMaximumNumberOfSamplesPerWrite(SbPlayer player, SbMediaType sample_type) +``` + +### SbPlayerGetPreferredOutputMode + +Returns the preferred output mode of the implementation when a video described +by `creation_param` is played. It is assumed that it is okay to call +SbPlayerCreate() with the same video described by `creation_param`, with its +`output_mode` member replaced by the returned output mode. When the caller has +no preference on the output mode, it will set `creation_param->output_mode` to +`kSbPlayerOutputModeInvalid`, and the implementation can return its preferred +output mode based on the information contained in `creation_param`. The caller +can also set `creation_param->output_mode` to its preferred output mode, and the +implementation should return the same output mode if it is supported, otherwise +the implementation should return an output mode that it is supported, as if +`creation_param->output_mode` is set to `kSbPlayerOutputModeInvalid` prior to +the call. Note that it is not the responsibility of this function to verify +whether the video described by `creation_param` can be played on the platform, +and the implementation should try its best effort to return a valid output mode. +`creation_param` must not be NULL. + +#### Declaration + +``` +SbPlayerOutputMode SbPlayerGetPreferredOutputMode(const SbPlayerCreationParam *creation_param) +``` + +### SbPlayerIsValid + +Returns whether the given player handle is valid. + +#### Declaration + +``` +static bool SbPlayerIsValid(SbPlayer player) +``` + +### SbPlayerSeek + +Tells the player to freeze playback (if playback has already started), reset or +flush the decoder pipeline, and go back to the Prerolling state. The player +should restart playback once it can display the frame at `seek_to_timestamp`, or +the closest it can get. (Some players can only seek to I-Frames, for example.) + +* Seek must be called before samples are sent when starting playback for the + first time, or the client never receives the + `kSbPlayerDecoderStateNeedsData` signal. + +* A call to seek may interrupt another seek. + +* After this function is called, the client should not send any more audio or + video samples until `SbPlayerDecoderStatusFunc` is called back with + `kSbPlayerDecoderStateNeedsData` for each required media type. + `SbPlayerDecoderStatusFunc` is the `decoder_status_func` callback function + that was specified when the player was created (SbPlayerCreate). + +`player`: The SbPlayer in which the seek operation is being performed. Must not +be `kSbPlayerInvalid`. + +`seek_to_timestamp`: The frame at which playback should begin. + +`ticket`: A user-supplied unique ID to be passed to all subsequent +`SbPlayerDecoderStatusFunc` calls. (That is the `decoder_status_func` callback +function specified when calling SbPlayerCreate.) + +The `ticket` value is used to filter calls that may have been in flight when +SbPlayerSeek was called. To be very specific, once SbPlayerSeek has been called +with ticket X, a client should ignore all `SbPlayerDecoderStatusFunc` calls that +do not pass in ticket X. + +#### Declaration + +``` +void SbPlayerSeek(SbPlayer player, int64_t seek_to_timestamp, int ticket) +``` + +### SbPlayerSetBounds + +Sets the player bounds to the given graphics plane coordinates. The changes do +not take effect until the next graphics frame buffer swap. The default bounds +for a player is the full screen. This function is only relevant when the +`player` is created with the kSbPlayerOutputModePunchOut output mode, and if +this is not the case then this function call can be ignored. + +This function is called on every graphics frame that changes the video bounds. +For example, if the video bounds are being animated, then this will be called at +up to 60 Hz. Since the function could be called up to once per frame, +implementors should take care to avoid related performance concerns with such +frequent calls. + +`player`: The player that is being resized. Must not be `kSbPlayerInvalid`. + +`z_index`: The z-index of the player. When the bounds of multiple players are +overlapped, the one with larger z-index will be rendered on top of the ones with +smaller z-index. + +`x`: The x-coordinate of the upper-left corner of the player. + +`y`: The y-coordinate of the upper-left corner of the player. + +`width`: The width of the player, in pixels. + +`height`: The height of the player, in pixels. + +#### Declaration + +``` +void SbPlayerSetBounds(SbPlayer player, int z_index, int x, int y, int width, int height) +``` + +### SbPlayerSetPlaybackRate + +Set the playback rate of the `player`. `rate` is default to 1.0 which indicates +the playback is at its original speed. A `rate` greater than one will make the +playback faster than its original speed. For example, when `rate` is 2, the +video will be played at twice the speed as its original speed. A `rate` less +than 1.0 will make the playback slower than its original speed. When `rate` is +0, the playback will be paused. The function returns true when the playback rate +is set to `playback_rate` or to a rate that is close to `playback_rate` which +the implementation supports. It returns false when the playback rate is +unchanged, this can happen when `playback_rate` is negative or if it is too high +to support. + +`player` must not be `kSbPlayerInvalid`. + +#### Declaration + +``` +bool SbPlayerSetPlaybackRate(SbPlayer player, double playback_rate) +``` + +### SbPlayerSetVolume + +Sets the player's volume. + +`player`: The player in which the volume is being adjusted. Must not be +`kSbPlayerInvalid`. + +`volume`: The new player volume. The value must be between `0.0` and `1.0`, +inclusive. A value of `0.0` means that the audio should be muted, and a value of +`1.0` means that it should be played at full volume. + +#### Declaration + +``` +void SbPlayerSetVolume(SbPlayer player, double volume) +``` + +### SbPlayerWriteEndOfStream + +Writes a marker to `player`'s input stream of `stream_type` indicating that +there are no more samples for that media type for the remainder of this media +stream. This marker is invalidated, along with the rest of the stream's +contents, after a call to SbPlayerSeek. + +`player`: The player to which the marker is written. + +`stream_type`: The type of stream for which the marker is written. + +#### Declaration + +``` +void SbPlayerWriteEndOfStream(SbPlayer player, SbMediaType stream_type) +``` + +### SbPlayerWriteSamples + +Writes samples of the given media type to `player`'s input stream. The lifetime +of `sample_infos`, and the members of its elements like `buffer`, +`video_sample_info`, and `drm_info` (as well as member `subsample_mapping` +contained inside it) are not guaranteed past the call to SbPlayerWriteSamples(). +That means that before returning, the implementation must synchronously copy any +information it wants to retain from those structures. + +SbPlayerWriteSamples() allows writing of multiple samples in one call. + +`player`: The player to which the sample is written. Must not be +`kSbPlayerInvalid`. + +`sample_type`: The type of sample being written. See the `SbMediaType` enum in +media.h. + +`sample_infos`: A pointer to an array of SbPlayerSampleInfo with +`number_of_sample_infos` elements, each holds the data for an sample, i.e. a +sequence of whole NAL Units for video, or a complete audio frame. `sample_infos` +cannot be assumed to live past the call into SbPlayerWriteSamples(), so it must +be copied if its content will be used after SbPlayerWriteSamples() returns. + +`number_of_sample_infos`: Specify the number of samples contained inside +`sample_infos`. It has to be at least one, and at most the return value of +SbPlayerGetMaximumNumberOfSamplesPerWrite(). + +#### Declaration + +``` +void SbPlayerWriteSamples(SbPlayer player, SbMediaType sample_type, const SbPlayerSampleInfo *sample_infos, int number_of_sample_infos) +``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/socket.md b/cobalt/site/docs/reference/starboard/modules/16/socket.md similarity index 98% rename from cobalt/site/docs/reference/starboard/modules/13/socket.md rename to cobalt/site/docs/reference/starboard/modules/16/socket.md index 744c04e3847d..beeab4fddb6e 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/socket.md +++ b/cobalt/site/docs/reference/starboard/modules/16/socket.md @@ -540,15 +540,15 @@ Sets the `SO_KEEPALIVE`, or equivalent, option to `value` on `socket`. The return value indicates whether the option was actually set. `socket`: The SbSocket for which the option is set. `value`: If set to `true`, -then `period` specifies the minimum time (SbTime) is always in microseconds) -between keep-alive packets. If set to `false`, `period` is ignored. `period`: -The time between keep-alive packets. This value is only relevant if `value` is -`true`. +then `period` specifies the minimum time in microseconds between keep-alive +packets. If set to `false`, `period` is ignored. `period`: The time in +microseconds between keep-alive packets. This value is only relevant if `value` +is `true`. #### Declaration ``` -bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, SbTime period) +bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, int64_t period) ``` ### SbSocketSetTcpNoDelay diff --git a/cobalt/site/docs/reference/starboard/modules/13/socket_waiter.md b/cobalt/site/docs/reference/starboard/modules/16/socket_waiter.md similarity index 95% rename from cobalt/site/docs/reference/starboard/modules/13/socket_waiter.md rename to cobalt/site/docs/reference/starboard/modules/16/socket_waiter.md index f1c6bd8b9f2f..8632f88a5f12 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/socket_waiter.md +++ b/cobalt/site/docs/reference/starboard/modules/16/socket_waiter.md @@ -202,15 +202,15 @@ SbSocketWaiterWakeUp() it not called by that time. The return value indicates the reason that the socket waiter exited. This function should only be called on the thread that waits on this waiter. -`duration`: The minimum amount of time after which the socket waiter should exit -if it is not woken up before then. As with SbThreadSleep() (see thread.h), this -function may wait longer than `duration`, such as if the timeout expires while a -callback is being fired. +`duration`: The minimum amount of time in microseconds after which the socket +waiter should exit if it is not woken up before then. As with SbThreadSleep() +(see thread.h), this function may wait longer than `duration`, such as if the +timeout expires while a callback is being fired. #### Declaration ``` -SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, SbTime duration) +SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, int64_t duration) ``` ### SbSocketWaiterWakeUp diff --git a/cobalt/site/docs/reference/starboard/modules/13/speech_synthesis.md b/cobalt/site/docs/reference/starboard/modules/16/speech_synthesis.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/speech_synthesis.md rename to cobalt/site/docs/reference/starboard/modules/16/speech_synthesis.md diff --git a/cobalt/site/docs/reference/starboard/modules/16/storage.md b/cobalt/site/docs/reference/starboard/modules/16/storage.md new file mode 100644 index 000000000000..f648057c6096 --- /dev/null +++ b/cobalt/site/docs/reference/starboard/modules/16/storage.md @@ -0,0 +1,155 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard Module Reference: `storage.h` + +Defines a Storage API. This is a simple, all-at-once BLOB storage and retrieval +API that is intended for robust long-term storage. Some platforms have different +mechanisms for this kind of storage, so this API exists to allow a client +application to access this kind of storage. + +Note that there can be only one storage record and, thus, a maximum of one open +storage record can exist. Attempting to open a second record will result in +undefined behavior. + +These APIs are NOT expected to be thread-safe, so either call them from a single +thread, or perform proper synchronization around all calls. + +## Macros + +### kSbStorageInvalidRecord + +Well-defined value for an invalid storage record handle. + +## Typedefs + +### SbStorageRecord + +A handle to an open storage record. + +#### Definition + +``` +typedef SbStorageRecordPrivate* SbStorageRecord +``` + +## Functions + +### SbStorageCloseRecord + +Closes `record`, synchronously ensuring that all written data is flushed. This +function performs blocking I/O on the calling thread. + +The return value indicates whether the operation succeeded. Storage writes +should be as atomic as possible, so the record should either be fully written or +deleted (or, even better, untouched). + +`record`: The storage record to close. `record` is invalid after this point, and +subsequent calls referring to `record` will fail. + +#### Declaration + +``` +bool SbStorageCloseRecord(SbStorageRecord record) +``` + +### SbStorageDeleteRecord + +Deletes the `SbStorageRecord` named `name`. The return value indicates whether +the record existed and was successfully deleted. If the record did not exist or +could not be deleted, the function returns `false`. + +If `name` is NULL, deletes the default storage record, like what would have been +deleted with the previous version of SbStorageDeleteRecord. + +This function must not be called while the storage record is open. This function +performs blocking I/O on the calling thread. + +`name`: The filesystem-safe name of the record to open. + +#### Declaration + +``` +bool SbStorageDeleteRecord(const char *name) +``` + +### SbStorageGetRecordSize + +Returns the size of `record`, or `-1` if there is an error. This function +performs blocking I/O on the calling thread. + +`record`: The record to retrieve the size of. + +#### Declaration + +``` +int64_t SbStorageGetRecordSize(SbStorageRecord record) +``` + +### SbStorageIsValidRecord + +Returns whether the given storage record handle is valid. + +#### Declaration + +``` +static bool SbStorageIsValidRecord(SbStorageRecord record) +``` + +### SbStorageOpenRecord + +Opens and returns the SbStorageRecord named `name`, blocking I/O on the calling +thread until the open is completed. Will return an `SbStorageRecord` of size +zero if the record does not yet exist. Opening an already-open `SbStorageRecord` +has undefined behavior. + +If `name` is NULL, opens the default storage record, like what would have been +saved with the previous version of SbStorageOpenRecord. + +`name`: The filesystem-safe name of the record to open. + +#### Declaration + +``` +SbStorageRecord SbStorageOpenRecord(const char *name) +``` + +### SbStorageReadRecord + +Reads up to `data_size` bytes from `record`, starting at the beginning of the +record. The function returns the actual number of bytes read, which must be <= +`data_size`. The function returns `-1` in the event of an error. This function +makes a best-effort to read the entire record, and it performs blocking I/O on +the calling thread until the entire record is read or an error is encountered. + +`record`: The record to be read. `out_data`: The data read from the record. +`data_size`: The amount of data, in bytes, to read. + +#### Declaration + +``` +int64_t SbStorageReadRecord(SbStorageRecord record, char *out_data, int64_t data_size) +``` + +### SbStorageWriteRecord + +Replaces the data in `record` with `data_size` bytes from `data`. This function +always deletes any previous data in that record. The return value indicates +whether the write succeeded. This function makes a best-effort to write the +entire record, and it may perform blocking I/O on the calling thread until the +entire record is written or an error is encountered. + +While `SbStorageWriteRecord()` may defer the persistence, +`SbStorageReadRecord()` is expected to work as expected immediately afterwards, +even without a call to `SbStorageCloseRecord()`. The data should be persisted +after a short time, even if there is an unexpected process termination before +`SbStorageCloseRecord()` is called. + +`record`: The record to be written to. `data`: The data to write to the record. +`data_size`: The amount of `data`, in bytes, to write to the record. + +#### Declaration + +``` +bool SbStorageWriteRecord(SbStorageRecord record, const char *data, int64_t data_size) +``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/system.md b/cobalt/site/docs/reference/starboard/modules/16/system.md similarity index 93% rename from cobalt/site/docs/reference/starboard/modules/13/system.md rename to cobalt/site/docs/reference/starboard/modules/16/system.md index d3052d1ccde1..86437a3d0804 100644 --- a/cobalt/site/docs/reference/starboard/modules/13/system.md +++ b/cobalt/site/docs/reference/starboard/modules/16/system.md @@ -26,56 +26,6 @@ behavior of other APIs within the bounds of their operating range. only if) a system has this capability will SbSystemGetTotalGPUMemory() and SbSystemGetUsedGPUMemory() be valid to call. -### SbSystemConnectionType - -Enumeration of network connection types. - -#### Values - -* `kSbSystemConnectionTypeWired` - - The system is on a wired connection. -* `kSbSystemConnectionTypeWireless` - - The system is on a wireless connection. -* `kSbSystemConnectionTypeUnknown` - - The system connection type is unknown. - -### SbSystemDeviceType - -Enumeration of device types. - -#### Values - -* `kSbSystemDeviceTypeBlueRayDiskPlayer` - - Blue-ray Disc Player (BDP). -* `kSbSystemDeviceTypeGameConsole` - - A relatively high-powered TV device used primarily for playing games. -* `kSbSystemDeviceTypeOverTheTopBox` - - Over the top (OTT) devices stream content via the Internet over another type - of network, e.g. cable or satellite. -* `kSbSystemDeviceTypeSetTopBox` - - Set top boxes (STBs) stream content primarily over cable or satellite. Some - STBs can also stream OTT content via the Internet. -* `kSbSystemDeviceTypeTV` - - A Smart TV is a TV that can directly run applications that stream OTT - content via the Internet. -* `kSbSystemDeviceTypeDesktopPC` - - Desktop PC. -* `kSbSystemDeviceTypeAndroidTV` - - An Android TV Device. -* `kSbSystemDeviceTypeUnknown` - - Unknown device. - ### SbSystemPathId Enumeration of special paths that the platform can define. @@ -106,9 +56,6 @@ Enumeration of special paths that the platform can define. * `kSbSystemPathTempDirectory` Path to a directory where temporary files can be written. -* `kSbSystemPathTestOutputDirectory` - - Path to a directory where test results can be written. * `kSbSystemPathExecutableFile` Full path to the executable file. @@ -195,6 +142,19 @@ string generation. * `kSbSystemPropertyUserAgentAuxField` A field that, if available, is appended to the user agent +* `kSbSystemPropertyAdvertisingId` + + Advertising ID or IFA, typically a 128-bit UUID Please see [https://iabtechlab.com/OTT-IFA](https://iabtechlab.com/OTT-IFA) for + details. Corresponds to 'ifa' field. Note: `ifa_type` ifa_type field is not + provided. +* `kSbSystemPropertyLimitAdTracking` + + Limit advertising tracking, treated as boolean. Set to nonzero to indicate a + true value. Corresponds to 'lmt' field. +* `kSbSystemPropertyDeviceType` + + Type of the device, e.g. such as "TV", "STB", "OTT" Please see Youtube + Technical requirements for a full list of allowed values ## Typedefs @@ -264,26 +224,6 @@ Clears the last error set by a Starboard call in the current thread. void SbSystemClearLastError() ``` -### SbSystemGetConnectionType - -Returns the device's current network connection type. - -#### Declaration - -``` -SbSystemConnectionType SbSystemGetConnectionType() -``` - -### SbSystemGetDeviceType - -Returns the type of the device. - -#### Declaration - -``` -SbSystemDeviceType SbSystemGetDeviceType() -``` - ### SbSystemGetErrorString Generates a human-readable string for an error. The return value specifies the diff --git a/cobalt/site/docs/reference/starboard/modules/16/thread.md b/cobalt/site/docs/reference/starboard/modules/16/thread.md new file mode 100644 index 000000000000..7ee1406d63c0 --- /dev/null +++ b/cobalt/site/docs/reference/starboard/modules/16/thread.md @@ -0,0 +1,249 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard Module Reference: `thread.h` + +Defines functionality related to thread creation and cleanup. + +## Macros + +### kSbThreadContextInvalid + +Well-defined value for an invalid thread context. + +### kSbThreadInvalidId + +Well-defined constant value to mean "no thread ID." + +### kSbThreadSamplerInvalid + +Well-defined value for an invalid thread sampler. + +## Enums + +### SbThreadPriority + +A spectrum of thread priorities. Platforms map them appropriately to their own +priority system. Note that scheduling is platform-specific, and what these +priorities mean, if they mean anything at all, is also platform-specific. + +In particular, several of these priority values can map to the same priority on +a given platform. The only guarantee is that each lower priority should be +treated less-than-or-equal-to a higher priority. + +#### Values + +* `kSbThreadPriorityLowest` + + The lowest thread priority available on the current platform. +* `kSbThreadPriorityLow` + + A lower-than-normal thread priority, if available on the current platform. +* `kSbThreadPriorityNormal` + + Really, what is normal? You should spend time pondering that question more + than you consider less-important things, but less than you think about more- + important things. +* `kSbThreadPriorityHigh` + + A higher-than-normal thread priority, if available on the current platform. +* `kSbThreadPriorityHighest` + + The highest thread priority available on the current platform that isn't + considered "real-time" or "time-critical," if those terms have any meaning + on the current platform. +* `kSbThreadPriorityRealTime` + + If the platform provides any kind of real-time or time-critical scheduling, + this priority will request that treatment. Real-time scheduling generally + means that the thread will have more consistency in scheduling than non- + real-time scheduled threads, often by being more deterministic in how + threads run in relation to each other. But exactly how being real-time + affects the thread scheduling is platform-specific. + + For platforms where that is not offered, or otherwise not meaningful, this + will just be the highest priority available in the platform's scheme, which + may be the same as kSbThreadPriorityHighest. +* `kSbThreadNoPriority` + + Well-defined constant value to mean "no priority." This means to use the + default priority assignment method of that platform. This may mean to + inherit the priority of the spawning thread, or it may mean a specific + default priority, or it may mean something else, depending on the platform. + +## Typedefs + +### SbThreadContext + +A handle to the context of a frozen thread. + +#### Definition + +``` +typedef SbThreadContextPrivate* SbThreadContext +``` + +### SbThreadId + +An ID type that is unique per thread. + +#### Definition + +``` +typedef int32_t SbThreadId +``` + +### SbThreadSampler + +A handle to a thread sampler. + +#### Definition + +``` +typedef SbThreadSamplerPrivate* SbThreadSampler +``` + +## Functions + +### SbThreadContextGetPointer + +Gets the specified pointer-type `property` from the specified `context`. Returns +`true` if successful and `out_value` has been modified, otherwise returns +`false` and `out_value` is not modified. + +#### Declaration + +``` +bool SbThreadContextGetPointer(SbThreadContext context, SbThreadContextProperty property, void **out_value) +``` + +### SbThreadContextIsValid + +Returns whether the given thread context is valid. + +#### Declaration + +``` +static bool SbThreadContextIsValid(SbThreadContext context) +``` + +### SbThreadGetId + +Returns the Thread ID of the currently executing thread. + +#### Declaration + +``` +SbThreadId SbThreadGetId() +``` + +### SbThreadGetPriority + +Get the thread priority of the current thread. + +#### Declaration + +``` +bool SbThreadGetPriority(SbThreadPriority *priority) +``` + +### SbThreadIsValidId + +Returns whether the given thread ID is valid. + +#### Declaration + +``` +static bool SbThreadIsValidId(SbThreadId id) +``` + +### SbThreadIsValidPriority + +Returns whether the given thread priority is valid. + +#### Declaration + +``` +static bool SbThreadIsValidPriority(SbThreadPriority priority) +``` + +### SbThreadSamplerCreate + +Creates a new thread sampler for the specified `thread`. + +If successful, this function returns the newly created handle. If unsuccessful, +this function returns `kSbThreadSamplerInvalid`. + +#### Declaration + +``` +SbThreadSampler SbThreadSamplerCreate(pthread_t thread) +``` + +### SbThreadSamplerDestroy + +Destroys the `sampler` and frees whatever resources it was using. + +#### Declaration + +``` +void SbThreadSamplerDestroy(SbThreadSampler sampler) +``` + +### SbThreadSamplerFreeze + +Suspends execution of the thread that `sampler` was created for. + +If successful, this function returns a `SbThreadContext` for the frozen thread, +from which properties may be read while the thread remains frozen. If +unsuccessful, this function returns `kSbThreadContextInvalid`. + +#### Declaration + +``` +SbThreadContext SbThreadSamplerFreeze(SbThreadSampler sampler) +``` + +### SbThreadSamplerIsSupported + +Whether the current platform supports thread sampling. The result of this +function must not change over the course of the program, which means that the +results of this function may be cached indefinitely. If this returns false, +`SbThreadSamplerCreate` will return an invalid sampler. + +#### Declaration + +``` +bool SbThreadSamplerIsSupported() +``` + +### SbThreadSamplerIsValid + +Returns whether the given thread sampler is valid. + +#### Declaration + +``` +static bool SbThreadSamplerIsValid(SbThreadSampler sampler) +``` + +### SbThreadSamplerThaw + +Resumes execution of the thread that `sampler` was created for. This invalidates +the context returned from `SbThreadSamplerFreeze`. + +#### Declaration + +``` +bool SbThreadSamplerThaw(SbThreadSampler sampler) +``` + +### SbThreadSetPriority + +Set the thread priority of the current thread. + +#### Declaration + +``` +bool SbThreadSetPriority(SbThreadPriority priority) +``` diff --git a/cobalt/site/docs/reference/starboard/modules/16/time_zone.md b/cobalt/site/docs/reference/starboard/modules/16/time_zone.md new file mode 100644 index 000000000000..baad3759ac4b --- /dev/null +++ b/cobalt/site/docs/reference/starboard/modules/16/time_zone.md @@ -0,0 +1,47 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard Module Reference: `time_zone.h` + +Provides access to the system time zone information. + +## Typedefs + +### SbTimeZone + +The number of minutes west of the Greenwich Prime Meridian, NOT including +Daylight Savings Time adjustments. + +For example: America/Los_Angeles is 480 minutes (28800 seconds, 8 hours). + +#### Definition + +``` +typedef int SbTimeZone +``` + +## Functions + +### SbTimeZoneGetCurrent + +Gets the system's current SbTimeZone in minutes. + +#### Declaration + +``` +SbTimeZone SbTimeZoneGetCurrent() +``` + +### SbTimeZoneGetName + +Gets a string representation of the current timezone. The format should be in +the IANA format [https://data.iana.org/time-zones/theory.html#naming](https://data.iana.org/time-zones/theory.html#naming)) . +Names normally have the form AREA/LOCATION, where AREA is a continent or ocean, +and LOCATION is a specific location within the area. Typical names are +'Africa/Cairo', 'America/New_York', and 'Pacific/Honolulu'. + +#### Declaration + +``` +const char* SbTimeZoneGetName() +``` diff --git a/cobalt/site/docs/reference/starboard/modules/13/types.md b/cobalt/site/docs/reference/starboard/modules/16/types.md similarity index 100% rename from cobalt/site/docs/reference/starboard/modules/13/types.md rename to cobalt/site/docs/reference/starboard/modules/16/types.md diff --git a/cobalt/site/docs/reference/starboard/modules/16/window.md b/cobalt/site/docs/reference/starboard/modules/16/window.md new file mode 100644 index 000000000000..d652524e40f8 --- /dev/null +++ b/cobalt/site/docs/reference/starboard/modules/16/window.md @@ -0,0 +1,183 @@ +Project: /youtube/cobalt/_project.yaml +Book: /youtube/cobalt/_book.yaml + +# Starboard Module Reference: `window.h` + +Provides functionality to handle Window creation and management. + +## Macros + +### kSbWindowInvalid + +Well-defined value for an invalid window handle. + +## Typedefs + +### SbWindow + +A handle to a window. + +#### Definition + +``` +typedef SbWindowPrivate* SbWindow +``` + +## Structs + +### SbWindowOptions + +Options that can be requested at window creation time. + +#### Members + +* `SbWindowSize size` + + The requested size of the new window. The value of `video_pixel_ratio` will + not be used or looked at. +* `bool windowed` + + Whether the new window should be windowed or not. If not, the requested size + is really the requested resolution. +* `const char * name` + + The name of the window to create. + +### SbWindowSize + +The size of a window in graphics rendering coordinates. The width and height of +a window should correspond to the size of the graphics surface used for drawing +that would be created to back that window. + +#### Members + +* `int width` + + The width of the window in graphics pixels. +* `int height` + + The height of the window in graphics pixels. +* `float video_pixel_ratio` + + The ratio of video pixels to graphics pixels. This ratio must be applied + equally to width and height, meaning the aspect ratio is maintained. + + A value of 1.0f means the video resolution is the same as the graphics + resolution. This is the most common case. + + Values greater than 1.0f mean that the video resolution is higher (denser, + larger) than the graphics resolution. This is a common case as devices often + have more video decoding capabilities than graphics rendering capabilities + (or memory, etc...). + + Values less than 1.0f mean that the maximum video resolution is smaller than + the graphics resolution. + + A value of 0.0f means the ratio could not be determined, it should be + assumed to be the same as the graphics resolution (i.e. 1.0f). + +## Functions + +### SbWindowCreate + +Creates and returns a new system window with the given `options`, which may be +`NULL`. The function returns `kSbWindowInvalid` if it cannot create the +requested `SbWindow` due to policy, unsatisfiable options, or any other reason. + +If `options` are not specified, this function uses all defaults, which must work +on every platform. In general, it defaults to creating a fullscreen window at +the highest 16:9 resolution possible. If the platform does not support +fullscreen windows, then it creates a normal, windowed window. + +Some devices are fullscreen-only, including many production targets for +Starboard. In those cases, only one SbWindow may be created, and it must be +fullscreen. Additionally, in those cases, the requested size will actually be +the requested resolution. + +An SbWindow must be created to receive window-based events, like input events, +even on fullscreen-only devices. These events are dispatched to the Starboard +entry point. + +`options`: Options that specify parameters for the window being created. + +#### Declaration + +``` +SbWindow SbWindowCreate(const SbWindowOptions *options) +``` + +### SbWindowDestroy + +Destroys `window`, reclaiming associated resources. + +`window`: The `SbWindow` to destroy. + +#### Declaration + +``` +bool SbWindowDestroy(SbWindow window) +``` + +### SbWindowGetDiagonalSizeInInches + +Gets the size of the diagonal between two opposing screen corners. + +A return value of 0 means that starboard does not know what the screen diagonal +is. + +#### Declaration + +``` +float SbWindowGetDiagonalSizeInInches(SbWindow window) +``` + +### SbWindowGetPlatformHandle + +Gets the platform-specific handle for `window`, which can be passed as an +EGLNativeWindowType to initialize EGL/GLES. This return value is entirely +platform-specific, so there are no constraints about expected ranges. + +`window`: The SbWindow to retrieve the platform handle for. + +#### Declaration + +``` +void* SbWindowGetPlatformHandle(SbWindow window) +``` + +### SbWindowGetSize + +Retrieves the dimensions of `window` and sets `size` accordingly. This function +returns `true` if it completes successfully. If the function returns `false`, +then `size` will not have been modified. + +`window`: The SbWindow to retrieve the size of. `size`: The retrieved size. + +#### Declaration + +``` +bool SbWindowGetSize(SbWindow window, SbWindowSize *size) +``` + +### SbWindowIsValid + +Returns whether the given window handle is valid. + +#### Declaration + +``` +static bool SbWindowIsValid(SbWindow window) +``` + +### SbWindowSetDefaultOptions + +Sets the default options for system windows. + +`options`: The option values to use as default values. This object must not be +`NULL`. + +#### Declaration + +``` +void SbWindowSetDefaultOptions(SbWindowOptions *options) +``` diff --git a/cobalt/site/docs/reference/starboard/modules/byte_swap.md b/cobalt/site/docs/reference/starboard/modules/byte_swap.md deleted file mode 100644 index 72dc9327ed1e..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/byte_swap.md +++ /dev/null @@ -1,75 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `byte_swap.h` - -Specifies functions for swapping byte order. These functions are used to deal -with endianness when performing I/O. - -## Functions - -### SbByteSwapS16 - -Unconditionally swaps the byte order in signed 16-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -int16_t SbByteSwapS16(int16_t value) -``` - -### SbByteSwapS32 - -Unconditionally swaps the byte order in signed 32-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -int32_t SbByteSwapS32(int32_t value) -``` - -### SbByteSwapS64 - -Unconditionally swaps the byte order in signed 64-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -int64_t SbByteSwapS64(int64_t value) -``` - -### SbByteSwapU16 - -Unconditionally swaps the byte order in unsigned 16-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -uint16_t SbByteSwapU16(uint16_t value) -``` - -### SbByteSwapU32 - -Unconditionally swaps the byte order in unsigned 32-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -uint32_t SbByteSwapU32(uint32_t value) -``` - -### SbByteSwapU64 - -Unconditionally swaps the byte order in unsigned 64-bit `value`. `value`: The -value for which the byte order will be swapped. - -#### Declaration - -``` -uint64_t SbByteSwapU64(uint64_t value) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/condition_variable.md b/cobalt/site/docs/reference/starboard/modules/condition_variable.md deleted file mode 100644 index 2d8f30b5fdce..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/condition_variable.md +++ /dev/null @@ -1,140 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `condition_variable.h` - -Defines an interface for condition variables. - -## Macros - -### SB_CONDITION_VARIABLE_MAX_SIZE - -Max size of the SbConditionVariable type. - -## Enums - -### SbConditionVariableResult - -Enumeration of possible results from waiting on a condvar. - -#### Values - -* `kSbConditionVariableSignaled` - - The wait completed because the condition variable was signaled. -* `kSbConditionVariableTimedOut` - - The wait completed because it timed out, and was not signaled. -* `kSbConditionVariableFailed` - - The wait failed, either because a parameter wasn't valid, or the condition - variable has already been destroyed, or something similar. - -## Typedefs - -### SbConditionVariable - -An opaque handle to a condition variable type with reserved memory buffer of -size SB_CONDITION_VARIABLE_MAX_SIZE and aligned at void pointer type. - -#### Definition - -``` -typedef union SbConditionVariable SbConditionVariable -``` - -## Functions - -### SbConditionVariableBroadcast - -Broadcasts to all current waiters of `condition` to stop waiting. This function -wakes all of the threads waiting on `condition` while SbConditionVariableSignal -wakes a single thread. - -`condition`: The condition that should no longer be waited for. - -#### Declaration - -``` -bool SbConditionVariableBroadcast(SbConditionVariable *condition) -``` - -### SbConditionVariableCreate - -Creates a new condition variable to work with `opt_mutex`, which may be null, -placing the newly created condition variable in `out_condition`. - -The return value indicates whether the condition variable could be created. - -#### Declaration - -``` -bool SbConditionVariableCreate(SbConditionVariable *out_condition, SbMutex *opt_mutex) -``` - -### SbConditionVariableDestroy - -Destroys the specified SbConditionVariable . The return value indicates whether -the destruction was successful. The behavior is undefined if other threads are -currently waiting on this condition variable. - -`condition`: The SbConditionVariable to be destroyed. This invalidates the -condition variable. - -#### Declaration - -``` -bool SbConditionVariableDestroy(SbConditionVariable *condition) -``` - -### SbConditionVariableIsSignaled - -Returns whether the given result is a success. - -#### Declaration - -``` -static bool SbConditionVariableIsSignaled(SbConditionVariableResult result) -``` - -### SbConditionVariableSignal - -Signals the next waiter of `condition` to stop waiting. This function wakes a -single thread waiting on `condition` while SbConditionVariableBroadcast wakes -all threads waiting on it. - -`condition`: The condition that the waiter should stop waiting for. - -#### Declaration - -``` -bool SbConditionVariableSignal(SbConditionVariable *condition) -``` - -### SbConditionVariableWait - -Waits for `condition`, releasing the held lock `mutex`, blocking indefinitely, -and returning the result. Behavior is undefined if `mutex` is not held. - -#### Declaration - -``` -SbConditionVariableResult SbConditionVariableWait(SbConditionVariable *condition, SbMutex *mutex) -``` - -### SbConditionVariableWaitTimed - -Waits for `condition`, releasing the held lock `mutex`, blocking up to -`timeout_duration`, and returning the acquisition result. Behavior is undefined -if `mutex` is not held. - -`timeout_duration`: The maximum amount of time that function should wait for -`condition`. If the `timeout_duration` value is less than or equal to zero, the -function returns as quickly as possible with a kSbConditionVariableTimedOut -result. - -#### Declaration - -``` -SbConditionVariableResult SbConditionVariableWaitTimed(SbConditionVariable *condition, SbMutex *mutex, SbTime timeout_duration) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/configuration.md b/cobalt/site/docs/reference/starboard/modules/configuration.md index 1a3502e270ac..3ff1bef8b49c 100644 --- a/cobalt/site/docs/reference/starboard/modules/configuration.md +++ b/cobalt/site/docs/reference/starboard/modules/configuration.md @@ -53,6 +53,11 @@ will trigger a compiler warning when referenced. SB_DEPRECATED_EXTERNAL(...) annotates the function as deprecated for external clients, but not deprecated for starboard. +### SB_EXPORT_PLATFORM + +SB_C_FORCE_INLINE annotation for forcing a C function to be inlined. +SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. + ### SB_FUNCTION Whether we use **PRETTY_FUNCTION** PRETTY_FUNCTION or **FUNCTION** FUNCTION for @@ -71,6 +76,10 @@ Whether the current platform has 64-bit atomic operations. Determines at compile-time whether this platform has a quirk. +### SB_IMPORT_PLATFORM + +SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. + ### SB_INT64_C(x) Declare numeric literals of signed 64-bit type. @@ -86,7 +95,7 @@ Macro for hinting that an expression is likely to be true. ### SB_MAXIMUM_API_VERSION The maximum API version allowed by this version of the Starboard headers, -inclusive. +inclusive. The API version is not stable and is open for changes. ### SB_MINIMUM_API_VERSION @@ -98,11 +107,6 @@ inclusive. Macro to annotate a function as noreturn, which signals to the compiler that the function cannot return. -### SB_OVERRIDE - -Declares a function as overriding a virtual function on compilers that support -it. - ### SB_PREFERRED_RGBA_BYTE_ORDER_RGBA An enumeration of values for the kSbPreferredByteOrder configuration variable. @@ -123,7 +127,7 @@ base/compiler_specific.h) Include the platform-specific configuration. This macro is set by GN in starboard/build/config/BUILD.gn and passed in on the command line for all -targets and all configurations.Makes a pointer-typed parameter restricted so +targets and all configurations. Makes a pointer-typed parameter restricted so that the compiler can make certain optimizations because it knows the pointers are unique. diff --git a/cobalt/site/docs/reference/starboard/modules/configuration_constants.md b/cobalt/site/docs/reference/starboard/modules/configuration_constants.md index 18af4bc2945c..3866aab20c5f 100644 --- a/cobalt/site/docs/reference/starboard/modules/configuration_constants.md +++ b/cobalt/site/docs/reference/starboard/modules/configuration_constants.md @@ -9,6 +9,15 @@ runtime decisions based on per platform configurations. ## Variables +### kHasPartialAudioFramesSupport + +Platform can support partial audio frames + +### kSbCanMapExecutableMemory + +Whether this platform can map executable memory. This is required for platforms +that want to JIT. + ### kSbDefaultMmapThreshold Determines the threshold of allocation size that should be done with mmap (if @@ -139,7 +148,3 @@ The string form of SB_PATH_SEP_CHAR. Specifies the preferred byte order of color channels in a pixel. Refer to starboard/configuration.h for the possible values. EGL/GLES platforms should generally prefer a byte order of RGBA, regardless of endianness. - -### kSbUserMaxSignedIn - -The maximum number of users that can be signed in at the same time. diff --git a/cobalt/site/docs/reference/starboard/modules/cpu_features.md b/cobalt/site/docs/reference/starboard/modules/cpu_features.md index e2aa35f2bb1a..523089cd4c5d 100644 --- a/cobalt/site/docs/reference/starboard/modules/cpu_features.md +++ b/cobalt/site/docs/reference/starboard/modules/cpu_features.md @@ -98,7 +98,7 @@ Book: /youtube/cobalt/_book.yaml SDIV and UDIV hardware division in ARM mode. * `bool has_aes` - ###### Arm 64 feature flags + ##### Arm 64 feature flags AES instructions. * `bool has_crc32` diff --git a/cobalt/site/docs/reference/starboard/modules/decode_target.md b/cobalt/site/docs/reference/starboard/modules/decode_target.md index 6df175b6ba9a..a354dda6ed01 100644 --- a/cobalt/site/docs/reference/starboard/modules/decode_target.md +++ b/cobalt/site/docs/reference/starboard/modules/decode_target.md @@ -12,7 +12,7 @@ data. This allows the application to allocate fast graphics memory, and have decoding done directly into this memory, avoiding unnecessary memory copies, and also avoiding pushing data between CPU and GPU memory unnecessarily. -## SbDecodeTargetFormat +* SbDecodeTargetFormat SbDecodeTargets support several different formats that can be used to decode into and render from. Some formats may be easier to decode into, and others may @@ -21,7 +21,7 @@ the SbDecodeTargetFormat passed into it, or the decode will produce an error. Each decoder provides a way to check if a given SbDecodeTargetFormat is supported by that decoder. -## SbDecodeTargetGraphicsContextProvider +* SbDecodeTargetGraphicsContextProvider Some components may need to acquire SbDecodeTargets compatible with a certain rendering context, which may need to be created on a particular thread. The @@ -33,51 +33,7 @@ to run arbitrary code on the application's renderer thread with the renderer's EGLContext held current. This may be useful if your SbDecodeTarget creation code needs to execute GLES commands like, for example, glGenTextures(). -The primary usage is likely to be the the SbPlayer implementation on some -platforms. - -## SbDecodeTarget Example - -Let's say that we are an application and we would like to use the interface -defined in starboard/image.h to decode an imaginary "image/foo" image type. - -First, the application should enumerate which SbDecodeTargetFormats are -supported by that decoder. - -``` -SbDecodeTargetFormat kPreferredFormats[] = { - kSbDecodeTargetFormat3PlaneYUVI420, - kSbDecodeTargetFormat1PlaneRGBA, - kSbDecodeTargetFormat1PlaneBGRA, -}; - -SbDecodeTargetFormat format = kSbDecodeTargetFormatInvalid; -for (int i = 0; i < SB_ARRAY_SIZE_INT(kPreferredFormats); ++i) { - if (SbImageIsDecodeSupported("image/foo", kPreferredFormats[i])) { - format = kPreferredFormats[i]; - break; - } -} - -``` - -Now that the application has a format, it can create a decode target that it -will use to decode the .foo file into. Let's assume format is -kSbDecodeTargetFormat1PlaneRGBA, that we are on an EGL/GLES2 platform. Also, we -won't do any error checking, to keep things even simpler. - -``` -SbDecodeTarget target = SbImageDecode( - context_provider, encoded_foo_data, encoded_foo_data_size, - "image/foo", format); - -// If the decode works, you can get the texture out and render it. -SbDecodeTargetInfo info; -memset(&info, 0, sizeof(info)); -SbDecodeTargetGetInfo(target, &info); -GLuint texture = - info.planes[kSbDecodeTargetPlaneRGBA].texture; -``` +The primary usage is likely to be the SbPlayer implementation on some platforms. ## Macros @@ -127,9 +83,9 @@ premultiplied unless otherwise explicitly specified. A decoder target format consisting of a single plane with pixels laid out in the format UYVY. Since there are two Y values per sample, but only one U value and only one V value, horizontally the Y resolution is twice the size - of both the U and V resolutions. Vertically, they Y, U and V all have the - same resolution. This is a YUV 422 format. When using this format with GL - platforms, it is expected that the underlying texture will be set to the + of both the U and V resolutions. Vertically, the Y, U, and V planes all have + the same resolution. This is a YUV 422 format. When using this format with + GL platforms, it is expected that the underlying texture will be set to the GL_RGBA format, and the width of the texture will be equal to the number of UYVY tuples per row (e.g. the u/v width resolution). Content region left/right should be specified in u/v width resolution. @@ -207,8 +163,7 @@ information about the graphics context that will be used to render SbDecodeTargets. Some Starboard implementations may need to have references to some graphics objects when creating/destroying resources used by SbDecodeTarget. References to SbDecodeTargetGraphicsContextProvider objects should be provided -to all Starboard functions that might create SbDecodeTargets (e.g. -SbImageDecode()). +to all Starboard functions that might create SbDecodeTargets. #### Members @@ -216,12 +171,12 @@ SbImageDecode()). A reference to the EGLDisplay object that hosts the EGLContext that will be used to render any produced SbDecodeTargets. Note that it has the type - `void*` in order to avoid #including the EGL header files here. + `void*` in order to avoid including the EGL header files here. * `void * egl_context` The EGLContext object that will be used to render any produced SbDecodeTargets. Note that it has the type `void*` in order to avoid - #including the EGL header files here. + including the EGL header files here. * `SbDecodeTargetGlesContextRunner gles_context_runner` The `gles_context_runner` function pointer is passed in from the application @@ -264,7 +219,7 @@ This can be queried via calls to SbDecodeTargetGetInfo(). * `SbDecodeTargetInfoPlane planes` The image planes (e.g. kSbDecodeTargetPlaneRGBA, or {kSbDecodeTargetPlaneY, - kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV} associated with this decode + kSbDecodeTargetPlaneU, kSbDecodeTargetPlaneV}) associated with this decode target. ### SbDecodeTargetInfoContentRegion @@ -368,7 +323,7 @@ static bool SbDecodeTargetIsValid(SbDecodeTarget handle) Returns ownership of `decode_target` to the Starboard implementation. This function will likely result in the destruction of the SbDecodeTarget and all its associated surfaces, though in some cases, platforms may simply adjust a -reference count. This function must be called on a thread with the context +reference count. This function must be called on a thread with the context. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/directory.md b/cobalt/site/docs/reference/starboard/modules/directory.md index 6f845f6567a9..9d16dbc1aac3 100644 --- a/cobalt/site/docs/reference/starboard/modules/directory.md +++ b/cobalt/site/docs/reference/starboard/modules/directory.md @@ -25,18 +25,6 @@ typedef struct SbDirectoryPrivate* SbDirectory ## Functions -### SbDirectoryCanOpen - -Indicates whether SbDirectoryOpen is allowed for the given `path`. - -`path`: The path to be checked. - -#### Declaration - -``` -bool SbDirectoryCanOpen(const char *path) -``` - ### SbDirectoryClose Closes an open directory stream handle. The return value indicates whether the @@ -50,20 +38,6 @@ directory was closed successfully. bool SbDirectoryClose(SbDirectory directory) ``` -### SbDirectoryCreate - -Creates the directory `path`, assuming the parent directory already exists. This -function returns `true` if the directory now exists (even if it existed before) -and returns `false` if the directory does not exist. - -`path`: The path to be created. - -#### Declaration - -``` -bool SbDirectoryCreate(const char *path) -``` - ### SbDirectoryGetNext Populates `out_entry` with the next entry in the specified directory stream, and diff --git a/cobalt/site/docs/reference/starboard/modules/drm.md b/cobalt/site/docs/reference/starboard/modules/drm.md index f42e43bf3db7..7317fda307ff 100644 --- a/cobalt/site/docs/reference/starboard/modules/drm.md +++ b/cobalt/site/docs/reference/starboard/modules/drm.md @@ -29,7 +29,7 @@ Encryption scheme of the input sample, as defined in ISO/IEC 23001 part 7. ### SbDrmKeyStatus -Status of a particular media key. [https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus](https://w3c.github.io/encrypted-media/#idl-def-MediaKeyStatus) +Status of a particular media key. [https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus](https://www.w3.org/TR/encrypted-media/#idl-def-mediakeystatus) #### Values @@ -67,8 +67,9 @@ The status of session related operations. Used by * `kSbDrmStatusQuotaExceededError` * `kSbDrmStatusUnknownError` - The following error can be used when the error status cannot be mapped to - one of the above errors. + The kSbDrmStatusUnknownError can be used when the error status cannot be + mapped to one of the rest errors. New error codes (if needed) should be + added before kSbDrmStatusUnknownError. ## Typedefs @@ -85,7 +86,7 @@ typedef void(* SbDrmServerCertificateUpdatedFunc) (SbDrmSystem drm_system, void ### SbDrmSessionClosedFunc -A callback for signalling that a session has been closed by the SbDrmSystem +A callback for signalling that a session has been closed by the SbDrmSystem. #### Definition @@ -96,8 +97,15 @@ typedef void(* SbDrmSessionClosedFunc) (SbDrmSystem drm_system, void *context, c ### SbDrmSessionKeyStatusesChangedFunc A callback for notifications that the status of one or more keys in a session -has been changed. All keys of the session and their new status will be passed -along. Any keys not in the list is considered as deleted. +has been changed. A pointer to an array of all keys `key_ids` of the session and +their new status will be passed along. Any keys not in the list are considered +as deleted. + +`number_of_keys` is the number of keys. + +`key_ids` is a pointer to an array of keys. + +`key_statuses` is a pointer of a vector contains the status of each key. #### Definition @@ -119,6 +127,7 @@ context that was passed into the call to SbDrmCreateSystem(). `error_message` may contain an optional error message when `status` isn't `kSbDrmStatusSuccess` to provide more details about the error. It may be NULL if `status` is `kSbDrmStatusSuccess` or if no error message can be provided. + `ticket` will be the same ticket that was passed to SbDrmGenerateSessionUpdateRequest() or `kSbDrmTicketInvalid` if the update request was generated by the DRM system. @@ -246,6 +255,50 @@ Clear any internal states/resources related to the specified `session_id`. void SbDrmCloseSession(SbDrmSystem drm_system, const void *session_id, int session_id_size) ``` +### SbDrmCreateSystem + +Creates a new DRM system that can be used when constructing an SbPlayer or an +SbDecoder. + +This function returns `kSbDrmSystemInvalid` if `key_system` is unsupported. + +Also see the documentation of SbDrmGenerateSessionUpdateRequest() and +SbDrmUpdateSession() for more details. + +`key_system`: The DRM key system to be created. The value should be in the form +of "com.example.somesystem". All letters in the value should be lowercase and +will be matched exactly with known DRM key systems of the platform. Note the key +system will be matched case sensitive. For more details, refer to [https://w3c.github.io/encrypted-media/#dfn-key-system-s](https://w3c.github.io/encrypted-media/#dfn-key-system-s) + +`context`: A value passed when any of this function's callback parameters are +called. + +`update_request_callback`: A function that is called every time after +SbDrmGenerateSessionUpdateRequest() is called. + +`session_updated_callback`: A function that is called every time after +SbDrmUpdateSession() is called. + +`key_statuses_changed_callback`: A function that can be called to indicate that +key statuses have changed. + +`server_certificate_updated_callback`: A function that is called to report +whether the server certificate has been successfully updated. It is called once +and only once. It is possible that the callback is called before the function +returns. + +`session_closed_callback`: A function that can be called to indicate that a +session has closed. If `NULL` is passed for any of the callbacks +(`update_request_callback`, `session_updated_callback`, +`key_statuses_changed_callback`, `server_certificate_updated_callback`, or +`session_closed_callback`), then `kSbDrmSystemInvalid` must be returned. + +#### Declaration + +``` +SbDrmSystem SbDrmCreateSystem(const char *key_system, void *context, SbDrmSessionUpdateRequestFunc update_request_callback, SbDrmSessionUpdatedFunc session_updated_callback, SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, SbDrmServerCertificateUpdatedFunc server_certificate_updated_callback, SbDrmSessionClosedFunc session_closed_callback) +``` + ### SbDrmDestroySystem Destroys `drm_system`, which implicitly removes all keys installed in it and @@ -292,9 +345,12 @@ establish ticket uniqueness, issuing multiple requests with the same ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must not be used. `type`: The case-sensitive type of the session update request payload. Must not -be NULL. `initialization_data`: The data for which the session update request -payload is created. Must not be NULL. `initialization_data_size`: The size of -the session update request payload. +be NULL. + +`initialization_data`: The data for which the session update request payload is +created. Must not be NULL. + +`initialization_data_size`: The size of the session update request payload. #### Declaration @@ -375,14 +431,18 @@ a previous call is called. Note that this function should only be called after `SbDrmIsServerCertificateUpdatable` is called first and returned true. `drm_system`: The DRM system whose server certificate is being updated. Must not -be `kSbDrmSystemInvalid`. `ticket`: The opaque ID that allows to distinguish -callbacks from multiple concurrent calls to SbDrmUpdateServerCertificate(), -which will be passed to `server_certificate_updated_callback` as-is. It is the -responsibility of the caller to establish ticket uniqueness, issuing multiple -requests with the same ticket may result in undefined behavior. The value -`kSbDrmTicketInvalid` must not be used. `certificate`: Pointer to the server -certificate data. Must not be NULL. `certificate_size`: Size of the server -certificate data. +be `kSbDrmSystemInvalid`. + +`ticket`: The opaque ID that allows to distinguish callbacks from multiple +concurrent calls to SbDrmUpdateServerCertificate(), which will be passed to +`server_certificate_updated_callback` as-is. It is the responsibility of the +caller to establish ticket uniqueness, issuing multiple requests with the same +ticket may result in undefined behavior. The value `kSbDrmTicketInvalid` must +not be used. + +`certificate`: Pointer to the server certificate data. Must not be NULL. + +`certificate_size`: Size of the server certificate data. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/event.md b/cobalt/site/docs/reference/starboard/modules/event.md index b8005a5d6c36..25a7aabc2373 100644 --- a/cobalt/site/docs/reference/starboard/modules/event.md +++ b/cobalt/site/docs/reference/starboard/modules/event.md @@ -236,6 +236,9 @@ the type of the value pointed to by that data argument, if any. triggered by the application have tickets passed in via SbWindowBlurOnScreenKeyboard. System-triggered events have ticket value kSbEventOnScreenKeyboardInvalidTicket. +* `kSbEventTypeReserved1` + + Reserved for deprecated events. * `kSbEventTypeAccessibilityCaptionSettingsChanged` One or more of the fields returned by SbAccessibilityGetCaptionSettings has @@ -303,7 +306,7 @@ Structure representing a Starboard event and its data. #### Members * `SbEventType type` -* `SbTimeMonotonic timestamp` +* `int64_t timestamp` * `void * data` ### SbEventStartData @@ -389,7 +392,7 @@ of microseconds to wait before calling the `callback` function. Set `delay` to #### Declaration ``` -SbEventId SbEventSchedule(SbEventCallback callback, void *context, SbTime delay) +SbEventId SbEventSchedule(SbEventCallback callback, void *context, int64_t delay) ``` ### SbRunStarboardMain diff --git a/cobalt/site/docs/reference/starboard/modules/file.md b/cobalt/site/docs/reference/starboard/modules/file.md index 103af475ace1..f4acdaa2e812 100644 --- a/cobalt/site/docs/reference/starboard/modules/file.md +++ b/cobalt/site/docs/reference/starboard/modules/file.md @@ -124,15 +124,15 @@ Used to hold information about a file. * `bool is_symbolic_link` Whether the file corresponds to a symbolic link. -* `SbTime last_modified` +* `int64_t last_modified` - The last modified time of a file. -* `SbTime last_accessed` + The last modified time of a file - microseconds since Windows epoch UTC. +* `int64_t last_accessed` - The last accessed time of a file. -* `SbTime creation_time` + The last accessed time of a file - microseconds since Windows epoch UTC. +* `int64_t creation_time` - The creation time of a file. + The creation time of a file - microseconds since Windows epoch UTC. ## Functions @@ -192,18 +192,6 @@ fails if the file in question is being held open. bool SbFileDelete(const char *path) ``` -### SbFileExists - -Indicates whether a file or directory exists at `path`. - -`path`: The absolute path of the file or directory being checked. - -#### Declaration - -``` -bool SbFileExists(const char *path) -``` - ### SbFileFlush Flushes the write buffer to `file`. Data written via SbFileWrite is not diff --git a/cobalt/site/docs/reference/starboard/modules/image.md b/cobalt/site/docs/reference/starboard/modules/image.md deleted file mode 100644 index 945938a09903..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/image.md +++ /dev/null @@ -1,77 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `image.h` - -API for hardware accelerated image decoding. This module allows for the client -to feed in raw, encoded data to be decoded directly into an SbDecodeTarget. It -also provides an interface for the client to query what combinations of encoded -image formats and SbDecodeTargetFormats are supported or not. - -All functions in this module are safe to call from any thread at any point in -time. - -## SbImageIsDecodeSupported and SbImageDecode Example - -``` -SbDecodeTargetProvider* provider = GetProviderFromSomewhere(); -void* data = GetCompressedJPEGFromSomewhere(); -int data_size = GetCompressedJPEGSizeFromSomewhere(); -const char* mime_type = "image/jpeg"; -SbDecodeTargetFormat format = kSbDecodeTargetFormat1PlaneRGBA; - -if (!SbImageIsDecodeSupported(mime_type, format)) { - return; -} - -SbDecodeTarget result_target = SbImageDecode(provider, data, data_size, - mime_type, format); -``` - -## Functions - -### SbImageDecode - -Attempt to decode encoded `mime_type` image data `data` of size `data_size` into -an SbDecodeTarget of SbDecodeFormatType `format`, possibly using -SbDecodeTargetProvider `provider`, if it is non-null. Thus, four following -scenarios regarding the provider may happen: - -1. The provider is required by the `SbImageDecode` implementation and no - provider is given. The implementation should gracefully fail by immediately - returning kSbDecodeTargetInvalid. - -1. The provider is required and is passed in. The implementation will proceed - forward, using the SbDecodeTarget from the provider. - -1. The provider is not required and is passed in. The provider will NOT be - called, and the implementation will proceed to decoding however it desires. - -1. The provider is not required and is not passed in. The implementation will - proceed forward. The `data` pointer must not be NULL. The `mime_type` string - must not be NULL. Thus, it is NOT safe for clients of this API to assume - that the `provider` it passes in will be called. Finally, if the decode - succeeds, a new SbDecodeTarget will be allocated. If `mime_type` image - decoding for the requested format is not supported or the decode fails, - kSbDecodeTargetInvalid will be returned, with any intermediate allocations - being cleaned up in the implementation. - -#### Declaration - -``` -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider *context_provider, void *data, int data_size, const char *mime_type, SbDecodeTargetFormat format) -``` - -### SbImageIsDecodeSupported - -Whether the current platform supports hardware accelerated decoding an image of -mime type `mime_type` into SbDecodeTargetFormat `format`. The `mime_type` must -not be NULL. The result of this function must not change over the course of the -program, which means that the results of this function may be cached -indefinitely. - -#### Declaration - -``` -bool SbImageIsDecodeSupported(const char *mime_type, SbDecodeTargetFormat format) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/media.md b/cobalt/site/docs/reference/starboard/modules/media.md index 0619503f46f6..49186b116ac8 100644 --- a/cobalt/site/docs/reference/starboard/modules/media.md +++ b/cobalt/site/docs/reference/starboard/modules/media.md @@ -187,7 +187,7 @@ output. The type of audio connector. Will be `kSbMediaAudioConnectorUnknown` if this device cannot provide this information. -* `SbTime latency` +* `int64_t latency` The expected latency of audio over this output, in microseconds, or `0` if this device cannot provide this information. @@ -209,8 +209,8 @@ The set of information required by the decoder or player for each audio sample. * `SbMediaAudioStreamInfo stream_info` The set of information of the video stream associated with this sample. -* `SbTime discarded_duration_from_front` -* `SbTime discarded_duration_from_back` +* `int64_t discarded_duration_from_front` +* `int64_t discarded_duration_from_back` ### SbMediaAudioStreamInfo @@ -240,14 +240,13 @@ The set of information required by the decoder or player for each audio stream. The size, in bytes, of the audio_specific_config. * `const void * audio_specific_config` - The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1: [http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF](http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF) + The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1. ### SbMediaColorMetadata HDR (High Dynamic Range) Metadata common for HDR10 and WebM/VP9-based HDR formats, together with the ColorSpace. HDR reproduces a greater dynamic range of -luminosity than is possible with standard digital imaging. See the Consumer -Electronics Association press release: [https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx](https://www.cta.tech/News/Press-Releases/2015/August/CEA-Defines-%E2%80%98HDR-Compatible%E2%80%99-Displays.aspx) +luminosity than is possible with standard digital imaging. #### Members @@ -447,10 +446,12 @@ Note that neither `mime` nor `key_system` can be NULL. This function returns `mime`: The mime information of the media in the form of `video/webm` or `video/mp4; codecs="avc1.42001E"`. It may include arbitrary parameters like "codecs", "channels", etc. Note that the "codecs" parameter may contain more -than one codec, delimited by comma. `key_system`: A lowercase value in the form -of "com.example.somesystem" as suggested by [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system)) that can +than one codec, delimited by comma. + +`key_system`: A lowercase value in the form of "com.example.somesystem", and can be matched exactly with known DRM key systems of the platform. When `key_system` is an empty string, the return value is an indication for non-encrypted media. +For more detail, refer to [https://w3c.github.io/encrypted-media/#key-system](https://w3c.github.io/encrypted-media/#key-system) An implementation may choose to support `key_system` with extra attributes, separated by ';', like `com.example.somesystem; attribute_name1="value1"; @@ -462,23 +463,21 @@ attributes, it has to support all attributes defined by the Starboard version the implementation uses. An implementation should ignore any unknown attributes, and make a decision solely based on the key system and the known attributes. For example, if an implementation supports "com.widevine.alpha", it should also -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when -`key_system` is `com.widevine.alpha; invalid_attribute="invalid_value"`. -Currently the only attribute has to be supported is `encryptionscheme`. It -reflects the value passed to `encryptionScheme` encryptionScheme of -MediaKeySystemMediaCapability, as defined in [https://wicg.github.io/encrypted-media-encryption-scheme/,](https://wicg.github.io/encrypted-media-encryption-scheme/,),) which can take value "cenc", "cbcs", or "cbcs-1-9". Empty string is -not a valid value for `encryptionscheme` and the implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when +return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; +invalid_attribute="invalid_value"`. Currently the only attribute has to be +supported is `encryptionscheme`. It reflects the value passed to +`encryptionScheme` of MediaKeySystemMediaCapability. It can take value "cenc", +"cbcs", or "cbcs-1-9". Empty string is not a valid value for `encryptionscheme` +and the implementation should return `kSbMediaSupportTypeNotSupported` when `encryptionscheme` is set to "". The implementation should return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported for unknown -values of known attributes. For example, if an implementation supports -"encryptionscheme" with value "cenc", "cbcs", or "cbcs-1-9", then it should -return `kSbMediaSupportTypeProbably` kSbMediaSupportTypeProbably when +`kSbMediaSupportTypeNotSupported` for unknown values of known attributes. For +example, if an implementation supports "encryptionscheme" with value "cenc", +"cbcs", or "cbcs-1-9", then it should return `kSbMediaSupportTypeProbably` when `key_system` is `com.widevine.alpha; encryptionscheme="cenc"`, and return -`kSbMediaSupportTypeNotSupported` kSbMediaSupportTypeNotSupported when -`key_system` is `com.widevine.alpha; encryptionscheme="invalid"`. If an -implementation supports key system with attributes on one key system, it has to -support key system with attributes on all key systems supported. +`kSbMediaSupportTypeNotSupported` when `key_system` is `com.widevine.alpha; +encryptionscheme="invalid"`. If an implementation supports key system with +attributes on one key system, it has to support key system with attributes on +all key systems supported. For more detail, refer to [https://wicg.github.io/encrypted-media-encryption-scheme](https://wicg.github.io/encrypted-media-encryption-scheme) #### Declaration @@ -533,11 +532,13 @@ int SbMediaGetAudioOutputCount() ### SbMediaGetBufferAllocationUnit -When the media stack needs more memory to store media buffers, it will allocate -extra memory in units returned by SbMediaGetBufferAllocationUnit. This can -return 0, in which case the media stack will allocate extra memory on demand. -When SbMediaGetInitialBufferCapacity and this function both return 0, the media -stack will allocate individual buffers directly using SbMemory functions. +The media buffer will be allocated using the returned alignment. Set this to a +larger value may increase the memory consumption of media buffers. When the +media stack needs more memory to store media buffers, it will allocate extra +memory in units returned by SbMediaGetBufferAllocationUnit. This can return 0, +in which case the media stack will allocate extra memory on demand. When +SbMediaGetInitialBufferCapacity and this function both return 0, the media stack +will allocate individual buffers directly using malloc functions. #### Declaration @@ -547,19 +548,19 @@ int SbMediaGetBufferAllocationUnit() ### SbMediaGetBufferGarbageCollectionDurationThreshold -Specifies the duration threshold of media source garbage collection. When the -accumulated duration in a source buffer exceeds this value, the media source -implementation will try to eject existing buffers from the cache. This is -usually triggered when the video being played has a simple content and the -encoded data is small. In such case this can limit how much is allocated for the -book keeping data of the media buffers and avoid OOM of system heap. This should -return 170 seconds for most of the platforms. But it can be further reduced on -systems with extremely low memory. +Specifies the duration threshold of media source garbage collection in +microseconds. When the accumulated duration in a source buffer exceeds this +value, the media source implementation will try to eject existing buffers from +the cache. This is usually triggered when the video being played has a simple +content and the encoded data is small. In such case this can limit how much is +allocated for the book keeping data of the media buffers and avoid OOM of system +heap. This should return 170 seconds for most of the platforms. But it can be +further reduced on systems with extremely low memory. #### Declaration ``` -SbTime SbMediaGetBufferGarbageCollectionDurationThreshold() +int64_t SbMediaGetBufferGarbageCollectionDurationThreshold() ``` ### SbMediaGetBufferPadding @@ -574,22 +575,6 @@ padding. int SbMediaGetBufferPadding() ``` -### SbMediaGetBufferStorageType - -Returns SbMediaBufferStorageType of type `SbMediaStorageTypeMemory` or -`SbMediaStorageTypeFile`. For memory storage, the media buffers will be stored -in main memory allocated by SbMemory functions. For file storage, the media -buffers will be stored in a temporary file in the system cache folder acquired -by calling SbSystemGetPath() with "kSbSystemPathCacheDirectory". Note that when -its value is "file" the media stack will still allocate memory to cache the -buffers in use. - -#### Declaration - -``` -SbMediaBufferStorageType SbMediaGetBufferStorageType() -``` - ### SbMediaGetInitialBufferCapacity The amount of memory that will be used to store media buffers allocated during @@ -613,10 +598,14 @@ allocation of media buffers may only fail when there is not enough memory in the system to fulfill the request, under which case the app will be terminated as under other OOM situations. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -631,10 +620,14 @@ resolution of such videos shouldn't go beyond 1080p. Its value should be less than the sum of SbMediaGetAudioBufferBudget and 'SbMediaGetVideoBufferBudget(..., 1920, 1080, ...) but not less than 8 MB. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -650,10 +643,14 @@ being used by video buffers but will also make app less likely to re-download video data. Note that the app may experience significant difficulty if this value is too low. -`codec`: the video codec associated with the buffer. `resolution_width`: the -width of the video resolution. `resolution_height`: the height of the video -resolution. `bits_per_pixel`: the bits per pixel. This value is larger for HDR -than non- HDR video. +`codec`: the video codec associated with the buffer. + +`resolution_width`: the width of the video resolution. + +`resolution_height`: the height of the video resolution. + +`bits_per_pixel`: the bits per pixel. This value is larger for HDR than non-HDR +video. #### Declaration @@ -681,7 +678,7 @@ bool SbMediaIsBufferPoolAllocateOnDemand() ### SbMediaIsBufferUsingMemoryPool If SbMediaGetBufferUsingMemoryPool returns true, it indicates that media buffer -pools should be allocated on demand, as opposed to using SbMemory* functions. +pools should be allocated on demand, as opposed to using malloc functions. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/memory.md b/cobalt/site/docs/reference/starboard/modules/memory.md index 5b13119060ec..65a36ff69f89 100644 --- a/cobalt/site/docs/reference/starboard/modules/memory.md +++ b/cobalt/site/docs/reference/starboard/modules/memory.md @@ -43,290 +43,3 @@ the mapped memory can be used. * `kSbMemoryMapProtectWrite` * `kSbMemoryMapProtectExec` * `kSbMemoryMapProtectReadWrite` - -## Functions - -### SbMemoryAllocate - -Allocates and returns a chunk of memory of at least `size` bytes. This function -should be called from the client codebase. It is intended to be a drop-in -replacement for `malloc`. - -Note that this function returns `NULL` if it is unable to allocate the memory. - -`size`: The amount of memory to be allocated. If `size` is 0, the function may -return `NULL` or it may return a unique pointer value that can be passed to -SbMemoryDeallocate. - -#### Declaration - -``` -void* SbMemoryAllocate(size_t size) -``` - -### SbMemoryAllocateAligned - -Allocates and returns a chunk of memory of at least `size` bytes, aligned to -`alignment`. This function should be called from the client codebase. It is -meant to be a drop-in replacement for `memalign`. - -The function returns `NULL` if it cannot allocate the memory. In addition, the -function's behavior is undefined if `alignment` is not a power of two. - -`alignment`: The way that data is arranged and accessed in memory. The value -must be a power of two. `size`: The size of the memory to be allocated. If -`size` is `0`, the function may return `NULL` or it may return a unique aligned -pointer value that can be passed to SbMemoryDeallocateAligned. - -#### Declaration - -``` -void* SbMemoryAllocateAligned(size_t alignment, size_t size) -``` - -### SbMemoryAllocateAlignedChecked - -Same as SbMemoryAllocateAlignedUnchecked, but will abort() in the case of an -allocation failure. - -DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateAlignedChecked(size_t alignment, size_t size) -``` - -### SbMemoryAllocateAlignedUnchecked - -This is the implementation of SbMemoryAllocateAligned that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateAlignedUnchecked(size_t alignment, size_t size) -``` - -### SbMemoryAllocateChecked - -Same as SbMemoryAllocateUnchecked, but will abort() in the case of an allocation -failure. - -DO NOT CALL. Call SbMemoryAllocate(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateChecked(size_t size) -``` - -### SbMemoryAllocateNoReport - -DEPRECATED: Same as SbMemoryAllocate(). - -#### Declaration - -``` -void* SbMemoryAllocateNoReport(size_t size) -``` - -### SbMemoryAllocateUnchecked - -This is the implementation of SbMemoryAllocate that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryAllocate(...) instead. - -#### Declaration - -``` -void* SbMemoryAllocateUnchecked(size_t size) -``` - -### SbMemoryCalloc - -A wrapper that implements a drop-in replacement for `calloc`, which is used in -some packages. - -#### Declaration - -``` -static void* SbMemoryCalloc(size_t count, size_t size) -``` - -### SbMemoryDeallocate - -Frees a previously allocated chunk of memory. If `memory` is NULL, then the -operation is a no-op. This function should be called from the client codebase. -It is meant to be a drop-in replacement for `free`. - -`memory`: The chunk of memory to be freed. - -#### Declaration - -``` -void SbMemoryDeallocate(void *memory) -``` - -### SbMemoryDeallocateAligned - -`memory`: The chunk of memory to be freed. If `memory` is NULL, then the -function is a no-op. - -#### Declaration - -``` -void SbMemoryDeallocateAligned(void *memory) -``` - -### SbMemoryDeallocateNoReport - -DEPRECATED: Same as SbMemoryDeallocate() - -#### Declaration - -``` -void SbMemoryDeallocateNoReport(void *memory) -``` - -### SbMemoryFlush - -Flushes any data in the given virtual address range that is cached locally in -the current processor core to physical memory, ensuring that data and -instruction caches are cleared. This is required to be called on executable -memory that has been written to and might be executed in the future. - -#### Declaration - -``` -void SbMemoryFlush(void *virtual_address, int64_t size_bytes) -``` - -### SbMemoryFree - -This is the implementation of SbMemoryDeallocate that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryDeallocate(...) instead. - -#### Declaration - -``` -void SbMemoryFree(void *memory) -``` - -### SbMemoryFreeAligned - -This is the implementation of SbMemoryFreeAligned that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryDeallocateAligned(...) instead. - -#### Declaration - -``` -void SbMemoryFreeAligned(void *memory) -``` - -### SbMemoryMap - -Allocates `size_bytes` worth of physical memory pages and maps them into an -available virtual region. This function returns `SB_MEMORY_MAP_FAILED` on -failure. `NULL` is a valid return value. - -`size_bytes`: The amount of physical memory pages to be allocated. `flags`: The -bitwise OR of the protection flags for the mapped memory as specified in -`SbMemoryMapFlags`. Allocating executable memory is not allowed and will fail. -If executable memory is needed, map non-executable memory first and then switch -access to executable using SbMemoryProtect. When kSbMemoryMapProtectReserved is -used, the address space will not be accessible and, if possible, the platform -should not count it against any memory budget. `name`: A value that appears in -the debugger on some platforms. The value can be up to 32 bytes. - -#### Declaration - -``` -void* SbMemoryMap(int64_t size_bytes, int flags, const char *name) -``` - -### SbMemoryProtect - -Change the protection of `size_bytes` of memory regions, starting from -`virtual_address`, to `flags`, returning `true` on success. - -#### Declaration - -``` -bool SbMemoryProtect(void *virtual_address, int64_t size_bytes, int flags) -``` - -### SbMemoryReallocate - -Attempts to resize `memory` to be at least `size` bytes, without touching the -contents of memory. - -* If the function cannot perform the fast resize, it allocates a new chunk of - memory, copies the contents over, and frees the previous chunk, returning a - pointer to the new chunk. - -* If the function cannot perform the slow resize, it returns `NULL`, leaving - the given memory chunk unchanged. - -This function should be called from the client codebase. It is meant to be a -drop-in replacement for `realloc`. - -`memory`: The chunk of memory to be resized. `memory` may be NULL, in which case -it behaves exactly like SbMemoryAllocateUnchecked. `size`: The size to which -`memory` will be resized. If `size` is `0`, the function may return `NULL` or it -may return a unique pointer value that can be passed to SbMemoryDeallocate. - -#### Declaration - -``` -void* SbMemoryReallocate(void *memory, size_t size) -``` - -### SbMemoryReallocateChecked - -Same as SbMemoryReallocateUnchecked, but will abort() in the case of an -allocation failure. - -DO NOT CALL. Call SbMemoryReallocate(...) instead. - -#### Declaration - -``` -void* SbMemoryReallocateChecked(void *memory, size_t size) -``` - -### SbMemoryReallocateUnchecked - -This is the implementation of SbMemoryReallocate that must be provided by -Starboard ports. - -DO NOT CALL. Call SbMemoryReallocate(...) instead. - -#### Declaration - -``` -void* SbMemoryReallocateUnchecked(void *memory, size_t size) -``` - -### SbMemoryUnmap - -Unmap `size_bytes` of physical pages starting from `virtual_address`, returning -`true` on success. After this function completes, [virtual_address, -virtual_address + size_bytes) will not be read/writable. This function can unmap -multiple contiguous regions that were mapped with separate calls to -SbMemoryMap(). For example, if one call to `SbMemoryMap(0x1000)` returns -`(void*)0xA000`, and another call to `SbMemoryMap(0x1000)` returns -`(void*)0xB000`, `SbMemoryUnmap(0xA000, 0x2000)` should free both regions. - -#### Declaration - -``` -bool SbMemoryUnmap(void *virtual_address, int64_t size_bytes) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/memory_reporter.md b/cobalt/site/docs/reference/starboard/modules/memory_reporter.md deleted file mode 100644 index 5e49693e70bc..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/memory_reporter.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -layout: doc -title: "Starboard Module Reference: memory_reporter.h" ---- - -DEPRECATED: Provides an interface for memory reporting. - -## Typedefs ## - -### SbMemoryReporterOnAlloc ### - -A function to report a memory allocation from SbMemoryAllocate(). Note that -operator new calls SbMemoryAllocate which will delegate to this callback. - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnAlloc) (void *context, const void *memory, size_t size) -``` - -### SbMemoryReporterOnDealloc ### - -A function to report a memory deallocation from SbMemoryDeallcoate(). Note that -operator delete calls SbMemoryDeallocate which will delegate to this callback. - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnDealloc) (void *context, const void *memory) -``` - -### SbMemoryReporterOnMapMemory ### - -A function to report a memory mapping from SbMemoryMap(). - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnMapMemory) (void *context, const void *memory, size_t size) -``` - -### SbMemoryReporterOnUnMapMemory ### - -A function to report a memory unmapping from SbMemoryUnmap(). - -#### Definition #### - -``` -typedef void(* SbMemoryReporterOnUnMapMemory) (void *context, const void *memory, size_t size) -``` - -## Structs ## - -### SbMemoryReporter ### - -SbMemoryReporter allows memory reporting via user-supplied functions. The void* -context is passed to every call back. It's strongly recommended that C-Style -struct initialization is used so that the arguments can be typed check by the -compiler. For example, SbMemoryReporter mem_reporter = { MallocCallback, .... -context }; - -#### Members #### - -* `SbMemoryReporterOnAlloc on_alloc_cb` - - Callback to report allocations. -* `SbMemoryReporterOnDealloc on_dealloc_cb` - - Callback to report deallocations. -* `SbMemoryReporterOnMapMemory on_mapmem_cb` - - Callback to report memory map. -* `SbMemoryReporterOnUnMapMemory on_unmapmem_cb` - - Callback to report memory unmap. -* `void * context` - - Optional, is passed to callbacks as first argument. - -## Functions ## - -### SbMemorySetReporter ### - -Sets the MemoryReporter. Any previous memory reporter is unset. No lifetime -management is done internally on input pointer. - -NOTE: This module is unused starting with Starboard 15 and will be removed in -the future. - -Returns true if the memory reporter was set with no errors. If an error was -reported then check the log for why it failed. - -Note that other than a thread-barrier-write of the input pointer, there is no -thread safety guarantees with this function due to performance considerations. -It's recommended that this be called once during the lifetime of the program, or -not at all. Do not delete the supplied pointer, ever. Example (Good): -SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter); -... SbMemorySetReporter(NULL); // allow value to leak. Example (Bad): -SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter); -... SbMemorySetReporter(NULL); delete mem_reporter; // May crash. - -#### Declaration #### - -``` -bool SbMemorySetReporter(struct SbMemoryReporter *tracker) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/mutex.md b/cobalt/site/docs/reference/starboard/modules/mutex.md deleted file mode 100644 index 82ff8500ab8d..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/mutex.md +++ /dev/null @@ -1,127 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `mutex.h` - -Defines a mutually exclusive lock that can be used to coordinate with other -threads. - -## Macros - -### SB_MUTEX_MAX_SIZE - -Max size of the SbMutex type. - -## Enums - -### SbMutexResult - -Enumeration of possible results from acquiring a mutex. - -#### Values - -* `kSbMutexAcquired` - - The mutex was acquired successfully. -* `kSbMutexBusy` - - The mutex was not acquired because it was held by someone else. -* `kSbMutexDestroyed` - - The mutex has already been destroyed. - -## Typedefs - -### SbMutex - -An opaque handle to a mutex type with reserved memory buffer of size -SB_MUTEX_MAX_SIZE and aligned at void pointer type. - -#### Definition - -``` -typedef union SbMutex SbMutex -``` - -## Functions - -### SbMutexAcquire - -Acquires `mutex`, blocking indefinitely. The return value identifies the -acquisition result. SbMutexes are not reentrant, so a recursive acquisition -blocks forever. - -`mutex`: The mutex to be acquired. - -#### Declaration - -``` -SbMutexResult SbMutexAcquire(SbMutex *mutex) -``` - -### SbMutexAcquireTry - -Acquires `mutex`, without blocking. The return value identifies the acquisition -result. SbMutexes are not reentrant, so a recursive acquisition has undefined -behavior. - -`mutex`: The mutex to be acquired. - -#### Declaration - -``` -SbMutexResult SbMutexAcquireTry(SbMutex *mutex) -``` - -### SbMutexCreate - -Creates a new mutex. The return value indicates whether the function was able to -create a new mutex. - -`out_mutex`: The handle to the newly created mutex. - -#### Declaration - -``` -bool SbMutexCreate(SbMutex *out_mutex) -``` - -### SbMutexDestroy - -Destroys a mutex. The return value indicates whether the destruction was -successful. Destroying a locked mutex results in undefined behavior. - -`mutex`: The mutex to be invalidated. - -#### Declaration - -``` -bool SbMutexDestroy(SbMutex *mutex) -``` - -### SbMutexIsSuccess - -Indicates whether the given result is a success. A value of `true` indicates -that the mutex was acquired. - -`result`: The result being checked. - -#### Declaration - -``` -static bool SbMutexIsSuccess(SbMutexResult result) -``` - -### SbMutexRelease - -Releases `mutex` held by the current thread. The return value indicates whether -the release was successful. Releases should always be successful if `mutex` is -held by the current thread. - -`mutex`: The mutex to be released. - -#### Declaration - -``` -bool SbMutexRelease(SbMutex *mutex) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/once.md b/cobalt/site/docs/reference/starboard/modules/once.md deleted file mode 100644 index d77302467f8b..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/once.md +++ /dev/null @@ -1,57 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `once.h` - -Onces represent initializations that should only ever happen once per process, -in a thread-safe way. - -## Macros - -### SB_ONCE_MAX_SIZE - -Max size of the SbOnceControl type. - -## Typedefs - -### SbOnceControl - -An opaque handle to a once control type with reserved memory buffer of size -SB_ONCE_MAX_SIZE and aligned at void pointer type. - -#### Definition - -``` -typedef union SbOnceControl SbOnceControl -``` - -### SbOnceInitRoutine - -Function pointer type for methods that can be called via the SbOnce() system. - -#### Definition - -``` -typedef void(* SbOnceInitRoutine) (void) -``` - -## Functions - -### SbOnce - -Thread-safely runs `init_routine` only once. - -* If this `once_control` has not run a function yet, this function runs - `init_routine` in a thread-safe way and then returns `true`. - -* If SbOnce() was called with `once_control` before, the function returns - `true` immediately. - -* If `once_control` or `init_routine` is invalid, the function returns - `false`. - -#### Declaration - -``` -bool SbOnce(SbOnceControl *once_control, SbOnceInitRoutine init_routine) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/player.md b/cobalt/site/docs/reference/starboard/modules/player.md index 0382642a35fe..efbb73e3b2a4 100644 --- a/cobalt/site/docs/reference/starboard/modules/player.md +++ b/cobalt/site/docs/reference/starboard/modules/player.md @@ -52,9 +52,12 @@ data may come from multiple sources. * `kMatroskaBlockAdditional` The side data comes from the BlockAdditional data in the Matroska/Webm - container, as specified in [https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39](https://tools.ietf.org/id/draft-lhomme-cellar-matroska-03.html#rfc.section.7.3.39)9) andnd [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional)l) - . The first 8 bytes of the data contains the value of BlockAddID in big - endian format, followed by the content of BlockAdditional. + container. The first 8 bytes of the data contains the value of BlockAddID in + big endian format, followed by the content of BlockAdditional. See: + + [https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03](https://datatracker.ietf.org/doc/draft-lhomme-cellar-matroska/03) + + [https://www.webmproject.org/docs/container/#BlockAdditional](https://www.webmproject.org/docs/container/#BlockAdditional) ### SbPlayerState @@ -130,10 +133,13 @@ typedef void(* SbPlayerDecoderStatusFunc) (SbPlayer player, void *context, SbMed ### SbPlayerErrorFunc -Callback for player errors, that may set a `message`. `error`: indicates the -error code. `message`: provides specific informative diagnostic message about -the error condition encountered. It is ok for the message to be an empty string -or NULL if no information is available. +Callback for player errors, that may set a `message`. + +`error`: indicates the error code. + +`message`: provides specific informative diagnostic message about the error +condition encountered. It is ok for the message to be an empty string or NULL if +no information is available. #### Definition @@ -192,14 +198,14 @@ Information about the current media playback state. #### Members -* `SbTime current_media_timestamp` +* `int64_t current_media_timestamp` The position of the playback head, as precisely as possible, in microseconds. -* `SbTime duration` +* `int64_t duration` The known duration of the currently playing media stream, in microseconds. -* `SbTime start_date` +* `int64_t start_date` The result of getStartDate for the currently playing media stream, in microseconds since the epoch of January 1, 1601 UTC. @@ -250,9 +256,9 @@ Information about the samples to be written into SbPlayerWriteSamples(). * `int buffer_size` Size of the data pointed to by `buffer`. -* `SbTime timestamp` +* `int64_t timestamp` - The timestamp of the sample in SbTime. + The timestamp of the sample in microseconds since Windows epoch UTC. * `SbPlayerSampleSideData* side_data` Points to an array of side data for the input, when available. @@ -292,20 +298,123 @@ coming from multiple sources. ## Functions +### SbPlayerCreate + +Creates a player that will be displayed on `window` for the specified +`video_codec` and `audio_codec`, acquiring all resources needed to operate it, +and returning an opaque handle to it. The expectation is that a new player will +be created and destroyed for every playback. + +This function returns the created player. Note the following: + +* The associated decoder of the returned player should be assumed to not be in + `kSbPlayerDecoderStateNeedsData` until SbPlayerSeek() has been called on it. + +* It is expected either that the thread that calls SbPlayerCreate is the same + thread that calls the other `SbPlayer` functions for that player, or that + there is a mutex guarding calls into each `SbPlayer` instance. + +* If there is a platform limitation on how many players can coexist + simultaneously, then calls made to this function that attempt to exceed that + limit must return `kSbPlayerInvalid`. Multiple calls to SbPlayerCreate must + not cause a crash. + +`window`: The window that will display the player. `window` can be +`kSbWindowInvalid` for platforms where video is only displayed on a particular +window that the underlying implementation already has access to. + +`video_codec`: The video codec used for the player. If `video_codec` is +`kSbMediaVideoCodecNone`, the player is an audio-only player. If `video_codec` +is any other value, the player is an audio/video decoder. This can be set to +`kSbMediaVideoCodecNone` to play a video with only an audio track. + +`audio_codec`: The audio codec used for the player. The caller must provide a +populated `audio_sample_info` if audio codec is `kSbMediaAudioCodecAac`. Can be +set to `kSbMediaAudioCodecNone` to play a video without any audio track. In such +case `audio_sample_info` must be NULL. + +`drm_system`: If the media stream has encrypted portions, then this parameter +provides an appropriate DRM system, created with `SbDrmCreateSystem()`. If the +stream does not have encrypted portions, then `drm_system` may be +`kSbDrmSystemInvalid`. + +`audio_sample_info`: Note that the caller must provide a populated +`audio_sample_info` if the audio codec is `kSbMediaAudioCodecAac`. Otherwise, +`audio_sample_info` can be NULL. See media.h for the format of the +`SbMediaAudioSampleInfo` struct. + +Note that `audio_specific_config` is a pointer and the content it points to is +no longer valid after this function returns. The implementation has to make a +copy of the content if it is needed after the function returns. + +`max_video_capabilities`: This string communicates the max video capabilities +required to the platform. The web app will not provide a video stream exceeding +the maximums described by this parameter. Allows the platform to optimize +playback pipeline for low quality video streams if it knows that it will never +adapt to higher quality streams. The string uses the same format as the string +passed in to SbMediaCanPlayMimeAndKeySystem(), for example, when it is set to +"width=1920; height=1080; framerate=15;", the video will never adapt to +resolution higher than 1920x1080 or frame per second higher than 15 fps. When +the maximums are unknown, this will be set to NULL. + +`sample_deallocator_func`: If not `NULL`, the player calls this function on an +internal thread to free the sample buffers passed into SbPlayerWriteSample(). + +`decoder_status_func`: If not `NULL`, the decoder calls this function on an +internal thread to provide an update on the decoder's status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_status_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the playback status. No work should be +done on this thread. Rather, it should just signal the client thread interacting +with the decoder. + +`player_error_func`: If not `NULL`, the player calls this function on an +internal thread to provide an update on the error status. This callback is +responsible for setting the media error message. + +`context`: This is passed to all callbacks and is generally used to point at a +class or struct that contains state associated with the player. + +`output_mode`: Selects how the decoded video frames will be output. For example, +kSbPlayerOutputModePunchOut indicates that the decoded video frames will be +output to a background video layer by the platform, and +kSbPlayerOutputDecodeToTexture indicates that the decoded video frames should be +made available for the application to pull via calls to +SbPlayerGetCurrentFrame(). + +`provider`: Only present in Starboard version 3 and up. If not `NULL`, then when +output_mode == kSbPlayerOutputModeDecodeToTexture, the player MAY use the +provider to create SbDecodeTargets on the renderer thread. A provider may not +always be needed by the player, but if it is needed, and the provider is not +given, the player will fail by returning `kSbPlayerInvalid`. + +If `NULL` is passed to any of the callbacks (`sample_deallocator_func`, +`decoder_status_func`, `player_status_func`, or `player_error_func` if it +applies), then `kSbPlayerInvalid` must be returned. + +#### Declaration + +``` +SbPlayer SbPlayerCreate(SbWindow window, const SbPlayerCreationParam *creation_param, SbPlayerDeallocateSampleFunc sample_deallocate_func, SbPlayerDecoderStatusFunc decoder_status_func, SbPlayerStatusFunc player_status_func, SbPlayerErrorFunc player_error_func, void *context, SbDecodeTargetGraphicsContextProvider *context_provider) +``` + ### SbPlayerDestroy Destroys `player`, freeing all associated resources. * Upon calling this method, there should be one call to the player status callback (i.e. `player_status_func` used in the creation of the player) - which indicates the player is destroyed. Note, the callback has to be in- - flight when SbPlayerDestroyed is called. + which indicates the player is destroyed. Note, the callback has to be + inflight when SbPlayerDestroyed is called. * No more other callbacks should be issued after this function returns. * It is not allowed to pass `player` into any other `SbPlayer` function once - SbPlayerDestroy has been called on that player. `player`: The player to be - destroyed. Must not be `kSbPlayerInvalid`. + SbPlayerDestroy has been called on that player. + +`player`: The player to be destroyed. Must not be `kSbPlayerInvalid`. #### Declaration @@ -326,50 +435,50 @@ audio output configurations other than the ones already returned. The app will use the information returned to determine audio related behaviors, like: -Audio Write Duration: Audio write duration is how far past the current playback -position the app will write audio samples. The app will write all samples -between `current_playback_position` and `current_playback_position` + -`audio_write_duration`, as soon as they are available. - -`audio_write_duration` will be to `kSbPlayerWriteDurationLocal` -kSbPlayerWriteDurationLocal when all audio configurations linked to `player` is -local, or if there isn't any audio output. It will be set to -`kSbPlayerWriteDurationRemote` kSbPlayerWriteDurationRemote for remote or -wireless audio outputs, i.e. one of `kSbMediaAudioConnectorBluetooth` -kSbMediaAudioConnectorBluetooth or `kSbMediaAudioConnectorRemote*` -kSbMediaAudioConnectorRemote* . - -The app only guarantees to write `audio_write_duration` past -`current_playback_position`, but the app is free to write more samples than -that. So the platform shouldn't rely on this for flow control. The platform -should achieve flow control by sending `kSbPlayerDecoderStateNeedsData` -kSbPlayerDecoderStateNeedsData less frequently. - -The platform is responsible for guaranteeing that when only -`audio_write_duration` audio samples are written at a time, no playback issues -occur (such as transient or indefinite hanging). +* Audio Write Duration: Audio write duration is how far past the current + playback position the app will write audio samples. The app will write all + samples between `current_playback_position` and `current_playback_position` + + `audio_write_duration`, as soon as they are available. + +* `audio_write_duration` will be to `kSbPlayerWriteDurationLocal` when all + audio configurations linked to `player` is local, or if there isn't any + audio output. It will be set to `kSbPlayerWriteDurationRemote` for remote or + wireless audio outputs, i.e. one of `kSbMediaAudioConnectorBluetooth` or + `kSbMediaAudioConnectorRemote*`. + +* The app only guarantees to write `audio_write_duration` past + `current_playback_position`, but the app is free to write more samples than + that. So the platform shouldn't rely on this for flow control. The platform + should achieve flow control by sending `kSbPlayerDecoderStateNeedsData` less + frequently. + +* The platform is responsible for guaranteeing that when only + `audio_write_duration` audio samples are written at a time, no playback + issues occur (such as transient or indefinite hanging). The audio configurations should be available as soon as possible, and they have -to be available when the `player` is at `kSbPlayerStatePresenting` -kSbPlayerStatePresenting , unless the audio codec is `kSbMediaAudioCodecNone` or -there's no written audio inputs. +to be available when the `player` is at `kSbPlayerStatePresenting`, unless the +audio codec is `kSbMediaAudioCodecNone` or there's no written audio inputs. -The app will set `audio_write_duration` to `kSbPlayerWriteDurationLocal` -kSbPlayerWriteDurationLocal when the audio configuration isn't available (i.e. -the function returns false when index is 0). The platform has to make the audio -configuration available immediately after the SbPlayer is created, if it expects -the app to treat the platform as using wireless audio outputs. +The app will set `audio_write_duration` to `kSbPlayerWriteDurationLocal` when +the audio configuration isn't available (i.e. the function returns false when +index is 0). The platform has to make the audio configuration available +immediately after the SbPlayer is created, if it expects the app to treat the +platform as using wireless audio outputs. Once at least one audio configurations are returned, the return values and their orders shouldn't change during the life time of `player`. The platform may -inform the app of any changes by sending `kSbPlayerErrorCapabilityChanged` -kSbPlayerErrorCapabilityChanged to request a playback restart. +inform the app of any changes by sending `kSbPlayerErrorCapabilityChanged` to +request a playback restart. `player`: The player about which information is being retrieved. Must not be -`kSbPlayerInvalid`. `index`: The index of the audio output configuration. Must -be greater than or equal to 0. `out_audio_configuration`: The information about -the audio output, refer to `SbMediaAudioConfiguration` for more details. Must -not be NULL. +`kSbPlayerInvalid`. + +`index`: The index of the audio output configuration. Must be greater than or +equal to 0. + +`out_audio_configuration`: The information about the audio output, refer to +`SbMediaAudioConfiguration` for more details. Must not be NULL. #### Declaration @@ -395,19 +504,36 @@ kSbDecodeTargetInvalid is returned. SbDecodeTarget SbPlayerGetCurrentFrame(SbPlayer player) ``` +### SbPlayerGetInfo + +Gets a snapshot of the current player state and writes it to `out_player_info`. +This function may be called very frequently and is expected to be inexpensive. + +`player`: The player about which information is being retrieved. Must not be +`kSbPlayerInvalid`. + +`out_player_info`: The information retrieved for the player. + +#### Declaration + +``` +void SbPlayerGetInfo(SbPlayer player, SbPlayerInfo *out_player_info) +``` + ### SbPlayerGetMaximumNumberOfSamplesPerWrite -Writes a single sample of the given media type to `player`'s input stream. Its -data may be passed in via more than one buffers. The lifetime of -`sample_buffers`, `sample_buffer_sizes`, `video_sample_info`, and -`sample_drm_info` (as well as member `subsample_mapping` contained inside it) -are not guaranteed past the call to SbPlayerWriteSample. That means that before -returning, the implementation must synchronously copy any information it wants -to retain from those structures. +Returns the maximum number of samples that can be written in a single call to +SbPlayerWriteSamples(). Returning a value greater than one can improve +performance by allowing SbPlayerWriteSamples() to write multiple samples in one +call. -`player`: The player for which the number is retrieved. `sample_type`: The type -of sample for which the number is retrieved. See the `SbMediaType` enum in -media.h. +Note that this feature is currently disabled in Cobalt where +SbPlayerWriteSamples() will always be called with one sample. + +`player`: The player for which the number is retrieved. + +`sample_type`: The type of sample for which the number is retrieved. See the +`SbMediaType` enum in media.h. #### Declaration @@ -449,6 +575,45 @@ Returns whether the given player handle is valid. static bool SbPlayerIsValid(SbPlayer player) ``` +### SbPlayerSeek + +Tells the player to freeze playback (if playback has already started), reset or +flush the decoder pipeline, and go back to the Prerolling state. The player +should restart playback once it can display the frame at `seek_to_timestamp`, or +the closest it can get. (Some players can only seek to I-Frames, for example.) + +* Seek must be called before samples are sent when starting playback for the + first time, or the client never receives the + `kSbPlayerDecoderStateNeedsData` signal. + +* A call to seek may interrupt another seek. + +* After this function is called, the client should not send any more audio or + video samples until `SbPlayerDecoderStatusFunc` is called back with + `kSbPlayerDecoderStateNeedsData` for each required media type. + `SbPlayerDecoderStatusFunc` is the `decoder_status_func` callback function + that was specified when the player was created (SbPlayerCreate). + +`player`: The SbPlayer in which the seek operation is being performed. Must not +be `kSbPlayerInvalid`. + +`seek_to_timestamp`: The frame at which playback should begin. + +`ticket`: A user-supplied unique ID to be passed to all subsequent +`SbPlayerDecoderStatusFunc` calls. (That is the `decoder_status_func` callback +function specified when calling SbPlayerCreate.) + +The `ticket` value is used to filter calls that may have been in flight when +SbPlayerSeek was called. To be very specific, once SbPlayerSeek has been called +with ticket X, a client should ignore all `SbPlayerDecoderStatusFunc` calls that +do not pass in ticket X. + +#### Declaration + +``` +void SbPlayerSeek(SbPlayer player, int64_t seek_to_timestamp, int ticket) +``` + ### SbPlayerSetBounds Sets the player bounds to the given graphics plane coordinates. The changes do @@ -464,11 +629,18 @@ implementors should take care to avoid related performance concerns with such frequent calls. `player`: The player that is being resized. Must not be `kSbPlayerInvalid`. + `z_index`: The z-index of the player. When the bounds of multiple players are overlapped, the one with larger z-index will be rendered on top of the ones with -smaller z-index. `x`: The x-coordinate of the upper-left corner of the player. -`y`: The y-coordinate of the upper-left corner of the player. `width`: The width -of the player, in pixels. `height`: The height of the player, in pixels. +smaller z-index. + +`x`: The x-coordinate of the upper-left corner of the player. + +`y`: The y-coordinate of the upper-left corner of the player. + +`width`: The width of the player, in pixels. + +`height`: The height of the player, in pixels. #### Declaration @@ -502,9 +674,11 @@ bool SbPlayerSetPlaybackRate(SbPlayer player, double playback_rate) Sets the player's volume. `player`: The player in which the volume is being adjusted. Must not be -`kSbPlayerInvalid`. `volume`: The new player volume. The value must be between -`0.0` and `1.0`, inclusive. A value of `0.0` means that the audio should be -muted, and a value of `1.0` means that it should be played at full volume. +`kSbPlayerInvalid`. + +`volume`: The new player volume. The value must be between `0.0` and `1.0`, +inclusive. A value of `0.0` means that the audio should be muted, and a value of +`1.0` means that it should be played at full volume. #### Declaration @@ -519,8 +693,9 @@ there are no more samples for that media type for the remainder of this media stream. This marker is invalidated, along with the rest of the stream's contents, after a call to SbPlayerSeek. -`player`: The player to which the marker is written. `stream_type`: The type of -stream for which the marker is written. +`player`: The player to which the marker is written. + +`stream_type`: The type of stream for which the marker is written. #### Declaration @@ -530,14 +705,29 @@ void SbPlayerWriteEndOfStream(SbPlayer player, SbMediaType stream_type) ### SbPlayerWriteSamples +Writes samples of the given media type to `player`'s input stream. The lifetime +of `sample_infos`, and the members of its elements like `buffer`, +`video_sample_info`, and `drm_info` (as well as member `subsample_mapping` +contained inside it) are not guaranteed past the call to SbPlayerWriteSamples(). +That means that before returning, the implementation must synchronously copy any +information it wants to retain from those structures. + +SbPlayerWriteSamples() allows writing of multiple samples in one call. + +`player`: The player to which the sample is written. Must not be +`kSbPlayerInvalid`. + `sample_type`: The type of sample being written. See the `SbMediaType` enum in -media.h. `sample_infos`: A pointer to an array of SbPlayerSampleInfo with +media.h. + +`sample_infos`: A pointer to an array of SbPlayerSampleInfo with `number_of_sample_infos` elements, each holds the data for an sample, i.e. a sequence of whole NAL Units for video, or a complete audio frame. `sample_infos` cannot be assumed to live past the call into SbPlayerWriteSamples(), so it must be copied if its content will be used after SbPlayerWriteSamples() returns. + `number_of_sample_infos`: Specify the number of samples contained inside -`sample_infos`. It has to be at least one, and less than the return value of +`sample_infos`. It has to be at least one, and at most the return value of SbPlayerGetMaximumNumberOfSamplesPerWrite(). #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/socket.md b/cobalt/site/docs/reference/starboard/modules/socket.md index 744c04e3847d..beeab4fddb6e 100644 --- a/cobalt/site/docs/reference/starboard/modules/socket.md +++ b/cobalt/site/docs/reference/starboard/modules/socket.md @@ -540,15 +540,15 @@ Sets the `SO_KEEPALIVE`, or equivalent, option to `value` on `socket`. The return value indicates whether the option was actually set. `socket`: The SbSocket for which the option is set. `value`: If set to `true`, -then `period` specifies the minimum time (SbTime) is always in microseconds) -between keep-alive packets. If set to `false`, `period` is ignored. `period`: -The time between keep-alive packets. This value is only relevant if `value` is -`true`. +then `period` specifies the minimum time in microseconds between keep-alive +packets. If set to `false`, `period` is ignored. `period`: The time in +microseconds between keep-alive packets. This value is only relevant if `value` +is `true`. #### Declaration ``` -bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, SbTime period) +bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, int64_t period) ``` ### SbSocketSetTcpNoDelay diff --git a/cobalt/site/docs/reference/starboard/modules/socket_waiter.md b/cobalt/site/docs/reference/starboard/modules/socket_waiter.md index f1c6bd8b9f2f..8632f88a5f12 100644 --- a/cobalt/site/docs/reference/starboard/modules/socket_waiter.md +++ b/cobalt/site/docs/reference/starboard/modules/socket_waiter.md @@ -202,15 +202,15 @@ SbSocketWaiterWakeUp() it not called by that time. The return value indicates the reason that the socket waiter exited. This function should only be called on the thread that waits on this waiter. -`duration`: The minimum amount of time after which the socket waiter should exit -if it is not woken up before then. As with SbThreadSleep() (see thread.h), this -function may wait longer than `duration`, such as if the timeout expires while a -callback is being fired. +`duration`: The minimum amount of time in microseconds after which the socket +waiter should exit if it is not woken up before then. As with SbThreadSleep() +(see thread.h), this function may wait longer than `duration`, such as if the +timeout expires while a callback is being fired. #### Declaration ``` -SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, SbTime duration) +SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, int64_t duration) ``` ### SbSocketWaiterWakeUp diff --git a/cobalt/site/docs/reference/starboard/modules/storage.md b/cobalt/site/docs/reference/starboard/modules/storage.md index f20016113be1..f648057c6096 100644 --- a/cobalt/site/docs/reference/starboard/modules/storage.md +++ b/cobalt/site/docs/reference/starboard/modules/storage.md @@ -55,23 +55,22 @@ bool SbStorageCloseRecord(SbStorageRecord record) ### SbStorageDeleteRecord -Deletes the `SbStorageRecord` for `user` named `name`. The return value -indicates whether the record existed and was successfully deleted. If the record -did not exist or could not be deleted, the function returns `false`. +Deletes the `SbStorageRecord` named `name`. The return value indicates whether +the record existed and was successfully deleted. If the record did not exist or +could not be deleted, the function returns `false`. -If `name` is NULL, deletes the default storage record for the user, like what -would have been deleted with the previous version of SbStorageDeleteRecord. +If `name` is NULL, deletes the default storage record, like what would have been +deleted with the previous version of SbStorageDeleteRecord. -This function must not be called while the user's storage record is open. This -function performs blocking I/O on the calling thread. +This function must not be called while the storage record is open. This function +performs blocking I/O on the calling thread. -`user`: The user for whom the record will be deleted. `name`: The filesystem- -safe name of the record to open. +`name`: The filesystem-safe name of the record to open. #### Declaration ``` -bool SbStorageDeleteRecord(SbUser user, const char *name) +bool SbStorageDeleteRecord(const char *name) ``` ### SbStorageGetRecordSize @@ -99,22 +98,20 @@ static bool SbStorageIsValidRecord(SbStorageRecord record) ### SbStorageOpenRecord -Opens and returns the SbStorageRecord for `user` named `name`, blocking I/O on -the calling thread until the open is completed. If `user` is not a valid -`SbUser`, the function returns `kSbStorageInvalidRecord`. Will return an -`SbStorageRecord` of size zero if the record does not yet exist. Opening an -already-open `SbStorageRecord` has undefined behavior. +Opens and returns the SbStorageRecord named `name`, blocking I/O on the calling +thread until the open is completed. Will return an `SbStorageRecord` of size +zero if the record does not yet exist. Opening an already-open `SbStorageRecord` +has undefined behavior. -If `name` is NULL, opens the default storage record for the user, like what -would have been saved with the previous version of SbStorageOpenRecord. +If `name` is NULL, opens the default storage record, like what would have been +saved with the previous version of SbStorageOpenRecord. -`user`: The user for which the storage record will be opened. `name`: The -filesystem-safe name of the record to open. +`name`: The filesystem-safe name of the record to open. #### Declaration ``` -SbStorageRecord SbStorageOpenRecord(SbUser user, const char *name) +SbStorageRecord SbStorageOpenRecord(const char *name) ``` ### SbStorageReadRecord diff --git a/cobalt/site/docs/reference/starboard/modules/string.md b/cobalt/site/docs/reference/starboard/modules/string.md deleted file mode 100644 index 3fed809df461..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/string.md +++ /dev/null @@ -1,174 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `string.h` - -Defines functions for interacting with c-style strings. - -## Functions - -### SbStringCompareNoCase - -Compares two strings, ignoring differences in case. The return value is: - -* `< 0` if `string1` is ASCII-betically lower than `string2`. - -* `0` if the two strings are equal. - -* `> 0` if `string1` is ASCII-betically higher than `string2`. - -This function is meant to be a drop-in replacement for `strcasecmp`. - -`string1`: The first string to compare. `string2`: The second string to compare. - -#### Declaration - -``` -int SbStringCompareNoCase(const char *string1, const char *string2) -``` - -### SbStringCompareNoCaseN - -Compares the first `count` characters of two strings, ignoring differences in -case. The return value is: - -* `< 0` if `string1` is ASCII-betically lower than `string2`. - -* `0` if the two strings are equal. - -* `> 0` if `string1` is ASCII-betically higher than `string2`. - -This function is meant to be a drop-in replacement for `strncasecmp`. - -`string1`: The first string to compare. `string2`: The second string to compare. -`count`: The number of characters to compare. - -#### Declaration - -``` -int SbStringCompareNoCaseN(const char *string1, const char *string2, size_t count) -``` - -### SbStringDuplicate - -Copies `source` into a buffer that is allocated by this function and that can be -freed with SbMemoryDeallocate. This function is meant to be a drop-in -replacement for `strdup`. - -`source`: The string to be copied. - -#### Declaration - -``` -char* SbStringDuplicate(const char *source) -``` - -### SbStringFormat - -Produces a string formatted with `format` and `arguments`, placing as much of -the result that will fit into `out_buffer`. The return value specifies the -number of characters that the format would produce if `buffer_size` were -infinite. - -This function is meant to be a drop-in replacement for `vsnprintf`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `arguments`: Variable arguments used in the string. - -#### Declaration - -``` -int SbStringFormat(char *out_buffer, size_t buffer_size, const char *format, va_list arguments) SB_PRINTF_FORMAT(3 -``` - -### SbStringFormatF - -An inline wrapper of SbStringFormat that converts from ellipsis to va_args. This -function is meant to be a drop-in replacement for `snprintf`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `...`: Arguments used in the string. - -#### Declaration - -``` -int static int static int SbStringFormatF(char *out_buffer, size_t buffer_size, const char *format,...) SB_PRINTF_FORMAT(3 -``` - -### SbStringFormatUnsafeF - -An inline wrapper of SbStringFormat that is meant to be a drop-in replacement -for the unsafe but commonly used `sprintf`. - -`out_buffer`: The location where the formatted string is stored. `format`: A -string that specifies how the data should be formatted. `...`: Arguments used in -the string. - -#### Declaration - -``` -static int static int SbStringFormatUnsafeF(char *out_buffer, const char *format,...) SB_PRINTF_FORMAT(2 -``` - -### SbStringFormatWide - -This function is identical to SbStringFormat, but is for wide characters. It is -meant to be a drop-in replacement for `vswprintf`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `arguments`: Variable arguments used in the string. - -#### Declaration - -``` -int SbStringFormatWide(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format, va_list arguments) -``` - -### SbStringFormatWideF - -An inline wrapper of SbStringFormatWide that converts from ellipsis to -`va_args`. - -`out_buffer`: The location where the formatted string is stored. `buffer_size`: -The size of `out_buffer`. `format`: A string that specifies how the data should -be formatted. `...`: Arguments used in the string. - -#### Declaration - -``` -static int SbStringFormatWideF(wchar_t *out_buffer, size_t buffer_size, const wchar_t *format,...) -``` - -### SbStringScan - -Scans `buffer` for `pattern`, placing the extracted values in `arguments`. The -return value specifies the number of successfully matched items, which may be -`0`. - -This function is meant to be a drop-in replacement for `vsscanf`. - -`buffer`: The string to scan for the pattern. `pattern`: The string to search -for in `buffer`. `arguments`: Values matching `pattern` that were extracted from -`buffer`. - -#### Declaration - -``` -int SbStringScan(const char *buffer, const char *pattern, va_list arguments) -``` - -### SbStringScanF - -An inline wrapper of SbStringScan that converts from ellipsis to `va_args`. This -function is meant to be a drop-in replacement for `sscanf`. `buffer`: The string -to scan for the pattern. `pattern`: The string to search for in `buffer`. `...`: -Values matching `pattern` that were extracted from `buffer`. - -#### Declaration - -``` -static int SbStringScanF(const char *buffer, const char *pattern,...) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/thread.md b/cobalt/site/docs/reference/starboard/modules/thread.md index 56c7898a12b4..7ee1406d63c0 100644 --- a/cobalt/site/docs/reference/starboard/modules/thread.md +++ b/cobalt/site/docs/reference/starboard/modules/thread.md @@ -15,14 +15,6 @@ Well-defined value for an invalid thread context. Well-defined constant value to mean "no thread ID." -### kSbThreadLocalKeyInvalid - -Well-defined constant value to mean "no thread local key." - -### kSbThreadNoAffinity - -Well-defined constant value to mean "no affinity." - ### kSbThreadSamplerInvalid Well-defined value for an invalid thread sampler. @@ -81,28 +73,6 @@ treated less-than-or-equal-to a higher priority. ## Typedefs -### SbThread - -An opaque handle to a thread type. - -#### Definition - -``` -typedef void* SbThread -``` - -### SbThreadAffinity - -Type for thread core affinity. This generally will be a single cpu (or core or -hyperthread) identifier. Some platforms may not support affinity, and some may -have specific rules about how it must be used. - -#### Definition - -``` -typedef int32_t SbThreadAffinity -``` - ### SbThreadContext A handle to the context of a frozen thread. @@ -113,17 +83,6 @@ A handle to the context of a frozen thread. typedef SbThreadContextPrivate* SbThreadContext ``` -### SbThreadEntryPoint - -Function pointer type for SbThreadCreate. `context` is a pointer-sized bit of -data passed in from the calling thread. - -#### Definition - -``` -typedef void*(* SbThreadEntryPoint) (void *context) -``` - ### SbThreadId An ID type that is unique per thread. @@ -134,26 +93,6 @@ An ID type that is unique per thread. typedef int32_t SbThreadId ``` -### SbThreadLocalDestructor - -Function pointer type for Thread-Local destructors. - -#### Definition - -``` -typedef void(* SbThreadLocalDestructor) (void *value) -``` - -### SbThreadLocalKey - -A handle to a thread-local key. - -#### Definition - -``` -typedef SbThreadLocalKeyPrivate* SbThreadLocalKey -``` - ### SbThreadSampler A handle to a thread sampler. @@ -188,95 +127,6 @@ Returns whether the given thread context is valid. static bool SbThreadContextIsValid(SbThreadContext context) ``` -### SbThreadCreate - -Creates a new thread, which starts immediately. - -* If the function succeeds, the return value is a handle to the newly created - thread. - -* If the function fails, the return value is `kSbThreadInvalid`. - -`stack_size`: The amount of memory reserved for the thread. Set the value to `0` -to indicate that the default stack size should be used. `priority`: The thread's -priority. This value can be set to `kSbThreadNoPriority` to use the platform's -default priority. As examples, it could be set to a fixed, standard priority or -to a priority inherited from the thread that is calling SbThreadCreate(), or to -something else. `affinity`: The thread's affinity. This value can be set to -`kSbThreadNoAffinity` to use the platform's default affinity. `joinable`: -Indicates whether the thread can be joined (`true`) or should start out -"detached" (`false`). Note that for joinable threads, when you are done with the -thread handle, you must call `SbThreadJoin` to release system resources -associated with the thread. This is not necessary for detached threads, but -detached threads cannot be joined. `name`: A name used to identify the thread. -This value is used mainly for debugging, it can be `NULL`, and it might not be -used in production builds. `entry_point`: A pointer to a function that will be -executed on the newly created thread. `context`: This value will be passed to -the `entry_point` function. - -#### Declaration - -``` -SbThread SbThreadCreate(int64_t stack_size, SbThreadPriority priority, SbThreadAffinity affinity, bool joinable, const char *name, SbThreadEntryPoint entry_point, void *context) -``` - -### SbThreadCreateLocalKey - -Creates and returns a new, unique key for thread local data. If the function -does not succeed, the function returns `kSbThreadLocalKeyInvalid`. - -If `destructor` is specified, it will be called in the owning thread, and only -in the owning thread, when the thread exits. In that case, it is called on the -local value associated with the key in the current thread as long as the local -value is not NULL. - -`destructor`: A pointer to a function. The value may be NULL if no clean up is -needed. - -#### Declaration - -``` -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) -``` - -### SbThreadDestroyLocalKey - -Destroys thread local data for the specified key. The function is a no-op if the -key is invalid (kSbThreadLocalKeyInvalid`) or has already been destroyed. This -function does NOT call the destructor on any stored values. - -`key`: The key for which to destroy thread local data. - -#### Declaration - -``` -void SbThreadDestroyLocalKey(SbThreadLocalKey key) -``` - -### SbThreadDetach - -Detaches `thread`, which prevents it from being joined. This is sort of like a -non-blocking join. This function is a no-op if the thread is already detached or -if the thread is already being joined by another thread. - -`thread`: The thread to be detached. - -#### Declaration - -``` -void SbThreadDetach(SbThread thread) -``` - -### SbThreadGetCurrent - -Returns the handle of the currently executing thread. - -#### Declaration - -``` -SbThread SbThreadGetCurrent() -``` - ### SbThreadGetId Returns the Thread ID of the currently executing thread. @@ -287,72 +137,14 @@ Returns the Thread ID of the currently executing thread. SbThreadId SbThreadGetId() ``` -### SbThreadGetLocalValue - -Returns the pointer-sized value for `key` in the currently executing thread's -local storage. Returns `NULL` if key is `kSbThreadLocalKeyInvalid` or if the key -has already been destroyed. - -`key`: The key for which to return the value. - -#### Declaration - -``` -void* SbThreadGetLocalValue(SbThreadLocalKey key) -``` - -### SbThreadGetName - -Returns the debug name of the currently executing thread. - -#### Declaration - -``` -void SbThreadGetName(char *buffer, int buffer_size) -``` - -### SbThreadIsCurrent - -Returns whether `thread` is the current thread. - -`thread`: The thread to check. - -#### Declaration - -``` -static bool SbThreadIsCurrent(SbThread thread) -``` - -### SbThreadIsEqual - -Indicates whether `thread1` and `thread2` refer to the same thread. - -`thread1`: The first thread to compare. `thread2`: The second thread to compare. - -#### Declaration - -``` -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) -``` - -### SbThreadIsValid - -Returns whether the given thread handle is valid. - -#### Declaration - -``` -static bool SbThreadIsValid(SbThread thread) -``` - -### SbThreadIsValidAffinity +### SbThreadGetPriority -Returns whether the given thread affinity is valid. +Get the thread priority of the current thread. #### Declaration ``` -static bool SbThreadIsValidAffinity(SbThreadAffinity affinity) +bool SbThreadGetPriority(SbThreadPriority *priority) ``` ### SbThreadIsValidId @@ -365,16 +157,6 @@ Returns whether the given thread ID is valid. static bool SbThreadIsValidId(SbThreadId id) ``` -### SbThreadIsValidLocalKey - -Returns whether the given thread local variable key is valid. - -#### Declaration - -``` -static bool SbThreadIsValidLocalKey(SbThreadLocalKey key) -``` - ### SbThreadIsValidPriority Returns whether the given thread priority is valid. @@ -385,30 +167,6 @@ Returns whether the given thread priority is valid. static bool SbThreadIsValidPriority(SbThreadPriority priority) ``` -### SbThreadJoin - -Joins the thread on which this function is called with joinable `thread`. This -function blocks the caller until the designated thread exits, and then cleans up -that thread's resources. The cleanup process essentially detaches thread. - -The return value is `true` if the function is successful and `false` if `thread` -is invalid or detached. - -Each joinable thread can only be joined once and must be joined to be fully -cleaned up. Once SbThreadJoin is called, the thread behaves as if it were -detached to all threads other than the joining thread. - -`thread`: The thread to which the current thread will be joined. The `thread` -must have been created with SbThreadCreate. `out_return`: If this is not `NULL`, -then the SbThreadJoin function populates it with the return value of the -thread's `main` function. - -#### Declaration - -``` -bool SbThreadJoin(SbThread thread, void **out_return) -``` - ### SbThreadSamplerCreate Creates a new thread sampler for the specified `thread`. @@ -419,7 +177,7 @@ this function returns `kSbThreadSamplerInvalid`. #### Declaration ``` -SbThreadSampler SbThreadSamplerCreate(SbThread thread) +SbThreadSampler SbThreadSamplerCreate(pthread_t thread) ``` ### SbThreadSamplerDestroy @@ -480,54 +238,12 @@ the context returned from `SbThreadSamplerFreeze`. bool SbThreadSamplerThaw(SbThreadSampler sampler) ``` -### SbThreadSetLocalValue - -Sets the pointer-sized value for `key` in the currently executing thread's local -storage. The return value indicates whether `key` is valid and has not already -been destroyed. - -`key`: The key for which to set the key value. `value`: The new pointer-sized -key value. - -#### Declaration - -``` -bool SbThreadSetLocalValue(SbThreadLocalKey key, void *value) -``` - -### SbThreadSetName - -Sets the debug name of the currently executing thread by copying the specified -name string. - -`name`: The name to assign to the thread. - -#### Declaration - -``` -void SbThreadSetName(const char *name) -``` - -### SbThreadSleep - -Sleeps the currently executing thread. - -`duration`: The minimum amount of time, in microseconds, that the currently -executing thread should sleep. The function is a no-op if this value is negative -or `0`. - -#### Declaration - -``` -void SbThreadSleep(SbTime duration) -``` - -### SbThreadYield +### SbThreadSetPriority -Yields the currently executing thread, so another thread has a chance to run. +Set the thread priority of the current thread. #### Declaration ``` -void SbThreadYield() +bool SbThreadSetPriority(SbThreadPriority priority) ``` diff --git a/cobalt/site/docs/reference/starboard/modules/time.md b/cobalt/site/docs/reference/starboard/modules/time.md deleted file mode 100644 index a6228cc0de6c..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/time.md +++ /dev/null @@ -1,152 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `time.h` - -Provides access to system time and timers. - -## Macros - -### kSbTimeDay - -One day in SbTime units (microseconds). - -### kSbTimeHour - -One hour in SbTime units (microseconds). - -### kSbTimeMax - -The maximum value of an SbTime. - -### kSbTimeMillisecond - -One millisecond in SbTime units (microseconds). - -### kSbTimeMinute - -One minute in SbTime units (microseconds). - -### kSbTimeNanosecondsPerMicrosecond - -How many nanoseconds in one SbTime unit (microseconds). - -### kSbTimeSecond - -One second in SbTime units (microseconds). - -### kSbTimeToPosixDelta - -A term that can be added to an SbTime to convert it into the number of -microseconds since the POSIX epoch. - -## Typedefs - -### SbTime - -The number of microseconds since the epoch of January 1, 1601 UTC, or the number -of microseconds between two times. Always microseconds, ALWAYS UTC. - -#### Definition - -``` -typedef int64_t SbTime -``` - -### SbTimeMonotonic - -A number of microseconds from some point. The main property of this time is that -it increases monotonically. It should also be as high-resolution a timer as we -can get on a platform. So, it is good for measuring the time between two calls -without worrying about a system clock adjustment. It's not good for getting the -wall clock time. - -#### Definition - -``` -typedef int64_t SbTimeMonotonic -``` - -## Functions - -### SbTimeFromPosix - -Converts microseconds from the POSIX epoch into an `SbTime`. - -`time`: A time that measures the number of microseconds since January 1, 1970, -00:00:00, UTC. - -#### Declaration - -``` -static SbTime SbTimeFromPosix(int64_t time) -``` - -### SbTimeGetMonotonicNow - -Gets a monotonically increasing time representing right now. - -#### Declaration - -``` -SbTimeMonotonic SbTimeGetMonotonicNow() -``` - -### SbTimeGetMonotonicThreadNow - -Gets a monotonically increasing time representing how long the current thread -has been in the executing state (i.e. not pre-empted nor waiting on an event). -This is not necessarily total time and is intended to allow measuring thread -execution time between two timestamps. If this is not available then -SbTimeGetMonotonicNow() should be used. - -#### Declaration - -``` -SbTimeMonotonic SbTimeGetMonotonicThreadNow() -``` - -### SbTimeGetNow - -Gets the current system time as an `SbTime`. - -#### Declaration - -``` -SbTime SbTimeGetNow() -``` - -### SbTimeIsTimeThreadNowSupported - -Returns whether the current platform supports time thread now - -#### Declaration - -``` -bool SbTimeIsTimeThreadNowSupported() -``` - -### SbTimeNarrow - -Safely narrows a number from a more precise unit to a less precise one. This -function rounds negative values toward negative infinity. - -#### Declaration - -``` -static int64_t SbTimeNarrow(int64_t time, int64_t divisor) -``` - -### SbTimeToPosix - -Converts `SbTime` into microseconds from the POSIX epoch. - -`time`: A time that is either measured in microseconds since the epoch of -January 1, 1601, UTC, or that measures the number of microseconds between two -times. - -#### Declaration - -``` -static int64_t SbTimeToPosix(SbTime time) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/time_zone.md b/cobalt/site/docs/reference/starboard/modules/time_zone.md index 74d48172d63e..baad3759ac4b 100644 --- a/cobalt/site/docs/reference/starboard/modules/time_zone.md +++ b/cobalt/site/docs/reference/starboard/modules/time_zone.md @@ -12,7 +12,7 @@ Provides access to the system time zone information. The number of minutes west of the Greenwich Prime Meridian, NOT including Daylight Savings Time adjustments. -For example: PST/PDT is 480 minutes (28800 seconds, 8 hours). +For example: America/Los_Angeles is 480 minutes (28800 seconds, 8 hours). #### Definition @@ -34,11 +34,11 @@ SbTimeZone SbTimeZoneGetCurrent() ### SbTimeZoneGetName -Gets a string representation of the current timezone. Note that the string -representation can either be standard or daylight saving time. The output can be -of the form: 1) A three-letter abbreviation such as "PST" or "PDT" (preferred). -2) A time zone identifier such as "America/Los_Angeles" 3) An un-abbreviated -name such as "Pacific Standard Time". +Gets a string representation of the current timezone. The format should be in +the IANA format [https://data.iana.org/time-zones/theory.html#naming](https://data.iana.org/time-zones/theory.html#naming)) . +Names normally have the form AREA/LOCATION, where AREA is a continent or ocean, +and LOCATION is a specific location within the area. Typical names are +'Africa/Cairo', 'America/New_York', and 'Pacific/Honolulu'. #### Declaration diff --git a/cobalt/site/docs/reference/starboard/modules/ui_navigation.md b/cobalt/site/docs/reference/starboard/modules/ui_navigation.md deleted file mode 100644 index cb4176713005..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/ui_navigation.md +++ /dev/null @@ -1,322 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `ui_navigation.h` - -API to allow applications to take advantage of the platform's native UI engine. -This is mainly to drive the animation of visual elements and to signal which of -those elements have focus. The implementation should not render any visual -elements; instead, it will be used to guide the app in where these elements -should be drawn. - -When the application creates the user interface, it will create SbUiNavItems for -interactable elements. Additionally, the app must specify the position and size -of these navigation items. As the app's user interface changes, it will create -and destroy navigation items as appropriate. - -For each render frame, the app will query the local transform for each -SbUiNavItem in case the native UI engine moves individual items in response to -user interaction. If the navigation item is a container, then the content offset -will also be queried to determine the placement of its content items. - -## Macros - -### kSbUiNavItemInvalid - -Well-defined value for an invalid navigation item. - -## Enums - -### SbUiNavItemType - -Navigation items may be one of the following types. This must be specified upon -item creation and may not change during the item's lifespan. - -#### Values - -* `kSbUiNavItemTypeFocus` - - This is a single focusable item. -* `kSbUiNavItemTypeContainer` - - This is a container of navigation items which can also be containers - themselves or focusable items. Containers themselves cannot be focused. - -## Typedefs - -### SbUiNavItem - -An opaque handle to an implementation-private structure representing a -navigation item. - -#### Definition - -``` -typedef struct SbUiNavItemPrivate* SbUiNavItem -``` - -## Structs - -### SbUiNavCallbacks - -This structure specifies all the callbacks which the platform UI engine should -invoke for various interaction events on navigation items. These callbacks may -be invoked from any thread at any frequency. The `callback_context` is the value -that was passed on creation of the relevant SbUiNavItem. - -#### Members - -* `void(*onblur)(SbUiNavItem item, void *callback_context)` - - Invoke when an item has lost focus. This is only used with focus items. -* `void(*onfocus)(SbUiNavItem item, void *callback_context)` - - Invoke when an item has gained focus. This is only used with focus items. -* `void(*onscroll)(SbUiNavItem item, void *callback_context)` - - Invoke when an item's content offset is changed. This is only used with - container items. - -### SbUiNavInterface - -This structure declares the interface to the UI navigation implementation. All -function pointers must be specified if the platform supports UI navigation. - -#### Members - -* `SbUiNavItem(*create_item)(SbUiNavItemType type, const SbUiNavCallbacks - *callbacks, void *callback_context)` - - Create a new navigation item. When the user interacts with this item the - appropriate SbUiNavCallbacks function will be invoked with the provided - `callback_context`. An item is not interactable until it is enabled. -* `void(*destroy_item)(SbUiNavItem item)` - - Destroy the given navigation item. If this is a content of another item, - then it will first be unregistered. Additionally, if this item contains - other items, then those will be unregistered as well, but they will not be - automatically destroyed. -* `void(*set_focus)(SbUiNavItem item)` - - This is used to manually force focus on a navigation item of type - kSbUiNavItemTypeFocus. Any previously focused navigation item should receive - the blur event. If the item is not transitively a content of the root item, - then this does nothing. - - Specifying kSbUiNavItemInvalid should remove focus from the UI navigation - system. -* `void(*set_item_enabled)(SbUiNavItem item, bool enabled)` - - This is used to enable or disable user interaction with the specified - navigation item. All navigation items are disabled when created, and they - must be explicitly enabled to allow user interaction. If a container is - disabled, then all of its contents are not interactable even though they - remain enabled. If `enabled` is false, it must be guaranteed that once this - function returns, no callbacks associated with this item will be invoked - until the item is re-enabled. -* `void(*set_item_dir)(SbUiNavItem item, SbUiNavItemDir dir)` - - This specifies directionality for container items. Containers within - containers do not inherit directionality. Directionality must be specified - for each container explicitly. - - This should work even if `item` is disabled. -* `void(*set_item_focus_duration)(SbUiNavItem item, float seconds)` - - Set the minimum amount of time the focus item should remain focused once it - becomes focused. This may be used to make important focus items harder to - navigate over. Focus may still be moved before `seconds` has elapsed by - using the set_focus() function. By default, item focus duration is 0 - seconds. -* `void(*set_item_size)(SbUiNavItem item, float width, float height)` - - Set the interactable size of the specified navigation item. By default, an - item's size is (0,0). -* `void(*set_item_transform)(SbUiNavItem item, const SbUiNavMatrix2x3 - *transform)` - - Set the transform for the navigation item and its contents if the item is a - container. This specifies the placement of the item's center within its - container. The transform origin is the center of the item. Distance is - measured in pixels with the origin being the top-left of the item's - container. By default, an item's transform is identity. -* `bool(*get_item_focus_transform)(SbUiNavItem item, SbUiNavMatrix4 - *out_transform)` - - Retrieve the focus transform matrix for the navigation item. The UI engine - may translate, rotate, and/or tilt focus items to reflect user interaction. - This transform should be multiplied with the item's transform to get its - position inside its container. The transform origin is the center of the - item. Return false if the item position should not be changed (i.e. the - transform should be treated as identity). -* `bool(*get_item_focus_vector)(SbUiNavItem item, float *out_x, float *out_y)` - - Retrieve a vector representing the focus location within a focused item. - This is used to provide feedback about user input that is too small to - result in a focus change. If there is no focus vector for the navigation - item, then return false and leave `out_x` and `out_y` unchanged. Otherwise, - return true and set the output values in the range of [-1, +1] with (out_x, - out_y) of (-1, -1) being the top-left corner of the navigation item and (0, - 0) being the center. -* `void(*set_item_container_window)(SbUiNavItem item, SbWindow window)` - - This attaches the given navigation item (which must be a container) to the - specified window. Navigation items are only interactable if they are - transitively attached to a window. - - The native UI engine should never change this navigation item's content - offset. It is assumed to be used as a proxy for the system window. - - A navigation item may only have a SbUiNavItem or SbWindow as its direct - container. The navigation item hierarchy is established using - set_item_container_item() with the root container attached to a SbWindow - using set_item_container_window() to enable interaction with all enabled - items in the hierarchy. - - If `item` is already registered with a different window, then this will - unregister it from that window then attach it to the given `window`. It is - an error to register more than one navigation item with any given window. If - `window` is kSbWindowInvalid, then this will unregister the `item` from its - current window if any. Upon destruction of `item` or `window`, the `item` is - automatically unregistered from the `window`. -* `void(*set_item_container_item)(SbUiNavItem item, SbUiNavItem container)` - - A container navigation item may contain other navigation items. However, it - is an error to have circular containment or for `container` to not be of - type kSbUiNavItemTypeContainer. If `item` already has a different container, - then this first serves that connection. If `container` is - kSbUiNavItemInvalid, then this removes `item` from its current container. - Upon destruction of `item` or `container`, the `item` is automatically - removed from the `container`. - - The position of items within a container are specified relative to the - container's position. The position of these content items are further - modified by the container's "content offset". - - For example, consider item A with position (5,5) and content offset (0,0). - Given item B with position (10,10) is registered as a content of item A. - - 1) Item B should be drawn at position (15,15). - - 2) If item A's content offset is changed to (10,0), then item B should be - drawn at position (5,15). - - Essentially, content items should be drawn at: [container position] + - [content position] - [container content offset] - - Content items may overlap within a container. This can cause obscured items - to be unfocusable. The only rule that needs to be followed is that contents - which are focus items can obscure other contents which are containers, but - not vice versa. The caller must ensure that content focus items do not - overlap other content focus items and content container items do not overlap - other content container items. -* `void(*set_item_content_offset)(SbUiNavItem item, float content_offset_x, - float content_offset_y)` - - Set the current content offset for the given container. This may be used to - force scrolling to make certain content items visible. A container item's - content offset helps determine where its content items should be drawn. - Essentially, a content item should be drawn at: [container position] + - [content position] - [container content offset] If `item` is not a - container, then this does nothing. By default, the content offset is (0,0). - - This should update the values returned by get_item_content_offset() even if - the `item` is disabled. -* `void(*get_item_content_offset)(SbUiNavItem item, float - *out_content_offset_x, float *out_content_offset_y)` - - Retrieve the current content offset for the navigation item. If `item` is - not a container, then the content offset is (0,0). - - The native UI engine should not change the content offset of a container - unless one of its contents (possibly recursively) is focused. This is to - allow seamlessly disabling then re-enabling focus items without having their - containers change offsets. -* `void(*do_batch_update)(void(*update_function)(void *), void *context)` - - Call `update_function` with `context` to perform a series of UI navigation - changes atomically before returning. - -### SbUiNavItemDir - -Navigation items of type kSbUiNavItemTypeContainer have directionality. If -directionality is not specified for a container, it should default to left-to- -right and top-to-bottom. - -``` -/// For left-to-right, content offset x = 0 shows the leftmost content. -/// |<--Container Size-->| -/// +--------------------+--------------------+--------------------+ -/// | Not selectable. | Selectable. | Selectable. | -/// | Offscreen. | Onscreen. | Offscreen. | -/// | Negative position. | Positive position. | Positive position. | -/// +--------------------+--------------------+--------------------+ -/// ^ -/// Content Offset X = 0. -/// -/// For right-to-left, content offset x = 0 shows the rightmost content. -/// |<--Container Size-->| -/// +--------------------+--------------------+--------------------+ -/// | Selectable. | Selectable. | Not selectable. | -/// | Offscreen. | Onscreen. | Offscreen. | -/// | Negative position. | Positive position. | Positive position. | -/// +--------------------+--------------------+--------------------+ -/// ^ -/// Content Offset X = 0. -``` - -``` - Top-to-bottom is similar to left-to-right, but for the Y position. - Bottom-to-top is similar to right-to-left, but for the Y position. -``` - -#### Members - -* `bool is_left_to_right` -* `bool is_top_to_bottom` - -### SbUiNavMatrix2x3 - -This represents a 2x3 transform matrix in row-major order. - -``` -/// | a b tx | -/// | c d ty | -``` - -#### Members - -* `float m` - -### SbUiNavMatrix4 - -This represents a 4x4 transform matrix in row-major order. - -#### Members - -* `float m` - -## Functions - -### SbUiNavGetInterface - -Retrieve the platform's UI navigation implementation. If the platform does not -provide one, then return false without modifying `out_interface`. Otherwise, -initialize all members of `out_interface` and return true. The `out_interface` -pointer must not be NULL. - -#### Declaration - -``` -bool SbUiNavGetInterface(SbUiNavInterface *out_interface) -``` - -### SbUiNavItemIsValid - -Returns whether the given navigation item handle is valid. - -#### Declaration - -``` -static bool SbUiNavItemIsValid(SbUiNavItem item) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/user.md b/cobalt/site/docs/reference/starboard/modules/user.md deleted file mode 100644 index 309b939d066e..000000000000 --- a/cobalt/site/docs/reference/starboard/modules/user.md +++ /dev/null @@ -1,133 +0,0 @@ -Project: /youtube/cobalt/_project.yaml -Book: /youtube/cobalt/_book.yaml - -# Starboard Module Reference: `user.h` - -Defines a user management API. This module defines functions only for managing -signed-in users. Platforms that do not have users must still implement this API, -always reporting a single user that is current and signed in. - -These APIs are NOT expected to be thread-safe, so either call them from a single -thread, or perform proper synchronization around all calls. - -## Macros - -### kSbUserInvalid - -Well-defined value for an invalid user. - -## Enums - -### SbUserPropertyId - -A set of string properties that can be queried on a user. - -#### Values - -* `kSbUserPropertyAvatarUrl` - - The URL to the avatar for a user. Avatars are not provided on all platforms. -* `kSbUserPropertyHomeDirectory` - - The path to a user's home directory, if supported on this platform. -* `kSbUserPropertyUserName` - - The username of a user, which may be the same as the User ID, or it may be - friendlier. -* `kSbUserPropertyUserId` - - A unique user ID of a user. - -## Typedefs - -### SbUser - -A handle to a user. - -#### Definition - -``` -typedef SbUserPrivate* SbUser -``` - -## Functions - -### SbUserGetCurrent - -Gets the current primary user, if one exists. This is the user that is -determined, in a platform-specific way, to be the primary user controlling the -application. For example, the determination might be made because that user -launched the app, though it should be made using whatever criteria are -appropriate for the platform. - -It is expected that there will be a unique SbUser per signed-in user, and that -the referenced objects will persist for the lifetime of the app. - -#### Declaration - -``` -SbUser SbUserGetCurrent() -``` - -### SbUserGetProperty - -Retrieves the value of `property_id` for `user` and places it in `out_value`. -The function returns: - -* `true` if the property value is retrieved successfully - -* `false` if `user` is invalid; if `property_id` isn't recognized, supported, - or set for `user`; or if `value_size` is too small. - -`user`: The user for which property size data is being retrieved. `property_id`: -The property for which the data is requested. `out_value`: The retrieved -property value. `value_size`: The size of the retrieved property value. - -#### Declaration - -``` -bool SbUserGetProperty(SbUser user, SbUserPropertyId property_id, char *out_value, int value_size) -``` - -### SbUserGetPropertySize - -Returns the size of the value of `property_id` for `user`, INCLUDING the -terminating null character. The function returns `0` if `user` is invalid or if -`property_id` is not recognized, supported, or set for the user. - -`user`: The user for which property size data is being retrieved. `property_id`: -The property for which the data is requested. - -#### Declaration - -``` -int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id) -``` - -### SbUserGetSignedIn - -Gets a list of up to `users_size` signed-in users and places the results in -`out_users`. The return value identifies the actual number of signed-in users, -which may be greater or less than `users_size`. - -It is expected that there will be a unique `SbUser` per signed-in user and that -the referenced objects will persist for the lifetime of the app. - -`out_users`: Handles for the retrieved users. `users_size`: The maximum number -of signed-in users to retrieve. - -#### Declaration - -``` -int SbUserGetSignedIn(SbUser *out_users, int users_size) -``` - -### SbUserIsValid - -Returns whether the given user handle is valid. - -#### Declaration - -``` -static bool SbUserIsValid(SbUser user) -``` diff --git a/cobalt/site/docs/reference/starboard/modules/window.md b/cobalt/site/docs/reference/starboard/modules/window.md index 25845315aed4..d652524e40f8 100644 --- a/cobalt/site/docs/reference/starboard/modules/window.md +++ b/cobalt/site/docs/reference/starboard/modules/window.md @@ -7,11 +7,6 @@ Provides functionality to handle Window creation and management. ## Macros -### kSbEventOnScreenKeyboardInvalidTicket - -System-triggered OnScreenKeyboard events have ticket value -kSbEventOnScreenKeyboardInvalidTicket. - ### kSbWindowInvalid Well-defined value for an invalid window handle. @@ -48,18 +43,6 @@ Options that can be requested at window creation time. The name of the window to create. -### SbWindowRect - -Defines a rectangle via a point `(x, y)` and a size `(width, height)`. This -structure is used as output for SbWindowGetOnScreenKeyboardBoundingRect. - -#### Members - -* `float x` -* `float y` -* `float width` -* `float height` - ### SbWindowSize The size of a window in graphics rendering coordinates. The width and height of diff --git a/cobalt/site/scripts/cobalt_module_reference.py b/cobalt/site/scripts/cobalt_module_reference.py index 8cd3798b1df3..c3aa69b0937b 100644 --- a/cobalt/site/scripts/cobalt_module_reference.py +++ b/cobalt/site/scripts/cobalt_module_reference.py @@ -40,7 +40,7 @@ _SCRIPT_FILE = os.path.basename(__file__) _SCRIPT_NAME, _ = os.path.splitext(_SCRIPT_FILE) -_OSS_STARBOARD_VERSIONS = [13, 14, 15] +_OSS_STARBOARD_VERSIONS = [14, 15, 16] def _strip(string_or_none): @@ -198,12 +198,12 @@ def _node_to_markdown(out, node): out.unordered_list() elif node.tag == 'listitem': out.item() - elif node.tag == 'heading': + elif node.tag in ['heading', 'title']: # Block tags should never be nested inside other blocks. assert not _strip(tail) try: levels = int(node.get('level')) - except ValueError: + except (ValueError, TypeError): levels = 1 out.heading(levels=levels) elif node.tag == 'verbatim': @@ -228,7 +228,7 @@ def _node_to_markdown(out, node): out.end_link() elif node.tag in ['orderedlist', 'itemizedlist']: out.end_list() - elif node.tag == 'heading': + elif node.tag in ['heading', 'title']: out.end_heading() out.pop_heading_level() elif node.tag == 'listitem': diff --git a/cobalt/speech/microphone_starboard.cc b/cobalt/speech/microphone_starboard.cc index 0f7350637f26..e9e5dee0622b 100644 --- a/cobalt/speech/microphone_starboard.cc +++ b/cobalt/speech/microphone_starboard.cc @@ -14,8 +14,6 @@ #include "cobalt/speech/microphone_starboard.h" -#include "starboard/common/log.h" - namespace cobalt { namespace speech { diff --git a/cobalt/speech/speech_synthesis.cc b/cobalt/speech/speech_synthesis.cc index 27daed8c45c9..b3cd079ab09b 100644 --- a/cobalt/speech/speech_synthesis.cc +++ b/cobalt/speech/speech_synthesis.cc @@ -16,6 +16,7 @@ #include +#include "base/logging.h" #include "cobalt/dom/navigator.h" #include "starboard/speech_synthesis.h" @@ -120,8 +121,8 @@ void SpeechSynthesis::Speak( return; } - SB_DLOG(INFO) << "Speaking: \"" << utterance->text() << "\" " - << utterance->lang(); + DLOG(INFO) << "Speaking: \"" << utterance->text() << "\" " + << utterance->lang(); SbSpeechSynthesisSpeak(utterance->text().c_str()); utterance->DispatchStartEvent(); utterance->DispatchEndEvent(); diff --git a/cobalt/speech/url_fetcher_fake.cc b/cobalt/speech/url_fetcher_fake.cc index 02f5e010bfc3..c35fd5f9b941 100644 --- a/cobalt/speech/url_fetcher_fake.cc +++ b/cobalt/speech/url_fetcher_fake.cc @@ -24,7 +24,6 @@ #include "cobalt/network/custom/url_fetcher_response_writer.h" #include "cobalt/speech/google_streaming_api.pb.h" #include "net/base/io_buffer.h" -#include "starboard/common/log.h" namespace cobalt { namespace speech { diff --git a/cobalt/system_window/system_window.cc b/cobalt/system_window/system_window.cc index 76f77f6b025b..9c62f222b8a1 100644 --- a/cobalt/system_window/system_window.cc +++ b/cobalt/system_window/system_window.cc @@ -20,9 +20,9 @@ #include "base/logging.h" #include "base/strings/stringprintf.h" +#include "base/time/time.h" #include "cobalt/base/event_dispatcher.h" #include "cobalt/system_window/input_event.h" -#include "starboard/common/time.h" #include "starboard/system.h" namespace cobalt { @@ -123,7 +123,7 @@ void SystemWindow::DispatchInputEvent(const SbEvent* event, // Use the current time unless it was overridden. int64_t timestamp = event->timestamp; if (timestamp == 0) { - timestamp = starboard::CurrentMonotonicTime(); + timestamp = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); } // Starboard handily uses the Microsoft key mapping, which is also what Cobalt // uses. @@ -265,7 +265,7 @@ void HandleInputEvent(const SbEvent* event) { if (g_the_window != nullptr) { g_the_window->HandleInputEvent(event); } else { - SB_LOG(ERROR) << "Missing SystemWindow"; + LOG(ERROR) << "Missing SystemWindow"; } return; } diff --git a/cobalt/tools/automated_testing/cobalt_runner.py b/cobalt/tools/automated_testing/cobalt_runner.py index be7716995691..b57558899f16 100644 --- a/cobalt/tools/automated_testing/cobalt_runner.py +++ b/cobalt/tools/automated_testing/cobalt_runner.py @@ -135,24 +135,39 @@ def __init__(self, self.launcher_params = launcher_params self.log_handler = log_handler self.poll_until_wait_seconds = poll_until_wait_seconds + self.target_params = target_params + self.success_message = success_message if log_file: self.log_file = open(log_file, encoding='utf-8') # pylint: disable=consider-using-with logging.basicConfig(stream=self.log_file, level=logging.INFO) else: self.log_file = sys.stdout + + if self.launcher_params.target_params: + for target_param in self.launcher_params.target_params: + if target_param not in self.target_params: + self.target_params.append(target_param) + if url: self.url = url - self.target_params = target_params - self.success_message = success_message - if hasattr(self, 'url'): url_string = '--url=' + self.url if not self.target_params: self.target_params = [url_string] else: self.target_params.append(url_string) - if self.launcher_params.target_params: - self.target_params.extend(self.launcher_params.target_params) + + if url.startswith('http://'): + url_base = 'http://' + url.split('/')[2] + found = False + for (i, p) in enumerate(self.target_params): + if p.startswith('--unsafely-treat-insecure-origin-as-secure='): + found = True + self.target_params[i] += ';' + url_base + break + if not found: + self.target_params.append( + f'--unsafely-treat-insecure-origin-as-secure={url_base}') def SendResume(self): """Sends a resume signal to start Cobalt from preload.""" diff --git a/cobalt/trace_event/json_file_outputter.cc b/cobalt/trace_event/json_file_outputter.cc index a2ddd7660c51..5d63e88898c0 100644 --- a/cobalt/trace_event/json_file_outputter.cc +++ b/cobalt/trace_event/json_file_outputter.cc @@ -30,7 +30,6 @@ #endif #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" -#include "starboard/common/string.h" namespace cobalt { namespace trace_event { diff --git a/cobalt/updater/configurator.h b/cobalt/updater/configurator.h index 24b5f8064fdf..feea9ba1fee0 100644 --- a/cobalt/updater/configurator.h +++ b/cobalt/updater/configurator.h @@ -7,6 +7,7 @@ #include +#include #include #include #include @@ -114,7 +115,7 @@ class Configurator : public update_client::Configurator { std::string user_agent_string_; uint64_t min_free_space_bytes_ = 48 * 1024 * 1024; base::Lock min_free_space_bytes_lock_; - starboard::atomic_bool use_compressed_updates_; + std::atomic_bool use_compressed_updates_; DISALLOW_COPY_AND_ASSIGN(Configurator); }; diff --git a/cobalt/updater/crash_sandbox.cc b/cobalt/updater/crash_sandbox.cc index 4ef31a2bc5ac..b21f07b94d1c 100644 --- a/cobalt/updater/crash_sandbox.cc +++ b/cobalt/updater/crash_sandbox.cc @@ -14,7 +14,6 @@ // This is a test app for Evergreen that does nothing but crashes. -#include "starboard/common/log.h" #include "starboard/event.h" void SbEventHandle(const SbEvent* event) { diff --git a/cobalt/updater/unzipper.cc b/cobalt/updater/unzipper.cc index 71e8c0319b45..211de33f228d 100644 --- a/cobalt/updater/unzipper.cc +++ b/cobalt/updater/unzipper.cc @@ -10,7 +10,6 @@ #include "base/files/file_path.h" #include "base/logging.h" #include "base/time/time.h" -#include "starboard/common/time.h" #include "third_party/zlib/google/zip.h" namespace cobalt { @@ -24,10 +23,10 @@ class UnzipperImpl : public update_client::Unzipper { void Unzip(const base::FilePath& zip_path, const base::FilePath& output_path, UnzipCompleteCallback callback) override { - int64_t time_before_unzip = starboard::CurrentMonotonicTime(); + int64_t time_before_unzip = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); std::move(callback).Run(zip::Unzip(zip_path, output_path)); int64_t time_unzip_took_usec = - starboard::CurrentMonotonicTime() - time_before_unzip; + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() - time_before_unzip; LOG(INFO) << "Unzip file path = " << zip_path; LOG(INFO) << "output_path = " << output_path; LOG(INFO) << "Unzip took " @@ -38,10 +37,10 @@ class UnzipperImpl : public update_client::Unzipper { #if defined(IN_MEMORY_UPDATES) void Unzip(const std::string& zip_str, const base::FilePath& output_path, UnzipCompleteCallback callback) override { - int64_t time_before_unzip = starboard::CurrentMonotonicTime(); + int64_t time_before_unzip = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); std::move(callback).Run(zip::Unzip(zip_str, output_path)); int64_t time_unzip_took_usec = - starboard::CurrentMonotonicTime() - time_before_unzip; + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() - time_before_unzip; LOG(INFO) << "Unzip from string"; LOG(INFO) << "output_path = " << output_path; LOG(INFO) << "Unzip took " diff --git a/cobalt/updater/updater_module.cc b/cobalt/updater/updater_module.cc index 5de4bb6feead..5fc41d32f72d 100644 --- a/cobalt/updater/updater_module.cc +++ b/cobalt/updater/updater_module.cc @@ -39,7 +39,6 @@ #include "components/crx_file/crx_verifier.h" #include "components/update_client/cobalt_slot_management.h" #include "components/update_client/utils.h" -#include "starboard/common/file.h" #include "starboard/configuration_constants.h" #include "starboard/extension/installation_manager.h" diff --git a/cobalt/updater/utils_test.cc b/cobalt/updater/utils_test.cc index 6e6dbe1176e9..7791463fe1d8 100644 --- a/cobalt/updater/utils_test.cc +++ b/cobalt/updater/utils_test.cc @@ -136,23 +136,29 @@ class UtilsTest : public testing::Test { ASSERT_TRUE(SbFileDelete(manifest_path.c_str())); } - void CreateEmptyLibrary(const std::string& name, - const std::string& installation_path) { + std::string GetLibraryPath(const std::string& name, + const std::string& installation_path) { std::string lib_path = base::StrCat( {installation_path, kSbFileSepString, kEvergreenLibDirname}); - ASSERT_TRUE(EnsureDirectoryExists(lib_path.c_str())); + EXPECT_TRUE(EnsureDirectoryExists(lib_path.c_str())); + return base::StrCat({lib_path, kSbFileSepString, name}); + } - lib_path = base::StrCat({lib_path, kSbFileSepString, name}); + void CreateEmptyLibrary(const std::string& name, + const std::string& installation_path) { + std::string lib_path = GetLibraryPath(name, installation_path); SbFile sb_file = SbFileOpen( lib_path.c_str(), kSbFileOpenAlways | kSbFileRead, nullptr, nullptr); ASSERT_TRUE(SbFileIsValid(sb_file)); ASSERT_TRUE(SbFileClose(sb_file)); } - void DeleteLibraryDirRecursively(const std::string& installation_path) { - std::string lib_path = base::StrCat( - {installation_path, kSbFileSepString, kEvergreenLibDirname}); - ASSERT_TRUE(starboard::SbFileDeleteRecursive(lib_path.c_str(), false)); + void DeleteLibrary(const std::string& name, + const std::string& installation_path) { + std::string lib_path = GetLibraryPath(name, installation_path); + struct stat file_info; + ASSERT_TRUE(stat(lib_path.c_str(), &file_info) == 0); + ASSERT_TRUE(SbFileDelete(lib_path.c_str())); } std::vector temp_dir_path_; @@ -437,7 +443,8 @@ TEST_F(UtilsTest, "version": "1.2.0" })json"; CreateManifest(manifest_content, installation_path); - CreateEmptyLibrary("libcobalt.so", installation_path); + std::string library_name = "libcobalt.so"; + CreateEmptyLibrary(library_name, installation_path); EvergreenLibraryMetadata metadata = GetCurrentEvergreenLibraryMetadata(stub_get_extension_fn); @@ -446,7 +453,7 @@ TEST_F(UtilsTest, ASSERT_EQ(metadata.file_type, "Uncompressed"); DeleteManifest(installation_path); - DeleteLibraryDirRecursively(installation_path); + DeleteLibrary(library_name, installation_path); } TEST_F(UtilsTest, @@ -472,14 +479,15 @@ TEST_F(UtilsTest, [](const char* name) { return &kStubInstallationManagerApi; }; ASSERT_TRUE(EnsureDirectoryExists(installation_path.c_str())); - CreateEmptyLibrary("libcobalt.unexpected", installation_path); + std::string library_name = "libcobalt.unexpected"; + CreateEmptyLibrary(library_name, installation_path); EvergreenLibraryMetadata metadata = GetCurrentEvergreenLibraryMetadata(stub_get_extension_fn); ASSERT_EQ(metadata.file_type, "FileTypeUnknown"); - DeleteLibraryDirRecursively(installation_path); + DeleteLibrary(library_name, installation_path); } TEST_F(UtilsTest, @@ -506,7 +514,8 @@ TEST_F(UtilsTest, "version": "1.2.0" })json"; CreateManifest(manifest_content, installation_path); - CreateEmptyLibrary("libcobalt.lz4", installation_path); + std::string library_name = "libcobalt.lz4"; + CreateEmptyLibrary(library_name, installation_path); EvergreenLibraryMetadata metadata = GetCurrentEvergreenLibraryMetadata(stub_get_extension_fn); @@ -515,7 +524,7 @@ TEST_F(UtilsTest, ASSERT_EQ(metadata.file_type, "Compressed"); DeleteManifest(installation_path); - DeleteLibraryDirRecursively(installation_path); + DeleteLibrary(library_name, installation_path); } } // namespace diff --git a/cobalt/watchdog/instrumentation_log.cc b/cobalt/watchdog/instrumentation_log.cc index af7f248b54b5..532fc499d893 100644 --- a/cobalt/watchdog/instrumentation_log.cc +++ b/cobalt/watchdog/instrumentation_log.cc @@ -17,16 +17,18 @@ #include #include +#include "base/logging.h" + namespace cobalt { namespace watchdog { bool InstrumentationLog::LogEvent(const std::string& event) { if (event.length() > kMaxEventLenBytes) { - SB_DLOG(ERROR) << "[Watchdog] Log event exceeds max: " << kMaxEventLenBytes; + DLOG(ERROR) << "[Watchdog] Log event exceeds max: " << kMaxEventLenBytes; return false; } - starboard::ScopedLock scoped_lock(buffer_mutex_); + base::AutoLock scoped_lock(buffer_mutex_); buffer_.SaveToBuffer(event); return true; @@ -35,7 +37,7 @@ bool InstrumentationLog::LogEvent(const std::string& event) { std::vector InstrumentationLog::GetLogTrace() { std::vector traceEvents; - starboard::ScopedLock scoped_lock(buffer_mutex_); + base::AutoLock scoped_lock(buffer_mutex_); for (auto it = buffer_.Begin(); it; ++it) { traceEvents.push_back(**it); } @@ -46,7 +48,7 @@ std::vector InstrumentationLog::GetLogTrace() { base::Value InstrumentationLog::GetLogTraceAsValue() { base::Value log_trace_value = base::Value(base::Value::Type::LIST); - starboard::ScopedLock scoped_lock(buffer_mutex_); + base::AutoLock scoped_lock(buffer_mutex_); for (auto it = buffer_.Begin(); it; ++it) { log_trace_value.GetList().Append(**it); } @@ -55,7 +57,7 @@ base::Value InstrumentationLog::GetLogTraceAsValue() { } void InstrumentationLog::ClearLog() { - starboard::ScopedLock scoped_lock(buffer_mutex_); + base::AutoLock scoped_lock(buffer_mutex_); buffer_.Clear(); } diff --git a/cobalt/watchdog/instrumentation_log.h b/cobalt/watchdog/instrumentation_log.h index 599a1986215b..8bec2bc7a8f3 100644 --- a/cobalt/watchdog/instrumentation_log.h +++ b/cobalt/watchdog/instrumentation_log.h @@ -19,8 +19,8 @@ #include #include "base/containers/ring_buffer.h" +#include "base/synchronization/lock.h" #include "base/values.h" -#include "starboard/common/mutex.h" namespace cobalt { namespace watchdog { @@ -51,7 +51,7 @@ class InstrumentationLog { // Mutex to guard buffer operations. E.g. LogEvent() called from h5vcc API // handler and getLogTrace() called from watchdog monitoring thread. - starboard::Mutex buffer_mutex_; + base::Lock buffer_mutex_; }; } // namespace watchdog diff --git a/cobalt/watchdog/watchdog.cc b/cobalt/watchdog/watchdog.cc index 3846bbb0c47b..2123e8ded97f 100644 --- a/cobalt/watchdog/watchdog.cc +++ b/cobalt/watchdog/watchdog.cc @@ -24,9 +24,9 @@ #include "base/command_line.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" +#include "base/logging.h" +#include "base/time/time.h" #include "starboard/common/file.h" -#include "starboard/common/log.h" -#include "starboard/common/time.h" #include "starboard/configuration_constants.h" #if defined(_DEBUG) @@ -143,7 +143,7 @@ std::shared_ptr Watchdog::GetViolationsMap() { } if (violations_map_ == nullptr) { - SB_LOG(INFO) << "[Watchdog] No previous violations JSON."; + LOG(INFO) << "[Watchdog] No previous violations JSON."; violations_map_ = std::make_unique(base::Value::Type::DICT); } } @@ -159,7 +159,7 @@ std::string Watchdog::GetWatchdogFilePath() { kSbFileMaxPath); watchdog_file_path_ = std::string(cache_dir.data()) + kSbFileSepString + watchdog_file_name_; - SB_LOG(INFO) << "[Watchdog] Violations filepath: " << watchdog_file_path_; + LOG(INFO) << "[Watchdog] Violations filepath: " << watchdog_file_path_; } return watchdog_file_path_; } @@ -169,7 +169,7 @@ std::vector Watchdog::GetWatchdogViolationClientNames() { if (is_disabled_) return names; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); auto violation_map = GetViolationsMap()->GetDict().Clone(); for (base::Value::Dict::iterator it = violation_map.begin(); it != violation_map.end(); ++it) { @@ -181,7 +181,7 @@ std::vector Watchdog::GetWatchdogViolationClientNames() { void Watchdog::UpdateState(base::ApplicationState state) { if (is_disabled_) return; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); state_ = state; } @@ -189,20 +189,22 @@ void Watchdog::WriteWatchdogViolations() { // Writes Watchdog violations to persistent storage as a json file. std::string watchdog_json; base::JSONWriter::Write(*GetViolationsMap(), &watchdog_json); - SB_LOG(INFO) << "[Watchdog] Writing violations to JSON:\n" << watchdog_json; + LOG(INFO) << "[Watchdog] Writing violations to JSON:\n" << watchdog_json; starboard::ScopedFile watchdog_file(GetWatchdogFilePath().c_str(), kSbFileCreateAlways | kSbFileWrite); watchdog_file.WriteAll(watchdog_json.c_str(), static_cast(watchdog_json.size())); pending_write_ = false; - time_last_written_microseconds_ = starboard::CurrentMonotonicTime(); + time_last_written_microseconds_ = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); } void* Watchdog::Monitor(void* context) { pthread_setname_np(pthread_self(), "Watchdog"); - starboard::ScopedLock scoped_lock(static_cast(context)->mutex_); + base::AutoLock scoped_lock(static_cast(context)->mutex_); while (1) { - int64_t current_monotonic_time = starboard::CurrentMonotonicTime(); + int64_t current_monotonic_time = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); bool watchdog_violation = false; // Iterates through client map to monitor all name registered clients. @@ -226,8 +228,9 @@ void* Watchdog::Monitor(void* context) { if (watchdog_violation) MaybeTriggerCrash(context); // Wait - static_cast(context)->monitor_wait_.WaitTimed( + base::TimeDelta timeout = base::Microseconds( static_cast(context)->watchdog_monitor_frequency_); + static_cast(context)->monitor_wait_.TimedWait(timeout); // Shutdown if (!(static_cast(context)->is_monitoring_.load())) break; @@ -308,7 +311,8 @@ void Watchdog::UpdateViolationsMap(void* context, Client* client, violation.SetKey("timestampLastPingedMilliseconds", base::Value(std::to_string( client->time_last_pinged_microseconds / 1000))); - int64_t current_timestamp_millis = starboard::CurrentPosixTime() / 1000; + int64_t current_timestamp_millis = + (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds(); violation.SetKey("timestampViolationMilliseconds", base::Value(std::to_string(current_timestamp_millis))); violation.SetKey( @@ -442,7 +446,7 @@ void Watchdog::EvictWatchdogViolation(void* context) { } void Watchdog::MaybeWriteWatchdogViolations(void* context) { - if (starboard::CurrentMonotonicTime() > + if ((base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() > static_cast(context)->time_last_written_microseconds_ + static_cast(context)->write_wait_time_microseconds_) { static_cast(context)->WriteWatchdogViolations(); @@ -453,7 +457,7 @@ void Watchdog::MaybeTriggerCrash(void* context) { if (static_cast(context)->GetPersistentSettingWatchdogCrash()) { if (static_cast(context)->pending_write_) static_cast(context)->WriteWatchdogViolations(); - SB_LOG(ERROR) << "[Watchdog] Triggering violation Crash!"; + LOG(ERROR) << "[Watchdog] Triggering violation Crash!"; *(reinterpret_cast(0)) = 0; } } @@ -464,10 +468,12 @@ bool Watchdog::Register(std::string name, std::string description, int64_t time_wait_microseconds, Replace replace) { if (is_disabled_) return true; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); - int64_t current_time = starboard::CurrentPosixTime(); - int64_t current_monotonic_time = starboard::CurrentMonotonicTime(); + int64_t current_time = + (base::Time::Now() - base::Time::UnixEpoch()).InMicroseconds(); + int64_t current_monotonic_time = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); // If replace is PING or ALL, handles already registered cases. if (replace != NONE) { @@ -495,9 +501,9 @@ bool Watchdog::Register(std::string name, std::string description, auto result = client_map_.emplace(name, std::move(client)); if (result.second) { - SB_DLOG(INFO) << "[Watchdog] Registered: " << name; + DLOG(INFO) << "[Watchdog] Registered: " << name; } else { - SB_DLOG(ERROR) << "[Watchdog] Unable to Register: " << name; + DLOG(ERROR) << "[Watchdog] Unable to Register: " << name; } return result.second; } @@ -508,10 +514,12 @@ std::shared_ptr Watchdog::RegisterByClient( int64_t time_wait_microseconds) { if (is_disabled_) return nullptr; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); - int64_t current_time = starboard::CurrentPosixTime(); - int64_t current_monotonic_time = starboard::CurrentMonotonicTime(); + int64_t current_time = + (base::Time::Now() - base::Time::UnixEpoch()).InMicroseconds(); + int64_t current_monotonic_time = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); // Creates new client. std::shared_ptr client = CreateClient( @@ -522,7 +530,7 @@ std::shared_ptr Watchdog::RegisterByClient( // Registers. client_list_.emplace_back(client); - SB_DLOG(INFO) << "[Watchdog] Registered: " << name; + DLOG(INFO) << "[Watchdog] Registered: " << name; return client; } @@ -534,12 +542,12 @@ std::unique_ptr Watchdog::CreateClient( // Validates parameters. if (time_interval_microseconds < watchdog_monitor_frequency_ || time_wait_microseconds < 0) { - SB_DLOG(ERROR) << "[Watchdog] Unable to Register: " << name; + DLOG(ERROR) << "[Watchdog] Unable to Register: " << name; if (time_interval_microseconds < watchdog_monitor_frequency_) { - SB_DLOG(ERROR) << "[Watchdog] Time interval less than min: " - << watchdog_monitor_frequency_; + DLOG(ERROR) << "[Watchdog] Time interval less than min: " + << watchdog_monitor_frequency_; } else { - SB_DLOG(ERROR) << "[Watchdog] Time wait is negative."; + DLOG(ERROR) << "[Watchdog] Time wait is negative."; } return nullptr; } @@ -564,14 +572,18 @@ bool Watchdog::Unregister(const std::string& name, bool lock) { if (is_disabled_) return true; // Unregisters. - if (lock) mutex_.Acquire(); - auto result = client_map_.erase(name); - if (lock) mutex_.Release(); + int result = 0; + if (lock) { + base::AutoLock lock(mutex_); + result = client_map_.erase(name); + } else { + result = client_map_.erase(name); + } if (result) { - SB_DLOG(INFO) << "[Watchdog] Unregistered: " << name; + DLOG(INFO) << "[Watchdog] Unregistered: " << name; } else { - SB_DLOG(ERROR) << "[Watchdog] Unable to Unregister: " << name; + DLOG(ERROR) << "[Watchdog] Unable to Unregister: " << name; } return result; } @@ -579,7 +591,7 @@ bool Watchdog::Unregister(const std::string& name, bool lock) { bool Watchdog::UnregisterByClient(std::shared_ptr client) { if (is_disabled_) return true; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); std::string name = ""; if (client) name = client->name; @@ -588,11 +600,11 @@ bool Watchdog::UnregisterByClient(std::shared_ptr client) { for (auto it = client_list_.begin(); it != client_list_.end(); it++) { if (client == *it) { client_list_.erase(it); - SB_DLOG(INFO) << "[Watchdog] Unregistered: " << name; + DLOG(INFO) << "[Watchdog] Unregistered: " << name; return true; } } - SB_DLOG(ERROR) << "[Watchdog] Unable to Unregister: " << name; + DLOG(ERROR) << "[Watchdog] Unable to Unregister: " << name; return false; } @@ -601,7 +613,7 @@ bool Watchdog::Ping(const std::string& name) { return Ping(name, ""); } bool Watchdog::Ping(const std::string& name, const std::string& info) { if (is_disabled_) return true; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); auto it = client_map_.find(name); bool client_exists = it != client_map_.end(); @@ -610,7 +622,7 @@ bool Watchdog::Ping(const std::string& name, const std::string& info) { Client* client = it->second.get(); return PingHelper(client, name, info); } - SB_DLOG(ERROR) << "[Watchdog] Unable to Ping: " << name; + DLOG(ERROR) << "[Watchdog] Unable to Ping: " << name; return false; } @@ -625,14 +637,14 @@ bool Watchdog::PingByClient(std::shared_ptr client, std::string name = ""; if (client) name = client->name; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); for (auto it = client_list_.begin(); it != client_list_.end(); it++) { if (client == *it) { return PingHelper(client.get(), name, info); } } - SB_DLOG(ERROR) << "[Watchdog] Unable to Ping: " << name; + DLOG(ERROR) << "[Watchdog] Unable to Ping: " << name; return false; } @@ -640,14 +652,16 @@ bool Watchdog::PingHelper(Client* client, const std::string& name, const std::string& info) { // Validates parameters. if (info.length() > kWatchdogMaxPingInfoLength) { - SB_DLOG(ERROR) << "[Watchdog] Unable to Ping: " << name; - SB_DLOG(ERROR) << "[Watchdog] Ping info length exceeds max: " - << kWatchdogMaxPingInfoLength; + DLOG(ERROR) << "[Watchdog] Unable to Ping: " << name; + DLOG(ERROR) << "[Watchdog] Ping info length exceeds max: " + << kWatchdogMaxPingInfoLength; return false; } - int64_t current_time = starboard::CurrentPosixTime(); - int64_t current_monotonic_time = starboard::CurrentMonotonicTime(); + int64_t current_time = + (base::Time::Now() - base::Time::UnixEpoch()).InMicroseconds(); + int64_t current_monotonic_time = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); // Updates last ping. client->time_last_pinged_microseconds = current_time; @@ -675,7 +689,7 @@ std::string Watchdog::GetWatchdogViolations( std::string fetched_violations_json = ""; - starboard::ScopedLock scoped_lock(mutex_); + base::AutoLock scoped_lock(mutex_); if (GetViolationsMap()->DictSize() != 0) { if (clients.empty()) { @@ -705,16 +719,16 @@ std::string Watchdog::GetWatchdogViolations( EvictOldWatchdogViolations(); } } - SB_LOG(INFO) << "[Watchdog] Reading violations:\n" - << fetched_violations_json; + LOG(INFO) << "[Watchdog] Reading violations:\n" << fetched_violations_json; } else { - SB_LOG(INFO) << "[Watchdog] No violations."; + LOG(INFO) << "[Watchdog] No violations."; } return fetched_violations_json; } void Watchdog::EvictOldWatchdogViolations() { - int64_t current_timestamp_millis = starboard::CurrentPosixTime() / 1000; + int64_t current_timestamp_millis = + (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds(); int64_t cutoff_timestamp_millis = current_timestamp_millis - kWatchdogMaxViolationsAge; std::vector empty_violations; @@ -760,8 +774,9 @@ bool Watchdog::GetPersistentSettingWatchdogEnable() { if (!persistent_settings_) return kDefaultSettingWatchdogEnable; // Gets the boolean that controls whether or not Watchdog is enabled. - return persistent_settings_->GetPersistentSettingAsBool( - kPersistentSettingWatchdogEnable, kDefaultSettingWatchdogEnable); + base::Value value; + persistent_settings_->Get(kPersistentSettingWatchdogEnable, &value); + return value.GetIfBool().value_or(kDefaultSettingWatchdogEnable); } void Watchdog::SetPersistentSettingWatchdogEnable(bool enable_watchdog) { @@ -769,9 +784,8 @@ void Watchdog::SetPersistentSettingWatchdogEnable(bool enable_watchdog) { if (!persistent_settings_) return; // Sets the boolean that controls whether or not Watchdog is enabled. - persistent_settings_->SetPersistentSetting( - kPersistentSettingWatchdogEnable, - std::make_unique(enable_watchdog)); + persistent_settings_->Set(kPersistentSettingWatchdogEnable, + base::Value(enable_watchdog)); } bool Watchdog::GetPersistentSettingWatchdogCrash() { @@ -779,8 +793,9 @@ bool Watchdog::GetPersistentSettingWatchdogCrash() { if (!persistent_settings_) return kDefaultSettingWatchdogCrash; // Gets the boolean that controls whether or not crashes can be triggered. - return persistent_settings_->GetPersistentSettingAsBool( - kPersistentSettingWatchdogCrash, kDefaultSettingWatchdogCrash); + base::Value value; + persistent_settings_->Get(kPersistentSettingWatchdogCrash, &value); + return value.GetIfBool().value_or(kDefaultSettingWatchdogCrash); } void Watchdog::SetPersistentSettingWatchdogCrash(bool can_trigger_crash) { @@ -788,9 +803,8 @@ void Watchdog::SetPersistentSettingWatchdogCrash(bool can_trigger_crash) { if (!persistent_settings_) return; // Sets the boolean that controls whether or not crashes can be triggered. - persistent_settings_->SetPersistentSetting( - kPersistentSettingWatchdogCrash, - std::make_unique(can_trigger_crash)); + persistent_settings_->Set(kPersistentSettingWatchdogCrash, + base::Value(can_trigger_crash)); } bool Watchdog::LogEvent(const std::string& event) { @@ -821,17 +835,17 @@ bool Watchdog::GetPersistentSettingLogtraceEnable() { if (!persistent_settings_) return kDefaultSettingLogtraceEnable; // Gets the boolean that controls whether or not LogTrace is enabled. - return persistent_settings_->GetPersistentSettingAsBool( - kPersistentSettingLogtraceEnable, kDefaultSettingLogtraceEnable); + base::Value value; + persistent_settings_->Get(kPersistentSettingLogtraceEnable, &value); + return value.GetIfBool().value_or(kDefaultSettingLogtraceEnable); } void Watchdog::SetPersistentSettingLogtraceEnable(bool enable_logtrace) { if (!persistent_settings_) return; // Sets the boolean that controls whether or not LogTrace is enabled. - persistent_settings_->SetPersistentSetting( - kPersistentSettingLogtraceEnable, - std::make_unique(enable_logtrace)); + persistent_settings_->Set(kPersistentSettingLogtraceEnable, + base::Value(enable_logtrace)); } #if defined(_DEBUG) @@ -839,14 +853,15 @@ void Watchdog::SetPersistentSettingLogtraceEnable(bool enable_logtrace) { void Watchdog::MaybeInjectDebugDelay(const std::string& name) { if (is_disabled_) return; - starboard::ScopedLock scoped_lock(delay_mutex_); + base::AutoLock scoped_lock(delay_mutex_); if (name != delay_name_) return; - if (starboard::CurrentMonotonicTime() > + if ((base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() > time_last_delayed_microseconds_ + delay_wait_time_microseconds_) { usleep(delay_sleep_time_microseconds_); - time_last_delayed_microseconds_ = starboard::CurrentMonotonicTime(); + time_last_delayed_microseconds_ = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); } } #endif // defined(_DEBUG) diff --git a/cobalt/watchdog/watchdog.h b/cobalt/watchdog/watchdog.h index 2a452d20c623..b2e84f0e3252 100644 --- a/cobalt/watchdog/watchdog.h +++ b/cobalt/watchdog/watchdog.h @@ -17,19 +17,19 @@ #include +#include #include #include #include #include +#include "base/synchronization/condition_variable.h" +#include "base/synchronization/lock.h" #include "base/values.h" #include "cobalt/base/application_state.h" #include "cobalt/persistent_storage/persistent_settings.h" #include "cobalt/watchdog/instrumentation_log.h" #include "cobalt/watchdog/singleton.h" -#include "starboard/common/atomic.h" -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" namespace cobalt { namespace watchdog { @@ -178,7 +178,7 @@ class Watchdog : public Singleton { // only occur in between loops of monitor. API functions like Register(), // Unregister(), Ping(), and GetWatchdogViolations() will be called by // various threads and interact with these class variables. - starboard::Mutex mutex_; + base::Lock mutex_; // Tracks application state. base::ApplicationState state_ = base::kApplicationStateStarted; // Flag to trigger Watchdog violations writes to persistent storage. @@ -198,10 +198,9 @@ class Watchdog : public Singleton { // Monitor thread. pthread_t watchdog_thread_; // Flag to stop monitor thread. - starboard::atomic_bool is_monitoring_; + std::atomic_bool is_monitoring_; // Conditional Variable to wait and shutdown monitor thread. - starboard::ConditionVariable monitor_wait_ = - starboard::ConditionVariable(mutex_); + base::ConditionVariable monitor_wait_ = base::ConditionVariable(&mutex_); // The frequency in microseconds of monitor loops. int64_t watchdog_monitor_frequency_; // Captures string events emitted from Kabuki via logEvent() h5vcc API. @@ -211,7 +210,7 @@ class Watchdog : public Singleton { bool is_logtrace_disabled_; #if defined(_DEBUG) - starboard::Mutex delay_mutex_; + base::Lock delay_mutex_; // Name of the client to inject a delay for. std::string delay_name_ = ""; // Monotonically increasing timestamp when a delay was last injected. 0 diff --git a/cobalt/watchdog/watchdog_test.cc b/cobalt/watchdog/watchdog_test.cc index c5e93d5afb14..07c160d9d867 100644 --- a/cobalt/watchdog/watchdog_test.cc +++ b/cobalt/watchdog/watchdog_test.cc @@ -99,6 +99,11 @@ class WatchdogTest : public testing::Test { starboard::SbFileDeleteRecursive(path.c_str(), true); } + void Fence(PersistentSettings* persistent_settings, + const base::Location& location) { + persistent_settings->Fence(location); + } + const std::string kSettingsFileName = "test-settings.json"; watchdog::Watchdog* watchdog_; @@ -258,61 +263,61 @@ TEST_F(WatchdogTest, ViolationsJsonShouldPersistAndBeValid) { absl::optional violations_map_optional = base::JSONReader::Read(json); ASSERT_TRUE(violations_map_optional.has_value()); - std::unique_ptr violations_map = - std::make_unique( - std::move(*violations_map_optional.value().GetIfDict())); + const base::Value::Dict* violations_map = + violations_map_optional->GetIfDict(); ASSERT_NE(violations_map, nullptr); - base::Value::Dict* violation_dict = violations_map->FindDict("test-name"); + const base::Value::Dict* violation_dict = + violations_map->FindDict("test-name"); ASSERT_NE(violation_dict, nullptr); - std::string* description = violation_dict->FindString("description"); + const std::string* description = violation_dict->FindString("description"); ASSERT_NE(description, nullptr); ASSERT_EQ(*description, "test-desc"); - base::Value::List* violations = violation_dict->FindList("violations"); + const base::Value::List* violations = violation_dict->FindList("violations"); ASSERT_NE(violations, nullptr); ASSERT_EQ(violations->size(), 1); - std::string* monitor_state = + const std::string* monitor_state = (*violations)[0].GetDict().FindString("monitorState"); ASSERT_NE(monitor_state, nullptr); ASSERT_EQ( *monitor_state, std::string(GetApplicationStateString(base::kApplicationStateStarted))); - base::Value::List* ping_infos = + const base::Value::List* ping_infos = (*violations)[0].GetDict().FindList("pingInfos"); ASSERT_NE(ping_infos, nullptr); ASSERT_EQ(ping_infos->size(), 1); - std::string* info = (*ping_infos)[0].GetDict().FindString("info"); + const std::string* info = (*ping_infos)[0].GetDict().FindString("info"); ASSERT_NE(info, nullptr); ASSERT_EQ(*info, "test-ping"); - std::string* timestamp_milliseconds = + const std::string* timestamp_milliseconds = (*ping_infos)[0].GetDict().FindString("timestampMilliseconds"); ASSERT_NE(timestamp_milliseconds, nullptr); std::stoll(*timestamp_milliseconds); - base::Value::List* registered_clients = + const base::Value::List* registered_clients = (*violations)[0].GetDict().FindList("registeredClients"); ASSERT_NE(registered_clients, nullptr); ASSERT_EQ(registered_clients->size(), 1); ASSERT_EQ((*registered_clients)[0].GetString(), "test-name"); - std::string* time_interval_milliseconds = + const std::string* time_interval_milliseconds = (*violations)[0].GetDict().FindString("timeIntervalMilliseconds"); ASSERT_NE(time_interval_milliseconds, nullptr); std::stoll(*time_interval_milliseconds); - std::string* time_wait_milliseconds = + const std::string* time_wait_milliseconds = (*violations)[0].GetDict().FindString("timeWaitMilliseconds"); ASSERT_NE(time_wait_milliseconds, nullptr); std::stoll(*time_wait_milliseconds); - std::string* timestamp_last_pinged_milliseconds = + const std::string* timestamp_last_pinged_milliseconds = (*violations)[0].GetDict().FindString("timestampLastPingedMilliseconds"); ASSERT_NE(timestamp_last_pinged_milliseconds, nullptr); std::stoll(*timestamp_last_pinged_milliseconds); - std::string* timestamp_registered_milliseconds = + const std::string* timestamp_registered_milliseconds = (*violations)[0].GetDict().FindString("timestampRegisteredMilliseconds"); ASSERT_NE(timestamp_registered_milliseconds, nullptr); std::stoll(*timestamp_registered_milliseconds); - std::string* timestamp_violation_milliseconds = + const std::string* timestamp_violation_milliseconds = (*violations)[0].GetDict().FindString("timestampViolationMilliseconds"); ASSERT_NE(timestamp_violation_milliseconds, nullptr); std::stoll(*timestamp_violation_milliseconds); - std::string* violation_duration_milliseconds = + const std::string* violation_duration_milliseconds = (*violations)[0].GetDict().FindString("violationDurationMilliseconds"); ASSERT_NE(violation_duration_milliseconds, nullptr); std::stoll(*violation_duration_milliseconds); @@ -751,13 +756,15 @@ TEST_F(WatchdogTest, WatchdogMethodsAreNoopWhenWatchdogIsDisabled) { // PersistentSettings doesn't have interface so it's not mockable auto persistent_settings = std::make_unique(kSettingsFileName); - persistent_settings->ValidatePersistentSettings(); - persistent_settings->SetPersistentSetting( - kPersistentSettingWatchdogEnable, std::make_unique(false), - true); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool( - kPersistentSettingWatchdogEnable, true)); + persistent_settings->Set(kPersistentSettingWatchdogEnable, + base::Value(false)); + Fence(persistent_settings.get(), FROM_HERE); + { + base::Value value; + persistent_settings->Get(kPersistentSettingWatchdogEnable, &value); + ASSERT_FALSE(value.GetIfBool().value_or(true)); + } watchdog_ = new watchdog::Watchdog(); watchdog_->InitializeCustom(persistent_settings.get(), @@ -786,13 +793,15 @@ TEST_F(WatchdogTest, LogtraceMethodsAreNoopWhenLogtraceIsDisabled) { // PersistentSettings doesn't have interface so it's not mockable auto persistent_settings = std::make_unique(kSettingsFileName); - persistent_settings->ValidatePersistentSettings(); - persistent_settings->SetPersistentSetting( - kPersistentSettingLogtraceEnable, std::make_unique(false), - true); - ASSERT_FALSE(persistent_settings->GetPersistentSettingAsBool( - kPersistentSettingLogtraceEnable, true)); + persistent_settings->Set(kPersistentSettingLogtraceEnable, + base::Value(false)); + Fence(persistent_settings.get(), FROM_HERE); + { + base::Value value; + persistent_settings->Get(kPersistentSettingLogtraceEnable, &value); + ASSERT_FALSE(value.GetIfBool().value_or(true)); + } watchdog_ = new watchdog::Watchdog(); watchdog_->InitializeCustom(persistent_settings.get(), diff --git a/cobalt/web/event.cc b/cobalt/web/event.cc index 4a530c6675a8..6d8ec96324b6 100644 --- a/cobalt/web/event.cc +++ b/cobalt/web/event.cc @@ -17,14 +17,14 @@ #include "base/compiler_specific.h" #include "base/time/time.h" #include "cobalt/web/event_target.h" -#include "starboard/common/time.h" namespace cobalt { namespace web { Event::Event(UninitializedFlag uninitialized_flag) : event_phase_(kNone), - time_stamp_(GetEventTime(starboard::CurrentMonotonicTime())) { + time_stamp_(GetEventTime( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds())) { InitEventInternal(base_token::Token(), false, false); } @@ -32,20 +32,23 @@ Event::Event(const char* type) : Event(base_token::Token(type)) {} Event::Event(const std::string& type) : Event(base_token::Token(type)) {} Event::Event(base_token::Token type) : event_phase_(kNone), - time_stamp_(GetEventTime(starboard::CurrentMonotonicTime())) { + time_stamp_(GetEventTime( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds())) { InitEventInternal(type, false, false); } Event::Event(const std::string& type, const EventInit& init_dict) : Event(base_token::Token(type), init_dict) {} Event::Event(base_token::Token type, Bubbles bubbles, Cancelable cancelable) : event_phase_(kNone), - time_stamp_(GetEventTime(starboard::CurrentMonotonicTime())) { + time_stamp_(GetEventTime( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds())) { InitEventInternal(type, bubbles == kBubbles, cancelable == kCancelable); } Event::Event(base_token::Token type, const EventInit& init_dict) : event_phase_(kNone), - time_stamp_(GetEventTime(starboard::CurrentMonotonicTime())) { + time_stamp_(GetEventTime( + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds())) { SB_DCHECK(init_dict.has_bubbles()); SB_DCHECK(init_dict.has_cancelable()); if (init_dict.time_stamp() != 0) { @@ -101,8 +104,8 @@ void Event::TraceMembers(script::Tracer* tracer) { uint64 Event::GetEventTime(int64_t monotonic_time) { // Current delta from Windows epoch. int64_t time_delta = - starboard::PosixTimeToWindowsTime(starboard::CurrentPosixTime()) - - starboard::CurrentMonotonicTime(); + base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds() - + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); base::Time base_time = base::Time::FromDeltaSinceWindowsEpoch( base::TimeDelta::FromMicroseconds(time_delta + monotonic_time)); // For now, continue using the old specification which specifies real time diff --git a/cobalt/web/message_event.cc b/cobalt/web/message_event.cc index 262e23158873..142a4550d0e1 100644 --- a/cobalt/web/message_event.cc +++ b/cobalt/web/message_event.cc @@ -26,7 +26,6 @@ #include "cobalt/web/context.h" #include "cobalt/web/environment_settings.h" #include "cobalt/web/environment_settings_helper.h" -#include "starboard/common/string.h" #include "starboard/memory.h" #include "v8/include/v8.h" diff --git a/cobalt/web/navigator_ua_data.cc b/cobalt/web/navigator_ua_data.cc index 7c4d258ca7ad..25db46917b65 100644 --- a/cobalt/web/navigator_ua_data.cc +++ b/cobalt/web/navigator_ua_data.cc @@ -14,6 +14,7 @@ #include "cobalt/web/navigator_ua_data.h" +#include "base/logging.h" #include "base/strings/stringprintf.h" namespace cobalt { @@ -24,7 +25,7 @@ NavigatorUAData::NavigatorUAData( script::ScriptValueFactory* script_value_factory) : script_value_factory_(script_value_factory) { if (platform_info == nullptr) { - SB_DLOG(WARNING) + DLOG(WARNING) << "No UserAgentPlatformInfo object passed to NavigatorUAData"; return; } diff --git a/cobalt/webdriver/server.cc b/cobalt/webdriver/server.cc index 51e5709c89bd..b1bb2071b89b 100644 --- a/cobalt/webdriver/server.cc +++ b/cobalt/webdriver/server.cc @@ -76,7 +76,10 @@ class ResponseHandlerImpl : public WebDriverServer::ResponseHandler { ResponseHandlerImpl(net::HttpServer* server, int connection_id) : task_runner_(base::SequencedTaskRunner::GetCurrentDefault()), server_(server), - connection_id_(connection_id) {} + connection_id_(connection_id) { + server_->SetReceiveBufferSize(connection_id_, kMaxRecieveBufferSize); + server_->SetSendBufferSize(connection_id_, kMaxSendBufferSize); + } // https://www.selenium.dev/documentation/legacy/json_wire_protocol/#responses void Success(std::unique_ptr value) override { diff --git a/cobalt/webdriver/server.h b/cobalt/webdriver/server.h index 7d850aa3e6a7..6575a1ce882f 100644 --- a/cobalt/webdriver/server.h +++ b/cobalt/webdriver/server.h @@ -54,6 +54,9 @@ class WebDriverServer : public net::HttpServer::Delegate { // client. class ResponseHandler { public: + static const int kMaxRecieveBufferSize = 2 * 1024 * 1024; // 2 Mbytes. + static const int kMaxSendBufferSize = 8 * 1024 * 1024; // 8 Mbytes. + // Called after a successful WebDriver command. // https://www.selenium.dev/documentation/legacy/json_wire_protocol/#responses virtual void Success(std::unique_ptr) = 0; diff --git a/cobalt/websocket/BUILD.gn b/cobalt/websocket/BUILD.gn index 37383b215e90..1e100e92a397 100644 --- a/cobalt/websocket/BUILD.gn +++ b/cobalt/websocket/BUILD.gn @@ -41,11 +41,7 @@ static_library("websocket") { target(gtest_target_type, "websocket_test") { testonly = true has_pedantic_warnings = true - sources = [ - "mock_websocket_channel.cc", - "mock_websocket_channel.h", - "web_socket_test.cc", - ] + sources = [ "web_socket_test.cc" ] deps = [ ":websocket", "//cobalt/base", diff --git a/cobalt/websocket/mock_websocket_channel.cc b/cobalt/websocket/mock_websocket_channel.cc deleted file mode 100644 index fac87a19d311..000000000000 --- a/cobalt/websocket/mock_websocket_channel.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "cobalt/websocket/mock_websocket_channel.h" - -#include "cobalt/websocket/cobalt_web_socket_event_handler.h" - -// Generated constructors and destructors for GMock objects are very large. By -// putting them in a separate file we can speed up compile times. - -namespace cobalt { -namespace websocket { - -MockWebSocketChannel::MockWebSocketChannel( - WebSocketImpl* impl, network::NetworkModule* network_module) - : net::WebSocketChannel(std::unique_ptr( - new CobaltWebSocketEventHandler(impl)), - nullptr) {} - -MockWebSocketChannel::~MockWebSocketChannel() = default; - -} // namespace websocket -} // namespace cobalt diff --git a/cobalt/websocket/mock_websocket_channel.h b/cobalt/websocket/mock_websocket_channel.h deleted file mode 100644 index a6d766e4214f..000000000000 --- a/cobalt/websocket/mock_websocket_channel.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef COBALT_WEBSOCKET_MOCK_WEBSOCKET_CHANNEL_H_ -#define COBALT_WEBSOCKET_MOCK_WEBSOCKET_CHANNEL_H_ - -#include -#include - -#include "base/memory/scoped_refptr.h" -#include "base/synchronization/lock.h" -#include "cobalt/network/network_module.h" -#include "cobalt/websocket/web_socket_impl.h" -#include "net/websockets/websocket_channel.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace cobalt { -namespace websocket { - -class SourceLocation; - -class MockWebSocketChannel : public net::WebSocketChannel { - public: - MockWebSocketChannel(WebSocketImpl* impl, - network::NetworkModule* network_module); - ~MockWebSocketChannel(); - - MOCK_METHOD4(MockSendFrame, - net::WebSocketChannel::ChannelState( - bool fin, net::WebSocketFrameHeader::OpCode op_code, - scoped_refptr buffer, size_t buffer_size)); - net::WebSocketChannel::ChannelState SendFrame( - bool fin, net::WebSocketFrameHeader::OpCode op_code, - scoped_refptr buffer, size_t buffer_size) { - base::AutoLock scoped_lock(lock_); - return MockSendFrame(fin, op_code, buffer, buffer_size); - } - - base::Lock& lock() { return lock_; } - - private: - base::Lock lock_; -}; - -} // namespace websocket -} // namespace cobalt - -#endif // COBALT_WEBSOCKET_MOCK_WEBSOCKET_CHANNEL_H_ diff --git a/cobalt/worker/service_worker_jobs.cc b/cobalt/worker/service_worker_jobs.cc index ff010872cd62..e473ae3b3293 100644 --- a/cobalt/worker/service_worker_jobs.cc +++ b/cobalt/worker/service_worker_jobs.cc @@ -14,7 +14,11 @@ #include "cobalt/worker/service_worker_jobs.h" +#include +#include + #include "base/bind.h" +#include "base/command_line.h" #include "base/strings/stringprintf.h" #include "base/task/current_thread.h" #include "base/time/time.h" @@ -25,12 +29,20 @@ #include "cobalt/worker/extendable_event.h" #include "net/base/mime_util.h" #include "net/base/url_util.h" +#if !defined(COBALT_BUILD_TYPE_GOLD) +#include "base/strings/pattern.h" +#endif namespace cobalt { namespace worker { namespace { +#if !defined(COBALT_BUILD_TYPE_GOLD) +const char kUnsafelyTreatInsecureOriginAsSecure[] = + "unsafely-treat-insecure-origin-as-secure"; +#endif + bool PathContainsEscapedSlash(const GURL& url) { const std::string path = url.path(); return (path.find("%2f") != std::string::npos || @@ -73,11 +85,27 @@ bool IsOriginPotentiallyTrustworthy(const GURL& url) { // authenticated, return "Potentially Trustworthy". if (url.SchemeIs("h5vcc-embedded")) return true; - // 8. If origin has been configured as a trustworthy origin, return - // "Potentially Trustworthy". - if (origin.host() == "web-platform.test") { - return true; + // 8. If origin has been configured as a trustworthy origin, return + // "Potentially Trustworthy". +#if !defined(COBALT_BUILD_TYPE_GOLD) + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(kUnsafelyTreatInsecureOriginAsSecure)) { + std::string origins_str = + command_line.GetSwitchValueASCII(kUnsafelyTreatInsecureOriginAsSecure); + std::vector allowlist = base::SplitString( + origins_str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + if (base::Contains(allowlist, origin.Serialize())) { + return true; + } + + for (const std::string& origin_or_pattern : allowlist) { + if (base::MatchPattern(origin.host(), origin_or_pattern)) { + return true; + } + } } +#endif // 9. Return "Not Trustworthy". return false; @@ -787,8 +815,7 @@ void ServiceWorkerJobs::Install( // Using a shared pointer because this flag is explicitly defined in the spec // to be modified from the worker's event loop, at asynchronous promise // completion that may occur after a timeout. - std::shared_ptr install_failed( - new starboard::atomic_bool(false)); + std::shared_ptr install_failed(new std::atomic_bool(false)); // 2. Let newestWorker be the result of running Get Newest Worker algorithm // passing registration as its argument. @@ -878,7 +905,7 @@ void ServiceWorkerJobs::Install( base::Bind( [](ServiceWorkerObject* installing_worker, base::WaitableEvent* done_event, - std::shared_ptr install_failed) { + std::shared_ptr install_failed) { // 11.3.1.1. Let e be the result of creating an event with // ExtendableEvent. // 11.3.1.2. Initialize e’s type attribute to install. @@ -895,7 +922,7 @@ void ServiceWorkerJobs::Install( // If task is discarded, set installFailed to true. auto done_callback = base::BindOnce( [](base::WaitableEvent* done_event, - std::shared_ptr install_failed, + std::shared_ptr install_failed, bool was_rejected) { if (was_rejected) install_failed->store(true); done_event->Signal(); diff --git a/cobalt/worker/service_worker_jobs.h b/cobalt/worker/service_worker_jobs.h index 62b5b9593094..0fb9530549e8 100644 --- a/cobalt/worker/service_worker_jobs.h +++ b/cobalt/worker/service_worker_jobs.h @@ -15,6 +15,7 @@ #ifndef COBALT_WORKER_SERVICE_WORKER_JOBS_H_ #define COBALT_WORKER_SERVICE_WORKER_JOBS_H_ +#include #include #include #include @@ -83,7 +84,7 @@ class ServiceWorkerJobs { bool is_pending() const { return is_pending_.load(); } private: - starboard::atomic_bool is_pending_{true}; + std::atomic_bool is_pending_{true}; std::unique_ptr promise_bool_reference_; std::unique_ptr diff --git a/cobalt/worker/service_worker_object.h b/cobalt/worker/service_worker_object.h index 7e70d0ceb78a..7f4d579671c5 100644 --- a/cobalt/worker/service_worker_object.h +++ b/cobalt/worker/service_worker_object.h @@ -15,6 +15,7 @@ #ifndef COBALT_WORKER_SERVICE_WORKER_OBJECT_H_ #define COBALT_WORKER_SERVICE_WORKER_OBJECT_H_ +#include #include #include #include @@ -196,7 +197,7 @@ class ServiceWorkerObject // https://www.w3.org/TR/2022/CRD-service-workers-20220712/#service-worker-start-status std::unique_ptr start_status_; - starboard::atomic_bool start_failed_; + std::atomic_bool start_failed_; scoped_refptr worker_global_scope_; diff --git a/cobalt/worker/service_worker_persistent_settings.cc b/cobalt/worker/service_worker_persistent_settings.cc index 0a2112a3a65a..87712ce91036 100644 --- a/cobalt/worker/service_worker_persistent_settings.cc +++ b/cobalt/worker/service_worker_persistent_settings.cc @@ -66,22 +66,6 @@ const char kSettingsSetOfUsedScriptsKey[] = "set_of_used_scripts"; const char kSettingsSkipWaitingKey[] = "skip_waiting"; const char kSettingsClassicScriptsImportedKey[] = "classic_scripts_imported"; const char kSettingsRawHeadersKey[] = "raw_headers"; - -bool CheckPersistentValue( - std::string key_string, std::string settings_key, - base::flat_map>& dict, - base::Value::Type type) { - if (!dict.contains(settings_key)) { - DLOG(INFO) << "Key: " << key_string << " does not contain " << settings_key; - return false; - } else if (!(dict[settings_key]->type() == type)) { - DLOG(INFO) << "Key: " << key_string << " " << settings_key - << " is of type: " << dict[settings_key]->type() - << ", but expected type is: " << type; - return false; - } - return true; -} } // namespace ServiceWorkerPersistentSettings::ServiceWorkerPersistentSettings( @@ -89,7 +73,7 @@ ServiceWorkerPersistentSettings::ServiceWorkerPersistentSettings( : options_(options) { persistent_settings_.reset(new cobalt::persistent_storage::PersistentSettings( WorkerConsts::kSettingsJson)); - persistent_settings_->ValidatePersistentSettings(); + persistent_settings_->Validate(); DCHECK(persistent_settings_); } @@ -97,69 +81,61 @@ void ServiceWorkerPersistentSettings::ReadServiceWorkerRegistrationMapSettings( std::map>& registration_map) { - std::vector key_list = - persistent_settings_->GetPersistentSettingAsList(kSettingsKeyList); + base::Value local_key_list_value; + persistent_settings_->Get(kSettingsKeyList, &local_key_list_value); + const base::Value::List* key_list = local_key_list_value.GetIfList(); + if (!key_list || key_list->empty()) return; std::set unverified_key_set; - for (auto& key : key_list) { + for (auto& key : *key_list) { if (key.is_string()) { unverified_key_set.insert(key.GetString()); } } for (auto& key_string : unverified_key_set) { - auto dict = - persistent_settings_->GetPersistentSettingAsDictionary(key_string); - if (dict.empty()) { + base::Value local_dict_value; + persistent_settings_->Get(key_string, &local_dict_value); + const base::Value::Dict* dict = local_dict_value.GetIfDict(); + if (!dict || dict->empty()) { DLOG(INFO) << "Key: " << key_string << " does not exist in " << WorkerConsts::kSettingsJson; continue; } - if (!CheckPersistentValue(key_string, kSettingsStorageKeyKey, dict, - base::Value::Type::STRING)) - continue; - url::Origin storage_key = - url::Origin::Create(GURL(dict[kSettingsStorageKeyKey]->GetString())); + auto storage_key = dict->FindString(kSettingsStorageKeyKey); + if (!storage_key) continue; + url::Origin storage_key_origin = url::Origin::Create(GURL(*storage_key)); - if (!CheckPersistentValue(key_string, kSettingsScopeUrlKey, dict, - base::Value::Type::STRING)) - continue; - GURL scope(dict[kSettingsScopeUrlKey]->GetString()); + auto scope_url = dict->FindString(kSettingsScopeUrlKey); + if (!scope_url) continue; + GURL scope(*scope_url); - if (!CheckPersistentValue(key_string, kSettingsUpdateViaCacheModeKey, dict, - base::Value::Type::INTEGER)) - continue; + auto update_via_cache_mode = dict->FindInt(kSettingsUpdateViaCacheModeKey); + if (!update_via_cache_mode) continue; ServiceWorkerUpdateViaCache update_via_cache = - static_cast( - dict[kSettingsUpdateViaCacheModeKey]->GetInt()); + static_cast(*update_via_cache_mode); - if (!CheckPersistentValue(key_string, kSettingsScopeStringKey, dict, - base::Value::Type::STRING)) - continue; - std::string scope_string(dict[kSettingsScopeStringKey]->GetString()); + auto scope_string = dict->FindString(kSettingsScopeStringKey); + if (!scope_string) continue; - RegistrationMapKey key(storage_key, scope_string); + RegistrationMapKey key(storage_key_origin, *scope_string); scoped_refptr registration( - new ServiceWorkerRegistrationObject(storage_key, scope, + new ServiceWorkerRegistrationObject(storage_key_origin, scope, update_via_cache)); - auto worker_key = kSettingsWaitingWorkerKey; - if (!CheckPersistentValue(key_string, worker_key, dict, - base::Value::Type::DICT)) { - worker_key = kSettingsActiveWorkerKey; - if (!CheckPersistentValue(key_string, worker_key, dict, - base::Value::Type::DICT)) - continue; + const base::Value::Dict* worker = dict->FindDict(kSettingsWaitingWorkerKey); + if (!worker) { + worker = dict->FindDict(kSettingsActiveWorkerKey); + if (!worker) continue; } - if (!ReadServiceWorkerObjectSettings( - registration, key_string, std::move(dict[worker_key]), worker_key)) + if (!ReadServiceWorkerObjectSettings(registration, key_string, *worker)) continue; - if (CheckPersistentValue(key_string, kSettingsLastUpdateCheckTimeKey, dict, - base::Value::Type::STRING)) { - int64_t last_update_check_time = - std::atol(dict[kSettingsLastUpdateCheckTimeKey]->GetString().c_str()); + auto last_update_check_time = + dict->FindString(kSettingsLastUpdateCheckTimeKey); + if (last_update_check_time) { registration->set_last_update_check_time( base::Time::FromDeltaSinceWindowsEpoch( - base::TimeDelta::FromMicroseconds(last_update_check_time))); + base::TimeDelta::FromMicroseconds( + std::atol(last_update_check_time->c_str())))); } key_set_.insert(key_string); @@ -173,7 +149,7 @@ void ServiceWorkerPersistentSettings::ReadServiceWorkerRegistrationMapSettings( registration)); auto job = options_.service_worker_context->jobs()->CreateJobWithoutPromise( - ServiceWorkerJobs::JobType::kUpdate, storage_key, scope, + ServiceWorkerJobs::JobType::kUpdate, storage_key_origin, scope, registration->waiting_worker()->script_url()); options_.service_worker_context->task_runner()->PostTask( FROM_HERE, base::BindOnce(&ServiceWorkerJobs::ScheduleJob, @@ -185,11 +161,10 @@ void ServiceWorkerPersistentSettings::ReadServiceWorkerRegistrationMapSettings( bool ServiceWorkerPersistentSettings::ReadServiceWorkerObjectSettings( scoped_refptr registration, - std::string key_string, std::unique_ptr value_dict, - std::string worker_key_string) { - std::string* options_name_value = - value_dict->FindStringKey(kSettingsOptionsNameKey); - if (options_name_value == nullptr) return false; + std::string key_string, const base::Value::Dict& value_dict) { + const std::string* options_name_value = + value_dict.FindString(kSettingsOptionsNameKey); + if (!options_name_value) return false; ServiceWorkerObject::Options options(*options_name_value, options_.web_settings, options_.network_module, registration); @@ -197,42 +172,37 @@ bool ServiceWorkerPersistentSettings::ReadServiceWorkerObjectSettings( options.web_options.service_worker_context = options_.service_worker_context; scoped_refptr worker(new ServiceWorkerObject(options)); - std::string* script_url_value = - value_dict->FindStringKey(kSettingsScriptUrlKey); - if (script_url_value == nullptr) return false; + const std::string* script_url_value = + value_dict.FindString(kSettingsScriptUrlKey); + if (!script_url_value) return false; worker->set_script_url(GURL(*script_url_value)); absl::optional skip_waiting_value = - value_dict->FindBoolKey(kSettingsSkipWaitingKey); - if (!skip_waiting_value.has_value()) return false; + value_dict.FindBool(kSettingsSkipWaitingKey); + if (!skip_waiting_value) return false; if (skip_waiting_value.value()) worker->set_skip_waiting(); absl::optional classic_scripts_imported_value = - value_dict->FindBoolKey(kSettingsClassicScriptsImportedKey); - if (!classic_scripts_imported_value.has_value()) return false; + value_dict.FindBool(kSettingsClassicScriptsImportedKey); + if (!classic_scripts_imported_value) return false; if (classic_scripts_imported_value.value()) worker->set_classic_scripts_imported(); worker->set_start_status(nullptr); - base::Value* used_scripts_value = - value_dict->FindListKey(kSettingsSetOfUsedScriptsKey); - if (used_scripts_value == nullptr) return false; - base::Value::List used_scripts_list = - std::move(*used_scripts_value).TakeList(); - for (int i = 0; i < used_scripts_list.size(); i++) { - auto script_value = std::move(used_scripts_list[i]); + const base::Value::List* used_scripts_list = + value_dict.FindList(kSettingsSetOfUsedScriptsKey); + if (!used_scripts_list) return false; + for (const auto& script_value : *used_scripts_list) { if (script_value.is_string()) { worker->AppendToSetOfUsedScripts(GURL(script_value.GetString())); } } - base::Value* script_urls_value = - value_dict->FindListKey(kSettingsScriptResourceMapScriptUrlsKey); - if (script_urls_value == nullptr) return false; - base::Value::List script_urls_list = std::move(*script_urls_value).TakeList(); + const base::Value::List* script_urls_list = + value_dict.FindList(kSettingsScriptResourceMapScriptUrlsKey); + if (!script_urls_list) return false; ScriptResourceMap script_resource_map; - for (int i = 0; i < script_urls_list.size(); i++) { - auto script_url_value = std::move(script_urls_list[i]); + for (const auto& script_url_value : *script_urls_list) { if (script_url_value.is_string()) { auto script_url_string = script_url_value.GetString(); auto script_url = GURL(script_url_string); @@ -248,9 +218,9 @@ bool ServiceWorkerPersistentSettings::ReadServiceWorkerObjectSettings( if (script_url == worker->script_url()) { // Get the persistent headers for the ServiceWorkerObject script_url_. // This is used in ServiceWorkerObject::Initialize(). - std::string* raw_header_value = - value_dict->FindStringKey(kSettingsRawHeadersKey); - if (raw_header_value == nullptr) return false; + const std::string* raw_header_value = + value_dict.FindString(kSettingsRawHeadersKey); + if (!raw_header_value) return false; const scoped_refptr headers = scoped_refptr( new net::HttpResponseHeaders(*raw_header_value)); @@ -306,8 +276,7 @@ void ServiceWorkerPersistentSettings:: for (auto& key : key_set_) { key_list.Append(key); } - persistent_settings_->SetPersistentSetting( - kSettingsKeyList, std::make_unique(std::move(key_list))); + persistent_settings_->Set(kSettingsKeyList, base::Value(std::move(key_list))); // Persist ServiceWorkerRegistrationObject's fields. dict.Set(kSettingsStorageKeyKey, registration->storage_key().GetURL().spec()); @@ -324,8 +293,7 @@ void ServiceWorkerPersistentSettings:: .ToDeltaSinceWindowsEpoch() .InMicroseconds())); - persistent_settings_->SetPersistentSetting( - key_string, std::make_unique(std::move(dict))); + persistent_settings_->Set(key_string, base::Value(std::move(dict))); } base::Value::Dict @@ -396,38 +364,33 @@ void ServiceWorkerPersistentSettings:: for (auto& key : key_set_) { key_list.Append(key); } - persistent_settings_->SetPersistentSetting( - kSettingsKeyList, std::make_unique(std::move(key_list))); + persistent_settings_->Set(kSettingsKeyList, base::Value(std::move(key_list))); // Remove the registration dictionary. - persistent_settings_->RemovePersistentSetting(key_string); + persistent_settings_->Remove(key_string); } void ServiceWorkerPersistentSettings::RemoveServiceWorkerObjectSettings( std::string key_string) { - auto dict = - persistent_settings_->GetPersistentSettingAsDictionary(key_string); - if (dict.empty()) return; + base::Value local_dict_value; + persistent_settings_->Get(key_string, &local_dict_value); + const base::Value::Dict* dict = local_dict_value.GetIfDict(); + if (!dict || dict->empty()) return; std::vector worker_keys{kSettingsWaitingWorkerKey, kSettingsActiveWorkerKey}; for (std::string worker_key : worker_keys) { - if (!CheckPersistentValue(key_string, worker_key, dict, - base::Value::Type::DICT)) - continue; - auto worker_dict = std::move(dict[worker_key]); - base::Value* script_urls_value = - worker_dict->FindListKey(kSettingsScriptResourceMapScriptUrlsKey); - if (script_urls_value == nullptr) return; - base::Value::List script_urls_list = - std::move(*script_urls_value).TakeList(); - - for (int i = 0; i < script_urls_list.size(); i++) { - auto script_url_value = std::move(script_urls_list[i]); - if (script_url_value.is_string()) { - auto script_url_string = script_url_value.GetString(); + const base::Value::Dict* worker = dict->FindDict(worker_key); + if (!worker) continue; + const base::Value::List* script_urls = + worker->FindList(kSettingsScriptResourceMapScriptUrlsKey); + if (!script_urls) return; + + for (const auto& script_url : *script_urls) { + auto script_url_string = script_url.GetIfString(); + if (script_url_string) { cobalt::cache::Cache::GetInstance()->Delete( network::disk_cache::ResourceType::kServiceWorkerScript, - web::cache_utils::GetKey(key_string + script_url_string)); + web::cache_utils::GetKey(key_string + *script_url_string)); } } } @@ -435,12 +398,12 @@ void ServiceWorkerPersistentSettings::RemoveServiceWorkerObjectSettings( void ServiceWorkerPersistentSettings::RemoveAll() { for (auto& key : key_set_) { - persistent_settings_->RemovePersistentSetting(key); + persistent_settings_->Remove(key); } } void ServiceWorkerPersistentSettings::DeleteAll() { - persistent_settings_->DeletePersistentSettings(); + persistent_settings_->RemoveAll(); } } // namespace worker diff --git a/cobalt/worker/service_worker_persistent_settings.h b/cobalt/worker/service_worker_persistent_settings.h index 90b150934a9b..5eab1be87f86 100644 --- a/cobalt/worker/service_worker_persistent_settings.h +++ b/cobalt/worker/service_worker_persistent_settings.h @@ -68,8 +68,7 @@ class ServiceWorkerPersistentSettings { bool ReadServiceWorkerObjectSettings( scoped_refptr registration, - std::string key_string, std::unique_ptr value_dict, - std::string worker_type_string); + std::string key_string, const base::Value::Dict& value_dict); void WriteServiceWorkerRegistrationObjectSettings( RegistrationMapKey key, @@ -81,13 +80,13 @@ class ServiceWorkerPersistentSettings { void RemoveServiceWorkerRegistrationObjectSettings(RegistrationMapKey key); - void RemoveServiceWorkerObjectSettings(std::string key_string); - void RemoveAll(); void DeleteAll(); private: + void RemoveServiceWorkerObjectSettings(std::string key_string); + Options options_; std::unique_ptr diff --git a/cobalt/xhr/url_fetcher_buffer_writer.cc b/cobalt/xhr/url_fetcher_buffer_writer.cc index 38764375a45d..eaa71836d44b 100644 --- a/cobalt/xhr/url_fetcher_buffer_writer.cc +++ b/cobalt/xhr/url_fetcher_buffer_writer.cc @@ -274,8 +274,8 @@ void URLFetcherResponseWriter::Buffer::Write(const void* buffer, if (type_ == kString) { if (capacity_known_ && num_bytes + data_as_string_.size() >= data_as_string_.capacity()) { - SB_LOG(WARNING) << "Data written is larger than the preset capacity " - << data_as_string_.capacity(); + LOG(WARNING) << "Data written is larger than the preset capacity " + << data_as_string_.capacity(); } data_as_string_.append(data, num_bytes); return; @@ -285,8 +285,8 @@ void URLFetcherResponseWriter::Buffer::Write(const void* buffer, if (data_as_array_buffer_size_ + num_bytes > data_as_array_buffer_.byte_length()) { if (capacity_known_) { - SB_LOG(WARNING) << "Data written is larger than the preset capacity " - << data_as_array_buffer_.byte_length(); + LOG(WARNING) << "Data written is larger than the preset capacity " + << data_as_array_buffer_.byte_length(); } size_t new_size = std::max( std::min(data_as_array_buffer_.byte_length() * kResizingMultiplier, diff --git a/cobalt/xhr/xml_http_request.h b/cobalt/xhr/xml_http_request.h index a4dacc218ddb..b6cbf651926e 100644 --- a/cobalt/xhr/xml_http_request.h +++ b/cobalt/xhr/xml_http_request.h @@ -15,6 +15,7 @@ #ifndef COBALT_XHR_XML_HTTP_REQUEST_H_ #define COBALT_XHR_XML_HTTP_REQUEST_H_ +#include #include #include #include @@ -347,7 +348,7 @@ class XMLHttpRequestImpl : public base::SupportsWeakPtr, bool upload_listener_; bool with_credentials_; XMLHttpRequest* xhr_; - starboard::atomic_bool will_destroy_current_task_runner_; + std::atomic_bool will_destroy_current_task_runner_; // A corspreflight instance for potentially sending preflight // request and performing cors check for all cross origin requests. diff --git a/components/crx_file/crx_verifier.cc b/components/crx_file/crx_verifier.cc index 4ed1d83766da..7cb72b5b89a3 100644 --- a/components/crx_file/crx_verifier.cc +++ b/components/crx_file/crx_verifier.cc @@ -592,7 +592,7 @@ VerifierResult Verify( ReadAndHashLittleEndianUInt32FromString(&it, file_hash.get()); VerifierResult result; if (version == 2) - SB_LOG(WARNING) << "The string is in CRX2 format, which is deprecated and " + LOG(WARNING) << "The string is in CRX2 format, which is deprecated and " << "will not be supported in M78+"; if (format == VerifierFormat::CRX2_OR_CRX3 && (version == 2 || (diff && version == 0))) { diff --git a/components/prefs/BUILD.gn b/components/prefs/BUILD.gn index ec4efb30b541..ee349a03c47a 100644 --- a/components/prefs/BUILD.gn +++ b/components/prefs/BUILD.gn @@ -56,10 +56,7 @@ static_library("prefs") { configs += [ ":prefs_config" ] - deps = [ - "//base", - # "//base/util/values:values_util", - ] + deps = [ "//base" ] } source_set("test_support") { diff --git a/components/prefs/testing_pref_service.h b/components/prefs/testing_pref_service.h index 8c713dc4982b..f0b05fa800e1 100644 --- a/components/prefs/testing_pref_service.h +++ b/components/prefs/testing_pref_service.h @@ -220,7 +220,7 @@ void TestingPrefServiceBase:: SetPref(TestingPrefStore* pref_store, const std::string& path, std::unique_ptr value) { - pref_store->SetValue(path, base::Value(), + pref_store->SetValue(path, base::Value(std::move(*value)), WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); } diff --git a/components/update_client/cobalt_slot_management_test.cc b/components/update_client/cobalt_slot_management_test.cc index 6790005827a3..47e3434be6b6 100644 --- a/components/update_client/cobalt_slot_management_test.cc +++ b/components/update_client/cobalt_slot_management_test.cc @@ -20,8 +20,8 @@ #include #include "base/strings/string_util.h" +#include "base/time/time.h" #include "starboard/common/file.h" -#include "starboard/common/time.h" #include "starboard/extension/free_space.h" #include "starboard/loader_app/app_key_files.h" #include "starboard/loader_app/drain_file.h" @@ -206,7 +206,7 @@ TEST_F(CobaltSlotManagementTest, ConfirmSlotBailsIfOtherAppStartedDrainFirst) { // In order to be higher ranked, the other app's drain file needs to be older // but not expired. int64_t current_time_us = - starboard::PosixTimeToWindowsTime(starboard::CurrentPosixTime()); + base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds(); starboard::loader_app::ScopedDrainFile racing_drain_file( slot_path, kTestAppKey2, current_time_us - (kDrainFileMaximumAgeUsec / 2)); diff --git a/components/variations/BUILD.gn b/components/variations/BUILD.gn index 34d3b8fbe7cf..d05dfc245432 100644 --- a/components/variations/BUILD.gn +++ b/components/variations/BUILD.gn @@ -23,8 +23,8 @@ static_library("variations") { "client_filterable_state.h", "entropy_provider.cc", "entropy_provider.h", - # "experiment_labels.cc", - # "experiment_labels.h", + "experiment_labels.cc", + "experiment_labels.h", "hashing.cc", "hashing.h", "metrics.cc", @@ -84,6 +84,10 @@ static_library("variations") { "proto/permuted_entropy_cache.proto", "proto/study.proto", "proto/variations_seed.proto", + + # These can't be by compiled and aren't used in Cobalt. + "experiment_labels.cc", + "experiment_labels.h", ] } diff --git a/crypto/BUILD.gn b/crypto/BUILD.gn index f8d58ae34dae..8b64afc0ddee 100644 --- a/crypto/BUILD.gn +++ b/crypto/BUILD.gn @@ -4,9 +4,10 @@ import("//build/buildflag_header.gni") import("//build/config/chromeos/ui_mode.gni") -# import("//components/nacl/toolchain.gni") +if (!use_cobalt_customizations) { +import("//components/nacl/toolchain.gni") +} import("//crypto/features.gni") -import("//build_overrides/crypto.gni") import("//testing/test.gni") buildflag_header("buildflags") { diff --git a/crypto/METADATA b/crypto/METADATA index b9ff5a1cbeac..fffa850fa0b3 100644 --- a/crypto/METADATA +++ b/crypto/METADATA @@ -5,12 +5,12 @@ description: third_party { identifier { type: "ChromiumVersion" - value: "114.0.5735.331" # from https://chromereleases.googleblog.com/2023/08/long-term-support-channel-update-for_23.html + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html } identifier { type: "Git" value: "https://chromium.googlesource.com/chromium/src.git" - version: "fed499399d3f44d3a7957549d493bf30a5d8c867" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" } identifier { type: "UpstreamSubdir" diff --git a/crypto/ec_private_key.cc b/crypto/ec_private_key.cc index 3994a8a00a3a..2b56908a28ac 100644 --- a/crypto/ec_private_key.cc +++ b/crypto/ec_private_key.cc @@ -11,7 +11,6 @@ #include "base/check_op.h" #include "crypto/openssl_util.h" -#include "third_party/boringssl/src/include/openssl/bn.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/ec.h" #include "third_party/boringssl/src/include/openssl/ec_key.h" diff --git a/crypto/ec_private_key_unittest.cc b/crypto/ec_private_key_unittest.cc index 863fdc8bfe6d..12ec3c94e06d 100644 --- a/crypto/ec_private_key_unittest.cc +++ b/crypto/ec_private_key_unittest.cc @@ -9,7 +9,6 @@ #include #include -#include "base/macros.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/crypto/ec_signature_creator_impl.cc b/crypto/ec_signature_creator_impl.cc index f81fceffd200..3129ef487231 100644 --- a/crypto/ec_signature_creator_impl.cc +++ b/crypto/ec_signature_creator_impl.cc @@ -7,7 +7,6 @@ #include #include -#include "base/logging.h" #include "crypto/ec_private_key.h" #include "crypto/openssl_util.h" #include "third_party/boringssl/src/include/openssl/bn.h" diff --git a/crypto/hmac_unittest.cc b/crypto/hmac_unittest.cc index 2c48ccfef2ad..364503791980 100644 --- a/crypto/hmac_unittest.cc +++ b/crypto/hmac_unittest.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crypto/hmac.h" + #include +#include #include -#include "base/macros.h" -#include "crypto/hmac.h" #include "testing/gtest/include/gtest/gtest.h" static const size_t kSHA1DigestSize = 20; diff --git a/crypto/secure_util.cc b/crypto/secure_util.cc index 659f46663952..a1ff9e45ccc2 100644 --- a/crypto/secure_util.cc +++ b/crypto/secure_util.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include - #include "crypto/secure_util.h" #include "third_party/boringssl/src/include/openssl/mem.h" diff --git a/docker-compose-windows-internal.yml b/docker-compose-windows-internal.yml index 4cea203ad308..9a166a04de0f 100644 --- a/docker-compose-windows-internal.yml +++ b/docker-compose-windows-internal.yml @@ -54,31 +54,6 @@ services: depends_on: - cobalt-build-win-base - ps4: - <<: *common-definitions - build: - context: ./internal/docker/windows/ - dockerfile: ps4/Dockerfile - args: - - encoded_keyfile=${ENCODED_GS_SERVICE_KEY_FILE} - - FROM_IMAGE=cobalt-build-win-internal - environment: - <<: *shared-build-env - PLATFORM: ps4 - image: cobalt-build-ps4 - depends_on: - - cobalt-build-win-internal - - ps4-kokoro: - build: - context: ./internal/docker/windows/kokoro/ - dockerfile: Dockerfile - args: - - FROM_IMAGE=${FROM_IMAGE:-cobalt-build-ps4} - image: cobalt-kokoro-ps4 - depends_on: - - ps4 - ps5: <<: *common-definitions build: diff --git a/glimp/.gitattributes b/glimp/.gitattributes deleted file mode 100644 index 10dbe12fc08e..000000000000 --- a/glimp/.gitattributes +++ /dev/null @@ -1,29 +0,0 @@ -# These files are text and should be normalized (convert crlf > lf). -*.bat text eol=lf -*.cc text eol=lf -*.cg text eol=lf -*.cpp text eol=lf -*.css text eol=lf -*.gyp text eol=lf -*.gypi text eol=lf -*.h text eol=lf -*.html text eol=lf -*.idl text eol=lf -*.js text eol=lf -*.pump text eol=lf -*.py text eol=lf -*.sublime-project text eol=lf -*.sublime-workspace text eol=lf -*.template text eol=lf -*.txt text eol=lf -*.y text eol=lf -.clang-format text eol=lf -codereview.settings text eol=lf - -# Images should be treated as binary files. -*.exe binary -*.jpg binary -*.mp4 binary -*.png binary -*.pyc binary -*.ttf binary diff --git a/glimp/.gitignore b/glimp/.gitignore deleted file mode 100644 index 5b69378606da..000000000000 --- a/glimp/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.pyc -*.sublime-workspace -*.swp -*.tmp -.DS_Store diff --git a/glimp/BUILD.gn b/glimp/BUILD.gn deleted file mode 100644 index bc8f348c6f37..000000000000 --- a/glimp/BUILD.gn +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//starboard/build/platform_path.gni") - -config("glimp_config") { - include_dirs = [ "include" ] - defines = [ - # There doesn't appear to be any way to use the C preprocessor to do - # string concatenation with the / character. This prevents us from using - # the preprocessor to assemble an include file path, so we have to do - # the concatenation here in GYP. - # http://stackoverflow.com/questions/29601786/c-preprocessor-building-a-path-string - "GLIMP_EGLPLATFORM_INCLUDE=\"../../../$starboard_path/glimp/eglplatform_public.h\"", - "GLIMP_KHRPLATFORM_INCLUDE=\"../../../$starboard_path/glimp/khrplatform_public.h\"", - - # Uncomment the define below to enable and use tracing inside glimp. - # "ENABLE_GLIMP_TRACING", - ] -} - -group("glimp") { - public_configs = [ ":glimp_config" ] - deps = [ "//$starboard_path/glimp:glimp_platform" ] -} - -config("glimp_common_sources_public_config") { - configs = [ ":glimp_config" ] - include_dirs = [ "//$starboard_path/glimp/platform" ] -} - -source_set("glimp_common_sources") { - check_includes = false - sources = [ - "egl/attrib_map.cc", - "egl/attrib_map.h", - "egl/config.cc", - "egl/config.h", - "egl/display.cc", - "egl/display.h", - "egl/display_impl.h", - "egl/display_registry.cc", - "egl/display_registry.h", - "egl/error.cc", - "egl/error.h", - "egl/get_proc_address_impl.h", - "egl/scoped_egl_lock.cc", - "egl/scoped_egl_lock.h", - "egl/surface.cc", - "egl/surface.h", - "egl/surface_impl.h", - "entry_points/egl.cc", - "entry_points/egl_ext.cc", - "entry_points/gles_2_0.cc", - "entry_points/gles_2_0_ext.cc", - "entry_points/gles_3_0.cc", - "gles/blend_state.h", - "gles/buffer.cc", - "gles/buffer.h", - "gles/buffer_impl.h", - "gles/context.cc", - "gles/context.h", - "gles/context_impl.h", - "gles/convert_pixel_data.cc", - "gles/convert_pixel_data.h", - "gles/cull_face_state.h", - "gles/draw_mode.h", - "gles/draw_state.cc", - "gles/draw_state.h", - "gles/framebuffer.cc", - "gles/framebuffer.h", - "gles/index_data_type.h", - "gles/pixel_format.cc", - "gles/pixel_format.h", - "gles/program.cc", - "gles/program.h", - "gles/program_impl.h", - "gles/ref_counted_resource_map.h", - "gles/renderbuffer.cc", - "gles/renderbuffer.h", - "gles/resource_manager.cc", - "gles/resource_manager.h", - "gles/sampler.h", - "gles/shader.cc", - "gles/shader.h", - "gles/shader_impl.h", - "gles/texture.cc", - "gles/texture.h", - "gles/texture_impl.h", - "gles/uniform_info.h", - "gles/unique_id_generator.cc", - "gles/unique_id_generator.h", - "gles/vertex_attribute.h", - "polymorphic_downcast.h", - "rect.h", - "ref_counted.cc", - "ref_counted.h", - "shaders/glsl_shader_map_helpers.h", - "shaders/hash_glsl_source.cc", - "shaders/hash_glsl_source.h", - "thread_collision_warner.cc", - "thread_collision_warner.h", - ] - public_configs = [ ":glimp_common_sources_public_config" ] - deps = [ - "//glimp/tracing", - "//starboard:starboard_headers_only", - ] -} diff --git a/glimp/LICENSE b/glimp/LICENSE deleted file mode 100644 index d64569567334..000000000000 --- a/glimp/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/glimp/egl/attrib_map.cc b/glimp/egl/attrib_map.cc deleted file mode 100644 index 97af8865eade..000000000000 --- a/glimp/egl/attrib_map.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/attrib_map.h" - -namespace glimp { -namespace egl { - -AttribMap ParseRawAttribList(const EGLint* attrib_list) { - AttribMap ret; - if (!attrib_list) { - return ret; - } - - const int* current_attrib = attrib_list; - while (*current_attrib != EGL_NONE) { - int key = *current_attrib++; - int value = *current_attrib++; - - ret[key] = value; - } - - return ret; -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/attrib_map.h b/glimp/egl/attrib_map.h deleted file mode 100644 index 62fe5acb88df..000000000000 --- a/glimp/egl/attrib_map.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_ATTRIB_MAP_H_ -#define GLIMP_EGL_ATTRIB_MAP_H_ - -#include - -#include - -namespace glimp { -namespace egl { - -typedef std::map AttribMap; - -// Many EGL functions take an "attribute list" as a parameter that all share a -// similar format: A list of integer key/value pairs and concluded with the -// value EGL_NONE (like a null terminated C string). This function parses -// that attribute list into a map and returns it. -AttribMap ParseRawAttribList(const EGLint* attrib_list); - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_ATTRIB_MAP_H_ diff --git a/glimp/egl/config.cc b/glimp/egl/config.cc deleted file mode 100644 index 33a30a688bc9..000000000000 --- a/glimp/egl/config.cc +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/config.h" - -#include - -#include "starboard/common/log.h" - -namespace glimp { -namespace egl { - -namespace { -bool AttributeKeyAndValueAreValid(int key, int value) { - switch (key) { - // Deal with the size keys where all values are valid. - case EGL_RED_SIZE: - case EGL_GREEN_SIZE: - case EGL_BLUE_SIZE: - case EGL_ALPHA_SIZE: - case EGL_BUFFER_SIZE: - case EGL_LUMINANCE_SIZE: - case EGL_STENCIL_SIZE: { - return true; - } - - // Deal with the mask keys where all values are valid. - case EGL_CONFORMANT: - case EGL_RENDERABLE_TYPE: - case EGL_SURFACE_TYPE: { - return true; - } - - // Deal with boolean values. - case EGL_BIND_TO_TEXTURE_RGBA: { - switch (value) { - case EGL_DONT_CARE: - case EGL_TRUE: - case EGL_FALSE: { - return true; - } - } - return false; - } - - case EGL_COLOR_BUFFER_TYPE: { - switch (value) { - case EGL_RGB_BUFFER: - case EGL_LUMINANCE_BUFFER: { - return true; - } - } - return false; - } - } - - // If the switch statement didn't catch the key, this is an unknown - // key values. - // TODO: glimp doesn't support all values yet, and will return false for keys - // that it doesn't support. - return false; -} -} // namespace - -bool ValidateConfigAttribList(const AttribMap& attribs) { - for (AttribMap::const_iterator iter = attribs.begin(); iter != attribs.end(); - ++iter) { - if (!AttributeKeyAndValueAreValid(iter->first, iter->second)) { - return false; - } - } - return true; -} - -namespace { -// Returns whether or not a single attribute (the parameters |key| and |value|) -// matches a config or not. -bool ConfigMatchesAttribute(const Config& config, int key, int value) { - SB_DCHECK(AttributeKeyAndValueAreValid(key, value)); - SB_DCHECK(value != EGL_DONT_CARE); - - switch (key) { - case EGL_RED_SIZE: - case EGL_GREEN_SIZE: - case EGL_BLUE_SIZE: - case EGL_ALPHA_SIZE: - case EGL_BUFFER_SIZE: - case EGL_LUMINANCE_SIZE: - case EGL_STENCIL_SIZE: { - // We match if our config's bit depth is greater than or equal to the - // requested value. - return config.find(key)->second >= value; - } - - case EGL_CONFORMANT: - case EGL_RENDERABLE_TYPE: - case EGL_SURFACE_TYPE: { - // We match if our config's bit mask includes the requested bit mask. - return (config.find(key)->second & value) == value; - } - - case EGL_BIND_TO_TEXTURE_RGBA: { - // Our config matches booleans if the requested boolean is not true, or - // else if the config's corresponding boolean is also true. - return value != EGL_TRUE || config.find(key)->second == EGL_TRUE; - } - - case EGL_COLOR_BUFFER_TYPE: { - // We match if our config value matches the requested value exactly. - return config.find(key)->second == value; - } - } - - // The attributes should have been validated when this function is called, - // so if we reach this point, then there is an inconsistency between - // this function and AttributeKeyAndValueAreValid(). - SB_NOTREACHED(); - return false; -} - -bool ConfigMatchesAttributes(const Config& config, - const AttribMap& attrib_list) { - for (AttribMap::const_iterator iter = attrib_list.begin(); - iter != attrib_list.end(); ++iter) { - if (iter->second != EGL_DONT_CARE) { - if (!ConfigMatchesAttribute(config, iter->first, iter->second)) { - return false; - } - } - } - return true; -} -} // namespace - -std::vector FilterConfigs(const std::set& configs, - const AttribMap& attrib_list) { - std::vector ret; - - for (std::set::const_iterator iter = configs.begin(); - iter != configs.end(); ++iter) { - if (ConfigMatchesAttributes(**iter, attrib_list)) { - ret.push_back(*iter); - } - } - - return ret; -} - -namespace { - -class ConfigSorter { - public: - explicit ConfigSorter(const AttribMap& attrib_list) - : attrib_list_(attrib_list) {} - - // We define this such that it sorts in decreasing order of preference. - bool operator()(const Config* lhs, const Config* rhs) const { - // Bit depth must be sorted in ascending order as a total over all - // channels that are specified by the config. - if (GetTotalBitDepth(*lhs) > GetTotalBitDepth(*rhs)) { - return true; - } - return false; - } - - private: - // Returns the bit depth for a given channel, or 0 if we don't care about - // it's value (e.g. it is not in the specified attribute list). - int GetTotalBitDepthForChannel(const Config& config, int key) const { - AttribMap::const_iterator found = attrib_list_.find(key); - if (found == attrib_list_.end() || found->second == EGL_DONT_CARE) { - return 0; - } else { - return found->second; - } - } - - // Gets the total depth for all color channels, to be used to decide the - // sort order. - int GetTotalBitDepth(const Config& config) const { - int total_bit_depth = 0; - total_bit_depth += GetTotalBitDepthForChannel(config, EGL_RED_SIZE); - total_bit_depth += GetTotalBitDepthForChannel(config, EGL_GREEN_SIZE); - total_bit_depth += GetTotalBitDepthForChannel(config, EGL_BLUE_SIZE); - total_bit_depth += GetTotalBitDepthForChannel(config, EGL_ALPHA_SIZE); - return total_bit_depth; - } - - const AttribMap& attrib_list_; -}; -} // namespace - -void SortConfigs(const AttribMap& attrib_list, - std::vector* in_out_configs) { - ConfigSorter config_sorter(attrib_list); - std::sort(in_out_configs->begin(), in_out_configs->end(), config_sorter); -} - -EGLConfig ToEGLConfig(Config* config) { - return reinterpret_cast(config); -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/config.h b/glimp/egl/config.h deleted file mode 100644 index 5ac18fdfe7f7..000000000000 --- a/glimp/egl/config.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_CONFIG_H_ -#define GLIMP_EGL_CONFIG_H_ - -#include - -#include -#include -#include - -#include "glimp/egl/attrib_map.h" - -namespace glimp { -namespace egl { - -// Our underlying EGLConfig structure is just a mapping from config key to -// value. -typedef std::map Config; - -// Examines the |attribs| list of attributes passed in to eglGetConfig(), and -// checks if the attributes are invalid, in which case false is returned, -// otherwise true is returned. -bool ValidateConfigAttribList(const AttribMap& attribs); - -// Filters the input configs such that only those that match the specified -// |attrib_list| are returned. -std::vector FilterConfigs(const std::set& configs, - const AttribMap& attrib_list); - -// Sorts the input list in place according to what best metches the specified -// |attrib_list|. |in_out_configs| will be sorted after this function returns. -void SortConfigs(const AttribMap& attrib_list, - std::vector* in_out_configs); - -// Convert our internal Config pointer type into a public EGLConfig type. -EGLConfig ToEGLConfig(Config* config); - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_CONFIG_H_ diff --git a/glimp/egl/display.cc b/glimp/egl/display.cc deleted file mode 100644 index d8541bec0d8f..000000000000 --- a/glimp/egl/display.cc +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright 2015 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/display.h" - -#include -#include -#include - -#include "glimp/egl/config.h" -#include "glimp/egl/error.h" -#include "starboard/common/log.h" -#include "starboard/event.h" - -namespace glimp { -namespace egl { - -const int64_t kSubmitDoneDelay = 1000000 / 60; // 1/60 seconds, in microseconds - -// Don't repeat the submitDone callback during suspension -// until specified by eglTerminate. -bool Display::repeat_submit_done_during_suspend = false; - -namespace { -void ScheduleSubmitDoneCallback(void* context) { - if (Display::repeat_submit_done_during_suspend) { - SB_DCHECK(true) << "Suspend mode is disabled. ScheduleSubmitDoneCallback " - "shouldn't be triggered."; - DisplayImpl::CallSubmitDone(); - Display::RepeatSubmitDoneDuringSuspend(); - } -} -} // namespace - -void Display::RepeatSubmitDoneDuringSuspend() { - static SbEventId submit_done_repeating_callback_event = kSbEventIdInvalid; - if (Display::repeat_submit_done_during_suspend) { - submit_done_repeating_callback_event = - SbEventSchedule(&ScheduleSubmitDoneCallback, NULL, kSubmitDoneDelay); - } else { - if (submit_done_repeating_callback_event != kSbEventIdInvalid) { - SbEventCancel(submit_done_repeating_callback_event); - } - } -} - -Display::Display(std::unique_ptr display_impl) - : impl_(std::move(display_impl)) {} - -Display::~Display() { - SB_DCHECK(active_surfaces_.empty()); -} - -void Display::GetVersionInfo(EGLint* major, EGLint* minor) { - DisplayImpl::VersionInfo version_info = impl_->GetVersionInfo(); - if (major) { - *major = version_info.major; - } - if (minor) { - *minor = version_info.minor; - } -} - -bool Display::ChooseConfig(const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - if (!num_config) { - SetError(EGL_BAD_PARAMETER); - return false; - } - AttribMap attribs = ParseRawAttribList(attrib_list); - if (!ValidateConfigAttribList(attribs)) { - SetError(EGL_BAD_ATTRIBUTE); - return false; - } - - std::vector configs_vector = - FilterConfigs(impl_->GetSupportedConfigs(), attribs); - SortConfigs(attribs, &configs_vector); - - if (configs) { - *num_config = - std::min(config_size, static_cast(configs_vector.size())); - for (int i = 0; i < *num_config; ++i) { - configs[i] = ToEGLConfig(configs_vector[i]); - } - } else { - *num_config = static_cast(configs_vector.size()); - } - - return true; -} - -bool Display::ConfigIsValid(EGLConfig config) { - const DisplayImpl::ConfigSet& supported_configs = - impl_->GetSupportedConfigs(); - - return supported_configs.find(reinterpret_cast(config)) != - supported_configs.end(); -} - -EGLSurface Display::CreateWindowSurface(EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) { - AttribMap attribs = ParseRawAttribList(attrib_list); - if (!ValidateSurfaceAttribList(attribs)) { - SetError(EGL_BAD_ATTRIBUTE); - return EGL_NO_SURFACE; - } - - if (!ConfigIsValid(config)) { - SetError(EGL_BAD_CONFIG); - return EGL_NO_SURFACE; - } - - if (!((*reinterpret_cast(config))[EGL_SURFACE_TYPE] | - EGL_WINDOW_BIT)) { - // The config used must have the EGL_WINDOW_BIT set in order for us to - // be able to create windows. - SetError(EGL_BAD_MATCH); - return EGL_NO_SURFACE; - } - - std::unique_ptr surface_impl = impl_->CreateWindowSurface( - reinterpret_cast(config), win, attribs); - if (!surface_impl) { - return EGL_NO_SURFACE; - } - - Surface* surface = new Surface(std::move(surface_impl)); - active_surfaces_.insert(surface); - - return ToEGLSurface(surface); -} - -EGLSurface Display::CreatePbufferSurface(EGLConfig config, - const EGLint* attrib_list) { - AttribMap attribs = ParseRawAttribList(attrib_list); - if (!ValidateSurfaceAttribList(attribs)) { - SetError(EGL_BAD_ATTRIBUTE); - return EGL_NO_SURFACE; - } - - if (!ConfigIsValid(config)) { - SetError(EGL_BAD_CONFIG); - return EGL_NO_SURFACE; - } - - if (!((*reinterpret_cast(config))[EGL_SURFACE_TYPE] | - EGL_PBUFFER_BIT)) { - // The config used must have the EGL_PBUFFER_BIT set in order for us to - // be able to create pbuffers. - SetError(EGL_BAD_MATCH); - return EGL_NO_SURFACE; - } - - std::unique_ptr surface_impl = - impl_->CreatePbufferSurface(reinterpret_cast(config), attribs); - if (!surface_impl) { - return EGL_NO_SURFACE; - } - - Surface* surface = new Surface(std::move(surface_impl)); - active_surfaces_.insert(surface); - - return ToEGLSurface(surface); -} - -bool Display::SurfaceIsValid(EGLSurface surface) { - return active_surfaces_.find(FromEGLSurface(surface)) != - active_surfaces_.end(); -} - -bool Display::DestroySurface(EGLSurface surface) { - if (!SurfaceIsValid(surface)) { - SetError(EGL_BAD_SURFACE); - return false; - } - - Surface* surf = FromEGLSurface(surface); - active_surfaces_.erase(surf); - delete surf; - return true; -} - -namespace { -// Returns -1 if the context attributes are invalid. -int GetContextVersion(const EGLint* attrib_list) { - AttribMap attribs = ParseRawAttribList(attrib_list); - - // According to - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglCreateContext.xhtml, - // the default version of the GL ES context is 1. - if (attribs.empty()) { - return 1; - } - - // EGL_CONTEXT_CLIENT_VERSION is the only valid attribute for CreateContext. - AttribMap::const_iterator found = attribs.find(EGL_CONTEXT_CLIENT_VERSION); - if (found == attribs.end()) { - // If we didn't find it, and the attribute list is not empty (checked above) - // then this is an invalid attribute list. - return -1; - } else { - return found->second; - } -} -} // namespace - -EGLContext Display::CreateContext(EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) { - // glimp only supports GL ES versions 2 and 3. - int context_version = GetContextVersion(attrib_list); - if (context_version != 2 && context_version != 3) { - SetError(EGL_BAD_ATTRIBUTE); - return EGL_NO_CONTEXT; - } - - if (!ConfigIsValid(config)) { - SetError(EGL_BAD_CONFIG); - return EGL_NO_CONTEXT; - } - - // Ensure that |share_context| is either unspecified, or valid. - gles::Context* share = NULL; - if (share_context != EGL_NO_CONTEXT) { - if (!ContextIsValid(share_context)) { - SetError(EGL_BAD_CONTEXT); - return EGL_NO_CONTEXT; - } - share = reinterpret_cast(share_context); - } - - std::unique_ptr context_impl = - impl_->CreateContext(reinterpret_cast(config), context_version); - if (!context_impl) { - return EGL_NO_CONTEXT; - } - - gles::Context* context = new gles::Context(std::move(context_impl), share); - active_contexts_.insert(context); - - return reinterpret_cast(context); -} - -bool Display::ContextIsValid(EGLContext context) { - return active_contexts_.find(reinterpret_cast(context)) != - active_contexts_.end(); -} - -bool Display::DestroyContext(EGLContext ctx) { - if (!ContextIsValid(ctx)) { - SetError(EGL_BAD_CONTEXT); - return false; - } - - gles::Context* context = reinterpret_cast(ctx); - active_contexts_.erase(context); - delete context; - return true; -} - -bool Display::MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx) { - if (draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE && - ctx == EGL_NO_CONTEXT) { - if (!ContextIsValid(reinterpret_cast( - gles::Context::GetTLSCurrentContext()))) { - SB_DLOG(WARNING) - << "Attempted to release a context not owned by this display."; - SetError(EGL_BAD_CONTEXT); - return false; - } - gles::Context::ReleaseTLSCurrentContext(); - return true; - } - - if (!ContextIsValid(ctx)) { - SetError(EGL_BAD_CONTEXT); - return false; - } - - if (!SurfaceIsValid(draw)) { - SetError(EGL_BAD_SURFACE); - return false; - } - - if (!SurfaceIsValid(read)) { - SetError(EGL_BAD_SURFACE); - return false; - } - - return gles::Context::SetTLSCurrentContext( - reinterpret_cast(ctx), FromEGLSurface(draw), - FromEGLSurface(read)); -} - -bool Display::SwapBuffers(EGLSurface surface) { - if (!SurfaceIsValid(surface)) { - SetError(EGL_BAD_SURFACE); - return false; - } - Surface* surface_object = FromEGLSurface(surface); - - gles::Context* current_context = gles::Context::GetTLSCurrentContext(); - if (!ContextIsValid(reinterpret_cast(current_context))) { - // The specification for eglSwapBuffers() does not explicitly state that - // the surface's context needs to be current when eglSwapBuffers() is - // called, but we enforce this in glimp as it is a very typical use-case and - // it considerably simplifies the process. - SB_DLOG(WARNING) - << "eglSwapBuffers() called when no or an invalid context was current."; - SetError(EGL_BAD_SURFACE); - return false; - } - - if (current_context->draw_surface() != surface_object) { - SB_DLOG(WARNING) - << "eglSwapBuffers() called on a surface that is not the draw surface " - << "of the current context."; - SetError(EGL_BAD_SURFACE); - return false; - } - - current_context->SwapBuffers(); - return true; -} - -bool Display::SwapInterval(EGLint interval) { - return impl_->SetSwapInterval(interval); -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/display.h b/glimp/egl/display.h deleted file mode 100644 index 090806f26aa7..000000000000 --- a/glimp/egl/display.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2015 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_DISPLAY_H_ -#define GLIMP_EGL_DISPLAY_H_ - -#include - -#include -#include "glimp/egl/config.h" -#include "glimp/egl/display_impl.h" -#include "glimp/gles/context.h" - -namespace glimp { -namespace egl { - -// Encapsulates the concept of an EGL display. There is usually only one of -// these per process, and it represents the entire graphics system. It is -// the highest level object, and the "factory" responsible for generating -// graphics contexts. It is a platform-independent object that wraps a -// platform-dependent DisplayImpl object which must be injected into the Display -// upon construction. -class Display { - public: - static void RepeatSubmitDoneDuringSuspend(); - static bool repeat_submit_done_during_suspend; - - // In order to create a display, it must have a platform-specific - // implementation injected into it, where many methods will forward to. - explicit Display(std::unique_ptr display_impl); - ~Display(); - - void GetVersionInfo(EGLint* major, EGLint* minor); - - bool ChooseConfig(const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config); - bool ConfigIsValid(EGLConfig config); - - EGLSurface CreateWindowSurface(EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list); - EGLSurface CreatePbufferSurface(EGLConfig config, const EGLint* attrib_list); - - bool SurfaceIsValid(EGLSurface surface); - bool DestroySurface(EGLSurface surface); - - EGLContext CreateContext(EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list); - bool ContextIsValid(EGLContext context); - bool DestroyContext(EGLContext ctx); - - bool MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx); - bool SwapBuffers(EGLSurface surface); - bool SwapInterval(EGLint interval); - - DisplayImpl* impl() const { return impl_.get(); } - - private: - std::unique_ptr impl_; - - // Keeps track of all created but not destroyed surfaces. - std::set active_surfaces_; - - // Keeps track of all created but not destroyed contexts. - std::set active_contexts_; -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_DISPLAY_H_ diff --git a/glimp/egl/display_impl.h b/glimp/egl/display_impl.h deleted file mode 100644 index 9583859e9025..000000000000 --- a/glimp/egl/display_impl.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2015 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_DISPLAY_IMPL_H_ -#define GLIMP_EGL_DISPLAY_IMPL_H_ - -#include - -#include - -#include -#include "glimp/egl/attrib_map.h" -#include "glimp/egl/config.h" -#include "glimp/egl/surface.h" -#include "glimp/gles/context_impl.h" - -namespace glimp { -namespace egl { - -// All platform-specific aspects of a EGL Display are implemented within -// subclasses of DisplayImpl. Platforms must also implement -// DisplayImpl::Create(), declared below, in order to define how -// platform-specific DisplayImpls are to be created. -class DisplayImpl { - public: - // Return value type for the method GetVersionInfo(). - struct VersionInfo { - int major; - int minor; - }; - - typedef std::set ConfigSet; - - virtual ~DisplayImpl() {} - - // Returns true if the given |native_display| is a valid display ID that can - // be subsequently passed into Create(). - // To be implemented by each implementing platform. - static bool IsValidNativeDisplayType(EGLNativeDisplayType display_id); - // Creates and returns a new DisplayImpl object. - // To be implemented by each implementing platform. - static std::unique_ptr Create(EGLNativeDisplayType display_id); - // Submit done call. - static void CallSubmitDone(); - - // Returns the EGL major and minor versions, if they are not NULL. - // Called by eglInitialize(): - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglInitialize.xhtml - virtual VersionInfo GetVersionInfo() = 0; - - // Returns *all* configs for this display that may be chosen via a call to - // eglChooseConfig(). - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglChooseConfig.xhtml - virtual const ConfigSet& GetSupportedConfigs() const = 0; - - // Creates and returns a SurfaceImpl object that represents the surface of a - // window and is compatible with this DisplayImpl object. This will be called - // when eglCreateWindowSurface() is called. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglCreateWindowSurface.xhtml - virtual std::unique_ptr CreateWindowSurface( - const Config* config, - EGLNativeWindowType win, - const AttribMap& attributes) = 0; - - // Creates and returns a SurfaceImpl object that represents the surface of a - // Pbuffer and is compatible with this DisplayImpl object. This will be - // called when eglCreatePbufferSurface() is called. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglCreatePbufferSurface.xhtml - virtual std::unique_ptr CreatePbufferSurface( - const Config* config, - const AttribMap& attributes) = 0; - - // Creates and returns a gles::ContextImpl object that contains the platform - // specific implementation of a GL ES Context, of the specified version that - // is compatible with the specified config. - virtual std::unique_ptr CreateContext( - const Config* config, - int gles_version) = 0; - - // Sets the swap behavior for this display. This will be called when - // eglSwapInterval() is called. Returns true on success and false on failure. - // https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglSwapInterval.xhtml - virtual bool SetSwapInterval(int interval) = 0; - - private: -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_DISPLAY_IMPL_H_ diff --git a/glimp/egl/display_registry.cc b/glimp/egl/display_registry.cc deleted file mode 100644 index 88bc338210f3..000000000000 --- a/glimp/egl/display_registry.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/display_registry.h" - -#include -#include - -#include "glimp/egl/display_impl.h" -#include "glimp/egl/error.h" - -namespace glimp { -namespace egl { - -int DisplayRegistry::num_connections_ = 0; -DisplayRegistry::Connection - DisplayRegistry::connections_[DisplayRegistry::kMaxDisplays]; - -EGLDisplay DisplayRegistry::GetDisplay(EGLNativeDisplayType native_display) { - // Check to see if a display already exists for this native_display. If so, - // return it, otherwise create a new one and return that. - for (int i = 0; i < num_connections_; ++i) { - if (connections_[i].native_display == native_display) { - return reinterpret_cast(&connections_[i]); - } - } - - // If the platform-specific implementation does not accept the specified - // |native_display|, return in error. - if (!DisplayImpl::IsValidNativeDisplayType(native_display)) { - return EGL_NO_DISPLAY; - } else { - // Create a new display connection (i.e. EGLDisplay), add it to our - // display mapping so it can be looked up later, and then return it. - SB_CHECK(num_connections_ < kMaxDisplays); - connections_[num_connections_].native_display = native_display; - connections_[num_connections_].display = NULL; - ++num_connections_; - return reinterpret_cast(&connections_[num_connections_ - 1]); - } -} - -bool DisplayRegistry::InitializeDisplay(EGLDisplay display) { - SB_DCHECK(Valid(display)); - Connection* connection = reinterpret_cast(display); - if (!connection->display) { - std::unique_ptr display_impl = - DisplayImpl::Create(connection->native_display); - // If the platform-specific glimp implementation rejected the native - // display, then we return false to indicate failure. - if (!display_impl) { - return false; - } - - connection->display = new Display(std::move(display_impl)); - } - - return true; -} - -void DisplayRegistry::TerminateDisplay(EGLDisplay display) { - SB_DCHECK(Valid(display)); - Connection* connection = reinterpret_cast(display); - - if (connection->display) { - delete connection->display; - connection->display = NULL; - } -} - -bool DisplayRegistry::Valid(EGLDisplay display) { - Connection* connection = reinterpret_cast(display); - for (int i = 0; i < num_connections_; ++i) { - if (connection == &connections_[i]) { - return true; - } - } - return false; -} - -// This function will either return the Display object associated with the -// given EGLDisplay, or else set the appropriate EGL error and then return -// NULL. -egl::Display* GetDisplayOrSetError(EGLDisplay egl_display) { - if (!egl::DisplayRegistry::Valid(egl_display)) { - egl::SetError(EGL_BAD_DISPLAY); - return NULL; - } - egl::Display* display = egl::DisplayRegistry::ToDisplay(egl_display); - if (!display) { - egl::SetError(EGL_NOT_INITIALIZED); - return NULL; - } - - return display; -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/display_registry.h b/glimp/egl/display_registry.h deleted file mode 100644 index 160365ea5d8e..000000000000 --- a/glimp/egl/display_registry.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_DISPLAY_REGISTRY_H_ -#define GLIMP_EGL_DISPLAY_REGISTRY_H_ - -#include "glimp/egl/display.h" -#include "starboard/common/log.h" - -namespace glimp { -namespace egl { - -// Maintains a registry of EGLDisplays as well as mappings from -// EGLNativeDisplayType to those EGLDisplays. Internally, an EGLDisplay is -// represented as a DisplayRegistry::Connection object that has a possibly null -// pointer to a Display object. The Display object will be initialized when -// DisplayRegistry::InitializeDisplay() is called, after which it may be -// retrieved and have methods called on it. -class DisplayRegistry { - public: - // Looks up the mapping from EGLNativeDisplayType to EGLDisplay, or creates - // one if it doesn't already exist, and returns the EGLDisplay associated - // with it. No failures will be reported by this method, it is - // InitializeDisplay() that will ultimately have the platform check - // whether the native display is valid or not. - static EGLDisplay GetDisplay(EGLNativeDisplayType native_display); - - // Construct the Display object, if it has not yet been initialized already. - // This method can fail if the native display associated with the EGLDisplay - // is rejected by the platform. Returns true if the display is already - // initialized or successfully initialized, otherwise returns false. - static bool InitializeDisplay(EGLDisplay display); - - // Terminates the display if it is initialized, otherwise it does nothing. - static void TerminateDisplay(EGLDisplay display); - - // Returns true if the given |display| is valid, which will be true if it - // was at some point previously returned by GetDisplay() and false otherwise. - static bool Valid(EGLDisplay display); - - // Returns the Display object associated with the given [valid] EGLDisplay - // object, or NULL if it is not initialized. - static Display* ToDisplay(EGLDisplay display) { - SB_DCHECK(Valid(display)); - return reinterpret_cast(display)->display; - } - - private: - // A Connection is the internal type of a EGLDisplay handle. It - // maintains a mapping from EGLNativeDisplayType to a (possibly null if it - // hasn't yet been eglInitialize()d) Display object. - struct Connection { - EGLNativeDisplayType native_display; - Display* display; - }; - - static const int kMaxDisplays = 10; - - // The number of display connections currently active. - static int num_connections_; - - // The mapping from native type to possibly initialized connection. - static Connection connections_[kMaxDisplays]; -}; - -// This function will either return the Display object associated with the -// given EGLDisplay, or else set the appropriate EGL error and then return -// NULL. -egl::Display* GetDisplayOrSetError(EGLDisplay egl_display); - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_DISPLAY_REGISTRY_H_ diff --git a/glimp/egl/error.cc b/glimp/egl/error.cc deleted file mode 100644 index 4f88dd979820..000000000000 --- a/glimp/egl/error.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/error.h" - -#include - -#include "starboard/thread.h" - -namespace glimp { -namespace egl { - -namespace { -pthread_once_t s_error_once_control = PTHREAD_ONCE_INIT; -pthread_key_t s_error_tls_key = 0; - -void InitializeError() { - pthread_key_create(&s_error_tls_key, NULL); -} -} // namespace - -EGLint GetError() { - pthread_once(&s_error_once_control, &InitializeError); - void* local_value = pthread_getspecific(s_error_tls_key); - if (local_value == NULL) { - // The EGL error has never been set. In this case, return EGL_SUCCESS as - // that is the initial value for eglGetError(). - // Note that NULL or 0 are not valid EGL error codes. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglGetError.xhtml - return EGL_SUCCESS; - } - return static_cast(reinterpret_cast(local_value)); -} - -void SetError(EGLint error) { - pthread_once(&s_error_once_control, &InitializeError); - pthread_setspecific(s_error_tls_key, reinterpret_cast(error)); -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/error.h b/glimp/egl/error.h deleted file mode 100644 index 51df12261be7..000000000000 --- a/glimp/egl/error.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_ERROR_H_ -#define GLIMP_EGL_ERROR_H_ - -#include - -namespace glimp { -namespace egl { - -// Implements support for getting and setting the thread local EGL error -// value. -// https://www.khronos.org/registry/egl/sdk/docs/man/html/eglGetError.xhtml - -// Returns the current thread local error code. -EGLint GetError(); - -// Sets the current thread local error code. -void SetError(EGLint error); - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_ERROR_H_ diff --git a/glimp/egl/get_proc_address_impl.h b/glimp/egl/get_proc_address_impl.h deleted file mode 100644 index 5ff61c6f4363..000000000000 --- a/glimp/egl/get_proc_address_impl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_GET_PROC_ADDRESS_IMPL_H_ -#define GLIMP_EGL_GET_PROC_ADDRESS_IMPL_H_ - -namespace glimp { -namespace egl { - -typedef void (*MustCastToProperFunctionPointerType)(void); - -// Calls to eglGetProcAddress() that are unhandled by platform-independent -// glimp code are forwarded to this platform-specific call, so that different -// platforms can implement custom extensions. This function should return -// a function pointer to the requested function upon success, and return NULL -// if the requested function is not available. -MustCastToProperFunctionPointerType GetProcAddressImpl(const char* procname); - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_GET_PROC_ADDRESS_IMPL_H_ diff --git a/glimp/egl/scoped_egl_lock.cc b/glimp/egl/scoped_egl_lock.cc deleted file mode 100644 index 572dfb8ba380..000000000000 --- a/glimp/egl/scoped_egl_lock.cc +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/scoped_egl_lock.h" - -namespace glimp { -namespace egl { - -pthread_mutex_t ScopedEGLLock::mutex_ = PTHREAD_MUTEX_INITIALIZER; - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/scoped_egl_lock.h b/glimp/egl/scoped_egl_lock.h deleted file mode 100644 index 442b2c3fd294..000000000000 --- a/glimp/egl/scoped_egl_lock.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_SCOPED_EGL_LOCK_H_ -#define GLIMP_EGL_SCOPED_EGL_LOCK_H_ - -#include - -namespace glimp { -namespace egl { - -// A helper class to enable easy locking of the glimp EGL global mutex. -class ScopedEGLLock { - public: - ScopedEGLLock() { pthread_mutex_lock(&mutex_); } - ~ScopedEGLLock() { pthread_mutex_unlock(&mutex_); } - - private: - static pthread_mutex_t mutex_; -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_SCOPED_EGL_LOCK_H_ diff --git a/glimp/egl/surface.cc b/glimp/egl/surface.cc deleted file mode 100644 index 4a33437e4d21..000000000000 --- a/glimp/egl/surface.cc +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/surface.h" - -#include - -#include "glimp/egl/error.h" -#include "glimp/gles/context.h" -#include "starboard/common/log.h" - -namespace glimp { -namespace egl { - -Surface::Surface(std::unique_ptr surface_impl) - : surface_impl_(std::move(surface_impl)), is_bound_to_texture_(false) {} - -int Surface::GetWidth() const { - return surface_impl_->GetWidth(); -} - -int Surface::GetHeight() const { - return surface_impl_->GetHeight(); -} - -EGLint Surface::GetTextureFormat() const { - return EGL_TEXTURE_RGBA; -} - -EGLint Surface::GetTextureTarget() const { - return EGL_TEXTURE_2D; -} - -EGLBoolean Surface::QuerySurface(EGLint attribute, EGLint* value) { - switch (attribute) { - case EGL_HEIGHT: { - *value = GetHeight(); - return true; - } - - case EGL_WIDTH: { - *value = GetWidth(); - return true; - } - - case EGL_TEXTURE_FORMAT: { - // glimp only supports EGL_TEXTURE_RGBA. - *value = GetTextureFormat(); - return true; - } - - case EGL_TEXTURE_TARGET: { - // glimp only supports EGL_TEXTURE_2D. - *value = GetTextureTarget(); - } - - case EGL_CONFIG_ID: - case EGL_HORIZONTAL_RESOLUTION: - case EGL_LARGEST_PBUFFER: - case EGL_MIPMAP_LEVEL: - case EGL_MIPMAP_TEXTURE: - case EGL_MULTISAMPLE_RESOLVE: - case EGL_PIXEL_ASPECT_RATIO: - case EGL_RENDER_BUFFER: - case EGL_SWAP_BEHAVIOR: - case EGL_VERTICAL_RESOLUTION: { - SB_NOTIMPLEMENTED(); - } // Fall through to default on purpose. - - default: - SetError(EGL_BAD_ATTRIBUTE); - return false; - } - - return true; -} - -EGLBoolean Surface::BindTexImage(EGLint buffer) { - if (buffer != EGL_BACK_BUFFER) { - SetError(EGL_BAD_MATCH); - return false; - } - - if (is_bound_to_texture_) { - SetError(EGL_BAD_ACCESS); - return false; - } - - if (GetTextureTarget() == EGL_NO_TEXTURE) { - SetError(EGL_BAD_MATCH); - return false; - } - if (GetTextureTarget() != EGL_TEXTURE_2D) { - SB_NOTIMPLEMENTED() << "glimp does not support binding anything other than " - "EGL_TEXTURE_2D."; - SetError(EGL_BAD_MATCH); - return false; - } - - // When this method is called, we should bind to the currently bound active - // texture in the current GL context. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglBindTexImage.xhtml - gles::Context* current_context = gles::Context::GetTLSCurrentContext(); - if (current_context == NULL) { - SB_DLOG(WARNING) - << "No GL ES context current during call to eglBindTexImage()."; - // This error is non-specified behavior, but seems reasonable. - SetError(EGL_BAD_CONTEXT); - return false; - } - - is_bound_to_texture_ = current_context->BindTextureToEGLSurface(this); - return is_bound_to_texture_; -} - -EGLBoolean Surface::ReleaseTexImage(EGLint buffer) { - if (buffer != EGL_BACK_BUFFER) { - SetError(EGL_BAD_MATCH); - return false; - } - - if (!is_bound_to_texture_) { - // Nothing to do if the surface is not already bound. - return true; - } - - gles::Context* current_context = gles::Context::GetTLSCurrentContext(); - if (current_context == NULL) { - SB_DLOG(WARNING) - << "No GL ES context current during call to eglReleaseTexImage()."; - // This error is non-specified behavior, but seems reasonable. - SetError(EGL_BAD_CONTEXT); - return false; - } - - if (current_context->ReleaseTextureFromEGLSurface(this)) { - is_bound_to_texture_ = false; - return true; - } else { - return false; - } -} - -namespace { -bool AttributeKeyAndValueAreValid(int key, int value) { - switch (key) { - // First deal with the trivial keys where all values are valid. - case EGL_WIDTH: - case EGL_HEIGHT: { - return true; - } - - case EGL_TEXTURE_TARGET: { - return value == EGL_TEXTURE_2D; - } - - case EGL_TEXTURE_FORMAT: { - return value == EGL_TEXTURE_RGBA; - } - } - - // If the switch statement didn't catch the key, this is an unknown - // key. - // TODO: glimp doesn't support all values yet, and will return false for keys - // that it doesn't support. - return false; -} -} // namespace - -bool ValidateSurfaceAttribList(const AttribMap& attribs) { - for (AttribMap::const_iterator iter = attribs.begin(); iter != attribs.end(); - ++iter) { - if (!AttributeKeyAndValueAreValid(iter->first, iter->second)) { - return false; - } - } - return true; -} - -EGLSurface ToEGLSurface(Surface* surface) { - return reinterpret_cast(surface); -} - -Surface* FromEGLSurface(EGLSurface surface) { - return reinterpret_cast(surface); -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/egl/surface.h b/glimp/egl/surface.h deleted file mode 100644 index 1139796b1568..000000000000 --- a/glimp/egl/surface.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_SURFACE_H_ -#define GLIMP_EGL_SURFACE_H_ - -#include - -#include - -#include -#include "glimp/egl/attrib_map.h" -#include "glimp/egl/surface_impl.h" - -namespace glimp { -namespace egl { - -class Surface { - public: - explicit Surface(std::unique_ptr surface_impl); - - int GetWidth() const; - int GetHeight() const; - - EGLint GetTextureFormat() const; - EGLint GetTextureTarget() const; - - EGLBoolean QuerySurface(EGLint attribute, EGLint* value); - EGLBoolean BindTexImage(EGLint buffer); - EGLBoolean ReleaseTexImage(EGLint buffer); - - bool is_bound_to_texture() const { return is_bound_to_texture_; } - - SurfaceImpl* impl() const { return surface_impl_.get(); } - - private: - std::unique_ptr surface_impl_; - - // True if this surface is currently bound to a GL ES texture via - // eglBindTexImage(). - bool is_bound_to_texture_; -}; - -bool ValidateSurfaceAttribList(const AttribMap& attribs); - -EGLSurface ToEGLSurface(Surface* surface); -Surface* FromEGLSurface(EGLSurface surface); - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_SURFACE_H_ diff --git a/glimp/egl/surface_impl.h b/glimp/egl/surface_impl.h deleted file mode 100644 index fc026c31c66a..000000000000 --- a/glimp/egl/surface_impl.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_EGL_SURFACE_IMPL_H_ -#define GLIMP_EGL_SURFACE_IMPL_H_ - -#include - -namespace glimp { -namespace egl { - -class SurfaceImpl { - public: - virtual ~SurfaceImpl() {} - - // Returns a description of the underlying surface. This method will be - // referenced when functions like eglQuerySurface() are called. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglQuerySurface.xhtml - virtual int GetWidth() const = 0; - virtual int GetHeight() const = 0; - - // Returns true if the surface is a window surface, false if the surface is a - // pixel buffer or a pixmap. - virtual bool IsWindowSurface() const = 0; - - private: -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_EGL_SURFACE_IMPL_H_ diff --git a/glimp/entry_points/egl.cc b/glimp/entry_points/egl.cc deleted file mode 100644 index 71ad8bee8bd4..000000000000 --- a/glimp/entry_points/egl.cc +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright 2015 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "glimp/egl/config.h" -#include "glimp/egl/display.h" -#include "glimp/egl/display_registry.h" -#include "glimp/egl/error.h" -#include "glimp/egl/get_proc_address_impl.h" -#include "glimp/egl/scoped_egl_lock.h" -#include "starboard/common/log.h" - -namespace egl = glimp::egl; - -namespace { -egl::Surface* GetSurfaceOrSetError(EGLDisplay egl_display, - EGLSurface egl_surface) { - egl::Display* display = egl::GetDisplayOrSetError(egl_display); - if (!display) { - return NULL; - } - - if (!display->SurfaceIsValid(egl_surface)) { - egl::SetError(EGL_BAD_SURFACE); - return NULL; - } - - return egl::FromEGLSurface(egl_surface); -} -} // namespace - -extern "C" { - -EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return false; - } - - return display->ChooseConfig(attrib_list, configs, config_size, num_config); -} - -EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return EGL_NO_CONTEXT; - } - - return display->CreateContext(config, share_context, attrib_list); -} - -EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return EGL_NO_SURFACE; - } - - return display->CreatePbufferSurface(config, attrib_list); -} - -EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_SURFACE; -} - -EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return EGL_NO_SURFACE; - } - - return display->CreateWindowSurface(config, win, attrib_list); -} - -EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return false; - } - - return display->DestroyContext(ctx); -} - -EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return false; - } - - return display->DestroySurface(surface); -} - -EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_DISPLAY; -} - -EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_SURFACE; -} - -EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { - egl::ScopedEGLLock egl_lock; - return egl::DisplayRegistry::GetDisplay(display_id); -} - -EGLint EGLAPIENTRY eglGetError(void) { - // No lock needed as this function accesses only thread local data. - return egl::GetError(); -} - -EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, - EGLint* major, - EGLint* minor) { - egl::ScopedEGLLock egl_lock; - if (!egl::DisplayRegistry::Valid(dpy)) { - egl::SetError(EGL_BAD_DISPLAY); - return false; - } - if (!egl::DisplayRegistry::InitializeDisplay(dpy)) { - egl::SetError(EGL_NOT_INITIALIZED); - return false; - } - - egl::Display* display = egl::DisplayRegistry::ToDisplay(dpy); - display->GetVersionInfo(major, minor); - - egl::SetError(EGL_SUCCESS); - egl::Display::repeat_submit_done_during_suspend = false; - egl::Display::RepeatSubmitDoneDuringSuspend(); - return true; -} - -EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return false; - } - - return display->MakeCurrent(draw, read, ctx); -} - -EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -const char* EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return NULL; -} - -EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value) { - egl::ScopedEGLLock egl_lock; - - egl::Surface* surf = GetSurfaceOrSetError(dpy, surface); - if (!surf) { - return false; - } - - return surf->QuerySurface(attribute, value); -} - -EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { - egl::ScopedEGLLock egl_lock; - - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return false; - } - - return display->SwapBuffers(surface); -} - -EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { - egl::ScopedEGLLock egl_lock; - if (!egl::DisplayRegistry::Valid(dpy)) { - egl::SetError(EGL_BAD_DISPLAY); - return false; - } - - egl::DisplayRegistry::TerminateDisplay(dpy); - - egl::SetError(EGL_SUCCESS); - egl::Display::repeat_submit_done_during_suspend = true; - egl::Display::RepeatSubmitDoneDuringSuspend(); - return true; -} - -EGLBoolean EGLAPIENTRY eglWaitGL(void) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - egl::ScopedEGLLock egl_lock; - - egl::Surface* surf = GetSurfaceOrSetError(dpy, surface); - if (!surf) { - return false; - } - - return surf->BindTexImage(buffer); -} - -EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer) { - egl::ScopedEGLLock egl_lock; - - egl::Surface* surf = GetSurfaceOrSetError(dpy, surface); - if (!surf) { - return false; - } - - return surf->ReleaseTexImage(buffer); -} - -EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) { - egl::ScopedEGLLock egl_lock; - egl::Display* display = egl::GetDisplayOrSetError(dpy); - if (!display) { - return false; - } - - return display->SwapInterval(interval); -} - -EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLenum EGLAPIENTRY eglQueryAPI(void) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return 0; -} - -EGLSurface EGLAPIENTRY -eglCreatePbufferFromClientBuffer(EGLDisplay dpy, - EGLenum buftype, - EGLClientBuffer buffer, - EGLConfig config, - const EGLint* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_SURFACE; -} - -EGLBoolean EGLAPIENTRY eglReleaseThread(void) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglWaitClient(void) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLContext EGLAPIENTRY eglGetCurrentContext(void) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_CONTEXT; -} - -EGLSync EGLAPIENTRY eglCreateSync(EGLDisplay dpy, - EGLenum type, - const EGLAttrib* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return 0; -} - -EGLBoolean EGLAPIENTRY eglDestroySync(EGLDisplay dpy, EGLSync sync) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLint EGLAPIENTRY eglClientWaitSync(EGLDisplay dpy, - EGLSync sync, - EGLint flags, - EGLTime timeout) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return 0; -} - -EGLBoolean EGLAPIENTRY eglGetSyncAttrib(EGLDisplay dpy, - EGLSync sync, - EGLint attribute, - EGLAttrib* value) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLImage EGLAPIENTRY eglCreateImage(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLAttrib* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return 0; -} - -EGLBoolean EGLAPIENTRY eglDestroyImage(EGLDisplay dpy, EGLImage image) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -EGLDisplay EGLAPIENTRY eglGetPlatformDisplay(EGLenum platform, - void* native_display, - const EGLAttrib* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_DISPLAY; -} - -EGLSurface EGLAPIENTRY -eglCreatePlatformWindowSurface(EGLDisplay dpy, - EGLConfig config, - void* native_window, - const EGLAttrib* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_SURFACE; -} - -EGLSurface EGLAPIENTRY -eglCreatePlatformPixmapSurface(EGLDisplay dpy, - EGLConfig config, - void* native_pixmap, - const EGLAttrib* attrib_list) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return EGL_NO_SURFACE; -} - -EGLBoolean EGLAPIENTRY eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) { - egl::ScopedEGLLock egl_lock; - SB_NOTIMPLEMENTED(); - return false; -} - -__eglMustCastToProperFunctionPointerType EGLAPIENTRY -eglGetProcAddress(const char* procname) { - egl::ScopedEGLLock egl_lock; - - // Forward the call on to platform-specific code to possibly handle. - return egl::GetProcAddressImpl(procname); -} - -} // extern "C" diff --git a/glimp/entry_points/egl_ext.cc b/glimp/entry_points/egl_ext.cc deleted file mode 100644 index 944bc700e799..000000000000 --- a/glimp/entry_points/egl_ext.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "starboard/common/log.h" - -extern "C" { - -EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value) { - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height) { - SB_NOTIMPLEMENTED(); - return false; -} - -EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platform, - void* native_display, - const EGLint* attrib_list) { - SB_NOTIMPLEMENTED(); - return EGL_NO_DISPLAY; -} - -EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT(EGLDisplay dpy, - EGLint attribute, - EGLAttrib* value) { - SB_NOTIMPLEMENTED(); - return false; -} - -EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT(EGLDeviceEXT device, - EGLint attribute, - EGLAttrib* value) { - SB_NOTIMPLEMENTED(); - return false; -} - -const char* EGLAPIENTRY eglQueryDeviceStringEXT(EGLDeviceEXT device, - EGLint name) { - SB_NOTIMPLEMENTED(); - return NULL; -} - -EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list) { - SB_NOTIMPLEMENTED(); - return 0; -} - -EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) { - SB_NOTIMPLEMENTED(); - return false; -} - -EGLDeviceEXT EGLAPIENTRY eglCreateDeviceANGLE(EGLint device_type, - void* native_device, - const EGLAttrib* attrib_list) { - SB_NOTIMPLEMENTED(); - return 0; -} - -EGLBoolean EGLAPIENTRY eglReleaseDeviceANGLE(EGLDeviceEXT device) { - SB_NOTIMPLEMENTED(); - return false; -} - -} // extern "C" diff --git a/glimp/entry_points/gles_2_0.cc b/glimp/entry_points/gles_2_0.cc deleted file mode 100644 index cd6b5148f3e3..000000000000 --- a/glimp/entry_points/gles_2_0.cc +++ /dev/null @@ -1,1284 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "glimp/gles/context.h" -#include "starboard/common/log.h" - -namespace gles = glimp::gles; - -namespace { -gles::Context* GetCurrentContext() { - gles::Context* context = gles::Context::GetTLSCurrentContext(); - SB_DCHECK(context) << "GL ES command issued while no context was current."; - return context; -} -} // namespace - -extern "C" { - -void GL_APIENTRY glActiveTexture(GLenum texture) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->ActiveTexture(texture); -} - -void GL_APIENTRY glAttachShader(GLuint program, GLuint shader) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->AttachShader(program, shader); -} - -void GL_APIENTRY glBindAttribLocation(GLuint program, - GLuint index, - const GLchar* name) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BindAttribLocation(program, index, name); -} - -void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BindBuffer(target, buffer); -} - -void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BindFramebuffer(target, framebuffer); -} - -void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BindRenderbuffer(target, renderbuffer); -} - -void GL_APIENTRY glBindTexture(GLenum target, GLuint texture) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->BindTexture(target, texture); -} - -void GL_APIENTRY glBlendColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBlendEquation(GLenum mode) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BlendEquation(mode); -} - -void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BlendFunc(sfactor, dfactor); -} - -void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBufferData(GLenum target, - GLsizeiptr size, - const GLvoid* data, - GLenum usage) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BufferData(target, size, data, usage); -} - -void GL_APIENTRY glBufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const GLvoid* data) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->BufferSubData(target, offset, size, data); -} - -GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return 0; - } - - return context->CheckFramebufferStatus(target); -} - -void GL_APIENTRY glClear(GLbitfield mask) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Clear(mask); -} - -void GL_APIENTRY glClearColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->ClearColor(red, green, blue, alpha); -} - -void GL_APIENTRY glClearDepthf(GLfloat depth) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glClearStencil(GLint s) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->ClearStencil(s); -} - -void GL_APIENTRY glColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->ColorMask(red, green, blue, alpha); -} - -void GL_APIENTRY glCompileShader(GLuint shader) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->CompileShader(shader); -} - -void GL_APIENTRY glCompressedTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const GLvoid* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const GLvoid* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glCopyTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glCopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, - width, height); -} - -GLuint GL_APIENTRY glCreateProgram(void) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return 0; - } - - return context->CreateProgram(); -} - -GLuint GL_APIENTRY glCreateShader(GLenum type) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return 0; - } - - return context->CreateShader(type); -} - -void GL_APIENTRY glCullFace(GLenum mode) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->CullFace(mode); -} - -void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DeleteBuffers(n, buffers); -} - -void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DeleteFramebuffers(n, framebuffers); -} - -void GL_APIENTRY glDeleteProgram(GLuint program) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DeleteProgram(program); -} - -void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DeleteRenderbuffers(n, renderbuffers); -} - -void GL_APIENTRY glDeleteShader(GLuint shader) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DeleteShader(shader); -} - -void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DeleteTextures(n, textures); -} - -void GL_APIENTRY glDepthFunc(GLenum func) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDepthMask(GLboolean flag) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->DepthMask(flag); -} - -void GL_APIENTRY glDepthRangef(GLfloat n, GLfloat f) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDetachShader(GLuint program, GLuint shader) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDisable(GLenum cap) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Disable(cap); -} - -void GL_APIENTRY glDisableVertexAttribArray(GLuint index) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DisableVertexAttribArray(index); -} - -void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DrawArrays(mode, first, count); -} - -void GL_APIENTRY glDrawElements(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid* indices) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->DrawElements(mode, count, type, indices); -} - -void GL_APIENTRY glEnable(GLenum cap) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Enable(cap); -} - -void GL_APIENTRY glEnableVertexAttribArray(GLuint index) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->EnableVertexAttribArray(index); -} - -void GL_APIENTRY glFinish(void) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->Finish(); -} - -void GL_APIENTRY glFlush(void) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->Flush(); -} - -void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->FramebufferRenderbuffer(target, attachment, - renderbuffertarget, renderbuffer); -} - -void GL_APIENTRY glFramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->FramebufferTexture2D(target, attachment, textarget, texture, - level); -} - -void GL_APIENTRY glFrontFace(GLenum face) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->FrontFace(face); -} - -void GL_APIENTRY glGenBuffersForVideoFrame(GLsizei n, GLuint* buffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->GenBuffersForVideoFrame(n, buffers); -} - -void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->GenBuffers(n, buffers); -} - -void GL_APIENTRY glGenerateMipmap(GLenum target) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->GenFramebuffers(n, framebuffers); -} - -void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->GenRenderbuffers(n, renderbuffers); -} - -void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->GenTextures(n, textures); -} - -void GL_APIENTRY glGetActiveAttrib(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetActiveUniform(GLuint program, - GLuint index, - GLsizei bufsize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetAttachedShaders(GLuint program, - GLsizei maxcount, - GLsizei* count, - GLuint* shaders) { - SB_NOTIMPLEMENTED(); -} - -GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name) { - SB_NOTIMPLEMENTED(); - return 0; -} - -void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -GLenum GL_APIENTRY glGetError(void) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return GL_NO_ERROR; - } - - return context->GetError(); -} - -void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->GetIntegerv(pname, params); -} - -void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->GetProgramiv(program, pname, params); -} - -void GL_APIENTRY glGetProgramInfoLog(GLuint program, - GLsizei bufsize, - GLsizei* length, - GLchar* infolog) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->GetProgramInfoLog(program, bufsize, length, infolog); -} - -void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->GetShaderiv(shader, pname, params); -} - -void GL_APIENTRY glGetShaderInfoLog(GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* infolog) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->GetShaderInfoLog(shader, bufsize, length, infolog); -} - -void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetShaderSource(GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* source) { - SB_NOTIMPLEMENTED(); -} - -const GLubyte* GL_APIENTRY glGetString(GLenum name) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return NULL; - } - - return context->GetString(name); -} - -void GL_APIENTRY glGetTexParameterfv(GLenum target, - GLenum pname, - GLfloat* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetTexParameteriv(GLenum target, - GLenum pname, - GLint* params) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->GetTexParameteriv(target, pname, params); -} - -void GL_APIENTRY glGetUniformfv(GLuint program, - GLint location, - GLfloat* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params) { - SB_NOTIMPLEMENTED(); -} - -GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return -1; - } - - return context->GetUniformLocation(program, name); -} - -void GL_APIENTRY glGetVertexAttribfv(GLuint index, - GLenum pname, - GLfloat* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetVertexAttribiv(GLuint index, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, - GLenum pname, - GLvoid** pointer) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glHint(GLenum target, GLenum mode) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsBuffer(GLuint buffer) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glIsEnabled(GLenum cap) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glIsProgram(GLuint program) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glIsShader(GLuint shader) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glIsTexture(GLuint texture) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glLineWidth(GLfloat width) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->LineWidth(width); -} - -void GL_APIENTRY glLinkProgram(GLuint program) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->LinkProgram(program); -} - -void GL_APIENTRY glPixelStorei(GLenum pname, GLint param) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->PixelStorei(pname, param); -} - -void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLvoid* pixels) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->ReadPixels(x, y, width, height, format, type, pixels); -} - -void GL_APIENTRY glReleaseShaderCompiler(void) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glRenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->RenderbufferStorage(target, internalformat, width, height); -} - -void GL_APIENTRY glSampleCoverage(GLfloat value, GLboolean invert) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->Scissor(x, y, width, height); -} - -void GL_APIENTRY glShaderBinary(GLsizei n, - const GLuint* shaders, - GLenum binaryformat, - const GLvoid* binary, - GLsizei length) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->ShaderSource(shader, count, string, length); -} - -void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glStencilFuncSeparate(GLenum face, - GLenum func, - GLint ref, - GLuint mask) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glStencilMask(GLuint mask) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->StencilMask(mask); -} - -void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glStencilOpSeparate(GLenum face, - GLenum fail, - GLenum zfail, - GLenum zpass) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const GLvoid* pixels) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->TexImage2D(target, level, internalformat, width, height, - border, format, type, pixels); -} - -void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexParameterfv(GLenum target, - GLenum pname, - const GLfloat* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->TexParameteri(target, pname, param); -} - -void GL_APIENTRY glTexParameteriv(GLenum target, - GLenum pname, - const GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const GLvoid* pixels) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->TexSubImage2D(target, level, xoffset, yoffset, width, height, - format, type, pixels); -} - -void GL_APIENTRY glUniform1f(GLint location, GLfloat x) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformfv(location, 1, 1, &x); -} - -void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformfv(location, count, 1, v); -} - -void GL_APIENTRY glUniform1i(GLint location, GLint x) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformiv(location, 1, 1, &x); -} - -void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformiv(location, count, 1, v); -} - -void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - float v[2]; - v[0] = x; - v[1] = y; - context->Uniformfv(location, 1, 2, v); -} - -void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformfv(location, count, 2, v); -} - -void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - int v[2]; - v[0] = x; - v[1] = y; - context->Uniformiv(location, 1, 2, v); -} - -void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformiv(location, count, 2, v); -} - -void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - float v[3]; - v[0] = x; - v[1] = y; - v[2] = z; - context->Uniformfv(location, 1, 3, v); -} - -void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformfv(location, count, 3, v); -} - -void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - int v[3]; - v[0] = x; - v[1] = y; - v[2] = z; - context->Uniformiv(location, 1, 3, v); -} - -void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformiv(location, count, 3, v); -} - -void GL_APIENTRY -glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - float v[4]; - v[0] = x; - v[1] = y; - v[2] = z; - v[3] = w; - context->Uniformfv(location, 1, 4, v); -} - -void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformfv(location, count, 4, v); -} - -void GL_APIENTRY -glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - int v[4]; - v[0] = x; - v[1] = y; - v[2] = z; - v[3] = w; - context->Uniformiv(location, 1, 4, v); -} - -void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->Uniformiv(location, count, 4, v); -} - -void GL_APIENTRY glUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->UniformMatrixfv(location, count, transpose, 2, value); -} - -void GL_APIENTRY glUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->UniformMatrixfv(location, count, transpose, 3, value); -} - -void GL_APIENTRY glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - context->UniformMatrixfv(location, count, transpose, 4, value); -} - -void GL_APIENTRY glUseProgram(GLuint program) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->UseProgram(program); -} - -void GL_APIENTRY glValidateProgram(GLuint program) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glVertexAttrib1f(GLuint indx, GLfloat x) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->VertexAttribfv(indx, 1, &x); -} - -void GL_APIENTRY glVertexAttrib1fv(GLuint indx, const GLfloat* values) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->VertexAttribfv(indx, 1, values); -} - -void GL_APIENTRY glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - GLfloat values[2] = {x, y}; - return context->VertexAttribfv(indx, 2, values); -} - -void GL_APIENTRY glVertexAttrib2fv(GLuint indx, const GLfloat* values) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->VertexAttribfv(indx, 2, values); -} - -void GL_APIENTRY glVertexAttrib3f(GLuint indx, - GLfloat x, - GLfloat y, - GLfloat z) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - GLfloat values[3] = {x, y, z}; - return context->VertexAttribfv(indx, 3, values); -} - -void GL_APIENTRY glVertexAttrib3fv(GLuint indx, const GLfloat* values) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->VertexAttribfv(indx, 3, values); -} - -void GL_APIENTRY -glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - GLfloat values[4] = {x, y, z, w}; - return context->VertexAttribfv(indx, 4, values); -} - -void GL_APIENTRY glVertexAttrib4fv(GLuint indx, const GLfloat* values) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->VertexAttribfv(indx, 4, values); -} - -void GL_APIENTRY glVertexAttribPointer(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const GLvoid* ptr) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->VertexAttribPointer(indx, size, type, normalized, stride, - ptr); -} - -void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return; - } - - return context->Viewport(x, y, width, height); -} - -} // extern "C" diff --git a/glimp/entry_points/gles_2_0_ext.cc b/glimp/entry_points/gles_2_0_ext.cc deleted file mode 100644 index bc1e01dbacda..000000000000 --- a/glimp/entry_points/gles_2_0_ext.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "starboard/common/log.h" - -extern "C" { - -void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDiscardFramebufferEXT(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsFenceNV(GLuint fence) { - SB_NOTIMPLEMENTED(); - return false; -} - -GLboolean GL_APIENTRY glTestFenceNV(GLuint fence) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glFinishFenceNV(GLuint fence) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* source) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexStorage2DEXT(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) { - SB_NOTIMPLEMENTED(); -} - -GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void) { - SB_NOTIMPLEMENTED(); - return 0; -} - -void GL_APIENTRY glReadnPixelsEXT(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetnUniformfvEXT(GLuint program, - GLint location, - GLsizei bufSize, - float* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetnUniformivEXT(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint* ids) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsQueryEXT(GLuint id) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glEndQueryEXT(GLenum target) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, - GLenum pname, - GLuint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum* bufs) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetProgramBinaryOES(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glProgramBinaryOES(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLint length) { - SB_NOTIMPLEMENTED(); -} - -void* GL_APIENTRY glMapBufferOES(GLenum target, GLenum access) { - SB_NOTIMPLEMENTED(); - return NULL; -} - -GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glGetBufferPointervOES(GLenum target, - GLenum pname, - GLvoid** params) { - SB_NOTIMPLEMENTED(); -} - -void* GL_APIENTRY glMapBufferRangeEXT(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - SB_NOTIMPLEMENTED(); - return NULL; -} - -void GL_APIENTRY glFlushMappedBufferRangeEXT(GLenum target, - GLintptr offset, - GLsizeiptr length) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glInsertEventMarkerEXT(GLsizei length, const char* marker) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glPushGroupMarkerEXT(GLsizei length, const char* marker) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glPopGroupMarkerEXT() { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, - GLeglImageOES image) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, - GLeglImageOES image) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBindVertexArrayOES(GLuint array) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenVertexArraysOES(GLsizei n, GLuint* arrays) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsVertexArrayOES(GLuint array) { - SB_NOTIMPLEMENTED(); - return false; -} - -} // extern "C" diff --git a/glimp/entry_points/gles_3_0.cc b/glimp/entry_points/gles_3_0.cc deleted file mode 100644 index 66f8c271544f..000000000000 --- a/glimp/entry_points/gles_3_0.cc +++ /dev/null @@ -1,685 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "glimp/gles/context.h" -#include "starboard/common/log.h" - -namespace gles = glimp::gles; - -namespace { -gles::Context* GetCurrentContext() { - gles::Context* context = gles::Context::GetTLSCurrentContext(); - if (!context) { - SB_DLOG(WARNING) << "GL ES command issued while no context was current."; - } - return context; -} -} // namespace - -extern "C" { - -void GL_APIENTRY glReadBuffer(GLenum mode) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid* indices) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexImage3D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const GLvoid* pixels) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - const GLvoid* pixels) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glCopyTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glCompressedTexImage3D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const GLvoid* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLsizei imageSize, - const GLvoid* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsQuery(GLuint id) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glBeginQuery(GLenum target, GLuint id) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glEndQuery(GLenum target) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glUnmapBuffer(GLenum target) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return GL_FALSE; - } - - return context->UnmapBuffer(target); -} - -void GL_APIENTRY glGetBufferPointerv(GLenum target, - GLenum pname, - GLvoid** params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBlitFramebuffer(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glFramebufferTextureLayer(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer) { - SB_NOTIMPLEMENTED(); -} - -GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - gles::Context* context = GetCurrentContext(); - if (!context) { - return NULL; - } - - return context->MapBufferRange(target, offset, length, access); -} - -void GL_APIENTRY glFlushMappedBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBindVertexArray(GLuint array) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsVertexArray(GLuint array) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glEndTransformFeedback(void) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBindBufferRange(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glVertexAttribIPointer(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const GLvoid* pointer) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetVertexAttribIiv(GLuint index, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, - GLenum pname, - GLuint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY -glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY -glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetUniformuiv(GLuint program, - GLint location, - GLuint* params) { - SB_NOTIMPLEMENTED(); -} - -GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar* name) { - SB_NOTIMPLEMENTED(); - return 0; -} - -void GL_APIENTRY glUniform1ui(GLint location, GLuint v0) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY -glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniform1uiv(GLint location, - GLsizei count, - const GLuint* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniform2uiv(GLint location, - GLsizei count, - const GLuint* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniform3uiv(GLint location, - GLsizei count, - const GLuint* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniform4uiv(GLint location, - GLsizei count, - const GLuint* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glClearBufferiv(GLenum buffer, - GLint drawbuffer, - const GLint* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glClearBufferuiv(GLenum buffer, - GLint drawbuffer, - const GLuint* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glClearBufferfv(GLenum buffer, - GLint drawbuffer, - const GLfloat* value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glClearBufferfi(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil) { - SB_NOTIMPLEMENTED(); -} - -const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index) { - SB_NOTIMPLEMENTED(); - return NULL; -} - -void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetUniformIndices(GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetActiveUniformsiv(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, - const GLchar* uniformBlockName) { - SB_NOTIMPLEMENTED(); - return 0; -} - -void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glUniformBlockBinding(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawArraysInstanced(GLenum mode, - GLint first, - GLsizei count, - GLsizei instanceCount) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDrawElementsInstanced(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid* indices, - GLsizei instanceCount) { - SB_NOTIMPLEMENTED(); -} - -GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags) { - SB_NOTIMPLEMENTED(); - return 0; -} - -GLboolean GL_APIENTRY glIsSync(GLsync sync) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glDeleteSync(GLsync sync) { - SB_NOTIMPLEMENTED(); -} - -GLenum GL_APIENTRY glClientWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - SB_NOTIMPLEMENTED(); - return 0; -} - -void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetSynciv(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetBufferParameteri64v(GLenum target, - GLenum pname, - GLint64* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsSampler(GLuint sampler) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glSamplerParameteri(GLuint sampler, - GLenum pname, - GLint param) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glSamplerParameteriv(GLuint sampler, - GLenum pname, - const GLint* param) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glSamplerParameterf(GLuint sampler, - GLenum pname, - GLfloat param) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glSamplerParameterfv(GLuint sampler, - GLenum pname, - const GLfloat* param) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, - GLenum pname, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, - GLenum pname, - GLfloat* params) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids) { - SB_NOTIMPLEMENTED(); -} - -GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id) { - SB_NOTIMPLEMENTED(); - return false; -} - -void GL_APIENTRY glPauseTransformFeedback(void) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glResumeTransformFeedback(void) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetProgramBinary(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - GLvoid* binary) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glProgramBinary(GLuint program, - GLenum binaryFormat, - const GLvoid* binary, - GLsizei length) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glProgramParameteri(GLuint program, - GLenum pname, - GLint value) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glInvalidateFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glInvalidateSubFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexStorage2D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glTexStorage3D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth) { - SB_NOTIMPLEMENTED(); -} - -void GL_APIENTRY glGetInternalformativ(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params) { - SB_NOTIMPLEMENTED(); -} - -} // extern "C" diff --git a/glimp/gles/blend_state.h b/glimp/gles/blend_state.h deleted file mode 100644 index e04f8b7b1e52..000000000000 --- a/glimp/gles/blend_state.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_BLEND_STATE_H_ -#define GLIMP_GLES_BLEND_STATE_H_ - -namespace glimp { -namespace gles { - -// Describes GL blend state, which can be modified via commands like -// glBlendFunc(). -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml -struct BlendState { - enum Factor { - kFactorZero, - kFactorOne, - kFactorSrcColor, - kFactorOneMinusSrcColor, - kFactorDstColor, - kFactorOneMinusDstColor, - kFactorSrcAlpha, - kFactorOneMinusSrcAlpha, - kFactorDstAlpha, - kFactorOneMinusDstAlpha, - kFactorConstantColor, - kFactorOneMinusConstantColor, - kFactorConstantAlpha, - kFactorOneMinusConstantAlpha, - kFactorSrcAlphaSaturate, - kFactorInvalid, - }; - - // https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glBlendEquation.xml - enum Equation { - kEquationFuncAdd, - kEquationFuncSubtract, - kEquationFuncReverseSubtract, - kEquationFuncInvalid, - }; - - // Setup the blend state with initial values specified by the specification. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml - BlendState() - : src_factor(kFactorOne), - dst_factor(kFactorZero), - enabled(false), - equation(kEquationFuncAdd) {} - - Factor src_factor; - Factor dst_factor; - - Equation equation; - - bool enabled; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_BLEND_STATE_H_ diff --git a/glimp/gles/buffer.cc b/glimp/gles/buffer.cc deleted file mode 100644 index eabd4ae904b3..000000000000 --- a/glimp/gles/buffer.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/buffer.h" - -#include - -namespace glimp { -namespace gles { - -namespace { - -BufferImpl::Usage GLUsageEnumToUsage(GLenum usage) { - switch (usage) { - case GL_STREAM_DRAW: - return BufferImpl::kStreamDraw; - case GL_STATIC_DRAW: - return BufferImpl::kStaticDraw; - case GL_DYNAMIC_DRAW: - return BufferImpl::kDynamicDraw; - } - - SB_NOTREACHED(); - return BufferImpl::kStaticDraw; -} - -} // namespace - -Buffer::Buffer(std::unique_ptr impl) - : impl_(std::move(impl)), size_in_bytes_(0) {} - -bool Buffer::Allocate(GLenum usage, size_t size) { - size_in_bytes_ = size; - return impl_->Allocate(GLUsageEnumToUsage(usage), size); -} - -bool Buffer::SetData(GLintptr offset, GLsizeiptr size, const GLvoid* data) { - SB_DCHECK(size_in_bytes_ >= offset + size); - SB_DCHECK(offset >= 0); - SB_DCHECK(size >= 0); - SB_DCHECK(!is_mapped_); - - if (size > 0) { - return impl_->SetData(offset, static_cast(size), data); - } else { - return true; - } -} - -void* Buffer::Map() { - SB_DCHECK(!is_mapped_); - is_mapped_ = true; - - return impl_->Map(); -} - -bool Buffer::Unmap() { - SB_DCHECK(is_mapped_); - is_mapped_ = false; - - return impl_->Unmap(); -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/buffer.h b/glimp/gles/buffer.h deleted file mode 100644 index 8391442e42f6..000000000000 --- a/glimp/gles/buffer.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_BUFFER_H_ -#define GLIMP_GLES_BUFFER_H_ - -#include - -#include -#include "glimp/gles/buffer_impl.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class Buffer : public nb::RefCountedThreadSafe { - public: - explicit Buffer(std::unique_ptr impl); - - // Allocates memory within this Buffer object. Returns false if there - // was an allocation failure. - bool Allocate(GLenum usage, size_t size); - - // Implements support for glBufferData() on this buffer object. Returns - // false if there was an allocation failure. - bool SetData(GLintptr offset, GLsizeiptr size, const GLvoid* data); - - // Maps the buffer's memory to a CPU-accessible pointer and returns it, or - // NULL on failure. - void* Map(); - bool Unmap(); - - // Returns true if the buffer is currently mapped to the CPU address space. - bool is_mapped() const { return is_mapped_; } - - GLsizeiptr size_in_bytes() const { return size_in_bytes_; } - - BufferImpl* impl() const { return impl_.get(); } - - private: - friend class nb::RefCountedThreadSafe; - ~Buffer() {} - - std::unique_ptr impl_; - - // The size of the allocated memory used by this buffer. - GLsizeiptr size_in_bytes_; - - // Is the buffer's data currently mapped to CPU address space? - bool is_mapped_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_BUFFER_H_ diff --git a/glimp/gles/buffer_impl.h b/glimp/gles/buffer_impl.h deleted file mode 100644 index 2845a02221cc..000000000000 --- a/glimp/gles/buffer_impl.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_BUFFER_IMPL_H_ -#define GLIMP_GLES_BUFFER_IMPL_H_ - -#include - -namespace glimp { -namespace gles { - -// Implements functionality required to support GL memory buffers. These -// buffers are typically used to store vertex data and vertex index data, -// however it can also be used to store texture data that can later be used -// to create a texture. -class BufferImpl { - public: - // Corresponds to the |usage| GLenum passed into glBufferData(). - enum Usage { - kStreamDraw, - kStaticDraw, - kDynamicDraw, - }; - - virtual ~BufferImpl() {} - - // Sets the size and usage of allocated memory for the buffer. - // Since no data is available at this point, implementations are free to - // delay the actual allocation of memory until data is provided. Called from - // glBufferData(). Returns true on success and false on failure. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBufferData.xml - virtual bool Allocate(Usage usage, size_t size) = 0; - - // Upload the specified data into this buffer. Allocate() must have - // previously been called for a call to SetData() to be valid. - // This method is called by glBufferData() (when data is not NULL) and - // glBufferSubData(). Returns true on success and false on an allocation - // failure. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBufferData.xml - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBufferSubData.xml - virtual bool SetData(intptr_t offset, size_t size, const void* data) = 0; - - // Maps the buffer's data to a CPU-addressible memory location and then - // returns a pointer to that location. This method is called when - // glMapBufferRange() is called. glimp only supports calls to - // glMapBufferRange() with the flag GL_MAP_INVALIDATE_BUFFER_BIT set, - // therefore this method is free to throw away any existing memory when - // this method is called. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml - virtual void* Map() = 0; - - // Unmaps the data previously mapped to a CPU-addressible memory location - // through a call to Map(). This method will be called when - // glUnmapBuffer() is called. This command should return false if the - // underlying buffer resource has become invalid while the memory was mapped. - // Otherwise, it should return true. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml - virtual bool Unmap() = 0; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_BUFFER_IMPL_H_ diff --git a/glimp/gles/context.cc b/glimp/gles/context.cc deleted file mode 100644 index 33bda203b0aa..000000000000 --- a/glimp/gles/context.cc +++ /dev/null @@ -1,2551 +0,0 @@ -/* - * Copyright 2015 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/context.h" - -#include - -#include -#include - -#include "glimp/egl/error.h" -#include "glimp/egl/surface.h" -#include "glimp/gles/blend_state.h" -#include "glimp/gles/cull_face_state.h" -#include "glimp/gles/draw_mode.h" -#include "glimp/gles/index_data_type.h" -#include "glimp/gles/pixel_format.h" -#include "glimp/tracing/tracing.h" -#include "starboard/common/log.h" -#include "starboard/common/once.h" -#include "starboard/common/pointer_arithmetic.h" -#include "starboard/memory.h" - -namespace glimp { -namespace gles { - -namespace { - -std::atomic_int s_context_id_counter_(0); -pthread_once_t s_tls_current_context_key_once_control = PTHREAD_ONCE_INIT; -pthread_key_t s_tls_current_context_key = 0; - -void InitializeThreadLocalKey() { - pthread_key_create(&s_tls_current_context_key, NULL); -} - -pthread_key_t GetThreadLocalKey() { - pthread_once(&s_tls_current_context_key_once_control, - &InitializeThreadLocalKey); - return s_tls_current_context_key; -} - -} // namespace - -Context::Context(std::unique_ptr context_impl, - Context* share_context) - : impl_(std::move(context_impl)), - context_id_(s_context_id_counter_++), - current_thread_(kSbThreadInvalid), - has_been_current_(false), - active_texture_(GL_TEXTURE0), - enabled_textures_dirty_(true), - enabled_vertex_attribs_dirty_(true), - pack_alignment_(4), - unpack_alignment_(4), - unpack_row_length_(0), - error_(GL_NO_ERROR) { - SbAtomicRelease_Store(&has_swapped_buffers_, 0); - if (share_context != NULL) { - resource_manager_ = share_context->resource_manager_; - } else { - resource_manager_ = new ResourceManager(); - } - - SetupExtensionsString(); - - texture_units_.reset( - new nb::scoped_refptr[impl_->GetMaxFragmentTextureUnits()]); -} - -Context* Context::GetTLSCurrentContext() { - return reinterpret_cast(pthread_getspecific(GetThreadLocalKey())); -} - -bool Context::SetTLSCurrentContext(Context* context, - egl::Surface* draw, - egl::Surface* read) { - SB_DCHECK(context); - SB_DCHECK(draw); - SB_DCHECK(read); - - if (context->current_thread() != kSbThreadInvalid && - context->current_thread() != SbThreadGetCurrent()) { - SB_DLOG(WARNING) << "Another thread holds current the context that is to " - "be made current on this thread."; - egl::SetError(EGL_BAD_ACCESS); - return false; - } - - // If this thread currently has another context current, release that one - // before we continue. - Context* existing_context = GetTLSCurrentContext(); - if (existing_context != context) { - if (existing_context) { - existing_context->ReleaseContext(); - } - pthread_setspecific(GetThreadLocalKey(), reinterpret_cast(context)); - } - - context->MakeCurrent(draw, read); - return true; -} - -void Context::ReleaseTLSCurrentContext() { - Context* existing_context = GetTLSCurrentContext(); - if (existing_context) { - existing_context->ReleaseContext(); - pthread_setspecific(GetThreadLocalKey(), NULL); - } -} - -GLenum Context::GetError() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - GLenum error = error_; - error_ = GL_NO_ERROR; - return error; -} - -const GLubyte* Context::GetString(GLenum name) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (name) { - case GL_EXTENSIONS: - return reinterpret_cast(extensions_string_.c_str()); - case GL_VERSION: - return reinterpret_cast("OpenGL ES 2.0 (glimp)"); - case GL_VENDOR: - return reinterpret_cast("Google Inc."); - case GL_RENDERER: - return reinterpret_cast("glimp"); - case GL_SHADING_LANGUAGE_VERSION: - return reinterpret_cast("OpenGL ES GLSL ES 1.00"); - - default: { - SetError(GL_INVALID_ENUM); - return NULL; - } - } -} - -void Context::GetIntegerv(GLenum pname, GLint* params) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (pname) { - case GL_MAX_TEXTURE_SIZE: - *params = impl_->GetMaxTextureSize(); - break; - case GL_ACTIVE_TEXTURE: - *params = static_cast(active_texture_); - break; - case GL_MAX_RENDERBUFFER_SIZE: - *params = impl_->GetMaxRenderbufferSize(); - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS: - // We don't currently support compressed textures. - *params = 0; - break; - case GL_MAX_VERTEX_ATTRIBS: - *params = impl_->GetMaxVertexAttribs(); - break; - case GL_MAX_TEXTURE_IMAGE_UNITS: - *params = impl_->GetMaxFragmentTextureUnits(); - break; - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: - *params = impl_->GetMaxFragmentUniformVectors(); - break; - case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: - *params = impl_->GetMaxVertexTextureImageUnits(); - break; - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: - *params = impl_->GetMaxCombinedTextureImageUnits(); - break; - case GL_UNPACK_ALIGNMENT: - *params = unpack_alignment_; - break; - default: { - SB_NOTIMPLEMENTED(); - SetError(GL_INVALID_ENUM); - } - } -} - -void Context::GetShaderiv(GLuint shader, GLenum pname, GLint* params) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - nb::scoped_refptr shader_object = - resource_manager_->GetShader(shader); - if (!shader_object) { - SetError(GL_INVALID_VALUE); - return; - } - - GLenum result = shader_object->GetShaderiv(pname, params); - if (result != GL_NO_ERROR) { - SetError(result); - } -} - -void Context::GetShaderInfoLog(GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* infolog) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (bufsize < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - nb::scoped_refptr shader_object = - resource_manager_->GetShader(shader); - if (!shader_object) { - SetError(GL_INVALID_VALUE); - return; - } - - shader_object->GetShaderInfoLog(bufsize, length, infolog); -} - -void Context::GetProgramiv(GLuint program, GLenum pname, GLint* params) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return; - } - - GLenum result = program_object->GetProgramiv(pname, params); - if (result != GL_NO_ERROR) { - SetError(result); - } -} - -void Context::GetProgramInfoLog(GLuint program, - GLsizei bufsize, - GLsizei* length, - GLchar* infolog) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (bufsize < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return; - } - - program_object->GetProgramInfoLog(bufsize, length, infolog); -} - -void Context::PixelStorei(GLenum pname, GLint param) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (pname) { - case GL_PACK_ALIGNMENT: - case GL_UNPACK_ALIGNMENT: - if (param != 1 && param != 4 && param != 8) { - SetError(GL_INVALID_VALUE); - return; - } - break; - - default: - if (param < 0) { - SetError(GL_INVALID_VALUE); - return; - } - break; - } - - switch (pname) { - case GL_PACK_ALIGNMENT: - pack_alignment_ = param; - break; - case GL_UNPACK_ALIGNMENT: - unpack_alignment_ = param; - break; - case GL_UNPACK_ROW_LENGTH: - unpack_row_length_ = param; - break; - case GL_PACK_ROW_LENGTH: - case GL_PACK_SKIP_ROWS: - case GL_PACK_SKIP_PIXELS: - case GL_UNPACK_IMAGE_HEIGHT: - case GL_UNPACK_SKIP_ROWS: - case GL_UNPACK_SKIP_PIXELS: - case GL_UNPACK_SKIP_IMAGES: - SB_NOTIMPLEMENTED(); - default: - SetError(GL_INVALID_ENUM); - break; - } -} - -void Context::Enable(GLenum cap) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (cap) { - case GL_BLEND: - draw_state_.blend_state.enabled = true; - draw_state_dirty_flags_.blend_state_dirty = true; - break; - case GL_SCISSOR_TEST: - draw_state_.scissor.enabled = true; - draw_state_dirty_flags_.scissor_dirty = true; - break; - case GL_CULL_FACE: - draw_state_.cull_face_state.enabled = true; - draw_state_.cull_face_state.mode = CullFaceState::kBack; - draw_state_dirty_flags_.cull_face_dirty = true; - break; - case GL_DEPTH_TEST: - case GL_DITHER: - case GL_STENCIL_TEST: - case GL_POLYGON_OFFSET_FILL: - case GL_SAMPLE_ALPHA_TO_COVERAGE: - case GL_SAMPLE_COVERAGE: - SB_NOTIMPLEMENTED(); - default: - SetError(GL_INVALID_ENUM); - } -} - -void Context::Disable(GLenum cap) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (cap) { - case GL_BLEND: - draw_state_.blend_state.enabled = false; - draw_state_dirty_flags_.blend_state_dirty = true; - break; - case GL_SCISSOR_TEST: - draw_state_.scissor.enabled = false; - draw_state_dirty_flags_.scissor_dirty = true; - break; - case GL_CULL_FACE: - draw_state_.cull_face_state.enabled = false; - draw_state_dirty_flags_.cull_face_dirty = true; - break; - case GL_DEPTH_TEST: - case GL_DITHER: - case GL_STENCIL_TEST: - case GL_POLYGON_OFFSET_FILL: - case GL_SAMPLE_ALPHA_TO_COVERAGE: - case GL_SAMPLE_COVERAGE: - // Since these are not implemented yet, it is not an error to do nothing - // when we ask for them to be disabled! - break; - default: - SetError(GL_INVALID_ENUM); - } -} - -void Context::ColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - draw_state_.color_mask = gles::ColorMask(red, green, blue, alpha); - draw_state_dirty_flags_.color_mask_dirty = true; -} - -void Context::DepthMask(GLboolean flag) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (flag == GL_TRUE) { - SB_NOTIMPLEMENTED() << "glimp currently does not support depth buffers."; - SetError(GL_INVALID_OPERATION); - } -} - -void Context::Clear(GLbitfield mask) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - impl_->Clear(mask & GL_COLOR_BUFFER_BIT, mask & GL_DEPTH_BUFFER_BIT, - mask & GL_STENCIL_BUFFER_BIT, draw_state_, - &draw_state_dirty_flags_); -} - -void Context::ClearColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - draw_state_.clear_color = gles::ClearColor(red, green, blue, alpha); - draw_state_dirty_flags_.clear_color_dirty = true; -} - -namespace { -BlendState::Factor BlendStateFactorFromGLenum(GLenum blend_factor) { - switch (blend_factor) { - case GL_ZERO: - return BlendState::kFactorZero; - case GL_ONE: - return BlendState::kFactorOne; - case GL_SRC_COLOR: - return BlendState::kFactorSrcColor; - case GL_ONE_MINUS_SRC_COLOR: - return BlendState::kFactorOneMinusSrcColor; - case GL_DST_COLOR: - return BlendState::kFactorDstColor; - case GL_ONE_MINUS_DST_COLOR: - return BlendState::kFactorOneMinusDstColor; - case GL_SRC_ALPHA: - return BlendState::kFactorSrcAlpha; - case GL_ONE_MINUS_SRC_ALPHA: - return BlendState::kFactorOneMinusSrcAlpha; - case GL_DST_ALPHA: - return BlendState::kFactorDstAlpha; - case GL_ONE_MINUS_DST_ALPHA: - return BlendState::kFactorOneMinusDstAlpha; - case GL_CONSTANT_COLOR: - return BlendState::kFactorConstantColor; - case GL_ONE_MINUS_CONSTANT_COLOR: - return BlendState::kFactorOneMinusConstantColor; - case GL_CONSTANT_ALPHA: - return BlendState::kFactorConstantAlpha; - case GL_ONE_MINUS_CONSTANT_ALPHA: - return BlendState::kFactorOneMinusConstantAlpha; - case GL_SRC_ALPHA_SATURATE: - return BlendState::kFactorSrcAlphaSaturate; - default: - return BlendState::kFactorInvalid; - } -} - -BlendState::Equation BlendStateEquationFromGLenum(GLenum equation) { - switch (equation) { - case GL_FUNC_ADD: - return BlendState::kEquationFuncAdd; - case GL_FUNC_SUBTRACT: - return BlendState::kEquationFuncSubtract; - case GL_FUNC_REVERSE_SUBTRACT: - return BlendState::kEquationFuncReverseSubtract; - default: - return BlendState::kEquationFuncInvalid; - } -} -} // namespace - -void Context::BlendFunc(GLenum sfactor, GLenum dfactor) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - BlendState::Factor src_factor = BlendStateFactorFromGLenum(sfactor); - BlendState::Factor dst_factor = BlendStateFactorFromGLenum(dfactor); - if (src_factor == BlendState::kFactorInvalid || - dst_factor == BlendState::kFactorInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - draw_state_.blend_state.src_factor = src_factor; - draw_state_.blend_state.dst_factor = dst_factor; - draw_state_dirty_flags_.blend_state_dirty = true; -} - -void Context::BlendEquation(GLenum mode) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - BlendState::Equation equation = BlendStateEquationFromGLenum(mode); - if (equation == BlendState::kEquationFuncInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - draw_state_.blend_state.equation = equation; - draw_state_dirty_flags_.blend_state_dirty = true; -} - -namespace { -CullFaceState::Mode CullFaceModeFromEnum(GLenum mode) { - switch (mode) { - case GL_FRONT: - return CullFaceState::kFront; - case GL_BACK: - return CullFaceState::kBack; - case GL_FRONT_AND_BACK: - return CullFaceState::kFrontAndBack; - default: - return CullFaceState::kModeInvalid; - } -} -} // namespace - -void Context::CullFace(GLenum mode) { - CullFaceState::Mode cull_face_mode = CullFaceModeFromEnum(mode); - if (cull_face_mode == CullFaceState::kModeInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - draw_state_.cull_face_state.mode = cull_face_mode; - draw_state_dirty_flags_.cull_face_dirty = true; -} - -GLuint Context::CreateProgram() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - std::unique_ptr program_impl = impl_->CreateProgram(); - SB_DCHECK(program_impl); - - nb::scoped_refptr program(new Program(std::move(program_impl))); - - return resource_manager_->RegisterProgram(program); -} - -void Context::DeleteProgram(GLuint program) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - // As indicated by the specification for glDeleteProgram(), - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteProgram.xml - // values of 0 will be silently ignored. - if (program == 0) { - return; - } - - nb::scoped_refptr program_object = - resource_manager_->DeregisterProgram(program); - - if (!program_object) { - SetError(GL_INVALID_VALUE); - } -} - -void Context::AttachShader(GLuint program, GLuint shader) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return; - } - - nb::scoped_refptr shader_object = - resource_manager_->GetShader(shader); - if (!shader_object) { - SetError(GL_INVALID_VALUE); - return; - } - - if (!program_object->AttachShader(shader_object)) { - // A shader of the given type was already attached. - SetError(GL_INVALID_OPERATION); - } -} - -void Context::LinkProgram(GLuint program) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return; - } - - program_object->Link(); - - if (program_object.get() == draw_state_.used_program.get()) { - MarkUsedProgramDirty(); - } -} - -void Context::BindAttribLocation(GLuint program, - GLuint index, - const GLchar* name) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (index >= GL_MAX_VERTEX_ATTRIBS) { - SetError(GL_INVALID_VALUE); - return; - } - - if (name[0] == 'g' && name[1] == 'l' && name[2] == '_') { - // |name| is not allowed to begin with the reserved prefix, "gl_". - SetError(GL_INVALID_OPERATION); - return; - } - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return; - } - - program_object->BindAttribLocation(index, name); - - if (program_object.get() == draw_state_.used_program.get()) { - draw_state_dirty_flags_.vertex_attributes_dirty = true; - } -} - -void Context::UseProgram(GLuint program) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (program == 0) { - draw_state_.used_program = NULL; - MarkUsedProgramDirty(); - return; - } - - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return; - } - - if (!program_object->linked()) { - // Only linked programs can be used. - SetError(GL_INVALID_OPERATION); - return; - } - - if (program_object.get() != draw_state_.used_program.get()) { - draw_state_.used_program = program_object; - MarkUsedProgramDirty(); - } -} - -GLuint Context::CreateShader(GLenum type) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - std::unique_ptr shader_impl; - if (type == GL_VERTEX_SHADER) { - shader_impl = impl_->CreateVertexShader(); - } else if (type == GL_FRAGMENT_SHADER) { - shader_impl = impl_->CreateFragmentShader(); - } else { - SetError(GL_INVALID_ENUM); - return 0; - } - SB_DCHECK(shader_impl); - - nb::scoped_refptr shader(new Shader(std::move(shader_impl), type)); - - return resource_manager_->RegisterShader(shader); -} - -void Context::DeleteShader(GLuint shader) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - // As indicated by the specification for glDeleteShader(), - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteShader.xml - // values of 0 will be silently ignored. - if (shader == 0) { - return; - } - - nb::scoped_refptr shader_object = - resource_manager_->DeregisterShader(shader); - - if (!shader_object) { - SetError(GL_INVALID_VALUE); - } -} - -void Context::ShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (count < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - nb::scoped_refptr shader_object = - resource_manager_->GetShader(shader); - - if (!shader_object) { - SetError(GL_INVALID_VALUE); - return; - } - - shader_object->ShaderSource(count, string, length); -} - -void Context::CompileShader(GLuint shader) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - nb::scoped_refptr shader_object = - resource_manager_->GetShader(shader); - - if (!shader_object) { - SetError(GL_INVALID_VALUE); - return; - } - - shader_object->CompileShader(); -} - -void Context::GenBuffers(GLsizei n, GLuint* buffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - std::unique_ptr buffer_impl = impl_->CreateBuffer(); - SB_DCHECK(buffer_impl); - - nb::scoped_refptr buffer(new Buffer(std::move(buffer_impl))); - - buffers[i] = resource_manager_->RegisterBuffer(buffer); - } -} - -void Context::GenBuffersForVideoFrame(GLsizei n, GLuint* buffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - std::unique_ptr buffer_impl = - impl_->CreateBufferForVideoFrame(); - SB_DCHECK(buffer_impl); - - buffers[i] = resource_manager_->RegisterBuffer( - nb::make_scoped_refptr(new Buffer(std::move(buffer_impl)))); - } -} - -void Context::FrontFace(GLenum mode) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if ((mode != GL_CW) && (mode != GL_CCW)) { - SetError(GL_INVALID_VALUE); - return; - } - - // The default face is GL_CCW, per documentation at: - // https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrontFace.xml - if (mode != GL_CCW) { - SB_NOTIMPLEMENTED(); - } -} - -void Context::DeleteBuffers(GLsizei n, const GLuint* buffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - if (buffers[i] == 0) { - // Silently ignore 0 buffers. - continue; - } - - nb::scoped_refptr buffer_object = - resource_manager_->DeregisterBuffer(buffers[i]); - - if (!buffer_object) { - // The specification does not indicate that any error should be set - // in the case that there was an error deleting a specific buffer. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteBuffers.xml - return; - } - - if (buffer_object->is_mapped()) { - // Buffer objects should be unmapped if they are deleted. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml - buffer_object->Unmap(); - } - - // If a bound buffer is deleted, set the bound buffer to NULL. The buffer - // may be bound to any target, therefore we must scan them all. - const GLenum buffer_targets[3] = {GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, - GL_PIXEL_UNPACK_BUFFER}; - for (int target_index = 0; target_index < SB_ARRAY_SIZE(buffer_targets); - ++target_index) { - GLenum target = buffer_targets[target_index]; - nb::scoped_refptr* bound_buffer = GetBoundBufferForTarget(target); - SB_DCHECK(bound_buffer); - if ((*bound_buffer).get() == buffer_object.get()) { - *bound_buffer = NULL; - } - } - } -} - -namespace { -bool IsValidBufferTarget(GLenum target) { - switch (target) { - case GL_ARRAY_BUFFER: - case GL_ELEMENT_ARRAY_BUFFER: - case GL_PIXEL_UNPACK_BUFFER: - return true; - break; - case GL_COPY_READ_BUFFER: - case GL_COPY_WRITE_BUFFER: - case GL_PIXEL_PACK_BUFFER: - case GL_TRANSFORM_FEEDBACK_BUFFER: - case GL_UNIFORM_BUFFER: - SB_NOTIMPLEMENTED() << "Buffer target " << target - << " is not supported " - "in glimp."; - default: - return false; - } -} -} // namespace - -void Context::BindBuffer(GLenum target, GLuint buffer) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (!IsValidBufferTarget(target)) { - SetError(GL_INVALID_ENUM); - return; - } - - nb::scoped_refptr* bound_buffer = GetBoundBufferForTarget(target); - SB_DCHECK(bound_buffer); - nb::scoped_refptr buffer_object; - if (buffer != 0) { - buffer_object = resource_manager_->GetBuffer(buffer); - if (!buffer_object) { - // The buffer to be bound is invalid. - SB_NOTIMPLEMENTED() - << "Creating buffers with glBindBuffer () not supported"; - return; - } - } - - *bound_buffer = buffer_object; -} - -void Context::BufferData(GLenum target, - GLsizeiptr size, - const GLvoid* data, - GLenum usage) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (size < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (usage != GL_STREAM_DRAW && usage != GL_STATIC_DRAW && - usage != GL_DYNAMIC_DRAW) { - SetError(GL_INVALID_ENUM); - return; - } - - if (!IsValidBufferTarget(target)) { - SetError(GL_INVALID_ENUM); - return; - } - - nb::scoped_refptr bound_buffer = *GetBoundBufferForTarget(target); - if (bound_buffer == 0) { - SetError(GL_INVALID_OPERATION); - return; - } - - if (bound_buffer->is_mapped()) { - // According to the specification, we must unmap the buffer if its data - // store is recreated with glBufferData. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml - bound_buffer->Unmap(); - } - - if (!bound_buffer->Allocate(usage, size)) { - SetError(GL_OUT_OF_MEMORY); - return; - } - - if (data) { - if (!bound_buffer->SetData(0, size, data)) { - SetError(GL_OUT_OF_MEMORY); - return; - } - } -} - -void Context::BufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const GLvoid* data) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (size < 0 || offset < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (!IsValidBufferTarget(target)) { - SetError(GL_INVALID_ENUM); - return; - } - - nb::scoped_refptr bound_buffer = *GetBoundBufferForTarget(target); - if (bound_buffer == 0) { - SetError(GL_INVALID_OPERATION); - return; - } - - if (offset + size > bound_buffer->size_in_bytes()) { - SetError(GL_INVALID_VALUE); - return; - } - - if (bound_buffer->is_mapped()) { - // According to the specification, we must unmap the buffer if its data - // store is recreated with glBufferData. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml - bound_buffer->Unmap(); - } - - // Nothing in the specification says there should be an error if data - // is NULL. - if (data) { - if (!bound_buffer->SetData(offset, size, data)) { - SetError(GL_OUT_OF_MEMORY); - return; - } - } -} - -namespace { -// This function is based off of the logic described in the "Errors" section -// of the specification: -// https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml -bool MapBufferRangeAccessFlagsAreValid(GLbitfield access) { - if (access & ~(GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | - GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | - GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT)) { - return false; - } - - if (!(access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) { - return false; - } - - if ((access & GL_MAP_READ_BIT) && - (access & (GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | - GL_MAP_UNSYNCHRONIZED_BIT))) { - return false; - } - - if ((access & GL_MAP_FLUSH_EXPLICIT_BIT) && !(access & GL_MAP_WRITE_BIT)) { - return false; - } - - return true; -} -} // namespace - -void* Context::MapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (!IsValidBufferTarget(target)) { - SetError(GL_INVALID_ENUM); - return NULL; - } - - nb::scoped_refptr bound_buffer = *GetBoundBufferForTarget(target); - if (bound_buffer == 0) { - SetError(GL_INVALID_OPERATION); - return NULL; - } - - if (offset < 0 || length < 0 || - offset + length > bound_buffer->size_in_bytes()) { - SetError(GL_INVALID_VALUE); - return NULL; - } - - if (bound_buffer->is_mapped()) { - SetError(GL_INVALID_OPERATION); - return NULL; - } - - if (!MapBufferRangeAccessFlagsAreValid(access)) { - SetError(GL_INVALID_OPERATION); - return NULL; - } - - SB_DCHECK(access & GL_MAP_INVALIDATE_BUFFER_BIT) - << "glimp requires the GL_MAP_INVALIDATE_BUFFER_BIT flag to be set."; - SB_DCHECK(access & GL_MAP_UNSYNCHRONIZED_BIT) - << "glimp requires the GL_MAP_UNSYNCHRONIZED_BIT flag to be set."; - SB_DCHECK(!(access & GL_MAP_FLUSH_EXPLICIT_BIT)) - << "glimp does not support the GL_MAP_FLUSH_EXPLICIT_BIT flag."; - SB_DCHECK(length == bound_buffer->size_in_bytes()) - << "glimp only supports mapping the entire buffer."; - - void* mapped = bound_buffer->Map(); - if (!mapped) { - SetError(GL_OUT_OF_MEMORY); - } - - return mapped; -} - -bool Context::UnmapBuffer(GLenum target) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (!IsValidBufferTarget(target)) { - SetError(GL_INVALID_ENUM); - return GL_FALSE; - } - - nb::scoped_refptr bound_buffer = *GetBoundBufferForTarget(target); - if (bound_buffer == 0) { - SetError(GL_INVALID_OPERATION); - return GL_FALSE; - } - - if (bound_buffer->is_mapped()) { - return bound_buffer->Unmap(); - } else { - // The specification is unclear on what to do in the case where the buffer - // was not mapped to begin with, so we return GL_FALSE in this case. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glMapBufferRange.xhtml - return GL_FALSE; - } -} - -void Context::LineWidth(GLfloat width) { - if (width <= 0) { - SetError(GL_INVALID_VALUE); - return; - } - const GLfloat kDefaultLineWidth = 1.0f; - if (fabs(width - kDefaultLineWidth) > 0.01f * kDefaultLineWidth) { - SB_NOTIMPLEMENTED(); - } -} - -void Context::MakeCurrent(egl::Surface* draw, egl::Surface* read) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(current_thread_ == kSbThreadInvalid || - current_thread_ == SbThreadGetCurrent()); - - current_thread_ = SbThreadGetCurrent(); - - if (!has_been_current_) { - // According to the documentation for eglMakeCurrent(), - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglMakeCurrent.xhtml - // we should set the scissor and viewport to the draw surface the first - // time this context is made current. - Scissor(0, 0, draw->impl()->GetWidth(), draw->impl()->GetHeight()); - Viewport(0, 0, draw->impl()->GetWidth(), draw->impl()->GetHeight()); - - // Setup the default framebuffers and bind them. - SB_DCHECK(!default_draw_framebuffer_); - SB_DCHECK(!default_read_framebuffer_); - SB_DCHECK(!draw_state_.framebuffer); - default_draw_framebuffer_ = new Framebuffer(draw); - default_read_framebuffer_ = new Framebuffer(read); - draw_state_.framebuffer = default_draw_framebuffer_; - read_framebuffer_ = default_read_framebuffer_; - - has_been_current_ = true; - } - - // Update our draw and read framebuffers, marking the framebuffer dirty - // flag if the default framebuffer is the one that is currently bound. - if (default_draw_framebuffer_->color_attachment_surface() != draw) { - default_draw_framebuffer_->UpdateColorSurface(draw); - if (draw_state_.framebuffer == default_draw_framebuffer_) { - draw_state_dirty_flags_.framebuffer_dirty = true; - } - } - if (default_read_framebuffer_->color_attachment_surface() != read) { - default_read_framebuffer_->UpdateColorSurface(read); - } -} - -void Context::ReleaseContext() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(current_thread_ != kSbThreadInvalid); - SB_DCHECK(current_thread_ == SbThreadGetCurrent()); - SB_DCHECK(has_been_current_); - - current_thread_ = kSbThreadInvalid; -} - -nb::scoped_refptr* Context::GetBoundBufferForTarget(GLenum target) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (target) { - case GL_ARRAY_BUFFER: - draw_state_dirty_flags_.array_buffer_dirty = true; - return &draw_state_.array_buffer; - case GL_ELEMENT_ARRAY_BUFFER: - draw_state_dirty_flags_.element_array_buffer_dirty = true; - return &draw_state_.element_array_buffer; - case GL_PIXEL_UNPACK_BUFFER: - return &bound_pixel_unpack_buffer_; - } - - SB_NOTREACHED(); - return NULL; -} - -nb::scoped_refptr* Context::GetBoundTextureForTarget(GLenum target, - GLenum texture) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - switch (target) { - case GL_TEXTURE_2D: - return &(texture_units_[texture - GL_TEXTURE0]); - case GL_TEXTURE_CUBE_MAP: - SB_NOTREACHED() << "Currently unimplemented in glimp."; - return NULL; - } - - SB_NOTREACHED(); - return NULL; -} - -void Context::SetupExtensionsString() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - // Extract the list of extensions from the platform-specific implementation - // and then turn them into a string. - ContextImpl::ExtensionList impl_extensions = impl_->GetExtensions(); - - extensions_string_ = ""; - for (int i = 0; i < impl_extensions.size(); ++i) { - if (i > 0) { - extensions_string_ += " "; - } - extensions_string_ += impl_extensions[i]; - } - - // Since extensions_string_ will eventually be returned as an array of - // unsigned chars, make sure that none of the characters in it are negative. - for (int i = 0; i < extensions_string_.size(); ++i) { - SB_DCHECK(extensions_string_[i] > 0); - } -} - -void Context::GenTextures(GLsizei n, GLuint* textures) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - std::unique_ptr texture_impl = impl_->CreateTexture(); - SB_DCHECK(texture_impl); - - nb::scoped_refptr texture(new Texture(std::move(texture_impl))); - - textures[i] = resource_manager_->RegisterTexture(texture); - } -} - -void Context::DeleteTextures(GLsizei n, const GLuint* textures) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - if (textures[i] == 0) { - // Silently ignore 0 textures. - continue; - } - nb::scoped_refptr texture_object = - resource_manager_->DeregisterTexture(textures[i]); - - if (!texture_object) { - // The specification does not indicate that any error should be set - // in the case that there was an error deleting a specific texture. - // https://www.khronos.org/opengles/sdk/1.1/docs/man/glDeleteTextures.xml - return; - } - - // If a bound texture is deleted, set the bound texture to NULL. The texture - // may be bound to multiple texture units, including texture units that are - // not active, therefore we must scan them all. - for (int texture_index = 0; - texture_index < impl_->GetMaxFragmentTextureUnits(); ++texture_index) { - GLenum texture_unit = texture_index + GL_TEXTURE0; - nb::scoped_refptr* bound_texture = - GetBoundTextureForTarget(GL_TEXTURE_2D, texture_unit); - if ((*bound_texture).get() == texture_object.get()) { - enabled_textures_dirty_ = true; - *bound_texture = NULL; - } - } - } -} - -void Context::ActiveTexture(GLenum texture) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (texture < GL_TEXTURE0 || - texture >= GL_TEXTURE0 + impl_->GetMaxFragmentTextureUnits()) { - SetError(GL_INVALID_ENUM); - return; - } - - active_texture_ = texture; -} - -void Context::BindTexture(GLenum target, GLuint texture) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP) { - SetError(GL_INVALID_ENUM); - return; - } - - nb::scoped_refptr* bound_texture = - GetBoundTextureForTarget(target, active_texture_); - SB_DCHECK(bound_texture); - nb::scoped_refptr texture_object; - if (texture != 0) { - texture_object = resource_manager_->GetTexture(texture); - if (!texture_object) { - // The texture to be bound is invalid. - SB_NOTIMPLEMENTED() - << "Creating textures with glBindTexture() not supported"; - return; - } - } - - if ((*bound_texture).get() == texture_object.get()) { - // The new texture being bound is the same as the already the bound - // texture. - return; - } - *bound_texture = texture_object; - enabled_textures_dirty_ = true; -} - -namespace { -Sampler::MinFilter MinFilterFromGLEnum(GLenum min_filter) { - switch (min_filter) { - case GL_NEAREST: - return Sampler::kMinFilterNearest; - case GL_LINEAR: - return Sampler::kMinFilterLinear; - case GL_NEAREST_MIPMAP_NEAREST: - return Sampler::kMinFilterNearestMipMapNearest; - case GL_NEAREST_MIPMAP_LINEAR: - return Sampler::kMinFilterNearestMipMapLinear; - case GL_LINEAR_MIPMAP_NEAREST: - return Sampler::kMinFilterLinearMipMapNearest; - case GL_LINEAR_MIPMAP_LINEAR: - return Sampler::kMinFilterLinearMipMapLinear; - default: - return Sampler::kMinFilterInvalid; - } -} - -Sampler::MagFilter MagFilterFromGLEnum(GLenum mag_filter) { - switch (mag_filter) { - case GL_NEAREST: - return Sampler::kMagFilterNearest; - case GL_LINEAR: - return Sampler::kMagFilterLinear; - default: - return Sampler::kMagFilterInvalid; - } -} - -Sampler::WrapMode WrapModeFromGLEnum(GLenum wrap_mode) { - switch (wrap_mode) { - case GL_CLAMP_TO_EDGE: - return Sampler::kWrapModeClampToEdge; - case GL_MIRRORED_REPEAT: - return Sampler::kWrapModeMirroredRepeat; - case GL_REPEAT: - return Sampler::kWrapModeRepeat; - default: - return Sampler::kWrapModeInvalid; - } -} - -GLenum GLEnumFromMinFilter(Sampler::MinFilter min_filter) { - switch (min_filter) { - case Sampler::kMinFilterNearest: - return GL_NEAREST; - case Sampler::kMinFilterLinear: - return GL_LINEAR; - case Sampler::kMinFilterNearestMipMapNearest: - return GL_NEAREST_MIPMAP_NEAREST; - case Sampler::kMinFilterNearestMipMapLinear: - return GL_NEAREST_MIPMAP_LINEAR; - case Sampler::kMinFilterLinearMipMapNearest: - return GL_LINEAR_MIPMAP_NEAREST; - case Sampler::kMinFilterLinearMipMapLinear: - return GL_LINEAR_MIPMAP_LINEAR; - default: { - SB_NOTREACHED(); - return GL_LINEAR; - } - } -} - -GLenum GLEnumFromMagFilter(Sampler::MagFilter mag_filter) { - switch (mag_filter) { - case Sampler::kMagFilterNearest: - return GL_NEAREST; - case Sampler::kMagFilterLinear: - return GL_LINEAR; - default: { - SB_NOTREACHED(); - return GL_LINEAR; - } - } -} - -GLenum GLEnumFromWrapMode(Sampler::WrapMode wrap_mode) { - switch (wrap_mode) { - case Sampler::kWrapModeClampToEdge: - return GL_CLAMP_TO_EDGE; - case Sampler::kWrapModeMirroredRepeat: - return GL_MIRRORED_REPEAT; - case Sampler::kWrapModeRepeat: - return GL_REPEAT; - default: { - SB_NOTREACHED(); - return GL_REPEAT; - } - } -} -} // namespace - -void Context::GetTexParameteriv(GLenum target, GLenum pname, GLint* params) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - Sampler* active_sampler = (*GetBoundTextureForTarget(target, active_texture_)) - ->sampler_parameters(); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: { - *params = GLEnumFromMagFilter(active_sampler->mag_filter); - } break; - case GL_TEXTURE_MIN_FILTER: { - *params = GLEnumFromMinFilter(active_sampler->min_filter); - } break; - case GL_TEXTURE_WRAP_S: { - *params = GLEnumFromWrapMode(active_sampler->wrap_s); - } break; - case GL_TEXTURE_WRAP_T: { - *params = GLEnumFromWrapMode(active_sampler->wrap_t); - } break; - - default: { - SetError(GL_INVALID_ENUM); - return; - } - } -} - -void Context::TexParameteri(GLenum target, GLenum pname, GLint param) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - Sampler* active_sampler = (*GetBoundTextureForTarget(target, active_texture_)) - ->sampler_parameters(); - - switch (pname) { - case GL_TEXTURE_MAG_FILTER: { - Sampler::MagFilter mag_filter = MagFilterFromGLEnum(param); - if (mag_filter == Sampler::kMagFilterInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - active_sampler->mag_filter = mag_filter; - } break; - case GL_TEXTURE_MIN_FILTER: { - Sampler::MinFilter min_filter = MinFilterFromGLEnum(param); - if (min_filter == Sampler::kMinFilterInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - active_sampler->min_filter = min_filter; - } break; - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: { - Sampler::WrapMode wrap_mode = WrapModeFromGLEnum(param); - if (wrap_mode == Sampler::kWrapModeInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - if (pname == GL_TEXTURE_WRAP_S) { - active_sampler->wrap_s = wrap_mode; - } else { - SB_DCHECK(pname == GL_TEXTURE_WRAP_T); - active_sampler->wrap_t = wrap_mode; - } - } break; - - default: { - SetError(GL_INVALID_ENUM); - return; - } - } - - enabled_textures_dirty_ = true; -} - -namespace { - -bool TextureFormatIsValid(GLenum format) { - switch (format) { - case GL_ALPHA: - case GL_RGB: - case GL_RGBA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RED_INTEGER: - return true; - default: - return false; - } -} - -bool TextureTypeIsValid(GLenum type) { - switch (type) { - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - return true; - default: - return false; - } -} - -// Converts a GL type and format to a glimp PixelFormat. Information about -// the different possible values for type and format can be found here: -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml -// Note that glimp may not support all possible formats described above. -PixelFormat PixelFormatFromGLTypeAndFormat(GLenum format, GLenum type) { - if (type == GL_UNSIGNED_BYTE) { - switch (format) { - case GL_RGBA: - return kPixelFormatRGBA8; - case GL_ALPHA: - return kPixelFormatA8; - case GL_LUMINANCE_ALPHA: - return kPixelFormatBA8; - } - } else if (type == GL_UNSIGNED_SHORT && format == GL_RED_INTEGER) { - return kPixelFormatA16; - } - return kPixelFormatInvalid; -} - -} // namespace - -void Context::TexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const GLvoid* pixels) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_TEXTURE_2D) { - SB_NOTREACHED() << "Only target=GL_TEXTURE_2D is supported in glimp."; - SetError(GL_INVALID_ENUM); - return; - } - - if (width < 0 || height < 0 || level < 0 || border != 0) { - SetError(GL_INVALID_VALUE); - return; - } - - int max_texture_size = impl_->GetMaxTextureSize(); - if (width > max_texture_size || height > max_texture_size) { - SetError(GL_INVALID_VALUE); - return; - } - - if (format != internalformat) { - SetError(GL_INVALID_OPERATION); - return; - } - - if (!TextureFormatIsValid(format)) { - SetError(GL_INVALID_ENUM); - return; - } - - if (!TextureTypeIsValid(type)) { - SetError(GL_INVALID_ENUM); - return; - } - - // Fold format and type together to determine a single glimp PixelFormat - // value for the incoming data. - PixelFormat pixel_format = PixelFormatFromGLTypeAndFormat(format, type); - SB_DCHECK(pixel_format != kPixelFormatInvalid) - << "Pixel format not supported by glimp."; - - nb::scoped_refptr texture_object = - *GetBoundTextureForTarget(target, active_texture_); - if (!texture_object) { - // According to the specification, no error is generated if no texture - // is bound. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml - return; - } - - // The incoming pixel data should be aligned as the client has specified - // that it will be. - SB_DCHECK(starboard::common::IsAligned( - pixels, static_cast(unpack_alignment_))); - - // Determine pitch taking into account glPixelStorei() settings. - int pitch_in_bytes = GetPitchForTextureData(width, pixel_format); - - texture_object->Initialize(level, pixel_format, width, height); - - if (bound_pixel_unpack_buffer_) { - if (bound_pixel_unpack_buffer_->is_mapped() || - height * pitch_in_bytes > bound_pixel_unpack_buffer_->size_in_bytes()) { - SetError(GL_INVALID_OPERATION); - return; - } - - texture_object->UpdateDataFromBuffer( - level, 0, 0, width, height, pitch_in_bytes, bound_pixel_unpack_buffer_, - starboard::common::AsInteger(pixels)); - } else if (pixels) { - if (!texture_object->UpdateData(level, 0, 0, width, height, pitch_in_bytes, - pixels)) { - SetError(GL_OUT_OF_MEMORY); - } - } -} - -void Context::TexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const GLvoid* pixels) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_TEXTURE_2D) { - SB_NOTREACHED() << "Only target=GL_TEXTURE_2D is supported in glimp."; - SetError(GL_INVALID_ENUM); - return; - } - - if (width < 0 || height < 0 || level < 0 || xoffset < 0 || yoffset < 0) { - SetError(GL_INVALID_VALUE); - } - - if (!TextureFormatIsValid(format)) { - SetError(GL_INVALID_ENUM); - return; - } - - if (!TextureTypeIsValid(type)) { - SetError(GL_INVALID_ENUM); - return; - } - - PixelFormat pixel_format = PixelFormatFromGLTypeAndFormat(format, type); - SB_DCHECK(pixel_format != kPixelFormatInvalid) - << "Pixel format not supported by glimp."; - - nb::scoped_refptr texture_object = - *GetBoundTextureForTarget(target, active_texture_); - if (!texture_object) { - // According to the specification, no error is generated if no texture - // is bound. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexSubImage2D.xml - return; - } - - if (!texture_object->texture_allocated() || - pixel_format != texture_object->pixel_format()) { - SetError(GL_INVALID_OPERATION); - return; - } - - if (xoffset + width > texture_object->width() || - yoffset + height > texture_object->height()) { - SetError(GL_INVALID_VALUE); - return; - } - - // The incoming pixel data should be aligned as the client has specified - // that it will be. - SB_DCHECK(starboard::common::IsAligned( - pixels, static_cast(unpack_alignment_))); - - // Determine pitch taking into account glPixelStorei() settings. - int pitch_in_bytes = GetPitchForTextureData(width, pixel_format); - - if (bound_pixel_unpack_buffer_) { - if (bound_pixel_unpack_buffer_->is_mapped() || - height * pitch_in_bytes > bound_pixel_unpack_buffer_->size_in_bytes()) { - SetError(GL_INVALID_OPERATION); - return; - } - - texture_object->UpdateDataFromBuffer( - level, xoffset, yoffset, width, height, pitch_in_bytes, - bound_pixel_unpack_buffer_, starboard::common::AsInteger(pixels)); - } else { - if (!texture_object->UpdateData(level, xoffset, yoffset, width, height, - pitch_in_bytes, pixels)) { - SetError(GL_OUT_OF_MEMORY); - } - } -} - -void Context::CopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_TEXTURE_2D) { - SB_NOTREACHED() << "Only target=GL_TEXTURE_2D is supported in glimp."; - SetError(GL_INVALID_ENUM); - return; - } - - if (width < 0 || height < 0 || level < 0 || xoffset < 0 || yoffset < 0) { - SetError(GL_INVALID_VALUE); - } - - nb::scoped_refptr texture_object = - *GetBoundTextureForTarget(target, active_texture_); - if (!texture_object) { - // According to the specification, no error is generated if no texture - // is bound. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexSubImage2D.xml - return; - } - - if (!texture_object->texture_allocated()) { - SetError(GL_INVALID_OPERATION); - return; - } - - if (xoffset + width > texture_object->width() || - yoffset + height > texture_object->height()) { - SetError(GL_INVALID_VALUE); - return; - } - - if (read_framebuffer_->CheckFramebufferStatus() != GL_FRAMEBUFFER_COMPLETE) { - SetError(GL_INVALID_FRAMEBUFFER_OPERATION); - return; - } - - // The pixels in the rectangle are processed exactly as if glReadPixels had - // been called with format set to GL_RGBA, but the process stops just after - // conversion of RGBA values. Subsequent processing is identical to that - // described for glTexSubImage2D. - uint8_t pixels[read_framebuffer_->GetWidth() * - read_framebuffer_->GetHeight() * - BytesPerPixel(kPixelFormatRGBA8)]; - ReadPixels(0, 0, read_framebuffer_->GetWidth(), - read_framebuffer_->GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, - &pixels); - - // If any of the pixels within the specified rectangle are outside the - // framebuffer associated with the current rendering context, then the values - // obtained for those pixels are undefined. Make sure that we only access - // pixels within a valid range. - x = std::max(0, x); - y = std::max(0, y); - width = std::min(read_framebuffer_->GetWidth() - x, width); - height = std::min(read_framebuffer_->GetHeight() - y, height); - int pitch_in_bytes = - read_framebuffer_->GetWidth() * BytesPerPixel(kPixelFormatRGBA8); - if (!texture_object->UpdateData( - level, xoffset, yoffset, width, height, pitch_in_bytes, - &pixels[y * pitch_in_bytes + x * BytesPerPixel(kPixelFormatRGBA8)])) { - SetError(GL_OUT_OF_MEMORY); - } -} - -void Context::GenFramebuffers(GLsizei n, GLuint* framebuffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - nb::scoped_refptr framebuffer(new Framebuffer()); - - framebuffers[i] = resource_manager_->RegisterFramebuffer(framebuffer); - } -} - -void Context::DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - if (framebuffers[i] == 0) { - // Silently ignore 0 framebuffers. - continue; - } - - nb::scoped_refptr framebuffer_object = - resource_manager_->DeregisterFramebuffer(framebuffers[i]); - - if (!framebuffer_object) { - // The specification does not indicate that any error should be set - // in the case that there was an error deleting a specific framebuffer. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteFramebuffers.xml - return; - } - - // If a bound framebuffer is deleted, set the bound framebuffer back to - // the default framebuffer. - if (framebuffer_object == draw_state_.framebuffer) { - SetBoundDrawFramebufferToDefault(); - } - if (framebuffer_object == read_framebuffer_) { - SetBoundReadFramebufferToDefault(); - } - } -} - -void Context::BindFramebuffer(GLenum target, GLuint framebuffer) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_FRAMEBUFFER) { - SetError(GL_INVALID_ENUM); - return; - } - - if (framebuffer == 0) { - SetBoundDrawFramebufferToDefault(); - SetBoundReadFramebufferToDefault(); - return; - } - - nb::scoped_refptr framebuffer_object = - resource_manager_->GetFramebuffer(framebuffer); - - if (!framebuffer_object) { - // According to the specification, no error is generated if the buffer is - // invalid. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindFramebuffer.xml - SB_DLOG(WARNING) << "Could not glBindFramebuffer() to invalid framebuffer."; - return; - } - - draw_state_.framebuffer = framebuffer_object; - draw_state_dirty_flags_.framebuffer_dirty = true; - - read_framebuffer_ = framebuffer_object; -} - -void Context::FramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_FRAMEBUFFER) { - SetError(GL_INVALID_ENUM); - return; - } - - if (IsDefaultDrawFramebufferBound() || IsDefaultReadFramebufferBound()) { - SetError(GL_INVALID_OPERATION); - return; - } - - if (textarget != GL_TEXTURE_2D) { - SB_NOTREACHED() << "Only textarget=GL_TEXTURE_2D is supported in glimp."; - SetError(GL_INVALID_ENUM); - return; - } - - if (attachment != GL_COLOR_ATTACHMENT0) { - SB_NOTREACHED() - << "Only attachment=GL_COLOR_ATTACHMENT0 is supported in glimp."; - SetError(GL_INVALID_ENUM); - return; - } - - nb::scoped_refptr texture_object; - if (texture != 0) { - texture_object = resource_manager_->GetTexture(texture); - if (!texture_object) { - SetError(GL_INVALID_OPERATION); - return; - } - } - - draw_state_.framebuffer->AttachTexture2D(texture_object, level); -} - -GLenum Context::CheckFramebufferStatus(GLenum target) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_FRAMEBUFFER) { - SetError(GL_INVALID_ENUM); - return 0; - } - - return draw_state_.framebuffer->CheckFramebufferStatus(); -} - -void Context::FramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_FRAMEBUFFER || renderbuffertarget != GL_RENDERBUFFER) { - SetError(GL_INVALID_ENUM); - return; - } - - SB_DCHECK(attachment != GL_COLOR_ATTACHMENT0) - << "glimp does not support attaching color renderbuffers to " - "framebuffers."; - - if (IsDefaultDrawFramebufferBound()) { - SetError(GL_INVALID_OPERATION); - return; - } - - nb::scoped_refptr renderbuffer_object = nullptr; - - // Resolve the actual render buffer object to bind if we are not binding - // render buffer 0, in which case we leave the value to set as NULL. - if (renderbuffer != 0) { - renderbuffer_object = resource_manager_->GetRenderbuffer(renderbuffer); - - if (!renderbuffer_object) { - SetError(GL_INVALID_OPERATION); - return; - } - } - - switch (attachment) { - case GL_DEPTH_ATTACHMENT: - draw_state_.framebuffer->SetDepthAttachment(renderbuffer_object); - break; - case GL_STENCIL_ATTACHMENT: - draw_state_.framebuffer->SetStencilAttachment(renderbuffer_object); - break; - default: - SetError(GL_INVALID_ENUM); - } -} - -void Context::GenRenderbuffers(GLsizei n, GLuint* renderbuffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - nb::scoped_refptr renderbuffer(new Renderbuffer()); - - renderbuffers[i] = resource_manager_->RegisterRenderbuffer(renderbuffer); - } -} - -void Context::DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (n < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - for (GLsizei i = 0; i < n; ++i) { - if (renderbuffers[i] == 0) { - // Silently ignore 0 renderbuffers. - continue; - } - - nb::scoped_refptr renderbuffer_object = - resource_manager_->DeregisterRenderbuffer(renderbuffers[i]); - - if (!renderbuffer_object) { - // The specification does not indicate that any error should be set - // in the case that there was an error deleting a specific renderbuffer. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDeleteRenderbuffers.xml - return; - } - - // If we're deleting the currently bound renderbuffer, set the currently - // bound render buffer to NULL. - if (renderbuffer_object == bound_renderbuffer_) { - bound_renderbuffer_ = NULL; - } - } -} - -void Context::BindRenderbuffer(GLenum target, GLuint renderbuffer) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_RENDERBUFFER) { - SetError(GL_INVALID_ENUM); - return; - } - - if (renderbuffer == 0) { - bound_renderbuffer_ = NULL; - return; - } - - nb::scoped_refptr renderbuffer_object = - resource_manager_->GetRenderbuffer(renderbuffer); - - if (!renderbuffer_object) { - // According to the specification, no error is generated if the buffer is - // invalid. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindRenderbuffer.xml - SB_DLOG(WARNING) - << "Could not glBindRenderbuffer() to invalid renderbuffer."; - return; - } - - bound_renderbuffer_ = renderbuffer_object; -} - -namespace { -// Valid formats as listed here: -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glRenderbufferStorage.xml -bool RenderbufferStorageFormatIsValid(GLenum internalformat) { - switch (internalformat) { - case GL_RGBA4: - case GL_RGB565: - case GL_RGB5_A1: - case GL_DEPTH_COMPONENT16: - case GL_STENCIL_INDEX8: - return true; - default: - return false; - } -} -} // namespace - -void Context::RenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (target != GL_RENDERBUFFER) { - SetError(GL_INVALID_ENUM); - return; - } - - if (!RenderbufferStorageFormatIsValid(internalformat)) { - SetError(GL_INVALID_ENUM); - return; - } - - if (width < 0 || height < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (bound_renderbuffer_ == 0) { - SetError(GL_INVALID_OPERATION); - return; - } - - bound_renderbuffer_->Initialize(internalformat, width, height); -} - -void Context::StencilMask(GLuint mask) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (mask != 0xFFFFFFFF) { - // If we are not setting stencil mask to its initial value then indicate - // that our implementation is lacking. - SB_NOTIMPLEMENTED(); - } -} - -void Context::ClearStencil(GLint s) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (s != 0) { - // If we are not setting stencil clear to its initial value then indicate - // that our implementation is lacking. - SB_NOTIMPLEMENTED(); - } -} - -void Context::Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - draw_state_.viewport.rect = nb::Rect(x, y, width, height); - draw_state_dirty_flags_.viewport_dirty = true; -} - -void Context::Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (x < 0) { - SB_DLOG(WARNING) << "glScissor() x coordinate is set to negative."; - } - if (y < 0) { - SB_DLOG(WARNING) << "glScissor() y coordinate is set to negative."; - } - draw_state_.scissor.rect = nb::Rect(x, y, width, height); - draw_state_dirty_flags_.scissor_dirty = true; -} - -namespace { -// Converts from the GLenum passed into glVertexAttribPointer() to the enum -// defined in VertexAttribute. -static VertexAttributeType VertexAttributeTypeFromGLEnum(GLenum type) { - switch (type) { - case GL_BYTE: - return kVertexAttributeTypeByte; - case GL_UNSIGNED_BYTE: - return kVertexAttributeTypeUnsignedByte; - case GL_SHORT: - return kVertexAttributeTypeShort; - case GL_UNSIGNED_SHORT: - return kVertexAttributeTypeUnsignedShort; - case GL_FIXED: - return kVertexAttributeTypeFixed; - case GL_FLOAT: - return kVertexAttributeTypeFloat; - case GL_HALF_FLOAT: - return kVertexAttributeTypeHalfFloat; - default: - return kVertexAttributeTypeInvalid; - } -} -} // namespace - -void Context::VertexAttribPointer(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const GLvoid* ptr) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (indx >= GL_MAX_VERTEX_ATTRIBS) { - SetError(GL_INVALID_VALUE); - return; - } - if (size < 1 || size > 4) { - SetError(GL_INVALID_VALUE); - return; - } - if (stride < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - VertexAttributeType vertex_attribute_type = - VertexAttributeTypeFromGLEnum(type); - if (vertex_attribute_type == kVertexAttributeTypeInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - vertex_attrib_map_[indx] = - VertexAttributeArray(size, vertex_attribute_type, normalized, stride, - static_cast(reinterpret_cast(ptr))); - if (enabled_vertex_attribs_.find(indx) != enabled_vertex_attribs_.end()) { - enabled_vertex_attribs_dirty_ = true; - } -} - -void Context::EnableVertexAttribArray(GLuint index) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (index >= GL_MAX_VERTEX_ATTRIBS) { - SetError(GL_INVALID_VALUE); - return; - } - - enabled_vertex_attribs_.insert(index); - enabled_vertex_attribs_dirty_ = true; -} - -void Context::DisableVertexAttribArray(GLuint index) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (index >= GL_MAX_VERTEX_ATTRIBS) { - SetError(GL_INVALID_VALUE); - return; - } - - enabled_vertex_attribs_.erase(index); - enabled_vertex_attribs_dirty_ = true; -} - -void Context::VertexAttribfv(GLuint indx, - int elem_size, - const GLfloat* values) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(elem_size > 0); - SB_DCHECK(elem_size <= 4); - - VertexAttributeConstant* value = &const_vertex_attrib_map_[indx]; - memset(value, 0, sizeof(*value)); - for (int i = 0; i < elem_size; ++i) { - value->data[i] = values[i]; - } - value->size = elem_size; - value->type = kVertexAttributeTypeFloat; - - enabled_vertex_attribs_dirty_ = true; -} - -GLint Context::GetUniformLocation(GLuint program, const GLchar* name) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (name[0] == 'g' && name[1] == 'l' && name[2] == '_') { - // |name| is not allowed to begin with the reserved prefix, "gl_". - return -1; - } - - nb::scoped_refptr program_object = - resource_manager_->GetProgram(program); - if (!program_object) { - SetError(GL_INVALID_VALUE); - return -1; - } - - if (!program_object->linked()) { - SetError(GL_INVALID_OPERATION); - return -1; - } - - return program_object->GetUniformLocation(name); -} - -void Context::Uniformiv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLint* v) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(elem_size >= 1 && elem_size <= 4); - - if (count < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (!draw_state_.used_program) { - SetError(GL_INVALID_VALUE); - return; - } - - GLenum result = - draw_state_.used_program->Uniformiv(location, count, elem_size, v); - if (result == GL_NO_ERROR) { - draw_state_dirty_flags_.uniforms_dirty.Mark(location); - } else { - SetError(result); - } -} - -void Context::Uniformfv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLfloat* v) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(elem_size >= 1 && elem_size <= 4); - - if (count < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (!draw_state_.used_program) { - SetError(GL_INVALID_VALUE); - return; - } - - GLenum result = - draw_state_.used_program->Uniformfv(location, count, elem_size, v); - if (result == GL_NO_ERROR) { - draw_state_dirty_flags_.uniforms_dirty.Mark(location); - } else { - SetError(result); - } -} - -void Context::UniformMatrixfv(GLint location, - GLsizei count, - GLboolean transpose, - GLsizei dim_size, - const GLfloat* value) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(dim_size >= 2 && dim_size <= 4); - - if (transpose != GL_FALSE) { - SetError(GL_INVALID_VALUE); - return; - } - - if (!draw_state_.used_program) { - SetError(GL_INVALID_VALUE); - return; - } - - GLenum result = draw_state_.used_program->UniformMatrixfv(location, count, - dim_size, value); - if (result == GL_NO_ERROR) { - draw_state_dirty_flags_.uniforms_dirty.Mark(location); - } else { - SetError(result); - } -} - -namespace { -DrawMode DrawModeFromGLEnum(GLenum mode) { - switch (mode) { - case GL_POINTS: - return kDrawModePoints; - case GL_LINE_STRIP: - return kDrawModeLineStrip; - case GL_LINE_LOOP: - return kDrawModeLineLoop; - case GL_LINES: - return kDrawModeLines; - case GL_TRIANGLE_STRIP: - return kDrawModeTriangleStrip; - case GL_TRIANGLE_FAN: - return kDrawModeTriangleFan; - case GL_TRIANGLES: - return kDrawModeTriangles; - default: - return kDrawModeInvalid; - } -} -} // namespace - -void Context::DrawArrays(GLenum mode, GLint first, GLsizei count) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (count < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (draw_state_.framebuffer->CheckFramebufferStatus() != - GL_FRAMEBUFFER_COMPLETE) { - SetError(GL_INVALID_FRAMEBUFFER_OPERATION); - return; - } - - DrawMode draw_mode = DrawModeFromGLEnum(mode); - if (draw_mode == kDrawModeInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - SB_DCHECK(draw_state_.array_buffer) - << "glimp only supports vertices from vertex buffers."; - - CompressDrawStateForDrawCall(); - - impl_->DrawArrays(draw_mode, first, count, draw_state_, - &draw_state_dirty_flags_); -} - -namespace { -IndexDataType IndexDataTypeFromGLenum(GLenum type) { - switch (type) { - case GL_UNSIGNED_BYTE: - return kIndexDataTypeUnsignedByte; - case GL_UNSIGNED_SHORT: - return kIndexDataTypeUnsignedShort; - default: - return kIndexDataTypeInvalid; - } -} -} // namespace - -void Context::DrawElements(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid* indices) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (count < 0) { - SetError(GL_INVALID_VALUE); - return; - } - - if (draw_state_.framebuffer->CheckFramebufferStatus() != - GL_FRAMEBUFFER_COMPLETE) { - SetError(GL_INVALID_FRAMEBUFFER_OPERATION); - return; - } - - DrawMode draw_mode = DrawModeFromGLEnum(mode); - if (draw_mode == kDrawModeInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - IndexDataType index_data_type = IndexDataTypeFromGLenum(type); - if (type == kIndexDataTypeInvalid) { - SetError(GL_INVALID_ENUM); - return; - } - - SB_DCHECK(draw_state_.array_buffer) - << "glimp only supports vertices from vertex buffers."; - SB_DCHECK(draw_state_.element_array_buffer) - << "glimp only supports indices from element vertex buffers."; - - CompressDrawStateForDrawCall(); - - impl_->DrawElements(draw_mode, count, index_data_type, - reinterpret_cast(indices), draw_state_, - &draw_state_dirty_flags_); -} - -namespace { -bool ValidReadPixelsFormat(GLenum format) { - switch (format) { - case GL_RGBA: - case GL_RGBA_INTEGER: - case GL_RED_INTEGER: - return true; - break; - default: - return false; - break; - } -} - -bool ValidReadPixelsType(GLenum type) { - switch (type) { - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_INT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_FLOAT: - return true; - break; - default: - return false; - break; - } -} -} // namespace - -void Context::ReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLvoid* pixels) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (!ValidReadPixelsFormat(format) || !ValidReadPixelsType(type)) { - SetError(GL_INVALID_ENUM); - return; - } - - SB_DCHECK(format == GL_RGBA) << "glimp only supports format=GL_RGBA."; - SB_DCHECK(type == GL_UNSIGNED_BYTE) - << "glimp only supports type=GL_UNSIGNED_BYTE."; - - SB_DCHECK(read_framebuffer_->color_attachment_texture()) - << "glimp only supports glReadPixels() calls on non-default " - "framebuffers."; - - if (x < 0 || y < 0 || width < 0 || height < 0 || - x + width > read_framebuffer_->GetWidth() || - y + height > read_framebuffer_->GetHeight()) { - SetError(GL_INVALID_VALUE); - return; - } - - // Ensure that all GPU activity (in particular, texture writes) complete - // before we attempt to read pixel data from the texture. - Finish(); - - read_framebuffer_->color_attachment_texture()->ReadPixelsAsRGBA8( - x, y, width, height, width * BytesPerPixel(kPixelFormatRGBA8), pixels); -} - -void Context::Flush() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - impl_->Flush(); -} - -void Context::Finish() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - impl_->Finish(); -} - -void Context::SwapBuffers() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - egl::Surface* surface = default_draw_framebuffer_->color_attachment_surface(); - // If surface is a pixel buffer or a pixmap, eglSwapBuffers has no effect, and - // no error is generated. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglSwapBuffers.xhtml - if (surface->impl()->IsWindowSurface()) { - Flush(); - impl_->SwapBuffers(surface); - if (!has_swapped_buffers()) { - SbAtomicBarrier_Increment(&has_swapped_buffers_, 1); - } - } -} - -bool Context::BindTextureToEGLSurface(egl::Surface* surface) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - SB_DCHECK(surface->GetTextureTarget() == EGL_TEXTURE_2D); - - const nb::scoped_refptr& current_texture = - *GetBoundTextureForTarget(GL_TEXTURE_2D, active_texture_); - - if (!current_texture) { - SB_DLOG(WARNING) << "No texture is currently bound during call to " - "eglBindTexImage()."; - return false; - } - - SB_DCHECK(bound_egl_surfaces_.find(surface) == bound_egl_surfaces_.end()); - - bool success = current_texture->BindToEGLSurface(surface); - if (success) { - bound_egl_surfaces_[surface] = current_texture; - } - - return success; -} - -bool Context::ReleaseTextureFromEGLSurface(egl::Surface* surface) { - GLIMP_TRACE_EVENT0(__FUNCTION__); - std::map >::iterator found = - bound_egl_surfaces_.find(surface); - if (found == bound_egl_surfaces_.end()) { - SB_LOG(WARNING) << "Releasing EGLSurface was never bound to a texture in " - "this context."; - return false; - } - - bool success = found->second->ReleaseFromEGLSurface(surface); - if (success) { - bound_egl_surfaces_.erase(found); - } - return success; -} - -void Context::UpdateVertexAttribsInDrawState() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - // Setup the dense list of enabled vertex attributes. - draw_state_.vertex_attributes.clear(); - for (std::set::const_iterator iter = - enabled_vertex_attribs_.begin(); - iter != enabled_vertex_attribs_.end(); ++iter) { - draw_state_.vertex_attributes.push_back( - std::make_pair(*iter, &vertex_attrib_map_[*iter])); - } - - draw_state_.constant_vertex_attributes.clear(); - for (std::map::iterator iter = - const_vertex_attrib_map_.begin(); - iter != const_vertex_attrib_map_.end(); ++iter) { - // Add constant vertex attributes only if they do not have a vertex - // attribute array enabled for them. - if (enabled_vertex_attribs_.find(iter->first) == - enabled_vertex_attribs_.end()) { - draw_state_.constant_vertex_attributes.push_back( - std::make_pair(iter->first, &iter->second)); - } - } - - draw_state_dirty_flags_.vertex_attributes_dirty = true; - enabled_vertex_attribs_dirty_ = false; -} - -void Context::UpdateSamplersInDrawState() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - // Setup the list of enabled samplers. - draw_state_.textures.clear(); - int max_active_textures = impl_->GetMaxFragmentTextureUnits(); - for (int i = 0; i < max_active_textures; ++i) { - if (texture_units_[i]) { - draw_state_.textures.push_back(std::make_pair( - static_cast(i), texture_units_[i].get())); - } - } - - draw_state_dirty_flags_.textures_dirty = true; - enabled_textures_dirty_ = false; -} - -void Context::CompressDrawStateForDrawCall() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (enabled_vertex_attribs_dirty_) { - UpdateVertexAttribsInDrawState(); - SB_DCHECK(enabled_vertex_attribs_dirty_ == false); - } - - if (enabled_textures_dirty_) { - UpdateSamplersInDrawState(); - SB_DCHECK(enabled_textures_dirty_ == false); - } -} - -void Context::MarkUsedProgramDirty() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - draw_state_dirty_flags_.MarkUsedProgram(); -} - -void Context::SetBoundDrawFramebufferToDefault() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (draw_state_.framebuffer != default_draw_framebuffer_) { - draw_state_.framebuffer = default_draw_framebuffer_; - draw_state_dirty_flags_.framebuffer_dirty = true; - } -} - -void Context::SetBoundReadFramebufferToDefault() { - GLIMP_TRACE_EVENT0(__FUNCTION__); - if (read_framebuffer_ != default_read_framebuffer_) { - read_framebuffer_ = default_read_framebuffer_; - } -} - -bool Context::IsDefaultDrawFramebufferBound() const { - GLIMP_TRACE_EVENT0(__FUNCTION__); - return draw_state_.framebuffer == default_draw_framebuffer_; -} - -bool Context::IsDefaultReadFramebufferBound() const { - GLIMP_TRACE_EVENT0(__FUNCTION__); - return read_framebuffer_ == default_read_framebuffer_; -} - -int Context::GetPitchForTextureData(int width, PixelFormat pixel_format) const { - GLIMP_TRACE_EVENT0(__FUNCTION__); - // The equations for determining the pitch are described here: - // https://www.khronos.org/opengles/sdk/docs/man3/html/glPixelStorei.xhtml - int n = BytesPerPixel(pixel_format); - int s = 1; - int len = unpack_row_length_ > 0 ? unpack_row_length_ : width; - int a = unpack_alignment_; - - if (s >= a) { - return n * len; - } else { - return starboard::common::AlignUp(s * n * len, a) / s; - } -} - -SbAtomic32 Context::has_swapped_buffers_ = 0; - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/context.h b/glimp/gles/context.h deleted file mode 100644 index 66f5fb589240..000000000000 --- a/glimp/gles/context.h +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright 2015 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_CONTEXT_H_ -#define GLIMP_GLES_CONTEXT_H_ - -#include - -#include -#include -#include -#include -#include - -#include -#include "glimp/egl/surface.h" -#include "glimp/gles/context_impl.h" -#include "glimp/gles/draw_state.h" -#include "glimp/gles/framebuffer.h" -#include "glimp/gles/resource_manager.h" -#include "glimp/gles/sampler.h" -#include "glimp/gles/vertex_attribute.h" -#include "glimp/ref_counted.h" -#include "starboard/atomic.h" -#include "starboard/thread.h" - -namespace glimp { -namespace gles { - -class Context { - public: - Context(std::unique_ptr context_impl, Context* share_context); - - ~Context() { SbAtomicRelease_Store(&has_swapped_buffers_, 0); } - - // Returns current thread's current context, or NULL if nothing is current. - static Context* GetTLSCurrentContext(); - - // Sets the current thread's current context. None of the parameters can - // be NULL (use ReleaseTLSCurrentContext() if you wish to release the current - // context). - static bool SetTLSCurrentContext(Context* context, - egl::Surface* draw, - egl::Surface* read); - - // Releases the current thread's current context. - static void ReleaseTLSCurrentContext(); - - // Returns the unique id of the context instance. - int context_id() const { return context_id_; } - - egl::Surface* draw_surface() { - return default_draw_framebuffer_->color_attachment_surface(); - } - - // Returns the thread that currently holds this Context, or kSbThreadInvalid - // if no thread currently holds the context. - SbThread current_thread() const { return current_thread_; } - - // Return the last error generated and reset the error flag to GL_NO_ERROR. - GLenum GetError(); - - const GLubyte* GetString(GLenum name); - void GetIntegerv(GLenum pname, GLint* params); - void GetShaderiv(GLuint shader, GLenum pname, GLint* params); - void GetShaderInfoLog(GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* infolog); - void GetProgramiv(GLuint program, GLenum pname, GLint* params); - void GetProgramInfoLog(GLuint program, - GLsizei bufsize, - GLsizei* length, - GLchar* infolog); - - void PixelStorei(GLenum pname, GLint param); - - void Enable(GLenum cap); - void Disable(GLenum cap); - - void ColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); - void DepthMask(GLboolean flag); - - void Clear(GLbitfield mask); - void ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); - - void BlendFunc(GLenum sfactor, GLenum dfactor); - void BlendEquation(GLenum mode); - - void CullFace(GLenum mode); - void FrontFace(GLenum mode); - - GLuint CreateProgram(); - void DeleteProgram(GLuint program); - void AttachShader(GLuint program, GLuint shader); - void LinkProgram(GLuint program); - void BindAttribLocation(GLuint program, GLuint index, const GLchar* name); - void UseProgram(GLuint program); - - GLuint CreateShader(GLenum type); - void DeleteShader(GLuint shader); - void ShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); - void CompileShader(GLuint shader); - - void GenBuffers(GLsizei n, GLuint* buffers); - void GenBuffersForVideoFrame(GLsizei n, GLuint* buffers); - void DeleteBuffers(GLsizei n, const GLuint* buffers); - void BindBuffer(GLenum target, GLuint buffer); - void BufferData(GLenum target, - GLsizeiptr size, - const GLvoid* data, - GLenum usage); - void BufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const GLvoid* data); - void* MapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); - bool UnmapBuffer(GLenum target); - - void LineWidth(GLfloat width); - - void GenTextures(GLsizei n, GLuint* textures); - void DeleteTextures(GLsizei n, const GLuint* textures); - void ActiveTexture(GLenum texture); - void BindTexture(GLenum target, GLuint texture); - void GetTexParameteriv(GLenum target, GLenum pname, GLint* params); - void TexParameteri(GLenum target, GLenum pname, GLint param); - void TexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const GLvoid* pixels); - void TexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const GLvoid* pixels); - void CopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); - - void GenFramebuffers(GLsizei n, GLuint* framebuffers); - void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers); - void BindFramebuffer(GLenum target, GLuint framebuffer); - void FramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); - GLenum CheckFramebufferStatus(GLenum target); - void FramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); - - void GenRenderbuffers(GLsizei n, GLuint* renderbuffers); - void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers); - void BindRenderbuffer(GLenum target, GLuint renderbuffer); - void RenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); - - void StencilMask(GLuint mask); - void ClearStencil(GLint s); - - void Viewport(GLint x, GLint y, GLsizei width, GLsizei height); - void Scissor(GLint x, GLint y, GLsizei width, GLsizei height); - - void VertexAttribPointer(GLuint indx, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const GLvoid* ptr); - void EnableVertexAttribArray(GLuint index); - void DisableVertexAttribArray(GLuint index); - void VertexAttribfv(GLuint indx, int elem_size, const GLfloat* values); - - GLint GetUniformLocation(GLuint program, const GLchar* name); - void Uniformiv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLint* v); - void Uniformfv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLfloat* v); - void UniformMatrixfv(GLint location, - GLsizei count, - GLboolean transpose, - GLsizei dim_size, - const GLfloat* value); - - void DrawArrays(GLenum mode, GLint first, GLsizei count); - void DrawElements(GLenum mode, - GLsizei count, - GLenum type, - const GLvoid* indices); - - void ReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLvoid* pixels); - - void Flush(); - void Finish(); - void SwapBuffers(); - - // Called when eglBindTexImage() is called. - bool BindTextureToEGLSurface(egl::Surface* surface); - // Called when eglReleaseTexImage() is called. - bool ReleaseTextureFromEGLSurface(egl::Surface* surface); - - // Utility functions for use by other modules. - nb::scoped_refptr GetTexture(uint32_t id) { - return resource_manager_->GetTexture(id); - } - - DrawStateDirtyFlags* GetDrawStateDirtyFlags() { - return &draw_state_dirty_flags_; - } - - static bool has_swapped_buffers() { - return SbAtomicAcquire_Load(&has_swapped_buffers_) != 0; - } - - private: - void MakeCurrent(egl::Surface* draw, egl::Surface* read); - void ReleaseContext(); - void SetError(GLenum error) { error_ = error; } - - // Returns the bound buffer for the specific specified target. - // This returns a pointer because it is used by glBindBuffer() which modifies - // what the returned scoped_refptr points to. - nb::scoped_refptr* GetBoundBufferForTarget(GLenum target); - - // Returns the bound texture for the specific specified target and slot. - // This returns a pointer because it is used by glBindTexture() which modifies - // what the returned scoped_refptr points to. - nb::scoped_refptr* GetBoundTextureForTarget(GLenum target, - GLenum texture); - - void SetupExtensionsString(); - - void UpdateVertexAttribsInDrawState(); - void UpdateSamplersInDrawState(); - - // Packs enabled vertex attributes and samplers into dense lists in the - // |draw_state_| if they have been modified. - void CompressDrawStateForDrawCall(); - - // Marks the used program as being dirty, but this may also imply the marking - // of attributes and uniforms as being dirty as well. - void MarkUsedProgramDirty(); - - // Sets the bound framebuffer to the default framebuffer (e.g. when - // glBindFramebuffer(GL_FRAMEBUFFER, 0) is called). - void SetBoundDrawFramebufferToDefault(); - void SetBoundReadFramebufferToDefault(); - bool IsDefaultDrawFramebufferBound() const; - bool IsDefaultReadFramebufferBound() const; - - // Takes settings like GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT into - // account to determine the pitch of incoming pixel data. - int GetPitchForTextureData(int width, PixelFormat pixel_format) const; - - // A reference to the platform-specific implementation aspects of the context. - std::unique_ptr impl_; - - // The unique id of context instance. It might be queried from different - // threads. - std::atomic_int context_id_; - - // The thread that currently holds this context as its current context. - SbThread current_thread_; - - // Has this context ever been made current before? - bool has_been_current_; - - // The value to be returned when GetString(GL_EXTENSIONS) is called. - std::string extensions_string_; - - // The resource manager containing all referenced resources. - nb::scoped_refptr resource_manager_; - - // Sets the active texture, which can be thought of more intuitively as - // the active "sampler". Set using glActiveTexture(). - GLenum active_texture_; - - // The set of sampler units, of which |active_texture_| indexes. - std::unique_ptr[]> texture_units_; - bool enabled_textures_dirty_; - - // A mapping from an integer index (specified by the index parameter of - // glBindAttribLocation(), glVertexAttribPointer(), and others) to vertex - // attribute information structure. - std::map vertex_attrib_map_; - - // This map is populated by calls to glVertexAttribXfv() and contains - // attribute values that, when used, should apply to ALL vertices in a draw - // call. These attribute values will be used instead of those set by - // glVertexAttribPointer() whenever the corresponding vertex attribute id - // (the key of this map) attribute array is disabled through a call to - // glDisableVertexAttribArray(). - std::map const_vertex_attrib_map_; - - // Keeps track of which vertex attributes are enabled. This set is modified - // through calls to glEnableVertexAttribArray() and - // glDisableVertexAttribArray(). - std::set enabled_vertex_attribs_; - bool enabled_vertex_attribs_dirty_; - - // The default draw and read framebuffer are those whose surfaces are set by - // calls to eglMakeCurrent(). The default draw framebuffer is the initial - // framebuffer target for draw commands, and can be selected by calling - // glBindFramebuffer(0). - nb::scoped_refptr default_draw_framebuffer_; - nb::scoped_refptr default_read_framebuffer_; - - // The currently bound read framebuffer. If this is set to the default read - // framebuffer, then it will be equal to |default_read_framebuffer_|. - nb::scoped_refptr read_framebuffer_; - - // Tracks all GL draw state. It is updated by making various GL calls, - // and it is read when a draw (or clear) call is made. It is modified - // by this Context object and read from the ContextImpl object. - DrawState draw_state_; - - // Tracks which members of |draw_state_| have been modified since the last - // draw (or clear) command issued to the ContextImpl object. This - // allows implementations to determine whether it is necessary to re-setup - // certain context information. It is expected that implementations will - // set these dirty flags to false after they have processed the corresponding - // draw state. - DrawStateDirtyFlags draw_state_dirty_flags_; - - // The pack/unpack alignments are used when transferring pixel data to/from - // client CPU memory, respectively. For example, calls to glTexImage2D() - // will refer to the unpack alignment to determine the expected alignment - // of each row of pixel data. These values are set through glPixelStorei(). - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml - int pack_alignment_; - int unpack_alignment_; - - // Allows the pitch of texture data to be explicitly specified. This value - // can be modified by calling glPixelStorei(GL_UNPACK_ALIGNMENT, x). - // https://www.khronos.org/opengles/sdk/docs/man3/html/glPixelStorei.xhtml - int unpack_row_length_; - - // Tracks the currently bound pixel unpack buffer object, or NULL if none - // are bound. - nb::scoped_refptr bound_pixel_unpack_buffer_; - - // Keeps track of the set of EGLSurfaces that are bound to textures - // currently. - std::map > bound_egl_surfaces_; - - // The currently bound renderbuffer, specified through a call to - // glBindRenderbuffer(). - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindRenderbuffer.xml - nb::scoped_refptr bound_renderbuffer_; - - // The last GL ES error raised. - GLenum error_; - - // Track if SwapBuffers() has been called. Stores 0 if SwapBuffers() has not - // been called, and 1 if SwapBuffers() has been called. - static SbAtomic32 has_swapped_buffers_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_CONTEXT_H_ diff --git a/glimp/gles/context_impl.h b/glimp/gles/context_impl.h deleted file mode 100644 index 4c9792a603d5..000000000000 --- a/glimp/gles/context_impl.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_CONTEXT_IMPL_H_ -#define GLIMP_GLES_CONTEXT_IMPL_H_ - -#include -#include -#include - -#include -#include "glimp/egl/surface.h" -#include "glimp/gles/buffer.h" -#include "glimp/gles/buffer_impl.h" -#include "glimp/gles/draw_mode.h" -#include "glimp/gles/draw_state.h" -#include "glimp/gles/index_data_type.h" -#include "glimp/gles/program.h" -#include "glimp/gles/program_impl.h" -#include "glimp/gles/sampler.h" -#include "glimp/gles/shader_impl.h" -#include "glimp/gles/texture_impl.h" -#include "glimp/gles/vertex_attribute.h" - -namespace glimp { -namespace gles { - -// The ContextImpl class is the interface to the platform-specific backend -// implementation of GL ES Context calls. Many GL ES methods will ultimately -// end up calling a method on this class. This class is also responsible for -// acting as a factory for the generation of resource Impl objects as well, -// such as textures or shaders. -class ContextImpl { - public: - // Type returned from GetExtensions() in response to - // glGetString(GL_EXTENSIONS). - typedef std::vector ExtensionList; - - virtual ~ContextImpl() {} - - // Called via glGetString(GL_EXTENSIONS). - // Note that glimp common code may append its own extensions to the list - // provided by the implementation. - // https://www.khronos.org/opengles/sdk/1.1/docs/man/glGetString.xml - virtual ExtensionList GetExtensions() const = 0; - - // Called via glGetIntegerv(GL_MAX_VERTEX_ATTRIBS). - // Returns the maximum supported number of enabled vertex attributes. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxVertexAttribs() const = 0; - - // Called via glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS). - // Returns the maximum supported number of textures per fragment shader. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxFragmentTextureUnits() const = 0; - - // Called via glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS). - // Returns the maximum supported number of textures per vertex shader. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxVertexTextureImageUnits() const = 0; - - // Called via glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS). - // Returns the maximum supported number of textures that can be used - // to access textures from both vertex and fragment shaders combined. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxCombinedTextureImageUnits() const = 0; - - // Called via glGetIntegerv(GL_MAX_TEXTURE_SIZE). - // Returns the maximum width and height of a texture, in pixels. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxTextureSize() const = 0; - - // Called via glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE). - // Returns the maximum width and height of a render buffer, in pixels. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxRenderbufferSize() const = 0; - - // Called via glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS). - // Returns the maximum number of uniforms that can be bound to a fragment - // shader. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml - virtual int GetMaxFragmentUniformVectors() const = 0; - - // Called via glCreateProgram. Must create and return a platform-specific - // ProgramImpl implementation. If a NULL scoped_ptr is returned, it is - // treated as an error. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCreateProgram.xml - virtual std::unique_ptr CreateProgram() = 0; - - // Called via glCreateShader(GL_VERTEX_SHADER). Must create a - // platform-specific ShaderImpl object representing a vertex shader. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCreateShader.xml - virtual std::unique_ptr CreateVertexShader() = 0; - - // Called via glCreateShader(GL_FRAGMENT_SHADER). Must create a - // platform-specific ShaderImpl object representing a fragment shader. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCreateShader.xml - virtual std::unique_ptr CreateFragmentShader() = 0; - - // Called via glGenBuffers(). Must create a platform-specific BufferImpl - // object representing a buffer. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenBuffers.xml - virtual std::unique_ptr CreateBuffer() = 0; - - // Called via glGenBuffersForVideoFrame(). Must create a platform-specific - // BufferImpl object representing a buffer for compressed textures. - virtual std::unique_ptr CreateBufferForVideoFrame() = 0; - - // Called via glGenTextures(). Must create a platform-specific TextureImpl - // object representing a texture. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenTextures.xml - virtual std::unique_ptr CreateTexture() = 0; - - // Called when glFlush() is called. After this method is called, client - // code may assume that all previously issued graphics commands will - // eventually be executed by the GPU. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glFlush.xml - virtual void Flush() = 0; - - // Called when glFinish() is called. After this method is called, client - // code can assume that all previously issued GL commands have been submitted - // and also have finished being processed by the GPU. - // https://www.khronos.org/opengles/sdk/docs/man3/html/glFinish.xhtml - virtual void Finish() = 0; - - // Called when glClear() is called. Clears all of the three buffers that have - // their |clear_*| parameters set. - // |draw_state| represents the current GL ES draw state at the time of this - // call. - // |dirty_flags| represents which members of the |draw_state| have been - // modified since the last draw (or clear) call. This can - // be leveraged to avoid reconfiguring unchanged state. - // It is expected that implementations will manually set - // these flags to false after they have processed the - // corresponding draw state member. - // https://www.opengl.org/sdk/docs/man2/xhtml/glClear.xml - virtual void Clear(bool clear_color, - bool clear_depth, - bool clear_stencil, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) = 0; - - // Called when glDrawArrays() is called. This method must generate GPU - // commands to render the passed in |draw_state.array_buffer| whose structure - // is defined by |draw_state.attributes|. The vertex program - // |draw_state.used_program| should be used to render the vertices, and - // |draw_state.samplers| defines the set of textures to be bound for - // the draw call. - // |draw_state| represents the current GL ES draw state at the time of this - // call. - // |dirty_flags| represents which members of the |draw_state| have been - // modified since the last draw (or clear) call. This can - // be leveraged to avoid reconfiguring unchanged state. - // It is expected that implementations will manually set - // these flags to false after they have processed the - // corresponding draw state member. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawArrays.xml - virtual void DrawArrays(DrawMode mode, - int first_vertex, - int num_vertices, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) = 0; - - // Called when glDrawElements() is called. This method must generate GPU - // commands to render the passed in |draw_state.array_buffer| whose structure - // is defined by |draw_state.attributes|. The particular vertices rendered - // are chosen by the indices defined within |draw_state.element_array_buffer| - // + |intptr_t index_offset_in_bytes|. The vertex program - // |draw_state.used_program| should be used to render the vertices, and - // |draw_state.samplers| defines the set of textures to be bound for the draw - // call. - // |draw_state| represents the current GL ES draw state at the time of this - // call. - // |dirty_flags| represents which members of the |draw_state| have been - // modified since the last draw (or clear) call. This can - // be leveraged to avoid reconfiguring unchanged state. - // It is expected that implementations will manually set - // these flags to false after they have processed the - // corresponding draw state member. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml - virtual void DrawElements(DrawMode mode, - int num_vertices, - IndexDataType index_data_type, - intptr_t index_offset_in_bytes, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) = 0; - - // Called when eglSwapBuffers() is called. This method is responsible for - // submitting a command to the GPU to indicate that we are done rendering this - // frame and that the current draw surface should be swapped to the display. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglSwapBuffers.xhtml - virtual void SwapBuffers(egl::Surface* surface) = 0; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_CONTEXT_IMPL_H_ diff --git a/glimp/gles/convert_pixel_data.cc b/glimp/gles/convert_pixel_data.cc deleted file mode 100644 index ca59f8f56f6a..000000000000 --- a/glimp/gles/convert_pixel_data.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/convert_pixel_data.h" - -#include "starboard/common/log.h" -#include "starboard/memory.h" - -namespace glimp { -namespace gles { - -namespace { - -// Helper method to properly copy pixel data from a source to destination -// pixel data, taking into account source and destination pitch. -void CopyPixelData(uint8_t* destination, - int destination_pitch, - const uint8_t* source, - int source_pitch, - int bytes_per_row, - int num_rows) { - if (destination_pitch == source_pitch) { - // If the pitches are equal, we can do the entire copy in one memcpy(). - memcpy(destination, source, destination_pitch * num_rows); - } else { - // If the pitches are not equal, we must memcpy each row separately. - for (int i = 0; i < num_rows; ++i) { - memcpy(destination + i * destination_pitch, source + i * source_pitch, - bytes_per_row); - } - } -} - -typedef void (*ConvertRowFunction)(int, uint8_t*, const uint8_t*, int); - -// Remaps input pixel channels such that 4-byte destination color values will -// have byte X set from source color value's channel_X_source byte. If -// any value for channel_X_source is set to -1, a 0 is instead set for that -// destination channel. -template -void RemapPixelChannels(int source_bytes_per_pixel, - uint8_t* destination, - const uint8_t* source, - int num_pixels) { - for (int i = 0; i < num_pixels; ++i) { - uint8_t channel_0 = channel_0_source == -1 ? 0 : source[channel_0_source]; - uint8_t channel_1 = channel_1_source == -1 ? 0 : source[channel_1_source]; - uint8_t channel_2 = channel_2_source == -1 ? 0 : source[channel_2_source]; - uint8_t channel_3 = channel_3_source == -1 ? 0 : source[channel_3_source]; - destination[0] = channel_0; - destination[1] = channel_1; - destination[2] = channel_2; - destination[3] = channel_3; - - destination += 4; - source += source_bytes_per_pixel; - } -} - -// Given a destination and source format, returns a function that will convert -// a row of pixels in a source buffer to a row of pixels in a destination -// buffer that contains a different format. This function may not implement -// every conversion, it is expected that conversion implementations will be -// added as they are needed. -ConvertRowFunction SelectConvertRowFunction(PixelFormat destination_format, - PixelFormat source_format) { - if (destination_format == source_format) { - return &RemapPixelChannels<0, 1, 2, 3>; - } else if (destination_format == kPixelFormatRGBA8 && - source_format == kPixelFormatARGB8) { - return &RemapPixelChannels<1, 2, 3, 0>; - } else if (destination_format == kPixelFormatRGBA8 && - source_format == kPixelFormatBGRA8) { - return &RemapPixelChannels<2, 1, 0, 3>; - } - - // Only what is currently needed by dependent libraries is supported, so - // feel free to add support for more pixel formats here as the need arises. - - return NULL; -} - -} // namespace - -void ConvertPixelDataInplace(uint8_t* pixels, - int pitch_in_bytes, - PixelFormat destination_format, - PixelFormat source_format, - int width, - int height) { - if (destination_format == source_format) { - return; - } - SB_DCHECK(BytesPerPixel(destination_format) == BytesPerPixel(source_format)); - // The destination format is different from the source format, so we must - // perform a conversion between pixels. - - // First select the function that will reformat the pixels, based on - // the destination and source pixel formats. - ConvertRowFunction convert_row_function = - SelectConvertRowFunction(destination_format, source_format); - SB_DCHECK(convert_row_function) - << "The requested pixel conversion is not yet implemented."; - - // Now, iterate through each row running the selected conversion function on - // each one. - uint8_t* pixel_row = pixels; - for (int row = 0; row < height; ++row) { - convert_row_function(BytesPerPixel(source_format), pixel_row, pixel_row, - width); - pixel_row += pitch_in_bytes; - } -} - -void ConvertPixelData(uint8_t* destination, - int destination_pitch_in_bytes, - PixelFormat destination_format, - const uint8_t* source, - int source_pitch_in_bytes, - PixelFormat source_format, - int width, - int height, - bool flip_y) { - if (destination_format == source_format && !flip_y) { - CopyPixelData(destination, destination_pitch_in_bytes, source, - source_pitch_in_bytes, BytesPerPixel(source_format) * width, - height); - } else { - // The destination format is different from the source format, so we must - // perform a conversion between pixels. - - // First select the function that will reformat the pixels, based on - // the destination and source pixel formats. - ConvertRowFunction convert_row_function = - SelectConvertRowFunction(destination_format, source_format); - SB_DCHECK(convert_row_function) - << "The requested pixel conversion is not yet implemented."; - - // Now, iterate through each row running the selected conversion function on - // each one. - for (int dest_row = 0; dest_row < height; ++dest_row) { - int source_row = flip_y ? height - dest_row - 1 : dest_row; - convert_row_function(BytesPerPixel(source_format), - destination + dest_row * destination_pitch_in_bytes, - source + source_row * source_pitch_in_bytes, width); - } - } -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/convert_pixel_data.h b/glimp/gles/convert_pixel_data.h deleted file mode 100644 index c11721b28fe3..000000000000 --- a/glimp/gles/convert_pixel_data.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_CONVERT_PIXEL_DATA_H_ -#define GLIMP_GLES_CONVERT_PIXEL_DATA_H_ - -#include "glimp/gles/pixel_format.h" - -namespace glimp { -namespace gles { - -enum PixelDataEndian { - kPixelDataLittleEndian, - kPixelDataBigEndian, -}; - -// Converts pixel data in pixel buffer from the source format into the -// destination format, swizzeling the pixel color components if necessary. -void ConvertPixelDataInplace(uint8_t* pixels, - int pitch_in_bytes, - PixelFormat destination_format, - PixelFormat source_format, - int width, - int height); - -// Copies pixel data from the source buffer and format into the destination -// buffer and format, swizzeling the pixel color components if necessary. -void ConvertPixelData(uint8_t* destination, - int destination_pitch_in_bytes, - PixelFormat destination_format, - const uint8_t* source, - int source_pitch_in_bytes, - PixelFormat source_format, - int width, - int height, - bool flip_y); - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_CONVERT_PIXEL_DATA_H_ diff --git a/glimp/gles/cull_face_state.h b/glimp/gles/cull_face_state.h deleted file mode 100644 index b68d6b0015e5..000000000000 --- a/glimp/gles/cull_face_state.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_CULL_FACE_STATE_H_ -#define GLIMP_GLES_CULL_FACE_STATE_H_ - -namespace glimp { -namespace gles { - -// Describes GL cull face state, which can be modified via commands like -// glCullFace(). -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCullFace.xml -struct CullFaceState { - // When enabled, the initial face culling value should be kBack. - enum Mode { - kFront, - kBack, - kFrontAndBack, - kModeInvalid, - }; - - // Default state is face culling off. - CullFaceState() : enabled(false), mode(kBack) {} - - Mode mode; - bool enabled; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_CULL_FACE_STATE_H_ diff --git a/glimp/gles/draw_mode.h b/glimp/gles/draw_mode.h deleted file mode 100644 index 365f173ecba2..000000000000 --- a/glimp/gles/draw_mode.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_DRAW_MODE_H_ -#define GLIMP_GLES_DRAW_MODE_H_ - -namespace glimp { -namespace gles { - -// Defines the legal values for the draw mode parameter passed into -// glDrawArrays() and glDrawElements(). -enum DrawMode { - kDrawModePoints, - kDrawModeLines, - kDrawModeLineLoop, - kDrawModeLineStrip, - kDrawModeTriangles, - kDrawModeTriangleStrip, - kDrawModeTriangleFan, - kDrawModeInvalid, -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_DRAW_MODE_H_ diff --git a/glimp/gles/draw_state.cc b/glimp/gles/draw_state.cc deleted file mode 100644 index b1fa91d079e6..000000000000 --- a/glimp/gles/draw_state.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/draw_state.h" - -namespace glimp { -namespace gles { - -DirtyUniforms::DirtyUniforms() : all_dirty_(true) {} - -bool DirtyUniforms::IsDirty(int location) const { - return all_dirty_ || std::find(uniforms_dirty_.begin(), uniforms_dirty_.end(), - location) != uniforms_dirty_.end(); -} - -bool DirtyUniforms::AnyDirty() const { - return all_dirty_ || !uniforms_dirty_.empty(); -} - -void DirtyUniforms::ClearAll() { - all_dirty_ = false; - uniforms_dirty_.clear(); -} - -void DirtyUniforms::MarkAll() { - all_dirty_ = true; -} - -void DirtyUniforms::Mark(int location) { - if (!IsDirty(location)) { - uniforms_dirty_.push_back(location); - } -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/draw_state.h b/glimp/gles/draw_state.h deleted file mode 100644 index 2af6c7176b2e..000000000000 --- a/glimp/gles/draw_state.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_DRAW_STATE_H_ -#define GLIMP_GLES_DRAW_STATE_H_ - -#include -#include -#include - -#include "glimp/egl/surface.h" -#include "glimp/gles/blend_state.h" -#include "glimp/gles/buffer.h" -#include "glimp/gles/cull_face_state.h" -#include "glimp/gles/framebuffer.h" -#include "glimp/gles/program.h" -#include "glimp/gles/sampler.h" -#include "glimp/gles/vertex_attribute.h" -#include "glimp/rect.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -// Types passed in as parameters to draw calls (like DrawArrays()) to -// describe the set of only enabled vertex attributes. -typedef std::vector > - EnabledVertexAttributeList; - -// If a vertex attribute constant is specified (e.g. through a call to -// glVertexAttribXfv()) for a location, and the vertex attribute array is -// disabled at that location, then this constant value will be included into -// the draw state. -typedef std::vector > - ConstantVertexAttributeList; - -// Similar to EnabledVertexAttributeList, but lists only texture units with -// textures bound to them. -typedef std::vector > EnabledTextureList; - -struct ViewportState { - ViewportState() : rect(-1, -1, -1, -1) {} - - nb::Rect rect; -}; - -struct ScissorState { - ScissorState() : rect(-1, -1, -1, -1), enabled(false) {} - - nb::Rect rect; - - bool enabled; -}; - -struct ClearColor { - // Setup initial values as defined in the specification. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glClearColor.xml - ClearColor() : red(0.0f), green(0.0f), blue(0.0f), alpha(0.0f) {} - ClearColor(float red, float green, float blue, float alpha) - : red(std::min(1.0f, std::max(0.0f, red))), - green(std::min(1.0f, std::max(0.0f, green))), - blue(std::min(1.0f, std::max(0.0f, blue))), - alpha(std::min(1.0f, std::max(0.0f, alpha))) {} - - // Clear color properties setup by calls to glClearColor(). - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glClearColor.xml - float red; - float green; - float blue; - float alpha; -}; - -// Represents the state set by glColorMask(). -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glColorMask.xml -struct ColorMask { - // Setup initial values as defined in the specification. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glColorMask.xml - ColorMask() : red(true), green(true), blue(true), alpha(true) {} - ColorMask(bool red, bool green, bool blue, bool alpha) - : red(red), green(green), blue(blue), alpha(alpha) {} - - bool red; - bool green; - bool blue; - bool alpha; -}; - -// This class is used to keep track of which uniform locations are dirty, or -// whether all of them are. -class DirtyUniforms { - public: - DirtyUniforms(); - - // Returns true if the uniform at |location| is dirty. - bool IsDirty(int location) const; - - // Returns true if any uniform is dirty. - bool AnyDirty() const; - - // Clears the dirty flag from all uniforms. - void ClearAll(); - - // Marks all uniforms as being dirty. - void MarkAll(); - - // Marks the uniform at |location| as being dirty. - void Mark(int location); - - private: - std::vector uniforms_dirty_; - bool all_dirty_; -}; - -// The DrawState structure aggregates all GL state relevant to draw (or clear) -// commands. It will be modified as GL ES commands are issued, but it will -// only be propagated to the platform-specific implementations when draw (or -// clear) calls are made. A dirty flag is kept -struct DrawState { - // The color the next color buffer clear will clear to. - ClearColor clear_color; - - // Identifies which channels a draw (or clear) call is permitted to modify. - ColorMask color_mask; - - // The current surface that draw (or clear) commands will target. - egl::Surface* draw_surface; - - // The list of all active samplers that are available to the next draw call. - EnabledTextureList textures; - - // The list of vertex attribute binding information for the next draw call. - EnabledVertexAttributeList vertex_attributes; - ConstantVertexAttributeList constant_vertex_attributes; - - // The scissor rectangle. Draw calls should not modify pixels outside of - // this. - ScissorState scissor; - - // The viewport defines how normalized device coordinates should be - // transformed to screen pixel coordinates. - ViewportState viewport; - - // Defines how pixels produced by a draw call should be blended with the - // existing pixels in the output framebuffer. - BlendState blend_state; - - // Defines whether face culling is enabled, and upon which face if so. - CullFaceState cull_face_state; - - // The currently bound array buffer, set by calling - // glBindBuffer(GL_ARRAY_BUFFER). - nb::scoped_refptr array_buffer; - - // The currently bound element array buffer, set by calling - // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER). - nb::scoped_refptr element_array_buffer; - - // The currently in-use Program object, set by a call to glUseProgram(). - nb::scoped_refptr used_program; - - // The currently bound framebuffer. This is never NULL, even if the - // default framebuffer is bound, in which case - // framebuffer->color_attachment_surface() will be non-NULL and point to - // the draw surface specified through eglMakeCurrent(). - nb::scoped_refptr framebuffer; -}; - -// The dirty flags structure tracks which draw state members have been modified -// since the last draw call was made. This can be leveraged by implementations -// to avoid re-configurating draw state that has not changed. Implementations -// should manually set these flags to false after they have been processed. -struct DrawStateDirtyFlags { - DrawStateDirtyFlags() { MarkAll(); } - - void MarkAll() { - clear_color_dirty = true; - color_mask_dirty = true; - draw_surface_dirty = true; - textures_dirty = true; - vertex_attributes_dirty = true; - scissor_dirty = true; - viewport_dirty = true; - blend_state_dirty = true; - cull_face_dirty = true; - array_buffer_dirty = true; - element_array_buffer_dirty = true; - used_program_dirty = true; - framebuffer_dirty = true; - uniforms_dirty.MarkAll(); - } - - void MarkUsedProgram() { - used_program_dirty = true; - // Switching programs marks all uniforms, samplers and vertex attributes - // as being dirty as well, since they are all properties of the program. - vertex_attributes_dirty = true; - textures_dirty = true; - uniforms_dirty.MarkAll(); - } - - bool clear_color_dirty; - bool color_mask_dirty; - bool draw_surface_dirty; - bool textures_dirty; - bool vertex_attributes_dirty; - bool scissor_dirty; - bool viewport_dirty; - bool blend_state_dirty; - bool cull_face_dirty; - bool array_buffer_dirty; - bool element_array_buffer_dirty; - bool used_program_dirty; - bool framebuffer_dirty; - - // A list of uniform locations (within DrawState::used_program->uniforms()) - // whose values are dirty. - DirtyUniforms uniforms_dirty; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_DRAW_STATE_H_ diff --git a/glimp/gles/framebuffer.cc b/glimp/gles/framebuffer.cc deleted file mode 100644 index d3bf696b20b8..000000000000 --- a/glimp/gles/framebuffer.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/framebuffer.h" -#include "starboard/common/log.h" - -namespace glimp { -namespace gles { - -Framebuffer::Framebuffer() : color_attachment_surface_(NULL) {} - -Framebuffer::Framebuffer(egl::Surface* surface) - : color_attachment_surface_(surface) { - SB_DCHECK(surface != NULL); -} - -int Framebuffer::GetWidth() const { - if (color_attachment_surface_) { - return color_attachment_surface_->GetWidth(); - } else { - SB_DCHECK(color_attachment_texture_); - return color_attachment_texture_->width(); - } -} - -int Framebuffer::GetHeight() const { - if (color_attachment_surface_) { - return color_attachment_surface_->GetHeight(); - } else { - SB_DCHECK(color_attachment_texture_); - return color_attachment_texture_->height(); - } -} - -void Framebuffer::AttachTexture2D(const nb::scoped_refptr& texture, - int level) { - SB_DCHECK(!color_attachment_surface_); - - SB_DCHECK(level == 0) << "Only level=0 is supported in glimp."; - - color_attachment_texture_ = texture; -} - -GLenum Framebuffer::CheckFramebufferStatus() const { - // If the default framebuffer is bound, then the framebuffer is guaranteed - // to be complete. - if (color_attachment_surface_) { - return GL_FRAMEBUFFER_COMPLETE; - } - - if (!color_attachment_texture_) { - return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; - } - - if (!color_attachment_texture_->CanBeAttachedToFramebuffer()) { - return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - } - - if (depth_attachment_) { - if (depth_attachment_->format() != GL_DEPTH_COMPONENT16) { - return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - } - - if (GetWidth() != depth_attachment_->width() || - GetHeight() != depth_attachment_->height()) { - return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; - } - } - - if (stencil_attachment_) { - if (stencil_attachment_->format() != GL_STENCIL_INDEX8) { - return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - } - - if (GetWidth() != stencil_attachment_->width() || - GetHeight() != stencil_attachment_->height()) { - return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; - } - } - - return GL_FRAMEBUFFER_COMPLETE; -} - -void Framebuffer::UpdateColorSurface(egl::Surface* surface) { - SB_DCHECK(!color_attachment_texture_); - SB_DCHECK(color_attachment_surface_); - color_attachment_surface_ = surface; -} - -void Framebuffer::SetDepthAttachment( - const nb::scoped_refptr& depth_attachment) { - depth_attachment_ = depth_attachment; -} - -void Framebuffer::SetStencilAttachment( - const nb::scoped_refptr& stencil_attachment) { - stencil_attachment_ = stencil_attachment; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/framebuffer.h b/glimp/gles/framebuffer.h deleted file mode 100644 index b59301cdd884..000000000000 --- a/glimp/gles/framebuffer.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_FRAMEBUFFER_H_ -#define GLIMP_GLES_FRAMEBUFFER_H_ - -#include "glimp/egl/surface.h" -#include "glimp/gles/renderbuffer.h" -#include "glimp/gles/texture.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -// Framebuffers represent GL framebuffer objects. They are generated via -// calls to glGenFramebuffers(). Framebuffers represent the collection of -// components required for draw calls to direct their output towards. These -// components are called "attachments" and include the color buffer, -// depth buffer and stencil buffer. These different buffers can be attached -// by various GL calls. For example, to attach a color buffer, one should -// call glFramebufferTexture2D() and pass in a GL texture object. -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenFramebuffers.xml -class Framebuffer : public nb::RefCountedThreadSafe { - public: - Framebuffer(); - - // This constructor can be used to initialize the default Framebuffer. This - // framebuffer cannot later have separate attachments made to it. - explicit Framebuffer(egl::Surface* surface); - - // Returns the attached color buffer's width and height. - int GetWidth() const; - int GetHeight() const; - - // Called when glFramebufferTexture2D() is called. Will attach the specified - // texture to this framebuffer. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glFramebufferTexture2D.xml - void AttachTexture2D(const nb::scoped_refptr& texture, int level); - - // Called when glCheckFramebufferStatus() is called. This will check that - // that there are not no components attached, and that all attached components - // are consistent with each other and valid. If everything checks out, - // GL_FRAMEBUFFER_COMPLETE is returned. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCheckFramebufferStatus.xml - GLenum CheckFramebufferStatus() const; - - // Called by eglMakeCurrent() on the default framebuffer in order to update - // the egl::Surface* on the color attachment. This can only be called on - // a surface constructed with a egl::Surface* parameter (e.g. the default - // framebuffer). - void UpdateColorSurface(egl::Surface* surface); - - void SetDepthAttachment(const nb::scoped_refptr& depth_buffer); - void SetStencilAttachment( - const nb::scoped_refptr& stencil_buffer); - - const nb::scoped_refptr& color_attachment_texture() const { - return color_attachment_texture_; - } - - egl::Surface* color_attachment_surface() const { - return color_attachment_surface_; - } - - const nb::scoped_refptr& depth_attachment() const { - return depth_attachment_; - } - - const nb::scoped_refptr& stencil_attachment() const { - return stencil_attachment_; - } - - private: - friend class nb::RefCountedThreadSafe; - ~Framebuffer() {} - - // Only one of |color_attachment_texture_| or |color_attachment_surface_| - // can be non-NULL. If |color_attachment_surface_| is non-NULL, then this - // is the default framebuffer. - nb::scoped_refptr color_attachment_texture_; - egl::Surface* color_attachment_surface_; - - nb::scoped_refptr depth_attachment_; - nb::scoped_refptr stencil_attachment_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_FRAMEBUFFER_H_ diff --git a/glimp/gles/index_data_type.h b/glimp/gles/index_data_type.h deleted file mode 100644 index 595cadc58066..000000000000 --- a/glimp/gles/index_data_type.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_INDEX_DATA_TYPE_H_ -#define GLIMP_GLES_INDEX_DATA_TYPE_H_ - -namespace glimp { -namespace gles { - -// Defines the data type of each index element stored in an index buffer. This -// will be passed into calls to DrawElements(). -enum IndexDataType { - kIndexDataTypeUnsignedByte, - kIndexDataTypeUnsignedShort, - kIndexDataTypeInvalid, -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_INDEX_DATA_TYPE_H_ diff --git a/glimp/gles/pixel_format.cc b/glimp/gles/pixel_format.cc deleted file mode 100644 index 48ed1355da00..000000000000 --- a/glimp/gles/pixel_format.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/pixel_format.h" - -namespace glimp { -namespace gles { - -namespace { - -// Must match the ordering of the PixelFormat enum defined in pixel_format.h. -const int kBytesPerPixel[] = { - 4, // kPixelFormatRGBA8 - 4, // kPixelFormatARGB8 - 4, // kPixelFormatBGRA8 - 2, // kPixelFormatRGB565 - 2, // kPixelFormatBA8 - 1, // kPixelFormatA8 - 2, // kPixelFormatA16 -}; - -} // namespace - -int BytesPerPixel(PixelFormat format) { - SB_COMPILE_ASSERT(SB_ARRAY_SIZE(kBytesPerPixel) == kPixelFormatNumFormats, - kBytesPerPixel_has_entries_for_each_enum_PixelFormat); - if (kPixelFormatInvalid == format) { - return 0; // Invalid formats have 0 bytes per pixel. - } - - if (format < 0 || format >= kPixelFormatNumFormats) { - SB_DCHECK(false) << "Invalid PixelFormat: " << format; - return 0; - } - return kBytesPerPixel[format]; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/pixel_format.h b/glimp/gles/pixel_format.h deleted file mode 100644 index 0a781486fd9d..000000000000 --- a/glimp/gles/pixel_format.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_PIXEL_FORMAT_H_ -#define GLIMP_GLES_PIXEL_FORMAT_H_ - -#include -#include "glimp/gles/buffer_impl.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -// An internal structure which maintains information on a limited number of -// glimp-supported pixel formats for both textures and render targets. -enum PixelFormat { - kPixelFormatRGBA8, - kPixelFormatARGB8, - kPixelFormatBGRA8, - kPixelFormatRGB565, - kPixelFormatBA8, - kPixelFormatA8, - kPixelFormatA16, - kPixelFormatInvalid, - kPixelFormatNumFormats = kPixelFormatInvalid -}; - -// Returns the number of bytes per pixel for a given PixelFormat. -int BytesPerPixel(PixelFormat format); - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_PIXEL_FORMAT_H_ diff --git a/glimp/gles/program.cc b/glimp/gles/program.cc deleted file mode 100644 index d58ba385ea4a..000000000000 --- a/glimp/gles/program.cc +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/program.h" - -#include - -#include "starboard/common/string.h" -#include "starboard/memory.h" - -namespace glimp { -namespace gles { - -Program::Program(std::unique_ptr impl) - : impl_(std::move(impl)), link_results_(false) {} - -bool Program::AttachShader(const nb::scoped_refptr& shader) { - if (shader->type() == GL_VERTEX_SHADER) { - if (vertex_shader_) { - return false; - } - vertex_shader_ = shader; - } else if (shader->type() == GL_FRAGMENT_SHADER) { - if (fragment_shader_) { - return false; - } - fragment_shader_ = shader; - } else { - SB_DLOG(FATAL) << "Invalid shader type."; - } - - return true; -} - -void Program::Link() { - if (!vertex_shader_ || !fragment_shader_) { - // We cannot successfully link if both a vertex and fragment shader - // have not yet been attached. - link_results_ = ProgramImpl::LinkResults( - false, "A fragment or vertex shader is not attached."); - return; - } - - link_results_ = impl_->Link(vertex_shader_, fragment_shader_); - if (link_results_.success) { - linked_vertex_shader_ = vertex_shader_; - linked_fragment_shader_ = fragment_shader_; - - ClearUniforms(); - - // Re-issue any binding attributes that are defined for this program. - for (BoundAttributes::const_iterator iter = bound_attrib_locations_.begin(); - iter != bound_attrib_locations_.end(); ++iter) { - impl_->BindAttribLocation(iter->first, iter->second.c_str()); - } - } -} - -void Program::BindAttribLocation(GLuint index, const GLchar* name) { - bound_attrib_locations_[index] = std::string(name); - - if (linked()) { - // If we are linked, then immediately pass this new binding information - // on to the platform-specific implementation. Otherwise, this information - // will all be communicated upon linking. - impl_->BindAttribLocation(index, name); - } -} - -GLenum Program::GetProgramiv(GLenum pname, GLint* params) { - switch (pname) { - case GL_LINK_STATUS: - *params = (link_results_.success ? 1 : 0); - break; - case GL_INFO_LOG_LENGTH: - *params = link_results_.info_log.size(); - break; - case GL_DELETE_STATUS: - case GL_VALIDATE_STATUS: - case GL_ATTACHED_SHADERS: - case GL_ACTIVE_ATTRIBUTES: - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - case GL_ACTIVE_UNIFORMS: - case GL_ACTIVE_UNIFORM_MAX_LENGTH: - SB_NOTIMPLEMENTED(); - break; - default: - return GL_INVALID_ENUM; - } - - return GL_NO_ERROR; -} - -void Program::GetProgramInfoLog(GLsizei bufsize, - GLsizei* length, - GLchar* infolog) { - *length = - starboard::strlcpy(infolog, link_results_.info_log.c_str(), bufsize); -} - -GLint Program::GetUniformLocation(const GLchar* name) { - SB_DCHECK(linked()); - int location = impl_->GetUniformLocation(name); - if (location != -1) { - if (std::find(active_uniform_locations_.begin(), - active_uniform_locations_.end(), - location) == active_uniform_locations_.end()) { - active_uniform_locations_.push_back(location); - } - } - return location; -} - -GLenum Program::Uniformiv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLint* v) { - return UpdateUniform(location, count, elem_size, v, - UniformInfo::kTypeInteger); -} - -GLenum Program::Uniformfv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLfloat* v) { - return UpdateUniform(location, count, elem_size, v, UniformInfo::kTypeFloat); -} - -GLenum Program::UniformMatrixfv(GLint location, - GLsizei count, - GLsizei dim_size, - const GLfloat* value) { - return UpdateUniform(location, count, dim_size, value, - UniformInfo::kTypeMatrix); -} - -Program::Uniform* Program::FindOrMakeUniform(int location) { - if (std::find(active_uniform_locations_.begin(), - active_uniform_locations_.end(), - location) == active_uniform_locations_.end()) { - return NULL; - } - - for (size_t i = 0; i < uniforms_.size(); ++i) { - if (uniforms_[i].location == location) { - return &uniforms_[i]; - } - } - uniforms_.push_back(Uniform()); - uniforms_.back().location = location; - return &uniforms_.back(); -} - -// Clear all stored uniform information and values. -void Program::ClearUniforms() { - for (size_t i = 0; i < uniforms_.size(); ++i) { - free(uniforms_[i].data); - } - uniforms_.clear(); - active_uniform_locations_.clear(); -} - -namespace { -int DataSizeForType(GLsizei count, GLsizei elem_size, UniformInfo::Type type) { - switch (type) { - case UniformInfo::kTypeInteger: - return sizeof(int) * count * elem_size; - case UniformInfo::kTypeFloat: - return sizeof(float) * count * elem_size; - case UniformInfo::kTypeMatrix: - return sizeof(float) * count * elem_size * elem_size; - default: - SB_NOTREACHED(); - return NULL; - } -} -} // namespace - -// Assign the specified data to the specified uniform, so that it is available -// to the next draw call. -GLenum Program::UpdateUniform(GLint location, - GLsizei count, - GLsizei elem_size, - const void* v, - UniformInfo::Type type) { - // TODO: It would be nice to be able to query the ProgramImpl object for - // UniformInfo information so that we can check it against incoming - // glUniform() calls to ensure consistency. As it is currently, we are - // defining this information through these glUniform() calls. - Uniform* uniform = FindOrMakeUniform(location); - if (uniform == NULL) { - return GL_INVALID_OPERATION; - } - - UniformInfo new_info = UniformInfo(type, count, elem_size); - if (new_info != uniform->info) { - // We need to reallocate data if the information has changed. - uniform->info = new_info; - - free(uniform->data); - uniform->data = malloc(DataSizeForType(count, elem_size, type)); - } - memcpy(uniform->data, v, DataSizeForType(count, elem_size, type)); - - return GL_NO_ERROR; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/program.h b/glimp/gles/program.h deleted file mode 100644 index c643620778d9..000000000000 --- a/glimp/gles/program.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_PROGRAM_H_ -#define GLIMP_GLES_PROGRAM_H_ - -#include - -#include -#include -#include - -#include -#include "glimp/gles/program_impl.h" -#include "glimp/gles/shader.h" -#include "glimp/gles/uniform_info.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class Program : public nb::RefCountedThreadSafe { - public: - // Represents a Uniform entry in this program, including type information - // about it and the actual data as it was last set via a call to - // UniformXv(). - struct Uniform { - Uniform() : location(-1), data(NULL) {} - - int location; - UniformInfo info; - void* data; - }; - - explicit Program(std::unique_ptr impl); - - // Attaches the specified shader to either this program's vertex or fragment - // shader slot, depending on the shader type. If a shader of the given - // type is already attached, this method does nothing and returns false, - // otherwise the shader is attached and true is returned. - bool AttachShader(const nb::scoped_refptr& shader); - - // Links the vertex and fragment shaders, making the shader usable. - void Link(); - - bool linked() const { return link_results_.success; } - - void BindAttribLocation(GLuint index, const GLchar* name); - - ProgramImpl* impl() const { return impl_.get(); } - - GLenum GetProgramiv(GLenum pname, GLint* params); - void GetProgramInfoLog(GLsizei bufsize, GLsizei* length, GLchar* infolog); - - GLint GetUniformLocation(const GLchar* name); - GLenum Uniformiv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLint* v); - GLenum Uniformfv(GLint location, - GLsizei count, - GLsizei elem_size, - const GLfloat* v); - GLenum UniformMatrixfv(GLint location, - GLsizei count, - GLsizei dim_size, - const GLfloat* value); - - // Returns the current list of all uniforms that have been targeted by - // UniformXv() calls since the last call to Link(). - const std::vector uniforms() const { return uniforms_; } - - private: - typedef std::map BoundAttributes; - friend class nb::RefCountedThreadSafe; - ~Program() {} - - // Returns a U - Uniform* FindOrMakeUniform(int location); - void ClearUniforms(); - GLenum UpdateUniform(GLint location, - GLsizei count, - GLsizei elem_size, - const void* v, - UniformInfo::Type type); - - std::unique_ptr impl_; - - nb::scoped_refptr vertex_shader_; - nb::scoped_refptr fragment_shader_; - - // We explicitly reference the last-linked vertex and fragment shaders to - // ensure that they stay valid as long as they're linked. - nb::scoped_refptr linked_vertex_shader_; - nb::scoped_refptr linked_fragment_shader_; - - // Stores the value that will be returned when glGetProgramiv(GL_LINK_STATUS) - // or glGetProgramiv(GL_INFO_LOG_LENGTH) is called. - ProgramImpl::LinkResults link_results_; - - // Constructed by glBindAttribLocation(), this maps generic vertex attribute - // indices to attribute names, and applies when and after a program is linked. - BoundAttributes bound_attrib_locations_; - - // The list of all uniforms that have been assigned values through - // the UniformXv() methods. - std::vector uniforms_; - - // Keeps track of all uniform locations that have been returned by a call - // to GetUniformLocation() above. These may or may not have had values - // assigned to them since a Link(). - std::vector active_uniform_locations_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_PROGRAM_H_ diff --git a/glimp/gles/program_impl.h b/glimp/gles/program_impl.h deleted file mode 100644 index 2cdad926ec0a..000000000000 --- a/glimp/gles/program_impl.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_PROGRAM_IMPL_H_ -#define GLIMP_GLES_PROGRAM_IMPL_H_ - -#include - -#include "glimp/gles/shader.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class ProgramImpl { - public: - // Return value from the Link() method. Can be used to communicate an - // error message to the client. - struct LinkResults { - explicit LinkResults(bool success) : success(success) {} - LinkResults(bool success, const std::string& info_log) - : success(success), info_log(info_log) {} - bool success; - std::string info_log; - }; - - virtual ~ProgramImpl() {} - - // Ultimately called by glLinkProgram(), this marks the end of the program's - // setup phase and the beginning of the program's ability to be used. - // This method should return true on success and false on failure, along - // with an information message if desired. - // Upon successful linking, BindAttribLocation() will be called for each - // existing attribute binding, so any exiting bindings should be cleared - // within Link(). - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glLinkProgram.xml - virtual LinkResults Link( - const nb::scoped_refptr& vertex_shader, - const nb::scoped_refptr& fragment_shader) = 0; - - // Binds the attribute with the specified |name| to the specified index. - // Implementations can take this opportunity to resolve |name| to a - // platform-specific attribute identifier so that a by-name lookup does not - // need to occur when a draw command is issued. This function will only - // be called after Link() is called. If a re-link is performed, this command - // is re-issued by Program for all existing bindings. - // Returns true on success and false if the attribute name could not be found. - // This method will be called when glBindAttribLocation() is called. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glBindAttribLocation.xml - virtual bool BindAttribLocation(unsigned int index, const char* name) = 0; - - // Returns the location of the specified uniform within the shader. Texture - // samplers are included in this definition of "uniform". This will later - // be used to reference the uniform, and will be eventually set in the - // DrawState that is passed into draw calls. This method should return - // -1 if there is no uniform by the given |name|. - // This method will be called when glGetUniformLocation() is called. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetUniformLocation.xml - virtual int GetUniformLocation(const char* name) = 0; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_PROGRAM_IMPL_H_ diff --git a/glimp/gles/ref_counted_resource_map.h b/glimp/gles/ref_counted_resource_map.h deleted file mode 100644 index f08be9d5f6fd..000000000000 --- a/glimp/gles/ref_counted_resource_map.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_REF_COUNTED_RESOURCE_MAP_H_ -#define GLIMP_GLES_REF_COUNTED_RESOURCE_MAP_H_ - -#include -#include - -#include "glimp/gles/unique_id_generator.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -// This class manages a mapping between an integer Id value and a reference -// counted object. It allocates Ids to resources upon registration, maintains -// a reference to the objects while registered, and facilitates retrieving -// objects by Id. -template -class RefCountedResourceMap { - public: - // Registers a resource into the map, and returns the id value that it is - // assigned. - uint32_t RegisterResource(const nb::scoped_refptr& resource) { - uint32_t id = id_generator_.AcquireId(); - resources_.insert(std::make_pair(id, resource)); - return id; - } - - // Returns a reference to the resource specified by id. If the resource - // does not exist in the map, scoped_refptr() is returned. - nb::scoped_refptr GetResource(uint32_t id) { - typename InternalResourceMap::iterator found = resources_.find(id); - return found == resources_.end() ? nb::scoped_refptr() : found->second; - } - - // Removes the resource with the specified id from the map and returns it. - // If the resource is not in the map, scoped_refptr() is returned. - nb::scoped_refptr DeregisterResource(uint32_t id) { - typename InternalResourceMap::iterator found = resources_.find(id); - if (found == resources_.end()) { - return nb::scoped_refptr(); - } - - id_generator_.ReleaseId(found->first); - nb::scoped_refptr resource(found->second); - - resources_.erase(found); - - return resource; - } - - // Returns whether the map contains any entries or not. - bool empty() const { return resources_.empty(); } - - private: - UniqueIdGenerator id_generator_; - typedef std::map > InternalResourceMap; - InternalResourceMap resources_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_REF_COUNTED_RESOURCE_MAP_H_ diff --git a/glimp/gles/renderbuffer.cc b/glimp/gles/renderbuffer.cc deleted file mode 100644 index 603aa64c989c..000000000000 --- a/glimp/gles/renderbuffer.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/renderbuffer.h" - -namespace glimp { -namespace gles { - -Renderbuffer::Renderbuffer() { - format_ = GL_INVALID_ENUM; - width_ = -1; - height_ = -1; -} - -void Renderbuffer::Initialize(GLenum format, GLsizei width, GLsizei height) { - format_ = format; - width_ = width; - height_ = height; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/renderbuffer.h b/glimp/gles/renderbuffer.h deleted file mode 100644 index aed999bc2178..000000000000 --- a/glimp/gles/renderbuffer.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_RENDERBUFFER_H_ -#define GLIMP_GLES_RENDERBUFFER_H_ - -#include - -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -// Renderbuffers are objects used to represent non-texture surfaces, such -// as depth buffers or stencil buffers. They can also be used as color -// render targets but this is not supported by glimp. Renderbuffers must be -// attached to framebuffer objects via glFramebufferRenderbuffer() in order for -// them to be used. -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenRenderbuffers.xml -class Renderbuffer : public nb::RefCountedThreadSafe { - public: - Renderbuffer(); - void Initialize(GLenum format, GLsizei width, GLsizei height); - - GLenum format() const { return format_; } - int width() const { return width_; } - int height() const { return height_; } - - private: - friend class nb::RefCountedThreadSafe; - ~Renderbuffer() {} - - GLenum format_; - int width_; - int height_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_RENDERBUFFER_H_ diff --git a/glimp/gles/resource_manager.cc b/glimp/gles/resource_manager.cc deleted file mode 100644 index 6ab6401d617c..000000000000 --- a/glimp/gles/resource_manager.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/resource_manager.h" - -namespace glimp { -namespace gles { - -ResourceManager::~ResourceManager() { - if (!programs_.empty()) { - SB_DLOG(WARNING) << "Un-deleted gl programs exist upon shutdown."; - } - - if (!shaders_.empty()) { - SB_DLOG(WARNING) << "Un-deleted gl shaders exist upon shutdown."; - } - - if (!buffers_.empty()) { - SB_DLOG(WARNING) << "Un-deleted gl buffers exist upon shutdown."; - } - - if (!textures_.empty()) { - SB_DLOG(WARNING) << "Un-deleted gl textures exist upon shutdown."; - } - - if (!framebuffers_.empty()) { - SB_DLOG(WARNING) << "Un-deleted gl framebuffers exist upon shutdown."; - } - - if (!renderbuffers_.empty()) { - SB_DLOG(WARNING) << "Un-deleted gl renderbuffers exist upon shutdown."; - } -} - -uint32_t ResourceManager::RegisterProgram( - const nb::scoped_refptr& program) { - starboard::ScopedLock lock(mutex_); - return programs_.RegisterResource(program); -} - -nb::scoped_refptr ResourceManager::GetProgram(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return programs_.GetResource(id); -} - -nb::scoped_refptr ResourceManager::DeregisterProgram(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return programs_.DeregisterResource(id); -} - -uint32_t ResourceManager::RegisterShader( - const nb::scoped_refptr& shader) { - starboard::ScopedLock lock(mutex_); - return shaders_.RegisterResource(shader); -} - -nb::scoped_refptr ResourceManager::GetShader(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return shaders_.GetResource(id); -} - -nb::scoped_refptr ResourceManager::DeregisterShader(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return shaders_.DeregisterResource(id); -} - -uint32_t ResourceManager::RegisterBuffer( - const nb::scoped_refptr& buffer) { - starboard::ScopedLock lock(mutex_); - return buffers_.RegisterResource(buffer); -} - -nb::scoped_refptr ResourceManager::GetBuffer(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return buffers_.GetResource(id); -} - -nb::scoped_refptr ResourceManager::DeregisterBuffer(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return buffers_.DeregisterResource(id); -} - -uint32_t ResourceManager::RegisterTexture( - const nb::scoped_refptr& texture) { - starboard::ScopedLock lock(mutex_); - return textures_.RegisterResource(texture); -} - -nb::scoped_refptr ResourceManager::GetTexture(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return textures_.GetResource(id); -} - -nb::scoped_refptr ResourceManager::DeregisterTexture(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return textures_.DeregisterResource(id); -} - -uint32_t ResourceManager::RegisterFramebuffer( - const nb::scoped_refptr& framebuffer) { - starboard::ScopedLock lock(mutex_); - return framebuffers_.RegisterResource(framebuffer); -} - -nb::scoped_refptr ResourceManager::GetFramebuffer(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return framebuffers_.GetResource(id); -} - -nb::scoped_refptr ResourceManager::DeregisterFramebuffer( - uint32_t id) { - starboard::ScopedLock lock(mutex_); - return framebuffers_.DeregisterResource(id); -} - -uint32_t ResourceManager::RegisterRenderbuffer( - const nb::scoped_refptr& renderbuffer) { - starboard::ScopedLock lock(mutex_); - return renderbuffers_.RegisterResource(renderbuffer); -} - -nb::scoped_refptr ResourceManager::GetRenderbuffer(uint32_t id) { - starboard::ScopedLock lock(mutex_); - return renderbuffers_.GetResource(id); -} - -nb::scoped_refptr ResourceManager::DeregisterRenderbuffer( - uint32_t id) { - starboard::ScopedLock lock(mutex_); - return renderbuffers_.DeregisterResource(id); -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/resource_manager.h b/glimp/gles/resource_manager.h deleted file mode 100644 index fa72e4743487..000000000000 --- a/glimp/gles/resource_manager.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_RESOURCE_MANAGER_H_ -#define GLIMP_GLES_RESOURCE_MANAGER_H_ - -#include "glimp/gles/buffer.h" -#include "glimp/gles/framebuffer.h" -#include "glimp/gles/program.h" -#include "glimp/gles/ref_counted_resource_map.h" -#include "glimp/gles/renderbuffer.h" -#include "glimp/gles/shader.h" -#include "glimp/gles/texture.h" -#include "glimp/ref_counted.h" -#include "starboard/common/mutex.h" - -namespace glimp { -namespace gles { - -// The ResourceManager is responsible for managing the set of all GL ES -// resources used by contexts. It manages the assignment of IDs to resources -// like textures, buffers, shaders, programs and so on. When it is specified -// that a context should share resources with another upon construction, it is -// this ResourceManager object that is shared between them, and thus it must -// also be thread-safe. -class ResourceManager : public nb::RefCountedThreadSafe { - public: - ~ResourceManager(); - - uint32_t RegisterProgram(const nb::scoped_refptr& program); - nb::scoped_refptr GetProgram(uint32_t id); - nb::scoped_refptr DeregisterProgram(uint32_t id); - - uint32_t RegisterShader(const nb::scoped_refptr& shader); - nb::scoped_refptr GetShader(uint32_t id); - nb::scoped_refptr DeregisterShader(uint32_t id); - - uint32_t RegisterBuffer(const nb::scoped_refptr& buffer); - nb::scoped_refptr GetBuffer(uint32_t id); - nb::scoped_refptr DeregisterBuffer(uint32_t id); - - uint32_t RegisterTexture(const nb::scoped_refptr& texture); - nb::scoped_refptr GetTexture(uint32_t id); - nb::scoped_refptr DeregisterTexture(uint32_t id); - - uint32_t RegisterFramebuffer( - const nb::scoped_refptr& framebuffer); - nb::scoped_refptr GetFramebuffer(uint32_t id); - nb::scoped_refptr DeregisterFramebuffer(uint32_t id); - - uint32_t RegisterRenderbuffer( - const nb::scoped_refptr& renderbuffer); - nb::scoped_refptr GetRenderbuffer(uint32_t id); - nb::scoped_refptr DeregisterRenderbuffer(uint32_t id); - - private: - starboard::Mutex mutex_; - - RefCountedResourceMap programs_; - RefCountedResourceMap shaders_; - RefCountedResourceMap buffers_; - RefCountedResourceMap textures_; - RefCountedResourceMap framebuffers_; - RefCountedResourceMap renderbuffers_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_RESOURCE_MANAGER_H_ diff --git a/glimp/gles/sampler.h b/glimp/gles/sampler.h deleted file mode 100644 index f0faf7a638e1..000000000000 --- a/glimp/gles/sampler.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_SAMPLER_H_ -#define GLIMP_GLES_SAMPLER_H_ - -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -// Helper function to represent what GL ES texture parameters. -struct Sampler { - enum MinFilter { - kMinFilterNearest, - kMinFilterLinear, - kMinFilterNearestMipMapNearest, - kMinFilterLinearMipMapNearest, - kMinFilterNearestMipMapLinear, - kMinFilterLinearMipMapLinear, - kMinFilterInvalid, - }; - enum MagFilter { - kMagFilterNearest, - kMagFilterLinear, - kMagFilterInvalid, - }; - enum WrapMode { - kWrapModeRepeat, - kWrapModeClampToEdge, - kWrapModeMirroredRepeat, - kWrapModeInvalid, - }; - - // Initialize the sampler with default values defined by the GL ES - // specification: - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml - Sampler() - : mag_filter(kMagFilterLinear), - min_filter(kMinFilterNearestMipMapLinear), - wrap_s(kWrapModeRepeat), - wrap_t(kWrapModeRepeat) {} - - // Parameters that are modifiable via glTexParameter() functions. - MagFilter mag_filter; - MinFilter min_filter; - WrapMode wrap_s; - WrapMode wrap_t; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_SAMPLER_H_ diff --git a/glimp/gles/shader.cc b/glimp/gles/shader.cc deleted file mode 100644 index 34d70ca0acc0..000000000000 --- a/glimp/gles/shader.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/shader.h" - -#include - -#include "starboard/common/string.h" - -namespace glimp { -namespace gles { - -Shader::Shader(std::unique_ptr impl, GLenum type) - : impl_(std::move(impl)), type_(type), compile_results_(false) {} - -void Shader::ShaderSource(GLsizei count, - const GLchar* const* string, - const GLint* length) { - source_.clear(); - - // Concatenate the input strings into one long string. - for (size_t i = 0; i < count; ++i) { - if (!length) { - // If length is NULL, all strings are assumed to be null-terminated. - source_.append(string[i]); - } else { - source_.append(string[i], length[i]); - } - } -} - -void Shader::CompileShader() { - compile_results_ = impl_->Compile(source_); -} - -GLenum Shader::GetShaderiv(GLenum pname, GLint* params) { - switch (pname) { - case GL_COMPILE_STATUS: - *params = compile_results_.success ? 1 : 0; - break; - case GL_SHADER_SOURCE_LENGTH: - *params = source_.size(); - break; - case GL_SHADER_TYPE: - *params = type_; - break; - case GL_INFO_LOG_LENGTH: - *params = compile_results_.info_log.size(); - break; - case GL_DELETE_STATUS: - SB_NOTIMPLEMENTED(); - break; - default: - return GL_INVALID_ENUM; - } - - return GL_NO_ERROR; -} - -void Shader::GetShaderInfoLog(GLsizei bufsize, - GLsizei* length, - GLchar* infolog) { - *length = - starboard::strlcpy(infolog, compile_results_.info_log.c_str(), bufsize); -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/shader.h b/glimp/gles/shader.h deleted file mode 100644 index 150c65324abb..000000000000 --- a/glimp/gles/shader.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_SHADER_H_ -#define GLIMP_GLES_SHADER_H_ - -#include - -#include - -#include -#include "glimp/gles/shader_impl.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class Shader : public nb::RefCountedThreadSafe { - public: - Shader(std::unique_ptr impl, GLenum type); - - GLenum type() const { return type_; } - - // Called when glShaderSource() is called. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glShaderSource.xml - void ShaderSource(GLsizei count, - const GLchar* const* string, - const GLint* length); - - // Called when glCompileShader() is called. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCompileShader.xml - void CompileShader(); - - // Called when glGetShaderiv() is called. Returns GL_NO_ERROR if the query - // was successful, otherwise returns the error GLenum that should be returned - // to the caller. - GLenum GetShaderiv(GLenum pname, GLint* params); - void GetShaderInfoLog(GLsizei bufsize, GLsizei* length, GLchar* infolog); - - bool compiled() const { return compile_results_.success; } - - ShaderImpl* impl() const { return impl_.get(); } - - private: - friend class nb::RefCountedThreadSafe; - ~Shader() {} - - std::unique_ptr impl_; - - GLenum type_; - - std::string source_; - - // Keeps track of the success of the last CompileShader() call. Can be - // queried via glGetShaderiv() with the parameter GL_COMPILE_STATUS or - // GL_INFO_LOG_LENGTH. - ShaderImpl::CompileResults compile_results_; - - GLint compile_status_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_SHADER_H_ diff --git a/glimp/gles/shader_impl.h b/glimp/gles/shader_impl.h deleted file mode 100644 index 250a6f00d179..000000000000 --- a/glimp/gles/shader_impl.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_SHADER_IMPL_H_ -#define GLIMP_GLES_SHADER_IMPL_H_ - -#include - -namespace glimp { -namespace gles { - -class ShaderImpl { - public: - // Return value from the Compile() method. Can be used to communicate an - // error message to the client. - struct CompileResults { - explicit CompileResults(bool success) : success(success) {} - CompileResults(bool success, const std::string& info_log) - : success(success), info_log(info_log) {} - bool success; - std::string info_log; - }; - - virtual ~ShaderImpl() {} - - // Called when glCompileShader() is called. The source passed in is whatever - // source was last set by glShaderSource(). This method should return true - // on success and false on failure, along with an information message if - // desired. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCompileShader.xml - virtual CompileResults Compile(const std::string& source) = 0; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_SHADER_IMPL_H_ diff --git a/glimp/gles/texture.cc b/glimp/gles/texture.cc deleted file mode 100644 index 7071a082095c..000000000000 --- a/glimp/gles/texture.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/texture.h" - -#include - -#include "glimp/rect.h" -#include "starboard/common/pointer_arithmetic.h" - -namespace glimp { -namespace gles { - -Texture::Texture(std::unique_ptr impl) - : impl_(std::move(impl)), - texture_allocated_(false), - bound_to_surface_(NULL) {} - -void Texture::Initialize(GLint level, - PixelFormat pixel_format, - GLsizei width, - GLsizei height) { - width_ = static_cast(width); - height_ = static_cast(height); - pixel_format_ = pixel_format; - - impl_->Initialize(level, pixel_format_, width_, height_); - - texture_allocated_ = true; -} - -bool Texture::UpdateData(GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - int pitch_in_bytes, - const GLvoid* pixels) { - SB_DCHECK(pixels != NULL); - return impl_->UpdateData(level, - nb::Rect(xoffset, yoffset, width, height), - pitch_in_bytes, pixels); -} - -void Texture::UpdateDataFromBuffer( - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - int pitch_in_bytes, - const nb::scoped_refptr& pixel_unpack_buffer, - uintptr_t buffer_offset) { - SB_DCHECK(pixel_unpack_buffer); - impl_->UpdateDataFromBuffer( - level, nb::Rect(xoffset, yoffset, width, height), pitch_in_bytes, - pixel_unpack_buffer, buffer_offset); -} - -bool Texture::BindToEGLSurface(egl::Surface* surface) { - if (bound_to_surface_ != NULL) { - SB_DLOG(WARNING) << "A EGLSurface is already bound to this texture."; - return false; - } - - width_ = surface->GetWidth(); - height_ = surface->GetHeight(); - - SB_DCHECK(surface->GetTextureFormat() == EGL_TEXTURE_RGBA); - pixel_format_ = kPixelFormatRGBA8; - texture_allocated_ = true; - - impl_->BindToEGLSurface(surface); - bound_to_surface_ = surface; - - return true; -} - -bool Texture::ReleaseFromEGLSurface(egl::Surface* surface) { - if (bound_to_surface_ != surface) { - SB_DLOG(WARNING) << "Attempting to release a surface that this texture was " - "not bound to."; - return false; - } - - width_ = 0; - height_ = 0; - pixel_format_ = kPixelFormatInvalid; - texture_allocated_ = false; - bound_to_surface_ = NULL; - - impl_->Initialize(0, kPixelFormatInvalid, 0, 0); - - return true; -} - -void Texture::ReadPixelsAsRGBA8(GLint x, - GLint y, - GLsizei width, - GLsizei height, - int pitch_in_bytes, - GLvoid* pixels) { - impl_->ReadPixelsAsRGBA8(nb::Rect(x, y, width, height), pitch_in_bytes, - pixels); -} - -bool Texture::CanBeAttachedToFramebuffer() const { - return impl_->CanBeAttachedToFramebuffer(); -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/texture.h b/glimp/gles/texture.h deleted file mode 100644 index e2a203403173..000000000000 --- a/glimp/gles/texture.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_TEXTURE_H_ -#define GLIMP_GLES_TEXTURE_H_ - -#include - -#include -#include "glimp/egl/surface.h" -#include "glimp/gles/buffer.h" -#include "glimp/gles/pixel_format.h" -#include "glimp/gles/sampler.h" -#include "glimp/gles/texture_impl.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class Texture : public nb::RefCountedThreadSafe { - public: - explicit Texture(std::unique_ptr impl); - - void Initialize(GLint level, - PixelFormat pixel_format, - GLsizei width, - GLsizei height); - - // Implements support for glTexSubImage2D() and glCopyTexSubImage2D(). - // This function will return true if successful, false if memory allocation - // failed. - bool UpdateData(GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - int pitch_in_bytes, - const GLvoid* pixels); - - // Implements support for glTexSubImage2D() when data is supplied by a - // GL_PIXEL_UNPACK_BUFFER. - void UpdateDataFromBuffer( - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - int pitch_in_bytes, - const nb::scoped_refptr& pixel_unpack_buffer, - uintptr_t buffer_offset); - - // These methods will be called when eglBindTexImage() and - // eglReleaseTexImage() are called. - bool BindToEGLSurface(egl::Surface* surface); - bool ReleaseFromEGLSurface(egl::Surface* surface); - - // Write a copy of the texture data into a window within the pointer specified - // by |pixels|. - void ReadPixelsAsRGBA8(GLint x, - GLint y, - GLsizei width, - GLsizei height, - int pitch_in_bytes, - GLvoid* pixels); - - // Returns true if this texture can be used as a framebuffer component. - // Essentially, this function is asking whether we can render to the texture - // or not. - bool CanBeAttachedToFramebuffer() const; - - TextureImpl* impl() const { return impl_.get(); } - - // Returns whether the data has been set yet or not. - bool texture_allocated() const { return texture_allocated_; } - - int width() const { - SB_DCHECK(texture_allocated_); - return width_; - } - - int height() const { - SB_DCHECK(texture_allocated_); - return height_; - } - - PixelFormat pixel_format() const { - SB_DCHECK(texture_allocated_); - return pixel_format_; - } - - Sampler* sampler_parameters() { return &sampler_parameters_; } - const Sampler* sampler_parameters() const { return &sampler_parameters_; } - - private: - friend class nb::RefCountedThreadSafe; - ~Texture() {} - - std::unique_ptr impl_; - - // True if underlying texture data has been allocated yet or not (e.g. - // will be true after glTexImage2D() is called.) - bool texture_allocated_; - - // The width and height of the texture, in pixels. - int width_; - int height_; - - // The pixel format of the set data. - PixelFormat pixel_format_; - - // Non-null if we are currently bound to an egl::Surface (e.g. from a - // call to eglBindTexImage()). - egl::Surface* bound_to_surface_; - - // Sampler parameters that are associated with this texture. - Sampler sampler_parameters_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_TEXTURE_H_ diff --git a/glimp/gles/texture_impl.h b/glimp/gles/texture_impl.h deleted file mode 100644 index cdf654e7fbdc..000000000000 --- a/glimp/gles/texture_impl.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_TEXTURE_IMPL_H_ -#define GLIMP_GLES_TEXTURE_IMPL_H_ - -#include "glimp/egl/surface.h" -#include "glimp/gles/buffer.h" -#include "glimp/gles/pixel_format.h" -#include "glimp/gles/shader.h" -#include "glimp/rect.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class TextureImpl { - public: - virtual ~TextureImpl() {} - - // Specifies texture parameters necessary to allocate texture data within - // this texture. This method must be called before pixel data can be - // provided to the texture via UpdateData*() methods. If |width| == 0, - // the texture should be placed in an uninitialized state where UpdateData*() - // methods are invalid. - // This method is called when glTexImage2D() is called. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml - virtual void Initialize(int level, - PixelFormat pixel_format, - int width, - int height) = 0; - - // Called when glTexImage2D() is called with non-null pixels, or when - // glTexSubImage2D() or glCopyTexSubImage2D() is called. Updates an already - // allocated texture with new texture data provided by the client. The - // parameters of this method define a window within the existing texture - // data of which should be updated with the provided (non-NULL) |pixels|. - // The provided |pitch_in_bytes| refers to the input data pixel rows. - // This function will return true if successful, false if memory allocation - // failed. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexSubImage2D.xml - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexSubImage2D.xml - virtual bool UpdateData(int level, - const nb::Rect& window, - int pitch_in_bytes, - const void* pixels) = 0; - - // Similar to UpdateData() above, however the source of pixels in this case - // is a buffer object, and an offset into it. This method will be called - // when glTexImage2D() or glTexSubImage2D() is called while a buffer is bound - // to the GL_PIXEL_UNPACK_BUFFER target. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexSubImage2D.xml - virtual void UpdateDataFromBuffer( - int level, - const nb::Rect& window, - int pitch_in_bytes, - const nb::scoped_refptr& pixel_unpack_buffer, - uintptr_t buffer_offset) = 0; - - // Called when eglBindTexImage() is called. When this occurs, the texture - // should configure itself to point at the same data as the passed in - // egl::Surface is pointing to, so that the egl::Surface can effectively be - // referenced as a texture. This method should clear out any existing image - // data in the texture when it is called. When eglReleaseTexImage() is - // called, TextureImpl::Initialize() will be called with |width| = 0 to reset - // this texture. - // https://www.khronos.org/registry/egl/sdk/docs/man/html/eglBindTexImage.xhtml - virtual void BindToEGLSurface(egl::Surface* surface) = 0; - - // This is called when glReadPixels() is called. The - virtual void ReadPixelsAsRGBA8(const nb::Rect& window, - int pitch_in_bytes, - void* pixels) = 0; - - // Returns true if this texture is valid for use as a Framebuffer color - // attachment. In other words, this should return true if the texture can - // be used as a render target. This method is called when the function - // glCheckFramebufferStatus() is called on a framebuffer that has this - // texture attached to it. - // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCheckFramebufferStatus.xml - virtual bool CanBeAttachedToFramebuffer() const = 0; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_TEXTURE_IMPL_H_ diff --git a/glimp/gles/uniform_info.h b/glimp/gles/uniform_info.h deleted file mode 100644 index 44f9bca1fa80..000000000000 --- a/glimp/gles/uniform_info.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_UNIFORM_INFO_H_ -#define GLIMP_GLES_UNIFORM_INFO_H_ - -namespace glimp { -namespace gles { - -// Maintains information about a shader program uniform. In particular, it -// tracks the type, count and element size of a uniform. For example, -// an array of 8 vec2s would be described by -// UniformInfo(UniformInfo::kTypeFloat, 8, 2) -struct UniformInfo { - enum Type { - kTypeFloat, - kTypeInteger, - kTypeMatrix, - kTypeUnknown, - }; - - UniformInfo() : type(kTypeUnknown), count(-1), element_size(-1) {} - UniformInfo(Type type, int count, int element_size) - : type(type), count(count), element_size(element_size) {} - bool operator==(const UniformInfo& rhs) const { - return type == rhs.type && count == rhs.count && - element_size == rhs.element_size; - } - bool operator!=(const UniformInfo& rhs) const { return !operator==(rhs); } - - // Data type of this uniform. - Type type; - // Number of uniforms in an array. - int count; - // The "vector size" of the uniform. - int element_size; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_UNIFORM_INFO_H_ diff --git a/glimp/gles/unique_id_generator.cc b/glimp/gles/unique_id_generator.cc deleted file mode 100644 index 7e6589f230eb..000000000000 --- a/glimp/gles/unique_id_generator.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/gles/unique_id_generator.h" - -#include - -#include "starboard/common/log.h" - -namespace glimp { -namespace gles { - -UniqueIdGenerator::UniqueIdGenerator() : largest_id_(0) {} - -uint32_t UniqueIdGenerator::AcquireId() { - if (reusable_ids_.empty()) { - ++largest_id_; - SB_DCHECK(largest_id_ != 0) - << "An Id overflow occurred, too many Ids allocated."; - return largest_id_; - } else { - uint32_t id = reusable_ids_.back(); - reusable_ids_.pop_back(); - return id; - } -} - -void UniqueIdGenerator::ReleaseId(uint32_t id) { - SB_DCHECK(id <= largest_id_); - SB_DCHECK(std::find(reusable_ids_.begin(), reusable_ids_.end(), id) == - reusable_ids_.end()); - reusable_ids_.push_back(id); -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/gles/unique_id_generator.h b/glimp/gles/unique_id_generator.h deleted file mode 100644 index c6527b5c1e88..000000000000 --- a/glimp/gles/unique_id_generator.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_UNIQUE_ID_GENERATOR_H_ -#define GLIMP_GLES_UNIQUE_ID_GENERATOR_H_ - -#include - -#include - -namespace glimp { -namespace gles { - -// A helper class to make it easy to obtain a unique Id (that we can assign -// to GL resources). In order to aid with debugging, it will never return -// 0 as a valid Id. -class UniqueIdGenerator { - public: - UniqueIdGenerator(); - uint32_t AcquireId(); - void ReleaseId(uint32_t id); - - private: - std::vector reusable_ids_; - uint32_t largest_id_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_UNIQUE_ID_GENERATOR_H_ diff --git a/glimp/gles/vertex_attribute.h b/glimp/gles/vertex_attribute.h deleted file mode 100644 index 7a9d82a512d0..000000000000 --- a/glimp/gles/vertex_attribute.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_GLES_VERTEX_ATTRIBUTE_H_ -#define GLIMP_GLES_VERTEX_ATTRIBUTE_H_ - -namespace glimp { -namespace gles { - -// An enum for the type of data stored for a specific vertex attribute. -enum VertexAttributeType { - kVertexAttributeTypeByte, - kVertexAttributeTypeUnsignedByte, - kVertexAttributeTypeShort, - kVertexAttributeTypeUnsignedShort, - kVertexAttributeTypeHalfFloat, - kVertexAttributeTypeFloat, - kVertexAttributeTypeFixed, - kVertexAttributeTypeInvalid, -}; - -// Stores all information that can be set about a vertex attribute through -// a call to VertexAttribPointer(). -// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttribPointer.xml -struct VertexAttributeArray { - // Initialize with default values defined by the specification for - // glVertexAttribPointer(). - VertexAttributeArray() - : size(4), - type(kVertexAttributeTypeFloat), - normalized(false), - stride_in_bytes(0), - offset(0) {} - - VertexAttributeArray(int size, - VertexAttributeType type, - bool normalized, - int stride_in_bytes, - int offset) - : size(size), - type(type), - normalized(normalized), - stride_in_bytes(stride_in_bytes), - offset(offset) {} - - // Number of components per vertex - int size; - - // The data type of each component. - VertexAttributeType type; - - // Whether each component should be normalized from their type's min/max range - // to the range [-1, 1] for signed values and [0, 1] for unsigned values. - bool normalized; - - // Number of bytes between subsequent vertices. - int stride_in_bytes; - - // Derived from the void* ptr parameter of glVertexAttribPointer(), but stored - // as an integer as only offsets into array buffers are supported in glimp. - int offset; -}; - -// Constant vertex attributes are specified through the glVertexAttribXfv() -// functions. When set for a specific attribute location, all vertices will -// be passed this constant attribute value. Constant vertex attributes are -// enabled whenever vertex attribute arrays are disabled. -struct VertexAttributeConstant { - VertexAttributeConstant() : type(kVertexAttributeTypeInvalid), size(0) {} - - VertexAttributeType type; - int size; - - // We currently only support floating point constant vertex attributes, - // but if needed this can be modified to be an arbitrary data store, and - // methods added to convert to the specified type. - float data[4]; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_GLES_VERTEX_ATTRIBUTE_H_ diff --git a/glimp/include/EGL/egl.h b/glimp/include/EGL/egl.h deleted file mode 100644 index 50f29397232b..000000000000 --- a/glimp/include/EGL/egl.h +++ /dev/null @@ -1,379 +0,0 @@ -#ifndef __egl_h_ -#define __egl_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun -*2015) $ -*/ - -#include - -/* Generated on date 20150623 */ - -/* Generated C header for: - * API: egl - * Versions considered: .* - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef EGL_VERSION_1_0 -#define EGL_VERSION_1_0 1 -typedef unsigned int EGLBoolean; -typedef void* EGLDisplay; -#include -#include -typedef void* EGLConfig; -typedef void* EGLSurface; -typedef void* EGLContext; -typedef void (*__eglMustCastToProperFunctionPointerType)(void); -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300A -#define EGL_BAD_NATIVE_WINDOW 0x300B -#define EGL_BAD_PARAMETER 0x300C -#define EGL_BAD_SURFACE 0x300D -#define EGL_BLUE_SIZE 0x3022 -#define EGL_BUFFER_SIZE 0x3020 -#define EGL_CONFIG_CAVEAT 0x3027 -#define EGL_CONFIG_ID 0x3028 -#define EGL_CORE_NATIVE_ENGINE 0x305B -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_DONT_CARE ((EGLint)-1) -#define EGL_DRAW 0x3059 -#define EGL_EXTENSIONS 0x3055 -#define EGL_FALSE 0 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_HEIGHT 0x3056 -#define EGL_LARGEST_PBUFFER 0x3058 -#define EGL_LEVEL 0x3029 -#define EGL_MAX_PBUFFER_HEIGHT 0x302A -#define EGL_MAX_PBUFFER_PIXELS 0x302B -#define EGL_MAX_PBUFFER_WIDTH 0x302C -#define EGL_NATIVE_RENDERABLE 0x302D -#define EGL_NATIVE_VISUAL_ID 0x302E -#define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_NONE 0x3038 -#define EGL_NON_CONFORMANT_CONFIG 0x3051 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_NO_CONTEXT ((EGLContext)0) -#define EGL_NO_DISPLAY ((EGLDisplay)0) -#define EGL_NO_SURFACE ((EGLSurface)0) -#define EGL_PBUFFER_BIT 0x0001 -#define EGL_PIXMAP_BIT 0x0002 -#define EGL_READ 0x305A -#define EGL_RED_SIZE 0x3024 -#define EGL_SAMPLES 0x3031 -#define EGL_SAMPLE_BUFFERS 0x3032 -#define EGL_SLOW_CONFIG 0x3050 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_SUCCESS 0x3000 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define EGL_TRANSPARENT_RED_VALUE 0x3037 -#define EGL_TRANSPARENT_RGB 0x3052 -#define EGL_TRANSPARENT_TYPE 0x3034 -#define EGL_TRUE 1 -#define EGL_VENDOR 0x3053 -#define EGL_VERSION 0x3054 -#define EGL_WIDTH 0x3057 -#define EGL_WINDOW_BIT 0x0004 -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, - const EGLint* attrib_list, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, - EGLSurface surface, - EGLNativePixmapType target); -EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, - EGLConfig config, - EGLContext share_context, - const EGLint* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePbufferSurface(EGLDisplay dpy, - EGLConfig config, - const EGLint* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, - EGLConfig config, - EGLNativeWindowType win, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, - EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, - EGLConfig config, - EGLint attribute, - EGLint* value); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, - EGLConfig* configs, - EGLint config_size, - EGLint* num_config); -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); -EGLAPI EGLint EGLAPIENTRY eglGetError(void); -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY -eglGetProcAddress(const char* procname); -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, - EGLint* major, - EGLint* minor); -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, - EGLSurface draw, - EGLSurface read, - EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, - EGLContext ctx, - EGLint attribute, - EGLint* value); -EGLAPI const char* EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint* value); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, - EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine); -#endif /* EGL_VERSION_1_0 */ - -#ifndef EGL_VERSION_1_1 -#define EGL_VERSION_1_1 1 -#define EGL_BACK_BUFFER 0x3084 -#define EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define EGL_CONTEXT_LOST 0x300E -#define EGL_MIN_SWAP_INTERVAL 0x303B -#define EGL_MAX_SWAP_INTERVAL 0x303C -#define EGL_MIPMAP_TEXTURE 0x3082 -#define EGL_MIPMAP_LEVEL 0x3083 -#define EGL_NO_TEXTURE 0x305C -#define EGL_TEXTURE_2D 0x305F -#define EGL_TEXTURE_FORMAT 0x3080 -#define EGL_TEXTURE_RGB 0x305D -#define EGL_TEXTURE_RGBA 0x305E -#define EGL_TEXTURE_TARGET 0x3081 -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, - EGLSurface surface, - EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); -#endif /* EGL_VERSION_1_1 */ - -#ifndef EGL_VERSION_1_2 -#define EGL_VERSION_1_2 1 -typedef unsigned int EGLenum; -typedef void* EGLClientBuffer; -#define EGL_ALPHA_FORMAT 0x3088 -#define EGL_ALPHA_FORMAT_NONPRE 0x308B -#define EGL_ALPHA_FORMAT_PRE 0x308C -#define EGL_ALPHA_MASK_SIZE 0x303E -#define EGL_BUFFER_PRESERVED 0x3094 -#define EGL_BUFFER_DESTROYED 0x3095 -#define EGL_CLIENT_APIS 0x308D -#define EGL_COLORSPACE 0x3087 -#define EGL_COLORSPACE_sRGB 0x3089 -#define EGL_COLORSPACE_LINEAR 0x308A -#define EGL_COLOR_BUFFER_TYPE 0x303F -#define EGL_CONTEXT_CLIENT_TYPE 0x3097 -#define EGL_DISPLAY_SCALING 10000 -#define EGL_HORIZONTAL_RESOLUTION 0x3090 -#define EGL_LUMINANCE_BUFFER 0x308F -#define EGL_LUMINANCE_SIZE 0x303D -#define EGL_OPENGL_ES_BIT 0x0001 -#define EGL_OPENVG_BIT 0x0002 -#define EGL_OPENGL_ES_API 0x30A0 -#define EGL_OPENVG_API 0x30A1 -#define EGL_OPENVG_IMAGE 0x3096 -#define EGL_PIXEL_ASPECT_RATIO 0x3092 -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_RGB_BUFFER 0x308E -#define EGL_SINGLE_BUFFER 0x3085 -#define EGL_SWAP_BEHAVIOR 0x3093 -#define EGL_UNKNOWN ((EGLint)-1) -#define EGL_VERTICAL_RESOLUTION 0x3091 -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api); -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void); -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePbufferFromClientBuffer(EGLDisplay dpy, - EGLenum buftype, - EGLClientBuffer buffer, - EGLConfig config, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void); -#endif /* EGL_VERSION_1_2 */ - -#ifndef EGL_VERSION_1_3 -#define EGL_VERSION_1_3 1 -#define EGL_CONFORMANT 0x3042 -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 -#define EGL_MATCH_NATIVE_PIXMAP 0x3041 -#define EGL_OPENGL_ES2_BIT 0x0004 -#define EGL_VG_ALPHA_FORMAT 0x3088 -#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B -#define EGL_VG_ALPHA_FORMAT_PRE 0x308C -#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 -#define EGL_VG_COLORSPACE 0x3087 -#define EGL_VG_COLORSPACE_sRGB 0x3089 -#define EGL_VG_COLORSPACE_LINEAR 0x308A -#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 -#endif /* EGL_VERSION_1_3 */ - -#ifndef EGL_VERSION_1_4 -#define EGL_VERSION_1_4 1 -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) -#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 -#define EGL_MULTISAMPLE_RESOLVE 0x3099 -#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A -#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B -#define EGL_OPENGL_API 0x30A2 -#define EGL_OPENGL_BIT 0x0008 -#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); -#endif /* EGL_VERSION_1_4 */ - -#ifndef EGL_VERSION_1_5 -#define EGL_VERSION_1_5 1 -typedef void* EGLSync; -typedef intptr_t EGLAttrib; -typedef khronos_utime_nanoseconds_t EGLTime; -typedef void* EGLImage; -#define EGL_CONTEXT_MAJOR_VERSION 0x3098 -#define EGL_CONTEXT_MINOR_VERSION 0x30FB -#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD -#define EGL_NO_RESET_NOTIFICATION 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 -#define EGL_OPENGL_ES3_BIT 0x00000040 -#define EGL_CL_EVENT_HANDLE 0x309C -#define EGL_SYNC_CL_EVENT 0x30FE -#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 -#define EGL_SYNC_TYPE 0x30F7 -#define EGL_SYNC_STATUS 0x30F1 -#define EGL_SYNC_CONDITION 0x30F8 -#define EGL_SIGNALED 0x30F2 -#define EGL_UNSIGNALED 0x30F3 -#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 -#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull -#define EGL_TIMEOUT_EXPIRED 0x30F5 -#define EGL_CONDITION_SATISFIED 0x30F6 -#define EGL_NO_SYNC ((EGLSync)0) -#define EGL_SYNC_FENCE 0x30F9 -#define EGL_GL_COLORSPACE 0x309D -#define EGL_GL_COLORSPACE_SRGB 0x3089 -#define EGL_GL_COLORSPACE_LINEAR 0x308A -#define EGL_GL_RENDERBUFFER 0x30B9 -#define EGL_GL_TEXTURE_2D 0x30B1 -#define EGL_GL_TEXTURE_LEVEL 0x30BC -#define EGL_GL_TEXTURE_3D 0x30B2 -#define EGL_GL_TEXTURE_ZOFFSET 0x30BD -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 -#define EGL_IMAGE_PRESERVED 0x30D2 -#define EGL_NO_IMAGE ((EGLImage)0) -EGLAPI EGLSync EGLAPIENTRY eglCreateSync(EGLDisplay dpy, - EGLenum type, - const EGLAttrib* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync(EGLDisplay dpy, EGLSync sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSync(EGLDisplay dpy, - EGLSync sync, - EGLint flags, - EGLTime timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib(EGLDisplay dpy, - EGLSync sync, - EGLint attribute, - EGLAttrib* value); -EGLAPI EGLImage EGLAPIENTRY eglCreateImage(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLAttrib* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage(EGLDisplay dpy, EGLImage image); -EGLAPI EGLDisplay EGLAPIENTRY -eglGetPlatformDisplay(EGLenum platform, - void* native_display, - const EGLAttrib* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePlatformWindowSurface(EGLDisplay dpy, - EGLConfig config, - void* native_window, - const EGLAttrib* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePlatformPixmapSurface(EGLDisplay dpy, - EGLConfig config, - void* native_pixmap, - const EGLAttrib* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync(EGLDisplay dpy, - EGLSync sync, - EGLint flags); -#endif /* EGL_VERSION_1_5 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/EGL/eglext.h b/glimp/include/EGL/eglext.h deleted file mode 100644 index 80f4d452ac7a..000000000000 --- a/glimp/include/EGL/eglext.h +++ /dev/null @@ -1,1306 +0,0 @@ -#ifndef __eglext_h_ -#define __eglext_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun -*2015) $ -*/ - -#include - -#define EGL_EGLEXT_VERSION 20150623 - -/* Generated C header for: - * API: egl - * Versions considered: .* - * Versions emitted: _nomatch_^ - * Default extensions included: egl - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef EGL_KHR_cl_event -#define EGL_KHR_cl_event 1 -#define EGL_CL_EVENT_HANDLE_KHR 0x309C -#define EGL_SYNC_CL_EVENT_KHR 0x30FE -#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF -#endif /* EGL_KHR_cl_event */ - -#ifndef EGL_KHR_cl_event2 -#define EGL_KHR_cl_event2 1 -typedef void* EGLSyncKHR; -typedef intptr_t EGLAttribKHR; -typedef EGLSyncKHR(EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC)( - EGLDisplay dpy, - EGLenum type, - const EGLAttribKHR* attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY -eglCreateSync64KHR(EGLDisplay dpy, - EGLenum type, - const EGLAttribKHR* attrib_list); -#endif -#endif /* EGL_KHR_cl_event2 */ - -#ifndef EGL_KHR_client_get_all_proc_addresses -#define EGL_KHR_client_get_all_proc_addresses 1 -#endif /* EGL_KHR_client_get_all_proc_addresses */ - -#ifndef EGL_KHR_config_attribs -#define EGL_KHR_config_attribs 1 -#define EGL_CONFORMANT_KHR 0x3042 -#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 -#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 -#endif /* EGL_KHR_config_attribs */ - -#ifndef EGL_KHR_create_context -#define EGL_KHR_create_context 1 -#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 -#endif /* EGL_KHR_create_context */ - -#ifndef EGL_KHR_create_context_no_error -#define EGL_KHR_create_context_no_error 1 -#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 -#endif /* EGL_KHR_create_context_no_error */ - -#ifndef EGL_KHR_fence_sync -#define EGL_KHR_fence_sync 1 -typedef khronos_utime_nanoseconds_t EGLTimeKHR; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 -#define EGL_SYNC_CONDITION_KHR 0x30F8 -#define EGL_SYNC_FENCE_KHR 0x30F9 -typedef EGLSyncKHR(EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC)( - EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC)(EGLDisplay dpy, - EGLSyncKHR sync); -typedef EGLint(EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, - EGLenum type, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, - EGLSyncKHR sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags, - EGLTimeKHR timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint attribute, - EGLint* value); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_fence_sync */ - -#ifndef EGL_KHR_get_all_proc_addresses -#define EGL_KHR_get_all_proc_addresses 1 -#endif /* EGL_KHR_get_all_proc_addresses */ - -#ifndef EGL_KHR_gl_colorspace -#define EGL_KHR_gl_colorspace 1 -#define EGL_GL_COLORSPACE_KHR 0x309D -#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 -#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A -#endif /* EGL_KHR_gl_colorspace */ - -#ifndef EGL_KHR_gl_renderbuffer_image -#define EGL_KHR_gl_renderbuffer_image 1 -#define EGL_GL_RENDERBUFFER_KHR 0x30B9 -#endif /* EGL_KHR_gl_renderbuffer_image */ - -#ifndef EGL_KHR_gl_texture_2D_image -#define EGL_KHR_gl_texture_2D_image 1 -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 -#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC -#endif /* EGL_KHR_gl_texture_2D_image */ - -#ifndef EGL_KHR_gl_texture_3D_image -#define EGL_KHR_gl_texture_3D_image 1 -#define EGL_GL_TEXTURE_3D_KHR 0x30B2 -#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD -#endif /* EGL_KHR_gl_texture_3D_image */ - -#ifndef EGL_KHR_gl_texture_cubemap_image -#define EGL_KHR_gl_texture_cubemap_image 1 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 -#endif /* EGL_KHR_gl_texture_cubemap_image */ - -#ifndef EGL_KHR_image -#define EGL_KHR_image 1 -typedef void* EGLImageKHR; -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 -#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) -typedef EGLImageKHR(EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC)( - EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC)(EGLDisplay dpy, - EGLImageKHR image); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, - EGLContext ctx, - EGLenum target, - EGLClientBuffer buffer, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, - EGLImageKHR image); -#endif -#endif /* EGL_KHR_image */ - -#ifndef EGL_KHR_image_base -#define EGL_KHR_image_base 1 -#define EGL_IMAGE_PRESERVED_KHR 0x30D2 -#endif /* EGL_KHR_image_base */ - -#ifndef EGL_KHR_image_pixmap -#define EGL_KHR_image_pixmap 1 -#endif /* EGL_KHR_image_pixmap */ - -#ifndef EGL_KHR_lock_surface -#define EGL_KHR_lock_surface 1 -#define EGL_READ_SURFACE_BIT_KHR 0x0001 -#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 -#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 -#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 -#define EGL_MATCH_FORMAT_KHR 0x3043 -#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 -#define EGL_FORMAT_RGB_565_KHR 0x30C1 -#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 -#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 -#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 -#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 -#define EGL_BITMAP_POINTER_KHR 0x30C6 -#define EGL_BITMAP_PITCH_KHR 0x30C7 -#define EGL_BITMAP_ORIGIN_KHR 0x30C8 -#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 -#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA -#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB -#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC -#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD -#define EGL_LOWER_LEFT_KHR 0x30CE -#define EGL_UPPER_LEFT_KHR 0x30CF -typedef EGLBoolean(EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC)( - EGLDisplay dpy, - EGLSurface surface, - const EGLint* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC)(EGLDisplay dpy, - EGLSurface surface); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR(EGLDisplay dpy, - EGLSurface surface, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR(EGLDisplay dpy, - EGLSurface surface); -#endif -#endif /* EGL_KHR_lock_surface */ - -#ifndef EGL_KHR_lock_surface2 -#define EGL_KHR_lock_surface2 1 -#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 -#endif /* EGL_KHR_lock_surface2 */ - -#ifndef EGL_KHR_lock_surface3 -#define EGL_KHR_lock_surface3 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLAttribKHR* value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - EGLAttribKHR* value); -#endif -#endif /* EGL_KHR_lock_surface3 */ - -#ifndef EGL_KHR_partial_update -#define EGL_KHR_partial_update 1 -#define EGL_BUFFER_AGE_KHR 0x313D -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint* rects, - EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR(EGLDisplay dpy, - EGLSurface surface, - EGLint* rects, - EGLint n_rects); -#endif -#endif /* EGL_KHR_partial_update */ - -#ifndef EGL_KHR_platform_android -#define EGL_KHR_platform_android 1 -#define EGL_PLATFORM_ANDROID_KHR 0x3141 -#endif /* EGL_KHR_platform_android */ - -#ifndef EGL_KHR_platform_gbm -#define EGL_KHR_platform_gbm 1 -#define EGL_PLATFORM_GBM_KHR 0x31D7 -#endif /* EGL_KHR_platform_gbm */ - -#ifndef EGL_KHR_platform_wayland -#define EGL_KHR_platform_wayland 1 -#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 -#endif /* EGL_KHR_platform_wayland */ - -#ifndef EGL_KHR_platform_x11 -#define EGL_KHR_platform_x11 1 -#define EGL_PLATFORM_X11_KHR 0x31D5 -#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 -#endif /* EGL_KHR_platform_x11 */ - -#ifndef EGL_KHR_reusable_sync -#define EGL_KHR_reusable_sync 1 -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_STATUS_KHR 0x30F1 -#define EGL_SIGNALED_KHR 0x30F2 -#define EGL_UNSIGNALED_KHR 0x30F3 -#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define EGL_SYNC_TYPE_KHR 0x30F7 -#define EGL_SYNC_REUSABLE_KHR 0x30FA -#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 -#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull -#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLenum mode); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLenum mode); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_reusable_sync */ - -#ifndef EGL_KHR_stream -#define EGL_KHR_stream 1 -typedef void* EGLStreamKHR; -typedef khronos_uint64_t EGLuint64KHR; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) -#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 -#define EGL_PRODUCER_FRAME_KHR 0x3212 -#define EGL_CONSUMER_FRAME_KHR 0x3213 -#define EGL_STREAM_STATE_KHR 0x3214 -#define EGL_STREAM_STATE_CREATED_KHR 0x3215 -#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 -#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 -#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 -#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 -#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A -#define EGL_BAD_STREAM_KHR 0x321B -#define EGL_BAD_STATE_KHR 0x321C -typedef EGLStreamKHR(EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)( - EGLDisplay dpy, - const EGLint* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)( - EGLDisplay dpy, - EGLStreamKHR stream); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLint value); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLint* value); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)( - EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLuint64KHR* value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, - EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLint* value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLuint64KHR* value); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_stream */ - -#ifndef EGL_KHR_stream_consumer_gltexture -#define EGL_KHR_stream_consumer_gltexture 1 -#ifdef EGL_KHR_stream -#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)( - EGLDisplay dpy, - EGLStreamKHR stream); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)( - EGLDisplay dpy, - EGLStreamKHR stream); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)( - EGLDisplay dpy, - EGLStreamKHR stream); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY -eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, - EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, - EGLStreamKHR stream); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_consumer_gltexture */ - -#ifndef EGL_KHR_stream_cross_process_fd -#define EGL_KHR_stream_cross_process_fd 1 -typedef int EGLNativeFileDescriptorKHR; -#ifdef EGL_KHR_stream -#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) -typedef EGLNativeFileDescriptorKHR( - EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, - EGLStreamKHR stream); -typedef EGLStreamKHR(EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)( - EGLDisplay dpy, - EGLNativeFileDescriptorKHR file_descriptor); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY -eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR( - EGLDisplay dpy, - EGLNativeFileDescriptorKHR file_descriptor); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_cross_process_fd */ - -#ifndef EGL_KHR_stream_fifo -#define EGL_KHR_stream_fifo 1 -#ifdef EGL_KHR_stream -#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC -#define EGL_STREAM_TIME_NOW_KHR 0x31FD -#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE -#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)( - EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLTimeKHR* value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum attribute, - EGLTimeKHR* value); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_fifo */ - -#ifndef EGL_KHR_stream_producer_aldatalocator -#define EGL_KHR_stream_producer_aldatalocator 1 -#ifdef EGL_KHR_stream -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_producer_aldatalocator */ - -#ifndef EGL_KHR_stream_producer_eglsurface -#define EGL_KHR_stream_producer_eglsurface 1 -#ifdef EGL_KHR_stream -#define EGL_STREAM_BIT_KHR 0x0800 -typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)( - EGLDisplay dpy, - EGLConfig config, - EGLStreamKHR stream, - const EGLint* attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSurface EGLAPIENTRY -eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, - EGLConfig config, - EGLStreamKHR stream, - const EGLint* attrib_list); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_producer_eglsurface */ - -#ifndef EGL_KHR_surfaceless_context -#define EGL_KHR_surfaceless_context 1 -#endif /* EGL_KHR_surfaceless_context */ - -#ifndef EGL_KHR_swap_buffers_with_damage -#define EGL_KHR_swap_buffers_with_damage 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint* rects, - EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR(EGLDisplay dpy, - EGLSurface surface, - EGLint* rects, - EGLint n_rects); -#endif -#endif /* EGL_KHR_swap_buffers_with_damage */ - -#ifndef EGL_KHR_vg_parent_image -#define EGL_KHR_vg_parent_image 1 -#define EGL_VG_PARENT_IMAGE_KHR 0x30BA -#endif /* EGL_KHR_vg_parent_image */ - -#ifndef EGL_KHR_wait_sync -#define EGL_KHR_wait_sync 1 -typedef EGLint(EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, - EGLSyncKHR sync, - EGLint flags); -#endif -#endif /* EGL_KHR_wait_sync */ - -#ifndef EGL_ANDROID_blob_cache -#define EGL_ANDROID_blob_cache 1 -typedef khronos_ssize_t EGLsizeiANDROID; -typedef void (*EGLSetBlobFuncANDROID)(const void* key, - EGLsizeiANDROID keySize, - const void* value, - EGLsizeiANDROID valueSize); -typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID)(const void* key, - EGLsizeiANDROID keySize, - void* value, - EGLsizeiANDROID valueSize); -typedef void(EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)( - EGLDisplay dpy, - EGLSetBlobFuncANDROID set, - EGLGetBlobFuncANDROID get); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, - EGLSetBlobFuncANDROID set, - EGLGetBlobFuncANDROID get); -#endif -#endif /* EGL_ANDROID_blob_cache */ - -#ifndef EGL_ANDROID_framebuffer_target -#define EGL_ANDROID_framebuffer_target 1 -#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 -#endif /* EGL_ANDROID_framebuffer_target */ - -#ifndef EGL_ANDROID_image_native_buffer -#define EGL_ANDROID_image_native_buffer 1 -#define EGL_NATIVE_BUFFER_ANDROID 0x3140 -#endif /* EGL_ANDROID_image_native_buffer */ - -#ifndef EGL_ANDROID_native_fence_sync -#define EGL_ANDROID_native_fence_sync 1 -#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 -#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 -#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 -#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 -typedef EGLint(EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, - EGLSyncKHR sync); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID(EGLDisplay dpy, - EGLSyncKHR sync); -#endif -#endif /* EGL_ANDROID_native_fence_sync */ - -#ifndef EGL_ANDROID_recordable -#define EGL_ANDROID_recordable 1 -#define EGL_RECORDABLE_ANDROID 0x3142 -#endif /* EGL_ANDROID_recordable */ - -#ifndef EGL_ANGLE_d3d_share_handle_client_buffer -#define EGL_ANGLE_d3d_share_handle_client_buffer 1 -#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 -#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ - -#ifndef EGL_ANGLE_device_d3d -#define EGL_ANGLE_device_d3d 1 -#define EGL_D3D9_DEVICE_ANGLE 0x33A0 -#define EGL_D3D11_DEVICE_ANGLE 0x33A1 -#endif /* EGL_ANGLE_device_d3d */ - -#ifndef EGL_ANGLE_keyed_mutex -#define EGL_ANGLE_keyed_mutex 1 -#define EGL_DXGI_KEYED_MUTEX_ANGLE 0x33A2 -#endif /* EGL_ANGLE_keyed_mutex */ - -#ifndef EGL_ANGLE_query_surface_pointer -#define EGL_ANGLE_query_surface_pointer 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE(EGLDisplay dpy, - EGLSurface surface, - EGLint attribute, - void** value); -#endif -#endif /* EGL_ANGLE_query_surface_pointer */ - -#ifndef EGL_ANGLE_software_display -#define EGL_ANGLE_software_display 1 -#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1) -#endif /* EGL_ANGLE_software_display */ - -#ifndef EGL_ANGLE_direct3d_display -#define EGL_ANGLE_direct3d_display 1 -#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2) -#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3) -#endif /* EGL_ANGLE_direct3d_display */ - -#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle -#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 -#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ - -#ifndef EGL_ANGLE_platform_angle -#define EGL_ANGLE_platform_angle 1 -#define EGL_PLATFORM_ANGLE_ANGLE 0x3202 -#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 -#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 -#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 -#define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3206 -#endif /* EGL_ANGLE_platform_angle */ - -#ifndef EGL_ANGLE_platform_angle_d3d -#define EGL_ANGLE_platform_angle_d3d 1 -#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 -#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE 0x320A -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B -#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE 0x320C -#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F -#endif /* EGL_ANGLE_platform_angle_d3d */ - -#ifndef EGL_ANGLE_platform_angle_opengl -#define EGL_ANGLE_platform_angle_opengl 1 -#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D -#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320E -#endif /* EGL_ANGLE_platform_angle_opengl */ - -#ifndef EGL_ANGLE_window_fixed_size -#define EGL_ANGLE_window_fixed_size 1 -#define EGL_FIXED_SIZE_ANGLE 0x3201 -#endif /* EGL_ANGLE_window_fixed_size */ - -#ifndef EGL_ANGLE_x11_visual -#define EGL_ANGLE_x11_visual -#define EGL_X11_VISUAL_ID_ANGLE 0x33A3 -#endif /* EGL_ANGLE_x11_visual */ - -#ifndef EGL_ARM_pixmap_multisample_discard -#define EGL_ARM_pixmap_multisample_discard 1 -#define EGL_DISCARD_SAMPLES_ARM 0x3286 -#endif /* EGL_ARM_pixmap_multisample_discard */ - -#ifndef EGL_EXT_buffer_age -#define EGL_EXT_buffer_age 1 -#define EGL_BUFFER_AGE_EXT 0x313D -#endif /* EGL_EXT_buffer_age */ - -#ifndef EGL_EXT_client_extensions -#define EGL_EXT_client_extensions 1 -#endif /* EGL_EXT_client_extensions */ - -#ifndef EGL_EXT_create_context_robustness -#define EGL_EXT_create_context_robustness 1 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 -#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF -#endif /* EGL_EXT_create_context_robustness */ - -#ifndef EGL_EXT_device_base -#define EGL_EXT_device_base 1 -typedef void* EGLDeviceEXT; -#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) -#define EGL_BAD_DEVICE_EXT 0x322B -#define EGL_DEVICE_EXT 0x322C -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC)( - EGLDeviceEXT device, - EGLint attribute, - EGLAttrib* value); -typedef const char*(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC)( - EGLDeviceEXT device, - EGLint name); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC)( - EGLint max_devices, - EGLDeviceEXT* devices, - EGLint* num_devices); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC)( - EGLDisplay dpy, - EGLint attribute, - EGLAttrib* value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT(EGLDeviceEXT device, - EGLint attribute, - EGLAttrib* value); -EGLAPI const char* EGLAPIENTRY eglQueryDeviceStringEXT(EGLDeviceEXT device, - EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT(EGLint max_devices, - EGLDeviceEXT* devices, - EGLint* num_devices); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT(EGLDisplay dpy, - EGLint attribute, - EGLAttrib* value); -#endif -#endif /* EGL_EXT_device_base */ - -#ifndef EGL_ANGLE_device_creation -#define EGL_ANGLE_device_creation 1 -typedef EGLDeviceEXT(EGLAPIENTRYP PFNEGLCREATEDEVICEANGLEPROC)( - EGLint device_type, - void* native_device, - const EGLAttrib* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLRELEASEDEVICEANGLEPROC)( - EGLDeviceEXT device); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLDeviceEXT EGLAPIENTRY -eglCreateDeviceANGLE(EGLint device_type, - void* native_device, - const EGLAttrib* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseDeviceANGLE(EGLDeviceEXT device); -#endif -#endif /* EGL_ANGLE_device_creation */ - -#ifndef EGL_EXT_device_drm -#define EGL_EXT_device_drm 1 -#define EGL_DRM_DEVICE_FILE_EXT 0x3233 -#endif /* EGL_EXT_device_drm */ - -#ifndef EGL_EXT_device_enumeration -#define EGL_EXT_device_enumeration 1 -#endif /* EGL_EXT_device_enumeration */ - -#ifndef EGL_EXT_device_openwf -#define EGL_EXT_device_openwf 1 -#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 -#endif /* EGL_EXT_device_openwf */ - -#ifndef EGL_EXT_device_query -#define EGL_EXT_device_query 1 -#endif /* EGL_EXT_device_query */ - -#ifndef EGL_EXT_image_dma_buf_import -#define EGL_EXT_image_dma_buf_import 1 -#define EGL_LINUX_DMA_BUF_EXT 0x3270 -#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 -#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 -#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 -#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 -#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 -#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 -#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 -#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 -#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 -#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A -#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B -#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C -#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D -#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E -#define EGL_ITU_REC601_EXT 0x327F -#define EGL_ITU_REC709_EXT 0x3280 -#define EGL_ITU_REC2020_EXT 0x3281 -#define EGL_YUV_FULL_RANGE_EXT 0x3282 -#define EGL_YUV_NARROW_RANGE_EXT 0x3283 -#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 -#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 -#endif /* EGL_EXT_image_dma_buf_import */ - -#ifndef EGL_EXT_multiview_window -#define EGL_EXT_multiview_window 1 -#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 -#endif /* EGL_EXT_multiview_window */ - -#ifndef EGL_EXT_output_base -#define EGL_EXT_output_base 1 -typedef void* EGLOutputLayerEXT; -typedef void* EGLOutputPortEXT; -#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0) -#define EGL_NO_OUTPUT_PORT_EXT ((EGLOutputPortEXT)0) -#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D -#define EGL_BAD_OUTPUT_PORT_EXT 0x322E -#define EGL_SWAP_INTERVAL_EXT 0x322F -typedef EGLBoolean(EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC)( - EGLDisplay dpy, - const EGLAttrib* attrib_list, - EGLOutputLayerEXT* layers, - EGLint max_layers, - EGLint* num_layers); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC)( - EGLDisplay dpy, - const EGLAttrib* attrib_list, - EGLOutputPortEXT* ports, - EGLint max_ports, - EGLint* num_ports); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC)( - EGLDisplay dpy, - EGLOutputLayerEXT layer, - EGLint attribute, - EGLAttrib value); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC)( - EGLDisplay dpy, - EGLOutputLayerEXT layer, - EGLint attribute, - EGLAttrib* value); -typedef const char*(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC)( - EGLDisplay dpy, - EGLOutputLayerEXT layer, - EGLint name); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC)( - EGLDisplay dpy, - EGLOutputPortEXT port, - EGLint attribute, - EGLAttrib value); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC)( - EGLDisplay dpy, - EGLOutputPortEXT port, - EGLint attribute, - EGLAttrib* value); -typedef const char*(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC)( - EGLDisplay dpy, - EGLOutputPortEXT port, - EGLint name); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY -eglGetOutputLayersEXT(EGLDisplay dpy, - const EGLAttrib* attrib_list, - EGLOutputLayerEXT* layers, - EGLint max_layers, - EGLint* num_layers); -EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT(EGLDisplay dpy, - const EGLAttrib* attrib_list, - EGLOutputPortEXT* ports, - EGLint max_ports, - EGLint* num_ports); -EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT(EGLDisplay dpy, - EGLOutputLayerEXT layer, - EGLint attribute, - EGLAttrib value); -EGLAPI EGLBoolean EGLAPIENTRY -eglQueryOutputLayerAttribEXT(EGLDisplay dpy, - EGLOutputLayerEXT layer, - EGLint attribute, - EGLAttrib* value); -EGLAPI const char* EGLAPIENTRY -eglQueryOutputLayerStringEXT(EGLDisplay dpy, - EGLOutputLayerEXT layer, - EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT(EGLDisplay dpy, - EGLOutputPortEXT port, - EGLint attribute, - EGLAttrib value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT(EGLDisplay dpy, - EGLOutputPortEXT port, - EGLint attribute, - EGLAttrib* value); -EGLAPI const char* EGLAPIENTRY -eglQueryOutputPortStringEXT(EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); -#endif -#endif /* EGL_EXT_output_base */ - -#ifndef EGL_EXT_output_drm -#define EGL_EXT_output_drm 1 -#define EGL_DRM_CRTC_EXT 0x3234 -#define EGL_DRM_PLANE_EXT 0x3235 -#define EGL_DRM_CONNECTOR_EXT 0x3236 -#endif /* EGL_EXT_output_drm */ - -#ifndef EGL_EXT_output_openwf -#define EGL_EXT_output_openwf 1 -#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 -#define EGL_OPENWF_PORT_ID_EXT 0x3239 -#endif /* EGL_EXT_output_openwf */ - -#ifndef EGL_EXT_platform_base -#define EGL_EXT_platform_base 1 -typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)( - EGLenum platform, - void* native_display, - const EGLint* attrib_list); -typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)( - EGLDisplay dpy, - EGLConfig config, - void* native_window, - const EGLint* attrib_list); -typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC)( - EGLDisplay dpy, - EGLConfig config, - void* native_pixmap, - const EGLint* attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLDisplay EGLAPIENTRY -eglGetPlatformDisplayEXT(EGLenum platform, - void* native_display, - const EGLint* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, - EGLConfig config, - void* native_window, - const EGLint* attrib_list); -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, - EGLConfig config, - void* native_pixmap, - const EGLint* attrib_list); -#endif -#endif /* EGL_EXT_platform_base */ - -#ifndef EGL_EXT_platform_device -#define EGL_EXT_platform_device 1 -#define EGL_PLATFORM_DEVICE_EXT 0x313F -#endif /* EGL_EXT_platform_device */ - -#ifndef EGL_EXT_platform_wayland -#define EGL_EXT_platform_wayland 1 -#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 -#endif /* EGL_EXT_platform_wayland */ - -#ifndef EGL_EXT_platform_x11 -#define EGL_EXT_platform_x11 1 -#define EGL_PLATFORM_X11_EXT 0x31D5 -#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 -#endif /* EGL_EXT_platform_x11 */ - -#ifndef EGL_EXT_protected_surface -#define EGL_EXT_protected_surface 1 -#define EGL_PROTECTED_CONTENT_EXT 0x32C0 -#endif /* EGL_EXT_protected_surface */ - -#ifndef EGL_EXT_stream_consumer_egloutput -#define EGL_EXT_stream_consumer_egloutput 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC)( - EGLDisplay dpy, - EGLStreamKHR stream, - EGLOutputLayerEXT layer); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY -eglStreamConsumerOutputEXT(EGLDisplay dpy, - EGLStreamKHR stream, - EGLOutputLayerEXT layer); -#endif -#endif /* EGL_EXT_stream_consumer_egloutput */ - -#ifndef EGL_EXT_swap_buffers_with_damage -#define EGL_EXT_swap_buffers_with_damage 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint* rects, - EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT(EGLDisplay dpy, - EGLSurface surface, - EGLint* rects, - EGLint n_rects); -#endif -#endif /* EGL_EXT_swap_buffers_with_damage */ - -#ifndef EGL_EXT_yuv_surface -#define EGL_EXT_yuv_surface 1 -#define EGL_YUV_ORDER_EXT 0x3301 -#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 -#define EGL_YUV_SUBSAMPLE_EXT 0x3312 -#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 -#define EGL_YUV_CSC_STANDARD_EXT 0x330A -#define EGL_YUV_PLANE_BPP_EXT 0x331A -#define EGL_YUV_BUFFER_EXT 0x3300 -#define EGL_YUV_ORDER_YUV_EXT 0x3302 -#define EGL_YUV_ORDER_YVU_EXT 0x3303 -#define EGL_YUV_ORDER_YUYV_EXT 0x3304 -#define EGL_YUV_ORDER_UYVY_EXT 0x3305 -#define EGL_YUV_ORDER_YVYU_EXT 0x3306 -#define EGL_YUV_ORDER_VYUY_EXT 0x3307 -#define EGL_YUV_ORDER_AYUV_EXT 0x3308 -#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 -#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 -#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 -#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 -#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 -#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B -#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C -#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D -#define EGL_YUV_PLANE_BPP_0_EXT 0x331B -#define EGL_YUV_PLANE_BPP_8_EXT 0x331C -#define EGL_YUV_PLANE_BPP_10_EXT 0x331D -#endif /* EGL_EXT_yuv_surface */ - -#ifndef EGL_HI_clientpixmap -#define EGL_HI_clientpixmap 1 -struct EGLClientPixmapHI { - void* pData; - EGLint iWidth; - EGLint iHeight; - EGLint iStride; -}; -#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 -typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC)( - EGLDisplay dpy, - EGLConfig config, - struct EGLClientPixmapHI* pixmap); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSurface EGLAPIENTRY -eglCreatePixmapSurfaceHI(EGLDisplay dpy, - EGLConfig config, - struct EGLClientPixmapHI* pixmap); -#endif -#endif /* EGL_HI_clientpixmap */ - -#ifndef EGL_HI_colorformats -#define EGL_HI_colorformats 1 -#define EGL_COLOR_FORMAT_HI 0x8F70 -#define EGL_COLOR_RGB_HI 0x8F71 -#define EGL_COLOR_RGBA_HI 0x8F72 -#define EGL_COLOR_ARGB_HI 0x8F73 -#endif /* EGL_HI_colorformats */ - -#ifndef EGL_IMG_context_priority -#define EGL_IMG_context_priority 1 -#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#endif /* EGL_IMG_context_priority */ - -#ifndef EGL_MESA_drm_image -#define EGL_MESA_drm_image 1 -#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 -#define EGL_DRM_BUFFER_USE_MESA 0x31D1 -#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 -#define EGL_DRM_BUFFER_MESA 0x31D3 -#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 -#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 -#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 -typedef EGLImageKHR(EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC)( - EGLDisplay dpy, - const EGLint* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC)(EGLDisplay dpy, - EGLImageKHR image, - EGLint* name, - EGLint* handle, - EGLint* stride); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA(EGLDisplay dpy, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA(EGLDisplay dpy, - EGLImageKHR image, - EGLint* name, - EGLint* handle, - EGLint* stride); -#endif -#endif /* EGL_MESA_drm_image */ - -#ifndef EGL_MESA_image_dma_buf_export -#define EGL_MESA_image_dma_buf_export 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC)( - EGLDisplay dpy, - EGLImageKHR image, - int* fourcc, - int* num_planes, - EGLuint64KHR* modifiers); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC)( - EGLDisplay dpy, - EGLImageKHR image, - int* fds, - EGLint* strides, - EGLint* offsets); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY -eglExportDMABUFImageQueryMESA(EGLDisplay dpy, - EGLImageKHR image, - int* fourcc, - int* num_planes, - EGLuint64KHR* modifiers); -EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA(EGLDisplay dpy, - EGLImageKHR image, - int* fds, - EGLint* strides, - EGLint* offsets); -#endif -#endif /* EGL_MESA_image_dma_buf_export */ - -#ifndef EGL_MESA_platform_gbm -#define EGL_MESA_platform_gbm 1 -#define EGL_PLATFORM_GBM_MESA 0x31D7 -#endif /* EGL_MESA_platform_gbm */ - -#ifndef EGL_NOK_swap_region -#define EGL_NOK_swap_region 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint numRects, - const EGLint* rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK(EGLDisplay dpy, - EGLSurface surface, - EGLint numRects, - const EGLint* rects); -#endif -#endif /* EGL_NOK_swap_region */ - -#ifndef EGL_NOK_swap_region2 -#define EGL_NOK_swap_region2 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC)( - EGLDisplay dpy, - EGLSurface surface, - EGLint numRects, - const EGLint* rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK(EGLDisplay dpy, - EGLSurface surface, - EGLint numRects, - const EGLint* rects); -#endif -#endif /* EGL_NOK_swap_region2 */ - -#ifndef EGL_NOK_texture_from_pixmap -#define EGL_NOK_texture_from_pixmap 1 -#define EGL_Y_INVERTED_NOK 0x307F -#endif /* EGL_NOK_texture_from_pixmap */ - -#ifndef EGL_NV_3dvision_surface -#define EGL_NV_3dvision_surface 1 -#define EGL_AUTO_STEREO_NV 0x3136 -#endif /* EGL_NV_3dvision_surface */ - -#ifndef EGL_NV_coverage_sample -#define EGL_NV_coverage_sample 1 -#define EGL_COVERAGE_BUFFERS_NV 0x30E0 -#define EGL_COVERAGE_SAMPLES_NV 0x30E1 -#endif /* EGL_NV_coverage_sample */ - -#ifndef EGL_NV_coverage_sample_resolve -#define EGL_NV_coverage_sample_resolve 1 -#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 -#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 -#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 -#endif /* EGL_NV_coverage_sample_resolve */ - -#ifndef EGL_NV_cuda_event -#define EGL_NV_cuda_event 1 -#define EGL_CUDA_EVENT_HANDLE_NV 0x323B -#define EGL_SYNC_CUDA_EVENT_NV 0x323C -#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D -#endif /* EGL_NV_cuda_event */ - -#ifndef EGL_NV_depth_nonlinear -#define EGL_NV_depth_nonlinear 1 -#define EGL_DEPTH_ENCODING_NV 0x30E2 -#define EGL_DEPTH_ENCODING_NONE_NV 0 -#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 -#endif /* EGL_NV_depth_nonlinear */ - -#ifndef EGL_NV_device_cuda -#define EGL_NV_device_cuda 1 -#define EGL_CUDA_DEVICE_NV 0x323A -#endif /* EGL_NV_device_cuda */ - -#ifndef EGL_NV_native_query -#define EGL_NV_native_query 1 -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)( - EGLDisplay dpy, - EGLNativeDisplayType* display_id); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)( - EGLDisplay dpy, - EGLSurface surf, - EGLNativeWindowType* window); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)( - EGLDisplay dpy, - EGLSurface surf, - EGLNativePixmapType* pixmap); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY -eglQueryNativeDisplayNV(EGLDisplay dpy, EGLNativeDisplayType* display_id); -EGLAPI EGLBoolean EGLAPIENTRY -eglQueryNativeWindowNV(EGLDisplay dpy, - EGLSurface surf, - EGLNativeWindowType* window); -EGLAPI EGLBoolean EGLAPIENTRY -eglQueryNativePixmapNV(EGLDisplay dpy, - EGLSurface surf, - EGLNativePixmapType* pixmap); -#endif -#endif /* EGL_NV_native_query */ - -#ifndef EGL_NV_post_convert_rounding -#define EGL_NV_post_convert_rounding 1 -#endif /* EGL_NV_post_convert_rounding */ - -#ifndef EGL_NV_post_sub_buffer -#define EGL_NV_post_sub_buffer 1 -#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE -typedef EGLBoolean(EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC)(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy, - EGLSurface surface, - EGLint x, - EGLint y, - EGLint width, - EGLint height); -#endif -#endif /* EGL_NV_post_sub_buffer */ - -#ifndef EGL_NV_stream_sync -#define EGL_NV_stream_sync 1 -#define EGL_SYNC_NEW_FRAME_NV 0x321F -typedef EGLSyncKHR(EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC)( - EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum type, - const EGLint* attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV(EGLDisplay dpy, - EGLStreamKHR stream, - EGLenum type, - const EGLint* attrib_list); -#endif -#endif /* EGL_NV_stream_sync */ - -#ifndef EGL_NV_sync -#define EGL_NV_sync 1 -typedef void* EGLSyncNV; -typedef khronos_utime_nanoseconds_t EGLTimeNV; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 -#define EGL_SYNC_STATUS_NV 0x30E7 -#define EGL_SIGNALED_NV 0x30E8 -#define EGL_UNSIGNALED_NV 0x30E9 -#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 -#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull -#define EGL_ALREADY_SIGNALED_NV 0x30EA -#define EGL_TIMEOUT_EXPIRED_NV 0x30EB -#define EGL_CONDITION_SATISFIED_NV 0x30EC -#define EGL_SYNC_TYPE_NV 0x30ED -#define EGL_SYNC_CONDITION_NV 0x30EE -#define EGL_SYNC_FENCE_NV 0x30EF -#define EGL_NO_SYNC_NV ((EGLSyncNV)0) -typedef EGLSyncNV(EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC)( - EGLDisplay dpy, - EGLenum condition, - const EGLint* attrib_list); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC)(EGLSyncNV sync); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLFENCENVPROC)(EGLSyncNV sync); -typedef EGLint(EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC)(EGLSyncNV sync, - EGLint flags, - EGLTimeNV timeout); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC)(EGLSyncNV sync, - EGLenum mode); -typedef EGLBoolean(EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC)(EGLSyncNV sync, - EGLint attribute, - EGLint* value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV(EGLDisplay dpy, - EGLenum condition, - const EGLint* attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV(EGLSyncNV sync); -EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV(EGLSyncNV sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV(EGLSyncNV sync, - EGLint flags, - EGLTimeNV timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV(EGLSyncNV sync, EGLenum mode); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV(EGLSyncNV sync, - EGLint attribute, - EGLint* value); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_NV_sync */ - -#ifndef EGL_NV_system_time -#define EGL_NV_system_time 1 -typedef khronos_utime_nanoseconds_t EGLuint64NV; -#ifdef KHRONOS_SUPPORT_INT64 -typedef EGLuint64NV(EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC)(void); -typedef EGLuint64NV(EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void); -EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_NV_system_time */ - -#ifndef EGL_TIZEN_image_native_buffer -#define EGL_TIZEN_image_native_buffer 1 -#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 -#endif /* EGL_TIZEN_image_native_buffer */ - -#ifndef EGL_TIZEN_image_native_surface -#define EGL_TIZEN_image_native_surface 1 -#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 -#endif /* EGL_TIZEN_image_native_surface */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/EGL/eglplatform.h b/glimp/include/EGL/eglplatform.h deleted file mode 100644 index 5fc6f8024273..000000000000 --- a/glimp/include/EGL/eglplatform.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef __eglplatform_h_ -#define __eglplatform_h_ - -/* -** Copyright (c) 2007-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. -*/ - -/* Platform-specific types and definitions for egl.h - * $Revision: 30994 $ on $Date: 2015-04-30 13:36:48 -0700 (Thu, 30 Apr 2015) $ - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "EGL" component "Registry". - */ - -#include - -/* Macros used in EGL function prototype declarations. - * - * EGL functions should be prototyped as: - * - * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); - * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); - * - * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h - */ - -#ifndef EGLAPI -#define EGLAPI KHRONOS_APICALL -#endif - -#ifndef EGLAPIENTRY -#define EGLAPIENTRY KHRONOS_APIENTRY -#endif -#define EGLAPIENTRYP EGLAPIENTRY * - -/* The types NativeDisplayType, NativeWindowType, and NativePixmapType - * are aliases of window-system-dependent types, such as X Display * or - * Windows Device Context. They must be defined in platform-specific - * code below. The EGL-prefixed versions of Native*Type are the same - * types, renamed in EGL 1.3 so all types in the API start with "EGL". - * - * Khronos STRONGLY RECOMMENDS that you use the default definitions - * provided below, since these changes affect both binary and source - * portability of applications using EGL running on different EGL - * implementations. - */ - -#include GLIMP_EGLPLATFORM_INCLUDE - -/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ -typedef EGLNativeDisplayType NativeDisplayType; -typedef EGLNativePixmapType NativePixmapType; -typedef EGLNativeWindowType NativeWindowType; - -/* Define EGLint. This must be a signed integral type large enough to contain - * all legal attribute names and values passed into and out of EGL, whether - * their type is boolean, bitmask, enumerant (symbolic constant), integer, - * handle, or other. While in general a 32-bit integer will suffice, if - * handles are 64 bit types, then EGLint should be defined as a signed 64-bit - * integer type. - */ -typedef khronos_int32_t EGLint; - -#endif /* __eglplatform_h */ diff --git a/glimp/include/GLES2/gl2.h b/glimp/include/GLES2/gl2.h deleted file mode 100644 index a6444282ed89..000000000000 --- a/glimp/include/GLES2/gl2.h +++ /dev/null @@ -1,1145 +0,0 @@ -#ifndef __gl2_h_ -#define __gl2_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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: 31811 $ on $Date: 2015-08-10 00:01:11 -0700 (Mon, 10 Aug -*2015) $ -*/ - -#include - -#ifndef GL_APIENTRYP -#define GL_APIENTRYP GL_APIENTRY * -#endif - -/* Generated on date 20150809 */ - -/* Generated C header for: - * API: gles2 - * Profile: common - * Versions considered: 2\.[0-9] - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_ES_VERSION_2_0 -#define GL_ES_VERSION_2_0 1 -#include -typedef khronos_int8_t GLbyte; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; -typedef short GLshort; -typedef unsigned short GLushort; -typedef void GLvoid; -typedef struct __GLsync* GLsync; -typedef khronos_int64_t GLint64; -typedef khronos_uint64_t GLuint64; -typedef unsigned int GLenum; -typedef unsigned int GLuint; -typedef char GLchar; -typedef khronos_float_t GLfloat; -typedef khronos_ssize_t GLsizeiptr; -typedef khronos_intptr_t GLintptr; -typedef unsigned int GLbitfield; -typedef int GLint; -typedef unsigned char GLboolean; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_FALSE 0 -#define GL_TRUE 1 -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#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_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#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_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#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_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_TEXTURE 0x1702 -#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_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#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_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 -#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_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 -#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_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#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_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#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_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_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_NONE 0 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -typedef void(GL_APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); -typedef void(GL_APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, - GLuint index, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); -typedef void(GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, - GLuint framebuffer); -typedef void(GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); -typedef void(GL_APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -typedef void(GL_APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -typedef void(GL_APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -typedef GLenum(GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); -typedef void(GL_APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d); -typedef void(GL_APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); -typedef void(GL_APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -typedef void(GL_APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -typedef void(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef GLuint(GL_APIENTRYP PFNGLCREATEPROGRAMPROC)(void); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); -typedef void(GL_APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, - const GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)( - GLsizei n, - const GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC)( - GLsizei n, - const GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, - const GLuint* textures); -typedef void(GL_APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); -typedef void(GL_APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); -typedef void(GL_APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); -typedef void(GL_APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLDISABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, - GLint first, - GLsizei count); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_APIENTRYP PFNGLENABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLFINISHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFLUSHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)( - GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -typedef void(GL_APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, - GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, - GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint* textures); -typedef void(GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -typedef GLint(GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef GLenum(GL_APIENTRYP PFNGLGETERRORPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat* data); -typedef void(GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)( - GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint* data); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)( - GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -typedef void(GL_APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, - GLint location, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, - GLint location, - GLint* params); -typedef GLint(GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, - GLenum pname, - void** pointer); -typedef void(GL_APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); -typedef GLboolean(GL_APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); -typedef GLboolean(GL_APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); -typedef GLboolean(GL_APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISSHADERPROC)(GLuint shader); -typedef GLboolean(GL_APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); -typedef void(GL_APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); -typedef void(GL_APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); -typedef void(GL_APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, - GLfloat units); -typedef void(GL_APIENTRYP PFNGLREADPIXELSPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -typedef void(GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, - GLboolean invert); -typedef void(GL_APIENTRYP PFNGLSCISSORPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, - GLenum zfail, - GLenum zpass); -typedef void(GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -typedef void(GL_APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - const GLfloat* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, - GLfloat x, - GLfloat y); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLVIEWPORTPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, - GLuint index, - const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, - GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer(GLenum target, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glBlendEquation(GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -GL_APICALL void GL_APIENTRY glBufferData(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target); -GL_APICALL void GL_APIENTRY glClear(GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glClearDepthf(GLfloat d); -GL_APICALL void GL_APIENTRY glClearStencil(GLint s); -GL_APICALL void GL_APIENTRY glColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram(void); -GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type); -GL_APICALL void GL_APIENTRY glCullFace(GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, - const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, - const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc(GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask(GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef(GLfloat n, GLfloat f); -GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable(GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays(GLenum mode, - GLint first, - GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glEnable(GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glFinish(void); -GL_APICALL void GL_APIENTRY glFlush(void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -GL_APICALL void GL_APIENTRY glFrontFace(GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenBuffersForVideoFrame(GLsizei n, - GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap(GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, - GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -GL_APICALL GLint GL_APIENTRY glGetAttribLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError(void); -GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* data); -GL_APICALL void GL_APIENTRY -glGetFramebufferAttachmentParameteriv(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* data); -GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv(GLenum target, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, - GLint location, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, - GLint location, - GLint* params); -GL_APICALL GLint GL_APIENTRY glGetUniformLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, - GLenum pname, - void** pointer); -GL_APICALL void GL_APIENTRY glHint(GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled(GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth(GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler(void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage(GLfloat value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor(GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask(GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, - GLenum zfail, - GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf(GLenum target, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv(GLenum target, - GLenum pname, - const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glUniform1f(GLint location, GLfloat v0); -GL_APICALL void GL_APIENTRY glUniform1fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform1i(GLint location, GLint v0); -GL_APICALL void GL_APIENTRY glUniform1iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform2f(GLint location, GLfloat v0, GLfloat v1); -GL_APICALL void GL_APIENTRY glUniform2fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform2i(GLint location, GLint v0, GLint v1); -GL_APICALL void GL_APIENTRY glUniform2iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform3f(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glUniform3fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform3i(GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glUniform3iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY -glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GL_APICALL void GL_APIENTRY glUniform4fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GL_APICALL void GL_APIENTRY glUniform4iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram(GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib2f(GLuint index, - GLfloat x, - GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib3f(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY -glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glViewport(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#endif -#endif /* GL_ES_VERSION_2_0 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/GLES2/gl2ext.h b/glimp/include/GLES2/gl2ext.h deleted file mode 100644 index 8ab97124957c..000000000000 --- a/glimp/include/GLES2/gl2ext.h +++ /dev/null @@ -1,5033 +0,0 @@ -#ifndef __gl2ext_h_ -#define __gl2ext_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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: 31902 $ on $Date: 2015-09-03 15:44:53 -0700 (Thu, 03 Sep -*2015) $ -*/ - -#ifndef GL_APIENTRYP -#define GL_APIENTRYP GL_APIENTRY * -#endif - -/* Generated on date 20150903 */ - -/* Generated C header for: - * API: gles2 - * Profile: common - * Versions considered: 2\.[0-9] - * Versions emitted: _nomatch_^ - * Default extensions included: gles2 - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_KHR_blend_equation_advanced -#define GL_KHR_blend_equation_advanced 1 -#define GL_MULTIPLY_KHR 0x9294 -#define GL_SCREEN_KHR 0x9295 -#define GL_OVERLAY_KHR 0x9296 -#define GL_DARKEN_KHR 0x9297 -#define GL_LIGHTEN_KHR 0x9298 -#define GL_COLORDODGE_KHR 0x9299 -#define GL_COLORBURN_KHR 0x929A -#define GL_HARDLIGHT_KHR 0x929B -#define GL_SOFTLIGHT_KHR 0x929C -#define GL_DIFFERENCE_KHR 0x929E -#define GL_EXCLUSION_KHR 0x92A0 -#define GL_HSL_HUE_KHR 0x92AD -#define GL_HSL_SATURATION_KHR 0x92AE -#define GL_HSL_COLOR_KHR 0x92AF -#define GL_HSL_LUMINOSITY_KHR 0x92B0 -typedef void(GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlendBarrierKHR(void); -#endif -#endif /* GL_KHR_blend_equation_advanced */ - -#ifndef GL_KHR_blend_equation_advanced_coherent -#define GL_KHR_blend_equation_advanced_coherent 1 -#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 -#endif /* GL_KHR_blend_equation_advanced_coherent */ - -#ifndef GL_KHR_context_flush_control -#define GL_KHR_context_flush_control 1 -#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB -#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC -#endif /* GL_KHR_context_flush_control */ - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -typedef void(GL_APIENTRY* GLDEBUGPROCKHR)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* message, - const void* userParam); -#define GL_SAMPLER 0x82E6 -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 -#define GL_DEBUG_SOURCE_API_KHR 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A -#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B -#define GL_DEBUG_TYPE_ERROR_KHR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 -#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 -#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D -#define GL_BUFFER_KHR 0x82E0 -#define GL_SHADER_KHR 0x82E1 -#define GL_PROGRAM_KHR 0x82E2 -#define GL_VERTEX_ARRAY_KHR 0x8074 -#define GL_QUERY_KHR 0x82E3 -#define GL_PROGRAM_PIPELINE_KHR 0x82E4 -#define GL_SAMPLER_KHR 0x82E6 -#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 -#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 -#define GL_DEBUG_OUTPUT_KHR 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 -#define GL_STACK_OVERFLOW_KHR 0x0503 -#define GL_STACK_UNDERFLOW_KHR 0x0504 -typedef void(GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC)(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled); -typedef void(GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf); -typedef void(GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC)( - GLDEBUGPROCKHR callback, - const void* userParam); -typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog); -typedef void(GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC)(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message); -typedef void(GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC)(void); -typedef void(GL_APIENTRYP PFNGLOBJECTLABELKHRPROC)(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC)(GLenum identifier, - GLuint name, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -typedef void(GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC)(const void* ptr, - GLsizei length, - const GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC)(const void* ptr, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETPOINTERVKHRPROC)(GLenum pname, void** params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDebugMessageControlKHR(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled); -GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf); -GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR(GLDEBUGPROCKHR callback, - const void* userParam); -GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog); -GL_APICALL void GL_APIENTRY glPushDebugGroupKHR(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message); -GL_APICALL void GL_APIENTRY glPopDebugGroupKHR(void); -GL_APICALL void GL_APIENTRY glObjectLabelKHR(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label); -GL_APICALL void GL_APIENTRY glGetObjectLabelKHR(GLenum identifier, - GLuint name, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR(const void* ptr, - GLsizei length, - const GLchar* label); -GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR(const void* ptr, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -GL_APICALL void GL_APIENTRY glGetPointervKHR(GLenum pname, void** params); -#endif -#endif /* GL_KHR_debug */ - -#ifndef GL_KHR_no_error -#define GL_KHR_no_error 1 -#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 -#endif /* GL_KHR_no_error */ - -#ifndef GL_KHR_robust_buffer_access_behavior -#define GL_KHR_robust_buffer_access_behavior 1 -#endif /* GL_KHR_robust_buffer_access_behavior */ - -#ifndef GL_KHR_robustness -#define GL_KHR_robustness 1 -#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 -#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 -#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 -#define GL_NO_RESET_NOTIFICATION_KHR 0x8261 -#define GL_CONTEXT_LOST_KHR 0x0507 -typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void); -typedef void(GL_APIENTRYP PFNGLREADNPIXELSKHRPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLuint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR(void); -GL_APICALL void GL_APIENTRY glReadnPixelsKHR(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data); -GL_APICALL void GL_APIENTRY glGetnUniformfvKHR(GLuint program, - GLint location, - GLsizei bufSize, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetnUniformivKHR(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params); -GL_APICALL void GL_APIENTRY glGetnUniformuivKHR(GLuint program, - GLint location, - GLsizei bufSize, - GLuint* params); -#endif -#endif /* GL_KHR_robustness */ - -#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_EGL_image -#define GL_OES_EGL_image 1 -typedef void* GLeglImageOES; -typedef void(GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)( - GLenum target, - GLeglImageOES image); -typedef void(GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)( - GLenum target, - GLeglImageOES image); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, - GLeglImageOES image); -GL_APICALL void GL_APIENTRY -glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); -#endif -#endif /* GL_OES_EGL_image */ - -#ifndef GL_OES_EGL_image_external -#define GL_OES_EGL_image_external 1 -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#endif /* GL_OES_EGL_image_external */ - -#ifndef GL_OES_EGL_image_external_essl3 -#define GL_OES_EGL_image_external_essl3 1 -#endif /* GL_OES_EGL_image_external_essl3 */ - -#ifndef GL_OES_compressed_ETC1_RGB8_sub_texture -#define GL_OES_compressed_ETC1_RGB8_sub_texture 1 -#endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */ - -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_OES_compressed_ETC1_RGB8_texture 1 -#define GL_ETC1_RGB8_OES 0x8D64 -#endif /* GL_OES_compressed_ETC1_RGB8_texture */ - -#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_copy_image -#define GL_OES_copy_image 1 -typedef void(GL_APIENTRYP PFNGLCOPYIMAGESUBDATAOESPROC)(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); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCopyImageSubDataOES(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); -#endif -#endif /* GL_OES_copy_image */ - -#ifndef GL_OES_depth24 -#define GL_OES_depth24 1 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif /* GL_OES_depth24 */ - -#ifndef GL_OES_depth32 -#define GL_OES_depth32 1 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#endif /* GL_OES_depth32 */ - -#ifndef GL_OES_depth_texture -#define GL_OES_depth_texture 1 -#endif /* GL_OES_depth_texture */ - -#ifndef GL_OES_draw_buffers_indexed -#define GL_OES_draw_buffers_indexed 1 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -typedef void(GL_APIENTRYP PFNGLENABLEIOESPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLDISABLEIOESPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONIOESPROC)(GLuint buf, GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIOESPROC)(GLuint buf, - GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCIOESPROC)(GLuint buf, - GLenum src, - GLenum dst); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIOESPROC)(GLuint buf, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -typedef void(GL_APIENTRYP PFNGLCOLORMASKIOESPROC)(GLuint index, - GLboolean r, - GLboolean g, - GLboolean b, - GLboolean a); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDIOESPROC)(GLenum target, - GLuint index); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEnableiOES(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glDisableiOES(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glBlendEquationiOES(GLuint buf, GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparateiOES(GLuint buf, - GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunciOES(GLuint buf, GLenum src, GLenum dst); -GL_APICALL void GL_APIENTRY glBlendFuncSeparateiOES(GLuint buf, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -GL_APICALL void GL_APIENTRY glColorMaskiOES(GLuint index, - GLboolean r, - GLboolean g, - GLboolean b, - GLboolean a); -GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES(GLenum target, GLuint index); -#endif -#endif /* GL_OES_draw_buffers_indexed */ - -#ifndef GL_OES_draw_elements_base_vertex -#define GL_OES_draw_elements_base_vertex 1 -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC)( - GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXOESPROC)( - GLenum mode, - const GLsizei* count, - GLenum type, - const void* const* indices, - GLsizei primcount, - const GLint* basevertex); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glDrawRangeElementsBaseVertexOES(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glDrawElementsInstancedBaseVertexOES(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glMultiDrawElementsBaseVertexOES(GLenum mode, - const GLsizei* count, - GLenum type, - const void* const* indices, - GLsizei primcount, - const GLint* basevertex); -#endif -#endif /* GL_OES_draw_elements_base_vertex */ - -#ifndef GL_OES_element_index_uint -#define GL_OES_element_index_uint 1 -#endif /* GL_OES_element_index_uint */ - -#ifndef GL_OES_fbo_render_mipmap -#define GL_OES_fbo_render_mipmap 1 -#endif /* GL_OES_fbo_render_mipmap */ - -#ifndef GL_OES_fragment_precision_high -#define GL_OES_fragment_precision_high 1 -#endif /* GL_OES_fragment_precision_high */ - -#ifndef GL_OES_geometry_point_size -#define GL_OES_geometry_point_size 1 -#endif /* GL_OES_geometry_point_size */ - -#ifndef GL_OES_geometry_shader -#define GL_OES_geometry_shader 1 -#define GL_GEOMETRY_SHADER_OES 0x8DD9 -#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004 -#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916 -#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917 -#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918 -#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F -#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E -#define GL_LINES_ADJACENCY_OES 0x000A -#define GL_LINE_STRIP_ADJACENCY_OES 0x000B -#define GL_TRIANGLES_ADJACENCY_OES 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124 -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1 -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5 -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7 -#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E -#define GL_UNDEFINED_VERTEX_OES 0x8260 -#define GL_PRIMITIVES_GENERATED_OES 0x8C87 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312 -#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7 -#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309 -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREOESPROC)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glFramebufferTextureOES(GLenum target, - GLenum attachment, - GLuint texture, - GLint level); -#endif -#endif /* GL_OES_geometry_shader */ - -#ifndef GL_OES_get_program_binary -#define GL_OES_get_program_binary 1 -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -typedef void(GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -typedef void(GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC)(GLuint program, - GLenum binaryFormat, - const void* binary, - GLint length); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetProgramBinaryOES(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -GL_APICALL void GL_APIENTRY glProgramBinaryOES(GLuint program, - GLenum binaryFormat, - const void* binary, - GLint length); -#endif -#endif /* GL_OES_get_program_binary */ - -#ifndef GL_OES_gpu_shader5 -#define GL_OES_gpu_shader5 1 -#endif /* GL_OES_gpu_shader5 */ - -#ifndef GL_OES_mapbuffer -#define GL_OES_mapbuffer 1 -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_ACCESS_OES 0x88BB -#define GL_BUFFER_MAPPED_OES 0x88BC -#define GL_BUFFER_MAP_POINTER_OES 0x88BD -typedef void*(GL_APIENTRYP PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access); -typedef GLboolean(GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, - GLenum pname, - void** params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferOES(GLenum target, GLenum access); -GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointervOES(GLenum target, - GLenum pname, - void** params); -#endif -#endif /* GL_OES_mapbuffer */ - -#ifndef GL_OES_packed_depth_stencil -#define GL_OES_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif /* GL_OES_packed_depth_stencil */ - -#ifndef GL_OES_primitive_bounding_box -#define GL_OES_primitive_bounding_box 1 -#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE -typedef void(GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXOESPROC)(GLfloat minX, - GLfloat minY, - GLfloat minZ, - GLfloat minW, - GLfloat maxX, - GLfloat maxY, - GLfloat maxZ, - GLfloat maxW); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxOES(GLfloat minX, - GLfloat minY, - GLfloat minZ, - GLfloat minW, - GLfloat maxX, - GLfloat maxY, - GLfloat maxZ, - GLfloat maxW); -#endif -#endif /* GL_OES_primitive_bounding_box */ - -#ifndef GL_OES_required_internalformat -#define GL_OES_required_internalformat 1 -#define GL_ALPHA8_OES 0x803C -#define GL_DEPTH_COMPONENT16_OES 0x81A5 -#define GL_LUMINANCE4_ALPHA4_OES 0x8043 -#define GL_LUMINANCE8_ALPHA8_OES 0x8045 -#define GL_LUMINANCE8_OES 0x8040 -#define GL_RGBA4_OES 0x8056 -#define GL_RGB5_A1_OES 0x8057 -#define GL_RGB565_OES 0x8D62 -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB10_A2_EXT 0x8059 -#endif /* GL_OES_required_internalformat */ - -#ifndef GL_OES_rgb8_rgba8 -#define GL_OES_rgb8_rgba8 1 -#endif /* GL_OES_rgb8_rgba8 */ - -#ifndef GL_OES_sample_shading -#define GL_OES_sample_shading 1 -#define GL_SAMPLE_SHADING_OES 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37 -typedef void(GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC)(GLfloat value); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMinSampleShadingOES(GLfloat value); -#endif -#endif /* GL_OES_sample_shading */ - -#ifndef GL_OES_sample_variables -#define GL_OES_sample_variables 1 -#endif /* GL_OES_sample_variables */ - -#ifndef GL_OES_shader_image_atomic -#define GL_OES_shader_image_atomic 1 -#endif /* GL_OES_shader_image_atomic */ - -#ifndef GL_OES_shader_io_blocks -#define GL_OES_shader_io_blocks 1 -#endif /* GL_OES_shader_io_blocks */ - -#ifndef GL_OES_shader_multisample_interpolation -#define GL_OES_shader_multisample_interpolation 1 -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D -#endif /* GL_OES_shader_multisample_interpolation */ - -#ifndef GL_OES_standard_derivatives -#define GL_OES_standard_derivatives 1 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#endif /* GL_OES_standard_derivatives */ - -#ifndef GL_OES_stencil1 -#define GL_OES_stencil1 1 -#define GL_STENCIL_INDEX1_OES 0x8D46 -#endif /* GL_OES_stencil1 */ - -#ifndef GL_OES_stencil4 -#define GL_OES_stencil4 1 -#define GL_STENCIL_INDEX4_OES 0x8D47 -#endif /* GL_OES_stencil4 */ - -#ifndef GL_OES_surfaceless_context -#define GL_OES_surfaceless_context 1 -#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 -#endif /* GL_OES_surfaceless_context */ - -#ifndef GL_OES_tessellation_point_size -#define GL_OES_tessellation_point_size 1 -#endif /* GL_OES_tessellation_point_size */ - -#ifndef GL_OES_tessellation_shader -#define GL_OES_tessellation_shader 1 -#define GL_PATCHES_OES 0x000E -#define GL_PATCH_VERTICES_OES 0x8E72 -#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75 -#define GL_TESS_GEN_MODE_OES 0x8E76 -#define GL_TESS_GEN_SPACING_OES 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78 -#define GL_TESS_GEN_POINT_MODE_OES 0x8E79 -#define GL_ISOLINES_OES 0x8E7A -#define GL_QUADS_OES 0x0007 -#define GL_FRACTIONAL_ODD_OES 0x8E7B -#define GL_FRACTIONAL_EVEN_OES 0x8E7C -#define GL_MAX_PATCH_VERTICES_OES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4 -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9 -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221 -#define GL_IS_PER_PATCH_OES 0x92E7 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308 -#define GL_TESS_CONTROL_SHADER_OES 0x8E88 -#define GL_TESS_EVALUATION_SHADER_OES 0x8E87 -#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010 -typedef void(GL_APIENTRYP PFNGLPATCHPARAMETERIOESPROC)(GLenum pname, - GLint value); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glPatchParameteriOES(GLenum pname, GLint value); -#endif -#endif /* GL_OES_tessellation_shader */ - -#ifndef GL_OES_texture_3D -#define GL_OES_texture_3D 1 -#define GL_TEXTURE_WRAP_R_OES 0x8072 -#define GL_TEXTURE_3D_OES 0x806F -#define GL_TEXTURE_BINDING_3D_OES 0x806A -#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 -#define GL_SAMPLER_3D_OES 0x8B5F -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 -typedef void(GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC)(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(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC)( - GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC)( - 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(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC)(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLint zoffset); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glTexSubImage3DOES(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLint zoffset); -#endif -#endif /* GL_OES_texture_3D */ - -#ifndef GL_OES_texture_border_clamp -#define GL_OES_texture_border_clamp 1 -#define GL_TEXTURE_BORDER_COLOR_OES 0x1004 -#define GL_CLAMP_TO_BORDER_OES 0x812D -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIIVOESPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIUIVOESPROC)(GLenum target, - GLenum pname, - const GLuint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIIVOESPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVOESPROC)(GLenum target, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, - GLenum pname, - const GLint* param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVOESPROC)( - GLuint sampler, - GLenum pname, - const GLuint* param); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVOESPROC)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVOESPROC)(GLuint sampler, - GLenum pname, - GLuint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexParameterIivOES(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexParameterIuivOES(GLenum target, - GLenum pname, - const GLuint* params); -GL_APICALL void GL_APIENTRY glGetTexParameterIivOES(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetTexParameterIuivOES(GLenum target, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY glSamplerParameterIivOES(GLuint sampler, - GLenum pname, - const GLint* param); -GL_APICALL void GL_APIENTRY glSamplerParameterIuivOES(GLuint sampler, - GLenum pname, - const GLuint* param); -GL_APICALL void GL_APIENTRY glGetSamplerParameterIivOES(GLuint sampler, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivOES(GLuint sampler, - GLenum pname, - GLuint* params); -#endif -#endif /* GL_OES_texture_border_clamp */ - -#ifndef GL_OES_texture_buffer -#define GL_OES_texture_buffer 1 -#define GL_TEXTURE_BUFFER_OES 0x8C2A -#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D -#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F -#define GL_SAMPLER_BUFFER_OES 0x8DC2 -#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8 -#define GL_IMAGE_BUFFER_OES 0x9051 -#define GL_INT_IMAGE_BUFFER_OES 0x905C -#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067 -#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D -#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E -typedef void(GL_APIENTRYP PFNGLTEXBUFFEROESPROC)(GLenum target, - GLenum internalformat, - GLuint buffer); -typedef void(GL_APIENTRYP PFNGLTEXBUFFERRANGEOESPROC)(GLenum target, - GLenum internalformat, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexBufferOES(GLenum target, - GLenum internalformat, - GLuint buffer); -GL_APICALL void GL_APIENTRY glTexBufferRangeOES(GLenum target, - GLenum internalformat, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -#endif -#endif /* GL_OES_texture_buffer */ - -#ifndef GL_OES_texture_compression_astc -#define GL_OES_texture_compression_astc 1 -#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 -#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 -#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 -#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 -#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 -#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 -#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 -#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 -#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 -#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 -#endif /* GL_OES_texture_compression_astc */ - -#ifndef GL_OES_texture_cube_map_array -#define GL_OES_texture_cube_map_array 1 -#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A -#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F -#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054 -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A -#endif /* GL_OES_texture_cube_map_array */ - -#ifndef GL_OES_texture_float -#define GL_OES_texture_float 1 -#endif /* GL_OES_texture_float */ - -#ifndef GL_OES_texture_float_linear -#define GL_OES_texture_float_linear 1 -#endif /* GL_OES_texture_float_linear */ - -#ifndef GL_OES_texture_half_float -#define GL_OES_texture_half_float 1 -#define GL_HALF_FLOAT_OES 0x8D61 -#endif /* GL_OES_texture_half_float */ - -#ifndef GL_OES_texture_half_float_linear -#define GL_OES_texture_half_float_linear 1 -#endif /* GL_OES_texture_half_float_linear */ - -#ifndef GL_OES_texture_npot -#define GL_OES_texture_npot 1 -#endif /* GL_OES_texture_npot */ - -#ifndef GL_OES_texture_stencil8 -#define GL_OES_texture_stencil8 1 -#define GL_STENCIL_INDEX_OES 0x1901 -#define GL_STENCIL_INDEX8_OES 0x8D48 -#endif /* GL_OES_texture_stencil8 */ - -#ifndef GL_OES_texture_storage_multisample_2d_array -#define GL_OES_texture_storage_multisample_2d_array 1 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105 -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLboolean fixedsamplelocations); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glTexStorage3DMultisampleOES(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLboolean fixedsamplelocations); -#endif -#endif /* GL_OES_texture_storage_multisample_2d_array */ - -#ifndef GL_OES_texture_view -#define GL_OES_texture_view 1 -#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -typedef void(GL_APIENTRYP PFNGLTEXTUREVIEWOESPROC)(GLuint texture, - GLenum target, - GLuint origtexture, - GLenum internalformat, - GLuint minlevel, - GLuint numlevels, - GLuint minlayer, - GLuint numlayers); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTextureViewOES(GLuint texture, - GLenum target, - GLuint origtexture, - GLenum internalformat, - GLuint minlevel, - GLuint numlevels, - GLuint minlayer, - GLuint numlayers); -#endif -#endif /* GL_OES_texture_view */ - -#ifndef GL_OES_vertex_array_object -#define GL_OES_vertex_array_object 1 -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -typedef void(GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC)(GLsizei n, - const GLuint* arrays); -typedef void(GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC)(GLsizei n, - GLuint* arrays); -typedef GLboolean(GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC)(GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBindVertexArrayOES(GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES(GLsizei n, - const GLuint* arrays); -GL_APICALL void GL_APIENTRY glGenVertexArraysOES(GLsizei n, GLuint* arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES(GLuint array); -#endif -#endif /* GL_OES_vertex_array_object */ - -#ifndef GL_OES_vertex_half_float -#define GL_OES_vertex_half_float 1 -#endif /* GL_OES_vertex_half_float */ - -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_OES_vertex_type_10_10_10_2 1 -#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 -#define GL_INT_10_10_10_2_OES 0x8DF7 -#endif /* GL_OES_vertex_type_10_10_10_2 */ - -#ifndef GL_AMD_compressed_3DC_texture -#define GL_AMD_compressed_3DC_texture 1 -#define GL_3DC_X_AMD 0x87F9 -#define GL_3DC_XY_AMD 0x87FA -#endif /* GL_AMD_compressed_3DC_texture */ - -#ifndef GL_AMD_compressed_ATC_texture -#define GL_AMD_compressed_ATC_texture 1 -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#endif /* GL_AMD_compressed_ATC_texture */ - -#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(GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC)(GLint* numGroups, - GLsizei groupsSize, - GLuint* groups); -typedef void(GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC)( - GLuint group, - GLint* numCounters, - GLint* maxActiveCounters, - GLsizei counterSize, - GLuint* counters); -typedef void(GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC)( - GLuint group, - GLsizei bufSize, - GLsizei* length, - GLchar* groupString); -typedef void(GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC)( - GLuint group, - GLuint counter, - GLsizei bufSize, - GLsizei* length, - GLchar* counterString); -typedef void(GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC)(GLuint group, - GLuint counter, - GLenum pname, - void* data); -typedef void(GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC)(GLsizei n, - GLuint* monitors); -typedef void(GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC)(GLsizei n, - GLuint* monitors); -typedef void(GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC)( - GLuint monitor, - GLboolean enable, - GLuint group, - GLint numCounters, - GLuint* counterList); -typedef void(GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC)(GLuint monitor); -typedef void(GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC)(GLuint monitor); -typedef void(GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC)( - GLuint monitor, - GLenum pname, - GLsizei dataSize, - GLuint* data, - GLint* bytesWritten); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD(GLint* numGroups, - GLsizei groupsSize, - GLuint* groups); -GL_APICALL void GL_APIENTRY -glGetPerfMonitorCountersAMD(GLuint group, - GLint* numCounters, - GLint* maxActiveCounters, - GLsizei counterSize, - GLuint* counters); -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD(GLuint group, - GLsizei bufSize, - GLsizei* length, - GLchar* groupString); -GL_APICALL void GL_APIENTRY -glGetPerfMonitorCounterStringAMD(GLuint group, - GLuint counter, - GLsizei bufSize, - GLsizei* length, - GLchar* counterString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD(GLuint group, - GLuint counter, - GLenum pname, - void* data); -GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD(GLsizei n, GLuint* monitors); -GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD(GLsizei n, - GLuint* monitors); -GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD(GLuint monitor, - GLboolean enable, - GLuint group, - GLint numCounters, - GLuint* counterList); -GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD(GLuint monitor); -GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD(GLuint monitor); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD(GLuint monitor, - GLenum pname, - GLsizei dataSize, - GLuint* data, - GLint* bytesWritten); -#endif -#endif /* GL_AMD_performance_monitor */ - -#ifndef GL_AMD_program_binary_Z400 -#define GL_AMD_program_binary_Z400 1 -#define GL_Z400_BINARY_AMD 0x8740 -#endif /* GL_AMD_program_binary_Z400 */ - -#ifndef GL_ANDROID_extension_pack_es31a -#define GL_ANDROID_extension_pack_es31a 1 -#endif /* GL_ANDROID_extension_pack_es31a */ - -#ifndef GL_ANGLE_depth_texture -#define GL_ANGLE_depth_texture 1 -#endif /* GL_ANGLE_depth_texture */ - -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -typedef void(GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -#endif -#endif /* GL_ANGLE_framebuffer_blit */ - -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisampleANGLE(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -#endif -#endif /* GL_ANGLE_framebuffer_multisample */ - -#ifndef GL_ANGLE_instanced_arrays -#define GL_ANGLE_instanced_arrays 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC)(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC)(GLuint index, - GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount); -GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, - GLuint divisor); -#endif -#endif /* GL_ANGLE_instanced_arrays */ - -#ifndef GL_ANGLE_pack_reverse_row_order -#define GL_ANGLE_pack_reverse_row_order 1 -#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 -#endif /* GL_ANGLE_pack_reverse_row_order */ - -#ifndef GL_ANGLE_program_binary -#define GL_ANGLE_program_binary 1 -#define GL_PROGRAM_BINARY_ANGLE 0x93A6 -#endif /* GL_ANGLE_program_binary */ - -#ifndef GL_ANGLE_texture_compression_dxt3 -#define GL_ANGLE_texture_compression_dxt3 1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 -#endif /* GL_ANGLE_texture_compression_dxt3 */ - -#ifndef GL_ANGLE_texture_compression_dxt5 -#define GL_ANGLE_texture_compression_dxt5 1 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 -#endif /* GL_ANGLE_texture_compression_dxt5 */ - -#ifndef GL_ANGLE_texture_usage -#define GL_ANGLE_texture_usage 1 -#define GL_TEXTURE_USAGE_ANGLE 0x93A2 -#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 -#endif /* GL_ANGLE_texture_usage */ - -#ifndef GL_ANGLE_translated_shader_source -#define GL_ANGLE_translated_shader_source 1 -#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 -typedef void(GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)( - GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* source); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, - GLsizei bufsize, - GLsizei* length, - GLchar* source); -#endif -#endif /* GL_ANGLE_translated_shader_source */ - -#ifndef GL_APPLE_clip_distance -#define GL_APPLE_clip_distance 1 -#define GL_MAX_CLIP_DISTANCES_APPLE 0x0D32 -#define GL_CLIP_DISTANCE0_APPLE 0x3000 -#define GL_CLIP_DISTANCE1_APPLE 0x3001 -#define GL_CLIP_DISTANCE2_APPLE 0x3002 -#define GL_CLIP_DISTANCE3_APPLE 0x3003 -#define GL_CLIP_DISTANCE4_APPLE 0x3004 -#define GL_CLIP_DISTANCE5_APPLE 0x3005 -#define GL_CLIP_DISTANCE6_APPLE 0x3006 -#define GL_CLIP_DISTANCE7_APPLE 0x3007 -#endif /* GL_APPLE_clip_distance */ - -#ifndef GL_APPLE_color_buffer_packed_float -#define GL_APPLE_color_buffer_packed_float 1 -#endif /* GL_APPLE_color_buffer_packed_float */ - -#ifndef GL_APPLE_copy_texture_levels -#define GL_APPLE_copy_texture_levels 1 -typedef void(GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC)( - GLuint destinationTexture, - GLuint sourceTexture, - GLint sourceBaseLevel, - GLsizei sourceLevelCount); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE(GLuint destinationTexture, - GLuint sourceTexture, - GLint sourceBaseLevel, - GLsizei sourceLevelCount); -#endif -#endif /* GL_APPLE_copy_texture_levels */ - -#ifndef GL_APPLE_framebuffer_multisample -#define GL_APPLE_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define GL_MAX_SAMPLES_APPLE 0x8D57 -#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisampleAPPLE(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE(void); -#endif -#endif /* GL_APPLE_framebuffer_multisample */ - -#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_sync -#define GL_APPLE_sync 1 -#define GL_SYNC_OBJECT_APPLE 0x8A53 -#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 -#define GL_OBJECT_TYPE_APPLE 0x9112 -#define GL_SYNC_CONDITION_APPLE 0x9113 -#define GL_SYNC_STATUS_APPLE 0x9114 -#define GL_SYNC_FLAGS_APPLE 0x9115 -#define GL_SYNC_FENCE_APPLE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 -#define GL_UNSIGNALED_APPLE 0x9118 -#define GL_SIGNALED_APPLE 0x9119 -#define GL_ALREADY_SIGNALED_APPLE 0x911A -#define GL_TIMEOUT_EXPIRED_APPLE 0x911B -#define GL_CONDITION_SATISFIED_APPLE 0x911C -#define GL_WAIT_FAILED_APPLE 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 -#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull -typedef GLsync(GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC)(GLenum condition, - GLbitfield flags); -typedef GLboolean(GL_APIENTRYP PFNGLISSYNCAPPLEPROC)(GLsync sync); -typedef void(GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC)(GLsync sync); -typedef GLenum(GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC)(GLenum pname, - GLint64* params); -typedef void(GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC)(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE(GLenum condition, - GLbitfield flags); -GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE(GLsync sync); -GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE(GLsync sync); -GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glWaitSyncAPPLE(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE(GLenum pname, GLint64* params); -GL_APICALL void GL_APIENTRY glGetSyncivAPPLE(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -#endif -#endif /* GL_APPLE_sync */ - -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_APPLE_texture_format_BGRA8888 1 -#define GL_BGRA_EXT 0x80E1 -#define GL_BGRA8_EXT 0x93A1 -#endif /* GL_APPLE_texture_format_BGRA8888 */ - -#ifndef GL_APPLE_texture_max_level -#define GL_APPLE_texture_max_level 1 -#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#endif /* GL_APPLE_texture_max_level */ - -#ifndef GL_APPLE_texture_packed_float -#define GL_APPLE_texture_packed_float 1 -#define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B -#define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E -#define GL_R11F_G11F_B10F_APPLE 0x8C3A -#define GL_RGB9_E5_APPLE 0x8C3D -#endif /* GL_APPLE_texture_packed_float */ - -#ifndef GL_ARM_mali_program_binary -#define GL_ARM_mali_program_binary 1 -#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 -#endif /* GL_ARM_mali_program_binary */ - -#ifndef GL_ARM_mali_shader_binary -#define GL_ARM_mali_shader_binary 1 -#define GL_MALI_SHADER_BINARY_ARM 0x8F60 -#endif /* GL_ARM_mali_shader_binary */ - -#ifndef GL_ARM_rgba8 -#define GL_ARM_rgba8 1 -#endif /* GL_ARM_rgba8 */ - -#ifndef GL_ARM_shader_framebuffer_fetch -#define GL_ARM_shader_framebuffer_fetch 1 -#define GL_FETCH_PER_SAMPLE_ARM 0x8F65 -#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 -#endif /* GL_ARM_shader_framebuffer_fetch */ - -#ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil -#define GL_ARM_shader_framebuffer_fetch_depth_stencil 1 -#endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */ - -#ifndef GL_DMP_program_binary -#define GL_DMP_program_binary 1 -#define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 -#define GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252 -#define GL_DMP_PROGRAM_BINARY_DMP 0x9253 -#endif /* GL_DMP_program_binary */ - -#ifndef GL_DMP_shader_binary -#define GL_DMP_shader_binary 1 -#define GL_SHADER_BINARY_DMP 0x9250 -#endif /* GL_DMP_shader_binary */ - -#ifndef GL_EXT_YUV_target -#define GL_EXT_YUV_target 1 -#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 -#endif /* GL_EXT_YUV_target */ - -#ifndef GL_EXT_base_instance -#define GL_EXT_base_instance 1 -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC)( - GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount, - GLuint baseinstance); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLuint baseinstance); -typedef void( - GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex, - GLuint baseinstance); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glDrawArraysInstancedBaseInstanceEXT(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount, - GLuint baseinstance); -GL_APICALL void GL_APIENTRY -glDrawElementsInstancedBaseInstanceEXT(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLuint baseinstance); -GL_APICALL void GL_APIENTRY -glDrawElementsInstancedBaseVertexBaseInstanceEXT(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex, - GLuint baseinstance); -#endif -#endif /* GL_EXT_base_instance */ - -#ifndef GL_EXT_blend_func_extended -#define GL_EXT_blend_func_extended 1 -#define GL_SRC1_COLOR_EXT 0x88F9 -#define GL_SRC1_ALPHA_EXT 0x8589 -#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB -#define GL_SRC_ALPHA_SATURATE_EXT 0x0308 -#define GL_LOCATION_INDEX_EXT 0x930F -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC -typedef void(GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC)( - GLuint program, - GLuint colorNumber, - GLuint index, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC)(GLuint program, - GLuint color, - const GLchar* name); -typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)( - GLuint program, - GLenum programInterface, - const GLchar* name); -typedef GLint(GL_APIENTRYP PFNGLGETFRAGDATAINDEXEXTPROC)(GLuint program, - const GLchar* name); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glBindFragDataLocationIndexedEXT(GLuint program, - GLuint colorNumber, - GLuint index, - const GLchar* name); -GL_APICALL void GL_APIENTRY glBindFragDataLocationEXT(GLuint program, - GLuint color, - const GLchar* name); -GL_APICALL GLint GL_APIENTRY -glGetProgramResourceLocationIndexEXT(GLuint program, - GLenum programInterface, - const GLchar* name); -GL_APICALL GLint GL_APIENTRY glGetFragDataIndexEXT(GLuint program, - const GLchar* name); -#endif -#endif /* GL_EXT_blend_func_extended */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif /* GL_EXT_blend_minmax */ - -#ifndef GL_EXT_buffer_storage -#define GL_EXT_buffer_storage 1 -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_PERSISTENT_BIT_EXT 0x0040 -#define GL_MAP_COHERENT_BIT_EXT 0x0080 -#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100 -#define GL_CLIENT_STORAGE_BIT_EXT 0x0200 -#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 -#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F -#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220 -typedef void(GL_APIENTRYP PFNGLBUFFERSTORAGEEXTPROC)(GLenum target, - GLsizeiptr size, - const void* data, - GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBufferStorageEXT(GLenum target, - GLsizeiptr size, - const void* data, - GLbitfield flags); -#endif -#endif /* GL_EXT_buffer_storage */ - -#ifndef GL_EXT_color_buffer_float -#define GL_EXT_color_buffer_float 1 -#endif /* GL_EXT_color_buffer_float */ - -#ifndef GL_EXT_color_buffer_half_float -#define GL_EXT_color_buffer_half_float 1 -#define GL_RGBA16F_EXT 0x881A -#define GL_RGB16F_EXT 0x881B -#define GL_RG16F_EXT 0x822F -#define GL_R16F_EXT 0x822D -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 -#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 -#endif /* GL_EXT_color_buffer_half_float */ - -#ifndef GL_EXT_copy_image -#define GL_EXT_copy_image 1 -typedef void(GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC)(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); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT(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); -#endif -#endif /* GL_EXT_copy_image */ - -#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 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -typedef void(GL_APIENTRYP PFNGLLABELOBJECTEXTPROC)(GLenum type, - GLuint object, - GLsizei length, - const GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC)(GLenum type, - GLuint object, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glLabelObjectEXT(GLenum type, - GLuint object, - GLsizei length, - const GLchar* label); -GL_APICALL void GL_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(GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, - const GLchar* marker); -typedef void(GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, - const GLchar* marker); -typedef void(GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT(GLsizei length, - const GLchar* marker); -GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT(GLsizei length, - const GLchar* marker); -GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT(void); -#endif -#endif /* GL_EXT_debug_marker */ - -#ifndef GL_EXT_discard_framebuffer -#define GL_EXT_discard_framebuffer 1 -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -typedef void(GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT(GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -#endif -#endif /* GL_EXT_discard_framebuffer */ - -#ifndef GL_EXT_disjoint_timer_query -#define GL_EXT_disjoint_timer_query 1 -#define GL_QUERY_COUNTER_BITS_EXT 0x8864 -#define GL_CURRENT_QUERY_EXT 0x8865 -#define GL_QUERY_RESULT_EXT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 -#define GL_TIME_ELAPSED_EXT 0x88BF -#define GL_TIMESTAMP_EXT 0x8E28 -#define GL_GPU_DISJOINT_EXT 0x8FBB -typedef void(GL_APIENTRYP PFNGLGENQUERIESEXTPROC)(GLsizei n, GLuint* ids); -typedef void(GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC)(GLsizei n, - const GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISQUERYEXTPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLBEGINQUERYEXTPROC)(GLenum target, GLuint id); -typedef void(GL_APIENTRYP PFNGLENDQUERYEXTPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC)(GLuint id, GLenum target); -typedef void(GL_APIENTRYP PFNGLGETQUERYIVEXTPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC)(GLuint id, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC)(GLuint id, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC)(GLuint id, - GLenum pname, - GLint64* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC)(GLuint id, - GLenum pname, - GLuint64* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids); -GL_APICALL void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT(GLuint id); -GL_APICALL void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glEndQueryEXT(GLenum target); -GL_APICALL void GL_APIENTRY glQueryCounterEXT(GLuint id, GLenum target); -GL_APICALL void GL_APIENTRY glGetQueryivEXT(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT(GLuint id, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT(GLuint id, - GLenum pname, - GLint64* params); -GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT(GLuint id, - GLenum pname, - GLuint64* params); -#endif -#endif /* GL_EXT_disjoint_timer_query */ - -#ifndef GL_EXT_draw_buffers -#define GL_EXT_draw_buffers 1 -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 -#define GL_DRAW_BUFFER0_EXT 0x8825 -#define GL_DRAW_BUFFER1_EXT 0x8826 -#define GL_DRAW_BUFFER2_EXT 0x8827 -#define GL_DRAW_BUFFER3_EXT 0x8828 -#define GL_DRAW_BUFFER4_EXT 0x8829 -#define GL_DRAW_BUFFER5_EXT 0x882A -#define GL_DRAW_BUFFER6_EXT 0x882B -#define GL_DRAW_BUFFER7_EXT 0x882C -#define GL_DRAW_BUFFER8_EXT 0x882D -#define GL_DRAW_BUFFER9_EXT 0x882E -#define GL_DRAW_BUFFER10_EXT 0x882F -#define GL_DRAW_BUFFER11_EXT 0x8830 -#define GL_DRAW_BUFFER12_EXT 0x8831 -#define GL_DRAW_BUFFER13_EXT 0x8832 -#define GL_DRAW_BUFFER14_EXT 0x8833 -#define GL_DRAW_BUFFER15_EXT 0x8834 -#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 -typedef void(GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC)(GLsizei n, - const GLenum* bufs); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum* bufs); -#endif -#endif /* GL_EXT_draw_buffers */ - -#ifndef GL_EXT_draw_buffers_indexed -#define GL_EXT_draw_buffers_indexed 1 -typedef void(GL_APIENTRYP PFNGLENABLEIEXTPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLDISABLEIEXTPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC)(GLuint buf, GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC)(GLuint buf, - GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC)(GLuint buf, - GLenum src, - GLenum dst); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC)(GLuint buf, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -typedef void(GL_APIENTRYP PFNGLCOLORMASKIEXTPROC)(GLuint index, - GLboolean r, - GLboolean g, - GLboolean b, - GLboolean a); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDIEXTPROC)(GLenum target, - GLuint index); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEnableiEXT(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glDisableiEXT(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glBlendEquationiEXT(GLuint buf, GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT(GLuint buf, - GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunciEXT(GLuint buf, GLenum src, GLenum dst); -GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT(GLuint buf, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -GL_APICALL void GL_APIENTRY glColorMaskiEXT(GLuint index, - GLboolean r, - GLboolean g, - GLboolean b, - GLboolean a); -GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT(GLenum target, GLuint index); -#endif -#endif /* GL_EXT_draw_buffers_indexed */ - -#ifndef GL_EXT_draw_elements_base_vertex -#define GL_EXT_draw_elements_base_vertex 1 -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC)( - GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC)( - GLenum mode, - const GLsizei* count, - GLenum type, - const void* const* indices, - GLsizei primcount, - const GLint* basevertex); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glDrawRangeElementsBaseVertexEXT(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glDrawElementsInstancedBaseVertexEXT(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glMultiDrawElementsBaseVertexEXT(GLenum mode, - const GLsizei* count, - GLenum type, - const void* const* indices, - GLsizei primcount, - const GLint* basevertex); -#endif -#endif /* GL_EXT_draw_elements_base_vertex */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC)(GLenum mode, - GLint start, - GLsizei count, - GLsizei primcount); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT(GLenum mode, - GLint start, - GLsizei count, - GLsizei primcount); -GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -#endif -#endif /* GL_EXT_draw_instanced */ - -#ifndef GL_EXT_float_blend -#define GL_EXT_float_blend 1 -#endif /* GL_EXT_float_blend */ - -#ifndef GL_EXT_geometry_point_size -#define GL_EXT_geometry_point_size 1 -#endif /* GL_EXT_geometry_point_size */ - -#ifndef GL_EXT_geometry_shader -#define GL_EXT_geometry_shader 1 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004 -#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916 -#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917 -#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918 -#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F -#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E -#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_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124 -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5 -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7 -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_UNDEFINED_VERTEX_EXT 0x8260 -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312 -#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309 -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glFramebufferTextureEXT(GLenum target, - GLenum attachment, - GLuint texture, - GLint level); -#endif -#endif /* GL_EXT_geometry_shader */ - -#ifndef GL_EXT_gpu_shader5 -#define GL_EXT_gpu_shader5 1 -#endif /* GL_EXT_gpu_shader5 */ - -#ifndef GL_EXT_instanced_arrays -#define GL_EXT_instanced_arrays 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC)(GLuint index, - GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT(GLuint index, - GLuint divisor); -#endif -#endif /* GL_EXT_instanced_arrays */ - -#ifndef GL_EXT_map_buffer_range -#define GL_EXT_map_buffer_range 1 -#define GL_MAP_READ_BIT_EXT 0x0001 -#define GL_MAP_WRITE_BIT_EXT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 -typedef void*(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -typedef void(GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC)( - GLenum target, - GLintptr offset, - GLsizeiptr length); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT(GLenum target, - GLintptr offset, - GLsizeiptr length); -#endif -#endif /* GL_EXT_map_buffer_range */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -typedef void(GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC)(GLenum mode, - const GLint* first, - const GLsizei* count, - GLsizei primcount); -typedef void(GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC)( - GLenum mode, - const GLsizei* count, - GLenum type, - const void* const* indices, - GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT(GLenum mode, - const GLint* first, - const GLsizei* count, - GLsizei primcount); -GL_APICALL void GL_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_multi_draw_indirect -#define GL_EXT_multi_draw_indirect 1 -typedef void(GL_APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC)( - GLenum mode, - const void* indirect, - GLsizei drawcount, - GLsizei stride); -typedef void(GL_APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC)( - GLenum mode, - GLenum type, - const void* indirect, - GLsizei drawcount, - GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysIndirectEXT(GLenum mode, - const void* indirect, - GLsizei drawcount, - GLsizei stride); -GL_APICALL void GL_APIENTRY glMultiDrawElementsIndirectEXT(GLenum mode, - GLenum type, - const void* indirect, - GLsizei drawcount, - GLsizei stride); -#endif -#endif /* GL_EXT_multi_draw_indirect */ - -#ifndef GL_EXT_multisampled_compatibility -#define GL_EXT_multisampled_compatibility 1 -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#endif /* GL_EXT_multisampled_compatibility */ - -#ifndef GL_EXT_multisampled_render_to_texture -#define GL_EXT_multisampled_render_to_texture 1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)( - GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisampleEXT(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY -glFramebufferTexture2DMultisampleEXT(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples); -#endif -#endif /* GL_EXT_multisampled_render_to_texture */ - -#ifndef GL_EXT_multiview_draw_buffers -#define GL_EXT_multiview_draw_buffers 1 -#define GL_COLOR_ATTACHMENT_EXT 0x90F0 -#define GL_MULTIVIEW_EXT 0x90F1 -#define GL_DRAW_BUFFER_EXT 0x0C01 -#define GL_READ_BUFFER_EXT 0x0C02 -#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 -typedef void(GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC)(GLenum src, - GLint index); -typedef void(GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC)( - GLint n, - const GLenum* location, - const GLint* indices); -typedef void(GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC)(GLenum target, - GLuint index, - GLint* data); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT(GLenum src, GLint index); -GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT(GLint n, - const GLenum* location, - const GLint* indices); -GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT(GLenum target, - GLuint index, - GLint* data); -#endif -#endif /* GL_EXT_multiview_draw_buffers */ - -#ifndef GL_EXT_occlusion_query_boolean -#define GL_EXT_occlusion_query_boolean 1 -#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A -#endif /* GL_EXT_occlusion_query_boolean */ - -#ifndef GL_EXT_post_depth_coverage -#define GL_EXT_post_depth_coverage 1 -#endif /* GL_EXT_post_depth_coverage */ - -#ifndef GL_EXT_primitive_bounding_box -#define GL_EXT_primitive_bounding_box 1 -#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE -typedef void(GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC)(GLfloat minX, - GLfloat minY, - GLfloat minZ, - GLfloat minW, - GLfloat maxX, - GLfloat maxY, - GLfloat maxZ, - GLfloat maxW); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT(GLfloat minX, - GLfloat minY, - GLfloat minZ, - GLfloat minW, - GLfloat maxX, - GLfloat maxY, - GLfloat maxZ, - GLfloat maxW); -#endif -#endif /* GL_EXT_primitive_bounding_box */ - -#ifndef GL_EXT_pvrtc_sRGB -#define GL_EXT_pvrtc_sRGB 1 -#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 -#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 -#endif /* GL_EXT_pvrtc_sRGB */ - -#ifndef GL_EXT_raster_multisample -#define GL_EXT_raster_multisample 1 -#define GL_RASTER_MULTISAMPLE_EXT 0x9327 -#define GL_RASTER_SAMPLES_EXT 0x9328 -#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 -#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A -#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B -#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C -typedef void(GL_APIENTRYP PFNGLRASTERSAMPLESEXTPROC)( - GLuint samples, - GLboolean fixedsamplelocations); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRasterSamplesEXT(GLuint samples, - GLboolean fixedsamplelocations); -#endif -#endif /* GL_EXT_raster_multisample */ - -#ifndef GL_EXT_read_format_bgra -#define GL_EXT_read_format_bgra 1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif /* GL_EXT_read_format_bgra */ - -#ifndef GL_EXT_render_snorm -#define GL_EXT_render_snorm 1 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM_EXT 0x8F98 -#define GL_RG16_SNORM_EXT 0x8F99 -#define GL_RGBA16_SNORM_EXT 0x8F9B -#endif /* GL_EXT_render_snorm */ - -#ifndef GL_EXT_robustness -#define GL_EXT_robustness 1 -#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 -#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 -#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 -#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 -#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 -typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC)(void); -typedef void(GL_APIENTRYP PFNGLREADNPIXELSEXTPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void); -GL_APICALL void GL_APIENTRY glReadnPixelsEXT(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data); -GL_APICALL void GL_APIENTRY glGetnUniformfvEXT(GLuint program, - GLint location, - GLsizei bufSize, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetnUniformivEXT(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params); -#endif -#endif /* GL_EXT_robustness */ - -#ifndef GL_EXT_sRGB -#define GL_EXT_sRGB 1 -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 -#endif /* GL_EXT_sRGB */ - -#ifndef GL_EXT_sRGB_write_control -#define GL_EXT_sRGB_write_control 1 -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#endif /* GL_EXT_sRGB_write_control */ - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 -#define GL_ACTIVE_PROGRAM_EXT 0x8259 -#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 -#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE_EXT 0x8258 -#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A -typedef void(GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC)(GLuint pipeline, - GLuint program); -typedef void(GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC)(GLuint pipeline); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC)( - GLenum type, - GLsizei count, - const GLchar** strings); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC)( - GLsizei n, - const GLuint* pipelines); -typedef void(GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC)(GLsizei n, - GLuint* pipelines); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC)( - GLuint pipeline, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC)(GLuint pipeline, - GLenum pname, - GLint* params); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC)(GLuint program, - GLenum pname, - GLint value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC)(GLuint program, - GLint location, - GLfloat v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC)(GLuint program, - GLint location, - GLint v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC)(GLuint pipeline, - GLbitfield stages, - GLuint program); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC)(GLuint program, - GLint location, - GLuint v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT(GLuint pipeline, - GLuint program); -GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT(GLuint pipeline); -GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT(GLenum type, - GLsizei count, - const GLchar** strings); -GL_APICALL void GL_APIENTRY -glDeleteProgramPipelinesEXT(GLsizei n, const GLuint* pipelines); -GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT(GLsizei n, - GLuint* pipelines); -GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT(GLuint pipeline, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT(GLuint pipeline, - GLenum pname, - GLint* params); -GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT(GLuint pipeline); -GL_APICALL void GL_APIENTRY glProgramParameteriEXT(GLuint program, - GLenum pname, - GLint value); -GL_APICALL void GL_APIENTRY glProgramUniform1fEXT(GLuint program, - GLint location, - GLfloat v0); -GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform1iEXT(GLuint program, - GLint location, - GLint v0); -GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform2fEXT(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1); -GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform2iEXT(GLuint program, - GLint location, - GLint v0, - GLint v1); -GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform3fEXT(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform3iEXT(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform4fEXT(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform4iEXT(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgramStagesEXT(GLuint pipeline, - GLbitfield stages, - GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT(GLuint pipeline); -GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT(GLuint program, - GLint location, - GLuint v0); -GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT(GLuint program, - GLint location, - GLuint v0, - GLuint v1); -GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY -glProgramUniformMatrix2x3fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glProgramUniformMatrix3x2fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glProgramUniformMatrix2x4fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glProgramUniformMatrix4x2fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glProgramUniformMatrix3x4fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glProgramUniformMatrix4x3fvEXT(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -#endif -#endif /* GL_EXT_separate_shader_objects */ - -#ifndef GL_EXT_shader_framebuffer_fetch -#define GL_EXT_shader_framebuffer_fetch 1 -#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 -#endif /* GL_EXT_shader_framebuffer_fetch */ - -#ifndef GL_EXT_shader_implicit_conversions -#define GL_EXT_shader_implicit_conversions 1 -#endif /* GL_EXT_shader_implicit_conversions */ - -#ifndef GL_EXT_shader_integer_mix -#define GL_EXT_shader_integer_mix 1 -#endif /* GL_EXT_shader_integer_mix */ - -#ifndef GL_EXT_shader_io_blocks -#define GL_EXT_shader_io_blocks 1 -#endif /* GL_EXT_shader_io_blocks */ - -#ifndef GL_EXT_shader_pixel_local_storage -#define GL_EXT_shader_pixel_local_storage 1 -#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 -#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67 -#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 -#endif /* GL_EXT_shader_pixel_local_storage */ - -#ifndef GL_EXT_shader_texture_lod -#define GL_EXT_shader_texture_lod 1 -#endif /* GL_EXT_shader_texture_lod */ - -#ifndef GL_EXT_shadow_samplers -#define GL_EXT_shadow_samplers 1 -#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C -#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D -#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E -#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 -#endif /* GL_EXT_shadow_samplers */ - -#ifndef GL_EXT_sparse_texture -#define GL_EXT_sparse_texture 1 -#define GL_TEXTURE_SPARSE_EXT 0x91A6 -#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7 -#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA -#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8 -#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_TEXTURE_3D 0x806F -#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A -#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9 -typedef void(GL_APIENTRYP PFNGLTEXPAGECOMMITMENTEXTPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLboolean commit); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexPageCommitmentEXT(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLboolean commit); -#endif -#endif /* GL_EXT_sparse_texture */ - -#ifndef GL_EXT_tessellation_point_size -#define GL_EXT_tessellation_point_size 1 -#endif /* GL_EXT_tessellation_point_size */ - -#ifndef GL_EXT_tessellation_shader -#define GL_EXT_tessellation_shader 1 -#define GL_PATCHES_EXT 0x000E -#define GL_PATCH_VERTICES_EXT 0x8E72 -#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75 -#define GL_TESS_GEN_MODE_EXT 0x8E76 -#define GL_TESS_GEN_SPACING_EXT 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78 -#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79 -#define GL_ISOLINES_EXT 0x8E7A -#define GL_QUADS_EXT 0x0007 -#define GL_FRACTIONAL_ODD_EXT 0x8E7B -#define GL_FRACTIONAL_EVEN_EXT 0x8E7C -#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4 -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9 -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define GL_IS_PER_PATCH_EXT 0x92E7 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308 -#define GL_TESS_CONTROL_SHADER_EXT 0x8E88 -#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87 -#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010 -typedef void(GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC)(GLenum pname, - GLint value); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glPatchParameteriEXT(GLenum pname, GLint value); -#endif -#endif /* GL_EXT_tessellation_shader */ - -#ifndef GL_EXT_texture_border_clamp -#define GL_EXT_texture_border_clamp 1 -#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004 -#define GL_CLAMP_TO_BORDER_EXT 0x812D -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC)(GLenum target, - GLenum pname, - const GLuint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC)(GLenum target, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, - GLenum pname, - const GLint* param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC)( - GLuint sampler, - GLenum pname, - const GLuint* param); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC)(GLuint sampler, - GLenum pname, - GLuint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexParameterIivEXT(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexParameterIuivEXT(GLenum target, - GLenum pname, - const GLuint* params); -GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT(GLenum target, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT(GLuint sampler, - GLenum pname, - const GLint* param); -GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT(GLuint sampler, - GLenum pname, - const GLuint* param); -GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT(GLuint sampler, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT(GLuint sampler, - GLenum pname, - GLuint* params); -#endif -#endif /* GL_EXT_texture_border_clamp */ - -#ifndef GL_EXT_texture_buffer -#define GL_EXT_texture_buffer 1 -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_TEXTURE_BUFFER_BINDING_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_OFFSET_ALIGNMENT_EXT 0x919F -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D -#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E -typedef void(GL_APIENTRYP PFNGLTEXBUFFEREXTPROC)(GLenum target, - GLenum internalformat, - GLuint buffer); -typedef void(GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC)(GLenum target, - GLenum internalformat, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexBufferEXT(GLenum target, - GLenum internalformat, - GLuint buffer); -GL_APICALL void GL_APIENTRY glTexBufferRangeEXT(GLenum target, - GLenum internalformat, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -#endif -#endif /* GL_EXT_texture_buffer */ - -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#endif /* GL_EXT_texture_compression_dxt1 */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 -#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_array -#define GL_EXT_texture_cube_map_array 1 -#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A -#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#endif /* GL_EXT_texture_cube_map_array */ - -#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_filter_minmax -#define GL_EXT_texture_filter_minmax 1 -#endif /* GL_EXT_texture_filter_minmax */ - -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_EXT_texture_format_BGRA8888 1 -#endif /* GL_EXT_texture_format_BGRA8888 */ - -#ifndef GL_EXT_texture_norm16 -#define GL_EXT_texture_norm16 1 -#define GL_R16_EXT 0x822A -#define GL_RG16_EXT 0x822C -#define GL_RGBA16_EXT 0x805B -#define GL_RGB16_EXT 0x8054 -#define GL_RGB16_SNORM_EXT 0x8F9A -#endif /* GL_EXT_texture_norm16 */ - -#ifndef GL_EXT_texture_rg -#define GL_EXT_texture_rg 1 -#define GL_RED_EXT 0x1903 -#define GL_RG_EXT 0x8227 -#define GL_R8_EXT 0x8229 -#define GL_RG8_EXT 0x822B -#endif /* GL_EXT_texture_rg */ - -#ifndef GL_EXT_texture_sRGB_R8 -#define GL_EXT_texture_sRGB_R8 1 -#define GL_SR8_EXT 0x8FBD -#endif /* GL_EXT_texture_sRGB_R8 */ - -#ifndef GL_EXT_texture_sRGB_RG8 -#define GL_EXT_texture_sRGB_RG8 1 -#define GL_SRG8_EXT 0x8FBE -#endif /* GL_EXT_texture_sRGB_RG8 */ - -#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_storage -#define GL_EXT_texture_storage 1 -#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F -#define GL_ALPHA8_EXT 0x803C -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_RGBA32F_EXT 0x8814 -#define GL_RGB32F_EXT 0x8815 -#define GL_ALPHA32F_EXT 0x8816 -#define GL_LUMINANCE32F_EXT 0x8818 -#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 -#define GL_ALPHA16F_EXT 0x881C -#define GL_LUMINANCE16F_EXT 0x881E -#define GL_LUMINANCE_ALPHA16F_EXT 0x881F -#define GL_R32F_EXT 0x822E -#define GL_RG32F_EXT 0x8230 -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -typedef void(GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC)(GLuint texture, - GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width); -typedef void(GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC)(GLuint texture, - GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC)(GLuint texture, - GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexStorage1DEXT(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width); -GL_APICALL void GL_APIENTRY glTexStorage2DEXT(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage3DEXT(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -GL_APICALL void GL_APIENTRY glTextureStorage1DEXT(GLuint texture, - GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width); -GL_APICALL void GL_APIENTRY glTextureStorage2DEXT(GLuint texture, - GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTextureStorage3DEXT(GLuint texture, - GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -#endif -#endif /* GL_EXT_texture_storage */ - -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_EXT_texture_type_2_10_10_10_REV 1 -#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#endif /* GL_EXT_texture_type_2_10_10_10_REV */ - -#ifndef GL_EXT_texture_view -#define GL_EXT_texture_view 1 -#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE -typedef void(GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC)(GLuint texture, - GLenum target, - GLuint origtexture, - GLenum internalformat, - GLuint minlevel, - GLuint numlevels, - GLuint minlayer, - GLuint numlayers); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTextureViewEXT(GLuint texture, - GLenum target, - GLuint origtexture, - GLenum internalformat, - GLuint minlevel, - GLuint numlevels, - GLuint minlayer, - GLuint numlayers); -#endif -#endif /* GL_EXT_texture_view */ - -#ifndef GL_EXT_unpack_subimage -#define GL_EXT_unpack_subimage 1 -#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 -#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 -#endif /* GL_EXT_unpack_subimage */ - -#ifndef GL_FJ_shader_binary_GCCSO -#define GL_FJ_shader_binary_GCCSO 1 -#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 -#endif /* GL_FJ_shader_binary_GCCSO */ - -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_IMG_multisampled_render_to_texture 1 -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC)( - GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisampleIMG(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY -glFramebufferTexture2DMultisampleIMG(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level, - GLsizei samples); -#endif -#endif /* GL_IMG_multisampled_render_to_texture */ - -#ifndef GL_IMG_program_binary -#define GL_IMG_program_binary 1 -#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 -#endif /* GL_IMG_program_binary */ - -#ifndef GL_IMG_read_format -#define GL_IMG_read_format 1 -#define GL_BGRA_IMG 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#endif /* GL_IMG_read_format */ - -#ifndef GL_IMG_shader_binary -#define GL_IMG_shader_binary 1 -#define GL_SGX_BINARY_IMG 0x8C0A -#endif /* GL_IMG_shader_binary */ - -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif /* GL_IMG_texture_compression_pvrtc */ - -#ifndef GL_IMG_texture_compression_pvrtc2 -#define GL_IMG_texture_compression_pvrtc2 1 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 -#endif /* GL_IMG_texture_compression_pvrtc2 */ - -#ifndef GL_INTEL_framebuffer_CMAA -#define GL_INTEL_framebuffer_CMAA 1 -typedef void(GL_APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glApplyFramebufferAttachmentCMAAINTEL(void); -#endif -#endif /* GL_INTEL_framebuffer_CMAA */ - -#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(GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC)(GLuint queryHandle); -typedef void(GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC)(GLuint queryId, - GLuint* queryHandle); -typedef void(GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC)(GLuint queryHandle); -typedef void(GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC)(GLuint queryHandle); -typedef void(GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC)(GLuint* queryId); -typedef void(GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC)( - GLuint queryId, - GLuint* nextQueryId); -typedef void(GL_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(GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC)(GLuint queryHandle, - GLuint flags, - GLsizei dataSize, - GLvoid* data, - GLuint* bytesWritten); -typedef void(GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC)(GLchar* queryName, - GLuint* queryId); -typedef void(GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC)( - GLuint queryId, - GLuint queryNameLength, - GLchar* queryName, - GLuint* dataSize, - GLuint* noCounters, - GLuint* noInstances, - GLuint* capsMask); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL(GLuint queryHandle); -GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL(GLuint queryId, - GLuint* queryHandle); -GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL(GLuint queryHandle); -GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL(GLuint queryHandle); -GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL(GLuint* queryId); -GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL(GLuint queryId, - GLuint* nextQueryId); -GL_APICALL void GL_APIENTRY -glGetPerfCounterInfoINTEL(GLuint queryId, - GLuint counterId, - GLuint counterNameLength, - GLchar* counterName, - GLuint counterDescLength, - GLchar* counterDesc, - GLuint* counterOffset, - GLuint* counterDataSize, - GLuint* counterTypeEnum, - GLuint* counterDataTypeEnum, - GLuint64* rawCounterMaxValue); -GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL(GLuint queryHandle, - GLuint flags, - GLsizei dataSize, - GLvoid* data, - GLuint* bytesWritten); -GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL(GLchar* queryName, - GLuint* queryId); -GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL(GLuint queryId, - GLuint queryNameLength, - GLchar* queryName, - GLuint* dataSize, - GLuint* noCounters, - GLuint* noInstances, - GLuint* capsMask); -#endif -#endif /* GL_INTEL_performance_query */ - -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -typedef GLuint64(GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC)(GLuint texture); -typedef GLuint64(GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC)( - GLuint texture, - GLuint sampler); -typedef void(GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC)( - GLuint64 handle); -typedef void(GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC)( - GLuint64 handle); -typedef GLuint64(GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC)(GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum format); -typedef void(GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC)(GLuint64 handle, - GLenum access); -typedef void(GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC)( - GLuint64 handle); -typedef void(GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC)(GLint location, - GLuint64 value); -typedef void(GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC)(GLint location, - GLsizei count, - const GLuint64* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC)(GLuint program, - GLint location, - GLuint64 value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC)( - GLuint program, - GLint location, - GLsizei count, - const GLuint64* values); -typedef GLboolean(GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC)( - GLuint64 handle); -typedef GLboolean(GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC)( - GLuint64 handle); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV(GLuint texture); -GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV(GLuint texture, - GLuint sampler); -GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV(GLuint64 handle); -GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV(GLuint64 handle); -GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV(GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum format); -GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV(GLuint64 handle, - GLenum access); -GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV(GLuint64 handle); -GL_APICALL void GL_APIENTRY glUniformHandleui64NV(GLint location, - GLuint64 value); -GL_APICALL void GL_APIENTRY glUniformHandleui64vNV(GLint location, - GLsizei count, - const GLuint64* value); -GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV(GLuint program, - GLint location, - GLuint64 value); -GL_APICALL void GL_APIENTRY -glProgramUniformHandleui64vNV(GLuint program, - GLint location, - GLsizei count, - const GLuint64* values); -GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV(GLuint64 handle); -GL_APICALL GLboolean GL_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(GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC)(GLenum pname, - GLint value); -typedef void(GL_APIENTRYP PFNGLBLENDBARRIERNVPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlendParameteriNV(GLenum pname, GLint value); -GL_APICALL void GL_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_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(GL_APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC)(GLuint id, - GLenum mode); -typedef void(GL_APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBeginConditionalRenderNV(GLuint id, GLenum mode); -GL_APICALL void GL_APIENTRY glEndConditionalRenderNV(void); -#endif -#endif /* GL_NV_conditional_render */ - -#ifndef GL_NV_conservative_raster -#define GL_NV_conservative_raster 1 -#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 -#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 -#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 -#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 -typedef void(GL_APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC)(GLuint xbits, - GLuint ybits); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV(GLuint xbits, - GLuint ybits); -#endif -#endif /* GL_NV_conservative_raster */ - -#ifndef GL_NV_copy_buffer -#define GL_NV_copy_buffer 1 -#define GL_COPY_READ_BUFFER_NV 0x8F36 -#define GL_COPY_WRITE_BUFFER_NV 0x8F37 -typedef void(GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC)(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -#endif -#endif /* GL_NV_copy_buffer */ - -#ifndef GL_NV_coverage_sample -#define GL_NV_coverage_sample 1 -#define GL_COVERAGE_COMPONENT_NV 0x8ED0 -#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 -#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 -#define GL_COVERAGE_BUFFERS_NV 0x8ED3 -#define GL_COVERAGE_SAMPLES_NV 0x8ED4 -#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 -#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 -#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 -typedef void(GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC)(GLboolean mask); -typedef void(GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC)(GLenum operation); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageMaskNV(GLboolean mask); -GL_APICALL void GL_APIENTRY glCoverageOperationNV(GLenum operation); -#endif -#endif /* GL_NV_coverage_sample */ - -#ifndef GL_NV_depth_nonlinear -#define GL_NV_depth_nonlinear 1 -#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C -#endif /* GL_NV_depth_nonlinear */ - -#ifndef GL_NV_draw_buffers -#define GL_NV_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_NV 0x8824 -#define GL_DRAW_BUFFER0_NV 0x8825 -#define GL_DRAW_BUFFER1_NV 0x8826 -#define GL_DRAW_BUFFER2_NV 0x8827 -#define GL_DRAW_BUFFER3_NV 0x8828 -#define GL_DRAW_BUFFER4_NV 0x8829 -#define GL_DRAW_BUFFER5_NV 0x882A -#define GL_DRAW_BUFFER6_NV 0x882B -#define GL_DRAW_BUFFER7_NV 0x882C -#define GL_DRAW_BUFFER8_NV 0x882D -#define GL_DRAW_BUFFER9_NV 0x882E -#define GL_DRAW_BUFFER10_NV 0x882F -#define GL_DRAW_BUFFER11_NV 0x8830 -#define GL_DRAW_BUFFER12_NV 0x8831 -#define GL_DRAW_BUFFER13_NV 0x8832 -#define GL_DRAW_BUFFER14_NV 0x8833 -#define GL_DRAW_BUFFER15_NV 0x8834 -#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 -#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 -#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 -#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 -#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 -#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 -#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 -#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 -#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 -#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 -#define GL_COLOR_ATTACHMENT10_NV 0x8CEA -#define GL_COLOR_ATTACHMENT11_NV 0x8CEB -#define GL_COLOR_ATTACHMENT12_NV 0x8CEC -#define GL_COLOR_ATTACHMENT13_NV 0x8CED -#define GL_COLOR_ATTACHMENT14_NV 0x8CEE -#define GL_COLOR_ATTACHMENT15_NV 0x8CEF -typedef void(GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC)(GLsizei n, - const GLenum* bufs); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawBuffersNV(GLsizei n, const GLenum* bufs); -#endif -#endif /* GL_NV_draw_buffers */ - -#ifndef GL_NV_draw_instanced -#define GL_NV_draw_instanced 1 -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC)(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV(GLenum mode, - GLint first, - GLsizei count, - GLsizei primcount); -GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei primcount); -#endif -#endif /* GL_NV_draw_instanced */ - -#ifndef GL_NV_explicit_attrib_location -#define GL_NV_explicit_attrib_location 1 -#endif /* GL_NV_explicit_attrib_location */ - -#ifndef GL_NV_fbo_color_attachments -#define GL_NV_fbo_color_attachments 1 -#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF -#endif /* GL_NV_fbo_color_attachments */ - -#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(GL_APIENTRYP PFNGLDELETEFENCESNVPROC)(GLsizei n, - const GLuint* fences); -typedef void(GL_APIENTRYP PFNGLGENFENCESNVPROC)(GLsizei n, GLuint* fences); -typedef GLboolean(GL_APIENTRYP PFNGLISFENCENVPROC)(GLuint fence); -typedef GLboolean(GL_APIENTRYP PFNGLTESTFENCENVPROC)(GLuint fence); -typedef void(GL_APIENTRYP PFNGLGETFENCEIVNVPROC)(GLuint fence, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLFINISHFENCENVPROC)(GLuint fence); -typedef void(GL_APIENTRYP PFNGLSETFENCENVPROC)(GLuint fence, GLenum condition); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences); -GL_APICALL void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences); -GL_APICALL GLboolean GL_APIENTRY glIsFenceNV(GLuint fence); -GL_APICALL GLboolean GL_APIENTRY glTestFenceNV(GLuint fence); -GL_APICALL void GL_APIENTRY glGetFenceivNV(GLuint fence, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glFinishFenceNV(GLuint fence); -GL_APICALL void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition); -#endif -#endif /* GL_NV_fence */ - -#ifndef GL_NV_fill_rectangle -#define GL_NV_fill_rectangle 1 -#define GL_FILL_RECTANGLE_NV 0x933C -#endif /* GL_NV_fill_rectangle */ - -#ifndef GL_NV_fragment_coverage_to_color -#define GL_NV_fragment_coverage_to_color 1 -#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD -#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE -typedef void(GL_APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC)(GLuint color); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glFragmentCoverageColorNV(GLuint color); -#endif -#endif /* GL_NV_fragment_coverage_to_color */ - -#ifndef GL_NV_fragment_shader_interlock -#define GL_NV_fragment_shader_interlock 1 -#endif /* GL_NV_fragment_shader_interlock */ - -#ifndef GL_NV_framebuffer_blit -#define GL_NV_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_NV 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA -typedef void(GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferNV(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -#endif -#endif /* GL_NV_framebuffer_blit */ - -#ifndef GL_NV_framebuffer_mixed_samples -#define GL_NV_framebuffer_mixed_samples 1 -#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#define GL_DEPTH_SAMPLES_NV 0x932D -#define GL_STENCIL_SAMPLES_NV 0x932E -#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F -#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 -#define GL_COVERAGE_MODULATION_NV 0x9332 -#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 -typedef void(GL_APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC)(GLsizei n, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC)( - GLsizei bufsize, - GLfloat* v); -typedef void(GL_APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC)(GLenum components); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageModulationTableNV(GLsizei n, - const GLfloat* v); -GL_APICALL void GL_APIENTRY glGetCoverageModulationTableNV(GLsizei bufsize, - GLfloat* v); -GL_APICALL void GL_APIENTRY glCoverageModulationNV(GLenum components); -#endif -#endif /* GL_NV_framebuffer_mixed_samples */ - -#ifndef GL_NV_framebuffer_multisample -#define GL_NV_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 -#define GL_MAX_SAMPLES_NV 0x8D57 -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisampleNV(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -#endif -#endif /* GL_NV_framebuffer_multisample */ - -#ifndef GL_NV_generate_mipmap_sRGB -#define GL_NV_generate_mipmap_sRGB 1 -#endif /* GL_NV_generate_mipmap_sRGB */ - -#ifndef GL_NV_geometry_shader_passthrough -#define GL_NV_geometry_shader_passthrough 1 -#endif /* GL_NV_geometry_shader_passthrough */ - -#ifndef GL_NV_image_formats -#define GL_NV_image_formats 1 -#endif /* GL_NV_image_formats */ - -#ifndef GL_NV_instanced_arrays -#define GL_NV_instanced_arrays 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC)(GLuint index, - GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV(GLuint index, - GLuint divisor); -#endif -#endif /* GL_NV_instanced_arrays */ - -#ifndef GL_NV_internalformat_sample_query -#define GL_NV_internalformat_sample_query 1 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_MULTISAMPLES_NV 0x9371 -#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 -#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 -#define GL_CONFORMANT_NV 0x9374 -typedef void(GL_APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC)( - GLenum target, - GLenum internalformat, - GLsizei samples, - GLenum pname, - GLsizei bufSize, - GLint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV(GLenum target, - GLenum internalformat, - GLsizei samples, - GLenum pname, - GLsizei bufSize, - GLint* params); -#endif -#endif /* GL_NV_internalformat_sample_query */ - -#ifndef GL_NV_non_square_matrices -#define GL_NV_non_square_matrices 1 -#define GL_FLOAT_MAT2x3_NV 0x8B65 -#define GL_FLOAT_MAT2x4_NV 0x8B66 -#define GL_FLOAT_MAT3x2_NV 0x8B67 -#define GL_FLOAT_MAT3x4_NV 0x8B68 -#define GL_FLOAT_MAT4x2_NV 0x8B69 -#define GL_FLOAT_MAT4x3_NV 0x8B6A -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -#endif -#endif /* GL_NV_non_square_matrices */ - -#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_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_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_ROUNDED_RECT_NV 0xE8 -#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 -#define GL_ROUNDED_RECT2_NV 0xEA -#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB -#define GL_ROUNDED_RECT4_NV 0xEC -#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED -#define GL_ROUNDED_RECT8_NV 0xEE -#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF -#define GL_RELATIVE_RECT_NV 0xF7 -#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 -#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 -#define GL_FONT_UNAVAILABLE_NV 0x936A -#define GL_FONT_UNINTELLIGIBLE_NV 0x936B -#define GL_CONIC_CURVE_TO_NV 0x1A -#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B -#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 -#define GL_STANDARD_FONT_FORMAT_NV 0x936C -#define GL_PATH_PROJECTION_NV 0x1701 -#define GL_PATH_MODELVIEW_NV 0x1700 -#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 -#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 -#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 -#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 -#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 -#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 -#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 -#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 -#define GL_FRAGMENT_INPUT_NV 0x936D -typedef GLuint(GL_APIENTRYP PFNGLGENPATHSNVPROC)(GLsizei range); -typedef void(GL_APIENTRYP PFNGLDELETEPATHSNVPROC)(GLuint path, GLsizei range); -typedef GLboolean(GL_APIENTRYP PFNGLISPATHNVPROC)(GLuint path); -typedef void(GL_APIENTRYP PFNGLPATHCOMMANDSNVPROC)(GLuint path, - GLsizei numCommands, - const GLubyte* commands, - GLsizei numCoords, - GLenum coordType, - const void* coords); -typedef void(GL_APIENTRYP PFNGLPATHCOORDSNVPROC)(GLuint path, - GLsizei numCoords, - GLenum coordType, - const void* coords); -typedef void(GL_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC)(GLuint path, - GLsizei commandStart, - GLsizei commandsToDelete, - GLsizei numCommands, - const GLubyte* commands, - GLsizei numCoords, - GLenum coordType, - const void* coords); -typedef void(GL_APIENTRYP PFNGLPATHSUBCOORDSNVPROC)(GLuint path, - GLsizei coordStart, - GLsizei numCoords, - GLenum coordType, - const void* coords); -typedef void(GL_APIENTRYP PFNGLPATHSTRINGNVPROC)(GLuint path, - GLenum format, - GLsizei length, - const void* pathString); -typedef void(GL_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(GL_APIENTRYP PFNGLPATHGLYPHRANGENVPROC)( - GLuint firstPathName, - GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLuint firstGlyph, - GLsizei numGlyphs, - GLenum handleMissingGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -typedef void(GL_APIENTRYP PFNGLWEIGHTPATHSNVPROC)(GLuint resultPath, - GLsizei numPaths, - const GLuint* paths, - const GLfloat* weights); -typedef void(GL_APIENTRYP PFNGLCOPYPATHNVPROC)(GLuint resultPath, - GLuint srcPath); -typedef void(GL_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC)(GLuint resultPath, - GLuint pathA, - GLuint pathB, - GLfloat weight); -typedef void(GL_APIENTRYP PFNGLTRANSFORMPATHNVPROC)( - GLuint resultPath, - GLuint srcPath, - GLenum transformType, - const GLfloat* transformValues); -typedef void(GL_APIENTRYP PFNGLPATHPARAMETERIVNVPROC)(GLuint path, - GLenum pname, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPATHPARAMETERINVPROC)(GLuint path, - GLenum pname, - GLint value); -typedef void(GL_APIENTRYP PFNGLPATHPARAMETERFVNVPROC)(GLuint path, - GLenum pname, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPATHPARAMETERFNVPROC)(GLuint path, - GLenum pname, - GLfloat value); -typedef void(GL_APIENTRYP PFNGLPATHDASHARRAYNVPROC)(GLuint path, - GLsizei dashCount, - const GLfloat* dashArray); -typedef void(GL_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC)(GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC)(GLfloat factor, - GLfloat units); -typedef void(GL_APIENTRYP PFNGLSTENCILFILLPATHNVPROC)(GLuint path, - GLenum fillMode, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC)(GLuint path, - GLint reference, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC)( - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum fillMode, - GLuint mask, - GLenum transformType, - const GLfloat* transformValues); -typedef void(GL_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC)( - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLint reference, - GLuint mask, - GLenum transformType, - const GLfloat* transformValues); -typedef void(GL_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC)(GLenum func); -typedef void(GL_APIENTRYP PFNGLCOVERFILLPATHNVPROC)(GLuint path, - GLenum coverMode); -typedef void(GL_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC)(GLuint path, - GLenum coverMode); -typedef void(GL_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC)( - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -typedef void(GL_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC)( - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -typedef void(GL_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC)(GLuint path, - GLenum pname, - GLint* value); -typedef void(GL_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC)(GLuint path, - GLenum pname, - GLfloat* value); -typedef void(GL_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC)(GLuint path, - GLubyte* commands); -typedef void(GL_APIENTRYP PFNGLGETPATHCOORDSNVPROC)(GLuint path, - GLfloat* coords); -typedef void(GL_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC)(GLuint path, - GLfloat* dashArray); -typedef void(GL_APIENTRYP PFNGLGETPATHMETRICSNVPROC)(GLbitfield metricQueryMask, - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLsizei stride, - GLfloat* metrics); -typedef void(GL_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC)( - GLbitfield metricQueryMask, - GLuint firstPathName, - GLsizei numPaths, - GLsizei stride, - GLfloat* metrics); -typedef void(GL_APIENTRYP PFNGLGETPATHSPACINGNVPROC)(GLenum pathListMode, - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLfloat advanceScale, - GLfloat kerningScale, - GLenum transformType, - GLfloat* returnedSpacing); -typedef GLboolean(GL_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC)(GLuint path, - GLuint mask, - GLfloat x, - GLfloat y); -typedef GLboolean(GL_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC)(GLuint path, - GLfloat x, - GLfloat y); -typedef GLfloat(GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC)(GLuint path, - GLsizei startSegment, - GLsizei numSegments); -typedef GLboolean(GL_APIENTRYP PFNGLPOINTALONGPATHNVPROC)(GLuint path, - GLsizei startSegment, - GLsizei numSegments, - GLfloat distance, - GLfloat* x, - GLfloat* y, - GLfloat* tangentX, - GLfloat* tangentY); -typedef void(GL_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC)(GLenum matrixMode, - const GLfloat* m); -typedef void(GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC)( - GLuint path, - GLenum fillMode, - GLuint mask, - GLenum coverMode); -typedef void(GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC)( - GLuint path, - GLint reference, - GLuint mask, - GLenum coverMode); -typedef void(GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC)( - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum fillMode, - GLuint mask, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -typedef void(GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC)( - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLint reference, - GLuint mask, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -typedef GLenum(GL_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC)( - GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLuint pathParameterTemplate, - GLfloat emScale, - GLuint baseAndCount[2]); -typedef GLenum(GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC)( - GLuint firstPathName, - GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLuint firstGlyphIndex, - GLsizei numGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -typedef GLenum(GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC)( - GLuint firstPathName, - GLenum fontTarget, - GLsizeiptr fontSize, - const void* fontData, - GLsizei faceIndex, - GLuint firstGlyphIndex, - GLsizei numGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -typedef void(GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC)( - GLuint program, - GLint location, - GLenum genMode, - GLint components, - const GLfloat* coeffs); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC)( - GLuint program, - GLenum programInterface, - GLuint index, - GLsizei propCount, - const GLenum* props, - GLsizei bufSize, - GLsizei* length, - GLfloat* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLuint GL_APIENTRY glGenPathsNV(GLsizei range); -GL_APICALL void GL_APIENTRY glDeletePathsNV(GLuint path, GLsizei range); -GL_APICALL GLboolean GL_APIENTRY glIsPathNV(GLuint path); -GL_APICALL void GL_APIENTRY glPathCommandsNV(GLuint path, - GLsizei numCommands, - const GLubyte* commands, - GLsizei numCoords, - GLenum coordType, - const void* coords); -GL_APICALL void GL_APIENTRY glPathCoordsNV(GLuint path, - GLsizei numCoords, - GLenum coordType, - const void* coords); -GL_APICALL void GL_APIENTRY glPathSubCommandsNV(GLuint path, - GLsizei commandStart, - GLsizei commandsToDelete, - GLsizei numCommands, - const GLubyte* commands, - GLsizei numCoords, - GLenum coordType, - const void* coords); -GL_APICALL void GL_APIENTRY glPathSubCoordsNV(GLuint path, - GLsizei coordStart, - GLsizei numCoords, - GLenum coordType, - const void* coords); -GL_APICALL void GL_APIENTRY glPathStringNV(GLuint path, - GLenum format, - GLsizei length, - const void* pathString); -GL_APICALL void GL_APIENTRY glPathGlyphsNV(GLuint firstPathName, - GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLsizei numGlyphs, - GLenum type, - const void* charcodes, - GLenum handleMissingGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -GL_APICALL void GL_APIENTRY glPathGlyphRangeNV(GLuint firstPathName, - GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLuint firstGlyph, - GLsizei numGlyphs, - GLenum handleMissingGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -GL_APICALL void GL_APIENTRY glWeightPathsNV(GLuint resultPath, - GLsizei numPaths, - const GLuint* paths, - const GLfloat* weights); -GL_APICALL void GL_APIENTRY glCopyPathNV(GLuint resultPath, GLuint srcPath); -GL_APICALL void GL_APIENTRY glInterpolatePathsNV(GLuint resultPath, - GLuint pathA, - GLuint pathB, - GLfloat weight); -GL_APICALL void GL_APIENTRY glTransformPathNV(GLuint resultPath, - GLuint srcPath, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL void GL_APIENTRY glPathParameterivNV(GLuint path, - GLenum pname, - const GLint* value); -GL_APICALL void GL_APIENTRY glPathParameteriNV(GLuint path, - GLenum pname, - GLint value); -GL_APICALL void GL_APIENTRY glPathParameterfvNV(GLuint path, - GLenum pname, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glPathParameterfNV(GLuint path, - GLenum pname, - GLfloat value); -GL_APICALL void GL_APIENTRY glPathDashArrayNV(GLuint path, - GLsizei dashCount, - const GLfloat* dashArray); -GL_APICALL void GL_APIENTRY glPathStencilFuncNV(GLenum func, - GLint ref, - GLuint mask); -GL_APICALL void GL_APIENTRY glPathStencilDepthOffsetNV(GLfloat factor, - GLfloat units); -GL_APICALL void GL_APIENTRY glStencilFillPathNV(GLuint path, - GLenum fillMode, - GLuint mask); -GL_APICALL void GL_APIENTRY glStencilStrokePathNV(GLuint path, - GLint reference, - GLuint mask); -GL_APICALL void GL_APIENTRY -glStencilFillPathInstancedNV(GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum fillMode, - GLuint mask, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL void GL_APIENTRY -glStencilStrokePathInstancedNV(GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLint reference, - GLuint mask, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL void GL_APIENTRY glPathCoverDepthFuncNV(GLenum func); -GL_APICALL void GL_APIENTRY glCoverFillPathNV(GLuint path, GLenum coverMode); -GL_APICALL void GL_APIENTRY glCoverStrokePathNV(GLuint path, GLenum coverMode); -GL_APICALL void GL_APIENTRY -glCoverFillPathInstancedNV(GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL void GL_APIENTRY -glCoverStrokePathInstancedNV(GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL void GL_APIENTRY glGetPathParameterivNV(GLuint path, - GLenum pname, - GLint* value); -GL_APICALL void GL_APIENTRY glGetPathParameterfvNV(GLuint path, - GLenum pname, - GLfloat* value); -GL_APICALL void GL_APIENTRY glGetPathCommandsNV(GLuint path, GLubyte* commands); -GL_APICALL void GL_APIENTRY glGetPathCoordsNV(GLuint path, GLfloat* coords); -GL_APICALL void GL_APIENTRY glGetPathDashArrayNV(GLuint path, - GLfloat* dashArray); -GL_APICALL void GL_APIENTRY glGetPathMetricsNV(GLbitfield metricQueryMask, - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLsizei stride, - GLfloat* metrics); -GL_APICALL void GL_APIENTRY glGetPathMetricRangeNV(GLbitfield metricQueryMask, - GLuint firstPathName, - GLsizei numPaths, - GLsizei stride, - GLfloat* metrics); -GL_APICALL void GL_APIENTRY glGetPathSpacingNV(GLenum pathListMode, - GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLfloat advanceScale, - GLfloat kerningScale, - GLenum transformType, - GLfloat* returnedSpacing); -GL_APICALL GLboolean GL_APIENTRY glIsPointInFillPathNV(GLuint path, - GLuint mask, - GLfloat x, - GLfloat y); -GL_APICALL GLboolean GL_APIENTRY glIsPointInStrokePathNV(GLuint path, - GLfloat x, - GLfloat y); -GL_APICALL GLfloat GL_APIENTRY glGetPathLengthNV(GLuint path, - GLsizei startSegment, - GLsizei numSegments); -GL_APICALL GLboolean GL_APIENTRY glPointAlongPathNV(GLuint path, - GLsizei startSegment, - GLsizei numSegments, - GLfloat distance, - GLfloat* x, - GLfloat* y, - GLfloat* tangentX, - GLfloat* tangentY); -GL_APICALL void GL_APIENTRY glMatrixLoad3x2fNV(GLenum matrixMode, - const GLfloat* m); -GL_APICALL void GL_APIENTRY glMatrixLoad3x3fNV(GLenum matrixMode, - const GLfloat* m); -GL_APICALL void GL_APIENTRY glMatrixLoadTranspose3x3fNV(GLenum matrixMode, - const GLfloat* m); -GL_APICALL void GL_APIENTRY glMatrixMult3x2fNV(GLenum matrixMode, - const GLfloat* m); -GL_APICALL void GL_APIENTRY glMatrixMult3x3fNV(GLenum matrixMode, - const GLfloat* m); -GL_APICALL void GL_APIENTRY glMatrixMultTranspose3x3fNV(GLenum matrixMode, - const GLfloat* m); -GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathNV(GLuint path, - GLenum fillMode, - GLuint mask, - GLenum coverMode); -GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathNV(GLuint path, - GLint reference, - GLuint mask, - GLenum coverMode); -GL_APICALL void GL_APIENTRY -glStencilThenCoverFillPathInstancedNV(GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLenum fillMode, - GLuint mask, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL void GL_APIENTRY -glStencilThenCoverStrokePathInstancedNV(GLsizei numPaths, - GLenum pathNameType, - const void* paths, - GLuint pathBase, - GLint reference, - GLuint mask, - GLenum coverMode, - GLenum transformType, - const GLfloat* transformValues); -GL_APICALL GLenum GL_APIENTRY -glPathGlyphIndexRangeNV(GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLuint pathParameterTemplate, - GLfloat emScale, - GLuint baseAndCount[2]); -GL_APICALL GLenum GL_APIENTRY -glPathGlyphIndexArrayNV(GLuint firstPathName, - GLenum fontTarget, - const void* fontName, - GLbitfield fontStyle, - GLuint firstGlyphIndex, - GLsizei numGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -GL_APICALL GLenum GL_APIENTRY -glPathMemoryGlyphIndexArrayNV(GLuint firstPathName, - GLenum fontTarget, - GLsizeiptr fontSize, - const void* fontData, - GLsizei faceIndex, - GLuint firstGlyphIndex, - GLsizei numGlyphs, - GLuint pathParameterTemplate, - GLfloat emScale); -GL_APICALL void GL_APIENTRY -glProgramPathFragmentInputGenNV(GLuint program, - GLint location, - GLenum genMode, - GLint components, - const GLfloat* coeffs); -GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV(GLuint program, - GLenum programInterface, - GLuint index, - GLsizei propCount, - const GLenum* props, - GLsizei bufSize, - GLsizei* length, - GLfloat* params); -#endif -#endif /* GL_NV_path_rendering */ - -#ifndef GL_NV_path_rendering_shared_edge -#define GL_NV_path_rendering_shared_edge 1 -#define GL_SHARED_EDGE_NV 0xC0 -#endif /* GL_NV_path_rendering_shared_edge */ - -#ifndef GL_NV_polygon_mode -#define GL_NV_polygon_mode 1 -#define GL_POLYGON_MODE_NV 0x0B40 -#define GL_POLYGON_OFFSET_POINT_NV 0x2A01 -#define GL_POLYGON_OFFSET_LINE_NV 0x2A02 -#define GL_POINT_NV 0x1B00 -#define GL_LINE_NV 0x1B01 -#define GL_FILL_NV 0x1B02 -typedef void(GL_APIENTRYP PFNGLPOLYGONMODENVPROC)(GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glPolygonModeNV(GLenum face, GLenum mode); -#endif -#endif /* GL_NV_polygon_mode */ - -#ifndef GL_NV_read_buffer -#define GL_NV_read_buffer 1 -#define GL_READ_BUFFER_NV 0x0C02 -typedef void(GL_APIENTRYP PFNGLREADBUFFERNVPROC)(GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBufferNV(GLenum mode); -#endif -#endif /* GL_NV_read_buffer */ - -#ifndef GL_NV_read_buffer_front -#define GL_NV_read_buffer_front 1 -#endif /* GL_NV_read_buffer_front */ - -#ifndef GL_NV_read_depth -#define GL_NV_read_depth 1 -#endif /* GL_NV_read_depth */ - -#ifndef GL_NV_read_depth_stencil -#define GL_NV_read_depth_stencil 1 -#endif /* GL_NV_read_depth_stencil */ - -#ifndef GL_NV_read_stencil -#define GL_NV_read_stencil 1 -#endif /* GL_NV_read_stencil */ - -#ifndef GL_NV_sRGB_formats -#define GL_NV_sRGB_formats 1 -#define GL_SLUMINANCE_NV 0x8C46 -#define GL_SLUMINANCE_ALPHA_NV 0x8C44 -#define GL_SRGB8_NV 0x8C41 -#define GL_SLUMINANCE8_NV 0x8C47 -#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 -#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F -#define GL_ETC1_SRGB8_NV 0x88EE -#endif /* GL_NV_sRGB_formats */ - -#ifndef GL_NV_sample_locations -#define GL_NV_sample_locations 1 -#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D -#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E -#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 -#define GL_SAMPLE_LOCATION_NV 0x8E50 -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 -#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 -#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC)( - GLenum target, - GLuint start, - GLsizei count, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC)( - GLuint framebuffer, - GLuint start, - GLsizei count, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC)(void); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glFramebufferSampleLocationsfvNV(GLenum target, - GLuint start, - GLsizei count, - const GLfloat* v); -GL_APICALL void GL_APIENTRY -glNamedFramebufferSampleLocationsfvNV(GLuint framebuffer, - GLuint start, - GLsizei count, - const GLfloat* v); -GL_APICALL void GL_APIENTRY glResolveDepthValuesNV(void); -#endif -#endif /* GL_NV_sample_locations */ - -#ifndef GL_NV_sample_mask_override_coverage -#define GL_NV_sample_mask_override_coverage 1 -#endif /* GL_NV_sample_mask_override_coverage */ - -#ifndef GL_NV_shader_noperspective_interpolation -#define GL_NV_shader_noperspective_interpolation 1 -#endif /* GL_NV_shader_noperspective_interpolation */ - -#ifndef GL_NV_shadow_samplers_array -#define GL_NV_shadow_samplers_array 1 -#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 -#endif /* GL_NV_shadow_samplers_array */ - -#ifndef GL_NV_shadow_samplers_cube -#define GL_NV_shadow_samplers_cube 1 -#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 -#endif /* GL_NV_shadow_samplers_cube */ - -#ifndef GL_NV_texture_border_clamp -#define GL_NV_texture_border_clamp 1 -#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 -#define GL_CLAMP_TO_BORDER_NV 0x812D -#endif /* GL_NV_texture_border_clamp */ - -#ifndef GL_NV_texture_compression_s3tc_update -#define GL_NV_texture_compression_s3tc_update 1 -#endif /* GL_NV_texture_compression_s3tc_update */ - -#ifndef GL_NV_texture_npot_2D_mipmap -#define GL_NV_texture_npot_2D_mipmap 1 -#endif /* GL_NV_texture_npot_2D_mipmap */ - -#ifndef GL_NV_viewport_array -#define GL_NV_viewport_array 1 -#define GL_MAX_VIEWPORTS_NV 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F -typedef void(GL_APIENTRYP PFNGLVIEWPORTARRAYVNVPROC)(GLuint first, - GLsizei count, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVIEWPORTINDEXEDFNVPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat w, - GLfloat h); -typedef void(GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVNVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLSCISSORARRAYVNVPROC)(GLuint first, - GLsizei count, - const GLint* v); -typedef void(GL_APIENTRYP PFNGLSCISSORINDEXEDNVPROC)(GLuint index, - GLint left, - GLint bottom, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSCISSORINDEXEDVNVPROC)(GLuint index, - const GLint* v); -typedef void(GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVNVPROC)(GLuint first, - GLsizei count, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFNVPROC)(GLuint index, - GLfloat n, - GLfloat f); -typedef void(GL_APIENTRYP PFNGLGETFLOATI_VNVPROC)(GLenum target, - GLuint index, - GLfloat* data); -typedef void(GL_APIENTRYP PFNGLENABLEINVPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLDISABLEINVPROC)(GLenum target, GLuint index); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDINVPROC)(GLenum target, - GLuint index); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glViewportArrayvNV(GLuint first, - GLsizei count, - const GLfloat* v); -GL_APICALL void GL_APIENTRY -glViewportIndexedfNV(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GL_APICALL void GL_APIENTRY glViewportIndexedfvNV(GLuint index, - const GLfloat* v); -GL_APICALL void GL_APIENTRY glScissorArrayvNV(GLuint first, - GLsizei count, - const GLint* v); -GL_APICALL void GL_APIENTRY glScissorIndexedNV(GLuint index, - GLint left, - GLint bottom, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glScissorIndexedvNV(GLuint index, const GLint* v); -GL_APICALL void GL_APIENTRY glDepthRangeArrayfvNV(GLuint first, - GLsizei count, - const GLfloat* v); -GL_APICALL void GL_APIENTRY glDepthRangeIndexedfNV(GLuint index, - GLfloat n, - GLfloat f); -GL_APICALL void GL_APIENTRY glGetFloati_vNV(GLenum target, - GLuint index, - GLfloat* data); -GL_APICALL void GL_APIENTRY glEnableiNV(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glDisableiNV(GLenum target, GLuint index); -GL_APICALL GLboolean GL_APIENTRY glIsEnablediNV(GLenum target, GLuint index); -#endif -#endif /* GL_NV_viewport_array */ - -#ifndef GL_NV_viewport_array2 -#define GL_NV_viewport_array2 1 -#endif /* GL_NV_viewport_array2 */ - -#ifndef GL_OVR_multiview -#define GL_OVR_multiview 1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 -#define GL_MAX_VIEWS_OVR 0x9631 -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)( - GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint baseViewIndex, - GLsizei numViews); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY -glFramebufferTextureMultiviewOVR(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint baseViewIndex, - GLsizei numViews); -#endif -#endif /* GL_OVR_multiview */ - -#ifndef GL_OVR_multiview2 -#define GL_OVR_multiview2 1 -#endif /* GL_OVR_multiview2 */ - -#ifndef GL_QCOM_alpha_test -#define GL_QCOM_alpha_test 1 -#define GL_ALPHA_TEST_QCOM 0x0BC0 -#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 -#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 -typedef void(GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC)(GLenum func, GLclampf ref); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glAlphaFuncQCOM(GLenum func, GLclampf ref); -#endif -#endif /* GL_QCOM_alpha_test */ - -#ifndef GL_QCOM_binning_control -#define GL_QCOM_binning_control 1 -#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 -#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 -#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 -#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 -#endif /* GL_QCOM_binning_control */ - -#ifndef GL_QCOM_driver_control -#define GL_QCOM_driver_control 1 -typedef void(GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC)( - GLint* num, - GLsizei size, - GLuint* driverControls); -typedef void(GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC)( - GLuint driverControl, - GLsizei bufSize, - GLsizei* length, - GLchar* driverControlString); -typedef void(GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC)( - GLuint driverControl); -typedef void(GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC)( - GLuint driverControl); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM(GLint* num, - GLsizei size, - GLuint* driverControls); -GL_APICALL void GL_APIENTRY -glGetDriverControlStringQCOM(GLuint driverControl, - GLsizei bufSize, - GLsizei* length, - GLchar* driverControlString); -GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM(GLuint driverControl); -GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM(GLuint driverControl); -#endif -#endif /* GL_QCOM_driver_control */ - -#ifndef GL_QCOM_extended_get -#define GL_QCOM_extended_get 1 -#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define GL_TEXTURE_TARGET_QCOM 0x8BDA -#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define GL_STATE_RESTORE 0x8BDC -typedef void(GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC)(GLuint* textures, - GLint maxTextures, - GLint* numTextures); -typedef void(GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC)(GLuint* buffers, - GLint maxBuffers, - GLint* numBuffers); -typedef void(GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC)( - GLuint* renderbuffers, - GLint maxRenderbuffers, - GLint* numRenderbuffers); -typedef void(GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC)( - GLuint* framebuffers, - GLint maxFramebuffers, - GLint* numFramebuffers); -typedef void(GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC)( - GLuint texture, - GLenum face, - GLint level, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC)( - GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - void* texels); -typedef void(GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC)(GLenum target, - void** params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM(GLuint* textures, - GLint maxTextures, - GLint* numTextures); -GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM(GLuint* buffers, - GLint maxBuffers, - GLint* numBuffers); -GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM(GLuint* renderbuffers, - GLint maxRenderbuffers, - GLint* numRenderbuffers); -GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM(GLuint* framebuffers, - GLint maxFramebuffers, - GLint* numFramebuffers); -GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM(GLuint texture, - GLenum face, - GLint level, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLsizei width, - GLsizei height, - GLsizei depth, - GLenum format, - GLenum type, - void* texels); -GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM(GLenum target, - void** params); -#endif -#endif /* GL_QCOM_extended_get */ - -#ifndef GL_QCOM_extended_get2 -#define GL_QCOM_extended_get2 1 -typedef void(GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC)(GLuint* shaders, - GLint maxShaders, - GLint* numShaders); -typedef void(GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC)(GLuint* programs, - GLint maxPrograms, - GLint* numPrograms); -typedef GLboolean(GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC)( - GLuint program, - GLenum shadertype, - GLchar* source, - GLint* length); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetShadersQCOM(GLuint* shaders, - GLint maxShaders, - GLint* numShaders); -GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM(GLuint* programs, - GLint maxPrograms, - GLint* numPrograms); -GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM(GLuint program); -GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM(GLuint program, - GLenum shadertype, - GLchar* source, - GLint* length); -#endif -#endif /* GL_QCOM_extended_get2 */ - -#ifndef GL_QCOM_perfmon_global_mode -#define GL_QCOM_perfmon_global_mode 1 -#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#endif /* GL_QCOM_perfmon_global_mode */ - -#ifndef GL_QCOM_tiled_rendering -#define GL_QCOM_tiled_rendering 1 -#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -typedef void(GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC)(GLuint x, - GLuint y, - GLuint width, - GLuint height, - GLbitfield preserveMask); -typedef void(GL_APIENTRYP PFNGLENDTILINGQCOMPROC)(GLbitfield preserveMask); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glStartTilingQCOM(GLuint x, - GLuint y, - GLuint width, - GLuint height, - GLbitfield preserveMask); -GL_APICALL void GL_APIENTRY glEndTilingQCOM(GLbitfield preserveMask); -#endif -#endif /* GL_QCOM_tiled_rendering */ - -#ifndef GL_QCOM_writeonly_rendering -#define GL_QCOM_writeonly_rendering 1 -#define GL_WRITEONLY_RENDERING_QCOM 0x8823 -#endif /* GL_QCOM_writeonly_rendering */ - -#ifndef GL_VIV_shader_binary -#define GL_VIV_shader_binary 1 -#define GL_SHADER_BINARY_VIV 0x8FC4 -#endif /* GL_VIV_shader_binary */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/GLES2/gl2platform.h b/glimp/include/GLES2/gl2platform.h deleted file mode 100644 index 259b3bbf4d86..000000000000 --- a/glimp/include/GLES2/gl2platform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __gl2platform_h_ -#define __gl2platform_h_ - -/* $Revision: 23328 $ on $Date:: 2013-10-02 02:28:28 -0700 #$ */ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -#include - -#ifndef GL_APICALL -#define GL_APICALL KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __gl2platform_h_ */ diff --git a/glimp/include/GLES3/gl3.h b/glimp/include/GLES3/gl3.h deleted file mode 100644 index 249a695bfc84..000000000000 --- a/glimp/include/GLES3/gl3.h +++ /dev/null @@ -1,2179 +0,0 @@ -#ifndef __gl3_h_ -#define __gl3_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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: 31811 $ on $Date: 2015-08-10 00:01:11 -0700 (Mon, 10 Aug -*2015) $ -*/ - -#include - -#ifndef GL_APIENTRYP -#define GL_APIENTRYP GL_APIENTRY * -#endif - -/* Generated on date 20150809 */ - -/* Generated C header for: - * API: gles2 - * Profile: common - * Versions considered: 2\.[0-9]|3\.0 - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_ES_VERSION_2_0 -#define GL_ES_VERSION_2_0 1 -#include -typedef khronos_int8_t GLbyte; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; -typedef short GLshort; -typedef unsigned short GLushort; -typedef void GLvoid; -typedef struct __GLsync* GLsync; -typedef khronos_int64_t GLint64; -typedef khronos_uint64_t GLuint64; -typedef unsigned int GLenum; -typedef unsigned int GLuint; -typedef char GLchar; -typedef khronos_float_t GLfloat; -typedef khronos_ssize_t GLsizeiptr; -typedef khronos_intptr_t GLintptr; -typedef unsigned int GLbitfield; -typedef int GLint; -typedef unsigned char GLboolean; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_FALSE 0 -#define GL_TRUE 1 -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#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_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#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_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#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_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_TEXTURE 0x1702 -#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_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#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_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 -#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_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 -#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_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#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_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#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_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_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_NONE 0 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -typedef void(GL_APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); -typedef void(GL_APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, - GLuint index, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); -typedef void(GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, - GLuint framebuffer); -typedef void(GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); -typedef void(GL_APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -typedef void(GL_APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -typedef void(GL_APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -typedef GLenum(GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); -typedef void(GL_APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d); -typedef void(GL_APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); -typedef void(GL_APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -typedef void(GL_APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -typedef void(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef GLuint(GL_APIENTRYP PFNGLCREATEPROGRAMPROC)(void); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); -typedef void(GL_APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, - const GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)( - GLsizei n, - const GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC)( - GLsizei n, - const GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, - const GLuint* textures); -typedef void(GL_APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); -typedef void(GL_APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); -typedef void(GL_APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); -typedef void(GL_APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLDISABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, - GLint first, - GLsizei count); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_APIENTRYP PFNGLENABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLFINISHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFLUSHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)( - GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -typedef void(GL_APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, - GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, - GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint* textures); -typedef void(GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -typedef GLint(GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef GLenum(GL_APIENTRYP PFNGLGETERRORPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat* data); -typedef void(GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)( - GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint* data); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)( - GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -typedef void(GL_APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, - GLint location, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, - GLint location, - GLint* params); -typedef GLint(GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, - GLenum pname, - void** pointer); -typedef void(GL_APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); -typedef GLboolean(GL_APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); -typedef GLboolean(GL_APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); -typedef GLboolean(GL_APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISSHADERPROC)(GLuint shader); -typedef GLboolean(GL_APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); -typedef void(GL_APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); -typedef void(GL_APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); -typedef void(GL_APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, - GLfloat units); -typedef void(GL_APIENTRYP PFNGLREADPIXELSPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -typedef void(GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, - GLboolean invert); -typedef void(GL_APIENTRYP PFNGLSCISSORPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, - GLenum zfail, - GLenum zpass); -typedef void(GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -typedef void(GL_APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - const GLfloat* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, - GLfloat x, - GLfloat y); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLVIEWPORTPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, - GLuint index, - const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, - GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer(GLenum target, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glBlendEquation(GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -GL_APICALL void GL_APIENTRY glBufferData(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target); -GL_APICALL void GL_APIENTRY glClear(GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glClearDepthf(GLfloat d); -GL_APICALL void GL_APIENTRY glClearStencil(GLint s); -GL_APICALL void GL_APIENTRY glColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram(void); -GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type); -GL_APICALL void GL_APIENTRY glCullFace(GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, - const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, - const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc(GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask(GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef(GLfloat n, GLfloat f); -GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable(GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays(GLenum mode, - GLint first, - GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glEnable(GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glFinish(void); -GL_APICALL void GL_APIENTRY glFlush(void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -GL_APICALL void GL_APIENTRY glFrontFace(GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap(GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, - GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -GL_APICALL GLint GL_APIENTRY glGetAttribLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError(void); -GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* data); -GL_APICALL void GL_APIENTRY -glGetFramebufferAttachmentParameteriv(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* data); -GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv(GLenum target, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, - GLint location, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, - GLint location, - GLint* params); -GL_APICALL GLint GL_APIENTRY glGetUniformLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, - GLenum pname, - void** pointer); -GL_APICALL void GL_APIENTRY glHint(GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled(GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth(GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler(void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage(GLfloat value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor(GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask(GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, - GLenum zfail, - GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf(GLenum target, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv(GLenum target, - GLenum pname, - const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glUniform1f(GLint location, GLfloat v0); -GL_APICALL void GL_APIENTRY glUniform1fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform1i(GLint location, GLint v0); -GL_APICALL void GL_APIENTRY glUniform1iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform2f(GLint location, GLfloat v0, GLfloat v1); -GL_APICALL void GL_APIENTRY glUniform2fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform2i(GLint location, GLint v0, GLint v1); -GL_APICALL void GL_APIENTRY glUniform2iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform3f(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glUniform3fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform3i(GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glUniform3iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY -glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GL_APICALL void GL_APIENTRY glUniform4fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GL_APICALL void GL_APIENTRY glUniform4iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram(GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib2f(GLuint index, - GLfloat x, - GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib3f(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY -glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glViewport(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#endif -#endif /* GL_ES_VERSION_2_0 */ - -#ifndef GL_ES_VERSION_3_0 -#define GL_ES_VERSION_3_0 1 -typedef unsigned short GLhalf; -#define GL_READ_BUFFER 0x0C02 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_RED 0x1903 -#define GL_RGB8 0x8051 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#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_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#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_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#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_SRGB8_ALPHA8 0x8C43 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#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_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#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_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_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_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#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_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#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_2D_ARRAY 0x8DD7 -#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_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_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#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_TEXTURE_LAYER 0x8CD4 -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#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_COLOR_ATTACHMENT16 0x8CF0 -#define GL_COLOR_ATTACHMENT17 0x8CF1 -#define GL_COLOR_ATTACHMENT18 0x8CF2 -#define GL_COLOR_ATTACHMENT19 0x8CF3 -#define GL_COLOR_ATTACHMENT20 0x8CF4 -#define GL_COLOR_ATTACHMENT21 0x8CF5 -#define GL_COLOR_ATTACHMENT22 0x8CF6 -#define GL_COLOR_ATTACHMENT23 0x8CF7 -#define GL_COLOR_ATTACHMENT24 0x8CF8 -#define GL_COLOR_ATTACHMENT25 0x8CF9 -#define GL_COLOR_ATTACHMENT26 0x8CFA -#define GL_COLOR_ATTACHMENT27 0x8CFB -#define GL_COLOR_ATTACHMENT28 0x8CFC -#define GL_COLOR_ATTACHMENT29 0x8CFD -#define GL_COLOR_ATTACHMENT30 0x8CFE -#define GL_COLOR_ATTACHMENT31 0x8CFF -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#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_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_RG8 0x822B -#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_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 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 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#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_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#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_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_INT_2_10_10_10_REV 0x8D9F -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#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_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_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_TEXTURE_IMMUTABLE_FORMAT 0x912F -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -typedef void(GL_APIENTRYP PFNGLREADBUFFERPROC)(GLenum src); -typedef void(GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_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(GL_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(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_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(GL_APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint* ids); -typedef void(GL_APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISQUERYPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); -typedef void(GL_APIENTRYP PFNGLENDQUERYPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, - GLenum pname, - GLuint* params); -typedef GLboolean(GL_APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, - GLenum pname, - void** params); -typedef void(GL_APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum* bufs); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -typedef void*(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -typedef void(GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length); -typedef void(GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, - const GLuint* arrays); -typedef void(GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint* arrays); -typedef GLboolean(GL_APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, - GLuint index, - GLint* data); -typedef void(GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)( - GLenum primitiveMode); -typedef void(GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, - GLuint index, - GLuint buffer); -typedef void(GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)( - GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode); -typedef void(GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, - GLint x, - GLint y, - GLint z, - GLint w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, - GLuint x, - GLuint y, - GLuint z, - GLuint w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, - const GLint* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, - const GLuint* v); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, - GLint location, - GLuint* params); -typedef GLint(GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, - GLint drawbuffer, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, - GLuint index); -typedef void(GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC)( - GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)( - GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -typedef GLuint(GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)( - GLuint program, - const GLchar* uniformBlockName); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName); -typedef void(GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount); -typedef GLsync(GL_APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, - GLbitfield flags); -typedef GLboolean(GL_APIENTRYP PFNGLISSYNCPROC)(GLsync sync); -typedef void(GL_APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync); -typedef GLenum(GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64* data); -typedef void(GL_APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, - GLuint index, - GLint64* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, - GLenum pname, - GLint64* params); -typedef void(GL_APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, - GLuint* samplers); -typedef void(GL_APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, - const GLuint* samplers); -typedef GLboolean(GL_APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler); -typedef void(GL_APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, - GLenum pname, - const GLint* param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, - GLenum pname, - const GLfloat* param); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, - GLuint divisor); -typedef void(GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, - GLuint id); -typedef void(GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, - const GLuint* ids); -typedef void(GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, - GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -typedef void(GL_APIENTRYP PFNGLPROGRAMBINARYPROC)(GLuint program, - GLenum binaryFormat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC)(GLuint program, - GLenum pname, - GLint value); -typedef void(GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -typedef void(GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE2DPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE3DPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -typedef void(GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBuffer(GLenum src); -GL_APICALL void GL_APIENTRY glDrawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glTexImage3D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids); -GL_APICALL void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsQuery(GLuint id); -GL_APICALL void GL_APIENTRY glBeginQuery(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glEndQuery(GLenum target); -GL_APICALL void GL_APIENTRY glGetQueryiv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetQueryObjectuiv(GLuint id, - GLenum pname, - GLuint* params); -GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer(GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointerv(GLenum target, - GLenum pname, - void** params); -GL_APICALL void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs); -GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glBlitFramebuffer(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glFramebufferTextureLayer(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -GL_APICALL void* GL_APIENTRY glMapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length); -GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArrays(GLsizei n, - const GLuint* arrays); -GL_APICALL void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArray(GLuint array); -GL_APICALL void GL_APIENTRY glGetIntegeri_v(GLenum target, - GLuint index, - GLint* data); -GL_APICALL void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode); -GL_APICALL void GL_APIENTRY glEndTransformFeedback(void); -GL_APICALL void GL_APIENTRY glBindBufferRange(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY glBindBufferBase(GLenum target, - GLuint index, - GLuint buffer); -GL_APICALL void GL_APIENTRY -glTransformFeedbackVaryings(GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode); -GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY -glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY -glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GL_APICALL void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v); -GL_APICALL void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v); -GL_APICALL void GL_APIENTRY glGetUniformuiv(GLuint program, - GLint location, - GLuint* params); -GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glUniform1ui(GLint location, GLuint v0); -GL_APICALL void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1); -GL_APICALL void GL_APIENTRY glUniform3ui(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -GL_APICALL void GL_APIENTRY -glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GL_APICALL void GL_APIENTRY glUniform1uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform2uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform3uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform4uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glClearBufferiv(GLenum buffer, - GLint drawbuffer, - const GLint* value); -GL_APICALL void GL_APIENTRY glClearBufferuiv(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -GL_APICALL void GL_APIENTRY glClearBufferfv(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glClearBufferfi(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil); -GL_APICALL const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index); -GL_APICALL void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY -glGetUniformIndices(GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices); -GL_APICALL void GL_APIENTRY glGetActiveUniformsiv(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -GL_APICALL GLuint GL_APIENTRY -glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName); -GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY -glGetActiveUniformBlockName(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName); -GL_APICALL void GL_APIENTRY glUniformBlockBinding(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -GL_APICALL void GL_APIENTRY glDrawArraysInstanced(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount); -GL_APICALL void GL_APIENTRY glDrawElementsInstanced(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount); -GL_APICALL GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags); -GL_APICALL GLboolean GL_APIENTRY glIsSync(GLsync sync); -GL_APICALL void GL_APIENTRY glDeleteSync(GLsync sync); -GL_APICALL GLenum GL_APIENTRY glClientWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* data); -GL_APICALL void GL_APIENTRY glGetSynciv(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -GL_APICALL void GL_APIENTRY glGetInteger64i_v(GLenum target, - GLuint index, - GLint64* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteri64v(GLenum target, - GLenum pname, - GLint64* params); -GL_APICALL void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers); -GL_APICALL void GL_APIENTRY glDeleteSamplers(GLsizei count, - const GLuint* samplers); -GL_APICALL GLboolean GL_APIENTRY glIsSampler(GLuint sampler); -GL_APICALL void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler); -GL_APICALL void GL_APIENTRY glSamplerParameteri(GLuint sampler, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glSamplerParameteriv(GLuint sampler, - GLenum pname, - const GLint* param); -GL_APICALL void GL_APIENTRY glSamplerParameterf(GLuint sampler, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glSamplerParameterfv(GLuint sampler, - GLenum pname, - const GLfloat* param); -GL_APICALL void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor); -GL_APICALL void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, - const GLuint* ids); -GL_APICALL void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id); -GL_APICALL void GL_APIENTRY glPauseTransformFeedback(void); -GL_APICALL void GL_APIENTRY glResumeTransformFeedback(void); -GL_APICALL void GL_APIENTRY glGetProgramBinary(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -GL_APICALL void GL_APIENTRY glProgramBinary(GLuint program, - GLenum binaryFormat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glProgramParameteri(GLuint program, - GLenum pname, - GLint value); -GL_APICALL void GL_APIENTRY glInvalidateFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -GL_APICALL void GL_APIENTRY -glInvalidateSubFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage2D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage3D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -GL_APICALL void GL_APIENTRY glGetInternalformativ(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -#endif -#endif /* GL_ES_VERSION_3_0 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/GLES3/gl31.h b/glimp/include/GLES3/gl31.h deleted file mode 100644 index 52025b1107f4..000000000000 --- a/glimp/include/GLES3/gl31.h +++ /dev/null @@ -1,2887 +0,0 @@ -#ifndef __gl31_h_ -#define __gl31_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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$ on $Date$ -*/ - -#include - -#ifndef GL_APIENTRYP -#define GL_APIENTRYP GL_APIENTRY * -#endif - -/* Generated on date 20150809 */ - -/* Generated C header for: - * API: gles2 - * Profile: common - * Versions considered: 2\.[0-9]|3\.[01] - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_ES_VERSION_2_0 -#define GL_ES_VERSION_2_0 1 -#include -typedef khronos_int8_t GLbyte; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; -typedef short GLshort; -typedef unsigned short GLushort; -typedef void GLvoid; -typedef struct __GLsync* GLsync; -typedef khronos_int64_t GLint64; -typedef khronos_uint64_t GLuint64; -typedef unsigned int GLenum; -typedef unsigned int GLuint; -typedef char GLchar; -typedef khronos_float_t GLfloat; -typedef khronos_ssize_t GLsizeiptr; -typedef khronos_intptr_t GLintptr; -typedef unsigned int GLbitfield; -typedef int GLint; -typedef unsigned char GLboolean; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_FALSE 0 -#define GL_TRUE 1 -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#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_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#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_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#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_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_TEXTURE 0x1702 -#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_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#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_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 -#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_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 -#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_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#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_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#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_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_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_NONE 0 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -typedef void(GL_APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); -typedef void(GL_APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, - GLuint index, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); -typedef void(GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, - GLuint framebuffer); -typedef void(GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); -typedef void(GL_APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -typedef void(GL_APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -typedef void(GL_APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -typedef GLenum(GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); -typedef void(GL_APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d); -typedef void(GL_APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); -typedef void(GL_APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -typedef void(GL_APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -typedef void(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef GLuint(GL_APIENTRYP PFNGLCREATEPROGRAMPROC)(void); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); -typedef void(GL_APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, - const GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)( - GLsizei n, - const GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC)( - GLsizei n, - const GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, - const GLuint* textures); -typedef void(GL_APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); -typedef void(GL_APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); -typedef void(GL_APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); -typedef void(GL_APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLDISABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, - GLint first, - GLsizei count); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_APIENTRYP PFNGLENABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLFINISHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFLUSHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)( - GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -typedef void(GL_APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, - GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, - GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint* textures); -typedef void(GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -typedef GLint(GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef GLenum(GL_APIENTRYP PFNGLGETERRORPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat* data); -typedef void(GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)( - GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint* data); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)( - GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -typedef void(GL_APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, - GLint location, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, - GLint location, - GLint* params); -typedef GLint(GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, - GLenum pname, - void** pointer); -typedef void(GL_APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); -typedef GLboolean(GL_APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); -typedef GLboolean(GL_APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); -typedef GLboolean(GL_APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISSHADERPROC)(GLuint shader); -typedef GLboolean(GL_APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); -typedef void(GL_APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); -typedef void(GL_APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); -typedef void(GL_APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, - GLfloat units); -typedef void(GL_APIENTRYP PFNGLREADPIXELSPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -typedef void(GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, - GLboolean invert); -typedef void(GL_APIENTRYP PFNGLSCISSORPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, - GLenum zfail, - GLenum zpass); -typedef void(GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -typedef void(GL_APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - const GLfloat* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, - GLfloat x, - GLfloat y); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLVIEWPORTPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, - GLuint index, - const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, - GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer(GLenum target, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glBlendEquation(GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -GL_APICALL void GL_APIENTRY glBufferData(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target); -GL_APICALL void GL_APIENTRY glClear(GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glClearDepthf(GLfloat d); -GL_APICALL void GL_APIENTRY glClearStencil(GLint s); -GL_APICALL void GL_APIENTRY glColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram(void); -GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type); -GL_APICALL void GL_APIENTRY glCullFace(GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, - const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, - const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc(GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask(GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef(GLfloat n, GLfloat f); -GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable(GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays(GLenum mode, - GLint first, - GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glEnable(GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glFinish(void); -GL_APICALL void GL_APIENTRY glFlush(void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -GL_APICALL void GL_APIENTRY glFrontFace(GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap(GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, - GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -GL_APICALL GLint GL_APIENTRY glGetAttribLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError(void); -GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* data); -GL_APICALL void GL_APIENTRY -glGetFramebufferAttachmentParameteriv(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* data); -GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv(GLenum target, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, - GLint location, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, - GLint location, - GLint* params); -GL_APICALL GLint GL_APIENTRY glGetUniformLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, - GLenum pname, - void** pointer); -GL_APICALL void GL_APIENTRY glHint(GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled(GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth(GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler(void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage(GLfloat value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor(GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask(GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, - GLenum zfail, - GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf(GLenum target, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv(GLenum target, - GLenum pname, - const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glUniform1f(GLint location, GLfloat v0); -GL_APICALL void GL_APIENTRY glUniform1fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform1i(GLint location, GLint v0); -GL_APICALL void GL_APIENTRY glUniform1iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform2f(GLint location, GLfloat v0, GLfloat v1); -GL_APICALL void GL_APIENTRY glUniform2fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform2i(GLint location, GLint v0, GLint v1); -GL_APICALL void GL_APIENTRY glUniform2iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform3f(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glUniform3fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform3i(GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glUniform3iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY -glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GL_APICALL void GL_APIENTRY glUniform4fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GL_APICALL void GL_APIENTRY glUniform4iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram(GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib2f(GLuint index, - GLfloat x, - GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib3f(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY -glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glViewport(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#endif -#endif /* GL_ES_VERSION_2_0 */ - -#ifndef GL_ES_VERSION_3_0 -#define GL_ES_VERSION_3_0 1 -typedef unsigned short GLhalf; -#define GL_READ_BUFFER 0x0C02 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_RED 0x1903 -#define GL_RGB8 0x8051 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#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_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#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_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#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_SRGB8_ALPHA8 0x8C43 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#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_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#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_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_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_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#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_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#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_2D_ARRAY 0x8DD7 -#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_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_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#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_TEXTURE_LAYER 0x8CD4 -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#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_COLOR_ATTACHMENT16 0x8CF0 -#define GL_COLOR_ATTACHMENT17 0x8CF1 -#define GL_COLOR_ATTACHMENT18 0x8CF2 -#define GL_COLOR_ATTACHMENT19 0x8CF3 -#define GL_COLOR_ATTACHMENT20 0x8CF4 -#define GL_COLOR_ATTACHMENT21 0x8CF5 -#define GL_COLOR_ATTACHMENT22 0x8CF6 -#define GL_COLOR_ATTACHMENT23 0x8CF7 -#define GL_COLOR_ATTACHMENT24 0x8CF8 -#define GL_COLOR_ATTACHMENT25 0x8CF9 -#define GL_COLOR_ATTACHMENT26 0x8CFA -#define GL_COLOR_ATTACHMENT27 0x8CFB -#define GL_COLOR_ATTACHMENT28 0x8CFC -#define GL_COLOR_ATTACHMENT29 0x8CFD -#define GL_COLOR_ATTACHMENT30 0x8CFE -#define GL_COLOR_ATTACHMENT31 0x8CFF -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#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_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_RG8 0x822B -#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_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 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 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#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_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#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_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_INT_2_10_10_10_REV 0x8D9F -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#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_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_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_TEXTURE_IMMUTABLE_FORMAT 0x912F -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -typedef void(GL_APIENTRYP PFNGLREADBUFFERPROC)(GLenum src); -typedef void(GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_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(GL_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(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_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(GL_APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint* ids); -typedef void(GL_APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISQUERYPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); -typedef void(GL_APIENTRYP PFNGLENDQUERYPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, - GLenum pname, - GLuint* params); -typedef GLboolean(GL_APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, - GLenum pname, - void** params); -typedef void(GL_APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum* bufs); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -typedef void*(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -typedef void(GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length); -typedef void(GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, - const GLuint* arrays); -typedef void(GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint* arrays); -typedef GLboolean(GL_APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, - GLuint index, - GLint* data); -typedef void(GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)( - GLenum primitiveMode); -typedef void(GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, - GLuint index, - GLuint buffer); -typedef void(GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)( - GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode); -typedef void(GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, - GLint x, - GLint y, - GLint z, - GLint w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, - GLuint x, - GLuint y, - GLuint z, - GLuint w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, - const GLint* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, - const GLuint* v); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, - GLint location, - GLuint* params); -typedef GLint(GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, - GLint drawbuffer, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, - GLuint index); -typedef void(GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC)( - GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)( - GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -typedef GLuint(GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)( - GLuint program, - const GLchar* uniformBlockName); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName); -typedef void(GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount); -typedef GLsync(GL_APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, - GLbitfield flags); -typedef GLboolean(GL_APIENTRYP PFNGLISSYNCPROC)(GLsync sync); -typedef void(GL_APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync); -typedef GLenum(GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64* data); -typedef void(GL_APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, - GLuint index, - GLint64* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, - GLenum pname, - GLint64* params); -typedef void(GL_APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, - GLuint* samplers); -typedef void(GL_APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, - const GLuint* samplers); -typedef GLboolean(GL_APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler); -typedef void(GL_APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, - GLenum pname, - const GLint* param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, - GLenum pname, - const GLfloat* param); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, - GLuint divisor); -typedef void(GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, - GLuint id); -typedef void(GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, - const GLuint* ids); -typedef void(GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, - GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -typedef void(GL_APIENTRYP PFNGLPROGRAMBINARYPROC)(GLuint program, - GLenum binaryFormat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC)(GLuint program, - GLenum pname, - GLint value); -typedef void(GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -typedef void(GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE2DPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE3DPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -typedef void(GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBuffer(GLenum src); -GL_APICALL void GL_APIENTRY glDrawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glTexImage3D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids); -GL_APICALL void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsQuery(GLuint id); -GL_APICALL void GL_APIENTRY glBeginQuery(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glEndQuery(GLenum target); -GL_APICALL void GL_APIENTRY glGetQueryiv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetQueryObjectuiv(GLuint id, - GLenum pname, - GLuint* params); -GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer(GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointerv(GLenum target, - GLenum pname, - void** params); -GL_APICALL void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs); -GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glBlitFramebuffer(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glFramebufferTextureLayer(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -GL_APICALL void* GL_APIENTRY glMapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length); -GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArrays(GLsizei n, - const GLuint* arrays); -GL_APICALL void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArray(GLuint array); -GL_APICALL void GL_APIENTRY glGetIntegeri_v(GLenum target, - GLuint index, - GLint* data); -GL_APICALL void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode); -GL_APICALL void GL_APIENTRY glEndTransformFeedback(void); -GL_APICALL void GL_APIENTRY glBindBufferRange(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY glBindBufferBase(GLenum target, - GLuint index, - GLuint buffer); -GL_APICALL void GL_APIENTRY -glTransformFeedbackVaryings(GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode); -GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY -glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY -glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GL_APICALL void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v); -GL_APICALL void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v); -GL_APICALL void GL_APIENTRY glGetUniformuiv(GLuint program, - GLint location, - GLuint* params); -GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glUniform1ui(GLint location, GLuint v0); -GL_APICALL void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1); -GL_APICALL void GL_APIENTRY glUniform3ui(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -GL_APICALL void GL_APIENTRY -glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GL_APICALL void GL_APIENTRY glUniform1uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform2uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform3uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform4uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glClearBufferiv(GLenum buffer, - GLint drawbuffer, - const GLint* value); -GL_APICALL void GL_APIENTRY glClearBufferuiv(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -GL_APICALL void GL_APIENTRY glClearBufferfv(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glClearBufferfi(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil); -GL_APICALL const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index); -GL_APICALL void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY -glGetUniformIndices(GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices); -GL_APICALL void GL_APIENTRY glGetActiveUniformsiv(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -GL_APICALL GLuint GL_APIENTRY -glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName); -GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY -glGetActiveUniformBlockName(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName); -GL_APICALL void GL_APIENTRY glUniformBlockBinding(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -GL_APICALL void GL_APIENTRY glDrawArraysInstanced(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount); -GL_APICALL void GL_APIENTRY glDrawElementsInstanced(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount); -GL_APICALL GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags); -GL_APICALL GLboolean GL_APIENTRY glIsSync(GLsync sync); -GL_APICALL void GL_APIENTRY glDeleteSync(GLsync sync); -GL_APICALL GLenum GL_APIENTRY glClientWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* data); -GL_APICALL void GL_APIENTRY glGetSynciv(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -GL_APICALL void GL_APIENTRY glGetInteger64i_v(GLenum target, - GLuint index, - GLint64* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteri64v(GLenum target, - GLenum pname, - GLint64* params); -GL_APICALL void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers); -GL_APICALL void GL_APIENTRY glDeleteSamplers(GLsizei count, - const GLuint* samplers); -GL_APICALL GLboolean GL_APIENTRY glIsSampler(GLuint sampler); -GL_APICALL void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler); -GL_APICALL void GL_APIENTRY glSamplerParameteri(GLuint sampler, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glSamplerParameteriv(GLuint sampler, - GLenum pname, - const GLint* param); -GL_APICALL void GL_APIENTRY glSamplerParameterf(GLuint sampler, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glSamplerParameterfv(GLuint sampler, - GLenum pname, - const GLfloat* param); -GL_APICALL void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor); -GL_APICALL void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, - const GLuint* ids); -GL_APICALL void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id); -GL_APICALL void GL_APIENTRY glPauseTransformFeedback(void); -GL_APICALL void GL_APIENTRY glResumeTransformFeedback(void); -GL_APICALL void GL_APIENTRY glGetProgramBinary(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -GL_APICALL void GL_APIENTRY glProgramBinary(GLuint program, - GLenum binaryFormat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glProgramParameteri(GLuint program, - GLenum pname, - GLint value); -GL_APICALL void GL_APIENTRY glInvalidateFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -GL_APICALL void GL_APIENTRY -glInvalidateSubFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage2D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage3D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -GL_APICALL void GL_APIENTRY glGetInternalformativ(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -#endif -#endif /* GL_ES_VERSION_3_0 */ - -#ifndef GL_ES_VERSION_3_1 -#define GL_ES_VERSION_3_1 1 -#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_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#define GL_MAX_UNIFORM_LOCATIONS 0x826E -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#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_SAMPLES 0x9318 -#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_ATOMIC_COUNTER_BUFFER 0x92C0 -#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_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_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_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#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_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_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#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_BINDING_FORMAT 0x906E -#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_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#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_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#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_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_STENCIL_INDEX 0x1901 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#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_TEXTURE_COMPRESSED 0x86A1 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#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_VERTEX_BINDING_BUFFER 0x8F4F -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -typedef void(GL_APIENTRYP PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, - GLuint num_groups_y, - GLuint num_groups_z); -typedef void(GL_APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, - const void* indirect); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, - GLenum type, - const void* indirect); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC)( - GLuint program, - GLenum programInterface, - GLenum pname, - GLint* params); -typedef GLuint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC)( - GLuint program, - GLenum programInterface, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC)( - GLuint program, - GLenum programInterface, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)( - GLuint program, - GLenum programInterface, - GLuint index, - GLsizei propCount, - const GLenum* props, - GLsizei bufSize, - GLsizei* length, - GLint* params); -typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC)( - GLuint program, - GLenum programInterface, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, - GLbitfield stages, - GLuint program); -typedef void(GL_APIENTRYP PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, - GLuint program); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROGRAMVPROC)( - GLenum type, - GLsizei count, - const GLchar* const* strings); -typedef void(GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC)( - GLsizei n, - const GLuint* pipelines); -typedef void(GL_APIENTRYP PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, - GLuint* pipelines); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, - GLint location, - GLint v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, - GLint location, - GLuint v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, - GLint location, - GLfloat v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, - GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum access, - GLenum format); -typedef void(GL_APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, - GLuint index, - GLboolean* data); -typedef void(GL_APIENTRYP PFNGLMEMORYBARRIERPROC)(GLbitfield barriers); -typedef void(GL_APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC)(GLbitfield barriers); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLboolean fixedsamplelocations); -typedef void(GL_APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, - GLuint index, - GLfloat* val); -typedef void(GL_APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, - GLbitfield mask); -typedef void(GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, - GLint level, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, - GLint level, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, - GLuint buffer, - GLintptr offset, - GLsizei stride); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, - GLint size, - GLenum type, - GLboolean normalized, - GLuint relativeoffset); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, - GLint size, - GLenum type, - GLuint relativeoffset); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, - GLuint bindingindex); -typedef void(GL_APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, - GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDispatchCompute(GLuint num_groups_x, - GLuint num_groups_y, - GLuint num_groups_z); -GL_APICALL void GL_APIENTRY glDispatchComputeIndirect(GLintptr indirect); -GL_APICALL void GL_APIENTRY glDrawArraysIndirect(GLenum mode, - const void* indirect); -GL_APICALL void GL_APIENTRY glDrawElementsIndirect(GLenum mode, - GLenum type, - const void* indirect); -GL_APICALL void GL_APIENTRY glFramebufferParameteri(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv(GLuint program, - GLenum programInterface, - GLenum pname, - GLint* params); -GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex(GLuint program, - GLenum programInterface, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetProgramResourceName(GLuint program, - GLenum programInterface, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetProgramResourceiv(GLuint program, - GLenum programInterface, - GLuint index, - GLsizei propCount, - const GLenum* props, - GLsizei bufSize, - GLsizei* length, - GLint* params); -GL_APICALL GLint GL_APIENTRY -glGetProgramResourceLocation(GLuint program, - GLenum programInterface, - const GLchar* name); -GL_APICALL void GL_APIENTRY glUseProgramStages(GLuint pipeline, - GLbitfield stages, - GLuint program); -GL_APICALL void GL_APIENTRY glActiveShaderProgram(GLuint pipeline, - GLuint program); -GL_APICALL GLuint GL_APIENTRY -glCreateShaderProgramv(GLenum type, - GLsizei count, - const GLchar* const* strings); -GL_APICALL void GL_APIENTRY glBindProgramPipeline(GLuint pipeline); -GL_APICALL void GL_APIENTRY glDeleteProgramPipelines(GLsizei n, - const GLuint* pipelines); -GL_APICALL void GL_APIENTRY glGenProgramPipelines(GLsizei n, GLuint* pipelines); -GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline(GLuint pipeline); -GL_APICALL void GL_APIENTRY glGetProgramPipelineiv(GLuint pipeline, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glProgramUniform1i(GLuint program, - GLint location, - GLint v0); -GL_APICALL void GL_APIENTRY glProgramUniform2i(GLuint program, - GLint location, - GLint v0, - GLint v1); -GL_APICALL void GL_APIENTRY glProgramUniform3i(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glProgramUniform4i(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -GL_APICALL void GL_APIENTRY glProgramUniform1ui(GLuint program, - GLint location, - GLuint v0); -GL_APICALL void GL_APIENTRY glProgramUniform2ui(GLuint program, - GLint location, - GLuint v0, - GLuint v1); -GL_APICALL void GL_APIENTRY glProgramUniform3ui(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -GL_APICALL void GL_APIENTRY glProgramUniform4ui(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -GL_APICALL void GL_APIENTRY glProgramUniform1f(GLuint program, - GLint location, - GLfloat v0); -GL_APICALL void GL_APIENTRY glProgramUniform2f(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1); -GL_APICALL void GL_APIENTRY glProgramUniform3f(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glProgramUniform4f(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -GL_APICALL void GL_APIENTRY glProgramUniform1iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform2iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform3iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform4iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform1uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform2uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform3uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform4uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform1fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform2fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform3fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform4fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glValidateProgramPipeline(GLuint pipeline); -GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog(GLuint pipeline, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glBindImageTexture(GLuint unit, - GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum access, - GLenum format); -GL_APICALL void GL_APIENTRY glGetBooleani_v(GLenum target, - GLuint index, - GLboolean* data); -GL_APICALL void GL_APIENTRY glMemoryBarrier(GLbitfield barriers); -GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion(GLbitfield barriers); -GL_APICALL void GL_APIENTRY -glTexStorage2DMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLboolean fixedsamplelocations); -GL_APICALL void GL_APIENTRY glGetMultisamplefv(GLenum pname, - GLuint index, - GLfloat* val); -GL_APICALL void GL_APIENTRY glSampleMaski(GLuint maskNumber, GLbitfield mask); -GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv(GLenum target, - GLint level, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv(GLenum target, - GLint level, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glBindVertexBuffer(GLuint bindingindex, - GLuint buffer, - GLintptr offset, - GLsizei stride); -GL_APICALL void GL_APIENTRY glVertexAttribFormat(GLuint attribindex, - GLint size, - GLenum type, - GLboolean normalized, - GLuint relativeoffset); -GL_APICALL void GL_APIENTRY glVertexAttribIFormat(GLuint attribindex, - GLint size, - GLenum type, - GLuint relativeoffset); -GL_APICALL void GL_APIENTRY glVertexAttribBinding(GLuint attribindex, - GLuint bindingindex); -GL_APICALL void GL_APIENTRY glVertexBindingDivisor(GLuint bindingindex, - GLuint divisor); -#endif -#endif /* GL_ES_VERSION_3_1 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/GLES3/gl32.h b/glimp/include/GLES3/gl32.h deleted file mode 100644 index 8fdec0ab0526..000000000000 --- a/glimp/include/GLES3/gl32.h +++ /dev/null @@ -1,3451 +0,0 @@ -#ifndef __gl32_h_ -#define __gl32_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 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$ on $Date$ -*/ - -#include - -#ifndef GL_APIENTRYP -#define GL_APIENTRYP GL_APIENTRY * -#endif - -/* Generated on date 20150809 */ - -/* Generated C header for: - * API: gles2 - * Profile: common - * Versions considered: 2\.[0-9]|3\.[012] - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_ES_VERSION_2_0 -#define GL_ES_VERSION_2_0 1 -#include -typedef khronos_int8_t GLbyte; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; -typedef short GLshort; -typedef unsigned short GLushort; -typedef void GLvoid; -typedef struct __GLsync* GLsync; -typedef khronos_int64_t GLint64; -typedef khronos_uint64_t GLuint64; -typedef unsigned int GLenum; -typedef unsigned int GLuint; -typedef char GLchar; -typedef khronos_float_t GLfloat; -typedef khronos_ssize_t GLsizeiptr; -typedef khronos_intptr_t GLintptr; -typedef unsigned int GLbitfield; -typedef int GLint; -typedef unsigned char GLboolean; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_FALSE 0 -#define GL_TRUE 1 -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#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_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#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_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#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_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_TEXTURE 0x1702 -#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_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#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_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 -#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_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 -#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_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#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_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#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_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_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_NONE 0 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -typedef void(GL_APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); -typedef void(GL_APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, - GLuint index, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); -typedef void(GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, - GLuint framebuffer); -typedef void(GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); -typedef void(GL_APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -typedef void(GL_APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -typedef void(GL_APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -typedef GLenum(GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); -typedef void(GL_APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -typedef void(GL_APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d); -typedef void(GL_APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); -typedef void(GL_APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -typedef void(GL_APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -typedef void(GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -typedef void(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef GLuint(GL_APIENTRYP PFNGLCREATEPROGRAMPROC)(void); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); -typedef void(GL_APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, - const GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)( - GLsizei n, - const GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC)( - GLsizei n, - const GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); -typedef void(GL_APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, - const GLuint* textures); -typedef void(GL_APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); -typedef void(GL_APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); -typedef void(GL_APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); -typedef void(GL_APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); -typedef void(GL_APIENTRYP PFNGLDISABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, - GLint first, - GLsizei count); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_APIENTRYP PFNGLENABLEPROC)(GLenum cap); -typedef void(GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void(GL_APIENTRYP PFNGLFINISHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFLUSHPROC)(void); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)( - GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -typedef void(GL_APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); -typedef void(GL_APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint* buffers); -typedef void(GL_APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, - GLuint* framebuffers); -typedef void(GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, - GLuint* renderbuffers); -typedef void(GL_APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint* textures); -typedef void(GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -typedef GLint(GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef GLenum(GL_APIENTRYP PFNGLGETERRORPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat* data); -typedef void(GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)( - GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint* data); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)( - GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -typedef void(GL_APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, - GLint location, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, - GLint location, - GLint* params); -typedef GLint(GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, - GLenum pname, - void** pointer); -typedef void(GL_APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); -typedef GLboolean(GL_APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); -typedef GLboolean(GL_APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); -typedef GLboolean(GL_APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef GLboolean(GL_APIENTRYP PFNGLISSHADERPROC)(GLuint shader); -typedef GLboolean(GL_APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); -typedef void(GL_APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); -typedef void(GL_APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); -typedef void(GL_APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, - GLfloat units); -typedef void(GL_APIENTRYP PFNGLREADPIXELSPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -typedef void(GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, - GLboolean invert); -typedef void(GL_APIENTRYP PFNGLSCISSORPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, - GLuint mask); -typedef void(GL_APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, - GLenum zfail, - GLenum zpass); -typedef void(GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -typedef void(GL_APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, - GLenum pname, - const GLfloat* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, - GLfloat x, - GLfloat y); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, - const GLfloat* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLVIEWPORTPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, - GLuint index, - const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, - GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer(GLenum target, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glBlendEquation(GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, - GLenum dfactorRGB, - GLenum sfactorAlpha, - GLenum dfactorAlpha); -GL_APICALL void GL_APIENTRY glBufferData(GLenum target, - GLsizeiptr size, - const void* data, - GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData(GLenum target, - GLintptr offset, - GLsizeiptr size, - const void* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target); -GL_APICALL void GL_APIENTRY glClear(GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor(GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha); -GL_APICALL void GL_APIENTRY glClearDepthf(GLfloat d); -GL_APICALL void GL_APIENTRY glClearStencil(GLint s); -GL_APICALL void GL_APIENTRY glColorMask(GLboolean red, - GLboolean green, - GLboolean blue, - GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D(GLenum target, - GLint level, - GLenum internalformat, - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram(void); -GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type); -GL_APICALL void GL_APIENTRY glCullFace(GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, - const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, - const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc(GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask(GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef(GLfloat n, GLfloat f); -GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable(GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays(GLenum mode, - GLint first, - GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glEnable(GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index); -GL_APICALL void GL_APIENTRY glFinish(void); -GL_APICALL void GL_APIENTRY glFlush(void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, - GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, - GLenum attachment, - GLenum textarget, - GLuint texture, - GLint level); -GL_APICALL void GL_APIENTRY glFrontFace(GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap(GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, - GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLint* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, - GLsizei maxCount, - GLsizei* count, - GLuint* shaders); -GL_APICALL GLint GL_APIENTRY glGetAttribLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError(void); -GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* data); -GL_APICALL void GL_APIENTRY -glGetFramebufferAttachmentParameteriv(GLenum target, - GLenum attachment, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* data); -GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, - GLenum precisiontype, - GLint* range, - GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, - GLsizei bufSize, - GLsizei* length, - GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv(GLenum target, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, - GLint location, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, - GLint location, - GLint* params); -GL_APICALL GLint GL_APIENTRY glGetUniformLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, - GLenum pname, - void** pointer); -GL_APICALL void GL_APIENTRY glHint(GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled(GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth(GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - void* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler(void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage(GLenum target, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage(GLfloat value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor(GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei count, - const GLuint* shaders, - GLenum binaryformat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, - GLsizei count, - const GLchar* const* string, - const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate(GLenum face, - GLenum func, - GLint ref, - GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask(GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, - GLenum zfail, - GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, - GLenum sfail, - GLenum dpfail, - GLenum dppass); -GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf(GLenum target, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv(GLenum target, - GLenum pname, - const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_APIENTRY glUniform1f(GLint location, GLfloat v0); -GL_APICALL void GL_APIENTRY glUniform1fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform1i(GLint location, GLint v0); -GL_APICALL void GL_APIENTRY glUniform1iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform2f(GLint location, GLfloat v0, GLfloat v1); -GL_APICALL void GL_APIENTRY glUniform2fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform2i(GLint location, GLint v0, GLint v1); -GL_APICALL void GL_APIENTRY glUniform2iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniform3f(GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glUniform3fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniform3i(GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glUniform3iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY -glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GL_APICALL void GL_APIENTRY glUniform4fv(GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY -glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GL_APICALL void GL_APIENTRY glUniform4iv(GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram(GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib2f(GLuint index, - GLfloat x, - GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttrib3f(GLuint index, - GLfloat x, - GLfloat y, - GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY -glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* v); -GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint index, - GLint size, - GLenum type, - GLboolean normalized, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glViewport(GLint x, - GLint y, - GLsizei width, - GLsizei height); -#endif -#endif /* GL_ES_VERSION_2_0 */ - -#ifndef GL_ES_VERSION_3_0 -#define GL_ES_VERSION_3_0 1 -typedef unsigned short GLhalf; -#define GL_READ_BUFFER 0x0C02 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_RED 0x1903 -#define GL_RGB8 0x8051 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#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_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#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_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#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_SRGB8_ALPHA8 0x8C43 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#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_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#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_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_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_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#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_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#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_2D_ARRAY 0x8DD7 -#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_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_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#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_TEXTURE_LAYER 0x8CD4 -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#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_COLOR_ATTACHMENT16 0x8CF0 -#define GL_COLOR_ATTACHMENT17 0x8CF1 -#define GL_COLOR_ATTACHMENT18 0x8CF2 -#define GL_COLOR_ATTACHMENT19 0x8CF3 -#define GL_COLOR_ATTACHMENT20 0x8CF4 -#define GL_COLOR_ATTACHMENT21 0x8CF5 -#define GL_COLOR_ATTACHMENT22 0x8CF6 -#define GL_COLOR_ATTACHMENT23 0x8CF7 -#define GL_COLOR_ATTACHMENT24 0x8CF8 -#define GL_COLOR_ATTACHMENT25 0x8CF9 -#define GL_COLOR_ATTACHMENT26 0x8CFA -#define GL_COLOR_ATTACHMENT27 0x8CFB -#define GL_COLOR_ATTACHMENT28 0x8CFC -#define GL_COLOR_ATTACHMENT29 0x8CFD -#define GL_COLOR_ATTACHMENT30 0x8CFE -#define GL_COLOR_ATTACHMENT31 0x8CFF -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#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_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_RG8 0x822B -#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_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 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 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#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_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#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_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_INT_2_10_10_10_REV 0x8D9F -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#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_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_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_TEXTURE_IMMUTABLE_FORMAT 0x912F -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -typedef void(GL_APIENTRYP PFNGLREADBUFFERPROC)(GLenum src); -typedef void(GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -typedef void(GL_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(GL_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(GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -typedef void(GL_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(GL_APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint* ids); -typedef void(GL_APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISQUERYPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); -typedef void(GL_APIENTRYP PFNGLENDQUERYPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, - GLenum pname, - GLuint* params); -typedef GLboolean(GL_APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, - GLenum pname, - void** params); -typedef void(GL_APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum* bufs); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -typedef void*(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -typedef void(GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, - GLintptr offset, - GLsizeiptr length); -typedef void(GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, - const GLuint* arrays); -typedef void(GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint* arrays); -typedef GLboolean(GL_APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array); -typedef void(GL_APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, - GLuint index, - GLint* data); -typedef void(GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)( - GLenum primitiveMode); -typedef void(GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, - GLuint index, - GLuint buffer); -typedef void(GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)( - GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode); -typedef void(GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const void* pointer); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, - GLint x, - GLint y, - GLint z, - GLint w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, - GLuint x, - GLuint y, - GLuint z, - GLuint w); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, - const GLint* v); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, - const GLuint* v); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, - GLint location, - GLuint* params); -typedef GLint(GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); -typedef void(GL_APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, - GLint drawbuffer, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil); -typedef const GLubyte*(GL_APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, - GLuint index); -typedef void(GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC)( - GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)( - GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -typedef GLuint(GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)( - GLuint program, - const GLchar* uniformBlockName); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName); -typedef void(GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)( - GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount); -typedef GLsync(GL_APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, - GLbitfield flags); -typedef GLboolean(GL_APIENTRYP PFNGLISSYNCPROC)(GLsync sync); -typedef void(GL_APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync); -typedef GLenum(GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64* data); -typedef void(GL_APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -typedef void(GL_APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, - GLuint index, - GLint64* data); -typedef void(GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, - GLenum pname, - GLint64* params); -typedef void(GL_APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, - GLuint* samplers); -typedef void(GL_APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, - const GLuint* samplers); -typedef GLboolean(GL_APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler); -typedef void(GL_APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, - GLenum pname, - const GLint* param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, - GLenum pname, - GLfloat param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, - GLenum pname, - const GLfloat* param); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, - GLuint divisor); -typedef void(GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, - GLuint id); -typedef void(GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, - const GLuint* ids); -typedef void(GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, - GLuint* ids); -typedef GLboolean(GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); -typedef void(GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC)(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -typedef void(GL_APIENTRYP PFNGLPROGRAMBINARYPROC)(GLuint program, - GLenum binaryFormat, - const void* binary, - GLsizei length); -typedef void(GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC)(GLuint program, - GLenum pname, - GLint value); -typedef void(GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -typedef void(GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC)( - GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE2DPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE3DPROC)(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -typedef void(GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBuffer(GLenum src); -GL_APICALL void GL_APIENTRY glDrawRangeElements(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices); -GL_APICALL void GL_APIENTRY glTexImage3D(GLenum target, - GLint level, - GLint internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLenum format, - GLenum type, - const void* pixels); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLint zoffset, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3D(GLenum target, - GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLint border, - GLsizei imageSize, - const void* data); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids); -GL_APICALL void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsQuery(GLuint id); -GL_APICALL void GL_APIENTRY glBeginQuery(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glEndQuery(GLenum target); -GL_APICALL void GL_APIENTRY glGetQueryiv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetQueryObjectuiv(GLuint id, - GLenum pname, - GLuint* params); -GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer(GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointerv(GLenum target, - GLenum pname, - void** params); -GL_APICALL void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs); -GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glBlitFramebuffer(GLint srcX0, - GLint srcY0, - GLint srcX1, - GLint srcY1, - GLint dstX0, - GLint dstY0, - GLint dstX1, - GLint dstY1, - GLbitfield mask, - GLenum filter); -GL_APICALL void GL_APIENTRY -glRenderbufferStorageMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glFramebufferTextureLayer(GLenum target, - GLenum attachment, - GLuint texture, - GLint level, - GLint layer); -GL_APICALL void* GL_APIENTRY glMapBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, - GLintptr offset, - GLsizeiptr length); -GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArrays(GLsizei n, - const GLuint* arrays); -GL_APICALL void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArray(GLuint array); -GL_APICALL void GL_APIENTRY glGetIntegeri_v(GLenum target, - GLuint index, - GLint* data); -GL_APICALL void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode); -GL_APICALL void GL_APIENTRY glEndTransformFeedback(void); -GL_APICALL void GL_APIENTRY glBindBufferRange(GLenum target, - GLuint index, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY glBindBufferBase(GLenum target, - GLuint index, - GLuint buffer); -GL_APICALL void GL_APIENTRY -glTransformFeedbackVaryings(GLuint program, - GLsizei count, - const GLchar* const* varyings, - GLenum bufferMode); -GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLsizei* size, - GLenum* type, - GLchar* name); -GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const void* pointer); -GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY -glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY -glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GL_APICALL void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v); -GL_APICALL void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v); -GL_APICALL void GL_APIENTRY glGetUniformuiv(GLuint program, - GLint location, - GLuint* params); -GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, - const GLchar* name); -GL_APICALL void GL_APIENTRY glUniform1ui(GLint location, GLuint v0); -GL_APICALL void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1); -GL_APICALL void GL_APIENTRY glUniform3ui(GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -GL_APICALL void GL_APIENTRY -glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GL_APICALL void GL_APIENTRY glUniform1uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform2uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform3uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glUniform4uiv(GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glClearBufferiv(GLenum buffer, - GLint drawbuffer, - const GLint* value); -GL_APICALL void GL_APIENTRY glClearBufferuiv(GLenum buffer, - GLint drawbuffer, - const GLuint* value); -GL_APICALL void GL_APIENTRY glClearBufferfv(GLenum buffer, - GLint drawbuffer, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glClearBufferfi(GLenum buffer, - GLint drawbuffer, - GLfloat depth, - GLint stencil); -GL_APICALL const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index); -GL_APICALL void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, - GLenum writeTarget, - GLintptr readOffset, - GLintptr writeOffset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY -glGetUniformIndices(GLuint program, - GLsizei uniformCount, - const GLchar* const* uniformNames, - GLuint* uniformIndices); -GL_APICALL void GL_APIENTRY glGetActiveUniformsiv(GLuint program, - GLsizei uniformCount, - const GLuint* uniformIndices, - GLenum pname, - GLint* params); -GL_APICALL GLuint GL_APIENTRY -glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName); -GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY -glGetActiveUniformBlockName(GLuint program, - GLuint uniformBlockIndex, - GLsizei bufSize, - GLsizei* length, - GLchar* uniformBlockName); -GL_APICALL void GL_APIENTRY glUniformBlockBinding(GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -GL_APICALL void GL_APIENTRY glDrawArraysInstanced(GLenum mode, - GLint first, - GLsizei count, - GLsizei instancecount); -GL_APICALL void GL_APIENTRY glDrawElementsInstanced(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount); -GL_APICALL GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags); -GL_APICALL GLboolean GL_APIENTRY glIsSync(GLsync sync); -GL_APICALL void GL_APIENTRY glDeleteSync(GLsync sync); -GL_APICALL GLenum GL_APIENTRY glClientWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); -GL_APICALL void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* data); -GL_APICALL void GL_APIENTRY glGetSynciv(GLsync sync, - GLenum pname, - GLsizei bufSize, - GLsizei* length, - GLint* values); -GL_APICALL void GL_APIENTRY glGetInteger64i_v(GLenum target, - GLuint index, - GLint64* data); -GL_APICALL void GL_APIENTRY glGetBufferParameteri64v(GLenum target, - GLenum pname, - GLint64* params); -GL_APICALL void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers); -GL_APICALL void GL_APIENTRY glDeleteSamplers(GLsizei count, - const GLuint* samplers); -GL_APICALL GLboolean GL_APIENTRY glIsSampler(GLuint sampler); -GL_APICALL void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler); -GL_APICALL void GL_APIENTRY glSamplerParameteri(GLuint sampler, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glSamplerParameteriv(GLuint sampler, - GLenum pname, - const GLint* param); -GL_APICALL void GL_APIENTRY glSamplerParameterf(GLuint sampler, - GLenum pname, - GLfloat param); -GL_APICALL void GL_APIENTRY glSamplerParameterfv(GLuint sampler, - GLenum pname, - const GLfloat* param); -GL_APICALL void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor); -GL_APICALL void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, - const GLuint* ids); -GL_APICALL void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids); -GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id); -GL_APICALL void GL_APIENTRY glPauseTransformFeedback(void); -GL_APICALL void GL_APIENTRY glResumeTransformFeedback(void); -GL_APICALL void GL_APIENTRY glGetProgramBinary(GLuint program, - GLsizei bufSize, - GLsizei* length, - GLenum* binaryFormat, - void* binary); -GL_APICALL void GL_APIENTRY glProgramBinary(GLuint program, - GLenum binaryFormat, - const void* binary, - GLsizei length); -GL_APICALL void GL_APIENTRY glProgramParameteri(GLuint program, - GLenum pname, - GLint value); -GL_APICALL void GL_APIENTRY glInvalidateFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments); -GL_APICALL void GL_APIENTRY -glInvalidateSubFramebuffer(GLenum target, - GLsizei numAttachments, - const GLenum* attachments, - GLint x, - GLint y, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage2D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage3D(GLenum target, - GLsizei levels, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth); -GL_APICALL void GL_APIENTRY glGetInternalformativ(GLenum target, - GLenum internalformat, - GLenum pname, - GLsizei bufSize, - GLint* params); -#endif -#endif /* GL_ES_VERSION_3_0 */ - -#ifndef GL_ES_VERSION_3_1 -#define GL_ES_VERSION_3_1 1 -#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_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#define GL_MAX_UNIFORM_LOCATIONS 0x826E -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#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_SAMPLES 0x9318 -#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_ATOMIC_COUNTER_BUFFER 0x92C0 -#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_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_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_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#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_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_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#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_BINDING_FORMAT 0x906E -#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_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#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_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#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_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_STENCIL_INDEX 0x1901 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#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_TEXTURE_COMPRESSED 0x86A1 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#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_VERTEX_BINDING_BUFFER 0x8F4F -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -typedef void(GL_APIENTRYP PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, - GLuint num_groups_y, - GLuint num_groups_z); -typedef void(GL_APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); -typedef void(GL_APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, - const void* indirect); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, - GLenum type, - const void* indirect); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, - GLenum pname, - GLint param); -typedef void(GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC)( - GLuint program, - GLenum programInterface, - GLenum pname, - GLint* params); -typedef GLuint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC)( - GLuint program, - GLenum programInterface, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC)( - GLuint program, - GLenum programInterface, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLchar* name); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)( - GLuint program, - GLenum programInterface, - GLuint index, - GLsizei propCount, - const GLenum* props, - GLsizei bufSize, - GLsizei* length, - GLint* params); -typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC)( - GLuint program, - GLenum programInterface, - const GLchar* name); -typedef void(GL_APIENTRYP PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, - GLbitfield stages, - GLuint program); -typedef void(GL_APIENTRYP PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, - GLuint program); -typedef GLuint(GL_APIENTRYP PFNGLCREATESHADERPROGRAMVPROC)( - GLenum type, - GLsizei count, - const GLchar* const* strings); -typedef void(GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC)( - GLsizei n, - const GLuint* pipelines); -typedef void(GL_APIENTRYP PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, - GLuint* pipelines); -typedef GLboolean(GL_APIENTRYP PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, - GLint location, - GLint v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, - GLint location, - GLuint v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, - GLint location, - GLfloat v0); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)( - GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -typedef void(GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline); -typedef void(GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -typedef void(GL_APIENTRYP PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, - GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum access, - GLenum format); -typedef void(GL_APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, - GLuint index, - GLboolean* data); -typedef void(GL_APIENTRYP PFNGLMEMORYBARRIERPROC)(GLbitfield barriers); -typedef void(GL_APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC)(GLbitfield barriers); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLboolean fixedsamplelocations); -typedef void(GL_APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, - GLuint index, - GLfloat* val); -typedef void(GL_APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, - GLbitfield mask); -typedef void(GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, - GLint level, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, - GLint level, - GLenum pname, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, - GLuint buffer, - GLintptr offset, - GLsizei stride); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, - GLint size, - GLenum type, - GLboolean normalized, - GLuint relativeoffset); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, - GLint size, - GLenum type, - GLuint relativeoffset); -typedef void(GL_APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, - GLuint bindingindex); -typedef void(GL_APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, - GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDispatchCompute(GLuint num_groups_x, - GLuint num_groups_y, - GLuint num_groups_z); -GL_APICALL void GL_APIENTRY glDispatchComputeIndirect(GLintptr indirect); -GL_APICALL void GL_APIENTRY glDrawArraysIndirect(GLenum mode, - const void* indirect); -GL_APICALL void GL_APIENTRY glDrawElementsIndirect(GLenum mode, - GLenum type, - const void* indirect); -GL_APICALL void GL_APIENTRY glFramebufferParameteri(GLenum target, - GLenum pname, - GLint param); -GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv(GLuint program, - GLenum programInterface, - GLenum pname, - GLint* params); -GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex(GLuint program, - GLenum programInterface, - const GLchar* name); -GL_APICALL void GL_APIENTRY glGetProgramResourceName(GLuint program, - GLenum programInterface, - GLuint index, - GLsizei bufSize, - GLsizei* length, - GLchar* name); -GL_APICALL void GL_APIENTRY glGetProgramResourceiv(GLuint program, - GLenum programInterface, - GLuint index, - GLsizei propCount, - const GLenum* props, - GLsizei bufSize, - GLsizei* length, - GLint* params); -GL_APICALL GLint GL_APIENTRY -glGetProgramResourceLocation(GLuint program, - GLenum programInterface, - const GLchar* name); -GL_APICALL void GL_APIENTRY glUseProgramStages(GLuint pipeline, - GLbitfield stages, - GLuint program); -GL_APICALL void GL_APIENTRY glActiveShaderProgram(GLuint pipeline, - GLuint program); -GL_APICALL GLuint GL_APIENTRY -glCreateShaderProgramv(GLenum type, - GLsizei count, - const GLchar* const* strings); -GL_APICALL void GL_APIENTRY glBindProgramPipeline(GLuint pipeline); -GL_APICALL void GL_APIENTRY glDeleteProgramPipelines(GLsizei n, - const GLuint* pipelines); -GL_APICALL void GL_APIENTRY glGenProgramPipelines(GLsizei n, GLuint* pipelines); -GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline(GLuint pipeline); -GL_APICALL void GL_APIENTRY glGetProgramPipelineiv(GLuint pipeline, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glProgramUniform1i(GLuint program, - GLint location, - GLint v0); -GL_APICALL void GL_APIENTRY glProgramUniform2i(GLuint program, - GLint location, - GLint v0, - GLint v1); -GL_APICALL void GL_APIENTRY glProgramUniform3i(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2); -GL_APICALL void GL_APIENTRY glProgramUniform4i(GLuint program, - GLint location, - GLint v0, - GLint v1, - GLint v2, - GLint v3); -GL_APICALL void GL_APIENTRY glProgramUniform1ui(GLuint program, - GLint location, - GLuint v0); -GL_APICALL void GL_APIENTRY glProgramUniform2ui(GLuint program, - GLint location, - GLuint v0, - GLuint v1); -GL_APICALL void GL_APIENTRY glProgramUniform3ui(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2); -GL_APICALL void GL_APIENTRY glProgramUniform4ui(GLuint program, - GLint location, - GLuint v0, - GLuint v1, - GLuint v2, - GLuint v3); -GL_APICALL void GL_APIENTRY glProgramUniform1f(GLuint program, - GLint location, - GLfloat v0); -GL_APICALL void GL_APIENTRY glProgramUniform2f(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1); -GL_APICALL void GL_APIENTRY glProgramUniform3f(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2); -GL_APICALL void GL_APIENTRY glProgramUniform4f(GLuint program, - GLint location, - GLfloat v0, - GLfloat v1, - GLfloat v2, - GLfloat v3); -GL_APICALL void GL_APIENTRY glProgramUniform1iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform2iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform3iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform4iv(GLuint program, - GLint location, - GLsizei count, - const GLint* value); -GL_APICALL void GL_APIENTRY glProgramUniform1uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform2uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform3uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform4uiv(GLuint program, - GLint location, - GLsizei count, - const GLuint* value); -GL_APICALL void GL_APIENTRY glProgramUniform1fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform2fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform3fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniform4fv(GLuint program, - GLint location, - GLsizei count, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv(GLuint program, - GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat* value); -GL_APICALL void GL_APIENTRY glValidateProgramPipeline(GLuint pipeline); -GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog(GLuint pipeline, - GLsizei bufSize, - GLsizei* length, - GLchar* infoLog); -GL_APICALL void GL_APIENTRY glBindImageTexture(GLuint unit, - GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum access, - GLenum format); -GL_APICALL void GL_APIENTRY glGetBooleani_v(GLenum target, - GLuint index, - GLboolean* data); -GL_APICALL void GL_APIENTRY glMemoryBarrier(GLbitfield barriers); -GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion(GLbitfield barriers); -GL_APICALL void GL_APIENTRY -glTexStorage2DMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLboolean fixedsamplelocations); -GL_APICALL void GL_APIENTRY glGetMultisamplefv(GLenum pname, - GLuint index, - GLfloat* val); -GL_APICALL void GL_APIENTRY glSampleMaski(GLuint maskNumber, GLbitfield mask); -GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv(GLenum target, - GLint level, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv(GLenum target, - GLint level, - GLenum pname, - GLfloat* params); -GL_APICALL void GL_APIENTRY glBindVertexBuffer(GLuint bindingindex, - GLuint buffer, - GLintptr offset, - GLsizei stride); -GL_APICALL void GL_APIENTRY glVertexAttribFormat(GLuint attribindex, - GLint size, - GLenum type, - GLboolean normalized, - GLuint relativeoffset); -GL_APICALL void GL_APIENTRY glVertexAttribIFormat(GLuint attribindex, - GLint size, - GLenum type, - GLuint relativeoffset); -GL_APICALL void GL_APIENTRY glVertexAttribBinding(GLuint attribindex, - GLuint bindingindex); -GL_APICALL void GL_APIENTRY glVertexBindingDivisor(GLuint bindingindex, - GLuint divisor); -#endif -#endif /* GL_ES_VERSION_3_1 */ - -#ifndef GL_ES_VERSION_3_2 -#define GL_ES_VERSION_3_2 1 -typedef void(GL_APIENTRY* GLDEBUGPROC)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* message, - const void* userParam); -#define GL_MULTISAMPLE_LINE_WIDTH_RANGE 0x9381 -#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY 0x9382 -#define GL_MULTIPLY 0x9294 -#define GL_SCREEN 0x9295 -#define GL_OVERLAY 0x9296 -#define GL_DARKEN 0x9297 -#define GL_LIGHTEN 0x9298 -#define GL_COLORDODGE 0x9299 -#define GL_COLORBURN 0x929A -#define GL_HARDLIGHT 0x929B -#define GL_SOFTLIGHT 0x929C -#define GL_DIFFERENCE 0x929E -#define GL_EXCLUSION 0x92A0 -#define GL_HSL_HUE 0x92AD -#define GL_HSL_SATURATION 0x92AE -#define GL_HSL_COLOR 0x92AF -#define GL_HSL_LUMINOSITY 0x92B0 -#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_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_VERTEX_ARRAY 0x8074 -#define GL_QUERY 0x82E3 -#define GL_PROGRAM_PIPELINE 0x82E4 -#define GL_SAMPLER 0x82E6 -#define GL_MAX_LABEL_LENGTH 0x82E8 -#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_OUTPUT 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_UNDEFINED_VERTEX 0x8260 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define GL_PRIMITIVE_BOUNDING_BOX 0x92BE -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 -#define GL_CONTEXT_FLAGS 0x821E -#define GL_LOSE_CONTEXT_ON_RESET 0x8252 -#define GL_GUILTY_CONTEXT_RESET 0x8253 -#define GL_INNOCENT_CONTEXT_RESET 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 -#define GL_NO_RESET_NOTIFICATION 0x8261 -#define GL_CONTEXT_LOST 0x0507 -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#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_QUADS 0x0007 -#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_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define GL_IS_PER_PATCH 0x92E7 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_TEXTURE_BUFFER_BINDING 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_BUFFER_OFFSET_ALIGNMENT 0x919F -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_TEXTURE_BUFFER_OFFSET 0x919D -#define GL_TEXTURE_BUFFER_SIZE 0x919E -#define GL_COMPRESSED_RGBA_ASTC_4x4 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12 0x93DD -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#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_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -typedef void(GL_APIENTRYP PFNGLBLENDBARRIERPROC)(void); -typedef void(GL_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(GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled); -typedef void(GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf); -typedef void(GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, - const void* userParam); -typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog); -typedef void(GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC)(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message); -typedef void(GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC)(void); -typedef void(GL_APIENTRYP PFNGLOBJECTLABELPROC)(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETOBJECTLABELPROC)(GLenum identifier, - GLuint name, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -typedef void(GL_APIENTRYP PFNGLOBJECTPTRLABELPROC)(const void* ptr, - GLsizei length, - const GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC)(const void* ptr, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -typedef void(GL_APIENTRYP PFNGLGETPOINTERVPROC)(GLenum pname, void** params); -typedef void(GL_APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode); -typedef void(GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, - GLenum modeRGB, - GLenum modeAlpha); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCIPROC)(GLuint buf, - GLenum src, - GLenum dst); -typedef void(GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -typedef void(GL_APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, - GLboolean r, - GLboolean g, - GLboolean b, - GLboolean a); -typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, - GLuint index); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)( - GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)( - GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex); -typedef void(GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, - GLenum attachment, - GLuint texture, - GLint level); -typedef void(GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXPROC)(GLfloat minX, - GLfloat minY, - GLfloat minZ, - GLfloat minW, - GLfloat maxX, - GLfloat maxY, - GLfloat maxZ, - GLfloat maxW); -typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC)(void); -typedef void(GL_APIENTRYP PFNGLREADNPIXELSPROC)(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMFVPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLfloat* params); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMIVPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETNUNIFORMUIVPROC)(GLuint program, - GLint location, - GLsizei bufSize, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLMINSAMPLESHADINGPROC)(GLfloat value); -typedef void(GL_APIENTRYP PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, - GLenum pname, - const GLint* params); -typedef void(GL_APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, - GLenum pname, - const GLuint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, - GLenum pname, - const GLint* param); -typedef void(GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, - GLenum pname, - const GLuint* param); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, - GLenum pname, - GLint* params); -typedef void(GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, - GLenum pname, - GLuint* params); -typedef void(GL_APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, - GLenum internalformat, - GLuint buffer); -typedef void(GL_APIENTRYP PFNGLTEXBUFFERRANGEPROC)(GLenum target, - GLenum internalformat, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -typedef void(GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC)( - GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLboolean fixedsamplelocations); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlendBarrier(void); -GL_APICALL void GL_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); -GL_APICALL void GL_APIENTRY glDebugMessageControl(GLenum source, - GLenum type, - GLenum severity, - GLsizei count, - const GLuint* ids, - GLboolean enabled); -GL_APICALL void GL_APIENTRY glDebugMessageInsert(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* buf); -GL_APICALL void GL_APIENTRY glDebugMessageCallback(GLDEBUGPROC callback, - const void* userParam); -GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog(GLuint count, - GLsizei bufSize, - GLenum* sources, - GLenum* types, - GLuint* ids, - GLenum* severities, - GLsizei* lengths, - GLchar* messageLog); -GL_APICALL void GL_APIENTRY glPushDebugGroup(GLenum source, - GLuint id, - GLsizei length, - const GLchar* message); -GL_APICALL void GL_APIENTRY glPopDebugGroup(void); -GL_APICALL void GL_APIENTRY glObjectLabel(GLenum identifier, - GLuint name, - GLsizei length, - const GLchar* label); -GL_APICALL void GL_APIENTRY glGetObjectLabel(GLenum identifier, - GLuint name, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -GL_APICALL void GL_APIENTRY glObjectPtrLabel(const void* ptr, - GLsizei length, - const GLchar* label); -GL_APICALL void GL_APIENTRY glGetObjectPtrLabel(const void* ptr, - GLsizei bufSize, - GLsizei* length, - GLchar* label); -GL_APICALL void GL_APIENTRY glGetPointerv(GLenum pname, void** params); -GL_APICALL void GL_APIENTRY glEnablei(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glDisablei(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glBlendEquationi(GLuint buf, GLenum mode); -GL_APICALL void GL_APIENTRY glBlendEquationSeparatei(GLuint buf, - GLenum modeRGB, - GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunci(GLuint buf, GLenum src, GLenum dst); -GL_APICALL void GL_APIENTRY glBlendFuncSeparatei(GLuint buf, - GLenum srcRGB, - GLenum dstRGB, - GLenum srcAlpha, - GLenum dstAlpha); -GL_APICALL void GL_APIENTRY -glColorMaski(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GL_APICALL GLboolean GL_APIENTRY glIsEnabledi(GLenum target, GLuint index); -GL_APICALL void GL_APIENTRY glDrawElementsBaseVertex(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertex(GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const void* indices, - GLint basevertex); -GL_APICALL void GL_APIENTRY -glDrawElementsInstancedBaseVertex(GLenum mode, - GLsizei count, - GLenum type, - const void* indices, - GLsizei instancecount, - GLint basevertex); -GL_APICALL void GL_APIENTRY glFramebufferTexture(GLenum target, - GLenum attachment, - GLuint texture, - GLint level); -GL_APICALL void GL_APIENTRY glPrimitiveBoundingBox(GLfloat minX, - GLfloat minY, - GLfloat minZ, - GLfloat minW, - GLfloat maxX, - GLfloat maxY, - GLfloat maxZ, - GLfloat maxW); -GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatus(void); -GL_APICALL void GL_APIENTRY glReadnPixels(GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLsizei bufSize, - void* data); -GL_APICALL void GL_APIENTRY glGetnUniformfv(GLuint program, - GLint location, - GLsizei bufSize, - GLfloat* params); -GL_APICALL void GL_APIENTRY glGetnUniformiv(GLuint program, - GLint location, - GLsizei bufSize, - GLint* params); -GL_APICALL void GL_APIENTRY glGetnUniformuiv(GLuint program, - GLint location, - GLsizei bufSize, - GLuint* params); -GL_APICALL void GL_APIENTRY glMinSampleShading(GLfloat value); -GL_APICALL void GL_APIENTRY glPatchParameteri(GLenum pname, GLint value); -GL_APICALL void GL_APIENTRY glTexParameterIiv(GLenum target, - GLenum pname, - const GLint* params); -GL_APICALL void GL_APIENTRY glTexParameterIuiv(GLenum target, - GLenum pname, - const GLuint* params); -GL_APICALL void GL_APIENTRY glGetTexParameterIiv(GLenum target, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetTexParameterIuiv(GLenum target, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY glSamplerParameterIiv(GLuint sampler, - GLenum pname, - const GLint* param); -GL_APICALL void GL_APIENTRY glSamplerParameterIuiv(GLuint sampler, - GLenum pname, - const GLuint* param); -GL_APICALL void GL_APIENTRY glGetSamplerParameterIiv(GLuint sampler, - GLenum pname, - GLint* params); -GL_APICALL void GL_APIENTRY glGetSamplerParameterIuiv(GLuint sampler, - GLenum pname, - GLuint* params); -GL_APICALL void GL_APIENTRY glTexBuffer(GLenum target, - GLenum internalformat, - GLuint buffer); -GL_APICALL void GL_APIENTRY glTexBufferRange(GLenum target, - GLenum internalformat, - GLuint buffer, - GLintptr offset, - GLsizeiptr size); -GL_APICALL void GL_APIENTRY -glTexStorage3DMultisample(GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLsizei depth, - GLboolean fixedsamplelocations); -#endif -#endif /* GL_ES_VERSION_3_2 */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glimp/include/GLES3/gl3platform.h b/glimp/include/GLES3/gl3platform.h deleted file mode 100644 index 956514d86e01..000000000000 --- a/glimp/include/GLES3/gl3platform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __gl3platform_h_ -#define __gl3platform_h_ - -/* $Revision: 23328 $ on $Date:: 2013-10-02 02:28:28 -0700 #$ */ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -#include - -#ifndef GL_APICALL -#define GL_APICALL KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __gl3platform_h_ */ diff --git a/glimp/include/KHR/khrplatform.h b/glimp/include/KHR/khrplatform.h deleted file mode 100644 index 9f0487dca140..000000000000 --- a/glimp/include/KHR/khrplatform.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2009 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. -*/ - -/* Khronos platform-specific types and definitions. - * - * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by sending them to the public Khronos Bugzilla - * (http://khronos.org/bugzilla) by filing a bug against product - * "Khronos (general)" component "Registry". - * - * A predefined template which fills in some of the bug fields can be - * reached using http://tinyurl.com/khrplatform-h-bugreport, but you - * must create a Bugzilla login first. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -#include GLIMP_KHRPLATFORM_INCLUDE - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/glimp/polymorphic_downcast.h b/glimp/polymorphic_downcast.h deleted file mode 100644 index 56dae892b657..000000000000 --- a/glimp/polymorphic_downcast.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2014 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_POLYMORPHIC_DOWNCAST_H_ -#define GLIMP_POLYMORPHIC_DOWNCAST_H_ - -#include "starboard/common/log.h" - -namespace nb { - -// This function is designed to model the behavior of polymorphic_downcast from -// http://www.boost.org/doc/libs/1_56_0/libs/conversion/cast.htm - -template -Derived polymorphic_downcast(Base base) { -#if defined(COBALT_BUILD_TYPE_DEBUG) || defined(COBALT_BUILD_TYPE_DEVEL) - SB_DCHECK(dynamic_cast(base) == base); -#endif - return static_cast(base); -} - -} // namespace nb - -#endif // GLIMP_POLYMORPHIC_DOWNCAST_H_ diff --git a/glimp/rect.h b/glimp/rect.h deleted file mode 100644 index 9d2e47decbed..000000000000 --- a/glimp/rect.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_RECT_H_ -#define GLIMP_RECT_H_ - -namespace nb { - -// A simple Rect structure to simplify repetitive definitions of a rectangle -// in various code. -template -struct Rect { - Rect(T left, T top, T width, T height) - : left(left), top(top), width(width), height(height) {} - - void Set(T left_p, T top_p, T width_p, T height_p) { - left = left_p; - top = top_p; - width = width_p; - height = height_p; - } - - T left; - T top; - T width; - T height; -}; - -} // namespace nb - -#endif // GLIMP_RECT_H_ diff --git a/glimp/ref_counted.cc b/glimp/ref_counted.cc deleted file mode 100644 index 00b739e171b9..000000000000 --- a/glimp/ref_counted.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "glimp/ref_counted.h" - -#include "starboard/common/log.h" - -namespace nb { - -namespace subtle { - -RefCountedBase::RefCountedBase() - : ref_count_(0) -#ifndef NDEBUG - , - in_dtor_(false) -#endif -{ -} - -RefCountedBase::~RefCountedBase() { -#ifndef NDEBUG - SB_DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()"; -#endif -} - -void RefCountedBase::AddRef() const { -// TODO(maruel): Add back once it doesn't assert 500 times/sec. -// Current thread books the critical section "AddRelease" without release it. -// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); -#ifndef NDEBUG - SB_DCHECK(!in_dtor_); -#endif - ++ref_count_; -} - -bool RefCountedBase::Release() const { -// TODO(maruel): Add back once it doesn't assert 500 times/sec. -// Current thread books the critical section "AddRelease" without release it. -// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); -#ifndef NDEBUG - SB_DCHECK(!in_dtor_); -#endif - if (--ref_count_ == 0) { -#ifndef NDEBUG - in_dtor_ = true; -#endif - return true; - } - return false; -} - -bool RefCountedThreadSafeBase::HasOneRef() const { - return (SbAtomicAcquire_Load( - &const_cast(this)->ref_count_) == 1); -} - -RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) { -#ifndef NDEBUG - in_dtor_ = false; -#endif -} - -RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { -#ifndef NDEBUG - SB_DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without " - "calling Release()"; -#endif -} - -void RefCountedThreadSafeBase::AddRef() const { -#ifndef NDEBUG - SB_DCHECK(!in_dtor_); -#endif - SbAtomicNoBarrier_Increment(&ref_count_, 1); -} - -bool RefCountedThreadSafeBase::Release() const { -#ifndef NDEBUG - SB_DCHECK(!in_dtor_); - SB_DCHECK(!(SbAtomicAcquire_Load(&ref_count_) == 0)); -#endif - if (SbAtomicBarrier_Increment(&ref_count_, -1) == 0) { -#ifndef NDEBUG - in_dtor_ = true; -#endif - return true; - } - return false; -} - -} // namespace subtle - -} // namespace nb diff --git a/glimp/ref_counted.h b/glimp/ref_counted.h deleted file mode 100644 index 52ff7678b818..000000000000 --- a/glimp/ref_counted.h +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GLIMP_REF_COUNTED_H_ -#define GLIMP_REF_COUNTED_H_ - -#include - -#include "glimp/thread_collision_warner.h" -#include "starboard/atomic.h" -#include "starboard/common/log.h" - -namespace nb { - -namespace subtle { - -class RefCountedBase { - public: - bool HasOneRef() const { return ref_count_ == 1; } - - protected: - RefCountedBase(); - ~RefCountedBase(); - - void AddRef() const; - - // Returns true if the object should self-delete. - bool Release() const; - - private: - mutable int ref_count_; -#ifndef NDEBUG - mutable bool in_dtor_; -#endif - - DFAKE_MUTEX(add_release_); -}; - -class RefCountedThreadSafeBase { - public: - bool HasOneRef() const; - - protected: - RefCountedThreadSafeBase(); - ~RefCountedThreadSafeBase(); - - void AddRef() const; - - // Returns true if the object should self-delete. - bool Release() const; - - private: - mutable SbAtomic32 ref_count_; -#ifndef NDEBUG - mutable bool in_dtor_; -#endif -}; - -} // namespace subtle - -// -// A base class for reference counted classes. Otherwise, known as a cheap -// knock-off of WebKit's RefCounted class. To use this guy just extend your -// class from it like so: -// -// class MyFoo : public nb::RefCounted { -// ... -// private: -// friend class nb::RefCounted; -// ~MyFoo(); -// }; -// -// You should always make your destructor private, to avoid any code deleting -// the object accidentally while there are references to it. -template -class RefCounted : public subtle::RefCountedBase { - public: - RefCounted() {} - - void AddRef() const { subtle::RefCountedBase::AddRef(); } - - void Release() const { - if (subtle::RefCountedBase::Release()) { - delete static_cast(this); - } - } - - protected: - ~RefCounted() {} -}; - -// Forward declaration. -template -class RefCountedThreadSafe; - -// Default traits for RefCountedThreadSafe. Deletes the object when its ref -// count reaches 0. Overload to delete it on a different thread etc. -template -struct DefaultRefCountedThreadSafeTraits { - static void Destruct(const T* x) { - // Delete through RefCountedThreadSafe to make child classes only need to be - // friend with RefCountedThreadSafe instead of this struct, which is an - // implementation detail. - RefCountedThreadSafe::DeleteInternal( - x); - } -}; - -// -// A thread-safe variant of RefCounted -// -// class MyFoo : public nb::RefCountedThreadSafe { -// ... -// }; -// -// If you're using the default trait, then you should add compile time -// asserts that no one else is deleting your object. i.e. -// private: -// friend class nb::RefCountedThreadSafe; -// ~MyFoo(); -template > -class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase { - public: - RefCountedThreadSafe() {} - - void AddRef() const { subtle::RefCountedThreadSafeBase::AddRef(); } - - void Release() const { - if (subtle::RefCountedThreadSafeBase::Release()) { - Traits::Destruct(static_cast(this)); - } - } - - protected: - ~RefCountedThreadSafe() {} - - private: - friend struct DefaultRefCountedThreadSafeTraits; - static void DeleteInternal(const T* x) { delete x; } -}; - -// -// A thread-safe wrapper for some piece of data so we can place other -// things in scoped_refptrs<>. -// -template -class RefCountedData : public nb::RefCountedThreadSafe > { - public: - RefCountedData() : data() {} - RefCountedData(const T& in_value) // NOLINT(runtime/explicit) - : data(in_value) {} - - T data; - - private: - friend class nb::RefCountedThreadSafe >; - ~RefCountedData() {} -}; - -// -// A smart pointer class for reference counted objects. Use this class instead -// of calling AddRef and Release manually on a reference counted object to -// avoid common memory leaks caused by forgetting to Release an object -// reference. Sample usage: -// -// class MyFoo : public RefCounted { -// ... -// }; -// -// void some_function() { -// scoped_refptr foo = new MyFoo(); -// foo->Method(param); -// // |foo| is released when this function returns -// } -// -// void some_other_function() { -// scoped_refptr foo = new MyFoo(); -// ... -// foo = NULL; // explicitly releases |foo| -// ... -// if (foo) -// foo->Method(param); -// } -// -// The above examples show how scoped_refptr acts like a pointer to T. -// Given two scoped_refptr classes, it is also possible to exchange -// references between the two objects, like so: -// -// { -// scoped_refptr a = new MyFoo(); -// scoped_refptr b; -// -// b.swap(a); -// // now, |b| references the MyFoo object, and |a| references NULL. -// } -// -// To make both |a| and |b| in the above example reference the same MyFoo -// object, simply use the assignment operator: -// -// { -// scoped_refptr a = new MyFoo(); -// scoped_refptr b; -// -// b = a; -// // now, |a| and |b| each own a reference to the same MyFoo object. -// } -// -template -class scoped_refptr { - public: - typedef T element_type; - - scoped_refptr() : ptr_(NULL) {} - - scoped_refptr(T* p) : ptr_(p) { // NOLINT(runtime/explicit) - if (ptr_) - ptr_->AddRef(); - } - - scoped_refptr(const scoped_refptr& r) : ptr_(r.ptr_) { - if (ptr_) - ptr_->AddRef(); - } - - template - scoped_refptr(const scoped_refptr& r) : ptr_(r.get()) { - if (ptr_) - ptr_->AddRef(); - } - - ~scoped_refptr() { - if (ptr_) - ptr_->Release(); - } - - T* get() const { return ptr_; } - operator T*() const { return ptr_; } - T* operator->() const { - SB_DCHECK(ptr_ != NULL); - return ptr_; - } - - scoped_refptr& operator=(T* p) { - // AddRef first so that self assignment should work - if (p) - p->AddRef(); - T* old_ptr = ptr_; - ptr_ = p; - if (old_ptr) - old_ptr->Release(); - return *this; - } - - scoped_refptr& operator=(const scoped_refptr& r) { - return *this = r.ptr_; - } - - template - scoped_refptr& operator=(const scoped_refptr& r) { - return *this = r.get(); - } - - void swap(T** pp) { - T* p = ptr_; - ptr_ = *pp; - *pp = p; - } - - void swap(scoped_refptr& r) { swap(&r.ptr_); } - - protected: - T* ptr_; -}; - -// Handy utility for creating a scoped_refptr out of a T* explicitly without -// having to retype all the template arguments -template -scoped_refptr make_scoped_refptr(T* t) { - return scoped_refptr(t); -} - -} // namespace nb - -#endif // GLIMP_REF_COUNTED_H_ diff --git a/glimp/shaders/generate_glsl_shader_map.py b/glimp/shaders/generate_glsl_shader_map.py deleted file mode 100644 index a601e1dab088..000000000000 --- a/glimp/shaders/generate_glsl_shader_map.py +++ /dev/null @@ -1,327 +0,0 @@ -#!/usr/bin/python -# Copyright 2016 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Associates GLSL files with platform-specific shaders based on filename. - -This script scans all input files and detects whether they are GLSL files or -not, based on file extension (e.g. "*.glsl" files are classified as GLSL -files, everything else is not a GLSL file). After this, GLSL files that share -the same base filename with a non-GLSL file is then associated with it. - -At this point we have a mapping from GLSL files to platform-specific shader -file. From here, we hash the GLSL file contents to obtain a mapping from GLSL -hash to platform-specific shader file. Once in this form, the data is ready to -be saved. - -The GLSL hash to platform-specific shader data is saved as a C++ header file, -at which point it can be included by C++ code. The C++ code should call -GenerateGLSLShaderMap() to obtain a std::map object -representing the desired mapping. ShaderData objects provide a pointer to -the data as well as its size. -""" - -import os -import re -import sys - - -def GetBasename(filename): - """Returns the filename without the directory and without its extension. - - Args: - filename: A filename from which a basename is to be extracted. - - Returns: - A string derived from the filename except the directory and extension - are removed. - """ - return os.path.splitext(os.path.basename(filename))[0] - - -def GetHeaderDataDefinitionStringForFile(input_file): - """Returns a string containing C++ that represents all file data in file.""" - with open(input_file, 'rb') as f: - file_contents = f.read() - - def Chunks(contents, chunk_size): - """ Yield successive |chunk_size|-sized chunks from |contents|.""" - for i in range(0, len(contents), chunk_size): - yield contents[i:i + chunk_size] - - # Break up the data into chunk sizes such that the produced output lines - # representing the data in the .h file are less than 80 characters long. - length_of_output_byte_string = 6 - max_characters_per_line = 80 - chunk_size = int(max_characters_per_line / length_of_output_byte_string) - - # Convert each byte to ASCII hexadecimal form and output that to the C++ - # header file, line-by-line. - data_definition_string = '{\n' - for output_line_data in Chunks(file_contents, chunk_size): - data_definition_string += ( - ' '.join([f'0x{y:02x},' for y in output_line_data]) + '\n') - data_definition_string += '};\n\n' - return data_definition_string - - -def GetHeaderDataDefinitionString(files): - """Returns a string containing C++ that represents all file data in files.""" - - data_definition_string = '' - for path in files: - input_file_variable_name = GetBasename(path) - data_definition_string += f'const uint8_t {input_file_variable_name}[] =\n' - data_definition_string += GetHeaderDataDefinitionStringForFile(path) - - return data_definition_string - - -def GetGenerateMapFunctionString(hash_to_shader_map): - """Generate C++ code to populate a hash map from GLSL hash to shader data. - - Args: - hash_to_shader_map: - A dictionary where the keys are hashes and the values are - platform-specific shader filenames. - Returns: - A string of C++ code that defines a function to setup a hash map where the - keys are the GLSL hashes and the values are the platform-specific shader - data. - """ - - generate_map_function_string = ( - 'inline void GenerateGLSLShaderMap(GLSLShaderHashMap* out_map) {\n') - - for k, v in hash_to_shader_map.items(): - input_file_variable_name = GetBasename(v) - generate_map_function_string += ( - f' (*out_map)[{k}U] = ShaderData({input_file_variable_name}, ' - f'sizeof({input_file_variable_name}));\n') - - generate_map_function_string += '}' - return generate_map_function_string - - -def GetShaderNameFunctionString(hash_to_shader_map): - """Generate C++ code to retrieve the shader name from a GLSL hash. - - Args: - hash_to_shader_map: - A dictionary where the keys are hashes and the values are - platform-specific shader filenames. - Returns: - A string of C++ code that defines a function that returns a string with the - corresponding shader name for the GLSL hash value passed as a parameter. - """ - - get_shader_name_function_string = ( - 'inline const char *GetShaderName(uint32_t hash_value) {\n' - ' switch(hash_value) {\n') - - for k, v in hash_to_shader_map.items(): - input_file_variable_name = GetBasename(v) - get_shader_name_function_string += (f' case {k}U: return ' - f'\"{input_file_variable_name}\";\n') - - get_shader_name_function_string += ' }\n return NULL;\n}' - return get_shader_name_function_string - - -HEADER_FILE_TEMPLATE = """ -// Copyright 2016 Google Inc. All Rights Reserved. -// This file is generated (by glimp/shaders/generate_glsl_shader_map.py). -// Do not edit! - -#ifndef {include_guard} -#define {include_guard} - -#include "glimp/shaders/glsl_shader_map_helpers.h" - -namespace glimp {{ -namespace shaders {{ - -{data_definitions} -{generate_map_function} - -#if !defined(NDEBUG) -{shader_name_function} -#endif - -}} // namespace shaders -}} // namespace glimp - -#endif // {include_guard} -""" - - -def GenerateHeaderFileOutput(output_file_name, hash_to_shader_map): - """Generate the actual C++ header file code. - - Args: - output_file_name: The filename for the output C++ header file. - hash_to_shader_map: - A Python dictionary whose keys are hashes and whose values are filenames - for platform-specific shader files. - """ - - include_guard = 'GLIMP_SHADERS_GENERATED_GLSL_SHADER_MAP_H_' - with open(output_file_name, 'w', encoding='utf-8') as output_file: - output_file.write( - HEADER_FILE_TEMPLATE.format( - include_guard=include_guard, - data_definitions=GetHeaderDataDefinitionString( - hash_to_shader_map.values()), - generate_map_function=GetGenerateMapFunctionString( - hash_to_shader_map), - shader_name_function=GetShaderNameFunctionString( - hash_to_shader_map))) - - -def AssociateGLSLFilesWithPlatformFiles(all_shaders): - """Returns a dictionary mapping GLSL to platform shaders. - - all_shaders is an unorganized mixed list of both keys and values. - This function reads it, identifies which items are GLSL files and which - are platform shader files, and then associates GLSL files to platform shader - files that share the same basename. - - Args: - all_shaders: A list containing a mixture of GLSL and platform - shader filenames. - Returns: - A dictionary mapping GLSL shader filenames to platform-specific shader - filenames. - """ - - def IsGLSL(filename): - return os.path.splitext(filename)[1].upper() == '.GLSL' - - # First iterate through our list of files and determine which ones are keys. - basename_to_glsl_file = {} - for item in all_shaders: - if IsGLSL(item): - basename = GetBasename(item) - if basename in basename_to_glsl_file: - raise RuntimeError('Multiple GLSL files match the same basename (' + - basename + ')') - basename_to_glsl_file[basename] = item - - # Now iterate through again linking keys to values to create the map that we - # will return. - mapped_files = {} - for item in all_shaders: - if not IsGLSL(item): - basename = GetBasename(item) - if not basename in basename_to_glsl_file: - raise RuntimeError('Platform-specific file ' + item + - ' has no GLSL match.') - glsl_file = basename_to_glsl_file[basename] - if glsl_file in mapped_files: - raise RuntimeError( - 'Multiple platform-specific files match the same GLSL ' + - 'file with basename ' + basename) - mapped_files[glsl_file] = item - - return mapped_files - - -def HashGLSLShaderFile(glsl_filename): - """Opens the given GLSL file and returns a hash based on its contents. - - The contents of the specified file are read, and a hash is computed based on - them. This hash is computed in the same way that glimp's C++ code in - hash_glsl_source.cc computes hashes so that hashes produced by this script - can be later matched at runtime to a GLSL source. - - Note that all space, newline and tab characters are ignored when computing - the hash. - - The hashing source is taken from the "one_at_a_time" hash function, by Bob - Jenkins, in the public domain at http://burtleburtle.net/bob/hash/doobs.html. - """ - with open(glsl_filename, 'r', encoding='utf-8') as glsl_file: - glsl_contents = glsl_file.read() - - def AddUint32(a, b): - return (a + b) & 0xffffffff - - def XorUint32(a, b): - return (a ^ b) & 0xffffffff - - hash_value = 0 - - # Introduce a generator function for returning only the hashable characters. - def GetHashableCharacters(hash_string): - str_without_comments = re.sub(r'//.*\n', '', hash_string) - str_without_whitespace = re.sub(r'[ \n\t]', '', str_without_comments) - str_without_empty_braces = str_without_whitespace.replace('{}', '') - - for c in str_without_empty_braces: - yield c - - for c in GetHashableCharacters(glsl_contents): - hash_value = AddUint32(hash_value, ord(c)) - hash_value = AddUint32(hash_value, hash_value << 10) - hash_value = XorUint32(hash_value, hash_value >> 6) - hash_value = AddUint32(hash_value, hash_value << 3) - hash_value = XorUint32(hash_value, hash_value >> 11) - hash_value = AddUint32(hash_value, hash_value << 15) - return hash_value - - -def CreateHashToShaderMap(glsl_to_shader_map): - """Calculates hashes for each GLSL filename and replaces the keys with hashes. - """ - hash_to_glsl_map = {} # Used for reporting hash map collisions. - hash_shader_map = {} - for k, v in glsl_to_shader_map.items(): - hashed_glsl = HashGLSLShaderFile(k) - if hashed_glsl in hash_shader_map: - raise RuntimeError('Hash collision between GLSL files ' + k + ' and ' + - hash_to_glsl_map[hashed_glsl] + '.') - hash_to_glsl_map[hashed_glsl] = k - hash_shader_map[hashed_glsl] = v - return hash_shader_map - - -def GetAllShaderFiles(input_files_filename, input_files_dir): - """Returns the list of all GLSL/platform shader files. - - Loads each line of |input_files_filename| into a list and then prepends entry - with |input_files_dir|. - """ - files = [] - with open(input_files_filename, encoding='utf-8') as input_files_file: - files = [x.strip() for x in input_files_file.readlines()] - - for filename in files: - # We filter out files that already have a full path (the case in GN). - if '/' in filename: - yield filename - else: - yield os.path.join(input_files_dir, filename) - - -def main(output_path, input_files_filename, input_files_dir): - all_shaders = list(GetAllShaderFiles(input_files_filename, input_files_dir)) - - glsl_to_shader_map = AssociateGLSLFilesWithPlatformFiles(all_shaders) - - hash_to_shader_map = CreateHashToShaderMap(glsl_to_shader_map) - - GenerateHeaderFileOutput(output_path, hash_to_shader_map) - - -if __name__ == '__main__': - main(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/glimp/shaders/glsl_shader_map_helpers.h b/glimp/shaders/glsl_shader_map_helpers.h deleted file mode 100644 index 0776d4ae57ca..000000000000 --- a/glimp/shaders/glsl_shader_map_helpers.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_SHADERS_GLSL_SHADER_MAP_HELPERS_H_ -#define GLIMP_SHADERS_GLSL_SHADER_MAP_HELPERS_H_ - -#include - -#include "starboard/types.h" - -namespace glimp { -namespace shaders { - -struct ShaderData { - ShaderData() : data(NULL), size(0) {} - ShaderData(const uint8_t* data, size_t size) : data(data), size(size) {} - - const uint8_t* data; - size_t size; -}; - -typedef std::map GLSLShaderHashMap; - -} // namespace shaders -} // namespace glimp - -#endif // GLIMP_SHADERS_GLSL_SHADER_MAP_HELPERS_H_ diff --git a/glimp/shaders/hash_glsl_source.cc b/glimp/shaders/hash_glsl_source.cc deleted file mode 100644 index df1997d1f0b6..000000000000 --- a/glimp/shaders/hash_glsl_source.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/shaders/hash_glsl_source.h" - -namespace glimp { -namespace shaders { - -namespace { -// Takes the current hash and combines it with a new character to produce a -// new hash. -uint32_t UpdateHash(uint32_t hash, char update_char) { - hash += update_char; - hash += (hash << 10); - hash ^= (hash >> 6); - return hash; -} - -// Applies some additional calculations to the hash after all characters -// have been accumulated. -uint32_t FinalizeHash(uint32_t hash) { - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - return hash; -} - -const char* ScanUntilNonWhitespace(const char* source) { - uint32_t i = 0; - for (; source[i] != '\0'; ++i) { - if (source[i] == ' ' || source[i] == '\t' || source[i] == '\n') { - continue; - } - - if (source[i] == '/' && source[i + 1] == '/') { - // If we see a comment, leave it out of the hash. - while (source[i] != '\n' && source[i] != '\0') { - ++i; - } - if (source[i] == '\0') { - break; - } else { - continue; - } - } - break; - } - - return &source[i]; -} - -const char* ScanUntilHashableCharacter(const char* source) { - while (true) { - const char* next_char = ScanUntilNonWhitespace(source); - - // If we find empty scopes (e.g: - // - // { - // // Stage 0: Texture - // } - // - // Skip past them without hashing those characters. - if (*next_char == '{') { - const char* next_next_char = ScanUntilNonWhitespace(next_char + 1); - if (*next_next_char == '}') { - source = next_next_char + 1; - continue; - } - } - return next_char; - } -} -} // namespace - -uint32_t HashGLSLSource(const char* source) { - uint32_t hash = 0; - const char* cur_char = source; - while (true) { - cur_char = ScanUntilHashableCharacter(cur_char); - if (*cur_char == '\0') { - break; - } - - hash = UpdateHash(hash, *cur_char); - ++cur_char; - } - return FinalizeHash(hash); -} - -} // namespace shaders -} // namespace glimp diff --git a/glimp/shaders/hash_glsl_source.h b/glimp/shaders/hash_glsl_source.h deleted file mode 100644 index 748077ec8d18..000000000000 --- a/glimp/shaders/hash_glsl_source.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_SHADERS_HASH_GLSL_SOURCE_H_ -#define GLIMP_SHADERS_HASH_GLSL_SOURCE_H_ - -#include - -namespace glimp { -namespace shaders { - -// This function takes a GLSL source and computes a hash value to represent it. -// This hash function is the exact same the one implemented in Python in -// generate_glsl_shader_map.py (the function HashGLSLShaderFile()) so that -// hashes by that script at build time can be linked up at runtime with this -// function. -// -// Note, all space, newline and tab characters are ignored when computing the -// hash. -// -// The hashing source is taken from the "one_at_a_time" hash function, by Bob -// Jenkins, in the public domain at http://burtleburtle.net/bob/hash/doobs.html. -uint32_t HashGLSLSource(const char* source); - -} // namespace shaders -} // namespace glimp - -#endif // GLIMP_SHADERS_HASH_GLSL_SOURCE_H_ diff --git a/glimp/stub/egl/display_impl.cc b/glimp/stub/egl/display_impl.cc deleted file mode 100644 index 9e8985a304d9..000000000000 --- a/glimp/stub/egl/display_impl.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/egl/display_impl.h" - -#include -#include "glimp/stub/egl/pbuffer_surface_impl.h" -#include "glimp/stub/egl/window_surface_impl.h" -#include "glimp/stub/gles/context_impl.h" -#include "starboard/common/log.h" -#include "starboard/common/once.h" -#include "starboard/types.h" - -namespace glimp { -namespace egl { - -DisplayImplStub::DisplayImplStub() { - InitializeSupportedConfigs(); -} - -DisplayImplStub::~DisplayImplStub() { - for (ConfigSet::iterator iter = supported_configs_.begin(); - iter != supported_configs_.end(); ++iter) { - delete *iter; - } -} - -bool DisplayImpl::IsValidNativeDisplayType( - EGLNativeDisplayType native_display) { - return native_display == EGL_DEFAULT_DISPLAY; -} - -std::unique_ptr DisplayImpl::Create( - EGLNativeDisplayType native_display) { - SB_CHECK(IsValidNativeDisplayType(native_display)); - return std::unique_ptr(new DisplayImplStub()); -} - -DisplayImpl::VersionInfo DisplayImplStub::GetVersionInfo() { - DisplayImpl::VersionInfo version_info; - version_info.major = 1; - version_info.minor = 5; - return version_info; -} - -void DisplayImplStub::InitializeSupportedConfigs() { - Config* config = new Config(); - (*config)[EGL_RED_SIZE] = 8; - (*config)[EGL_GREEN_SIZE] = 8; - (*config)[EGL_BLUE_SIZE] = 8; - (*config)[EGL_ALPHA_SIZE] = 8; - (*config)[EGL_BUFFER_SIZE] = 32; - (*config)[EGL_LUMINANCE_SIZE] = 0; - (*config)[EGL_STENCIL_SIZE] = 0; - (*config)[EGL_COLOR_BUFFER_TYPE] = EGL_RGB_BUFFER; - (*config)[EGL_CONFORMANT] = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT; - (*config)[EGL_RENDERABLE_TYPE] = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT; - (*config)[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; - (*config)[EGL_BIND_TO_TEXTURE_RGBA] = EGL_TRUE; - - supported_configs_.insert(config); -} - -std::unique_ptr DisplayImplStub::CreateContext( - const Config* config, - int gles_version) { - if (gles_version == 2 || gles_version == 3) { - return std::unique_ptr(new gles::ContextImplStub()); - } else { - return std::unique_ptr(); - } -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/stub/egl/display_impl.h b/glimp/stub/egl/display_impl.h deleted file mode 100644 index 497e97f7b5a7..000000000000 --- a/glimp/stub/egl/display_impl.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_EGL_DISPLAY_IMPL_H_ -#define GLIMP_STUB_EGL_DISPLAY_IMPL_H_ - -#include -#include - -#include -#include "glimp/egl/config.h" -#include "glimp/egl/display_impl.h" - -namespace glimp { -namespace egl { - -class DisplayImplStub : public DisplayImpl { - public: - DisplayImplStub(); - ~DisplayImplStub(); - - DisplayImpl::VersionInfo GetVersionInfo() override; - - const ConfigSet& GetSupportedConfigs() const override { - return supported_configs_; - } - - std::unique_ptr CreateWindowSurface( - const Config* config, - EGLNativeWindowType win, - const AttribMap& attributes) override; - - std::unique_ptr CreatePbufferSurface( - const Config* config, - const AttribMap& attributes) override; - - std::unique_ptr CreateContext(const Config* config, - int gles_version) override; - - bool SetSwapInterval(int interval) override { return true; } - - private: - void InitializeSupportedConfigs(); - - ConfigSet supported_configs_; -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_STUB_EGL_DISPLAY_IMPL_H_ diff --git a/glimp/stub/egl/get_proc_address_impl.cc b/glimp/stub/egl/get_proc_address_impl.cc deleted file mode 100644 index 7a76869940b3..000000000000 --- a/glimp/stub/egl/get_proc_address_impl.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/egl/get_proc_address_impl.h" - -#include "glimp/egl/display_registry.h" -#include "glimp/egl/scoped_egl_lock.h" -#include "glimp/polymorphic_downcast.h" -#include "glimp/stub/egl/display_impl.h" -#include "starboard/common/string.h" - -namespace glimp { -namespace egl { - -MustCastToProperFunctionPointerType GetProcAddressImpl(const char* procname) { - return NULL; -} - -} // namespace egl -} // namespace glimp diff --git a/glimp/stub/egl/pbuffer_surface_impl.cc b/glimp/stub/egl/pbuffer_surface_impl.cc deleted file mode 100644 index 348337282681..000000000000 --- a/glimp/stub/egl/pbuffer_surface_impl.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/egl/pbuffer_surface_impl.h" - -#include - -#include "starboard/common/pointer_arithmetic.h" - -namespace glimp { -namespace egl { - -PbufferSurfaceImplStub::PbufferSurfaceImplStub(int width, int height) - : width_(width), height_(height) {} - -PbufferSurfaceImplStub::~PbufferSurfaceImplStub() {} - -} // namespace egl -} // namespace glimp diff --git a/glimp/stub/egl/pbuffer_surface_impl.h b/glimp/stub/egl/pbuffer_surface_impl.h deleted file mode 100644 index 0932668def01..000000000000 --- a/glimp/stub/egl/pbuffer_surface_impl.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_EGL_PBUFFER_SURFACE_IMPL_H_ -#define GLIMP_STUB_EGL_PBUFFER_SURFACE_IMPL_H_ - -#include - -#include "glimp/ref_counted.h" -#include "glimp/stub/egl/surface_impl.h" - -namespace glimp { -namespace egl { - -class PbufferSurfaceImplStub : public SurfaceImplStub { - public: - PbufferSurfaceImplStub(int width, int height); - virtual ~PbufferSurfaceImplStub(); - - int GetWidth() const override { return width_; } - int GetHeight() const override { return height_; } - - private: - int width_; - int height_; -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_STUB_EGL_PBUFFER_SURFACE_IMPL_H_ diff --git a/glimp/stub/egl/surface_impl.cc b/glimp/stub/egl/surface_impl.cc deleted file mode 100644 index d05744c1e89e..000000000000 --- a/glimp/stub/egl/surface_impl.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/egl/surface_impl.h" - -namespace glimp { -namespace egl {} // namespace egl -} // namespace glimp diff --git a/glimp/stub/egl/surface_impl.h b/glimp/stub/egl/surface_impl.h deleted file mode 100644 index 7b4210462fa3..000000000000 --- a/glimp/stub/egl/surface_impl.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_EGL_SURFACE_IMPL_H_ -#define GLIMP_STUB_EGL_SURFACE_IMPL_H_ - -#include "glimp/egl/surface_impl.h" - -namespace glimp { -namespace egl { - -class SurfaceImplStub : public SurfaceImpl { - public: - bool IsWindowSurface() const final { return false; } -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_STUB_EGL_SURFACE_IMPL_H_ diff --git a/glimp/stub/egl/window_surface_impl.cc b/glimp/stub/egl/window_surface_impl.cc deleted file mode 100644 index 3d7d8e3239c9..000000000000 --- a/glimp/stub/egl/window_surface_impl.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/egl/window_surface_impl.h" - -#include "starboard/common/log.h" - -namespace glimp { -namespace egl { - -WindowSurfaceImplStub::WindowSurfaceImplStub() { - width_ = 0; - height_ = 0; -} - -WindowSurfaceImplStub::~WindowSurfaceImplStub() {} - -} // namespace egl -} // namespace glimp diff --git a/glimp/stub/egl/window_surface_impl.h b/glimp/stub/egl/window_surface_impl.h deleted file mode 100644 index 8b910a623a50..000000000000 --- a/glimp/stub/egl/window_surface_impl.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_EGL_WINDOW_SURFACE_IMPL_H_ -#define GLIMP_STUB_EGL_WINDOW_SURFACE_IMPL_H_ - -#include "glimp/stub/egl/surface_impl.h" -#include "starboard/configuration.h" - -namespace glimp { -namespace egl { - -class WindowSurfaceImplStub : public SurfaceImplStub { - public: - WindowSurfaceImplStub(); - virtual ~WindowSurfaceImplStub(); - - int GetWidth() const override { return width_; } - int GetHeight() const override { return height_; } - - private: - int width_; - int height_; -}; - -} // namespace egl -} // namespace glimp - -#endif // GLIMP_STUB_EGL_WINDOW_SURFACE_IMPL_H_ diff --git a/glimp/stub/gles/buffer_impl.cc b/glimp/stub/gles/buffer_impl.cc deleted file mode 100644 index 6f3f3b0e6124..000000000000 --- a/glimp/stub/gles/buffer_impl.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/gles/buffer_impl.h" - -#include "starboard/memory.h" - -namespace glimp { -namespace gles { - -BufferImplStub::BufferImplStub() {} - -bool BufferImplStub::Allocate(Usage usage, khronos_usize_t size) { - return false; -} - -bool BufferImplStub::SetData(khronos_intptr_t offset, - khronos_usize_t size, - const void* data) { - SB_DCHECK(data); - return false; -} - -void* BufferImplStub::Map() { - return NULL; -} - -bool BufferImplStub::Unmap() { - return true; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/stub/gles/buffer_impl.h b/glimp/stub/gles/buffer_impl.h deleted file mode 100644 index 17e0c6396c77..000000000000 --- a/glimp/stub/gles/buffer_impl.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_GLES_BUFFER_IMPL_H_ -#define GLIMP_STUB_GLES_BUFFER_IMPL_H_ - -#include "glimp/gles/buffer_impl.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class BufferImplStub : public BufferImpl { - public: - BufferImplStub(); - ~BufferImplStub() override {} - - bool Allocate(Usage usage, size_t size) override; - bool SetData(intptr_t offset, size_t size, const void* data) override; - - void* Map() override; - bool Unmap() override; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_STUB_GLES_BUFFER_IMPL_H_ diff --git a/glimp/stub/gles/context_impl.cc b/glimp/stub/gles/context_impl.cc deleted file mode 100644 index dc882cafea8c..000000000000 --- a/glimp/stub/gles/context_impl.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/gles/context_impl.h" - -#include -#include - -#include "glimp/polymorphic_downcast.h" -#include "glimp/rect.h" -#include "glimp/stub/egl/surface_impl.h" -#include "glimp/stub/gles/buffer_impl.h" -#include "glimp/stub/gles/program_impl.h" -#include "glimp/stub/gles/shader_impl.h" -#include "glimp/stub/gles/texture_impl.h" -#include "glimp/tracing/tracing.h" - -namespace glimp { -namespace gles { - -ContextImplStub::ContextImplStub() {} - -ContextImpl::ExtensionList ContextImplStub::GetExtensions() const { - ContextImpl::ExtensionList extensions; - - // We are able to accept RGBA8 textures as framebuffer attachments (i.e. - // as render targets). - extensions.push_back("GL_OES_rgb8_rgba8"); - - // This is required in order to render distance field fonts. - extensions.push_back("GL_OES_standard_derivatives"); - - return extensions; -} - -int ContextImplStub::GetMaxVertexAttribs() const { - return 16; -} - -int ContextImplStub::GetMaxFragmentTextureUnits() const { - return 16; -} - -int ContextImplStub::GetMaxCombinedTextureImageUnits() const { - return 0; -} - -int ContextImplStub::GetMaxTextureSize() const { - return 4096; -} - -int ContextImplStub::GetMaxRenderbufferSize() const { - return 4096; -} - -int ContextImplStub::GetMaxFragmentUniformVectors() const { - // GL ES requires that it is at least 16, so we will return that. - return ProgramImplStub::kMaxUniformsPerShader; -} - -std::unique_ptr ContextImplStub::CreateProgram() { - return std::unique_ptr(new ProgramImplStub()); -} - -std::unique_ptr ContextImplStub::CreateVertexShader() { - return std::unique_ptr( - new ShaderImplStub(ShaderImplStub::kVertex)); -} - -std::unique_ptr ContextImplStub::CreateFragmentShader() { - return std::unique_ptr( - new ShaderImplStub(ShaderImplStub::kFragment)); -} - -std::unique_ptr ContextImplStub::CreateBuffer() { - return std::unique_ptr(new BufferImplStub()); -} - -std::unique_ptr ContextImplStub::CreateTexture() { - return std::unique_ptr(new TextureImplStub()); -} - -void ContextImplStub::Flush() { - // Do nothing, we will flush when we swap buffers. -} - -void ContextImplStub::Finish() {} - -void ContextImplStub::Clear(bool clear_color, - bool clear_depth, - bool clear_stencil, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) {} - -void ContextImplStub::DrawArrays(DrawMode mode, - int first_vertex, - int num_vertices, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) {} - -void ContextImplStub::DrawElements(DrawMode mode, - int num_vertices, - IndexDataType index_data_type, - intptr_t index_offset_in_bytes, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) {} - -void ContextImplStub::SwapBuffers(egl::Surface* surface) {} - -} // namespace gles -} // namespace glimp diff --git a/glimp/stub/gles/context_impl.h b/glimp/stub/gles/context_impl.h deleted file mode 100644 index 6ed9626580b5..000000000000 --- a/glimp/stub/gles/context_impl.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_GLES_CONTEXT_IMPL_H_ -#define GLIMP_STUB_GLES_CONTEXT_IMPL_H_ - -#include -#include "glimp/egl/surface.h" -#include "glimp/gles/context_impl.h" -#include "glimp/gles/draw_state.h" -#include "glimp/gles/index_data_type.h" -#include "glimp/shaders/glsl_shader_map_helpers.h" - -namespace glimp { -namespace gles { - -class ContextImplStub : public ContextImpl { - public: - ContextImplStub(); - virtual ~ContextImplStub() {} - - ContextImpl::ExtensionList GetExtensions() const override; - int GetMaxVertexAttribs() const override; - int GetMaxFragmentTextureUnits() const override; - int GetMaxCombinedTextureImageUnits() const override; - int GetMaxTextureSize() const override; - int GetMaxRenderbufferSize() const override; - int GetMaxFragmentUniformVectors() const override; - int GetMaxVertexTextureImageUnits() const override { return 0; } - - std::unique_ptr CreateProgram() override; - - std::unique_ptr CreateVertexShader() override; - std::unique_ptr CreateFragmentShader() override; - - std::unique_ptr CreateBuffer() override; - - std::unique_ptr CreateTexture() override; - - void Flush() override; - void Finish() override; - - void Clear(bool clear_color, - bool clear_depth, - bool clear_stencil, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) override; - - void DrawArrays(DrawMode mode, - int first_vertex, - int num_vertices, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) override; - - void DrawElements(DrawMode mode, - int num_vertices, - IndexDataType index_data_type, - intptr_t index_offset_in_bytes, - const DrawState& draw_state, - DrawStateDirtyFlags* dirty_flags) override; - - void SwapBuffers(egl::Surface* surface) override; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_STUB_GLES_CONTEXT_IMPL_H_ diff --git a/glimp/stub/gles/program_impl.cc b/glimp/stub/gles/program_impl.cc deleted file mode 100644 index ae6afe87003e..000000000000 --- a/glimp/stub/gles/program_impl.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/gles/program_impl.h" - -#include "glimp/polymorphic_downcast.h" -#include "glimp/stub/gles/shader_impl.h" -#include "starboard/common/log.h" - -namespace glimp { -namespace gles { - -ProgramImplStub::ProgramImplStub() - : linked_vertex_shader_(NULL), linked_fragment_shader_(NULL) {} - -ProgramImpl::LinkResults ProgramImplStub::Link( - const nb::scoped_refptr& vertex_shader, - const nb::scoped_refptr& fragment_shader) { - linked_vertex_shader_ = - nb::polymorphic_downcast(vertex_shader->impl()); - linked_fragment_shader_ = - nb::polymorphic_downcast(fragment_shader->impl()); - - bound_attributes_.clear(); - - return ProgramImpl::LinkResults(true); -} - -bool ProgramImplStub::BindAttribLocation(unsigned int index, const char* name) { - SB_DCHECK(linked_vertex_shader_); - return false; -} - -int ProgramImplStub::GetUniformLocation(const char* name) { - return -1; -} - -int ProgramImplStub::GetResourceForBoundAttrib(unsigned int index) const { - std::map::const_iterator found = - bound_attributes_.find(index); - if (found == bound_attributes_.end()) { - return -1; - } - - return found->second; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/stub/gles/program_impl.h b/glimp/stub/gles/program_impl.h deleted file mode 100644 index 58257662111d..000000000000 --- a/glimp/stub/gles/program_impl.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_GLES_PROGRAM_IMPL_H_ -#define GLIMP_STUB_GLES_PROGRAM_IMPL_H_ - -#include - -#include "glimp/gles/program_impl.h" -#include "glimp/gles/shader.h" -#include "glimp/gles/uniform_info.h" -#include "glimp/ref_counted.h" -#include "glimp/stub/gles/shader_impl.h" - -namespace glimp { -namespace gles { - -class ProgramImplStub : public ProgramImpl { - public: - static const int kMaxUniformsPerShader = 16; - - ProgramImplStub(); - ~ProgramImplStub() override {} - - ProgramImpl::LinkResults Link( - const nb::scoped_refptr& vertex_shader, - const nb::scoped_refptr& fragment_shader) override; - - bool BindAttribLocation(unsigned int index, const char* name) override; - - int GetUniformLocation(const char* name) override; - - // Returns the location of the shader attribute that was previously bound - // to |index| in a call to BindAttribLocation(). - int GetResourceForBoundAttrib(unsigned int index) const; - - ShaderImplStub* linked_vertex_shader() const { return linked_vertex_shader_; } - - ShaderImplStub* linked_fragment_shader() const { - return linked_fragment_shader_; - } - - private: - ShaderImplStub* linked_vertex_shader_; - ShaderImplStub* linked_fragment_shader_; - - std::map bound_attributes_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_STUB_GLES_PROGRAM_IMPL_H_ diff --git a/glimp/stub/gles/shader_impl.cc b/glimp/stub/gles/shader_impl.cc deleted file mode 100644 index 12d5a5e3c9aa..000000000000 --- a/glimp/stub/gles/shader_impl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/gles/shader_impl.h" - -#include "glimp/shaders/hash_glsl_source.h" - -namespace glimp { -namespace gles { - -ShaderImplStub::ShaderImplStub(Type type) : type_(type) {} - -ShaderImpl::CompileResults ShaderImplStub::Compile(const std::string& source) { - return ShaderImpl::CompileResults(true); -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/stub/gles/shader_impl.h b/glimp/stub/gles/shader_impl.h deleted file mode 100644 index 862aa2eb039b..000000000000 --- a/glimp/stub/gles/shader_impl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_GLES_SHADER_IMPL_H_ -#define GLIMP_STUB_GLES_SHADER_IMPL_H_ - -#include - -#include "glimp/gles/shader_impl.h" -#include "glimp/gles/uniform_info.h" -#include "glimp/ref_counted.h" -#include "glimp/shaders/glsl_shader_map_helpers.h" -#include "starboard/common/log.h" - -namespace glimp { -namespace gles { - -class ShaderImplStub : public ShaderImpl { - public: - enum Type { - kVertex, - kFragment, - }; - - explicit ShaderImplStub(Type type); - ~ShaderImplStub() override {} - - ShaderImpl::CompileResults Compile(const std::string& source) override; - - private: - Type type_; -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_STUB_GLES_SHADER_IMPL_H_ diff --git a/glimp/stub/gles/texture_impl.cc b/glimp/stub/gles/texture_impl.cc deleted file mode 100644 index b7ed24a68ee0..000000000000 --- a/glimp/stub/gles/texture_impl.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "glimp/stub/gles/texture_impl.h" - -#include - -#include "glimp/gles/convert_pixel_data.h" -#include "glimp/polymorphic_downcast.h" -#include "glimp/stub/egl/pbuffer_surface_impl.h" -#include "glimp/stub/gles/buffer_impl.h" -#include "starboard/memory.h" - -namespace glimp { -namespace gles { - -TextureImplStub::TextureImplStub() {} - -void TextureImplStub::Initialize(int level, - PixelFormat pixel_format, - int width, - int height) { - SB_DCHECK(level == 0); -} - -bool TextureImplStub::UpdateData(int level, - const nb::Rect& window, - int pitch_in_bytes, - const void* pixels) { - return false; -} - -void TextureImplStub::UpdateDataFromBuffer( - int level, - const nb::Rect& window, - int pitch_in_bytes, - const nb::scoped_refptr& pixel_unpack_buffer, - uintptr_t buffer_offset) {} - -void TextureImplStub::BindToEGLSurface(egl::Surface* surface) {} - -void TextureImplStub::ReadPixelsAsRGBA8(const nb::Rect& window, - int pitch_in_bytes, - void* pixels) {} - -bool TextureImplStub::CanBeAttachedToFramebuffer() const { - return false; -} - -} // namespace gles -} // namespace glimp diff --git a/glimp/stub/gles/texture_impl.h b/glimp/stub/gles/texture_impl.h deleted file mode 100644 index 30a1fe955dae..000000000000 --- a/glimp/stub/gles/texture_impl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023 The Cobalt Authors. All Rights Reserved. - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_STUB_GLES_TEXTURE_IMPL_H_ -#define GLIMP_STUB_GLES_TEXTURE_IMPL_H_ - -#include - -#include "glimp/gles/buffer.h" -#include "glimp/gles/pixel_format.h" -#include "glimp/gles/texture_impl.h" -#include "glimp/rect.h" -#include "glimp/ref_counted.h" - -namespace glimp { -namespace gles { - -class TextureImplStub : public TextureImpl { - public: - TextureImplStub(); - ~TextureImplStub() override {} - - void Initialize(int level, - PixelFormat pixel_format, - int width, - int height) override; - - bool UpdateData(int level, - const nb::Rect& window, - int pitch_in_bytes, - const void* pixels) override; - - void UpdateDataFromBuffer( - int level, - const nb::Rect& window, - int pitch_in_bytes, - const nb::scoped_refptr& pixel_unpack_buffer, - uintptr_t buffer_offset) override; - - void BindToEGLSurface(egl::Surface* surface) override; - - void ReadPixelsAsRGBA8(const nb::Rect& window, - int pitch_in_bytes, - void* pixels) override; - - bool CanBeAttachedToFramebuffer() const override; - - private: -}; - -} // namespace gles -} // namespace glimp - -#endif // GLIMP_STUB_GLES_TEXTURE_IMPL_H_ diff --git a/glimp/thread_collision_warner.cc b/glimp/thread_collision_warner.cc deleted file mode 100644 index 31e62da5ff17..000000000000 --- a/glimp/thread_collision_warner.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "glimp/thread_collision_warner.h" - -#include "starboard/atomic.h" -#include "starboard/common/log.h" -#include "starboard/thread.h" -#include "starboard/types.h" - -namespace nb { - -void DCheckAsserter::warn() { - SB_NOTREACHED() << "Thread Collision"; -} - -static SbAtomic32 CurrentThread() { - const SbThreadId current_thread_id = SbThreadGetId(); - // We need to get the thread id into an atomic data type. This might be a - // truncating conversion, but any loss-of-information just increases the - // chance of a false negative, not a false positive. - const SbAtomic32 atomic_thread_id = - static_cast(current_thread_id); - return atomic_thread_id; -} - -void ThreadCollisionWarner::EnterSelf() { - // If the active thread is 0 then I'll write the current thread ID - // if two or more threads arrive here only one will succeed to - // write on valid_thread_id_ the current thread ID. - SbAtomic32 current_thread_id = CurrentThread(); - - int previous_value = - SbAtomicNoBarrier_CompareAndSwap(&valid_thread_id_, 0, current_thread_id); - if (previous_value != 0 && previous_value != current_thread_id) { - // gotcha! a thread is trying to use the same class and that is - // not current thread. - asserter_->warn(); - } - - SbAtomicNoBarrier_Increment(&counter_, 1); -} - -void ThreadCollisionWarner::Enter() { - SbAtomic32 current_thread_id = CurrentThread(); - - if (SbAtomicNoBarrier_CompareAndSwap(&valid_thread_id_, 0, - current_thread_id) != 0) { - // gotcha! another thread is trying to use the same class. - asserter_->warn(); - } - - SbAtomicNoBarrier_Increment(&counter_, 1); -} - -void ThreadCollisionWarner::Leave() { - if (SbAtomicBarrier_Increment(&counter_, -1) == 0) { - SbAtomicNoBarrier_Store(&valid_thread_id_, 0); - } -} - -} // namespace nb diff --git a/glimp/thread_collision_warner.h b/glimp/thread_collision_warner.h deleted file mode 100644 index ca30a047a27a..000000000000 --- a/glimp/thread_collision_warner.h +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GLIMP_THREAD_COLLISION_WARNER_H_ -#define GLIMP_THREAD_COLLISION_WARNER_H_ - -#include "starboard/atomic.h" - -// A helper class alongside macros to be used to verify assumptions about thread -// safety of a class. -// -// Example: Queue implementation non thread-safe but still usable if clients -// are synchronized somehow. -// -// In this case the macro DFAKE_SCOPED_LOCK has to be -// used, it checks that if a thread is inside the push/pop then -// no one else is still inside the pop/push -// -// class NonThreadSafeQueue { -// public: -// ... -// void push(int) { DFAKE_SCOPED_LOCK(push_pop_); ... } -// int pop() { DFAKE_SCOPED_LOCK(push_pop_); ... } -// ... -// private: -// DFAKE_MUTEX(push_pop_); -// }; -// -// -// Example: Queue implementation non thread-safe but still usable if clients -// are synchronized somehow, it calls a method to "protect" from -// a "protected" method -// -// In this case the macro DFAKE_SCOPED_RECURSIVE_LOCK -// has to be used, it checks that if a thread is inside the push/pop -// then no one else is still inside the pop/push -// -// class NonThreadSafeQueue { -// public: -// void push(int) { -// DFAKE_SCOPED_LOCK(push_pop_); -// ... -// } -// int pop() { -// DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); -// bar(); -// ... -// } -// void bar() { DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); ... } -// ... -// private: -// DFAKE_MUTEX(push_pop_); -// }; -// -// -// Example: Queue implementation not usable even if clients are synchronized, -// so only one thread in the class life cycle can use the two members -// push/pop. -// -// In this case the macro DFAKE_SCOPED_LOCK_THREAD_LOCKED pins the -// specified -// critical section the first time a thread enters push or pop, from -// that time on only that thread is allowed to execute push or pop. -// -// class NonThreadSafeQueue { -// public: -// ... -// void push(int) { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... } -// int pop() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... } -// ... -// private: -// DFAKE_MUTEX(push_pop_); -// }; -// -// -// Example: Class that has to be constructed/destroyed on same thread, it has -// a "shareable" method (with external synchronization) and a not -// shareable method (even with external synchronization). -// -// In this case 3 Critical sections have to be defined -// -// class ExoticClass { -// public: -// ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... } -// ~ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... } -// -// void Shareable() { DFAKE_SCOPED_LOCK(shareable_section_); ... } -// void NotShareable() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... } -// ... -// private: -// DFAKE_MUTEX(ctor_dtor_); -// DFAKE_MUTEX(shareable_section_); -// }; - -#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) - -// Defines a class member that acts like a mutex. It is used only as a -// verification tool. -#define DFAKE_MUTEX(obj) mutable nb::ThreadCollisionWarner obj -// Asserts the call is never called simultaneously in two threads. Used at -// member function scope. -#define DFAKE_SCOPED_LOCK(obj) \ - nb::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj) -// Asserts the call is never called simultaneously in two threads. Used at -// member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks. -#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \ - nb::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj) -// Asserts the code is always executed in the same thread. -#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \ - nb::ThreadCollisionWarner::Check check_##obj(&obj) - -#else - -#define DFAKE_MUTEX(obj) typedef void InternalFakeMutexType##obj -#define DFAKE_SCOPED_LOCK(obj) ((void)0) -#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) ((void)0) -#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) ((void)0) - -#endif - -namespace nb { - -// The class ThreadCollisionWarner uses an Asserter to notify the collision -// AsserterBase is the interfaces and DCheckAsserter is the default asserter -// used. During the unit tests is used another class that doesn't "DCHECK" -// in case of collision (check thread_collision_warner_unittests.cc) -struct AsserterBase { - virtual ~AsserterBase() {} - virtual void warn() = 0; -}; - -struct DCheckAsserter : public AsserterBase { - virtual ~DCheckAsserter() {} - virtual void warn(); -}; - -class ThreadCollisionWarner { - public: - // The parameter asserter is there only for test purpose - explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter()) - : valid_thread_id_(0), counter_(0), asserter_(asserter) {} - - ~ThreadCollisionWarner() { delete asserter_; } - - // This class is meant to be used through the macro - // DFAKE_SCOPED_LOCK_THREAD_LOCKED - // it doesn't leave the critical section, as opposed to ScopedCheck, - // because the critical section being pinned is allowed to be used only - // from one thread - class Check { - public: - explicit Check(ThreadCollisionWarner* warner) : warner_(warner) { - warner_->EnterSelf(); - } - - ~Check() {} - - private: - ThreadCollisionWarner* warner_; - }; - - // This class is meant to be used through the macro - // DFAKE_SCOPED_LOCK - class ScopedCheck { - public: - explicit ScopedCheck(ThreadCollisionWarner* warner) : warner_(warner) { - warner_->Enter(); - } - - ~ScopedCheck() { warner_->Leave(); } - - private: - ThreadCollisionWarner* warner_; - }; - - // This class is meant to be used through the macro - // DFAKE_SCOPED_RECURSIVE_LOCK - class ScopedRecursiveCheck { - public: - explicit ScopedRecursiveCheck(ThreadCollisionWarner* warner) - : warner_(warner) { - warner_->EnterSelf(); - } - - ~ScopedRecursiveCheck() { warner_->Leave(); } - - private: - ThreadCollisionWarner* warner_; - }; - - private: - // This method stores the current thread identifier and does a DCHECK - // if a another thread has already done it, it is safe if same thread - // calls this multiple time (recursion allowed). - void EnterSelf(); - - // Same as EnterSelf but recursion is not allowed. - void Enter(); - - // Removes the thread_id stored in order to allow other threads to - // call EnterSelf or Enter. - void Leave(); - - // This stores the thread id that is inside the critical section, if the - // value is 0 then no thread is inside. - volatile SbAtomic32 valid_thread_id_; - - // Counter to trace how many time a critical section was "pinned" - // (when allowed) in order to unpin it when counter_ reaches 0. - volatile SbAtomic32 counter_; - - // Here only for class unit tests purpose, during the test I need to not - // DCHECK but notify the collision with something else. - AsserterBase* asserter_; -}; - -} // namespace nb - -#endif // GLIMP_THREAD_COLLISION_WARNER_H_ diff --git a/glimp/tracing/BUILD.gn b/glimp/tracing/BUILD.gn deleted file mode 100644 index d9605c1bef96..000000000000 --- a/glimp/tracing/BUILD.gn +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("tracing") { - sources = [ - "tracing.cc", - "tracing.h", - ] - configs += [ "//glimp:glimp_config" ] -} diff --git a/glimp/tracing/tracing.cc b/glimp/tracing/tracing.cc deleted file mode 100644 index ddf30316bcdc..000000000000 --- a/glimp/tracing/tracing.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "glimp/tracing/tracing.h" - -#if defined(ENABLE_GLIMP_TRACING) - -namespace glimp { - -namespace { -TraceEventImpl* g_trace_event_implementation = NULL; -} // namespace - -ScopedTraceEvent::ScopedTraceEvent(const char* name) : name_(name) { - if (g_trace_event_implementation) { - g_trace_event_implementation->BeginTrace(name_); - } -} - -ScopedTraceEvent::~ScopedTraceEvent() { - if (g_trace_event_implementation) { - g_trace_event_implementation->EndTrace(name_); - } -} - -void SetTraceEventImplementation(TraceEventImpl* impl) { - g_trace_event_implementation = impl; -} - -} // namespace glimp - -#endif // #if defined(ENABLE_GLIMP_TRACING) diff --git a/glimp/tracing/tracing.h b/glimp/tracing/tracing.h deleted file mode 100644 index 8471f40cc044..000000000000 --- a/glimp/tracing/tracing.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GLIMP_TRACING_TRACING_H_ -#define GLIMP_TRACING_TRACING_H_ - -#if !defined(ENABLE_GLIMP_TRACING) - -#define GLIMP_TRACE_EVENT0(event) - -#else // !defined(ENABLE_GLIMP_TRACING) - -#define GLIMP_TRACE_EVENT0(event) \ - glimp::ScopedTraceEvent profileScope##__LINE__(event) - -namespace glimp { - -class ScopedTraceEvent { - public: - explicit ScopedTraceEvent(const char* name); - ~ScopedTraceEvent(); - - private: - const char* name_; -}; - -// Clients should implement TraceEventImpl so that the desired activities occur -// when we start and end a trace. For example, this might get hooked up to -// TRACE_EVENT_BEGIN0() and TRACE_EVENT_END0() if Chromium's base trace_event -// system is available. Then, SetTraceEventImplementation() should be called -// by the client to make install the client's TraceEventImpl. -class TraceEventImpl { - public: - virtual void BeginTrace(const char* name) = 0; - virtual void EndTrace(const char* name) = 0; -}; - -void SetTraceEventImplementation(TraceEventImpl* impl); - -} // namespace glimp - -#endif // !defined(ENABLE_GLIMP_TRACING) - -#endif // GLIMP_TRACING_TRACING_H_ diff --git a/media/base/media_util.cc b/media/base/media_util.cc index 34ee95dfead4..fe4b1982397a 100644 --- a/media/base/media_util.cc +++ b/media/base/media_util.cc @@ -31,12 +31,8 @@ AudioParameters::Format ConvertAudioCodecToBitstreamFormat(AudioCodec codec) { } bool MediaTraceIsEnabled() { -#if defined(STARBOARD) - return true; -#else // defined(STARBOARD) bool enable_decode_traces = false; TRACE_EVENT_CATEGORY_GROUP_ENABLED("media", &enable_decode_traces); return enable_decode_traces; -#endif // defined(STARBOARD) } } // namespace media diff --git a/media/formats/mp4/ac3.cc b/media/formats/mp4/ac3.cc index b08e8dcb5ffd..ba6b4e6fa24c 100644 --- a/media/formats/mp4/ac3.cc +++ b/media/formats/mp4/ac3.cc @@ -30,24 +30,41 @@ bool AC3::Parse(const std::vector& data, MediaLog* media_log) { return false; } + // For AC3SpecificBox, Please refer to ETSI TS 102 366 V1.4.1 + // https://www.etsi.org/deliver/etsi_ts/102300_102399/102366/01.03.01_60/ts_102366v010301p.pdf + // F.4 AC3SpecificBox + // fscod 2 bits + // bsid 5 bits + // bsmod 3 bits + // acmod 3 bits + // lfeon 1 bits + // bit_rate_code 5 bits + // reserved 5 bits + + if (data.size() * 8 < (2 + 5 + 3 + 3 + 1 + 5 + 5)) { + return false; + } + // Parse dac3 box using reader. BitReader reader(&data[0], data.size()); - // Please refer to ETSI TS 102 366 V1.4.1 - // https://www.etsi.org/deliver/etsi_ts/102300_102399/102366/01.03.01_60/ts_102366v010301p.pdf - // F.4 AC3SpecificBox - // fscod 2 bits - // bsid 5 bits - // bsmod 3 bits + // skip fscod, bsid, bsmod RCHECK(reader.SkipBits(2 + 5 + 3)); int acmod; RCHECK(reader.ReadBits(3, &acmod)); + if (acmod >= static_cast(sizeof(kGlobalChannelArray))) { + return false; + } + int lfeon; RCHECK(reader.ReadBits(1, &lfeon)); channel_count_ = kGlobalChannelArray[acmod] + lfeon; RCHECK(channel_count_ >= 1 && channel_count_ <= limits::kMaxChannels); + + // skip bit_rate_code, reserved + RCHECK(reader.SkipBits(5 + 5)); return true; } diff --git a/media/formats/mp4/ac3_unittest.cc b/media/formats/mp4/ac3_unittest.cc new file mode 100644 index 000000000000..6e791dcaaef4 --- /dev/null +++ b/media/formats/mp4/ac3_unittest.cc @@ -0,0 +1,53 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +#include "media/base/mock_media_log.h" +#include "media/formats/mp4/ac3.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using ::testing::AllOf; +using ::testing::HasSubstr; +using ::testing::InSequence; +using ::testing::StrictMock; + +namespace media { + +namespace mp4 { + +class AC3Test : public testing::Test { + public: + AC3Test() = default; + + bool Parse(const std::vector& data) { + return ac3_.Parse(data, &media_log_); + } + + StrictMock media_log_; + AC3 ac3_; +}; + +TEST_F(AC3Test, NoInputTest) { + std::vector data; + EXPECT_FALSE(Parse(data)); +} + +TEST_F(AC3Test, ShortInvalidInputTest) { + std::vector data({0x50, 0x11}); + + EXPECT_FALSE(Parse(data)); +} + +TEST_F(AC3Test, NormalInputTest) { + std::vector data({0x50, 0x11, 0x40}); + + EXPECT_TRUE(Parse(data)); + EXPECT_EQ(ac3_.GetChannelCount(), 2u); +} + +} // namespace mp4 + +} // namespace media diff --git a/media/formats/mp4/box_definitions.cc b/media/formats/mp4/box_definitions.cc index 6e87ed1aae37..ecd74dc828e7 100644 --- a/media/formats/mp4/box_definitions.cc +++ b/media/formats/mp4/box_definitions.cc @@ -1747,11 +1747,13 @@ bool AudioSampleEntry::Parse(BoxReader* reader) { #endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO) #if BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO) - if (format == FOURCC_AC3) { + if (format == FOURCC_AC3 || + (format == FOURCC_ENCA && sinf.format.format == FOURCC_AC3)) { RCHECK_MEDIA_LOGGED(reader->ReadChild(&ac3), reader->media_log(), "Failure parsing AC3SpecificBox (dac3)"); } - if (format == FOURCC_EAC3) { + if (format == FOURCC_EAC3 || + (format == FOURCC_ENCA && sinf.format.format == FOURCC_EAC3)) { RCHECK_MEDIA_LOGGED(reader->ReadChild(&eac3), reader->media_log(), "Failure parsing EC3SpecificBox (dec3)"); } diff --git a/media/formats/mp4/eac3.cc b/media/formats/mp4/eac3.cc index 4bdd58aad219..95dfc41cb0f3 100644 --- a/media/formats/mp4/eac3.cc +++ b/media/formats/mp4/eac3.cc @@ -30,6 +30,31 @@ bool EAC3::Parse(const std::vector& data, MediaLog* media_log) { return false; } + // For EC3SpecificBox, please refer to ETSI TS 102 366 V1.4.1 + // https://www.etsi.org/deliver/etsi_ts/102300_102399/102366/01.03.01_60/ts_102366v010301p.pdf + // F.6 EC3SpecificBox + // data_rate 13 bits + // num_ind_sub 3 bits + // { + // fscod 2 bits + // bsid 5 bits + // reserved 1 bits + // asvc 1 bits + // bsmod 3 bits + // acmod 3 bits + // lfeon 1 bits + // reserved 3 bits + // num_dep_sub 4 bits + // if num_dep_sub > 0 chan_loc 9 bits + // else reserved 1 bits + // } + // reserved variable bits + + // At least one independent substreams exist without ndependent substream + if (data.size() * 8 < (13 + 3 + (2 + 5 + 1 + 1 + 3 + 3 + 1 + 3 + 4 + 1))) { + return false; + } + // Parse dec3 box using reader. BitReader reader(&data[0], data.size()); @@ -41,18 +66,15 @@ bool EAC3::Parse(const std::vector& data, MediaLog* media_log) { int max_channel_count = 0; for (int i = 0; i < num_ind_sub + 1; i++) { - // Please refer to ETSI TS 102 366 V1.4.1 - // https://www.etsi.org/deliver/etsi_ts/102300_102399/102366/01.03.01_60/ts_102366v010301p.pdf - // F.4 AC3SpecificBox - // fscod 2 bits - // bsid 5 bits - // reserved 1 bits - // asvc 1 bits - // bsmod 3 bits + // skip fscod, bsid, reserved, asvc, bsmod RCHECK(reader.SkipBits(2 + 5 + 1 + 1 + 3)); int acmod; RCHECK(reader.ReadBits(3, &acmod)); + if (acmod >= static_cast(sizeof(kGlobalChannelArray))) { + return false; + } + int lfeon; RCHECK(reader.ReadBits(1, &lfeon)); diff --git a/media/formats/mp4/eac3_unittest.cc b/media/formats/mp4/eac3_unittest.cc new file mode 100644 index 000000000000..afdc1b32b673 --- /dev/null +++ b/media/formats/mp4/eac3_unittest.cc @@ -0,0 +1,53 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +#include "media/base/mock_media_log.h" +#include "media/formats/mp4/eac3.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using ::testing::AllOf; +using ::testing::HasSubstr; +using ::testing::InSequence; +using ::testing::StrictMock; + +namespace media { + +namespace mp4 { + +class EAC3Test : public testing::Test { + public: + EAC3Test() = default; + + bool Parse(const std::vector& data) { + return eac3_.Parse(data, &media_log_); + } + + StrictMock media_log_; + EAC3 eac3_; +}; + +TEST_F(EAC3Test, NoInputTest) { + std::vector data; + EXPECT_FALSE(Parse(data)); +} + +TEST_F(EAC3Test, ShortInvalidInputTest) { + std::vector data({0x06, 0xC8}); + + EXPECT_FALSE(Parse(data)); +} + +TEST_F(EAC3Test, NormalInputTest) { + std::vector data({0x06, 0xC8, 0x60, 0x04, 0x00}); + + EXPECT_TRUE(Parse(data)); + EXPECT_EQ(eac3_.GetChannelCount(), 2u); +} + +} // namespace mp4 + +} // namespace media diff --git a/net/BUILD.gn b/net/BUILD.gn index de607701226d..f5da8029472e 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn @@ -1234,8 +1234,6 @@ component("net") { sources += [ "base/network_change_notifier_linux.cc", "base/network_change_notifier_linux.h", - "base/network_interfaces_linux.cc", - "base/platform_mime_util_linux.cc", "proxy_resolution/proxy_config_service_linux.cc", "proxy_resolution/proxy_config_service_linux.h", ] @@ -1710,7 +1708,6 @@ source_set("net_deps") { ":cronet_buildflags", ":isolation_info_proto", ":net_export_header", - ":net_resources", ":preload_decoder", "//base", @@ -1719,7 +1716,6 @@ source_set("net_deps") { "//third_party/protobuf:protobuf_lite", "//third_party/zlib", "//url:buildflags", - "//third_party/boringssl", ] @@ -2146,7 +2142,7 @@ static_library("test_support") { ] if (is_win) { sources += [ "test/spawned_test_server/local_test_server_win.cc" ] - } else if (is_posix) { + } else if (is_posix || is_fuchsia) { sources += [ "test/spawned_test_server/local_test_server_posix.cc" ] } } @@ -2216,7 +2212,10 @@ if (!is_ios && !is_android && !use_cobalt_customizations) { proto_library("cert_verify_comparison_tool_proto") { sources = [ "tools/cert_verify_tool/dumper.proto" ] - # visibility = [ ":cert_verify_comparison_tool" ] + +if (!use_cobalt_customizations) { + visibility = [ ":cert_verify_comparison_tool" ] +} } executable("cert_verify_comparison_tool") { @@ -3077,7 +3076,6 @@ test("net_unittests") { ":net_unittest_files", ":third_party_unittest_files", "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", ] } @@ -5398,8 +5396,7 @@ if (!use_cobalt_customizations) { proto_library("backoff_entry_serializer_fuzzer_input") { proto_in_dir = "//" sources = [ "base/backoff_entry_serializer_fuzzer_input.proto" ] - - # link_deps = [ "//testing/libfuzzer/proto:json_proto" ] + link_deps = [ "//testing/libfuzzer/proto:json_proto" ] } fuzzer_test("net_backoff_entry_serializer_fuzzer") { @@ -6005,8 +6002,7 @@ if (!use_cobalt_customizations) { proto_library("reporting_policy_proto") { proto_in_dir = "//" sources = [ "reporting/reporting_policy.proto" ] - - # link_deps = [ "//testing/libfuzzer/proto:json_proto" ] + link_deps = [ "//testing/libfuzzer/proto:json_proto" ] } } diff --git a/net/METADATA b/net/METADATA index 41052cafd79a..147c39f4bd14 100644 --- a/net/METADATA +++ b/net/METADATA @@ -3,11 +3,19 @@ description: "Subtree at net." third_party { - url { - type: GIT - value: "https://chromium.googlesource.com/chromium/src" + identifier { + type: "ChromiumVersion" + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html + } + identifier { + type: "Git" + value: "https://chromium.googlesource.com/chromium/src.git" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" + } + identifier { + type: "UpstreamSubdir" + value: "net" } - version: "114.0.5735.331" last_upgrade_date { year: 2023 month: 9 diff --git a/net/base/io_buffer.cc b/net/base/io_buffer.cc index 948659290489..114b17901786 100644 --- a/net/base/io_buffer.cc +++ b/net/base/io_buffer.cc @@ -120,9 +120,9 @@ void GrowableIOBuffer::SetCapacity(int capacity) { free(real_data_.release()); real_data_.reset(); } else { - real_data_.reset( - static_cast(realloc(real_data_.release(), capacity))); + real_data_.reset(static_cast(realloc(real_data_.release(), capacity))); } + capacity_ = capacity; if (offset_ > capacity) set_offset(capacity); diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc index 534e5505afe5..52220d281614 100644 --- a/net/base/network_change_notifier_linux.cc +++ b/net/base/network_change_notifier_linux.cc @@ -30,10 +30,10 @@ class NetworkChangeNotifierLinux::BlockingThreadObjects { // Plumbing for NetworkChangeNotifier::GetCurrentConnectionType. // Safe to call from any thread. NetworkChangeNotifier::ConnectionType GetCurrentConnectionType() { - return NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN; + return address_tracker_.GetCurrentConnectionType(); } - internal::AddressTrackerLinux* address_tracker() { return nullptr; } + internal::AddressTrackerLinux* address_tracker() { return &address_tracker_; } // Begin watching for netlink changes. void Init(); @@ -44,20 +44,33 @@ class NetworkChangeNotifierLinux::BlockingThreadObjects { void OnIPAddressChanged(); void OnLinkChanged(); // Used to detect online/offline state and IP address changes. + internal::AddressTrackerLinux address_tracker_; NetworkChangeNotifier::ConnectionType last_type_ = NetworkChangeNotifier::CONNECTION_NONE; }; NetworkChangeNotifierLinux::BlockingThreadObjects::BlockingThreadObjects( const std::unordered_set& ignored_interfaces, - scoped_refptr blocking_thread_runner) {} + scoped_refptr blocking_thread_runner) + : address_tracker_( + base::BindRepeating(&NetworkChangeNotifierLinux:: + BlockingThreadObjects::OnIPAddressChanged, + base::Unretained(this)), + base::BindRepeating( + &NetworkChangeNotifierLinux::BlockingThreadObjects::OnLinkChanged, + base::Unretained(this)), + base::DoNothing(), + ignored_interfaces, + std::move(blocking_thread_runner)) {} void NetworkChangeNotifierLinux::BlockingThreadObjects::Init() { + address_tracker_.Init(); last_type_ = GetCurrentConnectionType(); } void NetworkChangeNotifierLinux::BlockingThreadObjects::InitForTesting( base::ScopedFD netlink_fd) { + address_tracker_.InitWithFdForTesting(std::move(netlink_fd)); // IN-TEST last_type_ = GetCurrentConnectionType(); } diff --git a/net/base/network_interfaces_linux.cc b/net/base/network_interfaces_linux.cc index 74c6212a3e2b..05fa1c7f9798 100644 --- a/net/base/network_interfaces_linux.cc +++ b/net/base/network_interfaces_linux.cc @@ -85,10 +85,46 @@ namespace internal { // or ethtool extensions. NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType( const std::string& ifname) { +/* Cobalt + base::ScopedFD s = GetSocketForIoctl(); + if (!s.is_valid()) + return NetworkChangeNotifier::CONNECTION_UNKNOWN; + + // Test wireless extensions for CONNECTION_WIFI + struct iwreq pwrq = {}; + strncpy(pwrq.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + if (ioctl(s.get(), SIOCGIWNAME, &pwrq) != -1) + return NetworkChangeNotifier::CONNECTION_WIFI; + +#if !BUILDFLAG(IS_ANDROID) + // Test ethtool for CONNECTION_ETHERNET + struct ethtool_cmd ecmd = {}; + ecmd.cmd = ETHTOOL_GSET; + struct ifreq ifr = {}; + ifr.ifr_data = &ecmd; + strncpy(ifr.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + if (ioctl(s.get(), SIOCETHTOOL, &ifr) != -1) + return NetworkChangeNotifier::CONNECTION_ETHERNET; +#endif // !BUILDFLAG(IS_ANDROID) +Cobalt */ + return NetworkChangeNotifier::CONNECTION_UNKNOWN; } std::string GetInterfaceSSID(const std::string& ifname) { +/* Cobalt + base::ScopedFD ioctl_socket = GetSocketForIoctl(); + if (!ioctl_socket.is_valid()) + return std::string(); + struct iwreq wreq = {}; + strncpy(wreq.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + + char ssid[IW_ESSID_MAX_SIZE + 1] = {0}; + wreq.u.essid.pointer = ssid; + wreq.u.essid.length = IW_ESSID_MAX_SIZE; + if (ioctl(ioctl_socket.get(), SIOCGIWESSID, &wreq) != -1) + return ssid; +Cobalt */ return std::string(); } @@ -98,6 +134,66 @@ bool GetNetworkListImpl( const std::unordered_set& online_links, const internal::AddressTrackerLinux::AddressMap& address_map, GetInterfaceNameFunction get_interface_name) { +/* Cobalt + std::map ifnames; + + for (const auto& it : address_map) { + // Ignore addresses whose links are not online. + if (online_links.find(it.second.ifa_index) == online_links.end()) + continue; + + sockaddr_storage sock_addr; + socklen_t sock_len = sizeof(sockaddr_storage); + + // Convert to sockaddr for next check. + if (!IPEndPoint(it.first, 0) + .ToSockAddr(reinterpret_cast(&sock_addr), &sock_len)) { + continue; + } + + // Skip unspecified addresses (i.e. made of zeroes) and loopback addresses + if (IsLoopbackOrUnspecifiedAddress(reinterpret_cast(&sock_addr))) + continue; + + int ip_attributes = IP_ADDRESS_ATTRIBUTE_NONE; + + if (it.second.ifa_family == AF_INET6) { + // Ignore addresses whose attributes are not actionable by + // the application layer. + if (!TryConvertNativeToNetIPAttributes(it.second.ifa_flags, + &ip_attributes)) + continue; + } + + // Find the name of this link. + std::map::const_iterator itname = + ifnames.find(it.second.ifa_index); + std::string ifname; + if (itname == ifnames.end()) { + char buffer[IFNAMSIZ] = {0}; + ifname.assign(get_interface_name(it.second.ifa_index, buffer)); + // Ignore addresses whose interface name can't be retrieved. + if (ifname.empty()) + continue; + ifnames[it.second.ifa_index] = ifname; + } else { + ifname = itname->second; + } + + // Based on the interface name and policy, determine whether we + // should ignore it. + if (ShouldIgnoreInterface(ifname, policy)) + continue; + + NetworkChangeNotifier::ConnectionType type = + GetInterfaceConnectionType(ifname); + + networks->push_back( + NetworkInterface(ifname, ifname, it.second.ifa_index, type, it.first, + it.second.ifa_prefixlen, ip_attributes)); + } +Cobalt */ + return true; } @@ -119,6 +215,12 @@ std::string GetWifiSSIDFromInterfaceListInternal( } base::ScopedFD GetSocketForIoctl() { +/* Cobalt + base::ScopedFD ioctl_socket(socket(AF_INET6, SOCK_DGRAM, 0)); + if (ioctl_socket.is_valid()) + return ioctl_socket; + return base::ScopedFD(socket(AF_INET, SOCK_DGRAM, 0)); +Cobalt */ return base::ScopedFD(); } @@ -152,7 +254,9 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) { #endif // BUILDFLAG(IS_ANDROID) const AddressMapOwnerLinux* map_owner = nullptr; - // absl::optional temp_tracker; +/* Cobalt + absl::optional temp_tracker; +Cobalt */ #if BUILDFLAG(IS_LINUX) // If NetworkChangeNotifier already maintains a map owner in this process, use // it. @@ -161,11 +265,13 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) { } #endif // BUILDFLAG(IS_LINUX) if (!map_owner) { +/* Cobalt // If there is no existing map_owner, create an AdressTrackerLinux and // initialize it. - // temp_tracker.emplace(); - // temp_tracker->Init(); - // map_owner = &temp_tracker.value(); + temp_tracker.emplace(); + temp_tracker->Init(); + map_owner = &temp_tracker.value(); +Cobalt */ } return internal::GetNetworkListImpl( diff --git a/net/base/platform_mime_util_linux.cc b/net/base/platform_mime_util_linux.cc index cbc83fae8dd5..4d124ba12a04 100644 --- a/net/base/platform_mime_util_linux.cc +++ b/net/base/platform_mime_util_linux.cc @@ -36,24 +36,26 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( const base::FilePath::StringType& ext, std::string* result) const { return false; - // base::FilePath dummy_path("foo." + ext); - // std::string out = base::nix::GetFileMimeType(dummy_path); +/* Cobalt + base::FilePath dummy_path("foo." + ext); + std::string out = base::nix::GetFileMimeType(dummy_path); - // // GetFileMimeType likes to return application/octet-stream - // // for everything it doesn't know - ignore that. - // if (out == "application/octet-stream" || out.empty()) - // return false; + // GetFileMimeType likes to return application/octet-stream + // for everything it doesn't know - ignore that. + if (out == "application/octet-stream" || out.empty()) + return false; - // // GetFileMimeType returns image/x-ico because that's what's in the XDG - // // mime database. That database is the merger of the Gnome and KDE mime - // // databases. Apparently someone working on KDE in 2001 decided .ico - // // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. - // // FWIW, image/vnd.microsoft.icon is the official IANA assignment. - // if (out == "image/x-ico") - // out = "image/x-icon"; + // GetFileMimeType returns image/x-ico because that's what's in the XDG + // mime database. That database is the merger of the Gnome and KDE mime + // databases. Apparently someone working on KDE in 2001 decided .ico + // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. + // FWIW, image/vnd.microsoft.icon is the official IANA assignment. + if (out == "image/x-ico") + out = "image/x-icon"; - // *result = out; - // return true; + *result = out; + return true; +Cobalt */ } #endif // BUILDFLAG(IS_ANDROID) diff --git a/net/cert/internal/trust_store_in_memory_starboard.cc b/net/cert/internal/trust_store_in_memory_starboard.cc index 826c6b143a67..c773a3185ae9 100644 --- a/net/cert/internal/trust_store_in_memory_starboard.cc +++ b/net/cert/internal/trust_store_in_memory_starboard.cc @@ -142,7 +142,7 @@ void TrustStoreInMemoryStarboard::SyncGetIssuersOf( ParsedCertificateList* issuers) { DCHECK(issuers); DCHECK(issuers->empty()); - starboard::ScopedLock scoped_lock(load_mutex_); + base::AutoLock scoped_lock(load_mutex_); // Look up the request certificate first in the trust store in memory. underlying_trust_store_.SyncGetIssuersOf(cert, issuers); if (issuers->empty()) { @@ -158,7 +158,7 @@ void TrustStoreInMemoryStarboard::SyncGetIssuersOf( CertificateTrust TrustStoreInMemoryStarboard::GetTrust(const ParsedCertificate* cert, base::SupportsUserData* debug_data) { - starboard::ScopedLock scoped_lock(load_mutex_); + base::AutoLock scoped_lock(load_mutex_); // Loop up the request certificate first in the trust store in memory. CertificateTrust trust = underlying_trust_store_.GetTrust(cert, debug_data); if (trust.HasUnspecifiedTrust()) { diff --git a/net/cert/internal/trust_store_in_memory_starboard.h b/net/cert/internal/trust_store_in_memory_starboard.h index 4e0e4e274a01..d8cb1d292834 100644 --- a/net/cert/internal/trust_store_in_memory_starboard.h +++ b/net/cert/internal/trust_store_in_memory_starboard.h @@ -18,8 +18,8 @@ #include #include "base/strings/string_piece.h" +#include "base/synchronization/lock.h" #include "net/cert/pki/trust_store_in_memory.h" -#include "starboard/common/mutex.h" namespace net { @@ -38,7 +38,7 @@ class NET_EXPORT TrustStoreInMemoryStarboard : public TrustStore { // Returns true if the trust store contains the given ParsedCertificate // (matches by DER). bool Contains(const ParsedCertificate* cert) const { - starboard::ScopedLock scoped_lock(load_mutex_); + base::AutoLock scoped_lock(load_mutex_); return underlying_trust_store_.Contains(cert); } @@ -58,7 +58,7 @@ class NET_EXPORT TrustStoreInMemoryStarboard : public TrustStore { // the synchronization issue is solved by initializing trust store at startup // and passing constant reference to consumers. Cobalt loads certs lazily and // therefore guards the underlying_trust_store_ with mutex. - starboard::Mutex load_mutex_; + mutable base::Lock load_mutex_; const std::unordered_set trusted_cert_names_on_disk_; }; diff --git a/net/cert/pki/ocsp.cc b/net/cert/pki/ocsp.cc index ea6f4ca1a83b..72044ebd0d62 100644 --- a/net/cert/pki/ocsp.cc +++ b/net/cert/pki/ocsp.cc @@ -765,20 +765,22 @@ OCSPRevocationStatus GetRevocationStatusForCert( if (!CheckCertIDMatchesCertificate(cert_id, cert, issuer_certificate)) continue; +/* Cobalt // The SingleResponse matches the certificate, but may be out of date. Out // of date responses are noted seperate from responses with mismatched // serial numbers. If an OCSP responder provides both an up to date // response and an expired response, the up to date response takes // precedence (PROVIDED > INVALID_DATE). - // if (!CheckRevocationDateValid(single_response.this_update, - // single_response.has_next_update - // ? &single_response.next_update - // : nullptr, - // verify_time_epoch_seconds, max_age_seconds)) { - // if (*response_details != OCSPVerifyResult::PROVIDED) - // *response_details = OCSPVerifyResult::INVALID_DATE; - // continue; - // } + if (!CheckRevocationDateValid(single_response.this_update, + single_response.has_next_update + ? &single_response.next_update + : nullptr, + verify_time_epoch_seconds, max_age_seconds)) { + if (*response_details != OCSPVerifyResult::PROVIDED) + *response_details = OCSPVerifyResult::INVALID_DATE; + continue; + } +Cobalt */ // In the case with multiple matching and up to date responses, keep only // the strictest status (REVOKED > UNKNOWN > GOOD). diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc index fb7dcaf7719d..1b3c0adf45fd 100644 --- a/net/cookies/cookie_util.cc +++ b/net/cookies/cookie_util.cc @@ -326,6 +326,9 @@ bool GetCookieDomainWithString(const GURL& url, // a sequence of individual domain name labels"; a label can only be empty if // it is the last label in the name, but a name ending in `..` would have an // empty label in the penultimate position and is thus invalid. +/* Cobalt + if (url_host.ends_with("..")) { +Cobalt */ if (base::EndsWith(url_host, "..")) { return false; } diff --git a/net/disk_cache/blockfile/mapped_file_posix.cc b/net/disk_cache/blockfile/mapped_file_posix.cc index ddf66e905eb5..f31e9371a0a1 100644 --- a/net/disk_cache/blockfile/mapped_file_posix.cc +++ b/net/disk_cache/blockfile/mapped_file_posix.cc @@ -14,6 +14,30 @@ namespace disk_cache { void* MappedFile::Init(const base::FilePath& name, size_t size) { +/* Cobalt + DCHECK(!init_); + if (init_ || !File::Init(name)) + return nullptr; + + size_t temp_len = size ? size : 4096; + if (!size) + size = GetLength(); + + buffer_ = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, + platform_file(), 0); + init_ = true; + view_size_ = size; + DPLOG_IF(FATAL, buffer_ == MAP_FAILED) << "Failed to mmap " << name.value(); + if (buffer_ == MAP_FAILED) + buffer_ = nullptr; + + // Make sure we detect hardware failures reading the headers. + auto temp = std::make_unique(temp_len); + if (!Read(temp.get(), temp_len, 0)) + return nullptr; + + return buffer_; +Cobalt */ return nullptr; } @@ -21,6 +45,15 @@ void MappedFile::Flush() { } MappedFile::~MappedFile() { +/* Cobalt + if (!init_) + return; + + if (buffer_) { + int ret = munmap(buffer_, view_size_); + DCHECK_EQ(0, ret); + } +Cobalt */ } } // namespace disk_cache diff --git a/net/disk_cache/disk_cache_test_base.cc b/net/disk_cache/disk_cache_test_base.cc index a342907073b5..872cd4a622d6 100644 --- a/net/disk_cache/disk_cache_test_base.cc +++ b/net/disk_cache/disk_cache_test_base.cc @@ -50,8 +50,11 @@ bool DiskCacheTest::CopyTestCache(const std::string& name) { path = path.AppendASCII("cache_tests"); path = path.AppendASCII(name); +/* Cobalt if (!CleanupCacheDir()) return false; + return base::CopyDirectory(path, cache_path_, false); +Cobalt */ return false; } diff --git a/net/disk_cache/simple/simple_index.cc b/net/disk_cache/simple/simple_index.cc index b2700c1fd65f..48dc134c2862 100644 --- a/net/disk_cache/simple/simple_index.cc +++ b/net/disk_cache/simple/simple_index.cc @@ -620,6 +620,9 @@ void SimpleIndex::WriteToDisk(IndexWriteToDiskReason reason) { if (cleanup_tracker_) { // Make anyone synchronizing with our cleanup wait for the index to be // written back. +/* Cobalt + after_write = base::DoNothingWithBoundArgs(cleanup_tracker_); +Cobalt */ after_write = base::DoNothingWithBoundArgs(std::move(cleanup_tracker_)); } diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn index 3b51206d4195..2021e463a9f3 100644 --- a/net/dns/BUILD.gn +++ b/net/dns/BUILD.gn @@ -527,7 +527,7 @@ if (!use_cobalt_customizations) { proto_library("host_cache_fuzzer_proto") { proto_in_dir = "//" sources = [ "host_cache_fuzzer.proto" ] - # deps = [ "//testing/libfuzzer/proto:json_proto" ] + deps = [ "//testing/libfuzzer/proto:json_proto" ] } fuzzer_test("net_dns_host_cache_fuzzer") { diff --git a/net/dns/context_host_resolver_unittest.cc b/net/dns/context_host_resolver_unittest.cc index c34b5999f3b1..928adabf6f1a 100644 --- a/net/dns/context_host_resolver_unittest.cc +++ b/net/dns/context_host_resolver_unittest.cc @@ -809,6 +809,9 @@ class NetworkAwareHostResolverProc : public HostResolverProc { handles::NetworkHandle network) override { // Presume failure *os_error = 1; +/* Cobalt + const auto* iter = kResults.find(network); +Cobalt */ const auto iter = kResults.find(network); if (iter == kResults.end()) return ERR_NETWORK_CHANGED; diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc index d1d4361d28f4..37c725f60c86 100644 --- a/net/dns/dns_config_service_linux.cc +++ b/net/dns/dns_config_service_linux.cc @@ -340,6 +340,34 @@ class DnsConfigServiceLinux::Watcher : public DnsConfigService::Watcher { CheckOnCorrectSequence(); bool success = true; +/* Cobalt + if (!resolv_watcher_.Watch( + base::FilePath(kFilePathResolv), + base::FilePathWatcher::Type::kNonRecursive, + base::BindRepeating(&Watcher::OnResolvFilePathWatcherChange, + base::Unretained(this)))) { + LOG(ERROR) << "DNS config (resolv.conf) watch failed to start."; + success = false; + } + + if (!nsswitch_watcher_.Watch( + base::FilePath(kFilePathNsswitch), + base::FilePathWatcher::Type::kNonRecursive, + base::BindRepeating(&Watcher::OnNsswitchFilePathWatcherChange, + base::Unretained(this)))) { + LOG(ERROR) << "DNS nsswitch.conf watch failed to start."; + success = false; + } + + if (!hosts_watcher_.Watch( + base::FilePath(kFilePathHosts), + base::FilePathWatcher::Type::kNonRecursive, + base::BindRepeating(&Watcher::OnHostsFilePathWatcherChange, + base::Unretained(this)))) { + LOG(ERROR) << "DNS hosts watch failed to start."; + success = false; + } +Cobalt */ return success; } @@ -357,6 +385,12 @@ class DnsConfigServiceLinux::Watcher : public DnsConfigService::Watcher { void OnHostsFilePathWatcherChange(const base::FilePath& path, bool error) { OnHostsChanged(!error); } + +/* Cobalt + base::FilePathWatcher resolv_watcher_; + base::FilePathWatcher nsswitch_watcher_; + base::FilePathWatcher hosts_watcher_; +Cobalt */ }; // A SerialWorker that uses libresolv to initialize res_state and converts diff --git a/net/dns/dns_names_util_unittest.cc b/net/dns/dns_names_util_unittest.cc index 08f9356f8b43..c04b0335e037 100644 --- a/net/dns/dns_names_util_unittest.cc +++ b/net/dns/dns_names_util_unittest.cc @@ -773,10 +773,7 @@ TEST(DnsUtilTest, CanonicalizeNames) { EXPECT_EQ(UrlCanonicalizeNameIfAble("g{oo}gle.test"), "g%7Boo%7Dgle.test"); EXPECT_EQ(UrlCanonicalizeNameIfAble("G{OO}GLE.test"), "g%7Boo%7Dgle.test"); -// The MSVC compiler can't handle the below character, even in a comment. -#if !defined(COMPILER_MSVC) - // g�gle.test -#endif + // gügle.test EXPECT_EQ(UrlCanonicalizeNameIfAble("g\u00FCgle.test"), "xn--ggle-0ra.test"); EXPECT_EQ(UrlCanonicalizeNameIfAble("G\u00fcGLE.test"), "xn--ggle-0ra.test"); } diff --git a/net/dns/host_resolver_internal_result.cc b/net/dns/host_resolver_internal_result.cc index 12cd46f08cb2..bb3434156833 100644 --- a/net/dns/host_resolver_internal_result.cc +++ b/net/dns/host_resolver_internal_result.cc @@ -100,6 +100,9 @@ absl::optional QueryTypeFromValue(const base::Value& value) { const std::string* query_type_string = value.GetIfString(); if (!query_type_string) return absl::nullopt; +/* Cobalt + const auto* query_type_it = +Cobalt */ const auto query_type_it = base::ranges::find(kDnsQueryTypes, *query_type_string, &decltype(kDnsQueryTypes)::value_type::second); @@ -261,6 +264,9 @@ bool HostResolverInternalResult::ValidateValueBaseDict( const std::string* query_type_string = dict.FindString(kValueQueryTypeKey); if (!query_type_string) return false; +/* Cobalt + const auto* query_type_it = +Cobalt */ const auto query_type_it = base::ranges::find(kDnsQueryTypes, *query_type_string, &decltype(kDnsQueryTypes)::value_type::second); diff --git a/net/dns/mock_host_resolver.h b/net/dns/mock_host_resolver.h index aa86d7c4fd83..488036fbe87d 100644 --- a/net/dns/mock_host_resolver.h +++ b/net/dns/mock_host_resolver.h @@ -240,6 +240,9 @@ class MockHostResolverBase } private: +/* Cobalt + friend class RefCounted; +Cobalt */ friend class base::RefCounted; ~State(); @@ -680,6 +683,9 @@ class HangingHostResolver : public HostResolver { void IncrementNumCancellations() { ++num_cancellations_; } private: +/* Cobalt + friend class RefCounted; +Cobalt */ friend class base::RefCounted; ~State(); diff --git a/net/filter/gzip_header.cc b/net/filter/gzip_header.cc index a94a902935ba..69028c17b4bd 100644 --- a/net/filter/gzip_header.cc +++ b/net/filter/gzip_header.cc @@ -4,8 +4,9 @@ #include "net/filter/gzip_header.h" +#include + #include -#include #include "base/check_op.h" #include "third_party/zlib/zlib.h" diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 4e06c8e38afc..093e8a5486f4 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -149,7 +149,6 @@ HttpNetworkSession::HttpNetworkSession(const HttpNetworkSessionParams& params, context.ct_policy_enforcer, &ssl_client_session_cache_, context.sct_auditing_delegate), -#if !defined(QUIC_DISABLED_FOR_STARBOARD) quic_stream_factory_(context.net_log, context.host_resolver, context.ssl_config_service, @@ -162,7 +161,6 @@ HttpNetworkSession::HttpNetworkSession(const HttpNetworkSessionParams& params, context.socket_performance_watcher_factory, context.quic_crypto_client_stream_factory, context.quic_context), -#endif spdy_session_pool_(context.host_resolver, &ssl_client_context_, context.http_server_properties, @@ -270,7 +268,6 @@ std::unique_ptr HttpNetworkSession::SpdySessionPoolInfoToValue() base::Value HttpNetworkSession::QuicInfoToValue() const { base::Value::Dict dict; -#if !defined(QUIC_DISABLED_FOR_STARBOARD) dict.Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); dict.Set("quic_enabled", IsQuicEnabled()); @@ -334,7 +331,6 @@ base::Value HttpNetworkSession::QuicInfoToValue() const { dict.Set("initial_rtt_for_handshake_milliseconds", static_cast( quic_params->initial_rtt_for_handshake.InMilliseconds())); -#endif return base::Value(std::move(dict)); } @@ -345,9 +341,7 @@ void HttpNetworkSession::CloseAllConnections(int net_error, websocket_socket_pool_manager_->FlushSocketPoolsWithError( net_error, net_log_reason_utf8); spdy_session_pool_.CloseCurrentSessions(static_cast(net_error)); -#if !defined(QUIC_DISABLED_FOR_STARBOARD) quic_stream_factory_.CloseAllSessions(net_error, quic::QUIC_PEER_GOING_AWAY); -#endif } void HttpNetworkSession::CloseIdleConnections(const char* net_log_reason_utf8) { @@ -364,17 +358,11 @@ void HttpNetworkSession::SetServerPushDelegate( push_delegate_ = std::move(push_delegate); spdy_session_pool_.set_server_push_delegate(push_delegate_.get()); -#if !defined(QUIC_DISABLED_FOR_STARBOARD) quic_stream_factory_.set_server_push_delegate(push_delegate_.get()); -#endif } bool HttpNetworkSession::IsQuicEnabled() const { -#if !defined(QUIC_DISABLED_FOR_STARBOARD) return params_.enable_quic; -#else - return false; -#endif } void HttpNetworkSession::DisableQuic() { @@ -403,11 +391,7 @@ CommonConnectJobParams HttpNetworkSession::CreateCommonConnectJobParams( context_.client_socket_factory, context_.host_resolver, &http_auth_cache_, context_.http_auth_handler_factory, &spdy_session_pool_, &context_.quic_context->params()->supported_versions, -#if !defined(QUIC_DISABLED_FOR_STARBOARD) &quic_stream_factory_, -#else - nullptr, -#endif context_.proxy_delegate, context_.http_user_agent_settings, &ssl_client_context_, context_.socket_performance_watcher_factory, diff --git a/net/http/http_stream_factory_job_controller.cc b/net/http/http_stream_factory_job_controller.cc index 246a63f53d0b..c2d1194a6309 100644 --- a/net/http/http_stream_factory_job_controller.cc +++ b/net/http/http_stream_factory_job_controller.cc @@ -1210,13 +1210,18 @@ HttpStreamFactory::JobController::GetAlternativeServiceInfoInternal( if (alternative_service_info_vector.empty() && session_->IsQuicEnabled() && session_->UseQuicForUnknownOrigin()) { url::SchemeHostPort origin(original_url); +// Leave the port restriction only in production builds to simplify testing +#if defined(COBALT_BUILD_TYPE_GOLD) if (origin.port() == kDefaultQUICServerPort) { +#endif quic::ParsedQuicVersionVector versions = quic::AllSupportedVersions(); return AlternativeServiceInfo::CreateQuicAlternativeServiceInfo( AlternativeService(net::kProtoQUIC, origin.host(), - kDefaultQUICServerPort), + origin.port()), base::Time::Max(), versions); +#if defined(COBALT_BUILD_TYPE_GOLD) } +#endif return AlternativeServiceInfo(); } #else diff --git a/net/proxy_resolution/proxy_config_service_linux.cc b/net/proxy_resolution/proxy_config_service_linux.cc index 51b89520eeb5..3756a6b2938a 100644 --- a/net/proxy_resolution/proxy_config_service_linux.cc +++ b/net/proxy_resolution/proxy_config_service_linux.cc @@ -40,11 +40,6 @@ #include #endif // defined(USE_GIO) -#if defined(STARBOARD) -#include "starboard/common/file.h" -#include "starboard/types.h" -#endif - namespace net { class ScopedAllowBlockingForSettingGetter : public base::ScopedAllowBlocking {}; @@ -625,12 +620,14 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { PLOG(ERROR) << "inotify_init failed"; return false; } - // if (!base::SetNonBlocking(inotify_fd_)) { - // PLOG(ERROR) << "base::SetNonBlocking failed"; - // close(inotify_fd_); - // inotify_fd_ = -1; - // return false; - // } +/* Cobalt + if (!base::SetNonBlocking(inotify_fd_)) { + PLOG(ERROR) << "base::SetNonBlocking failed"; + close(inotify_fd_); + inotify_fd_ = -1; + return false; + } +Cobalt */ constexpr base::TaskTraits kTraits = {base::TaskPriority::USER_VISIBLE, base::MayBlock()}; @@ -646,7 +643,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { void ShutDown() override { if (inotify_fd_ >= 0) { ResetCachedSettings(); - // inotify_watcher_.reset(); +/* Cobalt + inotify_watcher_.reset(); +Cobalt */ close(inotify_fd_); inotify_fd_ = -1; } @@ -675,7 +674,12 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { return false; } notify_delegate_ = delegate; - +/* Cobalt + inotify_watcher_ = base::FileDescriptorWatcher::WatchReadable( + inotify_fd_, + base::BindRepeating(&SettingGetterImplKDE::OnChangeNotification, + base::Unretained(this))); +Cobalt */ // Simulate a change to avoid possibly losing updates before this point. OnChangeNotification(); return true; @@ -863,6 +867,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { bool at_least_one_kioslaverc_opened = false; for (const auto& kde_config_dir : kde_config_dirs_) { base::FilePath kioslaverc = kde_config_dir.Append("kioslaverc"); +/* Cobalt + base::ScopedFILE input(base::OpenFile(kioslaverc, "r")); +Cobalt */ base::ScopedFILE input(new starboard::ScopedFile(kioslaverc.value().c_str(), kSbFileOpenOnly | kSbFileRead)); if (!input.get()) continue; @@ -876,68 +883,70 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { bool line_too_long = false; char line[BUFFER_SIZE]; // fgets() will return NULL on EOF or error. - // while (fgets(line, sizeof(line), input.get())) { - // // fgets() guarantees the line will be properly terminated. - // size_t length = strlen(line); - // if (!length) - // continue; - // // This should be true even with CRLF endings. - // if (line[length - 1] != '\n') { - // line_too_long = true; - // continue; - // } - // if (line_too_long) { - // // The previous line had no line ending, but this one does. This is - // // the end of the line that was too long, so warn here and skip it. - // LOG(WARNING) << "skipped very long line in " << kioslaverc.value(); - // line_too_long = false; - // continue; - // } - // // Remove the LF at the end, and the CR if there is one. - // line[--length] = '\0'; - // if (length && line[length - 1] == '\r') - // line[--length] = '\0'; - // // Now parse the line. - // if (line[0] == '[') { - // // Switching sections. All we care about is whether this is - // // the (a?) proxy settings section, for both KDE3 and KDE4. - // in_proxy_settings = !strncmp(line, "[Proxy Settings]", 16); - // } else if (in_proxy_settings) { - // // A regular line, in the (a?) proxy settings section. - // char* split = strchr(line, '='); - // // Skip this line if it does not contain an = sign. - // if (!split) - // continue; - // // Split the line on the = and advance |split|. - // *(split++) = 0; - // std::string key = line; - // std::string value = split; - // base::TrimWhitespaceASCII(key, base::TRIM_ALL, &key); - // base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value); - // // Skip this line if the key name is empty. - // if (key.empty()) - // continue; - // // Is the value name localized? - // if (key[key.length() - 1] == ']') { - // // Find the matching bracket. - // length = key.rfind('['); - // // Skip this line if the localization indicator is malformed. - // if (length == std::string::npos) - // continue; - // // Trim the localization indicator off. - // key.resize(length); - // // Remove any resulting trailing whitespace. - // base::TrimWhitespaceASCII(key, base::TRIM_TRAILING, &key); - // // Skip this line if the key name is now empty. - // if (key.empty()) - // continue; - // } - // // Now fill in the tables. - // AddKDESetting(key, value); - // } - // } - // if (ferror(input.get())) - // LOG(ERROR) << "error reading " << kioslaverc.value(); +/* Cobalt + while (fgets(line, sizeof(line), input.get())) { + // fgets() guarantees the line will be properly terminated. + size_t length = strlen(line); + if (!length) + continue; + // This should be true even with CRLF endings. + if (line[length - 1] != '\n') { + line_too_long = true; + continue; + } + if (line_too_long) { + // The previous line had no line ending, but this one does. This is + // the end of the line that was too long, so warn here and skip it. + LOG(WARNING) << "skipped very long line in " << kioslaverc.value(); + line_too_long = false; + continue; + } + // Remove the LF at the end, and the CR if there is one. + line[--length] = '\0'; + if (length && line[length - 1] == '\r') + line[--length] = '\0'; + // Now parse the line. + if (line[0] == '[') { + // Switching sections. All we care about is whether this is + // the (a?) proxy settings section, for both KDE3 and KDE4. + in_proxy_settings = !strncmp(line, "[Proxy Settings]", 16); + } else if (in_proxy_settings) { + // A regular line, in the (a?) proxy settings section. + char* split = strchr(line, '='); + // Skip this line if it does not contain an = sign. + if (!split) + continue; + // Split the line on the = and advance |split|. + *(split++) = 0; + std::string key = line; + std::string value = split; + base::TrimWhitespaceASCII(key, base::TRIM_ALL, &key); + base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value); + // Skip this line if the key name is empty. + if (key.empty()) + continue; + // Is the value name localized? + if (key[key.length() - 1] == ']') { + // Find the matching bracket. + length = key.rfind('['); + // Skip this line if the localization indicator is malformed. + if (length == std::string::npos) + continue; + // Trim the localization indicator off. + key.resize(length); + // Remove any resulting trailing whitespace. + base::TrimWhitespaceASCII(key, base::TRIM_TRAILING, &key); + // Skip this line if the key name is now empty. + if (key.empty()) + continue; + } + // Now fill in the tables. + AddKDESetting(key, value); + } + } + if (ferror(input.get())) + LOG(ERROR) << "error reading " << kioslaverc.value(); +Cobalt */ } if (at_least_one_kioslaverc_opened) { ResolveModeEffects(); @@ -993,7 +1002,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { // large), but if it does we'd warn continuously since |inotify_fd_| // would be forever ready to read. Close it and stop watching instead. LOG(ERROR) << "inotify failure; no longer watching kioslaverc!"; - // inotify_watcher_.reset(); +/* Cobalt + inotify_watcher_.reset(); +Cobalt */ close(inotify_fd_); inotify_fd_ = -1; } @@ -1014,7 +1025,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { std::vector > strings_map_type; int inotify_fd_ = -1; - // std::unique_ptr inotify_watcher_; +/* Cobalt + std::unique_ptr inotify_watcher_; +Cobalt */ raw_ptr notify_delegate_ = nullptr; std::unique_ptr debounce_timer_; std::vector kde_config_dirs_; diff --git a/net/quic/platform/impl/quic_test_flags_utils.cc b/net/quic/platform/impl/quic_test_flags_utils.cc index cefbcdf6352b..2b046d9ed64a 100644 --- a/net/quic/platform/impl/quic_test_flags_utils.cc +++ b/net/quic/platform/impl/quic_test_flags_utils.cc @@ -51,11 +51,9 @@ QuicFlagChecker::QuicFlagChecker() { QUIC_PROTOCOL_FLAG_CHECK(type, flag, external_value); #define CR_EXPAND_ARG(arg) #define GET_6TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...) arg6 -#define QUIC_PROTOCOL_FLAG(...) \ +#define QUIC_PROTOCOL_FLAG(...) \ CR_EXPAND_ARG(GET_6TH_ARG(__VA_ARGS__, DEFINE_QUIC_PROTOCOL_FLAG_TWO_VALUES, \ DEFINE_QUIC_PROTOCOL_FLAG_SINGLE_VALUE)(__VAR_ARGS__)) -// #define QUIC_PROTOCOL_FLAG(...) \ -// QUIC_PROTOCOL_FLAG_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__) #include "net/third_party/quiche/src/quiche/quic/core/quic_protocol_flags_list.h" #undef QUIC_PROTOCOL_FLAG #undef QUIC_PROTOCOL_FLAG_MACRO_CHOOSER diff --git a/net/quic/quic_chromium_client_session.cc b/net/quic/quic_chromium_client_session.cc index a1d37be5ba5a..3a2fb494df1a 100644 --- a/net/quic/quic_chromium_client_session.cc +++ b/net/quic/quic_chromium_client_session.cc @@ -1432,7 +1432,9 @@ bool QuicChromiumClientSession::GetSSLInfo(SSLInfo* ssl_info) const { ssl_info->signed_certificate_timestamps = cert_verify_result_->scts; ssl_info->ct_policy_compliance = cert_verify_result_->policy_compliance; +#if !defined(STARBOARD) DCHECK(connection()->version().UsesTls()); +#endif const auto& crypto_params = crypto_stream_->crypto_negotiated_params(); uint16_t cipher_suite = crypto_params.cipher_suite; int ssl_connection_status = 0; @@ -2036,8 +2038,10 @@ void QuicChromiumClientSession::OnConnectionClosed( tick_clock_->NowTicks() - connect_timing_.connect_end); UMA_HISTOGRAM_COUNTS_100("Net.QuicSession.NumMigrations", num_migrations_); +#if !defined(STARBOARD) // KeyUpdates are used in TLS, but we no longer support pre-TLS QUIC. DCHECK(connection()->version().UsesTls()); +#endif base::UmaHistogramCounts100("Net.QuicSession.KeyUpdate.PerConnection2", connection()->GetStats().key_update_count); base::UmaHistogramCounts100( @@ -3117,6 +3121,9 @@ QuicChromiumClientSession::CreateContextForMultiPortPath() { void QuicChromiumClientSession::MigrateToMultiPortPath( std::unique_ptr context) { +/* Cobalt + DCHECK_NE(nullptr, context); +Cobalt */ DCHECK_NE(nullptr, context.get()); auto* chrome_context = static_cast(context.get()); diff --git a/net/third_party/quiche/src/quiche/quic/core/quic_buffered_packet_store.cc b/net/third_party/quiche/src/quiche/quic/core/quic_buffered_packet_store.cc index df028f01ad09..284e3b93ad20 100644 --- a/net/third_party/quiche/src/quiche/quic/core/quic_buffered_packet_store.cc +++ b/net/third_party/quiche/src/quiche/quic/core/quic_buffered_packet_store.cc @@ -298,7 +298,9 @@ bool QuicBufferedPacketStore::IngestPacketForTlsChloExtraction( QUICHE_DCHECK_NE(out_alpns, nullptr); QUICHE_DCHECK_NE(out_sni, nullptr); QUICHE_DCHECK_NE(tls_alert, nullptr); +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(version.handshake_protocol, PROTOCOL_TLS1_3); +#endif auto it = undecryptable_packets_.find(connection_id); if (it == undecryptable_packets_.end()) { QUIC_BUG(quic_bug_10838_1) diff --git a/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc b/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc index e03eb465f8b0..6aa3e47ac853 100644 --- a/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc +++ b/net/third_party/quiche/src/quiche/quic/core/quic_connection.cc @@ -6167,7 +6167,9 @@ bool QuicConnection::IsHandshakeComplete() const { } bool QuicConnection::IsHandshakeConfirmed() const { +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(PROTOCOL_TLS1_3, version().handshake_protocol); +#endif return visitor_->GetHandshakeState() == HANDSHAKE_CONFIRMED; } diff --git a/net/third_party/quiche/src/quiche/quic/core/quic_session.cc b/net/third_party/quiche/src/quiche/quic/core/quic_session.cc index a5664acda70f..766e68c469f9 100644 --- a/net/third_party/quiche/src/quiche/quic/core/quic_session.cc +++ b/net/third_party/quiche/src/quiche/quic/core/quic_session.cc @@ -1466,7 +1466,9 @@ void QuicSession::OnNewStreamFlowControlWindow(QuicStreamOffset new_window) { void QuicSession::OnNewStreamUnidirectionalFlowControlWindow( QuicStreamOffset new_window) { +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); +#endif QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamUnidirectionalFlowControlWindow " << new_window; // Inform all existing outgoing unidirectional streams about the new window. @@ -1496,7 +1498,9 @@ void QuicSession::OnNewStreamUnidirectionalFlowControlWindow( void QuicSession::OnNewStreamOutgoingBidirectionalFlowControlWindow( QuicStreamOffset new_window) { +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); +#endif QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamOutgoingBidirectionalFlowControlWindow " << new_window; @@ -1527,7 +1531,9 @@ void QuicSession::OnNewStreamOutgoingBidirectionalFlowControlWindow( void QuicSession::OnNewStreamIncomingBidirectionalFlowControlWindow( QuicStreamOffset new_window) { +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); +#endif QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamIncomingBidirectionalFlowControlWindow " << new_window; @@ -1692,7 +1698,9 @@ void QuicSession::SetDefaultEncryptionLevel(EncryptionLevel level) { } void QuicSession::OnTlsHandshakeComplete() { +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(PROTOCOL_TLS1_3, connection_->version().handshake_protocol); +#endif QUIC_BUG_IF(quic_bug_12435_9, !GetCryptoStream()->crypto_negotiated_params().cipher_suite) << ENDPOINT << "Handshake completes without cipher suite negotiation."; diff --git a/net/third_party/quiche/src/quiche/quic/core/tls_server_handshaker.cc b/net/third_party/quiche/src/quiche/quic/core/tls_server_handshaker.cc index f4bbd3df8ff9..8cea8ca54f02 100644 --- a/net/third_party/quiche/src/quiche/quic/core/tls_server_handshaker.cc +++ b/net/third_party/quiche/src/quiche/quic/core/tls_server_handshaker.cc @@ -189,8 +189,10 @@ TlsServerHandshaker::TlsServerHandshaker( QUIC_DVLOG(1) << "TlsServerHandshaker: client_cert_mode initial value: " << client_cert_mode(); +#if !defined(STARBOARD) QUICHE_DCHECK_EQ(PROTOCOL_TLS1_3, session->connection()->version().handshake_protocol); +#endif // Configure the SSL to be a server. SSL_set_accept_state(ssl()); diff --git a/starboard/CHANGELOG.md b/starboard/CHANGELOG.md index f3642c128251..93dbedbc3cc2 100644 --- a/starboard/CHANGELOG.md +++ b/starboard/CHANGELOG.md @@ -9,6 +9,13 @@ since the version previous to it. ## Version 16 +## Added new configuration constant `kHasPartialAudioFramesSupport` +Set this to true if your platform supports partial audio frames. + +### Deprecated `SbMutex`, `SbConditionVariable` and `SbThread`. +The standard POSIX `pthread` APIs replace the Starboard concurrency +primitives. + ### Migrate the `SbThreadSampler` to use `pthread`. Switched the `SbThreadSampler` API to use `pthread` instead of `SbThread`. @@ -194,6 +201,10 @@ verified explicitly using nplb tests. An implementation that has specific padding requirement should make a copy of the incoming buffer when necessary. +### Deprecated SbMediaGetBufferStorageType() +The SbMediaGetBufferPadding() API was deprecated. SbMediaBufferStorageType was +also deprecated as a result. + ### Removed SbUser from SbStorageOpenRecord and SbStorageDeleteRecord The `SbStorageOpenRecord` and `SbStorageDeleteRecord` APIs defined in `starboard/storage.h` no longer have a parameter for `SbUser` as the APIs are diff --git a/starboard/android/apk/apk_sources.gni b/starboard/android/apk/apk_sources.gni index 29a454cbfd9f..3ca473a44d89 100644 --- a/starboard/android/apk/apk_sources.gni +++ b/starboard/android/apk/apk_sources.gni @@ -44,9 +44,11 @@ apk_sources = [ "//starboard/android/apk/app/src/main/java/dev/cobalt/media/CobaltMediaSession.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/Log.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridgeBuilder.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecCapabilitiesLogger.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecUtil.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaDrmBridge.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaFormatBuilder.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaImage.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoFrameReleaseTimeHelper.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoSurfaceTexture.java", diff --git a/starboard/android/apk/app/src/app/AndroidManifest.xml b/starboard/android/apk/app/src/app/AndroidManifest.xml index 4c17fd1910a7..5fd31967bc0b 100644 --- a/starboard/android/apk/app/src/app/AndroidManifest.xml +++ b/starboard/android/apk/app/src/app/AndroidManifest.xml @@ -24,7 +24,6 @@ - diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java b/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java index 64b1c545985b..62e9accfc23e 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java @@ -1,8 +1,4 @@ -// Copyright 2013 The Cobalt Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// Modifications Copyright 2017 The Cobalt Authors. All Rights Reserved. +// Copyright 2017 The Cobalt Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. package dev.cobalt.media; @@ -32,7 +32,6 @@ import android.os.Build; import android.os.Bundle; import android.view.Surface; -import androidx.annotation.Nullable; import dev.cobalt.util.Log; import dev.cobalt.util.UsedByNative; import java.nio.ByteBuffer; @@ -446,7 +445,7 @@ private String errorMessage() { } } - private MediaCodecBridge( + public MediaCodecBridge( long nativeMediaCodecBridge, MediaCodec mediaCodec, String mime, @@ -552,61 +551,6 @@ public static boolean isFrameRenderedCallbackEnabled() { return Build.VERSION.SDK_INT >= 34; } - @SuppressWarnings("unused") - @UsedByNative - public static MediaCodecBridge createAudioMediaCodecBridge( - long nativeMediaCodecBridge, - String mime, - String decoderName, - int sampleRate, - int channelCount, - MediaCrypto crypto, - @Nullable byte[] configurationData) { - if (decoderName.equals("")) { - Log.e(TAG, "Invalid decoder name."); - return null; - } - MediaCodec mediaCodec = null; - try { - Log.i(TAG, "Creating \"%s\" decoder.", decoderName); - mediaCodec = MediaCodec.createByCodecName(decoderName); - } catch (Exception e) { - Log.e(TAG, "Failed to create MediaCodec: %s, DecoderName: %s", mime, decoderName, e); - return null; - } - if (mediaCodec == null) { - return null; - } - MediaCodecBridge bridge = - new MediaCodecBridge( - nativeMediaCodecBridge, mediaCodec, mime, BitrateAdjustmentTypes.NO_ADJUSTMENT, -1); - - MediaFormat mediaFormat = createAudioFormat(mime, sampleRate, channelCount); - - if (mime.contains("opus")) { - if (!setOpusConfigurationData(mediaFormat, sampleRate, configurationData)) { - bridge.release(); - return null; - } - } else { - // TODO: Determine if we should explicitly check the mime for AAC audio before calling - // setFrameHasADTSHeader(), as more codecs may be supported here in the future. - setFrameHasADTSHeader(mediaFormat); - } - if (!bridge.configureAudio(mediaFormat, crypto, 0)) { - Log.e(TAG, "Failed to configure audio codec."); - bridge.release(); - return null; - } - if (!bridge.start()) { - Log.e(TAG, "Failed to start audio codec."); - bridge.release(); - return null; - } - - return bridge; - } - @SuppressWarnings("unused") @UsedByNative public static void createVideoMediaCodecBridge( @@ -834,7 +778,7 @@ public void release() { @SuppressWarnings("unused") @UsedByNative - private boolean start() { + public boolean start() { try { mMediaCodec.start(); } catch (IllegalStateException | IllegalArgumentException e) { @@ -895,12 +839,20 @@ private int flush() { return MEDIA_CODEC_OK; } + // It is required to reset mNativeMediaCodecBridge when the native media_codec_bridge object is + // destroyed. @SuppressWarnings("unused") @UsedByNative - private void stop() { + private void resetNativeMediaCodecBridge() { synchronized (this) { mNativeMediaCodecBridge = 0; } + } + + @SuppressWarnings("unused") + @UsedByNative + private void stop() { + resetNativeMediaCodecBridge(); try { mMediaCodec.stop(); } catch (Exception e) { @@ -1130,10 +1082,6 @@ private boolean configureVideo( return false; } - public static MediaFormat createAudioFormat(String mime, int sampleRate, int channelCount) { - return MediaFormat.createAudioFormat(mime, sampleRate, channelCount); - } - private static MediaFormat createVideoDecoderFormat( String mime, int widthHint, int heightHint, VideoCapabilities videoCapabilities) { return MediaFormat.createVideoFormat( @@ -1218,81 +1166,7 @@ private void maybeSetMaxVideoInputSize(MediaFormat format) { @SuppressWarnings("unused") @UsedByNative - private static void setCodecSpecificData(MediaFormat format, int index, byte[] bytes) { - // Codec Specific Data is set in the MediaFormat as ByteBuffer entries with keys csd-0, - // csd-1, and so on. See: http://developer.android.com/reference/android/media/MediaCodec.html - // for details. - String name; - switch (index) { - case 0: - name = "csd-0"; - break; - case 1: - name = "csd-1"; - break; - case 2: - name = "csd-2"; - break; - default: - name = null; - break; - } - if (name != null) { - format.setByteBuffer(name, ByteBuffer.wrap(bytes)); - } - } - - @SuppressWarnings("unused") - private static boolean setOpusConfigurationData( - MediaFormat format, int sampleRate, @Nullable byte[] configurationData) { - final int MIN_OPUS_INITIALIZATION_DATA_BUFFER_SIZE = 19; - final long NANOSECONDS_IN_ONE_SECOND = 1000000000L; - // 3840 is the default seek pre-roll samples used by ExoPlayer: - // https://github.com/google/ExoPlayer/blob/0ba317b1337eaa789f05dd6c5241246478a3d1e5/library/common/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java#L30. - final int DEFAULT_SEEK_PRE_ROLL_SAMPLES = 3840; - if (configurationData == null - || configurationData.length < MIN_OPUS_INITIALIZATION_DATA_BUFFER_SIZE) { - Log.e( - TAG, - "Failed to configure Opus audio codec. " - + (configurationData == null - ? "|configurationData| is null." - : String.format( - Locale.US, - "Configuration data size (%d) is less than the required size (%d).", - configurationData.length, - MIN_OPUS_INITIALIZATION_DATA_BUFFER_SIZE))); - return false; - } - // Both the number of samples to skip from the beginning of the stream and the amount of time - // to pre-roll when seeking must be specified when configuring the Opus decoder. Logic adapted - // from ExoPlayer: - // https://github.com/google/ExoPlayer/blob/0ba317b1337eaa789f05dd6c5241246478a3d1e5/library/common/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java#L52. - int preSkipSamples = ((configurationData[11] & 0xFF) << 8) | (configurationData[10] & 0xFF); - long preSkipNanos = (preSkipSamples * NANOSECONDS_IN_ONE_SECOND) / sampleRate; - long seekPreRollNanos = - (DEFAULT_SEEK_PRE_ROLL_SAMPLES * NANOSECONDS_IN_ONE_SECOND) / sampleRate; - setCodecSpecificData(format, 0, configurationData); - setCodecSpecificData( - format, - 1, - ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(preSkipNanos).array()); - setCodecSpecificData( - format, - 2, - ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(seekPreRollNanos).array()); - return true; - } - - @SuppressWarnings("unused") - @UsedByNative - private static void setFrameHasADTSHeader(MediaFormat format) { - format.setInteger(MediaFormat.KEY_IS_ADTS, 1); - } - - @SuppressWarnings("unused") - @UsedByNative - private boolean configureAudio(MediaFormat format, MediaCrypto crypto, int flags) { + public boolean configureAudio(MediaFormat format, MediaCrypto crypto, int flags) { try { mMediaCodec.configure(format, null, crypto, flags); return true; diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridgeBuilder.java b/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridgeBuilder.java new file mode 100644 index 000000000000..30b6299bfc9b --- /dev/null +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridgeBuilder.java @@ -0,0 +1,94 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2018 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.cobalt.media; + +import static dev.cobalt.media.Log.TAG; + +import android.media.MediaCodec; +import android.media.MediaCrypto; +import android.media.MediaFormat; +import androidx.annotation.Nullable; +import dev.cobalt.util.Log; +import dev.cobalt.util.UsedByNative; + +class MediaCodecBridgeBuilder { + @SuppressWarnings("unused") + @UsedByNative + public static MediaCodecBridge createAudioDecoder( + long nativeMediaCodecBridge, + String mime, + String decoderName, + int sampleRate, + int channelCount, + MediaCrypto crypto, + @Nullable byte[] configurationData) { + if (decoderName.equals("")) { + Log.e(TAG, "Invalid decoder name."); + return null; + } + MediaCodec mediaCodec = null; + try { + Log.i(TAG, "Creating \"%s\" decoder.", decoderName); + mediaCodec = MediaCodec.createByCodecName(decoderName); + } catch (Exception e) { + Log.e(TAG, "Failed to create MediaCodec: %s, DecoderName: %s", mime, decoderName, e); + return null; + } + if (mediaCodec == null) { + return null; + } + MediaCodecBridge bridge = + new MediaCodecBridge( + nativeMediaCodecBridge, + mediaCodec, + mime, + MediaCodecBridge.BitrateAdjustmentTypes.NO_ADJUSTMENT, + -1); + + byte[][] csds = {}; + boolean frameHasAdtsHeader = false; + if (mime.contains("opus")) { + csds = MediaFormatBuilder.starboardParseOpusConfigurationData(sampleRate, configurationData); + if (csds == null) { + bridge.release(); + return null; + } + } else { + // TODO: Determine if we should explicitly check the mime for AAC audio before setting + // frameHasAdtsHeader to true, as more codecs may be supported here in the future. + frameHasAdtsHeader = true; + } + MediaFormat mediaFormat = + MediaFormatBuilder.createAudioFormat( + mime, sampleRate, channelCount, csds, frameHasAdtsHeader); + + if (!bridge.configureAudio(mediaFormat, crypto, 0)) { + Log.e(TAG, "Failed to configure audio codec."); + bridge.release(); + return null; + } + if (!bridge.start()) { + Log.e(TAG, "Failed to start audio codec."); + bridge.release(); + return null; + } + + return bridge; + } +} diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaFormatBuilder.java b/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaFormatBuilder.java new file mode 100644 index 000000000000..cde6506065cb --- /dev/null +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaFormatBuilder.java @@ -0,0 +1,87 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2018 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package dev.cobalt.media; + +import static dev.cobalt.media.Log.TAG; + +import android.media.MediaFormat; +import androidx.annotation.Nullable; +import dev.cobalt.util.Log; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Locale; + +class MediaFormatBuilder { + public static void setCodecSpecificData(MediaFormat format, byte[][] csds) { + // Codec Specific Data is set in the MediaFormat as ByteBuffer entries with keys csd-0, + // csd-1, and so on. See: + // http://developer.android.com/reference/android/media/MediaCodec.html for details. + for (int i = 0; i < csds.length; ++i) { + if (csds[i].length == 0) continue; + String name = "csd-" + i; + format.setByteBuffer(name, ByteBuffer.wrap(csds[i])); + } + } + + public static MediaFormat createAudioFormat( + String mime, int sampleRate, int channelCount, byte[][] csds, boolean frameHasAdtsHeader) { + MediaFormat format = MediaFormat.createAudioFormat(mime, sampleRate, channelCount); + setCodecSpecificData(format, csds); + if (frameHasAdtsHeader) { + format.setInteger(MediaFormat.KEY_IS_ADTS, 1); + } + return format; + } + + public static byte[][] starboardParseOpusConfigurationData( + int sampleRate, @Nullable byte[] configurationData) { + final int MIN_OPUS_INITIALIZATION_DATA_BUFFER_SIZE = 19; + final long NANOSECONDS_IN_ONE_SECOND = 1000000000L; + // 3840 is the default seek pre-roll samples used by ExoPlayer: + // https://github.com/google/ExoPlayer/blob/0ba317b1337eaa789f05dd6c5241246478a3d1e5/library/common/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java#L30. + final int DEFAULT_SEEK_PRE_ROLL_SAMPLES = 3840; + if (configurationData == null + || configurationData.length < MIN_OPUS_INITIALIZATION_DATA_BUFFER_SIZE) { + Log.e( + TAG, + "Failed to configure Opus audio codec. " + + (configurationData == null + ? "|configurationData| is null." + : String.format( + Locale.US, + "Configuration data size (%d) is less than the required size (%d).", + configurationData.length, + MIN_OPUS_INITIALIZATION_DATA_BUFFER_SIZE))); + return null; + } + // Both the number of samples to skip from the beginning of the stream and the amount of time + // to pre-roll when seeking must be specified when configuring the Opus decoder. Logic adapted + // from ExoPlayer: + // https://github.com/google/ExoPlayer/blob/0ba317b1337eaa789f05dd6c5241246478a3d1e5/library/common/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java#L52. + int preSkipSamples = ((configurationData[11] & 0xFF) << 8) | (configurationData[10] & 0xFF); + long preSkipNanos = (preSkipSamples * NANOSECONDS_IN_ONE_SECOND) / sampleRate; + long seekPreRollNanos = + (DEFAULT_SEEK_PRE_ROLL_SAMPLES * NANOSECONDS_IN_ONE_SECOND) / sampleRate; + return new byte[][] { + configurationData, + ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(preSkipNanos).array(), + ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(seekPreRollNanos).array(), + }; + } +} diff --git a/starboard/android/arm/cobalt/configuration.py b/starboard/android/arm/cobalt/configuration.py index 579c23f83153..ba3f29386189 100644 --- a/starboard/android/arm/cobalt/configuration.py +++ b/starboard/android/arm/cobalt/configuration.py @@ -27,15 +27,6 @@ 'suspend_visibility', 'timer_hit_after_preload', 'timer_hit_in_preload', - 'service_worker_add_to_cache_test', - 'service_worker_cache_keys_test', - 'service_worker_controller_activation_test', - 'service_worker_get_registrations_test', - 'service_worker_fetch_main_resource_test', - 'service_worker_fetch_test', - 'service_worker_message_test', - 'service_worker_post_message_test', - 'service_worker_test', 'service_worker_persist_test', 'deep_links', 'web_platform_tests', diff --git a/starboard/android/shared/BUILD.gn b/starboard/android/shared/BUILD.gn index afff0c04ea48..39faadf9beba 100644 --- a/starboard/android/shared/BUILD.gn +++ b/starboard/android/shared/BUILD.gn @@ -77,6 +77,7 @@ static_library("starboard_platform") { "//starboard/shared/libevent/socket_waiter_wake_up.cc", "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", + "//starboard/shared/linux/memory_get_stack_bounds.cc", "//starboard/shared/linux/system_get_random_data.cc", "//starboard/shared/linux/system_get_total_cpu_memory.cc", "//starboard/shared/linux/system_get_used_cpu_memory.cc", @@ -279,6 +280,8 @@ static_library("starboard_platform") { "android_media_session_client.cc", "application_android.cc", "application_android.h", + "asset_manager.cc", + "asset_manager.h", "atomic_public.h", "audio_decoder.cc", "audio_decoder.h", @@ -352,6 +355,8 @@ static_library("starboard_platform") { "media_capabilities_cache.h", "media_codec_bridge.cc", "media_codec_bridge.h", + "media_codec_bridge_eradicator.cc", + "media_codec_bridge_eradicator.h", "media_common.h", "media_decoder.cc", "media_decoder.h", @@ -364,6 +369,8 @@ static_library("starboard_platform") { "media_is_buffer_pool_allocate_on_demand.cc", "media_is_supported.cc", "media_is_video_supported.cc", + "media_settings_api.cc", + "media_settings_api.h", "microphone_impl.cc", "network_status_impl.cc", "platform_info.cc", @@ -378,6 +385,8 @@ static_library("starboard_platform") { "player_set_max_video_input_size.cc", "player_set_max_video_input_size.h", "player_set_playback_rate.cc", + "posix_emu/errno.cc", + "posix_emu/file.cc", "posix_emu/pthread.cc", "posix_emu/stat.cc", "sanitizer_options.cc", diff --git a/starboard/android/shared/asset_manager.cc b/starboard/android/shared/asset_manager.cc new file mode 100644 index 000000000000..a386544390db --- /dev/null +++ b/starboard/android/shared/asset_manager.cc @@ -0,0 +1,138 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "starboard/android/shared/asset_manager.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "starboard/android/shared/file_internal.h" +#include "starboard/common/log.h" +#include "starboard/common/mutex.h" +#include "starboard/common/once.h" +#include "starboard/common/string.h" +#include "starboard/system.h" + +namespace starboard { +namespace android { +namespace shared { + +// static +SB_ONCE_INITIALIZE_FUNCTION(AssetManager, AssetManager::GetInstance); + +AssetManager::AssetManager() { + const int kPathSize = PATH_MAX / 2; + char path[kPathSize] = {0}; + SB_CHECK(SbSystemGetPath(kSbSystemPathTempDirectory, path, kPathSize)) + << "Unable to get system temp path for AssetManager."; + SB_CHECK(starboard::strlcat(path, "/asset_tmp", kPathSize) < kPathSize) + << "Unable to construct temp path for AssetManager."; + tmp_root_ = path; + ClearTempDir(); +} + +uint64_t AssetManager::AcquireInternalFd() { + ScopedLock scoped_lock(mutex_); + do { + ++internal_fd_; + } while (in_use_internal_fd_set_.count(internal_fd_) == 1); + in_use_internal_fd_set_.insert(internal_fd_); + return internal_fd_; +} + +std::string AssetManager::TempFilepath(uint64_t internal_fd) const { + return tmp_root_ + "/" + std::to_string(internal_fd); +} + +int AssetManager::Open(const char* path) { + if (!path) { + return -1; + } + + AAsset* asset = OpenAndroidAsset(path); + if (!asset) { + SB_LOG(WARNING) << "Asset path not found within package: " << path; + return -1; + } + + // Create temporary POSIX file for the asset + uint64_t internal_fd = AcquireInternalFd(); + std::string filepath = TempFilepath(internal_fd); + int fd = open(filepath.c_str(), O_RDWR | O_TRUNC | O_CREAT); + if (fd < 0) { + mutex_.Acquire(); + in_use_internal_fd_set_.erase(internal_fd); + mutex_.Release(); + return -1; + } + + // Copy contents of asset into temporary file and then seek to start of file. + const off_t size = AAsset_getLength(asset); + const void* const data = AAsset_getBuffer(asset); + if (write(fd, data, size) != size || lseek(fd, 0, SEEK_SET) != 0) { + SB_LOG(WARNING) << "Failed to write temporary file for asset: " << path; + mutex_.Acquire(); + in_use_internal_fd_set_.erase(internal_fd); + mutex_.Release(); // Can't hold lock when calling close(); + close(fd); + return -1; + } + AAsset_close(asset); + + // Keep track of the internal fd so we can delete its file on close(); + mutex_.Acquire(); + fd_to_internal_fd_map_[fd] = internal_fd; + mutex_.Release(); + return fd; +} + +bool AssetManager::IsAssetFd(int fd) const { + ScopedLock scoped_lock(mutex_); + return fd_to_internal_fd_map_.count(fd) == 1; +} + +int AssetManager::Close(int fd) { + mutex_.Acquire(); + if (auto search = fd_to_internal_fd_map_.find(fd); + search != fd_to_internal_fd_map_.end()) { + uint64_t internal_fd = search->second; + fd_to_internal_fd_map_.erase(search); + in_use_internal_fd_set_.erase(internal_fd); + mutex_.Release(); // Can't hold lock when calling close(); + int retval = close(fd); + std::string filepath = TempFilepath(internal_fd); + if (unlink(filepath.c_str()) != 0) { + SB_LOG(WARNING) << "Failed to delete temporary file: " << filepath; + } + return retval; + } + mutex_.Release(); + return -1; +} + +void AssetManager::ClearTempDir() { + auto callback = [](const char* child, const struct stat*, int file_type, + struct FTW*) -> int { return remove(child); }; + nftw(tmp_root_.c_str(), callback, 32, FTW_DEPTH | FTW_PHYS); + mkdir(tmp_root_.c_str(), 0700); +} + +} // namespace shared +} // namespace android +} // namespace starboard diff --git a/starboard/android/shared/asset_manager.h b/starboard/android/shared/asset_manager.h new file mode 100644 index 000000000000..10f1a8b5d526 --- /dev/null +++ b/starboard/android/shared/asset_manager.h @@ -0,0 +1,54 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_ANDROID_SHARED_ASSET_MANAGER_H_ +#define STARBOARD_ANDROID_SHARED_ASSET_MANAGER_H_ + +#include +#include +#include + +#include "starboard/common/mutex.h" + +namespace starboard { +namespace android { +namespace shared { + +// This class handles opening/closing Android asset files as POSIX filehandles. +class AssetManager { + public: + static AssetManager* GetInstance(); + int Open(const char* path); + int Close(int fd); + bool IsAssetFd(int fd) const; + + private: + AssetManager(); + ~AssetManager() { ClearTempDir(); } + uint64_t AcquireInternalFd(); + std::string TempFilepath(uint64_t internal_fd) const; + void ClearTempDir(); + + std::string tmp_root_; + mutable Mutex mutex_; + uint64_t internal_fd_ = 0; // Guarded by |mutex_|. + std::set in_use_internal_fd_set_; // Guarded by |mutex_|. + std::map fd_to_internal_fd_map_; // Guarded by |mutex_|. +}; + +} // namespace shared +} // namespace android +} // namespace starboard + +#endif // STARBOARD_ANDROID_SHARED_ASSET_MANAGER_H_ diff --git a/starboard/android/shared/configuration_constants.cc b/starboard/android/shared/configuration_constants.cc index 357c4a495645..0691cff41d12 100644 --- a/starboard/android/shared/configuration_constants.cc +++ b/starboard/android/shared/configuration_constants.cc @@ -142,4 +142,7 @@ const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB // Whether this platform can map executable memory. This is required for // platforms that want to JIT. SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; #endif diff --git a/starboard/android/shared/media_codec_bridge.cc b/starboard/android/shared/media_codec_bridge.cc index 67eea4df6018..cf7791672489 100644 --- a/starboard/android/shared/media_codec_bridge.cc +++ b/starboard/android/shared/media_codec_bridge.cc @@ -15,6 +15,7 @@ #include "starboard/android/shared/media_codec_bridge.h" #include "starboard/android/shared/media_capabilities_cache.h" +#include "starboard/android/shared/media_codec_bridge_eradicator.h" #include "starboard/common/string.h" namespace starboard { @@ -177,6 +178,11 @@ scoped_ptr MediaCodecBridge::CreateAudioMediaCodecBridge( return scoped_ptr(NULL); } + if (MediaCodecBridgeEradicator::GetInstance()->IsEnabled()) { + // block if the old MediaCodecBridge instances haven't been destroyed yet + MediaCodecBridgeEradicator::GetInstance()->WaitForPendingDestructions(); + } + JniEnvExt* env = JniEnvExt::Get(); ScopedLocalJavaRef configuration_data; if (audio_stream_info.codec == kSbMediaAudioCodecOpus && @@ -192,7 +198,7 @@ scoped_ptr MediaCodecBridge::CreateAudioMediaCodecBridge( scoped_ptr native_media_codec_bridge( new MediaCodecBridge(handler)); jobject j_media_codec_bridge = env->CallStaticObjectMethodOrAbort( - "dev/cobalt/media/MediaCodecBridge", "createAudioMediaCodecBridge", + "dev/cobalt/media/MediaCodecBridgeBuilder", "createAudioDecoder", "(JLjava/lang/String;Ljava/lang/String;IILandroid/media/MediaCrypto;" "[B)Ldev/cobalt/media/MediaCodecBridge;", reinterpret_cast(native_media_codec_bridge.get()), j_mime.Get(), @@ -271,6 +277,11 @@ scoped_ptr MediaCodecBridge::CreateVideoMediaCodecBridge( return scoped_ptr(NULL); } + if (MediaCodecBridgeEradicator::GetInstance()->IsEnabled()) { + // block if the old MediaCodecBridge instances haven't been destroyed yet + MediaCodecBridgeEradicator::GetInstance()->WaitForPendingDestructions(); + } + JniEnvExt* env = JniEnvExt::Get(); ScopedLocalJavaRef j_mime(env->NewStringStandardUTFOrAbort(mime)); ScopedLocalJavaRef j_decoder_name( @@ -348,6 +359,15 @@ MediaCodecBridge::~MediaCodecBridge() { return; } + if (MediaCodecBridgeEradicator::GetInstance()->IsEnabled()) { + if (MediaCodecBridgeEradicator::GetInstance()->Destroy( + j_media_codec_bridge_, j_reused_get_output_format_result_)) { + return; + } + SB_LOG(WARNING) + << "MediaCodecBridge destructor fallback into none eradicator mode."; + } + JniEnvExt* env = JniEnvExt::Get(); env->CallVoidMethodOrAbort(j_media_codec_bridge_, "stop", "()V"); diff --git a/starboard/android/shared/media_codec_bridge_eradicator.cc b/starboard/android/shared/media_codec_bridge_eradicator.cc new file mode 100644 index 000000000000..912279eada3c --- /dev/null +++ b/starboard/android/shared/media_codec_bridge_eradicator.cc @@ -0,0 +1,131 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "starboard/android/shared/media_codec_bridge_eradicator.h" + +#include + +#include "starboard/android/shared/jni_utils.h" +#include "starboard/common/log.h" +#include "starboard/common/once.h" + +namespace starboard { +namespace android { +namespace shared { + +SB_ONCE_INITIALIZE_FUNCTION(MediaCodecBridgeEradicator, + MediaCodecBridgeEradicator::GetInstance); + +namespace { + +struct EradicateParam { + EradicateParam(MediaCodecBridgeEradicator* eradicator, + jobject j_media_codec_bridge, + jobject j_reused_get_output_format_result) + : eradicator(eradicator), + j_media_codec_bridge(j_media_codec_bridge), + j_reused_get_output_format_result(j_reused_get_output_format_result) {} + + MediaCodecBridgeEradicator* eradicator; + jobject j_media_codec_bridge; + jobject j_reused_get_output_format_result; +}; + +} // namespace + +void MediaCodecBridgeEradicator::WaitForPendingDestructions() { + ScopedLock scoped_lock(mutex_); + while (!j_media_codec_bridge_set_.empty()) { + condition_variable_.Wait(); + } +} + +bool MediaCodecBridgeEradicator::Destroy( + jobject j_media_codec_bridge, + jobject j_reused_get_output_format_result) { + // Since the native media_codec_bridge object is about to be destroyed, remove + // its reference from the Java MediaCodecBridge object to prevent further + // access. Otherwise it could lead to an application crash. + // The de-reference has to happen before the java MediaCodecBridge object is + // destroyed. + JniEnvExt* env = JniEnvExt::Get(); + env->CallVoidMethodOrAbort(j_media_codec_bridge, + "resetNativeMediaCodecBridge", "()V"); + + { + // add the j_media_codec_bridge to the set before the work is started + ScopedLock scoped_lock(mutex_); + j_media_codec_bridge_set_.insert(j_media_codec_bridge); + } + + EradicateParam* param = new EradicateParam(this, j_media_codec_bridge, + j_reused_get_output_format_result); + pthread_t thread_id; + int result = pthread_create( + &thread_id, nullptr, &MediaCodecBridgeEradicator::DestroyMediaCodecBridge, + param); + + if (result == 0) { + pthread_detach(thread_id); + } else { + // If it fails to create the thread + delete param; + + ScopedLock scoped_lock(mutex_); + j_media_codec_bridge_set_.erase(j_media_codec_bridge); + if (j_media_codec_bridge_set_.empty()) { + condition_variable_.Signal(); + } + } + + return result == 0; +} + +void* MediaCodecBridgeEradicator::DestroyMediaCodecBridge(void* context) { + EradicateParam* param = static_cast(context); + SB_DCHECK(param != nullptr); + + MediaCodecBridgeEradicator* eradicator = param->eradicator; + jobject j_media_codec_bridge = param->j_media_codec_bridge; + jobject j_reused_get_output_format_result = + param->j_reused_get_output_format_result; + + delete param; + param = NULL; + + JniEnvExt* env = JniEnvExt::Get(); + + env->CallVoidMethodOrAbort(j_media_codec_bridge, "stop", "()V"); + env->CallVoidMethodOrAbort(j_media_codec_bridge, "release", "()V"); + env->DeleteGlobalRef(j_media_codec_bridge); + + SB_DCHECK(j_reused_get_output_format_result); + env->DeleteGlobalRef(j_reused_get_output_format_result); + + { + // the work is finished, delete the j_media_codec_bridge from the set + ScopedLock scoped_lock(eradicator->mutex_); + eradicator->j_media_codec_bridge_set_.erase(j_media_codec_bridge); + + if (eradicator->j_media_codec_bridge_set_.empty()) { + eradicator->condition_variable_.Signal(); + } + } + + return NULL; +} + +} // namespace shared +} // namespace android +} // namespace starboard diff --git a/starboard/android/shared/media_codec_bridge_eradicator.h b/starboard/android/shared/media_codec_bridge_eradicator.h new file mode 100644 index 000000000000..903601e7fa65 --- /dev/null +++ b/starboard/android/shared/media_codec_bridge_eradicator.h @@ -0,0 +1,60 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_ANDROID_SHARED_MEDIA_CODEC_BRIDGE_ERADICATOR_H_ +#define STARBOARD_ANDROID_SHARED_MEDIA_CODEC_BRIDGE_ERADICATOR_H_ + +#include +#include + +#include "starboard/android/shared/jni_env_ext.h" +#include "starboard/common/atomic.h" +#include "starboard/common/condition_variable.h" +#include "starboard/common/mutex.h" + +namespace starboard { +namespace android { +namespace shared { + +/** + * This class is a singleton utility that runs the MediaCodecBridge destructor + * on a separate thread to prevent Application Not Responding (ANR) errors in + * Android. + */ +class MediaCodecBridgeEradicator { + public: + static MediaCodecBridgeEradicator* GetInstance(); + + ~MediaCodecBridgeEradicator() { WaitForPendingDestructions(); } + + bool Destroy(jobject j_media_codec_bridge, + jobject j_reused_get_output_format_result); + void WaitForPendingDestructions(); + bool IsEnabled() const { return is_enabled_.load(); } + void SetEnabled(bool enabled) { is_enabled_.store(enabled); } + + private: + static void* DestroyMediaCodecBridge(void* context); + + atomic_bool is_enabled_; // false by default + Mutex mutex_; + ConditionVariable condition_variable_{mutex_}; + std::set j_media_codec_bridge_set_; +}; + +} // namespace shared +} // namespace android +} // namespace starboard + +#endif // STARBOARD_ANDROID_SHARED_MEDIA_CODEC_BRIDGE_ERADICATOR_H_ diff --git a/starboard/android/shared/media_settings_api.cc b/starboard/android/shared/media_settings_api.cc new file mode 100644 index 000000000000..7dd086899d8e --- /dev/null +++ b/starboard/android/shared/media_settings_api.cc @@ -0,0 +1,46 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "starboard/android/shared/media_settings_api.h" +#include "starboard/android/shared/media_codec_bridge_eradicator.h" +#include "starboard/extension/media_settings.h" + +namespace starboard { +namespace android { +namespace shared { + +namespace { + +// Definitions of any functions included as components in the extension +// are added here. + +void EnableAsyncReleaseMediaCodecBridge(bool value) { + MediaCodecBridgeEradicator::GetInstance()->SetEnabled(value); +} + +const StarboardExtensionMediaSettingsApi kMediaSettingsApi = { + kStarboardExtensionMediaSettingsName, + 1, // API version that's implemented. + &EnableAsyncReleaseMediaCodecBridge, +}; + +} // namespace + +const void* GetMediaSettingsApi() { + return &kMediaSettingsApi; +} + +} // namespace shared +} // namespace android +} // namespace starboard diff --git a/starboard/android/shared/media_settings_api.h b/starboard/android/shared/media_settings_api.h new file mode 100644 index 000000000000..388ec96d0725 --- /dev/null +++ b/starboard/android/shared/media_settings_api.h @@ -0,0 +1,28 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_ANDROID_SHARED_MEDIA_SETTINGS_API_H_ +#define STARBOARD_ANDROID_SHARED_MEDIA_SETTINGS_API_H_ + +namespace starboard { +namespace android { +namespace shared { + +const void* GetMediaSettingsApi(); + +} // namespace shared +} // namespace android +} // namespace starboard + +#endif // STARBOARD_ANDROID_SHARED_MEDIA_SETTINGS_API_H_ diff --git a/starboard/android/shared/platform_configuration/BUILD.gn b/starboard/android/shared/platform_configuration/BUILD.gn index ccc6d13dd913..9c7bc708fb56 100644 --- a/starboard/android/shared/platform_configuration/BUILD.gn +++ b/starboard/android/shared/platform_configuration/BUILD.gn @@ -21,7 +21,7 @@ config("platform_configuration") { defines = [] include_dirs = [ - # POSIX emulation headers + # POSIX emulation headers - these need to come *before* system include_dirs. "//starboard/android/shared/posix_emu/include", ] @@ -169,7 +169,11 @@ config("platform_configuration") { "-Wl,--wrap=eglSwapBuffers", ] if (!is_native_target_build) { - ldflags += [ "-Wl,--wrap=stat" ] + ldflags += [ + "-Wl,--wrap=close", + "-Wl,--wrap=open", + "-Wl,--wrap=stat", + ] } } diff --git a/starboard/android/shared/player_components_factory.h b/starboard/android/shared/player_components_factory.h index 0b38256bc0b8..536b404c67ea 100644 --- a/starboard/android/shared/player_components_factory.h +++ b/starboard/android/shared/player_components_factory.h @@ -75,6 +75,11 @@ constexpr bool kForceResetSurfaceUnderTunnelMode = true; // during Seek(). constexpr bool kForceFlushDecoderDuringReset = false; +// By default, Cobalt teardowns AudioDecoder during Reset(). +// Set the following variable to true to force it reset audio decoder +// during Reset(). This should be enabled with kForceFlushDecoderDuringReset. +constexpr bool kForceResetAudioDecoder = false; + // This class allows us to force int16 sample type when tunnel mode is enabled. class AudioRendererSinkAndroid : public ::starboard::shared::starboard::player:: filter::AudioRendererSinkImpl { @@ -381,6 +386,22 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player:: << tunnel_mode_audio_session_id << '.'; } + bool enable_reset_audio_decoder = + video_mime_type.GetParamBoolValue("enableresetaudiodecoder", false); + SB_LOG(INFO) << "Reset AudioDecoder during Reset(): " + << (enable_reset_audio_decoder ? "enabled. " : "disabled. ") + << "Video mime parameter \"enableresetaudiodecoder\" value: " + << video_mime_type.GetParamStringValue( + "enableresetaudiodecoder", "") + << "."; + + if (kForceResetAudioDecoder && !enable_reset_audio_decoder) { + SB_LOG(INFO) + << "`kForceResetAudioDecoder` is set to true, force resetting" + << " audio decoder during Reset()."; + enable_reset_audio_decoder = true; + } + bool enable_flush_during_seek = video_mime_type.GetParamBoolValue("enableflushduringseek", false); SB_LOG(INFO) << "Flush MediaCodec during Reset(): " @@ -430,7 +451,8 @@ class PlayerComponentsFactory : public starboard::shared::starboard::player:: audio_decoder->reset(new AdaptiveAudioDecoder( creation_parameters.audio_stream_info(), - creation_parameters.drm_system(), decoder_creator)); + creation_parameters.drm_system(), decoder_creator, + enable_reset_audio_decoder)); if (tunnel_mode_audio_session_id != -1) { *audio_renderer_sink = TryToCreateTunnelModeAudioRendererSink( diff --git a/starboard/android/shared/posix_emu/errno.cc b/starboard/android/shared/posix_emu/errno.cc new file mode 100644 index 000000000000..b01df5634791 --- /dev/null +++ b/starboard/android/shared/posix_emu/errno.cc @@ -0,0 +1,19 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +int* __errno_location(void) { + return __errno(); +} diff --git a/starboard/android/shared/posix_emu/file.cc b/starboard/android/shared/posix_emu/file.cc new file mode 100644 index 000000000000..d18ebefb3997 --- /dev/null +++ b/starboard/android/shared/posix_emu/file.cc @@ -0,0 +1,61 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include + +#include "starboard/android/shared/asset_manager.h" +#include "starboard/android/shared/file_internal.h" +#include "starboard/common/log.h" +#include "starboard/configuration_constants.h" +#include "starboard/directory.h" +#include "starboard/log.h" + +using starboard::android::shared::AssetManager; +using starboard::android::shared::IsAndroidAssetPath; +using starboard::android::shared::OpenAndroidAsset; + +// /////////////////////////////////////////////////////////////////////////////// +// // Implementations below exposed externally in pure C for emulation. +// /////////////////////////////////////////////////////////////////////////////// + +extern "C" { +int __real_close(int fildes); +int __real_open(const char* path, int oflag, ...); + +int __wrap_close(int fildes) { + AssetManager* asset_manager = AssetManager::GetInstance(); + if (asset_manager->IsAssetFd(fildes)) { + return asset_manager->Close(fildes); + } + return __real_close(fildes); +} + +int __wrap_open(const char* path, int oflag, ...) { + if (!IsAndroidAssetPath(path)) { + va_list args; + va_start(args, oflag); + int fd; + if (oflag & O_CREAT) { + mode_t mode = va_arg(args, int); + return __real_open(path, oflag, mode); + } else { + return __real_open(path, oflag); + } + } + return AssetManager::GetInstance()->Open(path); +} + +} // extern "C" diff --git a/starboard/android/shared/posix_emu/include/errno.h b/starboard/android/shared/posix_emu/include/errno.h new file mode 100644 index 000000000000..e091be6e382b --- /dev/null +++ b/starboard/android/shared/posix_emu/include/errno.h @@ -0,0 +1,31 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_ANDROID_SHARED_POSIX_EMU_INCLUDE_ERRNO_H_ +#define STARBOARD_ANDROID_SHARED_POSIX_EMU_INCLUDE_ERRNO_H_ + +#include_next // The AndroidSdk version of the same file. + +#ifdef __cplusplus +extern "C" { +#endif + +// __errno_location not available in Android NDK. +int* __errno_location(void); + +#ifdef __cplusplus +} +#endif + +#endif // STARBOARD_ANDROID_SHARED_POSIX_EMU_INCLUDE_ERRNO_H_ diff --git a/starboard/android/shared/test_filters.py b/starboard/android/shared/test_filters.py index 3d30f3deac2e..7c90f5484614 100644 --- a/starboard/android/shared/test_filters.py +++ b/starboard/android/shared/test_filters.py @@ -65,12 +65,6 @@ 'PosixDirectoryOpenTest.SunnyDayStaticContent', 'PosixFileGetPathInfoTest.WorksOnStaticContentDirectories', - # These POSIX tests should be disabled until asset manager starboard - # extension is implemented. - 'PosixFileGetInfoTest.WorksOnStaticContentFiles', - 'PosixFileReadTest/*.ReadStaticContent', - 'PosixFileSeekTest.FromEndInStaticContentWorks', - # These tests are disabled due to not receiving the kEndOfStream # player state update within the specified timeout. 'SbPlayerGetAudioConfigurationTests/SbPlayerGetAudioConfigurationTest.NoInput/*', diff --git a/starboard/android/shared/thread_create.cc b/starboard/android/shared/thread_create.cc index d760a611d367..35fb27f2e6d6 100644 --- a/starboard/android/shared/thread_create.cc +++ b/starboard/android/shared/thread_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include @@ -146,3 +148,4 @@ SbThread SbThreadCreate(int64_t stack_size, return kSbThreadInvalid; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/build/config/BUILDCONFIG.gn b/starboard/build/config/BUILDCONFIG.gn index 5fab7ac771c9..cc7eaab0d2b8 100644 --- a/starboard/build/config/BUILDCONFIG.gn +++ b/starboard/build/config/BUILDCONFIG.gn @@ -354,7 +354,6 @@ template("evergreen_loader") { # Add additional evergreen_loader target for every native target. original_target_name = invoker.original_target_name shared_data_deps = invoker.data_deps - shared_data_deps += [ "//third_party/icu:icudata" ] shared_data_deps += [ ":copy_loader_app_lib${original_target_name}", "//starboard/loader_app:copy_loader_app_content", @@ -628,7 +627,10 @@ template("shared_library") { not_needed([ "installable_target_dep" ]) type = "shared_library" - deps = [] + # When we build "{target_name}_install", we expect all files + # needed for a working target to be present. + deps = [ ":${actual_target_name}" ] + if (defined(invoker.deps)) { deps += invoker.deps } diff --git a/starboard/build/config/modular/arm/hardfp/BUILD.gn b/starboard/build/config/modular/arm/hardfp/BUILD.gn index f1f365ab108d..dc4e8b75bdcd 100644 --- a/starboard/build/config/modular/arm/hardfp/BUILD.gn +++ b/starboard/build/config/modular/arm/hardfp/BUILD.gn @@ -18,6 +18,7 @@ config("sabi_flags") { "-target", "armv7a-none-eabihf", ] + asmflags = cflags } config("hardfp") { diff --git a/starboard/build/config/win/BUILD.gn b/starboard/build/config/win/BUILD.gn index f5bc41bbabaa..759cafc3e791 100644 --- a/starboard/build/config/win/BUILD.gn +++ b/starboard/build/config/win/BUILD.gn @@ -227,6 +227,9 @@ config("common") { # but it's a universally acceptable price for better performance. "/wd4820", + # warning C4828: character 'ü' in net/dns/dns_names_util_unittest.cc + "/wd4828", + # Disable static analyzer warning for std::min and std::max with # objects. # https://connect.microsoft.com/VisualStudio/feedback/details/783808/static-analyzer-warning-c28285-for-std-min-and-std-max diff --git a/starboard/build/install/install_target.gni b/starboard/build/install/install_target.gni index 1d29e0674ed4..bc08211a8d1f 100644 --- a/starboard/build/install/install_target.gni +++ b/starboard/build/install/install_target.gni @@ -40,9 +40,6 @@ template("install_target") { copy("copy_" + target_name) { forward_variables_from(invoker, [ "testonly" ]) - # deps = [] - # not_needed(invoker, [ "deps" ]) - deps = invoker.deps deps += [ installable_target_dep ] sources = [ "$root_out_dir/$source_name" ] diff --git a/starboard/client_porting/eztime/BUILD.gn b/starboard/client_porting/eztime/BUILD.gn index 068980e7e4a0..5840b29ce981 100644 --- a/starboard/client_porting/eztime/BUILD.gn +++ b/starboard/client_porting/eztime/BUILD.gn @@ -42,8 +42,5 @@ target(gtest_target_type, "eztime_test") { "//testing/gtest", ] - data_deps = [ - # "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", - ] + data_deps = [ "//cobalt/network:copy_ssl_certificates" ] } diff --git a/starboard/common/BUILD.gn b/starboard/common/BUILD.gn index b46e127e8ea7..849e1309f83f 100644 --- a/starboard/common/BUILD.gn +++ b/starboard/common/BUILD.gn @@ -69,6 +69,8 @@ static_library("common") { "player.cc", "player.h", "pointer_arithmetic.h", + "process.cc", + "process.h", "queue.h", "recursive_mutex.cc", "recursive_mutex.h", diff --git a/starboard/common/log.cc b/starboard/common/log.cc index 9da18ec9d400..ca5a978c683a 100644 --- a/starboard/common/log.cc +++ b/starboard/common/log.cc @@ -171,7 +171,7 @@ void LogMessage::Init(const char* file, int line) { char name[128] = {0}; pthread_getname_np(pthread_self(), name, SB_ARRAY_SIZE_INT(name)); stream_ << '['; - stream_ << name << '/' << pthread_self() << ':'; + stream_ << name << '/' << SbThreadGetId() << ':'; struct timeval tv; gettimeofday(&tv, NULL); struct tm tm_time = {0}; diff --git a/starboard/common/process.cc b/starboard/common/process.cc new file mode 100644 index 000000000000..455a4f525dfa --- /dev/null +++ b/starboard/common/process.cc @@ -0,0 +1,21 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "starboard/common/process.h" + +namespace starboard { + +int kStarboardFakeProcessId = 1; + +} // namespace starboard diff --git a/starboard/common/process.h b/starboard/common/process.h new file mode 100644 index 000000000000..31824613fec3 --- /dev/null +++ b/starboard/common/process.h @@ -0,0 +1,26 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Cobalt is single-process, so we use a single process id value. + +#ifndef STARBOARD_COMMON_PROCESS_H_ +#define STARBOARD_COMMON_PROCESS_H_ + +namespace starboard { + +extern int kStarboardFakeProcessId; + +} // namespace starboard + +#endif // STARBOARD_COMMON_PROCESS_H_ diff --git a/starboard/common/recursive_mutex.cc b/starboard/common/recursive_mutex.cc index d77457526601..7b44bd0d42eb 100644 --- a/starboard/common/recursive_mutex.cc +++ b/starboard/common/recursive_mutex.cc @@ -17,13 +17,14 @@ namespace starboard { -RecursiveMutex::RecursiveMutex() : owner_id_(0), recurse_count_(0) {} +RecursiveMutex::RecursiveMutex() + : owner_id_(kSbThreadInvalidId), recurse_count_(0) {} RecursiveMutex::~RecursiveMutex() {} void RecursiveMutex::Acquire() { - pthread_t current_thread = pthread_self(); - if (pthread_equal(owner_id_, current_thread)) { + SbThreadId current_thread = SbThreadGetId(); + if (owner_id_ == current_thread) { recurse_count_++; SB_DCHECK(recurse_count_ > 0); return; @@ -34,20 +35,20 @@ void RecursiveMutex::Acquire() { } void RecursiveMutex::Release() { - SB_DCHECK(pthread_equal(owner_id_, pthread_self())); - if (pthread_equal(owner_id_, pthread_self())) { + SB_DCHECK(owner_id_ == SbThreadGetId()); + if (owner_id_ == SbThreadGetId()) { SB_DCHECK(0 < recurse_count_); recurse_count_--; if (recurse_count_ == 0) { - owner_id_ = 0; + owner_id_ = kSbThreadInvalidId; mutex_.Release(); } } } bool RecursiveMutex::AcquireTry() { - pthread_t current_thread = pthread_self(); - if (pthread_equal(owner_id_, current_thread)) { + SbThreadId current_thread = SbThreadGetId(); + if (owner_id_ == current_thread) { recurse_count_++; SB_DCHECK(recurse_count_ > 0); return true; diff --git a/starboard/common/recursive_mutex.h b/starboard/common/recursive_mutex.h index f86d184870ad..6806858cea1c 100644 --- a/starboard/common/recursive_mutex.h +++ b/starboard/common/recursive_mutex.h @@ -44,7 +44,7 @@ class RecursiveMutex { private: Mutex mutex_; - pthread_t owner_id_; + SbThreadId owner_id_; // Only the owner is able to modify recurse_count_. size_t recurse_count_; diff --git a/starboard/common/thread_collision_warner.cc b/starboard/common/thread_collision_warner.cc index 94d7649056c8..b1844234d648 100644 --- a/starboard/common/thread_collision_warner.cc +++ b/starboard/common/thread_collision_warner.cc @@ -4,8 +4,6 @@ #include "starboard/common/thread_collision_warner.h" -#include - #include "starboard/atomic.h" #include "starboard/common/log.h" #include "starboard/thread.h" @@ -36,9 +34,7 @@ ThreadCollisionWarner::Check::Check(ThreadCollisionWarner* warner) ThreadCollisionWarner::Check::~Check() {} static SbAtomic32 CurrentThread() { - uintptr_t current_thread_id = - reinterpret_cast(reinterpret_cast(pthread_self())); - + const SbThreadId current_thread_id = SbThreadGetId(); // We need to get the thread id into an atomic data type. This might be a // truncating conversion, but any loss-of-information just increases the // chance of a false negative, not a false positive. diff --git a/starboard/condition_variable.h b/starboard/condition_variable.h index 44928fcacd28..5fbb1ad102b6 100644 --- a/starboard/condition_variable.h +++ b/starboard/condition_variable.h @@ -19,6 +19,8 @@ #ifndef STARBOARD_CONDITION_VARIABLE_H_ #define STARBOARD_CONDITION_VARIABLE_H_ +#if SB_API_VERSION < 16 + #include "starboard/export.h" #include "starboard/mutex.h" #include "starboard/types.h" @@ -46,8 +48,7 @@ typedef union SbConditionVariable { #define SB_CONDITION_VARIABLE_INITIALIZER \ {} #else -#define SB_CONDITION_VARIABLE_INITIALIZER \ - { 0 } +#define SB_CONDITION_VARIABLE_INITIALIZER {0} #endif // Enumeration of possible results from waiting on a condvar. @@ -121,4 +122,5 @@ SB_EXPORT bool SbConditionVariableSignal(SbConditionVariable* condition); } // extern "C" #endif +#endif // SB_API_VERSION < 16 #endif // STARBOARD_CONDITION_VARIABLE_H_ diff --git a/starboard/configuration_constants.h b/starboard/configuration_constants.h index cb6bb6877b52..061208a18a55 100644 --- a/starboard/configuration_constants.h +++ b/starboard/configuration_constants.h @@ -157,6 +157,9 @@ SB_EXPORT extern const uint32_t kSbMaxSystemPathCacheDirectorySize; // Whether this platform can map executable memory. This is required for // platforms that want to JIT. SB_EXPORT extern const bool kSbCanMapExecutableMemory; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport; #endif #endif // STARBOARD_CONFIGURATION_CONSTANTS_H_ diff --git a/starboard/doc/evergreen/cobalt_evergreen_overview.md b/starboard/doc/evergreen/cobalt_evergreen_overview.md index 4f473ad97e23..179c3f0f75ac 100644 --- a/starboard/doc/evergreen/cobalt_evergreen_overview.md +++ b/starboard/doc/evergreen/cobalt_evergreen_overview.md @@ -486,7 +486,6 @@ Image required for all slot configurations: │ └── cobalt <--(SLOT_0) │ ├── content <--(relative path defined in kSystemImageContentPath) │ │ ├── fonts <--(`empty` configuration) -│ │ ├── (icu) <--(only present when it needs to be updated by Cobalt Update) │ │ ├── licenses │ │ ├── ssl │ ├── lib @@ -507,7 +506,6 @@ updates in an example 3-slot configuration: ├── installation_2 <--(SLOT_2 - contains new Cobalt version) │ ├── content │ │ ├── fonts <--(`empty` configuration) - │ │ ├── (icu) <--(only present when it needs to be updated by Cobalt Update) │ │ ├── licenses │ │ ├── ssl │ ├── lib @@ -515,7 +513,6 @@ updates in an example 3-slot configuration: │ ├── manifest.fingerprint │ └── manifest.json <-- (Evergreen version information of libcobalt.so under SLOT_2) ├── installation_store_.pb - └── icu (default location shared by installation slots, to be explained below) ``` Note that after the Cobalt binary is loaded by the loader_app, `kSbSystemPathContentDirectory` points to the content directory of the running binary, as stated in Starboard Module Reference of system.h. @@ -559,24 +556,6 @@ On Raspberry Pi the Cobalt fonts are configured the following way: /fonts ``` -### ICU Tables -The ICU table should be deployed under the `kSbSystemPathStorageDirectory`. This -way all Cobalt Evergreen installations would be able to share the same tables. -The current storage size for the ICU tables is 7MB. - -On Raspberry Pi this is: - -``` -/home/pi/.cobalt_storage/icu -``` -The Cobalt Evergreen package will not carry ICU tables by default but may add -them in the future if needed. When the package has ICU tables they would be -stored under the content location for the installation: - -``` -/content/icu -``` - ### Handling Pending Updates Pending updates will be picked up on the next application start, which means that on platforms that support suspending the platform should check diff --git a/starboard/doc/resources/starboard_16_posix.png b/starboard/doc/resources/starboard_16_posix.png new file mode 100644 index 000000000000..0d4034b1ab45 Binary files /dev/null and b/starboard/doc/resources/starboard_16_posix.png differ diff --git a/starboard/doc/starboard_16_posix.md b/starboard/doc/starboard_16_posix.md new file mode 100644 index 000000000000..2888b0c0068c --- /dev/null +++ b/starboard/doc/starboard_16_posix.md @@ -0,0 +1,339 @@ +# Starboard 16 POSIX APIs + + +## Background +Updating existing Chromium components in the Cobalt repository or +bringing new ones requires porting to Starboard. This Starboardization process +takes a lot of time, however the majority of the APIs +involved in the porting are well established POSIX APIs with duplicates in +Starboard e.g: `malloc()` - `SbMemoryAllocate()`, +`socket()` - `SbSocketCreate()`, `open()` - `SbFileOpen()`, +`opendir()` - `SbDirectoryOpen()`, `pthread_mutex_create()` - `SbMutexCreate()` + etc... + +## Deprecated Starboard APIs +Starting with Starboard 16 the POSIX equivalent Starboard APIs were +deprecated and removed, and the standard POSIX APIs are used instead: + +### Memory Management +Removed: + +``` +SbMemoryAllocate +SbMemoryAllocateAligned +SbMemoryAllocateAlignedUnchecked +SbMemoryAllocateNoReport +SbMemoryAllocateUnchecked +SbMemoryDeallocate +SbMemoryDeallocateAligned +SbMemoryDeallocateNoReport +SbMemoryFlush +SbMemoryFree +SbMemoryFreeAligned +SbMemoryMap +SbMemoryProtect +SbMemoryReallocate +SbMemoryReallocateUnchecked +SbMemoryUnmap +``` + +Supported POSIX equivalents: + +``` +calloc +free +malloc +posix_memalign +realloc +mmap +munmap +mprotect +msync +``` + + +### Concurrency +Removed: + +``` +SbConditionVariableBroadcast +SbConditionVariableDestroy +SbConditionVariableCreate +SbConditionVariableSignal +SbConditionVariableWait +SbConditionVariableWaitTimed +SbMutexAcquire +SbMutexAcquireTry +SbMutexCreate +SbMutexDestroy +SbMutexRelease +SbThreadCreate +SbThreadCreateLocalKey +SbThreadDestroyLocalKey +SbThreadDetach +SbThreadGetCurrent +SbThreadGetLocalValue +SbThreadGetName +SbThreadIsEqual +SbThreadJoin +SbThreadSetLocalValue +SbThreadSetName +SbThreadSleep +SbThreadYield +SbOnce +``` + +Supported POSIX equivalents: + +``` +pthread_attr_init +pthread_attr_destroy +pthread_attr_getdetachstate +pthread_attr_getstacksize +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_getclock +pthread_condattr_init +pthread_condattr_setclock +pthread_create +pthread_detach +pthread_equal +pthread_join +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_unlock +pthread_mutex_trylock +pthread_once +pthread_self +pthread_getspecific +pthread_key_create +pthread_key_delete +pthread_setspecific +pthread_setname_np +pthread_getname_np +sched_yield +usleep +``` + +### I/O, sockets, files, directories +Removed: + +``` +SbDirectoryCanOpen +SbDirectoryClose +SbDirectoryCreate +SbDirectoryGetNext +SbDirectoryOpen +SbFileCanOpen +SbFileClose +SbFileDelete +SbFileExists +SbFileFlush +SbFileGetInfo +SbFileGetPathInfo +SbFileModeStringToFlags +SbFileOpen +SbFileRead +SbFileSeek +SbFileTruncate +SbFileWrite +SbSocketAccept +SbSocketBind +SbSocketClearLastError +SbSocketConnect +SbSocketCreate +SbSocketDestroy +SbSocketFreeResolution +SbSocketGetInterfaceAddress +SbSocketGetLastError +SbSocketGetLocalAddress +SbSocketIsConnected +SbSocketIsConnectedAndIdle +SbSocketIsIpv6Supported +SbSocketJoinMulticastGroup +SbSocketListen +SbSocketReceiveFrom +SbSocketResolve +SbSocketSendTo +SbSocketSetBroadcast +SbSocketSetReceiveBufferSize +SbSocketSetReuseAddress +SbSocketSetSendBufferSize +SbSocketSetTcpKeepAlive +SbSocketSetTcpNoDelay +SbSocketSetTcpWindowScaling +``` + +Supported POSIX equivalents: + +``` +accept +close +bind +connect +freeifaddrs +freeaddrinfo +fstat +fsync +ftruncate +getifaddrs +getaddrinfo +inet_ntop +listen +lseek +mkdir +read +recv +recvfrom +rmdir +setsockopt +send +sendto +stat +socket +unlink +write + +``` + +### Strings +Removed: + +``` +SbStringCompareNoCase +SbStringCompareNoCaseN +SbStringDuplicate +SbStringScan +SbStringFormat +SbStringFormatWide +``` + +Supported POSIX equivalents: +``` +strdup +strcasecmp +strncasecmp +vfwprintf +vsnprintf +vsscanf +``` + +### Time +Removed: + +``` +SbTimeGetMonotonicNow +SbTimeGetMonotonicThreadNow +SbTimeGetNow +SbTimeIsTimeThreadNowSupported +``` + +Supported POSIX equivalents: + +``` +clock_gettime +gettimeofday +gmtime_r +time +``` +### Evergreen integration +![Evergreen Architecture](resources/starboard_16_posix.png) + +#### POSIX ABI headers (musl_types) +The POSIX standard doesn't provide an ABI specification. There is guidance +around type definitions, but the actual memory representation is left +to the platform implementation. For example the `clock_gettime(CLOCK_MONOTONIC, &ts)` uses +various constants (e.g. CLOCK_MONOTONIC) to define which system clock to query +and a `struct timespec` pointer to populate the time data. The struct has 2 +members, but the POSIX standard does not explicitly require that these members +be a specific number of bytes (e.g. the type long may be 4 or 8 bytes), +nor the padding/layout of the members in the struct +(e.g. a compiler is allowed to add additional padding). + +The Starboard 16 POSIX ABI is defined by a combination of existing +[third_party/musl](../../third_party/musl) types and values and new types +and values added under [third_party/musl/src/starboard](../../third_party/musl/src/starboard). +All of the types have a concrete stable ABI defined per CPU architecture. + +#### POSIX wrapper impl +The musl ABI types are translated to the native POSIX types in the +POSIX wrapper implementation. +The actual implementation, which assumes a native POSIX support is +implemented in `starboard/shared/modular`. For example +[starboard/shared/modular/starboard_layer_posix_time_abi_wrappers.h](../shared/modular/starboard_layer_posix_time_abi_wrappers.h), +[starboard/shared/modular/starboard_layer_posix_time_abi_wrappers.cc](../shared/modular/starboard_layer_posix_time_abi_wrappers.cc). + +If the provided implementation doesn't work out of the box +partners can fix it and adjust for their own internal platform. If the +fix is applicable to other POSIX implementations they can upstream the change +to the Cobalt project. + +#### Exported Symbols Map +The Exported Symbols Map is part of the Evergreen loader and provides all the unresolved +external symbols required by the Coabalt Core binary. The map is defined as +`std::map` and all the Starboard and POSIX symbols are +registered there. The implementation resides in +[starboard/elf_loader/exported_symbols.cc](../elf_loader/exported_symbols.cc). +For POSIX APIs a wrapper function is used whenever a translation +from `musl` types to platform POSIX types is needed e.g. + +``` +map_["clock_gettime"] = reinterpret_cast(&__abi_wrap_clock_gettime); +``` +The symbol may be registered directly without a wrapper if there is no need +for any translation or ajustements of the API e.g. +``` +REGISTER_SYMBOL(malloc); +``` + +### Verification +A test suite [starboard/nplb/posix_compliance](../nplb/posix_compliance) is added to `nplb` +to verify the POSIX APIs specification and to enforce uniformity across all platforms. + +The `elf_loader_sandbox` binary can be used to run tests in Evergreen mode. + +The `elf_loader_sandbox` is run using two command line switches: +`--evergreen_library` and `--evergreen_content`. These switches are the path to +the shared library to be run and the path to that shared library's content. +These paths should be *relative to the content of the elf_loader_sandbox*. + +For example, if we wanted to run the `nplb` set of tests and had the following +directory tree, + +``` +.../elf_loader_sandbox +.../content/app/nplb/lib/libnplb.so +.../content/app/nplb/content +``` + +we would use the following command to run `nplb`: + +``` +.../elf_loader_sandbox --evergreen_library=app/nplb/lib/libnplb.so + --evergreen_content=app/nplb/content +``` + +To build the `nplb` tests for Evergreen use the following commands. +The first of which builds the test using the Evergreen toolchain and +the second builds `elf_loader_sandbox` using the partner's toolchain: + +``` + +ninja -C out/evergreen-arm-softfp_devel/ nplb_install +ninja -C out/${PLATFORM}_devel/ elf_loader_sandbox_install + +``` + + +### Backwards compatibility with Starboard 14 and Starboard 15 +For older Starboard Versions e.g. 14 and 15 an emulation layer was provided through +the `third_party/musl` library. This should be completely transparent to +partner's integrations. diff --git a/starboard/egl_and_gles/BUILD.gn b/starboard/egl_and_gles/BUILD.gn index 78f817ed7a2f..8256b0b28849 100644 --- a/starboard/egl_and_gles/BUILD.gn +++ b/starboard/egl_and_gles/BUILD.gn @@ -38,7 +38,7 @@ config("egl_and_gles_glimp_public_config") { if (gl_type == "glimp") { group("egl_and_gles_glimp") { public_configs = [ ":egl_and_gles_glimp_public_config" ] - public_deps = [ "//glimp" ] + public_deps = [ "//internal/starboard/shared/glimp" ] } } diff --git a/starboard/elf_loader/BUILD.gn b/starboard/elf_loader/BUILD.gn index 379a002dc658..eaf10d8e2a27 100644 --- a/starboard/elf_loader/BUILD.gn +++ b/starboard/elf_loader/BUILD.gn @@ -90,11 +90,10 @@ if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) { # TODO: b/309493306 - Stop building evergreen targets for all non-evergreen platforms. if (current_toolchain == starboard_toolchain && !is_host_win) { target(starboard_level_final_executable_type, "elf_loader_sandbox") { - data_deps = [ "//third_party/icu:icudata" ] if (cobalt_font_package == "empty") { - data_deps += [ "//cobalt/content/fonts:copy_font_data" ] + data_deps = [ "//cobalt/content/fonts:copy_font_data" ] } else { - data_deps += [ + data_deps = [ "//cobalt/content/fonts:copy_fonts", "//cobalt/content/fonts:fonts_xml", ] @@ -116,7 +115,7 @@ if (current_toolchain == starboard_toolchain && !is_host_win) { deps += [ "//third_party/crashpad/crashpad/wrapper:wrapper_stub" ] } if (sb_is_evergreen_compatible && sb_evergreen_compatible_package) { - # deps += [ "//starboard/loader_app:copy_crashpad_handler_named_as_so" ] + deps += [ "//starboard/loader_app:copy_crashpad_handler_named_as_so" ] } } } diff --git a/starboard/elf_loader/exported_symbols.cc b/starboard/elf_loader/exported_symbols.cc index 3f49385a8cb5..c73c55bab79c 100644 --- a/starboard/elf_loader/exported_symbols.cc +++ b/starboard/elf_loader/exported_symbols.cc @@ -14,6 +14,7 @@ #include "starboard/elf_loader/exported_symbols.h" +#include #include #include #include @@ -53,6 +54,7 @@ #if SB_API_VERSION >= 16 #include "starboard/shared/modular/starboard_layer_posix_mmap_abi_wrappers.h" #include "starboard/shared/modular/starboard_layer_posix_pthread_abi_wrappers.h" +#include "starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.h" #include "starboard/shared/modular/starboard_layer_posix_stat_abi_wrappers.h" #include "starboard/shared/modular/starboard_layer_posix_time_abi_wrappers.h" #include "starboard/shared/modular/starboard_layer_posix_unistd_abi_wrappers.h" @@ -117,6 +119,7 @@ ExportedSymbols::ExportedSymbols() { #endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 REGISTER_SYMBOL(kSbCanMapExecutableMemory); + REGISTER_SYMBOL(kHasPartialAudioFramesSupport); #endif REGISTER_SYMBOL(SbAccessibilityGetCaptionSettings); REGISTER_SYMBOL(SbAccessibilityGetDisplaySettings); @@ -137,13 +140,13 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbByteSwapU16); REGISTER_SYMBOL(SbByteSwapU32); REGISTER_SYMBOL(SbByteSwapU64); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbConditionVariableBroadcast); REGISTER_SYMBOL(SbConditionVariableCreate); REGISTER_SYMBOL(SbConditionVariableDestroy); REGISTER_SYMBOL(SbConditionVariableSignal); REGISTER_SYMBOL(SbConditionVariableWait); REGISTER_SYMBOL(SbConditionVariableWaitTimed); +#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbCPUFeaturesGet); REGISTER_SYMBOL(SbDecodeTargetGetInfo); REGISTER_SYMBOL(SbDecodeTargetRelease); @@ -205,7 +208,9 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbMediaGetBufferAllocationUnit); REGISTER_SYMBOL(SbMediaGetBufferGarbageCollectionDurationThreshold); REGISTER_SYMBOL(SbMediaGetBufferPadding); +#if SB_API_VERSION < 16 REGISTER_SYMBOL(SbMediaGetBufferStorageType); +#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbMediaGetInitialBufferCapacity); REGISTER_SYMBOL(SbMediaGetMaxBufferCapacity); REGISTER_SYMBOL(SbMediaGetProgressiveBufferBudget); @@ -257,16 +262,14 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbMicrophoneIsSampleRateSupported); REGISTER_SYMBOL(SbMicrophoneOpen); REGISTER_SYMBOL(SbMicrophoneRead); +#if SB_API_VERSION < 16 REGISTER_SYMBOL(SbMutexAcquire); REGISTER_SYMBOL(SbMutexAcquireTry); REGISTER_SYMBOL(SbMutexCreate); REGISTER_SYMBOL(SbMutexDestroy); REGISTER_SYMBOL(SbMutexRelease); - -#if SB_API_VERSION < 16 REGISTER_SYMBOL(SbOnce); #endif // SB_API_VERSION < 16 - REGISTER_SYMBOL(SbPlayerCreate); REGISTER_SYMBOL(SbPlayerDestroy); #if SB_API_VERSION >= 15 @@ -380,46 +383,36 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbSystemSupportsResume); REGISTER_SYMBOL(SbSystemSymbolize); REGISTER_SYMBOL(SbThreadContextGetPointer); - REGISTER_SYMBOL(SbThreadCreate); - #if SB_API_VERSION < 16 + REGISTER_SYMBOL(SbThreadCreate); REGISTER_SYMBOL(SbThreadCreateLocalKey); REGISTER_SYMBOL(SbThreadDestroyLocalKey); -#endif // SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadDetach); REGISTER_SYMBOL(SbThreadGetCurrent); +#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadGetId); - #if SB_API_VERSION >= 16 REGISTER_SYMBOL(SbThreadGetPriority); #endif // SB_API_VERSION >= 16 - #if SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadGetLocalValue); REGISTER_SYMBOL(SbThreadGetName); -#endif // SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadIsEqual); REGISTER_SYMBOL(SbThreadJoin); +#endif // SB_API_VERSION < 16 + REGISTER_SYMBOL(SbThreadSamplerCreate); REGISTER_SYMBOL(SbThreadSamplerDestroy); REGISTER_SYMBOL(SbThreadSamplerFreeze); REGISTER_SYMBOL(SbThreadSamplerIsSupported); REGISTER_SYMBOL(SbThreadSamplerThaw); - #if SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadSetLocalValue); -#endif // SB_API_VERSION < 16 - -#if SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadSetName); #endif // SB_API_VERSION < 16 - #if SB_API_VERSION >= 16 REGISTER_SYMBOL(SbThreadSetPriority); #endif // SB_API_VERSION >= 16 - #if SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadSleep); REGISTER_SYMBOL(SbThreadYield); @@ -464,6 +457,7 @@ ExportedSymbols::ExportedSymbols() { #if SB_API_VERSION >= 16 // POSIX APIs + REGISTER_SYMBOL(__errno_location); REGISTER_SYMBOL(accept); REGISTER_SYMBOL(bind); REGISTER_SYMBOL(calloc); @@ -591,6 +585,12 @@ ExportedSymbols::ExportedSymbols() { map_["read"] = reinterpret_cast(&__abi_wrap_read); map_["stat"] = reinterpret_cast(&__abi_wrap_stat); map_["time"] = reinterpret_cast(&__abi_wrap_time); + map_["accept"] = reinterpret_cast(&__abi_wrap_accept); + map_["bind"] = reinterpret_cast(&__abi_wrap_bind); + map_["connect"] = reinterpret_cast(&__abi_wrap_connect); + map_["getaddrinfo"] = reinterpret_cast(&__abi_wrap_getaddrinfo); + map_["getifaddrs"] = reinterpret_cast(&__abi_wrap_getifaddrs); + map_["setsockopt"] = reinterpret_cast(&__abi_wrap_setsockopt); #if defined(_MSC_VER) // MSVC provides a template with the same name. diff --git a/starboard/evergreen/arm/softfp/platform_configuration/BUILD.gn b/starboard/evergreen/arm/softfp/platform_configuration/BUILD.gn index 01a909971e18..3300d87d29a9 100644 --- a/starboard/evergreen/arm/softfp/platform_configuration/BUILD.gn +++ b/starboard/evergreen/arm/softfp/platform_configuration/BUILD.gn @@ -18,6 +18,7 @@ config("sabi_flags") { "-target", "armv7a-none-eabi", ] + asmflags = cflags } config("platform_configuration") { diff --git a/starboard/examples/window/BUILD.gn b/starboard/examples/window/BUILD.gn index 1d31d6a07cad..79c6e1ad8fd2 100644 --- a/starboard/examples/window/BUILD.gn +++ b/starboard/examples/window/BUILD.gn @@ -17,5 +17,4 @@ target(final_executable_type, "starboard_window_example") { sources = [ "main.cc" ] public_deps = [ "//starboard:starboard_group" ] - data_deps = [ "//third_party/icu:icudata" ] } diff --git a/starboard/extension/BUILD.gn b/starboard/extension/BUILD.gn index e440b2aee66a..810ffdb88772 100644 --- a/starboard/extension/BUILD.gn +++ b/starboard/extension/BUILD.gn @@ -14,8 +14,7 @@ target(gtest_target_type, "extension_test") { testonly = true - - # has_pedantic_warnings = true + has_pedantic_warnings = true sources = [ "enhanced_audio_test.cc", "extension_test.cc", diff --git a/starboard/extension/extension_test.cc b/starboard/extension/extension_test.cc index 551e834860cc..24dae87a815a 100644 --- a/starboard/extension/extension_test.cc +++ b/starboard/extension/extension_test.cc @@ -26,6 +26,7 @@ #include "starboard/extension/javascript_cache.h" #include "starboard/extension/loader_app_metrics.h" #include "starboard/extension/media_session.h" +#include "starboard/extension/media_settings.h" #include "starboard/extension/memory_mapped_file.h" #include "starboard/extension/platform_info.h" #include "starboard/extension/platform_service.h" @@ -517,7 +518,7 @@ TEST(ExtensionTest, LoaderAppMetrics) { EXPECT_STREQ(extension_api->name, kExtensionName); EXPECT_GE(extension_api->version, 1u); - EXPECT_LE(extension_api->version, 2u); + EXPECT_LE(extension_api->version, 3u); EXPECT_NE(extension_api->SetCrashpadInstallationStatus, nullptr); EXPECT_NE(extension_api->GetCrashpadInstallationStatus, nullptr); @@ -535,6 +536,11 @@ TEST(ExtensionTest, LoaderAppMetrics) { EXPECT_NE(extension_api->GetMaxSampledUsedCpuBytesDuringElfLoad, nullptr); } + if (extension_api->version >= 3) { + EXPECT_NE(extension_api->SetSlotSelectionStatus, nullptr); + EXPECT_NE(extension_api->GetSlotSelectionStatus, nullptr); + } + const ExtensionApi* second_extension_api = static_cast(SbSystemGetExtension(kExtensionName)); EXPECT_EQ(second_extension_api, extension_api) @@ -564,5 +570,25 @@ TEST(ExtensionTest, PlayerConfiguration) { } } +TEST(ExtensionTest, MediaSettings) { + typedef StarboardExtensionMediaSettingsApi ExtensionApi; + const char* kExtensionName = kStarboardExtensionMediaSettingsName; + + const ExtensionApi* extension_api = + static_cast(SbSystemGetExtension(kExtensionName)); + if (!extension_api) { + return; + } + + EXPECT_STREQ(extension_api->name, kExtensionName); + EXPECT_EQ(extension_api->version, 1u); + EXPECT_NE(extension_api->EnableAsyncReleaseMediaCodecBridge, nullptr); + + const ExtensionApi* second_extension_api = + static_cast(SbSystemGetExtension(kExtensionName)); + EXPECT_EQ(second_extension_api, extension_api) + << "Extension struct should be a singleton"; +} + } // namespace extension } // namespace starboard diff --git a/starboard/extension/loader_app_metrics.h b/starboard/extension/loader_app_metrics.h index ea02a956d7cb..d077f7090e6d 100644 --- a/starboard/extension/loader_app_metrics.h +++ b/starboard/extension/loader_app_metrics.h @@ -28,7 +28,7 @@ extern "C" { // numeric values should never be reused. Must be kept in sync with the // corresponding definition in // tools/metrics/histograms/metadata/cobalt/enums.xml. -typedef enum CrashpadInstallationStatus { +typedef enum class CrashpadInstallationStatus { // The enumerators below this point were added in version 1 or later. kUnknown = 0, kSucceeded = 1, @@ -38,6 +38,23 @@ typedef enum CrashpadInstallationStatus { kMaxValue = kFailedSignalHandlerInstallationFailed } CrashpadInstallationStatus; +typedef enum class SlotSelectionStatus { + // The enumerators below this point were added in version 3 or later. + kUnknown = 0, + kCurrentSlot = 1, + kRollForward = 2, + kRollBackOutOfRetries = 3, + kRollBackNoLibFile = 4, + kRollBackBadAppKeyFile = 5, + kRollBackSlotDraining = 6, + kRollBackFailedToAdopt = 7, + kRollBackFailedToLoadCobalt = 8, + kRollBackFailedToCheckSabi = 9, + kRollBackFailedToLookUpSymbols = 10, + kEGLite = 11, + kMaxValue = kEGLite, +} SlotSelectionStatus; + typedef struct StarboardExtensionLoaderAppMetricsApi { // Name should be the string |kStarboardExtensionLoaderAppMetricsName|. // This helps to validate that the extension API is correct. @@ -87,6 +104,11 @@ typedef struct StarboardExtensionLoaderAppMetricsApi { // using RecordUsedCpuBytesDuringElfLoad(), or -1 if no value was recorded. int64_t (*GetMaxSampledUsedCpuBytesDuringElfLoad)(); + // The fields below this point were added in version 3 or later. + + void (*SetSlotSelectionStatus)(SlotSelectionStatus status); + SlotSelectionStatus (*GetSlotSelectionStatus)(); + } StarboardExtensionLoaderAppMetricsApi; #ifdef __cplusplus diff --git a/starboard/extension/media_settings.h b/starboard/extension/media_settings.h new file mode 100644 index 000000000000..015bf48d10d2 --- /dev/null +++ b/starboard/extension/media_settings.h @@ -0,0 +1,45 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_EXTENSION_MEDIA_SETTINGS_H_ +#define STARBOARD_EXTENSION_MEDIA_SETTINGS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define kStarboardExtensionMediaSettingsName \ + "dev.cobalt.extension.MediaSettings" + +typedef struct StarboardExtensionMediaSettingsApi { + // Name should be the string |kStarboardExtensionMediaSettingsName|. + // This helps to validate that the extension API is correct. + const char* name; + + // This specifies the version of the API that is implemented. + uint32_t version; + + // This API enables the feature to async release MediaCodecBridge on Android + // TV. + void (*EnableAsyncReleaseMediaCodecBridge)(bool value); + +} StarboardExtensionMediaSettingsApi; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // STARBOARD_EXTENSION_MEDIA_SETTINGS_H_ diff --git a/starboard/linux/shared/BUILD.gn b/starboard/linux/shared/BUILD.gn index 07daff0131ba..1e9ea031e2b6 100644 --- a/starboard/linux/shared/BUILD.gn +++ b/starboard/linux/shared/BUILD.gn @@ -445,7 +445,7 @@ static_library("starboard_platform_sources") { if (current_toolchain == starboard_toolchain) { target(starboard_level_gtest_target_type, "starboard_platform_tests") { - # build_loader = false + build_loader = false testonly = true sources = media_tests_sources + player_tests_sources + [ diff --git a/starboard/linux/shared/cobalt/configuration.py b/starboard/linux/shared/cobalt/configuration.py index da471061bc4e..cfff3641b613 100644 --- a/starboard/linux/shared/cobalt/configuration.py +++ b/starboard/linux/shared/cobalt/configuration.py @@ -32,6 +32,8 @@ 'All/SequenceManagerTest.DelayedTasksDontBadlyStarveNonDelayedWork_SameQueue/WithMockTaskRunner', # pylint: disable=line-too-long 'All/SequenceManagerTest.SweepCanceledDelayedTasks_ManyTasks/WithMessagePump', # pylint: disable=line-too-long 'All/SequenceManagerTest.SweepCanceledDelayedTasks_ManyTasks/WithMessagePumpAlignedWakeUps', # pylint: disable=line-too-long + # TODO: b/329507754 - Flaky after recent rebase. + 'ScopedBlockingCallIOJankMonitoringTest.MultiThreadedOverlappedWindows', 'TaskEnvironmentTest.MultiThreadedMockTimeAndThreadPoolQueuedMode' ], } diff --git a/starboard/linux/shared/configuration_constants.cc b/starboard/linux/shared/configuration_constants.cc index 640f9f606b86..341512540dad 100644 --- a/starboard/linux/shared/configuration_constants.cc +++ b/starboard/linux/shared/configuration_constants.cc @@ -139,4 +139,7 @@ const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #if SB_API_VERSION >= 16 SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; #endif diff --git a/starboard/linux/shared/platform_configuration/configuration.gni b/starboard/linux/shared/platform_configuration/configuration.gni index 852b0083000f..60ff849320e5 100644 --- a/starboard/linux/shared/platform_configuration/configuration.gni +++ b/starboard/linux/shared/platform_configuration/configuration.gni @@ -38,6 +38,6 @@ platform_tests_path = "//starboard/linux/shared:starboard_platform_tests($starboard_toolchain)" # TODO(b/330364592): re-enable when in-app-dial is fixed. -enable_in_app_dial = false +enable_in_app_dial = true v8_enable_webassembly = true diff --git a/starboard/linux/x64x11/platform_configuration/BUILD.gn b/starboard/linux/x64x11/platform_configuration/BUILD.gn index 7a91af178c6e..23738ecb2f44 100644 --- a/starboard/linux/x64x11/platform_configuration/BUILD.gn +++ b/starboard/linux/x64x11/platform_configuration/BUILD.gn @@ -13,17 +13,6 @@ # limitations under the License. config("platform_configuration") { - libs = [ - "X11", - "Xcomposite", - "Xrender", - ] - libs += [ - "asound", - "dl", - "pthread", - "rt", - ] configs = [ "//starboard/build/config/sabi", "//starboard/linux/x64x11/shared/platform_configuration", diff --git a/starboard/linux/x64x11/shared/BUILD.gn b/starboard/linux/x64x11/shared/BUILD.gn index 43605fde7676..4a77595b213d 100644 --- a/starboard/linux/x64x11/shared/BUILD.gn +++ b/starboard/linux/x64x11/shared/BUILD.gn @@ -21,7 +21,7 @@ group("starboard_platform") { deps = [ "//third_party/libdav1d:dav1d", - "//third_party/libjpeg-turbo:libjpeg", + "//third_party/libjpeg_turbo:libjpeg", "//third_party/libvpx", ] } diff --git a/starboard/loader_app/BUILD.gn b/starboard/loader_app/BUILD.gn index 25ce107fe6e5..5bf78822e06f 100644 --- a/starboard/loader_app/BUILD.gn +++ b/starboard/loader_app/BUILD.gn @@ -29,6 +29,7 @@ if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) { ":app_key", ":installation_manager", ":memory_tracker_thread", + ":record_loader_app_status", ":reset_evergreen_update", ":slot_management", "//starboard:starboard_group", @@ -77,15 +78,22 @@ if (sb_is_evergreen_compatible && sb_evergreen_compatible_package && } } +static_library("record_loader_app_status") { + sources = [ + "record_loader_app_status.cc", + "record_loader_app_status.h", + ] + deps = [ "//starboard:starboard_group" ] +} + if (sb_is_evergreen_compatible && current_toolchain == starboard_toolchain) { target(starboard_level_final_executable_type, "loader_app") { build_loader = false if (target_cpu == "x64" || target_cpu == "arm" || target_cpu == "arm64") { - data_deps = [ "//third_party/icu:icudata" ] if (cobalt_font_package == "empty") { - data_deps += [ "//cobalt/content/fonts:copy_font_data" ] + data_deps = [ "//cobalt/content/fonts:copy_font_data" ] } else { - data_deps += [ + data_deps = [ "//cobalt/content/fonts:copy_fonts", "//cobalt/content/fonts:fonts_xml", ] @@ -246,6 +254,7 @@ static_library("installation_manager") { deps = [ ":installation_store_proto", ":pending_restart", + ":record_loader_app_status", "//starboard:starboard_group", ] } diff --git a/starboard/loader_app/installation_manager.cc b/starboard/loader_app/installation_manager.cc index 76639688bf88..ecb3869c6658 100644 --- a/starboard/loader_app/installation_manager.cc +++ b/starboard/loader_app/installation_manager.cc @@ -27,12 +27,14 @@ #include "starboard/common/string.h" #include "starboard/configuration_constants.h" #include "starboard/directory.h" +#include "starboard/extension/loader_app_metrics.h" #include "starboard/file.h" #include "starboard/loader_app/installation_store.pb.h" #if !SB_IS(EVERGREEN_COMPATIBLE_LITE) #include "starboard/loader_app/pending_restart.h" // nogncheck #endif // !SB_IS(EVERGREEN_COMPATIBLE_LITE) #include "starboard/common/once.h" +#include "starboard/loader_app/record_loader_app_status.h" #include "starboard/string.h" namespace starboard { @@ -54,7 +56,7 @@ class InstallationManager { int RollForward(int installation_index); int DecrementInstallationNumTries(int installation_index); - int RevertToSuccessfulInstallation(); + int RevertToSuccessfulInstallation(SlotSelectionStatus status); int GetInstallationPath(int installation_index, char* path, int path_length); int GetCurrentInstallationIndex(); int MarkInstallationSuccessful(int installation_index); @@ -299,7 +301,8 @@ int InstallationManager::DecrementInstallationNumTries(int installation_index) { // [x] => [ ] // low [ ] [-] // -int InstallationManager::RevertToSuccessfulInstallation() { +int InstallationManager::RevertToSuccessfulInstallation( + SlotSelectionStatus status) { if (!initialized_) { SB_LOG(ERROR) << "RevertToSuccessfulInstallation: not initialized"; return IM_ERROR; @@ -347,6 +350,7 @@ int InstallationManager::RevertToSuccessfulInstallation() { << DumpInstallationSlots(); if (SaveInstallationStore()) { + RecordSlotSelectionStatus(status); return fallback_installation; } return IM_ERROR; @@ -418,7 +422,12 @@ int InstallationManager::RollForwardInternal(int installation_index) { current_installation_ = installation_index; SB_DLOG(INFO) << "RollForwardInternal: " << DumpInstallationSlots(); - return SaveInstallationStore() ? IM_SUCCESS : IM_ERROR; + + if (SaveInstallationStore()) { + RecordSlotSelectionStatus(SlotSelectionStatus::kRollForward); + return IM_SUCCESS; + } + return IM_ERROR; } // Shift the priority in the inclusive range either up or down based @@ -831,9 +840,9 @@ int ImRollForward(int installation_index) { return g_installation_manager_->RollForward(installation_index); } -int ImRevertToSuccessfulInstallation() { +int ImRevertToSuccessfulInstallation(SlotSelectionStatus status) { starboard::ScopedLock lock(*GetImMutex()); - return g_installation_manager_->RevertToSuccessfulInstallation(); + return g_installation_manager_->RevertToSuccessfulInstallation(status); } int ImRequestRollForwardToInstallation(int installation_index) { diff --git a/starboard/loader_app/installation_manager.h b/starboard/loader_app/installation_manager.h index 8ace1ac348d0..adf2d6796736 100644 --- a/starboard/loader_app/installation_manager.h +++ b/starboard/loader_app/installation_manager.h @@ -15,6 +15,8 @@ #ifndef STARBOARD_LOADER_APP_INSTALLATION_MANAGER_H_ #define STARBOARD_LOADER_APP_INSTALLATION_MANAGER_H_ +#include "starboard/extension/loader_app_metrics.h" + #ifdef __cplusplus extern "C" { #endif @@ -122,7 +124,7 @@ int ImRollForward(int installation_index); // Revert to a previous successful installation. // Returns the installation to which it was reverted. // Returns |IM_ERROR| on error. -int ImRevertToSuccessfulInstallation(); +int ImRevertToSuccessfulInstallation(SlotSelectionStatus status); // Request the installation at |installation_index| to be rolled // forward next time the Loader App tries to load the app. diff --git a/starboard/loader_app/installation_manager_test.cc b/starboard/loader_app/installation_manager_test.cc index fbf394fd28c1..ff6d02ac5f20 100644 --- a/starboard/loader_app/installation_manager_test.cc +++ b/starboard/loader_app/installation_manager_test.cc @@ -21,6 +21,7 @@ #include "starboard/common/file.h" #include "starboard/configuration_constants.h" +#include "starboard/extension/loader_app_metrics.h" #include "starboard/loader_app/installation_store.pb.h" #include "testing/gtest/include/gtest/gtest.h" @@ -146,7 +147,8 @@ class InstallationManagerTest : public ::testing::TestWithParam { SaveStorageState(installation_store); ASSERT_EQ(IM_SUCCESS, ImInitialize(max_num_installations, kAppKey)); - int result = ImRevertToSuccessfulInstallation(); + int result = + ImRevertToSuccessfulInstallation(SlotSelectionStatus::kUnknown); if (!expected_succeed) { ASSERT_EQ(IM_ERROR, result); } @@ -398,7 +400,7 @@ TEST_P(InstallationManagerTest, RevertToSuccessfulInstallation) { ASSERT_EQ(1, ImGetCurrentInstallationIndex()); ASSERT_EQ(IM_SUCCESS, ImMarkInstallationSuccessful(1)); ASSERT_EQ(1, ImGetCurrentInstallationIndex()); - ASSERT_EQ(0, ImRevertToSuccessfulInstallation()); + ASSERT_EQ(0, ImRevertToSuccessfulInstallation(SlotSelectionStatus::kUnknown)); ASSERT_EQ(0, ImGetCurrentInstallationIndex()); } @@ -410,7 +412,8 @@ TEST_F(InstallationManagerTest, InvalidInput) { ASSERT_EQ(IM_INSTALLATION_STATUS_ERROR, ImGetInstallationStatus(10)); ASSERT_EQ(IM_SUCCESS, ImMarkInstallationSuccessful(0)); ASSERT_EQ(IM_INSTALLATION_STATUS_ERROR, ImGetInstallationStatus(-2)); - ASSERT_EQ(IM_ERROR, ImRevertToSuccessfulInstallation()); + ASSERT_EQ(IM_ERROR, + ImRevertToSuccessfulInstallation(SlotSelectionStatus::kUnknown)); ASSERT_EQ(IM_ERROR, ImMarkInstallationSuccessful(10)); ASSERT_EQ(IM_ERROR, ImMarkInstallationSuccessful(-2)); ASSERT_EQ(IM_ERROR, ImDecrementInstallationNumTries(10)); diff --git a/starboard/loader_app/loader_app.cc b/starboard/loader_app/loader_app.cc index 272ec52eefa6..c8b439758f2e 100644 --- a/starboard/loader_app/loader_app.cc +++ b/starboard/loader_app/loader_app.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include #include @@ -26,15 +27,16 @@ #include "starboard/elf_loader/evergreen_info.h" #include "starboard/elf_loader/sabi_string.h" #include "starboard/event.h" +#include "starboard/extension/loader_app_metrics.h" #include "starboard/file.h" #include "starboard/loader_app/app_key.h" #include "starboard/loader_app/loader_app_switches.h" #include "starboard/loader_app/memory_tracker_thread.h" +#include "starboard/loader_app/record_loader_app_status.h" #include "starboard/loader_app/reset_evergreen_update.h" #include "starboard/loader_app/slot_management.h" #include "starboard/loader_app/system_get_extension_shim.h" #include "starboard/memory.h" -#include "starboard/mutex.h" #include "starboard/shared/starboard/command_line.h" #include "starboard/string.h" #include "third_party/crashpad/crashpad/wrapper/annotations.h" @@ -191,9 +193,9 @@ void LoadLibraryAndInitialize(const std::string& alternative_content_path, } // namespace void SbEventHandle(const SbEvent* event) { - static SbMutex mutex = SB_MUTEX_INITIALIZER; + static pthread_mutex_t mutex PTHREAD_MUTEX_INITIALIZER; - SB_CHECK(SbMutexAcquire(&mutex) == kSbMutexAcquired); + SB_CHECK(pthread_mutex_lock(&mutex) == 0); if (!g_sb_event_func && (event->type == kSbEventTypeStart || event->type == kSbEventTypePreload)) { @@ -205,7 +207,7 @@ void SbEventHandle(const SbEvent* event) { SB_LOG(INFO) << "Resetting the Evergreen Update"; starboard::loader_app::ResetEvergreenUpdate(); SbSystemRequestStop(0); - SB_CHECK(SbMutexRelease(&mutex) == true); + SB_CHECK(pthread_mutex_unlock(&mutex) == 0); return; } @@ -259,6 +261,8 @@ void SbEventHandle(const SbEvent* event) { } if (is_evergreen_lite) { + starboard::loader_app::RecordSlotSelectionStatus( + SlotSelectionStatus::kEGLite); LoadLibraryAndInitialize(alternative_content, use_memory_mapped_file); } else { std::string url = @@ -281,5 +285,5 @@ void SbEventHandle(const SbEvent* event) { g_sb_event_func(event); } - SB_CHECK(SbMutexRelease(&mutex) == true); + SB_CHECK(pthread_mutex_unlock(&mutex) == 0); } diff --git a/starboard/loader_app/record_loader_app_status.cc b/starboard/loader_app/record_loader_app_status.cc new file mode 100644 index 000000000000..12c310433f5c --- /dev/null +++ b/starboard/loader_app/record_loader_app_status.cc @@ -0,0 +1,37 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "starboard/loader_app/record_loader_app_status.h" + +#include + +#include "starboard/system.h" + +namespace starboard { +namespace loader_app { + +void RecordSlotSelectionStatus(SlotSelectionStatus status) { + auto metrics_extension = + static_cast( + SbSystemGetExtension(kStarboardExtensionLoaderAppMetricsName)); + if (metrics_extension && + strcmp(metrics_extension->name, + kStarboardExtensionLoaderAppMetricsName) == 0 && + metrics_extension->version >= 3) { + metrics_extension->SetSlotSelectionStatus(status); + } +} + +} // namespace loader_app +} // namespace starboard diff --git a/starboard/loader_app/record_loader_app_status.h b/starboard/loader_app/record_loader_app_status.h new file mode 100644 index 000000000000..8f6ac52f7713 --- /dev/null +++ b/starboard/loader_app/record_loader_app_status.h @@ -0,0 +1,31 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_LOADER_APP_RECORD_LOADER_APP_STATUS_H_ +#define STARBOARD_LOADER_APP_RECORD_LOADER_APP_STATUS_H_ + +#include + +#include "starboard/extension/loader_app_metrics.h" + +namespace starboard { +namespace loader_app { + +// Persist the slot selection status so that it can be read in the Cobalt layer +void RecordSlotSelectionStatus(SlotSelectionStatus status); + +} // namespace loader_app +} // namespace starboard + +#endif // STARBOARD_LOADER_APP_RECORD_LOADER_APP_STATUS_H_ diff --git a/starboard/loader_app/slot_management.cc b/starboard/loader_app/slot_management.cc index 928687e0f259..c576e565ed4c 100644 --- a/starboard/loader_app/slot_management.cc +++ b/starboard/loader_app/slot_management.cc @@ -24,6 +24,7 @@ #include "starboard/elf_loader/elf_loader_constants.h" #include "starboard/elf_loader/sabi_string.h" #include "starboard/event.h" +#include "starboard/extension/loader_app_metrics.h" #include "starboard/file.h" #include "starboard/loader_app/app_key_files.h" #include "starboard/loader_app/drain_file.h" @@ -57,7 +58,8 @@ const char kCobaltContentPath[] = "content"; int RevertBack(int current_installation, const std::string& app_key, - bool mark_bad) { + bool mark_bad, + SlotSelectionStatus status) { SB_LOG(INFO) << "RevertBack current_installation=" << current_installation; SB_DCHECK(current_installation != 0); if (mark_bad) { @@ -82,7 +84,7 @@ int RevertBack(int current_installation, << current_installation; } } - current_installation = ImRevertToSuccessfulInstallation(); + current_installation = ImRevertToSuccessfulInstallation(status); return current_installation; } @@ -163,7 +165,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, // the current image is not the system image. if (current_installation != 0) { current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackOutOfRetries); } } } @@ -181,7 +184,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, // the current image is not the system image. if (current_installation != 0) { current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackNoLibFile); continue; } else { // The system image at index 0 failed. @@ -202,7 +206,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, if (CheckBadFileExists(installation_path.data(), app_key.c_str())) { SB_LOG(INFO) << "Bad app key file"; current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackBadAppKeyFile); continue; } // If the current installation is in use by an updater roll back. @@ -210,7 +215,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, app_key.c_str())) { SB_LOG(INFO) << "Active slot draining"; current_installation = - RevertBack(current_installation, app_key, false /* mark_bad */); + RevertBack(current_installation, app_key, false /* mark_bad */, + SlotSelectionStatus::kRollBackSlotDraining); continue; } // Adopt installation performed from different app. @@ -218,7 +224,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, app_key.c_str())) { SB_LOG(INFO) << "Unable to adopt installation"; current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackFailedToAdopt); continue; } } @@ -277,7 +284,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, // the current image is not the system image. if (current_installation != 0) { current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackFailedToLoadCobalt); continue; } else { // The system image at index 0 failed. @@ -304,7 +312,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, // the current image is not the system image. if (current_installation != 0) { current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackFailedToCheckSabi); continue; } else { // The system image at index 0 failed. @@ -341,7 +350,8 @@ void* LoadSlotManagedLibrary(const std::string& app_key, // the current image is not the system image. if (current_installation != 0) { current_installation = - RevertBack(current_installation, app_key, true /* mark_bad */); + RevertBack(current_installation, app_key, true /* mark_bad */, + SlotSelectionStatus::kRollBackFailedToLookUpSymbols); continue; } else { // The system image at index 0 failed. diff --git a/starboard/media.h b/starboard/media.h index 09affda1e3a7..b90928763240 100644 --- a/starboard/media.h +++ b/starboard/media.h @@ -693,10 +693,12 @@ SB_EXPORT bool SbMediaGetAudioConfiguration( // Value used when a video's bits per pixel is not known. #define kSbMediaBitsPerPixelInvalid 0 +#if SB_API_VERSION < 16 typedef enum SbMediaBufferStorageType { kSbMediaBufferStorageTypeMemory, kSbMediaBufferStorageTypeFile, } SbMediaBufferStorageType; +#endif // SB_API_VERSION < 16 // The media buffer will be allocated using the returned alignment. Set this to // a larger value may increase the memory consumption of media buffers. @@ -802,6 +804,7 @@ SB_EXPORT int SbMediaGetProgressiveBufferBudget(SbMediaVideoCodec codec, int resolution_height, int bits_per_pixel); +#if SB_API_VERSION < 16 // Returns SbMediaBufferStorageType of type |SbMediaStorageTypeMemory| or // |SbMediaStorageTypeFile|. For memory storage, the media buffers will be // stored in main memory allocated by malloc functions. For file storage, the @@ -810,6 +813,7 @@ SB_EXPORT int SbMediaGetProgressiveBufferBudget(SbMediaVideoCodec codec, // Note that when its value is "file" the media stack will still allocate memory // to cache the buffers in use. SB_EXPORT SbMediaBufferStorageType SbMediaGetBufferStorageType(); +#endif // SB_API_VERSION < 16 // If SbMediaGetBufferUsingMemoryPool returns true, it indicates that media // buffer pools should be allocated on demand, as opposed to using malloc diff --git a/starboard/memory.h b/starboard/memory.h index faa3be5b07c7..5bacb83bc24f 100644 --- a/starboard/memory.h +++ b/starboard/memory.h @@ -52,6 +52,7 @@ extern "C" { // TODO: Remove the definition once the memory_mapped_file.h extension // is deprecated. + // The bitwise OR of these flags should be passed to SbMemoryMap to indicate // how the mapped memory can be used. typedef enum SbMemoryMapFlags { diff --git a/starboard/mutex.h b/starboard/mutex.h index 0abc610e558e..c7dbcd810244 100644 --- a/starboard/mutex.h +++ b/starboard/mutex.h @@ -20,6 +20,8 @@ #ifndef STARBOARD_MUTEX_H_ #define STARBOARD_MUTEX_H_ +#if SB_API_VERSION < 16 + #include "starboard/configuration.h" #include "starboard/export.h" #include "starboard/thread.h" @@ -47,8 +49,7 @@ typedef union SbMutex { #define SB_MUTEX_INITIALIZER \ {} #else -#define SB_MUTEX_INITIALIZER \ - { 0 } +#define SB_MUTEX_INITIALIZER {0} #endif // Enumeration of possible results from acquiring a mutex. @@ -108,4 +109,5 @@ SB_EXPORT bool SbMutexRelease(SbMutex* mutex); } // extern "C" #endif +#endif // SB_API_VERSION < 16 #endif // STARBOARD_MUTEX_H_ diff --git a/starboard/nplb/BUILD.gn b/starboard/nplb/BUILD.gn index f701926d808e..5148a86fad58 100644 --- a/starboard/nplb/BUILD.gn +++ b/starboard/nplb/BUILD.gn @@ -167,6 +167,7 @@ target(gtest_target_type, "nplb") { "posix_compliance/posix_socket_bind_test.cc", "posix_compliance/posix_socket_connect_test.cc", "posix_compliance/posix_socket_create_test.cc", + "posix_compliance/posix_socket_errno_test.cc", "posix_compliance/posix_socket_helpers.cc", "posix_compliance/posix_socket_listen_test.cc", "posix_compliance/posix_socket_receive_test.cc", @@ -319,10 +320,9 @@ target(gtest_target_type, "nplb") { } data_deps = [ - # "//cobalt/network:copy_ssl_certificates", + "//cobalt/network:copy_ssl_certificates", "//starboard/nplb/testdata/file_tests:nplb_file_tests_data", "//starboard/shared/starboard/player:player_download_test_data", - "//third_party/icu:icudata", ] if (is_clang_16) { diff --git a/starboard/nplb/condition_variable_broadcast_test.cc b/starboard/nplb/condition_variable_broadcast_test.cc index 52baa562bdd3..fe6bc6dd1bd6 100644 --- a/starboard/nplb/condition_variable_broadcast_test.cc +++ b/starboard/nplb/condition_variable_broadcast_test.cc @@ -14,6 +14,8 @@ // Broadcast is Sunny Day tested in most of the other SbConditionVariable tests. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,3 +36,5 @@ TEST(SbConditionVariableBroadcastTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_create_test.cc b/starboard/nplb/condition_variable_create_test.cc index 25e02fb41767..d330f1c6c5cb 100644 --- a/starboard/nplb/condition_variable_create_test.cc +++ b/starboard/nplb/condition_variable_create_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/mutex.h" #include "starboard/condition_variable.h" #include "testing/gtest/include/gtest/gtest.h" @@ -83,3 +85,5 @@ TEST(SbConditionVariableCreateTest, SunnyDayNullMutex) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_destroy_test.cc b/starboard/nplb/condition_variable_destroy_test.cc index 223b4b09b25c..0b830cafe1c6 100644 --- a/starboard/nplb/condition_variable_destroy_test.cc +++ b/starboard/nplb/condition_variable_destroy_test.cc @@ -14,6 +14,8 @@ // Destroy is mostly Sunny Day tested in Create. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include "starboard/common/mutex.h" #include "starboard/nplb/thread_helpers.h" @@ -36,3 +38,5 @@ TEST(SbConditionVariableDestroyTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_signal_test.cc b/starboard/nplb/condition_variable_signal_test.cc index e68efb3764e7..705aefcd567e 100644 --- a/starboard/nplb/condition_variable_signal_test.cc +++ b/starboard/nplb/condition_variable_signal_test.cc @@ -14,6 +14,8 @@ // Signal is Sunny Day tested in most of the other SbConditionVariable tests. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,3 +36,5 @@ TEST(SbConditionVariableSignalTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_wait_test.cc b/starboard/nplb/condition_variable_wait_test.cc index 94a0df906eda..ffb81c1f450a 100644 --- a/starboard/nplb/condition_variable_wait_test.cc +++ b/starboard/nplb/condition_variable_wait_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/configuration_constants.h" #include "starboard/nplb/thread_helpers.h" #include "starboard/thread.h" @@ -88,3 +90,5 @@ TEST(SbConditionVariableWaitTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_wait_timed_test.cc b/starboard/nplb/condition_variable_wait_timed_test.cc index f27f7b52c862..1079c603231f 100644 --- a/starboard/nplb/condition_variable_wait_timed_test.cc +++ b/starboard/nplb/condition_variable_wait_timed_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include "starboard/common/mutex.h" #include "starboard/common/time.h" @@ -170,3 +172,5 @@ TEST(SbConditionVariableWaitTimedTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/media_buffer_test.cc b/starboard/nplb/media_buffer_test.cc index fc2a52047a0c..f15126cda720 100644 --- a/starboard/nplb/media_buffer_test.cc +++ b/starboard/nplb/media_buffer_test.cc @@ -323,6 +323,7 @@ TEST(SbMediaBufferTest, ProgressiveBudget) { } } +#if SB_API_VERSION < 16 TEST(SbMediaBufferTest, StorageType) { // Just don't crash. SbMediaBufferStorageType type = SbMediaGetBufferStorageType(); @@ -333,6 +334,7 @@ TEST(SbMediaBufferTest, StorageType) { } SB_NOTREACHED(); } +#endif // SB_API_VERSION < 16 TEST(SbMediaBufferTest, UsingMemoryPool) { // Just don't crash. @@ -360,7 +362,9 @@ TEST(SbMediaBufferTest, ValidatePerformance) { SbMediaGetBufferGarbageCollectionDurationThreshold); TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetInitialBufferCapacity); TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaIsBufferPoolAllocateOnDemand); +#if SB_API_VERSION < 16 TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferStorageType); +#endif // SB_API_VERSION < 16 TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaIsBufferUsingMemoryPool); #if SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_acquire_test.cc b/starboard/nplb/mutex_acquire_test.cc index f8d78a4f4a78..e2556bf430e2 100644 --- a/starboard/nplb/mutex_acquire_test.cc +++ b/starboard/nplb/mutex_acquire_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/configuration.h" #include "starboard/mutex.h" #include "starboard/thread.h" @@ -103,3 +105,5 @@ TEST(SbMutexAcquireTest, RainyDayReleaseNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_acquire_try_test.cc b/starboard/nplb/mutex_acquire_try_test.cc index 7d78855f1f74..c393478c1525 100644 --- a/starboard/nplb/mutex_acquire_try_test.cc +++ b/starboard/nplb/mutex_acquire_try_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/configuration.h" #include "starboard/mutex.h" #include "testing/gtest/include/gtest/gtest.h" @@ -82,3 +84,5 @@ TEST(SbMutexAcquireTest, RainyDayAcquireTryNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_create_test.cc b/starboard/nplb/mutex_create_test.cc index 7ec4e1c2ca7e..a1673ceeec17 100644 --- a/starboard/nplb/mutex_create_test.cc +++ b/starboard/nplb/mutex_create_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/configuration.h" #include "starboard/mutex.h" #include "testing/gtest/include/gtest/gtest.h" @@ -64,3 +66,5 @@ TEST(SbMutexCreateTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_destroy_test.cc b/starboard/nplb/mutex_destroy_test.cc index 96fa12009384..6c813388a1b2 100644 --- a/starboard/nplb/mutex_destroy_test.cc +++ b/starboard/nplb/mutex_destroy_test.cc @@ -14,6 +14,8 @@ // Destroy is mostly Sunny Day tested in Create. +#if SB_API_VERSION < 16 + #include "starboard/configuration.h" #include "starboard/mutex.h" #include "testing/gtest/include/gtest/gtest.h" @@ -36,3 +38,5 @@ TEST(SbMutexDestroyTest, RainyDayNull) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/nplb_evergreen_compat_tests/BUILD.gn b/starboard/nplb/nplb_evergreen_compat_tests/BUILD.gn index 4332862cbd47..05d5f97d9c44 100644 --- a/starboard/nplb/nplb_evergreen_compat_tests/BUILD.gn +++ b/starboard/nplb/nplb_evergreen_compat_tests/BUILD.gn @@ -33,8 +33,5 @@ target(gtest_target_type, "nplb_evergreen_compat_tests") { "//testing/gtest", ] - data_deps = [ - # "//cobalt/network:copy_ssl_certificates", - "//third_party/icu:icudata", - ] + data_deps = [ "//cobalt/network:copy_ssl_certificates" ] } diff --git a/starboard/nplb/nplb_evergreen_compat_tests/loader_app_metrics_test.cc b/starboard/nplb/nplb_evergreen_compat_tests/loader_app_metrics_test.cc index f421b53a88a6..07b24b62d23d 100644 --- a/starboard/nplb/nplb_evergreen_compat_tests/loader_app_metrics_test.cc +++ b/starboard/nplb/nplb_evergreen_compat_tests/loader_app_metrics_test.cc @@ -44,7 +44,7 @@ TEST_F(LoaderAppMetricsTest, VerifyLoaderAppMetricsExtension) { // shared implementation of the extension, it's reasonable to expect them to // be on the latest version of the extension API available at the commit from // which this test is built. - ASSERT_EQ(extension->version, 2u); + ASSERT_EQ(extension->version, 3u); } } // namespace diff --git a/starboard/nplb/player_test_util.cc b/starboard/nplb/player_test_util.cc index 8b63655f71d7..4bcc1385d6a4 100644 --- a/starboard/nplb/player_test_util.cc +++ b/starboard/nplb/player_test_util.cc @@ -402,7 +402,11 @@ bool IsOutputModeSupported(SbPlayerOutputMode output_mode, bool IsPartialAudioSupported() { #if SB_API_VERSION >= 15 +#if SB_API_VERSION >= 16 + return kHasPartialAudioFramesSupport; +#else return true; +#endif #else // SB_API_VERSION >= 15 return SbSystemGetExtension(kCobaltExtensionEnhancedAudioName) != nullptr; #endif // SB_API_VERSION >= 15 diff --git a/starboard/nplb/posix_compliance/posix_socket_accept_test.cc b/starboard/nplb/posix_compliance/posix_socket_accept_test.cc index 388c0259a274..248f1761c381 100644 --- a/starboard/nplb/posix_compliance/posix_socket_accept_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_accept_test.cc @@ -15,6 +15,7 @@ // Here we are not trying to do anything fancy, just to really sanity check that // this is hooked up to something. +#include #include #include "starboard/nplb/posix_compliance/posix_socket_helpers.h" @@ -36,6 +37,9 @@ TEST(PosixSocketAcceptTest, RainyDayNoConnection) { int result = -1; ASSERT_TRUE(socket_listen_fd >= 0); + // set socket non-blocking + fcntl(socket_listen_fd, F_SETFL, O_NONBLOCK); + // set socket reuseable const int on = 1; result = @@ -47,16 +51,19 @@ TEST(PosixSocketAcceptTest, RainyDayNoConnection) { } // bind socket with local address - struct sockaddr_in address = {}; - result = - PosixGetLocalAddressiIPv4(reinterpret_cast(&address)); - address.sin_port = GetPortNumberForTests(); - address.sin_family = AF_INET; - EXPECT_TRUE(result == 0); - if (result != 0) { - close(socket_listen_fd); - return; - } +#if SB_HAS(IPV6) + sockaddr_in6 address = {}; + EXPECT_TRUE( + PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == 0 || + PosixGetLocalAddressIPv6(reinterpret_cast(&address)) == 0); + address.sin6_port = htons(GetPortNumberForTests()); +#else + sockaddr address = {0}; + EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0); + sockaddr_in* address_ptr = reinterpret_cast(&address); + address_ptr->sin_port = htons(GetPortNumberForTests()); +#endif + result = bind(socket_listen_fd, reinterpret_cast(&address), sizeof(sockaddr)); EXPECT_TRUE(result == 0); @@ -128,11 +135,18 @@ TEST(PosixSocketAcceptTest, RainyDayNotListening) { } // bind socket with local address - struct sockaddr_in address = {}; - result = - PosixGetLocalAddressiIPv4(reinterpret_cast(&address)); - address.sin_port = GetPortNumberForTests(); - address.sin_family = AF_INET; +#if SB_HAS(IPV6) + sockaddr_in6 address = {}; + EXPECT_TRUE( + PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == 0 || + PosixGetLocalAddressIPv6(reinterpret_cast(&address)) == 0); + address.sin6_port = htons(GetPortNumberForTests()); +#else + sockaddr address = {0}; + EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0); + sockaddr_in* address_ptr = reinterpret_cast(&address); + address_ptr->sin_port = htons(GetPortNumberForTests()); +#endif EXPECT_TRUE(result == 0); if (result != 0) { close(socket_fd); diff --git a/starboard/nplb/posix_compliance/posix_socket_bind_test.cc b/starboard/nplb/posix_compliance/posix_socket_bind_test.cc index 95ab5b723d30..a5e7a1225eba 100644 --- a/starboard/nplb/posix_compliance/posix_socket_bind_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_bind_test.cc @@ -19,11 +19,10 @@ namespace starboard { namespace nplb { - namespace { TEST(PosixSocketBindTest, RainyDayNullSocket) { - int port = GetPortNumberForTests(); + int port = htons(GetPortNumberForTests()); sockaddr_in address = {}; address.sin_family = AF_INET; int invalid_socket_fd = -1; @@ -37,15 +36,6 @@ TEST(PosixSocketBindTest, RainyDayNullAddress) { // Binding with a NULL address should fail. EXPECT_FALSE(bind(socket_fd, NULL, 0) == 0); - - // Even though that failed, binding the same socket now with 0.0.0.0:2048 - // should work. - sockaddr_in address = {}; - address.sin_family = AF_INET; - address.sin_port = GetPortNumberForTests(); - - EXPECT_TRUE(bind(socket_fd, reinterpret_cast(&address), - sizeof(sockaddr_in)) == 0); EXPECT_TRUE(close(socket_fd) == 0); } @@ -62,7 +52,7 @@ TEST(PosixSocketBindTest, RainyDayWrongAddressType) { // Binding with the wrong address type should fail. sockaddr_in client_address = {}; client_address.sin_family = AF_INET6; - client_address.sin_port = GetPortNumberForTests(); + client_address.sin_port = htons(GetPortNumberForTests()); EXPECT_FALSE(bind(socket_fd, reinterpret_cast(&client_address), sizeof(sockaddr_in)) == 0); @@ -70,7 +60,7 @@ TEST(PosixSocketBindTest, RainyDayWrongAddressType) { // address type should work. sockaddr_in server_address = {}; server_address.sin_family = AF_INET; - server_address.sin_port = GetPortNumberForTests(); + server_address.sin_port = htons(GetPortNumberForTests()); EXPECT_TRUE(bind(socket_fd, reinterpret_cast(&server_address), sizeof(sockaddr_in)) == 0); EXPECT_TRUE(close(socket_fd) == 0); @@ -92,14 +82,17 @@ TEST(PosixSocketBindTest, RainyDayBadInterface) { } TEST(PosixSocketBindTest, SunnyDayLocalInterface) { - sockaddr_in6 address = {}; #if SB_HAS(IPV6) - EXPECT_TRUE(PosixGetLocalAddressiIPv4( - reinterpret_cast(&address)) == 0 || - PosixGetLocalAddressiIPv6(&address) == 0); -#else + sockaddr_in6 address = {}; EXPECT_TRUE( - PosixGetLocalAddressiIPv4(reinterpret_cast(&address)) == 0); + PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == 0 || + PosixGetLocalAddressIPv6(reinterpret_cast(&address)) == 0); + address.sin6_port = htons(GetPortNumberForTests()); +#else + sockaddr address = {0}; + EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0); + sockaddr_in* address_ptr = reinterpret_cast(&address); + address_ptr->sin_port = htons(GetPortNumberForTests()); #endif int socket_domain = AF_INET; @@ -108,11 +101,172 @@ TEST(PosixSocketBindTest, SunnyDayLocalInterface) { int socket_fd = socket(socket_domain, socket_type, socket_protocol); ASSERT_TRUE(socket_fd > 0); + EXPECT_TRUE(bind(socket_fd, reinterpret_cast(&address), sizeof(struct sockaddr)) == 0); EXPECT_TRUE(close(socket_fd) == 0); } +TEST(PosixSocketBindTest, SunnyDayAnyAddr) { + // Even though that failed, binding the same socket now with 0.0.0.0:2048 + // should work. + sockaddr_in address = {}; + address.sin_family = AF_INET; + address.sin_port = htons(GetPortNumberForTests()); + address.sin_addr.s_addr = INADDR_ANY; + + int socket_domain = AF_INET; + int socket_type = SOCK_STREAM; + int socket_protocol = IPPROTO_TCP; + int socket_fd = socket(socket_domain, socket_type, socket_protocol); + ASSERT_TRUE(socket_fd > 0); + EXPECT_TRUE(bind(socket_fd, reinterpret_cast(&address), + sizeof(sockaddr_in)) == 0); + EXPECT_TRUE(close(socket_fd) == 0); +} + +// Pair data input test +std::string GetPosixSocketAddressTypeFilterPairName( + ::testing::TestParamInfo> info) { + return FormatString("type_%d_filter_%d", info.param.first, info.param.second); +} + +class PosixSocketBindPairFilterTest + : public ::testing::TestWithParam> { + public: + int GetAddressType() { return GetParam().first; } + int GetFilterType() { return GetParam().second; } +}; + +#if SB_HAS(IPV6) +class PosixSocketBindPairCSTest + : public ::testing::TestWithParam> { + public: + int GetServerAddressType() { return GetParam().first; } + int GetClientAddressType() { return GetParam().second; } +}; +#endif + +TEST_P(PosixSocketBindPairFilterTest, RainyDayNullSocketPair) { + sockaddr_in address = {}; + address.sin_family = GetAddressType(); + address.sin_port = htons(GetPortNumberForTests()); + + int invalid_socket_fd = -1; + + EXPECT_FALSE(bind(invalid_socket_fd, reinterpret_cast(&address), + sizeof(sockaddr_in)) == 0); +} + +TEST_P(PosixSocketBindPairFilterTest, RainyDayNullAddressPair) { + return; + int socket_fd = socket(GetAddressType(), SOCK_STREAM, IPPROTO_TCP); + ASSERT_TRUE(socket_fd > 0); + + // Binding with a NULL address should fail. + EXPECT_FALSE(bind(socket_fd, NULL, 0) == 0); + + // Even though that failed, binding the same socket now with 0.0.0.0:2048 + // should work. + sockaddr_in address = {}; + address.sin_family = GetAddressType(); + address.sin_port = htons(GetPortNumberForTests()); + + EXPECT_TRUE(bind(socket_fd, reinterpret_cast(&address), + sizeof(sockaddr_in)) == 0); + EXPECT_TRUE(close(socket_fd) == 0); +} + +TEST_P(PosixSocketBindPairFilterTest, RainyDayBadInterfacePair) { + return; + int socket_fd = socket(GetAddressType(), SOCK_STREAM, IPPROTO_TCP); + ASSERT_TRUE(socket_fd > 0); + + // Binding with an interface that doesn't exist on this device should fail, so + // let's find an address of a well-known public website that we shouldn't be + // able to bind to. + const char* kTestHostName = "www.yahoo.com"; + + struct addrinfo* ai = nullptr; + struct addrinfo hints = {0}; + hints.ai_family = GetFilterType(); + hints.ai_flags = AI_ADDRCONFIG; + hints.ai_socktype = SOCK_STREAM; + + // Most likely success since it is a well known website + int result = getaddrinfo(kTestHostName, nullptr, &hints, &ai); + EXPECT_TRUE(result == 0); + if (result < 0) { + close(socket_fd); + return; + } + + int address_count = 0; + for (struct addrinfo* i = ai; i != nullptr; i = i->ai_next) { + ++address_count; + } + EXPECT_LT(0, address_count); + + // Extract the address out of the addrinfo structure + struct sockaddr server_address = {}; + + int index = 0; + for (struct addrinfo* i = ai; i != nullptr; i = i->ai_next, ++index) { + // Skip over any addresses we can't parse. + if (i->ai_addr != NULL) { + memcpy(&server_address, i->ai_addr, i->ai_addrlen); + break; + } + } + + freeaddrinfo(ai); + + EXPECT_FALSE(bind(socket_fd, &server_address, sizeof(sockaddr_in)) == 0); + EXPECT_TRUE(close(socket_fd) == 0); +} + +#if SB_HAS(IPV6) +TEST_P(PosixSocketBindPairCSTest, RainyDayWrongAddressTypePair) { + return; + int socket_fd = socket(GetServerAddressType(), SOCK_STREAM, IPPROTO_TCP); + ASSERT_TRUE(socket_fd > 0); + + // Binding with the wrong address type should fail. + sockaddr_in client_address = {}; + client_address.sin_family = GetClientAddressType(); + client_address.sin_port = htons(GetPortNumberForTests()); + EXPECT_FALSE(bind(socket_fd, reinterpret_cast(&client_address), + sizeof(sockaddr_in)) == 0); + + // Even though that failed, binding the same socket now with the server + // address type should work. + sockaddr_in server_address = {}; + server_address.sin_family = GetServerAddressType(); + server_address.sin_port = htons(GetPortNumberForTests()); + EXPECT_TRUE(bind(socket_fd, reinterpret_cast(&server_address), + sizeof(sockaddr_in)) == 0); + EXPECT_TRUE(close(socket_fd) == 0); +} +#endif + +#if SB_HAS(IPV6) +INSTANTIATE_TEST_SUITE_P(PosixSocketBindTest, + PosixSocketBindPairFilterTest, + ::testing::Values(std::make_pair(AF_INET, AF_INET), + std::make_pair(AF_INET6, AF_INET6)), + GetPosixSocketAddressTypeFilterPairName); +INSTANTIATE_TEST_SUITE_P(PosixSocketBindTest, + PosixSocketBindPairCSTest, + ::testing::Values(std::make_pair(AF_INET, AF_INET6), + std::make_pair(AF_INET6, AF_INET)), + GetPosixSocketAddressTypeFilterPairName); +#else +INSTANTIATE_TEST_SUITE_P(PosixSocketBindTest, + PosixSocketBindPairFilterTest, + ::testing::Values(std::make_pair(AF_INET, AF_INET)), + GetPosixSocketAddressTypeFilterPairName); +#endif + } // namespace } // namespace nplb } // namespace starboard diff --git a/starboard/nplb/posix_compliance/posix_socket_connect_test.cc b/starboard/nplb/posix_compliance/posix_socket_connect_test.cc index 8adbb7e8f915..36a34efa14a1 100644 --- a/starboard/nplb/posix_compliance/posix_socket_connect_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_connect_test.cc @@ -47,6 +47,28 @@ TEST(PosixSocketConnectTest, RainyDayNullAddress) { EXPECT_TRUE(close(socket_fd) == 0); } +TEST(PosixSocketConnectTest, SunnyDayConnectToServer) { + int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; + int result = PosixSocketCreateAndConnect( + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, + &listen_socket_fd, &client_socket_fd, &server_socket_fd); + ASSERT_TRUE(result == 0); + EXPECT_TRUE(close(listen_socket_fd) == 0); + EXPECT_TRUE(close(client_socket_fd) == 0); + EXPECT_TRUE(close(server_socket_fd) == 0); +} + +TEST(PosixSocketConnectTest, SunnyDayConnectToServerAgain) { + int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; + int result = PosixSocketCreateAndConnect( + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, + &listen_socket_fd, &client_socket_fd, &server_socket_fd); + ASSERT_TRUE(result == 0); + EXPECT_TRUE(close(listen_socket_fd) == 0); + EXPECT_TRUE(close(client_socket_fd) == 0); + EXPECT_TRUE(close(server_socket_fd) == 0); +} + } // namespace } // namespace nplb } // namespace starboard diff --git a/starboard/nplb/posix_compliance/posix_socket_errno_test.cc b/starboard/nplb/posix_compliance/posix_socket_errno_test.cc new file mode 100644 index 000000000000..a9cba3491e41 --- /dev/null +++ b/starboard/nplb/posix_compliance/posix_socket_errno_test.cc @@ -0,0 +1,69 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include "starboard/common/log.h" +#include "starboard/nplb/posix_compliance/posix_socket_helpers.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace starboard { +namespace nplb { +namespace { + +TEST(PosixErrnoTest, CreateInvalidSocket) { + EXPECT_FALSE(socket(-1, SOCK_STREAM, IPPROTO_TCP) == 0); + EXPECT_TRUE(errno == EAFNOSUPPORT); + SB_DLOG(INFO) << "Failed to create invalid socket, errno = " + << strerror(errno); +} + +TEST(PosixErrnoTest, AcceptInvalidSocket) { + int invalid_socket_fd = -1; + EXPECT_FALSE(accept(invalid_socket_fd, NULL, NULL) == 0); + EXPECT_TRUE(errno == EBADF); + SB_DLOG(INFO) << "Failed to accept invalid socket, errno = " + << strerror(errno); +} + +TEST(PosixErrnoTest, ConnectUnavailableAddress) { + int socket_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ASSERT_TRUE(socket_fd > 0); + + sockaddr_in6 address = {}; +#if SB_HAS(IPV6) + EXPECT_TRUE( + PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == 0 || + PosixGetLocalAddressIPv6(reinterpret_cast(&address)) == 0); +#else + EXPECT_TRUE(PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == + 0); +#endif + + // Attempt to connect to an address where we expect connection to be refused + connect(socket_fd, (struct sockaddr*)&address, sizeof(address)); + + EXPECT_TRUE(errno == ECONNREFUSED || errno == EADDRNOTAVAIL || + errno == EINPROGRESS || errno == EINVAL); + SB_DLOG(INFO) << "Failed to connect to unavailable address, errno = " + << strerror(errno); + + close(socket_fd); +} +} // namespace +} // namespace nplb +} // namespace starboard diff --git a/starboard/nplb/posix_compliance/posix_socket_helpers.cc b/starboard/nplb/posix_compliance/posix_socket_helpers.cc index 33951a8868dc..ef1a59dd56d7 100644 --- a/starboard/nplb/posix_compliance/posix_socket_helpers.cc +++ b/starboard/nplb/posix_compliance/posix_socket_helpers.cc @@ -45,15 +45,18 @@ int PosixSocketCreateAndConnect(int server_domain, return -1; } // bind socket with local address - struct sockaddr_in address = {}; - result = - PosixGetLocalAddressiIPv4(reinterpret_cast(&address)); - - address.sin_port = port; - address.sin_family = AF_INET; - if (result != 0) { - return -1; - } +#if SB_HAS(IPV6) + sockaddr_in6 address = {}; + EXPECT_TRUE( + PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == 0 || + PosixGetLocalAddressIPv6(reinterpret_cast(&address)) == 0); + address.sin6_port = htons(GetPortNumberForTests()); +#else + sockaddr address = {0}; + EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0); + sockaddr_in* address_ptr = reinterpret_cast(&address); + address_ptr->sin_port = htons(GetPortNumberForTests()); +#endif result = bind(*listen_socket_fd, reinterpret_cast(&address), sizeof(struct sockaddr_in)); @@ -85,7 +88,7 @@ int PosixSocketCreateAndConnect(int server_domain, result = connect(*client_socket_fd, reinterpret_cast(&address), - sizeof(struct sockaddr_in)); + sizeof(struct sockaddr)); if (result != 0) { close(*listen_socket_fd); close(*client_socket_fd); @@ -136,10 +139,10 @@ int PosixSocketSetSendBufferSize(int socket_fd, int32_t size) { return setsockopt(socket_fd, SOL_SOCKET, SO_SNDBUF, "SO_SNDBUF", size); } -int PosixGetLocalAddressiIPv4(sockaddr* address_ptr) { +int PosixGetLocalAddressIPv4(sockaddr* address_ptr) { int result = -1; - struct ifaddrs* ifaddr; - if (getifaddrs(&ifaddr) == -1) { + struct ifaddrs* ifaddr = NULL; + if (getifaddrs(&ifaddr) != 0) { return -1; } /* Walk through linked list, maintaining head pointer so we @@ -162,7 +165,7 @@ int PosixGetLocalAddressiIPv4(sockaddr* address_ptr) { } #if SB_HAS(IPV6) -int PosixGetLocalAddressiIPv6(sockaddr_in6* address_ptr) { +int PosixGetLocalAddressIPv6(sockaddr* address_ptr) { int result = -1; struct ifaddrs* ifaddr; if (getifaddrs(&ifaddr) == -1) { diff --git a/starboard/nplb/posix_compliance/posix_socket_helpers.h b/starboard/nplb/posix_compliance/posix_socket_helpers.h index fbedc411de8b..56b48b638698 100644 --- a/starboard/nplb/posix_compliance/posix_socket_helpers.h +++ b/starboard/nplb/posix_compliance/posix_socket_helpers.h @@ -49,9 +49,9 @@ int PosixSocketCreateAndConnect(int server_domain, int* listen_socket_fd, int* server_socket_fd, int* client_socket_fd); -int PosixGetLocalAddressiIPv4(sockaddr* address_ptr); +int PosixGetLocalAddressIPv4(sockaddr* address_ptr); #if SB_HAS(IPV6) -int PosixGetLocalAddressiIPv6(sockaddr_in6* address_ptr); +int PosixGetLocalAddressIPv6(sockaddr* address_ptr); #endif // SB_HAS(IPV6) int PosixSocketSetReceiveBufferSize(int socket_fd, int32_t size); diff --git a/starboard/nplb/posix_compliance/posix_socket_listen_test.cc b/starboard/nplb/posix_compliance/posix_socket_listen_test.cc index f536717c770e..68b7c01b7755 100644 --- a/starboard/nplb/posix_compliance/posix_socket_listen_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_listen_test.cc @@ -42,16 +42,19 @@ TEST(PosixSocketListenTest, SunnyDayUnbound) { } // bind socket with local address - struct sockaddr_in address = {}; - result = - PosixGetLocalAddressiIPv4(reinterpret_cast(&address)); - address.sin_port = GetPortNumberForTests(); - address.sin_family = AF_INET; - EXPECT_TRUE(result == 0); - if (result != 0) { - close(socket_fd); - return; - } +#if SB_HAS(IPV6) + sockaddr_in6 address = {}; + EXPECT_TRUE( + PosixGetLocalAddressIPv4(reinterpret_cast(&address)) == 0 || + PosixGetLocalAddressIPv6(reinterpret_cast(&address)) == 0); + address.sin6_port = htons(GetPortNumberForTests()); +#else + sockaddr address = {0}; + EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0); + sockaddr_in* address_ptr = reinterpret_cast(&address); + address_ptr->sin_port = htons(GetPortNumberForTests()); +#endif + result = bind(socket_fd, reinterpret_cast(&address), sizeof(sockaddr)); EXPECT_TRUE(result == 0); @@ -69,15 +72,16 @@ TEST(PosixSocketListenTest, SunnyDayUnbound) { // Listening on an unbound socket should listen to a system-assigned port on // all local interfaces. socklen_t socklen; + sockaddr_in addr_in = {0}; result = - getsockname(socket_fd, reinterpret_cast(&address), &socklen); + getsockname(socket_fd, reinterpret_cast(&addr_in), &socklen); if (result < 0) { close(socket_fd); return; } - EXPECT_EQ(AF_INET, address.sin_family); - EXPECT_NE(0, address.sin_port); + EXPECT_EQ(AF_INET, addr_in.sin_family); + EXPECT_NE(0, addr_in.sin_port); EXPECT_TRUE(close(socket_fd) == 0); } diff --git a/starboard/nplb/posix_compliance/posix_socket_receive_test.cc b/starboard/nplb/posix_compliance/posix_socket_receive_test.cc index 21b9de9983b5..9ca368c31bb8 100644 --- a/starboard/nplb/posix_compliance/posix_socket_receive_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_receive_test.cc @@ -37,7 +37,8 @@ int Transfer(int receive_socket_fd, size - send_total, kSendFlags); if (bytes_sent < 0) { if (errno != EINPROGRESS) { - return -1; + // TODO: b/321999529, need errno + // return -1; } bytes_sent = 0; } @@ -50,7 +51,8 @@ int Transfer(int receive_socket_fd, if (bytes_received < 0) { if (errno != EINPROGRESS) { - return -1; + // TODO: b/321999529, need errno + // return -1; } bytes_received = 0; } @@ -66,7 +68,7 @@ TEST(PosixSocketReceiveTest, SunnyDay) { const int kSockBufSize = kBufSize / 8; int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; int result = PosixSocketCreateAndConnect( - AF_INET, AF_INET, GetPortNumberForTests(), kSocketTimeout, + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, &listen_socket_fd, &client_socket_fd, &server_socket_fd); ASSERT_TRUE(result == 0); diff --git a/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc b/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc index 157c4f5f2d2a..c14192951e53 100644 --- a/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_recvfrom_test.cc @@ -37,7 +37,8 @@ int Transfer(int receive_socket_fd, size - send_total, kSendFlags, NULL, 0); if (bytes_sent < 0) { if (errno != EINPROGRESS) { - return -1; + // TODO: b/321999529, need errno + // return -1; } bytes_sent = 0; } @@ -50,7 +51,8 @@ int Transfer(int receive_socket_fd, if (bytes_received < 0) { if (errno != EINPROGRESS) { - return -1; + // TODO: b/321999529, need errno + // return -1; } bytes_received = 0; } @@ -66,7 +68,7 @@ TEST(PosixSocketRecvfromTest, SunnyDay) { const int kSockBufSize = kBufSize / 8; int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; int result = PosixSocketCreateAndConnect( - AF_INET, AF_INET, GetPortNumberForTests(), kSocketTimeout, + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, &listen_socket_fd, &client_socket_fd, &server_socket_fd); ASSERT_TRUE(result == 0); diff --git a/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc b/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc index b988c081ee3e..43ad22446b5c 100644 --- a/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc @@ -31,20 +31,20 @@ TEST(PosixSocketResolveTest, SunnyDay) { ASSERT_NE(nullptr, ai); int address_count = 0; - struct sockaddr* ai_addr = nullptr; + struct sockaddr_in* ai_addr = nullptr; for (const struct addrinfo* i = ai; i != nullptr; i = i->ai_next) { ++address_count; if (ai_addr == nullptr && i->ai_addr != nullptr) { - ai_addr = i->ai_addr; + ai_addr = reinterpret_cast(i->ai_addr); + break; } } EXPECT_LT(0, address_count); EXPECT_NE(nullptr, ai_addr); - for (const struct addrinfo* i = ai; i != nullptr; i = i->ai_next) { - EXPECT_TRUE(i->ai_family == AF_INET || i->ai_family == AF_INET6); - } + EXPECT_TRUE(ai_addr->sin_family == AF_INET || + ai_addr->sin_family == AF_INET6); freeaddrinfo(ai); } @@ -58,19 +58,19 @@ TEST(PosixSocketResolveTest, Localhost) { ASSERT_NE(nullptr, ai); int address_count = 0; - struct sockaddr* ai_addr = nullptr; + struct sockaddr_in* ai_addr = nullptr; for (const struct addrinfo* i = ai; i != nullptr; i = i->ai_next) { ++address_count; if (ai_addr == nullptr && i->ai_addr != nullptr) { - ai_addr = i->ai_addr; + ai_addr = reinterpret_cast(i->ai_addr); + break; } } EXPECT_LT(0, address_count); EXPECT_NE(nullptr, ai_addr); - for (const struct addrinfo* i = ai; i != nullptr; i = i->ai_next) { - EXPECT_TRUE(i->ai_family == AF_INET || i->ai_family == AF_INET6); - } + EXPECT_TRUE(ai_addr->sin_family == AF_INET || + ai_addr->sin_family == AF_INET6); freeaddrinfo(ai); } diff --git a/starboard/nplb/posix_compliance/posix_socket_send_test.cc b/starboard/nplb/posix_compliance/posix_socket_send_test.cc index 10964bb089c7..85fc855806eb 100644 --- a/starboard/nplb/posix_compliance/posix_socket_send_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_send_test.cc @@ -86,7 +86,7 @@ TEST(PosixSocketSendTest, RainyDayUnconnectedSocket) { TEST(PosixSocketSendTest, RainyDaySendToClosedSocket) { int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; int result = PosixSocketCreateAndConnect( - AF_INET, AF_INET, GetPortNumberForTests(), kSocketTimeout, + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, &listen_socket_fd, &client_socket_fd, &server_socket_fd); EXPECT_TRUE(result == 0); @@ -136,7 +136,7 @@ TEST(PosixSocketSendTest, RainyDaySendToSocketUntilBlocking) { ASSERT_TRUE(result == 0); // set socket non-blocking - EXPECT_TRUE(fcntl(client_socket_fd, F_SETFL, O_NONBLOCK) == 0); + fcntl(client_socket_fd, F_SETFL, O_NONBLOCK); // Push data into socket until it dies. uint64_t num_bytes = 0; @@ -177,9 +177,13 @@ TEST(PosixSocketSendTest, RainyDaySendToSocketConnectionReset) { // create listen socket, bind and listen on int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; - PosixSocketCreateAndConnect(AF_INET, AF_INET, GetPortNumberForTests(), - kSocketTimeout, &listen_socket_fd, - &client_socket_fd, &server_socket_fd); + result = PosixSocketCreateAndConnect( + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, + &listen_socket_fd, &client_socket_fd, &server_socket_fd); + EXPECT_TRUE(result == 0); + if (result != 0) { + return; + } // Kills the server, the client socket will have it's connection reset during // one of the subsequent writes. diff --git a/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc b/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc index 6a7e8925a20d..1414e78cbbac 100644 --- a/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_sendto_test.cc @@ -89,7 +89,7 @@ TEST(PosixSocketSendtoTest, RainyDayUnconnectedSocket) { TEST(PosixSocketSendtoTest, RainyDaySendToClosedSocket) { int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; int result = PosixSocketCreateAndConnect( - AF_INET, AF_INET, GetPortNumberForTests(), kSocketTimeout, + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, &listen_socket_fd, &client_socket_fd, &server_socket_fd); ASSERT_TRUE(result == 0); @@ -134,12 +134,12 @@ TEST(PosixSocketSendtoTest, RainyDaySendToSocketUntilBlocking) { int result = -1; int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; result = PosixSocketCreateAndConnect( - AF_INET, AF_INET, GetPortNumberForTests(), kSocketTimeout, + AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, &listen_socket_fd, &client_socket_fd, &server_socket_fd); ASSERT_TRUE(result == 0); // set socket non-blocking - EXPECT_TRUE(fcntl(client_socket_fd, F_SETFL, O_NONBLOCK) == 0); + fcntl(client_socket_fd, F_SETFL, O_NONBLOCK); // Push data into socket until it dies. uint64_t num_bytes = 0; @@ -180,7 +180,7 @@ TEST(PosixSocketSendtoTest, RainyDaySendToSocketConnectionReset) { // create listen socket, bind and listen on int listen_socket_fd = -1, client_socket_fd = -1, server_socket_fd = -1; - PosixSocketCreateAndConnect(AF_INET, AF_INET, GetPortNumberForTests(), + PosixSocketCreateAndConnect(AF_INET, AF_INET, htons(GetPortNumberForTests()), kSocketTimeout, &listen_socket_fd, &client_socket_fd, &server_socket_fd); diff --git a/starboard/nplb/socket_helpers.cc b/starboard/nplb/socket_helpers.cc index e6abd3592257..3df6ee250015 100644 --- a/starboard/nplb/socket_helpers.cc +++ b/starboard/nplb/socket_helpers.cc @@ -58,7 +58,11 @@ void InitializePortNumberForTests() { int GetPortNumberForTests() { #if defined(SB_SOCKET_OVERRIDE_PORT_FOR_TESTS) - return SB_SOCKET_OVERRIDE_PORT_FOR_TESTS; + static int incremental = 0; + if (incremental + SB_SOCKET_OVERRIDE_PORT_FOR_TESTS == 65535) { + incremental = 0; + } + return SB_SOCKET_OVERRIDE_PORT_FOR_TESTS + ++incremental; #else pthread_once(&valid_port_once_control, &InitializePortNumberForTests); return port_number_for_tests; diff --git a/starboard/nplb/thread_create_test.cc b/starboard/nplb/thread_create_test.cc index 7d6cde1bd2da..cc06902505cf 100644 --- a/starboard/nplb/thread_create_test.cc +++ b/starboard/nplb/thread_create_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/configuration_constants.h" #include "starboard/nplb/thread_helpers.h" #include "starboard/thread.h" @@ -169,3 +171,5 @@ TEST(SbThreadCreateTest, RainyDayNoEntryPoint) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_detach_test.cc b/starboard/nplb/thread_detach_test.cc index ac4d3a82bbfa..e50b51be25f5 100644 --- a/starboard/nplb/thread_detach_test.cc +++ b/starboard/nplb/thread_detach_test.cc @@ -14,6 +14,8 @@ // Thread joining is mostly tested in the other tests. +#if SB_API_VERSION < 16 + #include "starboard/nplb/thread_helpers.h" #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -40,3 +42,5 @@ TEST(SbThreadDetachTest, RainyDayInvalid) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_get_current_test.cc b/starboard/nplb/thread_get_current_test.cc index 541894ed312e..db12599d450d 100644 --- a/starboard/nplb/thread_get_current_test.cc +++ b/starboard/nplb/thread_get_current_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/nplb/thread_helpers.h" #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -45,3 +47,5 @@ TEST(SbThreadGetCurrentTest, SunnyDay) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_get_id_test.cc b/starboard/nplb/thread_get_id_test.cc index 0fcc0897c75e..5c3caa957b16 100644 --- a/starboard/nplb/thread_get_id_test.cc +++ b/starboard/nplb/thread_get_id_test.cc @@ -14,7 +14,7 @@ // Thread joining is mostly tested in the other tests. -#include "starboard/nplb/thread_helpers.h" +#include "starboard/nplb/posix_compliance/posix_thread_helpers.h" #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -24,7 +24,7 @@ namespace { // Returns the thread's ID. void* GetThreadIdEntryPoint(void* context) { - return nplb::ToVoid(SbThreadGetId()); + return posix::ToVoid(SbThreadGetId()); } TEST(SbThreadGetIdTest, SunnyDay) { @@ -34,19 +34,18 @@ TEST(SbThreadGetIdTest, SunnyDay) { TEST(SbThreadGetIdTest, SunnyDayDifferentIds) { const int kThreads = 16; - SbThread threads[kThreads]; + pthread_t threads[kThreads]; for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, GetThreadIdEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(threads[i])); + pthread_create(&threads[i], nullptr, GetThreadIdEntryPoint, nullptr); + EXPECT_TRUE(threads[i] != 0); } // We join on all these threads to get their IDs back. SbThreadId thread_ids[kThreads]; for (int i = 0; i < kThreads; ++i) { void* result = NULL; - EXPECT_TRUE(SbThreadJoin(threads[i], &result)); - SbThreadId id = static_cast(nplb::FromVoid(result)); + EXPECT_EQ(pthread_join(threads[i], &result), 0); + SbThreadId id = static_cast(posix::FromVoid(result)); EXPECT_NE(id, SbThreadGetId()); thread_ids[i] = id; } diff --git a/starboard/nplb/thread_helpers.cc b/starboard/nplb/thread_helpers.cc index 283eaf77d167..66e893fb0f77 100644 --- a/starboard/nplb/thread_helpers.cc +++ b/starboard/nplb/thread_helpers.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include #include "starboard/nplb/thread_helpers.h" @@ -91,3 +93,5 @@ void WaiterContext::WaitForReturnSignal() { } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_helpers.h b/starboard/nplb/thread_helpers.h index b83e6f61a6fa..fcc1a6f8738a 100644 --- a/starboard/nplb/thread_helpers.h +++ b/starboard/nplb/thread_helpers.h @@ -15,6 +15,8 @@ #ifndef STARBOARD_NPLB_THREAD_HELPERS_H_ #define STARBOARD_NPLB_THREAD_HELPERS_H_ +#if SB_API_VERSION < 16 + #include "starboard/common/mutex.h" #include "starboard/common/semaphore.h" #include "starboard/condition_variable.h" @@ -195,4 +197,5 @@ class AbstractTestThread { } // namespace nplb } // namespace starboard +#endif // SB_API_VERSION < 16 #endif // STARBOARD_NPLB_THREAD_HELPERS_H_ diff --git a/starboard/nplb/thread_is_equal_test.cc b/starboard/nplb/thread_is_equal_test.cc index f0963acb6b82..5ab5ffd24b51 100644 --- a/starboard/nplb/thread_is_equal_test.cc +++ b/starboard/nplb/thread_is_equal_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/nplb/thread_helpers.h" #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -37,3 +39,5 @@ TEST(SbThreadIsEqualTest, Everything) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_join_test.cc b/starboard/nplb/thread_join_test.cc index 341aba335471..bf951043c179 100644 --- a/starboard/nplb/thread_join_test.cc +++ b/starboard/nplb/thread_join_test.cc @@ -14,6 +14,8 @@ // Thread joining is mostly tested in the other tests. +#if SB_API_VERSION < 16 + #include #include "starboard/thread.h" @@ -71,3 +73,5 @@ TEST(SbThreadLocalValueTest, ThreadJoinWaitsForFunctionRun) { } // namespace } // namespace nplb } // namespace starboard + +#endif // SB_API_VERSION < 16 diff --git a/starboard/raspi/shared/BUILD.gn b/starboard/raspi/shared/BUILD.gn index 3988122640b7..8adaea878175 100644 --- a/starboard/raspi/shared/BUILD.gn +++ b/starboard/raspi/shared/BUILD.gn @@ -22,7 +22,7 @@ group("starboard_platform") { static_library("starboard_platform_sources") { check_includes = false - # has_pedantic_warnings = true + has_pedantic_warnings = true sources = [ "//starboard/linux/shared/atomic_public.h", diff --git a/starboard/raspi/shared/configuration_constants.cc b/starboard/raspi/shared/configuration_constants.cc index 77275c19b294..d1163c476cfd 100644 --- a/starboard/raspi/shared/configuration_constants.cc +++ b/starboard/raspi/shared/configuration_constants.cc @@ -143,4 +143,7 @@ const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB // Whether this platform can map executable memory. This is required for // platforms that want to JIT. SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; #endif diff --git a/starboard/shared/libjpeg/jpeg_image_decoder.cc b/starboard/shared/libjpeg/jpeg_image_decoder.cc index 3a79422dbe5b..326a8c7e6126 100644 --- a/starboard/shared/libjpeg/jpeg_image_decoder.cc +++ b/starboard/shared/libjpeg/jpeg_image_decoder.cc @@ -27,8 +27,8 @@ // Inhibit C++ name-mangling for libjpeg functions. extern "C" { // clang-format off -#include "third_party/libjpeg-turbo/jpeglib.h" -#include "third_party/libjpeg-turbo/jpegint.h" +#include "third_party/libjpeg_turbo/jpeglib.h" +#include "third_party/libjpeg_turbo/jpegint.h" // clang-format on } diff --git a/starboard/shared/modular/BUILD.gn b/starboard/shared/modular/BUILD.gn index bf221e19f1ea..e9a59fe238c7 100644 --- a/starboard/shared/modular/BUILD.gn +++ b/starboard/shared/modular/BUILD.gn @@ -21,6 +21,8 @@ if (sb_is_modular || sb_is_evergreen_compatible) { "starboard_layer_posix_mmap_abi_wrappers.h", "starboard_layer_posix_pthread_abi_wrappers.cc", "starboard_layer_posix_pthread_abi_wrappers.h", + "starboard_layer_posix_socket_abi_wrappers.cc", + "starboard_layer_posix_socket_abi_wrappers.h", "starboard_layer_posix_stat_abi_wrappers.cc", "starboard_layer_posix_stat_abi_wrappers.h", "starboard_layer_posix_time_abi_wrappers.cc", @@ -41,6 +43,7 @@ if (sb_is_modular && !sb_is_evergreen && sources = [ "cobalt_layer_posix_mmap_abi_wrappers.cc", "cobalt_layer_posix_pthread_abi_wrappers.cc", + "cobalt_layer_posix_socket_abi_wrappers.cc", "cobalt_layer_posix_stat_abi_wrappers.cc", "cobalt_layer_posix_time_abi_wrappers.cc", "cobalt_layer_posix_unistd_abi_wrappers.cc", diff --git a/starboard/shared/modular/cobalt_layer_posix_socket_abi_wrappers.cc b/starboard/shared/modular/cobalt_layer_posix_socket_abi_wrappers.cc new file mode 100644 index 000000000000..f2701a9ae793 --- /dev/null +++ b/starboard/shared/modular/cobalt_layer_posix_socket_abi_wrappers.cc @@ -0,0 +1,74 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if SB_API_VERSION >= 16 + +#include +#include + +extern "C" { + +int __abi_wrap_accept(int sockfd, + struct sockaddr* addr, + socklen_t* addrlen_ptr); + +int accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen_ptr) { + return __abi_wrap_accept(sockfd, addr, addrlen_ptr); +} + +int __abi_wrap_bind(int sockfd, const struct sockaddr* addr, socklen_t addrlen); +int bind(int sockfd, const struct sockaddr* addr, socklen_t addrlen) { + return __abi_wrap_bind(sockfd, addr, addrlen); +} + +int __abi_wrap_connect(int sockfd, + const struct sockaddr* addr, + socklen_t addrlen); +int connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen) { + return __abi_wrap_connect(sockfd, addr, addrlen); +} + +int __abi_wrap_getaddrinfo(const char* node, + const char* service, + const struct addrinfo* hints, + struct addrinfo** res); +int getaddrinfo(const char* node, + const char* service, + const struct addrinfo* hints, + struct addrinfo** res) { + return __abi_wrap_getaddrinfo(node, service, hints, res); +} + +int __abi_wrap_getifaddrs(struct ifaddrs** ifap); +int getifaddrs(struct ifaddrs** ifap) { + return __abi_wrap_getifaddrs(ifap); +} + +int __abi_wrap_setsockopt(int socket, + int level, + int option_name, + const void* option_value, + socklen_t option_len); +int setsockopt(int socket, + int level, + int option_name, + const void* option_value, + socklen_t option_len) { + return __abi_wrap_setsockopt(socket, level, option_name, option_value, + option_len); +} + +} // extern "C" + +#endif // SB_API_VERSION >= 16 diff --git a/starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.cc b/starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.cc new file mode 100644 index 000000000000..a12f22213039 --- /dev/null +++ b/starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.cc @@ -0,0 +1,185 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.h" +#include + +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) +#include +#endif + +SB_EXPORT int __abi_wrap_accept(int sockfd, + musl_sockaddr* addr, + socklen_t* addrlen_ptr) { +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) + if (addr != nullptr) { + struct sockaddr new_addr = {}; + new_addr.sa_family = addr->sa_family; + new_addr.sa_len = 0; + memcpy(new_addr.sa_data, addr->sa_data, 14); + addr = reinterpret_cast(&new_addr); + } +#endif + return accept(sockfd, reinterpret_cast(addr), addrlen_ptr); +} + +SB_EXPORT int __abi_wrap_bind(int sockfd, + const musl_sockaddr* addr, + socklen_t addrlen) { +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) + if (addr != nullptr) { + struct sockaddr new_addr = {}; + new_addr.sa_family = addr->sa_family; + new_addr.sa_len = 0; + memcpy(new_addr.sa_data, addr->sa_data, 14); + return bind(sockfd, reinterpret_cast(&new_addr), + addrlen); + } else { + return bind(sockfd, reinterpret_cast(addr), + addrlen); + } +#else + return bind(sockfd, reinterpret_cast(addr), addrlen); +#endif +} + +SB_EXPORT int __abi_wrap_connect(int sockfd, + const musl_sockaddr* addr, + socklen_t addrlen) { +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) + if (addr != nullptr) { + struct sockaddr new_addr = {}; + new_addr.sa_family = addr->sa_family; + new_addr.sa_len = 0; + memcpy(new_addr.sa_data, addr->sa_data, 14); + return connect(sockfd, reinterpret_cast(&new_addr), + addrlen); + } else { + return connect(sockfd, reinterpret_cast(addr), + addrlen); + } +#else + return connect(sockfd, reinterpret_cast(addr), + addrlen); +#endif +} + +SB_EXPORT int __abi_wrap_getaddrinfo(const char* node, + const char* service, + const struct addrinfo* hints, + struct addrinfo** res) { + int result = getaddrinfo(node, service, hints, res); + +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) + struct addrinfo* ai = *res; + while (ai != nullptr) { + if (ai->ai_addr != nullptr) { + musl_sockaddr* musl_addr_ptr = + reinterpret_cast(ai->ai_addr); + struct sockaddr* addr_ptr = + reinterpret_cast(ai->ai_addr); + uint8_t sa_family = addr_ptr->sa_family; + musl_addr_ptr->sa_family = sa_family; + } + ai = ai->ai_next; + } +#endif + return result; +} + +SB_EXPORT int __abi_wrap_getifaddrs(struct ifaddrs** ifap) { + int result = getifaddrs(ifap); +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) + struct ifaddrs* ptr = *ifap; + struct ifaddrs* last_ptr = ptr; + while (ptr != nullptr) { + if (ptr->ifa_addr != nullptr) { + musl_sockaddr* musl_addr_ptr = + reinterpret_cast(ptr->ifa_addr); + struct sockaddr* addr_ptr = + reinterpret_cast(ptr->ifa_addr); + uint8_t sa_family = addr_ptr->sa_family; + musl_addr_ptr->sa_family = sa_family; + } + ptr = ptr->ifa_next; + } +#endif + return result; +} + +SB_EXPORT int __abi_wrap_setsockopt(int socket, + int level, + int option_name, + const void* option_value, + socklen_t option_len) { + if (socket <= 0) { + return -1; + } + int is_supported = 1; + +#if SB_HAS_QUIRK(SOCKADDR_WITH_LENGTH) + + // The value from POSIX +#define MUSL_SOL_SOCKET 1 // level +#define MUSL_SO_REUSEADDR 2 +#define MUSL_SO_RCVBUF 8 +#define MUSL_SO_SNDBUF 7 +#define MUSL_SO_KEEPALIVE 9 + +#define MUSL_SOL_TCP 6 // level +#define MUSL_TCP_NODELAY 1 +#define MUSL_TCP_KEEPIDLE 4 +#define MUSL_TCP_KEEPINTVL 5 + +#define MUSL_IPPROTO_TCP 6 // level + + if (level == MUSL_SOL_SOCKET) { + level = SOL_SOCKET; + switch (option_name) { + case MUSL_SO_REUSEADDR: + option_name = SO_REUSEADDR; + break; + case MUSL_SO_RCVBUF: + option_name = SO_RCVBUF; + break; + case MUSL_SO_SNDBUF: + option_name = SO_SNDBUF; + break; + case MUSL_SO_KEEPALIVE: + is_supported = 0; + break; + default: + is_supported = 0; + } + } + if (level == MUSL_IPPROTO_TCP) { + level = IPPROTO_TCP; + switch (option_name) { + case MUSL_TCP_NODELAY: + option_name = SCE_NET_TCP_NODELAY; + break; + default: + is_supported = 0; + } + } + if (level = MUSL_SOL_TCP) { + is_supported = 0; + } +#endif + + if (is_supported) { + return setsockopt(socket, level, option_name, option_value, option_len); + } + return 0; +} diff --git a/starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.h b/starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.h new file mode 100644 index 000000000000..58208a48d4a5 --- /dev/null +++ b/starboard/shared/modular/starboard_layer_posix_socket_abi_wrappers.h @@ -0,0 +1,69 @@ +// Copyright 2024 The Cobalt Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STARBOARD_SHARED_MODULAR_STARBOARD_LAYER_POSIX_SOCKET_ABI_WRAPPERS_H_ +#define STARBOARD_SHARED_MODULAR_STARBOARD_LAYER_POSIX_SOCKET_ABI_WRAPPERS_H_ + +#include + +#include +#include +#include +#include + +#include "starboard/configuration.h" +#include "starboard/export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// sizeof(sockaddr_in6) = 28, 28 - 2 = 26 +// This size enables musl_sockaddr to work for both IPv4 and IPv6 +#define MUSL_SOCKADDR_SA_DATA_SIZE 26 +typedef struct musl_sockaddr { + uint16_t sa_family; + char sa_data[MUSL_SOCKADDR_SA_DATA_SIZE]; +} musl_sockaddr; + +SB_EXPORT int __abi_wrap_accept(int sockfd, + musl_sockaddr* addr, + socklen_t* addrlen_ptr); + +SB_EXPORT int __abi_wrap_bind(int sockfd, + const musl_sockaddr* addr, + socklen_t addrlen); + +SB_EXPORT int __abi_wrap_connect(int sockfd, + const musl_sockaddr* addr, + socklen_t addrlen); + +SB_EXPORT int __abi_wrap_getaddrinfo(const char* node, + const char* service, + const struct addrinfo* hints, + struct addrinfo** res); + +SB_EXPORT int __abi_wrap_getifaddrs(struct ifaddrs** ifap); + +SB_EXPORT int __abi_wrap_setsockopt(int socket, + int level, + int option_name, + const void* option_value, + socklen_t option_len); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // STARBOARD_SHARED_MODULAR_STARBOARD_LAYER_POSIX_SOCKET_ABI_WRAPPERS_H_ diff --git a/starboard/shared/posix/socket_create.cc b/starboard/shared/posix/socket_create.cc index 5c0922c00768..83d02eb0beb3 100644 --- a/starboard/shared/posix/socket_create.cc +++ b/starboard/shared/posix/socket_create.cc @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "starboard/common/socket.h" - #include #include #include #include #include "starboard/common/log.h" +#include "starboard/common/socket.h" #include "starboard/shared/posix/handle_eintr.h" #include "starboard/shared/posix/set_non_blocking_internal.h" #include "starboard/shared/posix/socket_internal.h" diff --git a/starboard/shared/posix/socket_listen.cc b/starboard/shared/posix/socket_listen.cc index 19342134858a..d1b5d3c86654 100644 --- a/starboard/shared/posix/socket_listen.cc +++ b/starboard/shared/posix/socket_listen.cc @@ -48,7 +48,7 @@ SbSocketError SbSocketListen(SbSocket socket) { #endif int result = listen(socket->socket_fd, kMaxConn); if (result != 0) { - return (socket->error = sbposix::TranslateSocketErrno(result)); + return (socket->error = sbposix::TranslateSocketErrno(errno)); } return (socket->error = kSbSocketOk); diff --git a/starboard/shared/pthread/condition_variable_broadcast.cc b/starboard/shared/pthread/condition_variable_broadcast.cc index d6811e9f24d0..e45b259dac1d 100644 --- a/starboard/shared/pthread/condition_variable_broadcast.cc +++ b/starboard/shared/pthread/condition_variable_broadcast.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include @@ -37,3 +39,5 @@ bool SbConditionVariableBroadcast(SbConditionVariable* condition) { return IsSuccess(pthread_cond_broadcast( &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_create.cc b/starboard/shared/pthread/condition_variable_create.cc index de31fad4eeb4..52a98a239062 100644 --- a/starboard/shared/pthread/condition_variable_create.cc +++ b/starboard/shared/pthread/condition_variable_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include @@ -85,3 +87,5 @@ bool SbConditionVariableCreate(SbConditionVariable* out_condition, return status; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_destroy.cc b/starboard/shared/pthread/condition_variable_destroy.cc index fbc2a8db706f..9c8e30f4be9c 100644 --- a/starboard/shared/pthread/condition_variable_destroy.cc +++ b/starboard/shared/pthread/condition_variable_destroy.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include @@ -37,3 +39,5 @@ bool SbConditionVariableDestroy(SbConditionVariable* condition) { return IsSuccess(pthread_cond_destroy( &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_signal.cc b/starboard/shared/pthread/condition_variable_signal.cc index 8f40acbd983e..b8ee61d2f45a 100644 --- a/starboard/shared/pthread/condition_variable_signal.cc +++ b/starboard/shared/pthread/condition_variable_signal.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include @@ -37,3 +39,5 @@ bool SbConditionVariableSignal(SbConditionVariable* condition) { return IsSuccess(pthread_cond_signal( &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_wait.cc b/starboard/shared/pthread/condition_variable_wait.cc index fcd506a6af43..397d94d078ab 100644 --- a/starboard/shared/pthread/condition_variable_wait.cc +++ b/starboard/shared/pthread/condition_variable_wait.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include @@ -46,3 +48,4 @@ SbConditionVariableResult SbConditionVariableWait( return kSbConditionVariableFailed; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_wait_timed.cc b/starboard/shared/pthread/condition_variable_wait_timed.cc index a5c6179fa869..8807680cecd0 100644 --- a/starboard/shared/pthread/condition_variable_wait_timed.cc +++ b/starboard/shared/pthread/condition_variable_wait_timed.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/condition_variable.h" #include @@ -77,3 +79,5 @@ SbConditionVariableResult SbConditionVariableWaitTimed( return kSbConditionVariableFailed; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_acquire.cc b/starboard/shared/pthread/mutex_acquire.cc index cf951e4fce64..a9f4d26b7eed 100644 --- a/starboard/shared/pthread/mutex_acquire.cc +++ b/starboard/shared/pthread/mutex_acquire.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -47,3 +49,5 @@ SbMutexResult SbMutexAcquire(SbMutex* mutex) { return kSbMutexBusy; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_acquire_try.cc b/starboard/shared/pthread/mutex_acquire_try.cc index f9d86a3c18ed..58fb709b5e3a 100644 --- a/starboard/shared/pthread/mutex_acquire_try.cc +++ b/starboard/shared/pthread/mutex_acquire_try.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -40,3 +42,5 @@ SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { return kSbMutexBusy; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_create.cc b/starboard/shared/pthread/mutex_create.cc index 744caf49f3c5..e24abce5dd2a 100644 --- a/starboard/shared/pthread/mutex_create.cc +++ b/starboard/shared/pthread/mutex_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -33,3 +35,5 @@ bool SbMutexCreate(SbMutex* mutex) { SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); return IsSuccess(pthread_mutex_init(SB_PTHREAD_INTERNAL_MUTEX(mutex), NULL)); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_destroy.cc b/starboard/shared/pthread/mutex_destroy.cc index 3fb53f5f9edd..754c52d14019 100644 --- a/starboard/shared/pthread/mutex_destroy.cc +++ b/starboard/shared/pthread/mutex_destroy.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -38,3 +40,5 @@ bool SbMutexDestroy(SbMutex* mutex) { // thread, as well as deleting a locked mutex, result in undefined behavior. return IsSuccess(pthread_mutex_destroy(SB_PTHREAD_INTERNAL_MUTEX(mutex))); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_release.cc b/starboard/shared/pthread/mutex_release.cc index 86b318faeec2..0dbe87f363ce 100644 --- a/starboard/shared/pthread/mutex_release.cc +++ b/starboard/shared/pthread/mutex_release.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -33,3 +35,4 @@ bool SbMutexRelease(SbMutex* mutex) { } return IsSuccess(pthread_mutex_unlock(SB_PTHREAD_INTERNAL_MUTEX(mutex))); } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_create.cc b/starboard/shared/pthread/thread_create.cc index 1b9f7f14f696..41167eb00f54 100644 --- a/starboard/shared/pthread/thread_create.cc +++ b/starboard/shared/pthread/thread_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include @@ -127,3 +129,5 @@ SbThread SbThreadCreate(int64_t stack_size, return kSbThreadInvalid; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_detach.cc b/starboard/shared/pthread/thread_detach.cc index 3ba7471c814a..3a760d83727c 100644 --- a/starboard/shared/pthread/thread_detach.cc +++ b/starboard/shared/pthread/thread_detach.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include @@ -25,3 +27,5 @@ void SbThreadDetach(SbThread thread) { pthread_detach(SB_PTHREAD_INTERNAL_THREAD(thread)); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_get_current.cc b/starboard/shared/pthread/thread_get_current.cc index f547371e39b2..62a5d98576ca 100644 --- a/starboard/shared/pthread/thread_get_current.cc +++ b/starboard/shared/pthread/thread_get_current.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include @@ -21,3 +23,4 @@ SbThread SbThreadGetCurrent() { return SB_THREAD(pthread_self()); } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_is_equal.cc b/starboard/shared/pthread/thread_is_equal.cc index c8c634988647..7131ef3cdfe8 100644 --- a/starboard/shared/pthread/thread_is_equal.cc +++ b/starboard/shared/pthread/thread_is_equal.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include @@ -22,3 +24,5 @@ bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { return pthread_equal(SB_PTHREAD_INTERNAL_THREAD(thread1), SB_PTHREAD_INTERNAL_THREAD(thread2)) != 0; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_join.cc b/starboard/shared/pthread/thread_join.cc index d4488db2e77a..3136701fdb68 100644 --- a/starboard/shared/pthread/thread_join.cc +++ b/starboard/shared/pthread/thread_join.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include @@ -36,3 +38,5 @@ bool SbThreadJoin(SbThread thread, void** out_return) { return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/loader_app_metrics.cc b/starboard/shared/starboard/loader_app_metrics.cc index 388e8c08d85d..c9b831d222a6 100644 --- a/starboard/shared/starboard/loader_app_metrics.cc +++ b/starboard/shared/starboard/loader_app_metrics.cc @@ -36,6 +36,8 @@ static int64_t g_elf_decompression_duration_us = -1; static int64_t g_max_sampled_cpu_bytes_during_elf_load = -1; +static SlotSelectionStatus g_slot_selection_status; + void SetCrashpadInstallationStatus(CrashpadInstallationStatus status) { g_crashpad_installation_status = status; } @@ -78,9 +80,17 @@ int64_t GetMaxSampledUsedCpuBytesDuringElfLoad() { return g_max_sampled_cpu_bytes_during_elf_load; } +void SetSlotSelectionStatus(SlotSelectionStatus status) { + g_slot_selection_status = status; +} + +SlotSelectionStatus GetSlotSelectionStatus() { + return g_slot_selection_status; +} + const StarboardExtensionLoaderAppMetricsApi kLoaderAppMetricsApi = { kStarboardExtensionLoaderAppMetricsName, - 2, + 3, &SetCrashpadInstallationStatus, &GetCrashpadInstallationStatus, &SetElfLibraryStoredCompressed, @@ -90,7 +100,9 @@ const StarboardExtensionLoaderAppMetricsApi kLoaderAppMetricsApi = { &SetElfDecompressionDurationMicroseconds, &GetElfDecompressionDurationMicroseconds, &RecordUsedCpuBytesDuringElfLoad, - &GetMaxSampledUsedCpuBytesDuringElfLoad}; + &GetMaxSampledUsedCpuBytesDuringElfLoad, + &SetSlotSelectionStatus, + &GetSlotSelectionStatus}; } // namespace diff --git a/starboard/shared/starboard/media/media_get_buffer_storage_type.cc b/starboard/shared/starboard/media/media_get_buffer_storage_type.cc index 3d8dfcd4cfd8..5cb8977c078b 100644 --- a/starboard/shared/starboard/media/media_get_buffer_storage_type.cc +++ b/starboard/shared/starboard/media/media_get_buffer_storage_type.cc @@ -14,6 +14,8 @@ #include "starboard/media.h" +#if SB_API_VERSION < 16 SbMediaBufferStorageType SbMediaGetBufferStorageType() { return kSbMediaBufferStorageTypeMemory; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/once_types_public.h b/starboard/shared/starboard/once_types_public.h deleted file mode 100644 index 23bd4163048d..000000000000 --- a/starboard/shared/starboard/once_types_public.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Provides definitions useful for working with SbOnce implemented using -// SbAtomic32. - -#ifndef STARBOARD_SHARED_STARBOARD_ONCE_TYPES_PUBLIC_H_ -#define STARBOARD_SHARED_STARBOARD_ONCE_TYPES_PUBLIC_H_ - -#include "starboard/atomic.h" -#include "starboard/shared/starboard/lazy_initialization_public.h" - -// Defines once types for the platform-independent atomics-based implementation -// of SbOnce() defined in shared/once.cc. - -// Transparent Once control handle. -typedef InitializedState SbOnceControl; - -// Once static initializer. -#define SB_ONCE_INITIALIZER \ - { INITIALIZED_STATE_UNINITIALIZED } - -#endif // STARBOARD_SHARED_STARBOARD_ONCE_TYPES_PUBLIC_H_ diff --git a/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.cc b/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.cc index 440873581577..dbc9f1748776 100644 --- a/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.cc +++ b/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.cc @@ -43,6 +43,19 @@ AdaptiveAudioDecoder::AdaptiveAudioDecoder( SB_DCHECK(audio_stream_info.codec != kSbMediaAudioCodecNone); } +AdaptiveAudioDecoder::AdaptiveAudioDecoder( + const media::AudioStreamInfo& audio_stream_info, + SbDrmSystem drm_system, + const AudioDecoderCreator& audio_decoder_creator, + bool enable_reset_audio_decoder, + const OutputFormatAdjustmentCallback& output_adjustment_callback) + : AdaptiveAudioDecoder(audio_stream_info, + drm_system, + audio_decoder_creator, + output_adjustment_callback) { + enable_reset_audio_decoder_ = enable_reset_audio_decoder; +} + AdaptiveAudioDecoder::~AdaptiveAudioDecoder() { SB_DCHECK(BelongsToCurrentThread()); @@ -154,9 +167,13 @@ void AdaptiveAudioDecoder::Reset() { SB_DCHECK(BelongsToCurrentThread()); if (audio_decoder_) { - audio_decoder_->Reset(); - resampler_.reset(); - channel_mixer_.reset(); + if (enable_reset_audio_decoder_) { + audio_decoder_->Reset(); + resampler_.reset(); + channel_mixer_.reset(); + } else { + TeardownAudioDecoder(); + } } ResetInternal(); } diff --git a/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h b/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h index 5ee80a7b7b6b..70232de0fca3 100644 --- a/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h +++ b/starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h @@ -52,6 +52,12 @@ class AdaptiveAudioDecoder : public AudioDecoder, private JobQueue::JobOwner { const AudioDecoderCreator& audio_decoder_creator, const OutputFormatAdjustmentCallback& output_adjustment_callback = nullptr); + AdaptiveAudioDecoder(const media::AudioStreamInfo& audio_stream_info, + SbDrmSystem drm_system, + const AudioDecoderCreator& audio_decoder_creator, + bool enable_reset_audio_decoder, + const OutputFormatAdjustmentCallback& + output_adjustment_callback = nullptr); ~AdaptiveAudioDecoder() override; void Initialize(const OutputCB& output_cb, const ErrorCB& error_cb) override; @@ -91,6 +97,7 @@ class AdaptiveAudioDecoder : public AudioDecoder, private JobQueue::JobOwner { bool first_output_received_ = false; bool output_format_checked_ = false; bool first_input_written_ = false; + bool enable_reset_audio_decoder_ = false; }; } // namespace filter diff --git a/starboard/shared/starboard/player/filter/tools/BUILD.gn b/starboard/shared/starboard/player/filter/tools/BUILD.gn index 469de56f04db..1ef43e2ba2ba 100644 --- a/starboard/shared/starboard/player/filter/tools/BUILD.gn +++ b/starboard/shared/starboard/player/filter/tools/BUILD.gn @@ -14,7 +14,7 @@ if (current_toolchain == starboard_toolchain) { target(starboard_level_final_executable_type, "audio_dmp_player") { - # build_loader = false + build_loader = false sources = [ "audio_dmp_player.cc" ] configs += [ "//starboard/build/config:starboard_implementation" ] public_deps = [ @@ -24,9 +24,8 @@ if (current_toolchain == starboard_toolchain) { "//starboard/shared/starboard/player:video_dmp", ] data_deps = [ - # "//cobalt/network:copy_ssl_certificates", + "//cobalt/network:copy_ssl_certificates", "//starboard/shared/starboard/player:player_download_test_data", - "//third_party/icu:icudata", ] } } diff --git a/starboard/shared/starboard/player/job_queue.cc b/starboard/shared/starboard/player/job_queue.cc index e8612267d65e..5d774a1f2d3f 100644 --- a/starboard/shared/starboard/player/job_queue.cc +++ b/starboard/shared/starboard/player/job_queue.cc @@ -62,8 +62,8 @@ void ResetCurrentThreadJobQueue() { } // namespace -JobQueue::JobQueue() : thread_id_(pthread_self()), condition_(mutex_) { - SB_DCHECK(thread_id_ != 0); +JobQueue::JobQueue() : thread_id_(SbThreadGetId()), condition_(mutex_) { + SB_DCHECK(SbThreadIsValidId(thread_id_)); SetCurrentThreadJobQueue(this); } @@ -155,7 +155,7 @@ bool JobQueue::BelongsToCurrentThread() const { // The ctor already ensures that the current JobQueue is the only JobQueue of // the thread, checking for thread id is more light-weighted then calling // JobQueue::current() and compare the result with |this|. - return pthread_equal(thread_id_, pthread_self()); + return thread_id_ == SbThreadGetId(); } // static diff --git a/starboard/shared/starboard/player/job_queue.h b/starboard/shared/starboard/player/job_queue.h index b4cc1416dcb3..fab15b95ad1c 100644 --- a/starboard/shared/starboard/player/job_queue.h +++ b/starboard/shared/starboard/player/job_queue.h @@ -15,8 +15,6 @@ #ifndef STARBOARD_SHARED_STARBOARD_PLAYER_JOB_QUEUE_H_ #define STARBOARD_SHARED_STARBOARD_PLAYER_JOB_QUEUE_H_ -#include - #include #include #include @@ -173,7 +171,7 @@ class JobQueue { // be run. bool TryToRunOneJob(bool wait_for_next_job); - const pthread_t thread_id_; + const SbThreadId thread_id_; Mutex mutex_; ConditionVariable condition_; int64_t current_job_token_ = JobToken::kInvalidToken + 1; diff --git a/starboard/shared/starboard/thread_checker.h b/starboard/shared/starboard/thread_checker.h index 53355068dea0..5ec38aff824e 100644 --- a/starboard/shared/starboard/thread_checker.h +++ b/starboard/shared/starboard/thread_checker.h @@ -15,9 +15,8 @@ #ifndef STARBOARD_SHARED_STARBOARD_THREAD_CHECKER_H_ #define STARBOARD_SHARED_STARBOARD_THREAD_CHECKER_H_ -#include - #include "starboard/atomic.h" +#include "starboard/thread.h" namespace starboard { namespace shared { @@ -44,10 +43,9 @@ class ThreadChecker { explicit ThreadChecker(Type type = kSetThreadIdOnCreation) { if (type == kSetThreadIdOnCreation) - thread_id_ = - reinterpret_cast(reinterpret_cast(pthread_self())); + thread_id_ = SbThreadGetId(); else - thread_id_ = 0; + thread_id_ = kSbThreadInvalidId; } // Detached the thread checker from its current thread. The thread checker @@ -57,25 +55,19 @@ class ThreadChecker { void Detach() { // This is safe as when this function is called, it is expected that it // won't be called on its current thread. - thread_id_ = 0; + thread_id_ = kSbThreadInvalidId; } bool CalledOnValidThread() const { - uintptr_t current_thread_id = - reinterpret_cast(reinterpret_cast(pthread_self())); -#if SB_HAS(64_BIT_ATOMICS) - uintptr_t stored_thread_id = SbAtomicNoBarrier_CompareAndSwap64( - reinterpret_cast(&thread_id_), 0, current_thread_id); -#else - uintptr_t stored_thread_id = SbAtomicNoBarrier_CompareAndSwap( - reinterpret_cast(&thread_id_), 0, current_thread_id); -#endif - - return stored_thread_id == 0 || stored_thread_id == current_thread_id; + SbThreadId current_thread_id = SbThreadGetId(); + SbThreadId stored_thread_id = SbAtomicNoBarrier_CompareAndSwap( + &thread_id_, kSbThreadInvalidId, current_thread_id); + return stored_thread_id == kSbThreadInvalidId || + stored_thread_id == current_thread_id; } private: - mutable uintptr_t thread_id_; + mutable SbThreadId thread_id_; }; #endif // defined(COBALT_BUILD_TYPE_GOLD) diff --git a/starboard/shared/starboard/thread_local_storage_internal.cc b/starboard/shared/starboard/thread_local_storage_internal.cc deleted file mode 100644 index 9cb83b76b099..000000000000 --- a/starboard/shared/starboard/thread_local_storage_internal.cc +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/thread_local_storage_internal.h" - -#include -#include -#include -#include -#include -#include - -#include "starboard/common/flat_map.h" -#include "starboard/common/log.h" -#include "starboard/memory.h" -#include "starboard/once.h" - -struct SbThreadLocalKeyPrivate { - int index; -}; - -namespace starboard { -namespace shared { - -namespace { -TLSKeyManager* s_instance = NULL; -SbOnceControl s_instance_control = SB_ONCE_INITIALIZER; - -void InitializeTLS() { - s_instance = new TLSKeyManager(); -} - -template -class RawAllocator : public std::allocator { - public: - typedef typename std::allocator::pointer pointer; - typedef typename std::allocator::const_pointer const_pointer; - typedef typename std::allocator::reference reference; - typedef typename std::allocator::const_reference const_reference; - typedef typename std::allocator::size_type size_type; - typedef typename std::allocator::value_type value_type; - typedef typename std::allocator::difference_type difference_type; - - RawAllocator() {} - - // Constructor used for rebinding - template - RawAllocator(const RawAllocator& x) {} - - pointer allocate(size_type n, - std::allocator::const_pointer hint = NULL) { - void* ptr = malloc(n * sizeof(value_type)); - return static_cast(ptr); - } - - void deallocate(pointer p, size_type n) { free(p); } - template - struct rebind { - typedef RawAllocator other; - }; -}; - -// A map of ThreadId -> int. This map is highly concurrent and allows -// access of elements without much contention. -class ConcurrentThreadIdMap { - public: - ConcurrentThreadIdMap() { - // Prime number reduces collisions. - static const size_t kNumBuckets = 101; - map_vector_.resize(kNumBuckets); - - for (size_t i = 0; i < map_vector_.size(); ++i) { - void* memory_block = malloc(sizeof(LockedMap)); - map_vector_[i] = new (memory_block) LockedMap; - } - } - - ~ConcurrentThreadIdMap() { - for (size_t i = 0; i < map_vector_.size(); ++i) { - LockedMap* obj = map_vector_[i]; - obj->~LockedMap(); - free(obj); - } - } - - bool GetIfExists(SbThreadId key, int* value) const { - const LockedMap& map = GetBucket(key); - ScopedLock lock(map.mutex_); - ThreadIdMap::const_iterator it = map.map_.find(key); - if (it != map.map_.end()) { - *value = it->second; - return true; - } else { - return false; - } - } - - void Insert(SbThreadId key, int value) { - LockedMap& map = GetBucket(key); - ScopedLock lock(map.mutex_); - map.map_[key] = value; - } - - void Erase(SbThreadId key) { - LockedMap& map = GetBucket(key); - ScopedLock lock(map.mutex_); - map.map_.erase(key); - } - - private: - typedef std::map, - RawAllocator > > - ThreadIdMap; - - struct LockedMap { - Mutex mutex_; - ThreadIdMap map_; - }; - - // Simple hashing function for 32 bit numbers. - // Based off of Jenkins hash found at this url: - // https://gist.github.com/badboy/6267743#file-inthash-md - static size_t Hash(SbThreadId id) { - static const uint32_t kMagicNum1 = 0x7ed55d16; - static const uint32_t kMagicNum2 = 0xc761c23c; - static const uint32_t kMagicNum3 = 0x165667b1; - static const uint32_t kMagicNum4 = 0xd3a2646c; - static const uint32_t kMagicNum5 = 0xfd7046c5; - static const uint32_t kMagicNum6 = 0xfd7046c5; - - static const uint32_t kMagicShift1 = 12; - static const uint32_t kMagicShift2 = 19; - static const uint32_t kMagicShift3 = 5; - static const uint32_t kMagicShift4 = 9; - static const uint32_t kMagicShift5 = 3; - static const uint32_t kMagicShift6 = 16; - - uint32_t key = static_cast(id); - key = (key + kMagicNum1) + (key << kMagicShift1); - key = (key ^ kMagicNum2) ^ (key >> kMagicShift2); - key = (key + kMagicNum3) + (key << kMagicShift3); - key = (key + kMagicNum4) ^ (key << kMagicShift4); - key = (key + kMagicNum5) + (key << kMagicShift5); - key = (key ^ kMagicNum6) ^ (key >> kMagicShift6); - return static_cast(key); - } - - const LockedMap& GetBucket(SbThreadId key) const { - size_t bucket_index = Hash(key) % map_vector_.size(); - return *map_vector_[bucket_index]; - } - - LockedMap& GetBucket(SbThreadId key) { - size_t bucket_index = Hash(key) % map_vector_.size(); - return *map_vector_[bucket_index]; - } - - typedef std::vector > MapVector; - MapVector map_vector_; -}; - -} // namespace - -struct TLSKeyManager::InternalData { - // These data structures bypass memory reporting. If this wasn't here then - // any platform using this TLSKeyManager will crash during memory reporting. - typedef std::vector > VectorKeyRecord; - typedef std::vector > VectorInt; - typedef ConcurrentThreadIdMap ThreadIdMap; - - // Overrides new/delete for InternalData to bypass memory reporting. - static void* operator new(size_t n) { return malloc(n); } - static void operator delete(void* p) { free(p); } - - // The key record tracks all key values among all threads, along with their - // destructors, if specified. - VectorKeyRecord key_table_; - - // Tracks all thread IDs that are still available. - VectorInt available_thread_ids_; - - // This maps Starboard thread IDs to TLS thread ids. - ThreadIdMap thread_id_map_; -}; - -TLSKeyManager* TLSKeyManager::Get() { - SbOnce(&s_instance_control, &InitializeTLS); - return s_instance; -} - -TLSKeyManager::TLSKeyManager() { - data_.reset(new InternalData); - data_->available_thread_ids_.reserve(kMaxThreads); - for (int i = 0; i < kMaxThreads; ++i) { - data_->available_thread_ids_.push_back(i); - } -} - -SbThreadLocalKey TLSKeyManager::CreateKey(SbThreadLocalDestructor destructor) { - // Allocate key and bypass the the normal allocator. Otherwise there - // could be a re-entrant loop that kills the process. - void* memory_block = malloc(sizeof(SbThreadLocalKeyPrivate)); - SbThreadLocalKey key = new (memory_block) SbThreadLocalKeyPrivate(); - - ScopedLock lock(mutex_); - key->index = GetUnusedKeyIndex(); - - KeyRecord* record = &data_->key_table_[key->index]; - - record->destructor = destructor; - memset(record->values.data(), 0, - record->values.size() * sizeof(record->values[0])); - record->valid = true; - - return key; -} - -void TLSKeyManager::DestroyKey(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return; - } - - ScopedLock lock(mutex_); - - SB_DCHECK(IsKeyActive(key)); - data_->key_table_[key->index].valid = false; - - key.~SbThreadLocalKey(); - free(key); -} - -bool TLSKeyManager::SetLocalValue(SbThreadLocalKey key, void* value) { - if (!SbThreadIsValidLocalKey(key)) { - return false; - } - - int current_thread_id = GetCurrentThreadId(); - - ScopedLock lock(mutex_); - - if (!IsKeyActive(key)) { - return false; - } - - data_->key_table_[key->index].values[current_thread_id] = value; - - return true; -} - -void* TLSKeyManager::GetLocalValue(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return NULL; - } - - int current_thread_id = GetCurrentThreadId(); - - ScopedLock lock(mutex_); - - if (!IsKeyActive(key)) { - return NULL; - } - - return data_->key_table_[key->index].values[current_thread_id]; -} - -bool TLSKeyManager::IsKeyActive(SbThreadLocalKey key) { - return data_->key_table_[key->index].valid; -} - -int TLSKeyManager::GetUnusedKeyIndex() { - const size_t key_table_size = data_->key_table_.size(); - for (int i = 0; i < key_table_size; ++i) { - if (!data_->key_table_[i].valid) { - return i; - } - } - - data_->key_table_.push_back(KeyRecord()); - data_->key_table_.back().valid = false; - - return data_->key_table_.size() - 1; -} - -int TLSKeyManager::GetCurrentThreadId() { - const SbThreadId thread_id = SbThreadGetId(); - - int value = -1; - if (data_->thread_id_map_.GetIfExists(thread_id, &value)) { - return value; - } - - ScopedLock lock(mutex_); - - SB_DCHECK(!data_->available_thread_ids_.empty()); - int thread_tls_id = data_->available_thread_ids_.back(); - data_->available_thread_ids_.pop_back(); - - data_->thread_id_map_.Insert(thread_id, thread_tls_id); - return thread_tls_id; -} - -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/stub/condition_variable_broadcast.cc b/starboard/shared/stub/condition_variable_broadcast.cc index f7bfa45824ae..056366ac914b 100644 --- a/starboard/shared/stub/condition_variable_broadcast.cc +++ b/starboard/shared/stub/condition_variable_broadcast.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" bool SbConditionVariableBroadcast(SbConditionVariable* condition) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_create.cc b/starboard/shared/stub/condition_variable_create.cc index c11de476c107..1589001f9a55 100644 --- a/starboard/shared/stub/condition_variable_create.cc +++ b/starboard/shared/stub/condition_variable_create.cc @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 #include "starboard/common/condition_variable.h" bool SbConditionVariableCreate(SbConditionVariable* out_condition, SbMutex* opt_mutex) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_destroy.cc b/starboard/shared/stub/condition_variable_destroy.cc index 5b213d6c3c8a..654d2b1c9318 100644 --- a/starboard/shared/stub/condition_variable_destroy.cc +++ b/starboard/shared/stub/condition_variable_destroy.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" bool SbConditionVariableDestroy(SbConditionVariable* condition) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_signal.cc b/starboard/shared/stub/condition_variable_signal.cc index 73589d4d44bf..6f905ead1d47 100644 --- a/starboard/shared/stub/condition_variable_signal.cc +++ b/starboard/shared/stub/condition_variable_signal.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" bool SbConditionVariableSignal(SbConditionVariable* condition) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_wait.cc b/starboard/shared/stub/condition_variable_wait.cc index e649efdbecbc..8735a72337bb 100644 --- a/starboard/shared/stub/condition_variable_wait.cc +++ b/starboard/shared/stub/condition_variable_wait.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" SbConditionVariableResult SbConditionVariableWait( @@ -19,3 +21,4 @@ SbConditionVariableResult SbConditionVariableWait( SbMutex* mutex) { return kSbConditionVariableFailed; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_wait_timed.cc b/starboard/shared/stub/condition_variable_wait_timed.cc index dfc22d29771a..908759d0f98a 100644 --- a/starboard/shared/stub/condition_variable_wait_timed.cc +++ b/starboard/shared/stub/condition_variable_wait_timed.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" SbConditionVariableResult SbConditionVariableWaitTimed( @@ -20,3 +22,4 @@ SbConditionVariableResult SbConditionVariableWaitTimed( int64_t timeout) { return kSbConditionVariableFailed; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/media_get_buffer_storage_type.cc b/starboard/shared/stub/media_get_buffer_storage_type.cc index 802e19dfd701..23db3566c2ea 100644 --- a/starboard/shared/stub/media_get_buffer_storage_type.cc +++ b/starboard/shared/stub/media_get_buffer_storage_type.cc @@ -14,6 +14,8 @@ #include "starboard/media.h" +#if SB_API_VERSION < 16 SbMediaBufferStorageType SbMediaGetBufferStorageType() { return static_cast(0); } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_acquire.cc b/starboard/shared/stub/mutex_acquire.cc index 423202e813a6..db64efd19d1c 100644 --- a/starboard/shared/stub/mutex_acquire.cc +++ b/starboard/shared/stub/mutex_acquire.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" SbMutexResult SbMutexAcquire(SbMutex* mutex) { return kSbMutexDestroyed; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_acquire_try.cc b/starboard/shared/stub/mutex_acquire_try.cc index efc87b69d931..e59f2db4b581 100644 --- a/starboard/shared/stub/mutex_acquire_try.cc +++ b/starboard/shared/stub/mutex_acquire_try.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { return kSbMutexDestroyed; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_create.cc b/starboard/shared/stub/mutex_create.cc index 4439ee071147..52876be4af47 100644 --- a/starboard/shared/stub/mutex_create.cc +++ b/starboard/shared/stub/mutex_create.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" bool SbMutexCreate(SbMutex* mutex) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_destroy.cc b/starboard/shared/stub/mutex_destroy.cc index b88ae22767c5..e62414a53ec4 100644 --- a/starboard/shared/stub/mutex_destroy.cc +++ b/starboard/shared/stub/mutex_destroy.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" bool SbMutexDestroy(SbMutex* mutex) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_release.cc b/starboard/shared/stub/mutex_release.cc index 207b6428d30e..21f81caf467a 100644 --- a/starboard/shared/stub/mutex_release.cc +++ b/starboard/shared/stub/mutex_release.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" bool SbMutexRelease(SbMutex* mutex) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_create.cc b/starboard/shared/stub/thread_create.cc index 7dc0360bf863..5b93031f9d75 100644 --- a/starboard/shared/stub/thread_create.cc +++ b/starboard/shared/stub/thread_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" SbThread SbThreadCreate(int64_t stack_size, @@ -23,3 +25,4 @@ SbThread SbThreadCreate(int64_t stack_size, void* context) { return kSbThreadInvalid; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_detach.cc b/starboard/shared/stub/thread_detach.cc index b54ecd92f340..381a25025f0a 100644 --- a/starboard/shared/stub/thread_detach.cc +++ b/starboard/shared/stub/thread_detach.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 #include "starboard/thread.h" void SbThreadDetach(SbThread thread) {} +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_current.cc b/starboard/shared/stub/thread_get_current.cc index 9e59c54fcfd3..d6b495c38b9d 100644 --- a/starboard/shared/stub/thread_get_current.cc +++ b/starboard/shared/stub/thread_get_current.cc @@ -12,8 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" SbThread SbThreadGetCurrent() { return kSbThreadInvalid; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_is_equal.cc b/starboard/shared/stub/thread_is_equal.cc index fa8946921aa4..d1cf10aacd03 100644 --- a/starboard/shared/stub/thread_is_equal.cc +++ b/starboard/shared/stub/thread_is_equal.cc @@ -12,8 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { return false; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_join.cc b/starboard/shared/stub/thread_join.cc index 54059eccf131..d19376e56d07 100644 --- a/starboard/shared/stub/thread_join.cc +++ b/starboard/shared/stub/thread_join.cc @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" bool SbThreadJoin(SbThread thread, void** out_return) { return false; } +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_broadcast.cc b/starboard/shared/win32/condition_variable_broadcast.cc index 283887dd77aa..54afbd843ad7 100644 --- a/starboard/shared/win32/condition_variable_broadcast.cc +++ b/starboard/shared/win32/condition_variable_broadcast.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include @@ -25,3 +27,5 @@ bool SbConditionVariableBroadcast(SbConditionVariable* condition) { WakeAllConditionVariable(SB_WIN32_INTERNAL_CONDITION(condition)); return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_create.cc b/starboard/shared/win32/condition_variable_create.cc index 6bc8eaea3eef..8346a9cb1b41 100644 --- a/starboard/shared/win32/condition_variable_create.cc +++ b/starboard/shared/win32/condition_variable_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include @@ -29,3 +31,5 @@ bool SbConditionVariableCreate(SbConditionVariable* out_condition, InitializeConditionVariable(SB_WIN32_INTERNAL_CONDITION(out_condition)); return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_destroy.cc b/starboard/shared/win32/condition_variable_destroy.cc index f274855a39c3..a48c40fb4568 100644 --- a/starboard/shared/win32/condition_variable_destroy.cc +++ b/starboard/shared/win32/condition_variable_destroy.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include @@ -22,3 +24,5 @@ bool SbConditionVariableDestroy(SbConditionVariable* condition) { } return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_signal.cc b/starboard/shared/win32/condition_variable_signal.cc index 4653d6fa7103..ac38573e5232 100644 --- a/starboard/shared/win32/condition_variable_signal.cc +++ b/starboard/shared/win32/condition_variable_signal.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include @@ -25,3 +27,5 @@ bool SbConditionVariableSignal(SbConditionVariable* condition) { WakeConditionVariable(SB_WIN32_INTERNAL_CONDITION(condition)); return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_wait.cc b/starboard/shared/win32/condition_variable_wait.cc index d90dc89eda34..5360e7ec243c 100644 --- a/starboard/shared/win32/condition_variable_wait.cc +++ b/starboard/shared/win32/condition_variable_wait.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include @@ -30,3 +32,5 @@ SbConditionVariableResult SbConditionVariableWait( return result ? kSbConditionVariableSignaled : kSbConditionVariableFailed; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_wait_timed.cc b/starboard/shared/win32/condition_variable_wait_timed.cc index a2192ad1e6a4..2a448466affb 100644 --- a/starboard/shared/win32/condition_variable_wait_timed.cc +++ b/starboard/shared/win32/condition_variable_wait_timed.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/common/condition_variable.h" #include @@ -52,3 +54,5 @@ SbConditionVariableResult SbConditionVariableWaitTimed( } return kSbConditionVariableFailed; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_acquire.cc b/starboard/shared/win32/mutex_acquire.cc index 4e4238f48786..7c4bab841b86 100644 --- a/starboard/shared/win32/mutex_acquire.cc +++ b/starboard/shared/win32/mutex_acquire.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -25,3 +27,5 @@ SbMutexResult SbMutexAcquire(SbMutex* mutex) { AcquireSRWLockExclusive(SB_WIN32_INTERNAL_MUTEX(mutex)); return kSbMutexAcquired; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_acquire_try.cc b/starboard/shared/win32/mutex_acquire_try.cc index 391b6cfbdaf2..bc78ddaeab92 100644 --- a/starboard/shared/win32/mutex_acquire_try.cc +++ b/starboard/shared/win32/mutex_acquire_try.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -25,3 +27,5 @@ SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { bool result = TryAcquireSRWLockExclusive(SB_WIN32_INTERNAL_MUTEX(mutex)); return result ? kSbMutexAcquired : kSbMutexBusy; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_create.cc b/starboard/shared/win32/mutex_create.cc index d8aead293ccc..de9039c22dae 100644 --- a/starboard/shared/win32/mutex_create.cc +++ b/starboard/shared/win32/mutex_create.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -28,3 +30,5 @@ bool SbMutexCreate(SbMutex* mutex) { InitializeSRWLock(SB_WIN32_INTERNAL_MUTEX(mutex)); return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_destroy.cc b/starboard/shared/win32/mutex_destroy.cc index bad468940c34..d8745b771993 100644 --- a/starboard/shared/win32/mutex_destroy.cc +++ b/starboard/shared/win32/mutex_destroy.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -35,3 +37,5 @@ bool SbMutexDestroy(SbMutex* mutex) { // https://devblogs.microsoft.com/oldnewthing/20160819-00/?p=94125 return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_release.cc b/starboard/shared/win32/mutex_release.cc index 72fbe311c406..a1d3839baea2 100644 --- a/starboard/shared/win32/mutex_release.cc +++ b/starboard/shared/win32/mutex_release.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/mutex.h" #include @@ -25,3 +27,5 @@ bool SbMutexRelease(SbMutex* mutex) { ReleaseSRWLockExclusive(SB_WIN32_INTERNAL_MUTEX(mutex)); return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/posix_emu/pthread.cc b/starboard/shared/win32/posix_emu/pthread.cc index c7d1d957c0ad..5d8574f19234 100644 --- a/starboard/shared/win32/posix_emu/pthread.cc +++ b/starboard/shared/win32/posix_emu/pthread.cc @@ -121,14 +121,19 @@ int pthread_cond_signal(pthread_cond_t* cond) { int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* t) { + // take the current time as soon as possible to + // try to improve the accuracy of the timeout duration. + int64_t now_ms = starboard::CurrentPosixTime() / 1000; + if (!cond || !mutex) { return -1; } - int64_t now_ms = starboard::CurrentPosixTime() / 1000; - int64_t timeout_duration_ms = t->tv_sec * 1000 + t->tv_nsec / 1000000; timeout_duration_ms -= now_ms; + if (timeout_duration_ms < 0) { + timeout_duration_ms = 0; + } bool result = SleepConditionVariableSRW( reinterpret_cast(cond->buffer), @@ -208,15 +213,15 @@ static unsigned ThreadTrampoline(void* thread_create_info_context) { CallThreadLocalDestructorsMultipleTimes(); - SbMutexAcquire(&info->thread_private_.mutex_); + pthread_mutex_lock(&info->thread_private_.mutex_); info->thread_private_.result_ = result; info->thread_private_.result_is_valid_ = true; - SbConditionVariableSignal(&info->thread_private_.condition_); + pthread_cond_signal(&info->thread_private_.condition_); while (info->thread_private_.wait_for_join_) { - SbConditionVariableWait(&info->thread_private_.condition_, - &info->thread_private_.mutex_); + pthread_cond_wait(&info->thread_private_.condition_, + &info->thread_private_.mutex_); } - SbMutexRelease(&info->thread_private_.mutex_); + pthread_mutex_unlock(&info->thread_private_.mutex_); return 0; } @@ -268,22 +273,21 @@ int pthread_join(pthread_t thread, void** value_ptr) { SbThreadPrivate* thread_private = reinterpret_cast(thread); - SbMutexAcquire(&thread_private->mutex_); + pthread_mutex_lock(&thread_private->mutex_); if (!thread_private->wait_for_join_) { // Thread has already been detached. - SbMutexRelease(&thread_private->mutex_); + pthread_mutex_unlock(&thread_private->mutex_); return -1; } while (!thread_private->result_is_valid_) { - SbConditionVariableWait(&thread_private->condition_, - &thread_private->mutex_); + pthread_cond_wait(&thread_private->condition_, &thread_private->mutex_); } thread_private->wait_for_join_ = false; - SbConditionVariableSignal(&thread_private->condition_); + pthread_cond_signal(&thread_private->condition_); if (value_ptr != NULL) { *value_ptr = thread_private->result_; } - SbMutexRelease(&thread_private->mutex_); + pthread_mutex_unlock(&thread_private->mutex_); return 0; } @@ -293,10 +297,10 @@ int pthread_detach(pthread_t thread) { } SbThreadPrivate* thread_private = reinterpret_cast(thread); - SbMutexAcquire(&thread_private->mutex_); + pthread_mutex_lock(&thread_private->mutex_); thread_private->wait_for_join_ = false; - SbConditionVariableSignal(&thread_private->condition_); - SbMutexRelease(&thread_private->mutex_); + pthread_cond_signal(&thread_private->condition_); + pthread_mutex_unlock(&thread_private->mutex_); return 0; } @@ -325,9 +329,9 @@ int pthread_key_delete(pthread_key_t key) { DWORD tls_index = reinterpret_cast(key)->tls_index; ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - SbMutexAcquire(&singleton->mutex_); + pthread_mutex_lock(&singleton->mutex_); singleton->thread_local_keys_.erase(tls_index); - SbMutexRelease(&singleton->mutex_); + pthread_mutex_unlock(&singleton->mutex_); TlsInternalFree(tls_index); free(reinterpret_cast(key)); diff --git a/starboard/shared/win32/posix_emu/socket.cc b/starboard/shared/win32/posix_emu/socket.cc index 4d57a04e95b4..c55afaef1c1b 100644 --- a/starboard/shared/win32/posix_emu/socket.cc +++ b/starboard/shared/win32/posix_emu/socket.cc @@ -70,16 +70,19 @@ int handle_db_put(FileOrSocket handle) { static FileOrSocket handle_db_get(int fd, bool erase) { FileOrSocket invalid_handle = {/*is_file=*/false, -1, INVALID_SOCKET}; if (fd < 0) { + _set_errno(EBADF); return invalid_handle; } EnterCriticalSection(&g_critical_section.critical_section_); if (g_map_addr == nullptr) { g_map_addr = new std::map(); + _set_errno(EBADF); return invalid_handle; } auto itr = g_map_addr->find(fd); if (itr == g_map_addr->end()) { + _set_errno(EBADF); return invalid_handle; } @@ -91,6 +94,140 @@ static FileOrSocket handle_db_get(int fd, bool erase) { return handle; } +// WSAGetLastError should be called immediately to retrieve the extended error +// code for the failing function call. +// https://learn.microsoft.com/en-us/windows/win32/winsock/error-codes-errno-h-errno-and-wsagetlasterror-2 +static void set_errno() { + int winsockError = WSAGetLastError(); + int sockError = 0; + + // The error codes returned by Windows Sockets are similar to UNIX socket + // error code constants, but the constants are all prefixed with WSA. So in + // Winsock applications the WSAEWOULDBLOCK error code would be returned, while + // in UNIX applications the EWOULDBLOCK error code would be returned. The + // errno values in a WIN32 are a subset of the values for errno in UNIX + // systems. + switch (winsockError) { + case WSAEINTR: // Interrupted function call + sockError = EINTR; + break; + case WSAEBADF: // WSAEBADF + sockError = EBADF; + break; + case WSAEACCES: // WSAEACCES + sockError = EACCES; + break; + case WSAEFAULT: // Bad address + sockError = EFAULT; + break; + case WSAEINVAL: // Invalid argument + sockError = EINVAL; + break; + case WSAEMFILE: // Too many open files + sockError = EMFILE; + break; + case WSAEWOULDBLOCK: // Operation would block + sockError = EWOULDBLOCK; + break; + case WSAEINPROGRESS: // Operation now in progress + sockError = EINPROGRESS; + break; + case WSAEALREADY: // Operation already in progress + sockError = EALREADY; + break; + case WSAENOTSOCK: // Socket operation on non-socket + sockError = ENOTSOCK; + break; + case WSAEDESTADDRREQ: // Destination address required + sockError = EDESTADDRREQ; + break; + case WSAEMSGSIZE: // Message too long + sockError = EMSGSIZE; + break; + case WSAEPROTOTYPE: // Protocol wrong type for socket + sockError = EPROTOTYPE; + break; + case WSAENOPROTOOPT: // Bad protocol option + sockError = ENOPROTOOPT; + break; + case WSAEPROTONOSUPPORT: // Protocol not supported + sockError = EPROTONOSUPPORT; + break; + case WSAEOPNOTSUPP: // Operation not supported + sockError = EOPNOTSUPP; + break; + case WSAEAFNOSUPPORT: // Address family not supported by protocol family + sockError = EAFNOSUPPORT; + break; + case WSAEADDRINUSE: // Address already in use + sockError = EADDRINUSE; + break; + case WSAEADDRNOTAVAIL: // Cannot assign requested address + sockError = EADDRNOTAVAIL; + break; + case WSAENETDOWN: // Network is down + sockError = ENETDOWN; + break; + case WSAENETUNREACH: // Network is unreachable + sockError = ENETUNREACH; + break; + case WSAENETRESET: // Network dropped connection on reset + sockError = ENETRESET; + break; + case WSAECONNABORTED: // Software caused connection abort + sockError = ECONNABORTED; + break; + case WSAECONNRESET: // Connection reset by peer + sockError = ECONNRESET; + break; + case WSAENOBUFS: // No buffer space available + sockError = ENOBUFS; + break; + case WSAEISCONN: // Socket is already connected + sockError = EISCONN; + break; + case WSAENOTCONN: // Socket is not connected + sockError = ENOTCONN; + break; + case WSAETIMEDOUT: // Connection timed out + sockError = ETIMEDOUT; + break; + case WSAECONNREFUSED: // Connection refused + sockError = ECONNREFUSED; + break; + case WSAELOOP: // WSAELOOP + sockError = ELOOP; + break; + case WSAENAMETOOLONG: // WSAENAMETOOLONG + sockError = ENAMETOOLONG; + break; + case WSAEHOSTUNREACH: // No route to host + sockError = EHOSTUNREACH; + break; + case WSAENOTEMPTY: // WSAENOTEMPTY + sockError = ENOTEMPTY; + break; + case WSAHOST_NOT_FOUND: // Host not found + sockError = HOST_NOT_FOUND; + break; + case WSATRY_AGAIN: // Non-authoritative host not found + sockError = TRY_AGAIN; + break; + case WSANO_RECOVERY: // This is a non-recoverable error + sockError = NO_RECOVERY; + break; + case WSANO_DATA: // Valid name, no data record of requested type + sockError = NO_DATA; + break; + default: + SB_DLOG(WARNING) << "Unknown socket error."; + break; + } + + _set_errno(sockError); + SB_DLOG(INFO) << "Encounter socket error: " << sockError; +} + /////////////////////////////////////////////////////////////////////////////// // Implementations below exposed externally in pure C for emulation. /////////////////////////////////////////////////////////////////////////////// @@ -102,8 +239,7 @@ int sb_socket(int domain, int type, int protocol) { // socket() returns a handle to a kernel object instead SOCKET socket_handle = socket(domain, type, protocol); if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error - errno = WSAGetLastError(); + set_errno(); return -1; } @@ -139,10 +275,13 @@ int close(int fd) { FileOrSocket handle = handle_db_get(fd, true); if (!handle.is_file && handle.socket == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } else if (!handle.is_file) { - return closesocket(handle.socket); + int result = closesocket(handle.socket); + if (result == SOCKET_ERROR) { + set_errno(); + } + return result; } // This is then a file handle, so use Windows `_close` API. @@ -200,37 +339,38 @@ int write(int fd, const void* buffer, unsigned int count) { int sb_bind(int socket, const struct sockaddr* address, socklen_t address_len) { SOCKET socket_handle = handle_db_get(socket, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } int result = bind(socket_handle, address, address_len); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } int sb_listen(int socket, int backlog) { SOCKET socket_handle = handle_db_get(socket, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } int result = listen(socket_handle, backlog); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } int sb_accept(int socket, sockaddr* addr, int* addrlen) { SOCKET socket_handle = handle_db_get(socket, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } SOCKET accept_handle = accept(socket_handle, addr, addrlen); if (accept_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error + set_errno(); return -1; } @@ -241,35 +381,40 @@ int sb_accept(int socket, sockaddr* addr, int* addrlen) { int sb_connect(int socket, sockaddr* name, int namelen) { SOCKET socket_handle = handle_db_get(socket, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } int result = connect(socket_handle, name, namelen); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } int sb_send(int sockfd, const void* buf, size_t len, int flags) { SOCKET socket_handle = handle_db_get(sockfd, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } + int result = send(socket_handle, reinterpret_cast(buf), len, flags); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } int sb_recv(int sockfd, void* buf, size_t len, int flags) { SOCKET socket_handle = handle_db_get(sockfd, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } + int result = recv(socket_handle, reinterpret_cast(buf), len, flags); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } @@ -281,12 +426,14 @@ int sb_sendto(int sockfd, socklen_t dest_len) { SOCKET socket_handle = handle_db_get(sockfd, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } + int result = sendto(socket_handle, reinterpret_cast(buf), len, flags, dest_addr, dest_len); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } @@ -298,12 +445,14 @@ int sb_recvfrom(int sockfd, socklen_t* address_len) { SOCKET socket_handle = handle_db_get(sockfd, false).socket; if (socket_handle == INVALID_SOCKET) { - // TODO: update errno with file operation error return -1; } + int result = recvfrom(socket_handle, reinterpret_cast(buf), len, flags, address, address_len); - errno = WSAGetLastError(); + if (result == SOCKET_ERROR) { + set_errno(); + } return result; } @@ -321,14 +470,10 @@ int sb_setsockopt(int socket, int result = setsockopt(handle.socket, level, option_name, reinterpret_cast(option_value), option_len); - // TODO(b/321999529): Windows returns SOCKET_ERROR on failure. The specific - // error code can be retrieved by calling WSAGetLastError(), and Posix returns - // -1 on failure and sets errno to the error’s value. if (result == SOCKET_ERROR) { - errno = WSAGetLastError(); - return -1; + set_errno(); } - return 0; + return result; } int sb_fcntl(int fd, int cmd, ... /*arg*/) { @@ -350,5 +495,4 @@ int sb_fcntl(int fd, int cmd, ... /*arg*/) { } return 0; } - } // extern "C" diff --git a/starboard/shared/win32/socket_waiter_internal.cc b/starboard/shared/win32/socket_waiter_internal.cc index a0a7da438cb2..f745689092f7 100644 --- a/starboard/shared/win32/socket_waiter_internal.cc +++ b/starboard/shared/win32/socket_waiter_internal.cc @@ -123,7 +123,7 @@ SbSocketWaiterInterest CombineInterests(SbSocketWaiterInterest a, } // namespace SbSocketWaiterPrivate::SbSocketWaiterPrivate() - : thread_(SbThreadGetCurrent()), + : thread_(pthread_self()), wakeup_event_token_(-1), wakeup_event_(CreateEvent(nullptr, false, false, nullptr)) { { @@ -152,7 +152,7 @@ bool SbSocketWaiterPrivate::Add(SbSocket socket, SbSocketWaiterCallback callback, int interests, bool persistent) { - SB_DCHECK(SbThreadIsCurrent(thread_)); + SB_DCHECK(pthread_equal(pthread_self(), thread_)); if (!SbSocketIsValid(socket)) { SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; @@ -235,7 +235,7 @@ bool SbSocketWaiterPrivate::Add(SbSocket socket, } bool SbSocketWaiterPrivate::Remove(SbSocket socket) { - SB_DCHECK(SbThreadIsCurrent(thread_)); + SB_DCHECK(pthread_equal(pthread_self(), thread_)); if (!CheckSocketWaiterIsThis(socket)) { return false; @@ -277,7 +277,7 @@ bool SbSocketWaiterPrivate::CheckSocketWaiterIsThis(SbSocket socket) { } void SbSocketWaiterPrivate::Wait() { - SB_DCHECK(SbThreadIsCurrent(thread_)); + SB_DCHECK(pthread_equal(pthread_self(), thread_)); // We basically wait for the largest amount of time to achieve an indefinite // block. @@ -285,7 +285,7 @@ void SbSocketWaiterPrivate::Wait() { } SbSocketWaiterResult SbSocketWaiterPrivate::WaitTimed(int64_t duration_usec) { - SB_DCHECK(SbThreadIsCurrent(thread_)); + SB_DCHECK(pthread_equal(pthread_self(), thread_)); const int64_t start_time = starboard::CurrentMonotonicTime(); int64_t duration_left = duration_usec; diff --git a/starboard/shared/win32/socket_waiter_internal.h b/starboard/shared/win32/socket_waiter_internal.h index 52d8eda1b1c5..28bd02e78b38 100644 --- a/starboard/shared/win32/socket_waiter_internal.h +++ b/starboard/shared/win32/socket_waiter_internal.h @@ -131,7 +131,7 @@ class SbSocketWaiterPrivate { // The thread this waiter was created on. Immutable, so accessible from any // thread. - const SbThread thread_; + const pthread_t thread_; // The registry of currently registered Waitees. WaiteeRegistry waitees_; diff --git a/starboard/shared/win32/thread_create.cc b/starboard/shared/win32/thread_create.cc index 8bff3ed983f4..058452247a80 100644 --- a/starboard/shared/win32/thread_create.cc +++ b/starboard/shared/win32/thread_create.cc @@ -92,7 +92,7 @@ void CallThreadLocalDestructorsMultipleTimes() { // TODO note that the implementation below holds a global lock // while processing TLS destructors on thread exit. This could // be a bottleneck in some scenarios. A lockless approach may be preferable. - SbMutexAcquire(&singleton->mutex_); + pthread_mutex_lock(&singleton->mutex_); for (int i = 0; i < kNumDestructorPasses; ++i) { // Run through each destructor and call it. @@ -102,7 +102,7 @@ void CallThreadLocalDestructorsMultipleTimes() { } } num_tls_objects_remaining = CountTlsObjectsRemaining(singleton); - SbMutexRelease(&singleton->mutex_); + pthread_mutex_unlock(&singleton->mutex_); SB_DCHECK(num_tls_objects_remaining == 0) << "Dangling objects in TLS exist."; } @@ -121,15 +121,15 @@ unsigned ThreadTrampoline(void* thread_create_info_context) { CallThreadLocalDestructorsMultipleTimes(); - SbMutexAcquire(&info->thread_private_.mutex_); + pthread_mutex_lock(&info->thread_private_.mutex_); info->thread_private_.result_ = result; info->thread_private_.result_is_valid_ = true; - SbConditionVariableSignal(&info->thread_private_.condition_); + pthread_cond_signal(&info->thread_private_.condition_); while (info->thread_private_.wait_for_join_) { - SbConditionVariableWait(&info->thread_private_.condition_, - &info->thread_private_.mutex_); + pthread_cond_wait(&info->thread_private_.condition_, + &info->thread_private_.mutex_); } - SbMutexRelease(&info->thread_private_.mutex_); + pthread_mutex_destroy(&info->thread_private_.mutex_); return 0; } @@ -174,6 +174,7 @@ SbThreadPriority Win32PriorityToSbThreadPriority(int priority) { } } // namespace +#if SB_API_VERSION < 16 // Note that SetThreadAffinityMask() is not available on some // platforms (eg UWP). If it's necessary for a non-UWP platform, // please fork this implementation for UWP. @@ -218,6 +219,7 @@ SbThread SbThreadCreate(int64_t stack_size, return &info->thread_private_; } +#endif // SB_API_VERSION < 16 bool SbThreadSetPriority(SbThreadPriority priority) { return SetThreadPriority(GetCurrentThread(), diff --git a/starboard/shared/win32/thread_create_local_key.cc b/starboard/shared/win32/thread_create_local_key.cc index 56dc12037e4d..1b1b771fb3cd 100644 --- a/starboard/shared/win32/thread_create_local_key.cc +++ b/starboard/shared/win32/thread_create_local_key.cc @@ -57,9 +57,9 @@ SbThreadLocalKey SbThreadCreateLocalKeyInternal( result->tls_index = index; result->destructor = destructor; - SbMutexAcquire(&singleton->mutex_); + pthread_mutex_lock(&singleton->mutex_); singleton->thread_local_keys_.insert(std::make_pair(index, result)); - SbMutexRelease(&singleton->mutex_); + pthread_mutex_unlock(&singleton->mutex_); return result; } diff --git a/starboard/shared/win32/thread_detach.cc b/starboard/shared/win32/thread_detach.cc index d16f52455458..1dfff6d24c50 100644 --- a/starboard/shared/win32/thread_detach.cc +++ b/starboard/shared/win32/thread_detach.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include "starboard/common/condition_variable.h" @@ -31,3 +33,5 @@ void SbThreadDetach(SbThread thread) { SbConditionVariableSignal(&thread_private->condition_); SbMutexRelease(&thread_private->mutex_); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_get_current.cc b/starboard/shared/win32/thread_get_current.cc index 0b8af37f14a1..b3dc47319993 100644 --- a/starboard/shared/win32/thread_get_current.cc +++ b/starboard/shared/win32/thread_get_current.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include "starboard/shared/win32/thread_private.h" @@ -22,3 +24,5 @@ using starboard::shared::win32::SbThreadPrivate; SbThread SbThreadGetCurrent() { return GetCurrentSbThreadPrivate(); } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_is_equal.cc b/starboard/shared/win32/thread_is_equal.cc index e3afc0cbe81a..ae7ae9a7d2b1 100644 --- a/starboard/shared/win32/thread_is_equal.cc +++ b/starboard/shared/win32/thread_is_equal.cc @@ -12,8 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { return thread1 == thread2; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_join.cc b/starboard/shared/win32/thread_join.cc index 7f2e7619720f..4fd30c911df4 100644 --- a/starboard/shared/win32/thread_join.cc +++ b/starboard/shared/win32/thread_join.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 + #include "starboard/thread.h" #include "starboard/common/condition_variable.h" @@ -45,3 +47,5 @@ bool SbThreadJoin(SbThread thread, void** out_return) { SbMutexRelease(&thread_private->mutex_); return true; } + +#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_private.h b/starboard/shared/win32/thread_private.h index d5e62c4d0d5a..4f14d05e9825 100644 --- a/starboard/shared/win32/thread_private.h +++ b/starboard/shared/win32/thread_private.h @@ -28,6 +28,8 @@ #define kSbThreadLocalKeyInvalid (SbThreadLocalKey) NULL +typedef void (*SbThreadLocalDestructor)(void* value); + struct SbThreadLocalKeyPrivate { DWORD tls_index; SbThreadLocalDestructor destructor; @@ -60,10 +62,10 @@ SbThreadLocalKey SbThreadCreateLocalKeyInternal( class ThreadSubsystemSingleton { public: ThreadSubsystemSingleton() - : mutex_(SB_MUTEX_INITIALIZER), + : mutex_(PTHREAD_MUTEX_INITIALIZER), thread_private_key_(SbThreadCreateLocalKeyInternal(NULL, this)) {} // This mutex protects all class members - SbMutex mutex_; + pthread_mutex_t mutex_; // Allocated thread_local_keys. Note that std::map is used // so that elements can be deleted without triggering an allocation. std::map thread_local_keys_; @@ -82,8 +84,8 @@ void RegisterMainThread(); class SbThreadPrivate { public: SbThreadPrivate() - : mutex_(SB_MUTEX_INITIALIZER), - condition_(SB_CONDITION_VARIABLE_INITIALIZER), + : mutex_(PTHREAD_MUTEX_INITIALIZER), + condition_(PTHREAD_COND_INITIALIZER), handle_(NULL), result_(NULL), wait_for_join_(false), @@ -94,13 +96,13 @@ class SbThreadPrivate { CloseHandle(handle_); } - SbMutexDestroy(&mutex_); - SbConditionVariableDestroy(&condition_); + pthread_mutex_destroy(&mutex_); + pthread_cond_destroy(&condition_); } // This mutex protects all class members - SbMutex mutex_; - SbConditionVariable condition_; + pthread_mutex_t mutex_; + pthread_cond_t condition_; std::string name_; HANDLE handle_; // The result of the thread. The return value of SbThreadEntryPoint @@ -117,6 +119,8 @@ class SbThreadPrivate { // Obtains the current thread's SbThreadPrivate* from thread-local storage. SbThreadPrivate* GetCurrentSbThreadPrivate(); +typedef void* (*SbThreadEntryPoint)(void* context); + class ThreadCreateInfo { public: SbThreadPrivate thread_private_; diff --git a/starboard/stub/configuration_constants.cc b/starboard/stub/configuration_constants.cc index 9fedf69850e7..7b4a5cd4fec4 100644 --- a/starboard/stub/configuration_constants.cc +++ b/starboard/stub/configuration_constants.cc @@ -140,4 +140,7 @@ const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB // Whether this platform can map executable memory. This is required for // platforms that want to JIT. SB_EXPORT extern const bool kSbCanMapExecutableMemory = false; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport = false; #endif diff --git a/starboard/stub/configuration_public.h b/starboard/stub/configuration_public.h index 2ea3d945748e..80f29bfa6aa9 100644 --- a/starboard/stub/configuration_public.h +++ b/starboard/stub/configuration_public.h @@ -48,14 +48,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Media Configuration --------------------------------------------------- - -#if SB_API_VERSION <= 15 -// The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only -// when this macro is defined. -#undef SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES -#endif // SB_API_VERSION <= 15 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/thread.h b/starboard/thread.h index 94b1e502d24f..c7f3e9fc92ec 100644 --- a/starboard/thread.h +++ b/starboard/thread.h @@ -29,11 +29,6 @@ extern "C" { #endif -// An opaque handle to a thread type. -typedef void* SbThread; - -#define kSbThreadInvalid (SbThread) NULL - // A spectrum of thread priorities. Platforms map them appropriately to their // own priority system. Note that scheduling is platform-specific, and what // these priorities mean, if they mean anything at all, is also @@ -84,6 +79,36 @@ typedef enum SbThreadPriority { // An ID type that is unique per thread. typedef int32_t SbThreadId; +// Well-defined constant value to mean "no thread ID." +#define kSbThreadInvalidId (SbThreadId)0 + +// Returns whether the given thread ID is valid. +static inline bool SbThreadIsValidId(SbThreadId id) { + return id != kSbThreadInvalidId; +} + +// Returns whether the given thread priority is valid. +static inline bool SbThreadIsValidPriority(SbThreadPriority priority) { + return priority != kSbThreadNoPriority; +} + +// Returns the Thread ID of the currently executing thread. +SB_EXPORT SbThreadId SbThreadGetId(); + +#if SB_API_VERSION >= 16 +// Set the thread priority of the current thread. +SB_EXPORT bool SbThreadSetPriority(SbThreadPriority priority); + +// Get the thread priority of the current thread. +SB_EXPORT bool SbThreadGetPriority(SbThreadPriority* priority); +#endif + +#if SB_API_VERSION < 16 +// An opaque handle to a thread type. +typedef void* SbThread; + +#define kSbThreadInvalid (SbThread) NULL + // Function pointer type for SbThreadCreate. |context| is a pointer-sized bit // of data passed in from the calling thread. typedef void* (*SbThreadEntryPoint)(void* context); @@ -96,59 +121,32 @@ typedef void (*SbThreadLocalDestructor)(void* value); // may have specific rules about how it must be used. typedef int32_t SbThreadAffinity; -#if SB_API_VERSION < 16 // Private structure representing a thread-local key. typedef struct SbThreadLocalKeyPrivate SbThreadLocalKeyPrivate; // A handle to a thread-local key. typedef SbThreadLocalKeyPrivate* SbThreadLocalKey; -#endif - -// Well-defined constant value to mean "no thread ID." -#define kSbThreadInvalidId (SbThreadId)0 // Well-defined constant value to mean "no affinity." #define kSbThreadNoAffinity (SbThreadAffinity) kSbInvalidInt -#if SB_API_VERSION < 16 // Well-defined constant value to mean "no thread local key." #define kSbThreadLocalKeyInvalid (SbThreadLocalKey) NULL -#endif // Returns whether the given thread handle is valid. static inline bool SbThreadIsValid(SbThread thread) { return thread != kSbThreadInvalid; } -// Returns whether the given thread ID is valid. -static inline bool SbThreadIsValidId(SbThreadId id) { - return id != kSbThreadInvalidId; -} - -// Returns whether the given thread priority is valid. -static inline bool SbThreadIsValidPriority(SbThreadPriority priority) { - return priority != kSbThreadNoPriority; -} - // Returns whether the given thread affinity is valid. static inline bool SbThreadIsValidAffinity(SbThreadAffinity affinity) { return affinity != kSbThreadNoAffinity; } -#if SB_API_VERSION < 16 // Returns whether the given thread local variable key is valid. static inline bool SbThreadIsValidLocalKey(SbThreadLocalKey key) { return key != kSbThreadLocalKeyInvalid; } -#endif - -#if SB_API_VERSION >= 16 -// Set the thread priority of the current thread. -SB_EXPORT bool SbThreadSetPriority(SbThreadPriority priority); - -// Get the thread priority of the current thread. -SB_EXPORT bool SbThreadGetPriority(SbThreadPriority* priority); -#endif // Creates a new thread, which starts immediately. // - If the function succeeds, the return value is a handle to the newly @@ -206,7 +204,6 @@ SB_EXPORT bool SbThreadJoin(SbThread thread, void** out_return); // |thread|: The thread to be detached. SB_EXPORT void SbThreadDetach(SbThread thread); -#if SB_API_VERSION < 16 // Yields the currently executing thread, so another thread has a chance to run. SB_EXPORT void SbThreadYield(); @@ -216,21 +213,16 @@ SB_EXPORT void SbThreadYield(); // executing thread should sleep. The function is a no-op if this value is // negative or |0|. SB_EXPORT void SbThreadSleep(int64_t duration); -#endif // Returns the handle of the currently executing thread. SB_EXPORT SbThread SbThreadGetCurrent(); -// Returns the Thread ID of the currently executing thread. -SB_EXPORT SbThreadId SbThreadGetId(); - // Indicates whether |thread1| and |thread2| refer to the same thread. // // |thread1|: The first thread to compare. // |thread2|: The second thread to compare. SB_EXPORT bool SbThreadIsEqual(SbThread thread1, SbThread thread2); -#if SB_API_VERSION < 16 // Returns the debug name of the currently executing thread. SB_EXPORT void SbThreadGetName(char* buffer, int buffer_size); @@ -274,7 +266,6 @@ SB_EXPORT void* SbThreadGetLocalValue(SbThreadLocalKey key); // |key|: The key for which to set the key value. // |value|: The new pointer-sized key value. SB_EXPORT bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value); -#endif // Returns whether |thread| is the current thread. // @@ -282,6 +273,7 @@ SB_EXPORT bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value); static inline bool SbThreadIsCurrent(SbThread thread) { return SbThreadGetCurrent() == thread; } +#endif // Private structure representing the context of a frozen thread. typedef struct SbThreadContextPrivate SbThreadContextPrivate; diff --git a/starboard/tools/api_leak_detector/api_leak_detector.py b/starboard/tools/api_leak_detector/api_leak_detector.py index a31bf0e59f81..15bcfe76960e 100755 --- a/starboard/tools/api_leak_detector/api_leak_detector.py +++ b/starboard/tools/api_leak_detector/api_leak_detector.py @@ -87,6 +87,7 @@ # Allowed POSIX symbols in Starboard 16 _ALLOWED_SB16_POSIX_SYMBOLS = [ + '__errno_location', 'accept', 'bind', 'calloc', diff --git a/starboard/tools/api_leak_detector/stub/debug/docker_debian10_manifest b/starboard/tools/api_leak_detector/stub/debug/docker_debian10_manifest index 016ab12af8a2..e27b45266ccf 100644 --- a/starboard/tools/api_leak_detector/stub/debug/docker_debian10_manifest +++ b/starboard/tools/api_leak_detector/stub/debug/docker_debian10_manifest @@ -26,7 +26,6 @@ __ctype_get_mb_cur_max __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/debug/gn_built_docker_debian11_manifest b/starboard/tools/api_leak_detector/stub/debug/gn_built_docker_debian11_manifest index 7e7d6342ec15..29403aaefcff 100644 --- a/starboard/tools/api_leak_detector/stub/debug/gn_built_docker_debian11_manifest +++ b/starboard/tools/api_leak_detector/stub/debug/gn_built_docker_debian11_manifest @@ -26,7 +26,6 @@ __ctype_get_mb_cur_max __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/debug/manifest b/starboard/tools/api_leak_detector/stub/debug/manifest index 623b073983f2..9896fd581e18 100644 --- a/starboard/tools/api_leak_detector/stub/debug/manifest +++ b/starboard/tools/api_leak_detector/stub/debug/manifest @@ -26,7 +26,6 @@ __ctype_get_mb_cur_max __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/devel/docker_debian10_manifest b/starboard/tools/api_leak_detector/stub/devel/docker_debian10_manifest index 670a82092323..ed0dbbd11652 100644 --- a/starboard/tools/api_leak_detector/stub/devel/docker_debian10_manifest +++ b/starboard/tools/api_leak_detector/stub/devel/docker_debian10_manifest @@ -27,7 +27,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/devel/gn_built_docker_debian11_manifest b/starboard/tools/api_leak_detector/stub/devel/gn_built_docker_debian11_manifest index 59f1232d16d6..480ca8fae802 100644 --- a/starboard/tools/api_leak_detector/stub/devel/gn_built_docker_debian11_manifest +++ b/starboard/tools/api_leak_detector/stub/devel/gn_built_docker_debian11_manifest @@ -27,7 +27,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/devel/manifest b/starboard/tools/api_leak_detector/stub/devel/manifest index 8f01ab5c8d50..d55fed99e981 100644 --- a/starboard/tools/api_leak_detector/stub/devel/manifest +++ b/starboard/tools/api_leak_detector/stub/devel/manifest @@ -27,7 +27,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/gold/docker_debian10_manifest b/starboard/tools/api_leak_detector/stub/gold/docker_debian10_manifest index 02cd3d4a421c..7de42d06b67c 100644 --- a/starboard/tools/api_leak_detector/stub/gold/docker_debian10_manifest +++ b/starboard/tools/api_leak_detector/stub/gold/docker_debian10_manifest @@ -25,7 +25,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/gold/gn_built_docker_debian11_manifest b/starboard/tools/api_leak_detector/stub/gold/gn_built_docker_debian11_manifest index 926e11979a5f..fad0a61a385e 100644 --- a/starboard/tools/api_leak_detector/stub/gold/gn_built_docker_debian11_manifest +++ b/starboard/tools/api_leak_detector/stub/gold/gn_built_docker_debian11_manifest @@ -25,7 +25,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/gold/manifest b/starboard/tools/api_leak_detector/stub/gold/manifest index f0fb7f9d342f..5daffb4f64e0 100644 --- a/starboard/tools/api_leak_detector/stub/gold/manifest +++ b/starboard/tools/api_leak_detector/stub/gold/manifest @@ -25,7 +25,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/qa/docker_debian10_manifest b/starboard/tools/api_leak_detector/stub/qa/docker_debian10_manifest index 495b53fd8d23..cf160cb8c526 100644 --- a/starboard/tools/api_leak_detector/stub/qa/docker_debian10_manifest +++ b/starboard/tools/api_leak_detector/stub/qa/docker_debian10_manifest @@ -26,7 +26,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/qa/gn_built_docker_debian11_manifest b/starboard/tools/api_leak_detector/stub/qa/gn_built_docker_debian11_manifest index a1789127a2cb..21532b8af3a1 100644 --- a/starboard/tools/api_leak_detector/stub/qa/gn_built_docker_debian11_manifest +++ b/starboard/tools/api_leak_detector/stub/qa/gn_built_docker_debian11_manifest @@ -26,7 +26,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/api_leak_detector/stub/qa/manifest b/starboard/tools/api_leak_detector/stub/qa/manifest index 610cc36c596f..bff8901e7ffc 100644 --- a/starboard/tools/api_leak_detector/stub/qa/manifest +++ b/starboard/tools/api_leak_detector/stub/qa/manifest @@ -26,7 +26,6 @@ __ctype_toupper_loc __cxa_atexit __cxa_finalize __duplocale -__errno_location __freelocale __fxstat64 __gmon_start__ diff --git a/starboard/tools/testing/test_runner.py b/starboard/tools/testing/test_runner.py index e8924526f940..343827ae3e5e 100755 --- a/starboard/tools/testing/test_runner.py +++ b/starboard/tools/testing/test_runner.py @@ -204,7 +204,7 @@ def Join(self): def _Run(self) -> None: """Runs the launcher, and assigns a status and a return code.""" - return_code = TargetStatus.NOT_STARTED, 0 + return_code = TargetStatus.NOT_STARTED, 1 try: logging.info("Running launcher") return_code = self.run_test() diff --git a/starboard/win/shared/BUILD.gn b/starboard/win/shared/BUILD.gn index 792217f80d54..5eb68f55dfea 100644 --- a/starboard/win/shared/BUILD.gn +++ b/starboard/win/shared/BUILD.gn @@ -45,7 +45,7 @@ config("starboard_platform_config") { } static_library("starboard_platform") { - # has_pedantic_warnings = true + has_pedantic_warnings = true sources = [ "//starboard/common/thread.cc", diff --git a/starboard/win/shared/configuration_constants.cc b/starboard/win/shared/configuration_constants.cc index a70cdd43cc1c..8486d3b96f0d 100644 --- a/starboard/win/shared/configuration_constants.cc +++ b/starboard/win/shared/configuration_constants.cc @@ -149,4 +149,7 @@ const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB // Whether this platform can map executable memory. This is required for // platforms that want to JIT. SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; #endif diff --git a/starboard/win/win32/cobalt/configuration.py b/starboard/win/win32/cobalt/configuration.py index 831e13502ba5..9990bf4cae62 100644 --- a/starboard/win/win32/cobalt/configuration.py +++ b/starboard/win/win32/cobalt/configuration.py @@ -41,6 +41,7 @@ def GetWebPlatformTestFilters(self): 'TaskTraits*', 'FileTest.Length', 'All/SequenceManagerTest.DelayedTasksDontBadlyStarveNonDelayedWork_SameQueue/WithMessagePumpAlignedWakeUps', # pylint: disable=line-too-long + 'All/SequenceManagerTest.DelayedTasksDontBadlyStarveNonDelayedWork_SameQueue/WithMockTaskRunner', # pylint: disable=line-too-long ], 'renderer_test': [ # Flaky test is still being counted as a fail. diff --git a/starboard/win/win32/platform_configuration/BUILD.gn b/starboard/win/win32/platform_configuration/BUILD.gn index a6adbd2ba801..12b860980e0f 100644 --- a/starboard/win/win32/platform_configuration/BUILD.gn +++ b/starboard/win/win32/platform_configuration/BUILD.gn @@ -69,8 +69,4 @@ config("platform_configuration") { # Enable GNU extensions to get prototypes like ffsl. "_GNU_SOURCE=1", ] - - if (!cobalt_fastbuild) { - ldflags += [ "/DEBUG:FULL" ] - } } diff --git a/starboard/xb1/shared/configuration_constants.cc b/starboard/xb1/shared/configuration_constants.cc index 8fe8d744ece8..6a15e19925ca 100644 --- a/starboard/xb1/shared/configuration_constants.cc +++ b/starboard/xb1/shared/configuration_constants.cc @@ -146,4 +146,7 @@ const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB // Whether this platform can map executable memory. This is required for // platforms that want to JIT. SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; + +// Platform can support partial audio frames +SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; #endif diff --git a/testing/perf/BUILD.gn b/testing/perf/BUILD.gn index fe9b646c7da3..4b7c110af6c3 100644 --- a/testing/perf/BUILD.gn +++ b/testing/perf/BUILD.gn @@ -1 +1 @@ -group("perf") {} \ No newline at end of file +group("perf") {} diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn new file mode 100644 index 000000000000..17a8e4d2e169 --- /dev/null +++ b/third_party/BUILD.gn @@ -0,0 +1,63 @@ +# Copyright 2014 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/features.gni") +import("//build/config/freetype/freetype.gni") +import("//third_party/harfbuzz-ng/harfbuzz.gni") +import("//third_party/libjpeg.gni") + +config("system_libjpeg_config") { + libs = [ "jpeg" ] + defines = [ "USE_SYSTEM_LIBJPEG" ] +} + +config("libjpeg_turbo_config") { + defines = [ "USE_LIBJPEG_TURBO=1" ] +} + +# This is a meta target that forwards to the system's libjpeg, +# third_party/libjpeg, or third_party/libjpeg_turbo depending on the build args +# declared in this file. +group("jpeg") { + if (use_system_libjpeg) { + public_configs = [ ":system_libjpeg_config" ] + } else if (use_libjpeg_turbo) { + public_deps = [ "//third_party/libjpeg_turbo:libjpeg" ] + public_configs = [ ":libjpeg_turbo_config" ] + } else { + public_deps = [ "//third_party/libjpeg:libjpeg" ] + } +} + +# This is a meta target that forwards include paths only to the system's +# libjpeg, third_party/libjpeg, or third_party/libjpeg_turbo depending on the +# build args declared in this file. This is needed, rarely, for targets that +# need to reference libjpeg without explicitly building it. +group("jpeg_includes") { + if (use_system_libjpeg) { + public_configs = [ ":system_libjpeg_config" ] + } else if (use_libjpeg_turbo) { + public_configs = [ "//third_party/libjpeg_turbo:libjpeg_config" ] + } else { + public_configs = [ "//third_party/libjpeg:libjpeg_config" ] + } +} + +# FreeType and HarfBuzz libraries are dependent on each other. This component +# will depend on the appropriate source sets or export the system packages +# for both FreeType and HarfBuzz. +component("freetype_harfbuzz") { + public_configs = [] + public_deps = [] + if (use_system_freetype) { + public_configs += [ "//build/linux:freetype_from_pkgconfig" ] + } else { + public_deps += [ "//third_party/freetype:freetype_source" ] + } + if (use_system_harfbuzz) { + public_configs += [ "//third_party/harfbuzz-ng:harfbuzz_from_pkgconfig" ] + } else { + public_deps += [ "//third_party/harfbuzz-ng:harfbuzz_source" ] + } +} diff --git a/third_party/DEPS b/third_party/DEPS new file mode 100644 index 000000000000..d7eed3584ca1 --- /dev/null +++ b/third_party/DEPS @@ -0,0 +1,13 @@ +# Undo everything in the include_rules section of src/DEPS. +include_rules = [ + '-base', + '-build', + '-ipc', + '-third_party/perfetto/include/perfetto/tracing', + '-third_party/perfetto/include/perfetto/test', + '-library_loaders', + '-testing', + '-third_party/icu/source/common/unicode', + '-third_party/icu/source/i18n/unicode', + '-url', +] diff --git a/third_party/METADATA b/third_party/METADATA new file mode 100644 index 000000000000..aed165666398 --- /dev/null +++ b/third_party/METADATA @@ -0,0 +1,15 @@ +third_party { + identifier { + type: "ChromiumVersion" + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html + } + identifier { + type: "Git" + value: "https://chromium.googlesource.com/chromium/src.git" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" + } + identifier { + type: "UpstreamSubdir" + value: "third_party" + } +} diff --git a/third_party/OWNERS b/third_party/OWNERS index 72e8ffc0db8a..a590f0857c20 100644 --- a/third_party/OWNERS +++ b/third_party/OWNERS @@ -1 +1,26 @@ -* +# Owner approval for 3rd party is only required for +# adding new libraries. Be sure to follow the instructions for adding +# new third party libraries. +# +# https://chromium.googlesource.com/chromium/src.git/+/main/docs/adding_to_third_party.md +# +# For changes to existing code that has no OWNER file, simply TBR= one of +# people below in addition to getting an appropriate code review. Generally +# third_party modules should have owners, so if you find yourself doing this +# more than once or twice for a directory, consider adding an OWNER file. If +# you're making changes and there isn't a more obvious person, the owner is +# probably you! + +# ATL reviewer +file://ATL_OWNERS + +# Automatic round-robin assignment of reviewer for third-party licenses. +# No one receives email to this list, just use it as a reviewer. +chromium-third-party@google.com + +thakis@chromium.org + +per-file .gitignore=* + +# Translation artifacts: +per-file ....xtb=file://tools/translation/TRANSLATION_OWNERS diff --git a/third_party/PRESUBMIT.py b/third_party/PRESUBMIT.py new file mode 100644 index 000000000000..6064a3187595 --- /dev/null +++ b/third_party/PRESUBMIT.py @@ -0,0 +1,165 @@ +# Copyright 2011 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os + +USE_PYTHON3 = True + +PRESUBMIT_VERSION = '2.0.0' + +ANDROID_ALLOWED_LICENSES = [ + 'A(pple )?PSL 2(\.0)?', + 'Android Software Development Kit License', + 'Apache( License)?,?( Version)? 2(\.0)?', + '(New )?([23]-Clause )?BSD( [23]-Clause)?( with advertising clause)?', + 'GNU Lesser Public License', + 'L?GPL ?v?2(\.[01])?( or later)?( with the classpath exception)?', + '(The )?MIT(/X11)?(-like)?( License)?', + 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1', + 'MPL 2(\.0)?', + 'Microsoft Limited Public License', + 'Microsoft Permissive License', + 'Public Domain', + 'Python', + 'SIL Open Font License, Version 1.1', + 'SGI Free Software License B', + 'Unicode, Inc. License', + 'University of Illinois\/NCSA Open Source', + 'X11', + 'Zlib', +] + +def LicenseIsCompatibleWithAndroid(input_api, license): + regex = '^(%s)$' % '|'.join(ANDROID_ALLOWED_LICENSES) + tokens = \ + [x.strip() for x in input_api.re.split(' and |,', license) if len(x) > 0] + has_compatible_license = False + for token in tokens: + if input_api.re.match(regex, token, input_api.re.IGNORECASE): + has_compatible_license = True + break + return has_compatible_license + +def CheckThirdPartyReadmesUpdated(input_api, output_api): + """ + Checks to make sure that README.chromium files are properly updated + when dependencies in third_party are modified. + """ + readmes = [] + files = [] + errors = [] + for f in input_api.AffectedFiles(): + local_path = f.LocalPath() + if input_api.os_path.dirname(local_path) == 'third_party': + continue + if (local_path.startswith('third_party' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'blink' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'boringssl' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'closure_compiler' + input_api.os_path.sep + + 'externs' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'closure_compiler' + input_api.os_path.sep + + 'interfaces' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'feed_library' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'ipcz' + input_api.os_path.sep) and + # TODO(danakj): We should look for the README.chromium file in + # third_party/rust/CRATE_NAME/vVERSION/. + not local_path.startswith('third_party' + input_api.os_path.sep + + 'rust' + input_api.os_path.sep) and + not local_path.startswith('third_party' + input_api.os_path.sep + + 'webxr_test_pages' + input_api.os_path.sep)): + files.append(f) + if local_path.endswith("README.chromium"): + readmes.append(f) + if files and not readmes: + errors.append(output_api.PresubmitPromptWarning( + 'When updating or adding third party code the appropriate\n' + '\'README.chromium\' file should also be updated with the correct\n' + 'version and package information.', files)) + if not readmes: + return errors + + name_pattern = input_api.re.compile( + r'^Name: [a-zA-Z0-9_\-\. \(\)]+\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + shortname_pattern = input_api.re.compile( + r'^Short Name: [a-zA-Z0-9_\-\.]+\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + version_pattern = input_api.re.compile( + r'^Version: [a-zA-Z0-9_\-\+\.:/]+\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + release_pattern = input_api.re.compile( + r'^Security Critical: (yes|no)\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + license_pattern = input_api.re.compile( + r'^License: (.+)\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + not_shipped_pattern = input_api.re.compile( + r'^License File: NOT_SHIPPED\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + license_android_compatible_pattern = input_api.re.compile( + r'^License Android Compatible: (yes|no)\r?$', + input_api.re.IGNORECASE | input_api.re.MULTILINE) + + for f in readmes: + if 'D' in f.Action(): + _IgnoreIfDeleting(input_api, output_api, f, errors) + continue + + contents = input_api.ReadFile(f) + if (not shortname_pattern.search(contents) + and not name_pattern.search(contents)): + errors.append(output_api.PresubmitError( + 'Third party README files should contain either a \'Short Name\' or\n' + 'a \'Name\' which is the name under which the package is\n' + 'distributed. Check README.chromium.template for details.', + [f])) + if not version_pattern.search(contents): + errors.append(output_api.PresubmitError( + 'Third party README files should contain a \'Version\' field.\n' + 'If the package is not versioned or the version is not known\n' + 'list the version as \'unknown\'.\n' + 'Check README.chromium.template for details.', + [f])) + if not release_pattern.search(contents): + errors.append(output_api.PresubmitError( + 'Third party README files should contain a \'Security Critical\'\n' + 'field. This field specifies whether the package is built with\n' + 'Chromium. Check README.chromium.template for details.', + [f])) + license_match = license_pattern.search(contents) + if not license_match: + errors.append(output_api.PresubmitError( + 'Third party README files should contain a \'License\' field.\n' + 'This field specifies the license used by the package. Check\n' + 'README.chromium.template for details.', + [f])) + not_shipped_match = not_shipped_pattern.search(contents) + android_compatible_match = ( + license_android_compatible_pattern.search(contents)) + if (not not_shipped_match and not android_compatible_match and + not LicenseIsCompatibleWithAndroid(input_api, license_match.group(1))): + errors.append(output_api.PresubmitPromptWarning( + 'Cannot determine whether specified license is compatible with\n' + + 'the Android licensing requirements. Please check that the license\n' + + 'name is spelled according to third_party/PRESUBMIT.py. Please see\n' + + 'README.chromium.template for details.', + [f])) + return errors + + +def _IgnoreIfDeleting(input_api, output_api, affected_file, errors): + third_party_dir = input_api.os_path.dirname(affected_file.LocalPath()) + \ + os.path.sep + for f in input_api.AffectedFiles(): + if f.LocalPath().startswith(third_party_dir): + if 'D' not in f.Action(): + errors.append(output_api.PresubmitError( + 'Third party README should only be removed when the whole\n' + 'directory is being removed.\n', [f, affected_file])) diff --git a/third_party/README.chromium b/third_party/README.chromium deleted file mode 100644 index 08a82cbeacad..000000000000 --- a/third_party/README.chromium +++ /dev/null @@ -1,10 +0,0 @@ -The third_party directory contains sources from other projects. - -Code in third_party must document the license under which the source is being -used. If the source itself does not include a license header or file, create -an entry in this file that refers to reliable documentation of the project's -license terms on the web (and add a note pointing here in the README file in -that directory). - - - diff --git a/third_party/README.chromium.template b/third_party/README.chromium.template index 7294612b10b9..a0cc80807cde 100644 --- a/third_party/README.chromium.template +++ b/third_party/README.chromium.template @@ -1,16 +1,17 @@ -Name: Descriptive name of the package -Short Name: Name the package is distributed under (ex. libxml, openssl, etc) -URL: The URL where the package lives -Version: A searchable version number for the package (if the package does not version or is versioned by date or revision this field should be "0" and the revision, or date should be enumerated in the appropriate field) -Date: (OPTIONAL if version is supplied) The date that the package was updated -Revision: (OPTIONAL if version is supplied) The current revision of the package -License: The license under which the package is distributed. Arbitrary text is allowed, but prefer standard forms, eg MIT/X11/BSD/Apache 2.0/GPL/LGPL. -License File: (OPTIONAL) File that contains a copy of the package's license. Use the special value NOT_SHIPPED to indicate that the package is not included in the shipped product, so its license does not need to be included in about:credits and no license file is required. -Security Critical: Either yes or no depending on whether this package is shipped in releases. For example openssl is critical where cygwin is not. -License Android Compatible: (OPTIONAL) Whether the package uses a license compatible with Android. Required only if the package is compatible and the 'License' field uses a non-standard value. - -Description: -A short description of what the package is and is used for. - -Local Modifications: -Enumerate any changes that have been made locally to the package from the shipping version listed above. +Name: Descriptive name of the package +Short Name: Name the package is distributed under (ex. libxml, openssl, etc) +URL: The URL where the package lives +Version: A searchable version number for the package (if the package does not version or is versioned by date or revision this field should be "0" and the revision, or date should be enumerated in the appropriate field) +Date: (OPTIONAL if version is supplied) The date that the package was updated +Revision: (OPTIONAL if version is supplied) The current revision of the package +License: The license under which the package is distributed. Standard forms are only accepted, eg MIT/X11/BSD/Apache 2.0/GPL/LGPL. See ANDROID_ALLOWED_LICENSES in PRESUBMIT.py for allowed patterns. +License File: (OPTIONAL) File that contains a copy of the package's license. Use the special value NOT_SHIPPED to indicate that the package is not included in the shipped product, so its license does not need to be included in about:credits and no license file is required. +Security Critical: Either yes or no depending on whether this package is shipped in releases. For example openssl is critical where cygwin is not. +License Android Compatible: (OPTIONAL) Whether the package uses a license compatible with Android. Required only if the package is compatible and the 'License' field uses a non-standard value. +CPEPrefix: (OPTIONAL) A 'common platform enumeration' version 2.2, as per https://nvd.nist.gov/products/cpe/search, which represents the upstream package. This will be used to report known vulnerabilities in the upstream software package, such that we can be sure to merge fixes for those vulnerabilities. Please ensure you're using the closest applicable upstream version, according to the standard format for the CPE for that package. For example, cpe:/a:xmlsoft:libxslt:1.0.10. If no CPE is available for the package, please specify "unknown". If you're using a patched or modified version which is halfway between two public versions, please "round downwards" to the lower of the public versions (it's better for us to be notified of false-positive vulnerabilities than false-negatives). + +Description: +A short description of what the package is and is used for. + +Local Modifications: +Enumerate any changes that have been made locally to the package from the shipping version listed above. diff --git a/third_party/README.md b/third_party/README.md new file mode 100644 index 000000000000..09147cbb397f --- /dev/null +++ b/third_party/README.md @@ -0,0 +1,5 @@ +The third_party directory contains sources from other projects. + +For guidelines on adding a new package to the third_party directory +can be found at +[//docs/adding_to_third_party.md](../docs/adding_to_third_party.md) diff --git a/third_party/abseil-cpp/absl/base/internal/sysinfo_starboard.cc b/third_party/abseil-cpp/absl/base/internal/sysinfo_starboard.cc index 42224bbdba30..033ea3a0c6dd 100644 --- a/third_party/abseil-cpp/absl/base/internal/sysinfo_starboard.cc +++ b/third_party/abseil-cpp/absl/base/internal/sysinfo_starboard.cc @@ -14,11 +14,10 @@ #include "absl/base/internal/sysinfo.h" -#include - #include "absl/base/attributes.h" #include "starboard/system.h" +#include "starboard/thread.h" namespace absl { ABSL_NAMESPACE_BEGIN @@ -38,7 +37,7 @@ int NumCPUs() { // Return a per-thread small integer ID from pthread's thread-specific data. pid_t GetTID() { - return reinterpret_cast(reinterpret_cast(pthread_self())); + return SbThreadGetId(); } // GetCachedTID() caches the thread ID in thread-local storage (which is a diff --git a/third_party/angle/BUILD.gn b/third_party/angle/BUILD.gn index a399fa4315fc..0b2272acca75 100644 --- a/third_party/angle/BUILD.gn +++ b/third_party/angle/BUILD.gn @@ -254,7 +254,7 @@ angle_static_library("preprocessor") { sources = angle_preprocessor_sources if (is_starboard) { - # suppressed_configs += [ "//starboard/build/config:warnings_as_errors" ] + suppressed_configs += [ "//starboard/build/config:warnings_as_errors" ] } public_deps = [ @@ -518,7 +518,7 @@ angle_static_library("translator") { public_configs += [ ":external_config" ] if (is_starboard) { - # suppressed_configs += [ "//starboard/build/config:warnings_as_errors" ] + suppressed_configs += [ "//starboard/build/config:warnings_as_errors" ] } deps = [ diff --git a/third_party/boringssl/BUILD.gn b/third_party/boringssl/BUILD.gn index d30f5ca9909f..ad88eb2d5f6c 100644 --- a/third_party/boringssl/BUILD.gn +++ b/third_party/boringssl/BUILD.gn @@ -251,7 +251,6 @@ if (!use_cobalt_customizations) { configs -= [ "//starboard/build/config:size" ] configs += [ "//starboard/build/config:speed" ] - # sources += boringssl_linux_x86_64_files if (sb_is_modular) { calling_convention = sabi_variables.calling_convention if ((calling_convention != "aarch64" && calling_convention != "eabi" && @@ -501,10 +500,3 @@ if (build_with_chromium) { seed_corpus = "src/fuzz/server_corpus_no_fuzzer_mode" } } - -# group("boringssl") { -# all_dependent_configs = [ ":external_config" ] -# public_deps = [ -# ":crypto" -# ] -# } \ No newline at end of file diff --git a/third_party/crashpad/crashpad/client/BUILD.gn b/third_party/crashpad/crashpad/client/BUILD.gn index 96775f2cc69a..349c1fbd7d00 100644 --- a/third_party/crashpad/crashpad/client/BUILD.gn +++ b/third_party/crashpad/crashpad/client/BUILD.gn @@ -93,7 +93,7 @@ static_library("client") { deps = [] if (crashpad_is_in_starboard) { - # public_deps += [ "//starboard/elf_loader:evergreen_info" ] + public_deps += [ "//starboard/elf_loader:evergreen_info" ] } if (crashpad_is_in_starboard || crashpad_is_in_native_target_build) { deps += [ "../wrapper/proto:crashpad_annotations_proto" ] diff --git a/third_party/crashpad/crashpad/handler/BUILD.gn b/third_party/crashpad/crashpad/handler/BUILD.gn index 63a4d30229e4..214d5adc508b 100644 --- a/third_party/crashpad/crashpad/handler/BUILD.gn +++ b/third_party/crashpad/crashpad/handler/BUILD.gn @@ -159,7 +159,6 @@ if (!crashpad_is_ios) { crashpad_executable("crashpad_handler") { if (crashpad_is_in_starboard) { install_target = !crashpad_is_android - data_deps = [ "//third_party/icu:icudata" ] } sources = [ "main.cc" ] diff --git a/third_party/freetype/BUILD.gn b/third_party/freetype/BUILD.gn index f33aaa07b4bb..92d43c6e742f 100644 --- a/third_party/freetype/BUILD.gn +++ b/third_party/freetype/BUILD.gn @@ -4,6 +4,7 @@ import("//build/config/chromecast_build.gni") import("//build/config/freetype/freetype.gni") +import("//third_party/harfbuzz-ng/harfbuzz.gni") assert(!use_system_freetype, "Not used when using system freetype.") @@ -61,7 +62,9 @@ config("freetype-warnings") { } } -static_library("freetype") { +source_set("freetype_source") { + visibility = [ "//third_party:freetype_harfbuzz" ] + defines = [] # FreeType only exposes ft2build.h, all other FreeType headers are accessed by macro names. diff --git a/third_party/harfbuzz-ng/BUILD.gn b/third_party/harfbuzz-ng/BUILD.gn index 928874bdc4c2..216f825afe2a 100644 --- a/third_party/harfbuzz-ng/BUILD.gn +++ b/third_party/harfbuzz-ng/BUILD.gn @@ -1,190 +1,403 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. +# Copyright 2014 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/buildflags_paint_preview.gni") import("//build/config/chrome_build.gni") -import("//build/config/linux/pkg_config.gni") +import("//build/config/features.gni") +import("//build/config/freetype/freetype.gni") import("//build/config/ui.gni") - -# The GYP build supports system harfbuzz for non-official builds when using -# pangoft2 1.31.0 or greater (which pulls it in). -# TODO(brettw) we can consider doing this as well, although the benefit is -# unclear and requires shelling out to a script to check the version. -# -# ChromeOS uses an up-to-date system one that we have control over, so we -# don't want to bloat the binary more by including another copy. - -declare_args() { - # Since version 1.31.0, pangoft2 which we depend on pulls in harfbuzz - # anyways. However, we want to have control of the version of harfbuzz - # we use, so don't use system harfbuzz unless we are building for - # chrome os, where we have the system harfbuzz under control. - use_system_harfbuzz = - is_linux && is_chromeos && exec_script(pkg_config_script, - pkg_config_args + [ - "--atleast-version=1.31.0", - "pangoft2", - ], - "value") -} +import("//testing/libfuzzer/fuzzer_test.gni") +import("//third_party/harfbuzz-ng/harfbuzz.gni") if (use_system_harfbuzz) { - assert(!is_starboard, - "System harfbuzz should never be used for Cobalt/Starboard") import("//build/config/linux/pkg_config.gni") - pkg_config("harfbuzz_pkgconfig") { - packages = [ "harfbuzz" ] - } - group("harfbuzz-ng") { - public_configs = [ ":harfbuzz_pkgconfig" ] + pkg_config("harfbuzz_from_pkgconfig") { + visibility = [ + "//third_party:freetype_harfbuzz", + "//third_party/freetype:freetype_source", + ] + packages = [ + "harfbuzz", + "harfbuzz-subset", + ] } } else { - config("harfbuzz-ng_config") { - include_dirs = [ "src" ] + config("harfbuzz_config") { + include_dirs = [ "src/src" ] } config("harfbuzz_warnings") { - cflags = [] - if (is_clang) { - cflags += [ - "-Wno-unused-value", - - # Harfbuzz uses unused typedefs for its static asserts (and its - # static asserts are strange enough that they can't be replaced - # by static_assert). - "-Wno-unused-local-typedef", - ] - } if (is_win) { - if (is_starboard) { - # On amd64, size_t -> int, size_t -> unsigned int. - cflags += [ "/wd4267" ] - } # Result of 32-bit shift implicitly converted to 64 bits. - cflags += [ "/wd4334" ] + cflags = [ "/wd4334" ] } } - if (!is_starboard) { - # See also chrome/browser/ui/libgtk2ui/BUILD.gn which pulls this. - config("pangoft2_link_hack") { - if (is_linux && use_pango && !is_chromeos && !is_official_build && - current_cpu != "arm" && current_cpu != "mipsel" && !is_component_build) { - # These symbols are referenced from libpangoft2, which will be - # dynamically linked later. - ldflags = [ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ] - } - } - } + source_set("harfbuzz_source") { + visibility = [ "//third_party:freetype_harfbuzz" ] + + public = [ + "src/src/hb-blob.h", + "src/src/hb-buffer.h", + "src/src/hb-common.h", + "src/src/hb-cplusplus.hh", + "src/src/hb-deprecated.h", + "src/src/hb-face.h", + "src/src/hb-font.h", + "src/src/hb-ft.h", + "src/src/hb-icu.h", + "src/src/hb-map.h", + "src/src/hb-ot-font.h", + "src/src/hb-ot-layout.h", + "src/src/hb-ot-math.h", + "src/src/hb-ot-shape.h", + "src/src/hb-ot-var.h", + "src/src/hb-ot.h", + "src/src/hb-set.h", + "src/src/hb-shape-plan.h", + "src/src/hb-shape.h", + "src/src/hb-subset.h", + "src/src/hb-unicode.h", + "src/src/hb-version.h", + "src/src/hb.h", + ] - static_library("harfbuzz-ng") { sources = [ - "src/hb-atomic-private.hh", - "src/hb-blob.cc", - "src/hb-blob.h", - "src/hb-buffer-deserialize-json.hh", - "src/hb-buffer-deserialize-text.hh", - "src/hb-buffer-private.hh", - "src/hb-buffer-serialize.cc", - "src/hb-buffer.cc", - "src/hb-buffer.h", - "src/hb-cache-private.hh", - "src/hb-common.cc", - "src/hb-common.h", - "src/hb-deprecated.h", - "src/hb-face-private.hh", - "src/hb-face.cc", - "src/hb-face.h", - "src/hb-fallback-shape.cc", - "src/hb-font-private.hh", - "src/hb-font.cc", - "src/hb-font.h", - "src/hb-icu.cc", - "src/hb-icu.h", - "src/hb-mutex-private.hh", - "src/hb-object-private.hh", - "src/hb-open-file-private.hh", - "src/hb-open-type-private.hh", - "src/hb-ot-font.cc", - "src/hb-ot-font.h", - "src/hb-ot-head-table.hh", - "src/hb-ot-hhea-table.hh", - "src/hb-ot-hmtx-table.hh", - "src/hb-ot-layout-common-private.hh", - "src/hb-ot-layout-gdef-table.hh", - "src/hb-ot-layout-gpos-table.hh", - "src/hb-ot-layout-gsub-table.hh", - "src/hb-ot-layout-gsubgpos-private.hh", - "src/hb-ot-layout-private.hh", - "src/hb-ot-layout.cc", - "src/hb-ot-layout.h", - "src/hb-ot-map-private.hh", - "src/hb-ot-map.cc", - "src/hb-ot-maxp-table.hh", - "src/hb-ot-name-table.hh", - "src/hb-ot-shape-complex-arabic-fallback.hh", - "src/hb-ot-shape-complex-arabic-private.hh", - "src/hb-ot-shape-complex-arabic-table.hh", - "src/hb-ot-shape-complex-arabic.cc", - "src/hb-ot-shape-complex-default.cc", - "src/hb-ot-shape-complex-hangul.cc", - "src/hb-ot-shape-complex-hebrew.cc", - "src/hb-ot-shape-complex-indic-machine.hh", - "src/hb-ot-shape-complex-indic-private.hh", - "src/hb-ot-shape-complex-indic-table.cc", - "src/hb-ot-shape-complex-indic.cc", - "src/hb-ot-shape-complex-myanmar-machine.hh", - "src/hb-ot-shape-complex-myanmar.cc", - "src/hb-ot-shape-complex-private.hh", - "src/hb-ot-shape-complex-thai.cc", - "src/hb-ot-shape-complex-tibetan.cc", - "src/hb-ot-shape-complex-use-machine.hh", - "src/hb-ot-shape-complex-use-private.hh", - "src/hb-ot-shape-complex-use-table.cc", - "src/hb-ot-shape-complex-use.cc", - "src/hb-ot-shape-fallback-private.hh", - "src/hb-ot-shape-fallback.cc", - "src/hb-ot-shape-normalize-private.hh", - "src/hb-ot-shape-normalize.cc", - "src/hb-ot-shape-private.hh", - "src/hb-ot-shape.cc", - "src/hb-ot-shape.h", - "src/hb-ot-tag.cc", - "src/hb-ot-tag.h", - "src/hb-ot.h", - "src/hb-private.hh", - "src/hb-set-private.hh", - "src/hb-set.cc", - "src/hb-set.h", - "src/hb-shape-plan-private.hh", - "src/hb-shape-plan.cc", - "src/hb-shape-plan.h", - "src/hb-shape.cc", - "src/hb-shape.h", - "src/hb-shaper-impl-private.hh", - "src/hb-shaper-list.hh", - "src/hb-shaper-private.hh", - "src/hb-shaper.cc", - "src/hb-unicode-private.hh", - "src/hb-unicode.cc", - "src/hb-unicode.h", - "src/hb-utf-private.hh", - "src/hb-version.h", - "src/hb-warning.cc", - "src/hb.h", + "src/src/OT/Color/CBDT/CBDT.hh", + "src/src/OT/Color/COLR/COLR.hh", + "src/src/OT/Color/CPAL/CPAL.hh", + "src/src/OT/Color/sbix/sbix.hh", + "src/src/OT/Color/svg/svg.hh", + "src/src/OT/Layout/GDEF/GDEF.hh", + "src/src/OT/glyf/VarCompositeGlyph.hh", + "src/src/OT/glyf/composite-iter.hh", + "src/src/OT/glyf/coord-setter.hh", + "src/src/OT/name/name.hh", + "src/src/graph/classdef-graph.hh", + "src/src/graph/coverage-graph.hh", + "src/src/graph/gsubgpos-context.cc", + "src/src/graph/gsubgpos-context.hh", + "src/src/graph/gsubgpos-graph.hh", + "src/src/graph/markbasepos-graph.hh", + "src/src/graph/pairpos-graph.hh", + "src/src/graph/split-helpers.hh", + "src/src/hb-aat-layout-ankr-table.hh", + "src/src/hb-aat-layout-bsln-table.hh", + "src/src/hb-aat-layout-common.hh", + "src/src/hb-aat-layout-feat-table.hh", + "src/src/hb-aat-layout-just-table.hh", + "src/src/hb-aat-layout-kerx-table.hh", + "src/src/hb-aat-layout-morx-table.hh", + "src/src/hb-aat-layout-opbd-table.hh", + "src/src/hb-aat-layout-trak-table.hh", + "src/src/hb-aat-layout.cc", + "src/src/hb-aat-layout.h", + "src/src/hb-aat-layout.hh", + "src/src/hb-aat-ltag-table.hh", + "src/src/hb-aat-map.cc", + "src/src/hb-aat-map.hh", + "src/src/hb-aat.h", + "src/src/hb-algs.hh", + "src/src/hb-array.hh", + "src/src/hb-atomic.hh", + "src/src/hb-bimap.hh", + "src/src/hb-bit-page.hh", + "src/src/hb-bit-set-invertible.hh", + "src/src/hb-bit-set.hh", + "src/src/hb-blob.cc", + "src/src/hb-blob.hh", + "src/src/hb-buffer-deserialize-json.hh", + "src/src/hb-buffer-deserialize-text-glyphs.hh", + "src/src/hb-buffer-deserialize-text-unicode.hh", + "src/src/hb-buffer-serialize.cc", + "src/src/hb-buffer-verify.cc", + "src/src/hb-buffer.cc", + "src/src/hb-buffer.hh", + "src/src/hb-cache.hh", + "src/src/hb-cff-interp-common.hh", + "src/src/hb-cff-interp-cs-common.hh", + "src/src/hb-cff-interp-dict-common.hh", + "src/src/hb-cff1-interp-cs.hh", + "src/src/hb-cff2-interp-cs.hh", + "src/src/hb-common.cc", + "src/src/hb-config.hh", + "src/src/hb-cplusplus.hh", + "src/src/hb-debug.hh", + "src/src/hb-dispatch.hh", + "src/src/hb-draw.cc", + "src/src/hb-draw.h", + "src/src/hb-draw.hh", + "src/src/hb-face-builder.cc", + "src/src/hb-face.cc", + "src/src/hb-face.hh", + "src/src/hb-font.cc", + "src/src/hb-font.hh", + "src/src/hb-ft.cc", + "src/src/hb-icu.cc", + "src/src/hb-iter.hh", + "src/src/hb-kern.hh", + "src/src/hb-limits.hh", + "src/src/hb-machinery.hh", + "src/src/hb-map.cc", + "src/src/hb-map.hh", + "src/src/hb-meta.hh", + "src/src/hb-ms-feature-ranges.hh", + "src/src/hb-multimap.hh", + "src/src/hb-mutex.hh", + "src/src/hb-null.hh", + "src/src/hb-number-parser.hh", + "src/src/hb-number.cc", + "src/src/hb-number.hh", + "src/src/hb-object.hh", + "src/src/hb-open-file.hh", + "src/src/hb-open-type.hh", + "src/src/hb-ot-cff-common.hh", + "src/src/hb-ot-cff1-std-str.hh", + "src/src/hb-ot-cff1-table.cc", + "src/src/hb-ot-cff1-table.hh", + "src/src/hb-ot-cff2-table.cc", + "src/src/hb-ot-cff2-table.hh", + "src/src/hb-ot-cmap-table.hh", + "src/src/hb-ot-color.cc", + "src/src/hb-ot-color.h", + "src/src/hb-ot-deprecated.h", + "src/src/hb-ot-face-table-list.hh", + "src/src/hb-ot-face.cc", + "src/src/hb-ot-face.hh", + "src/src/hb-ot-font.cc", + "src/src/hb-ot-gasp-table.hh", + "src/src/hb-ot-glyf-table.hh", + "src/src/hb-ot-hdmx-table.hh", + "src/src/hb-ot-head-table.hh", + "src/src/hb-ot-hhea-table.hh", + "src/src/hb-ot-hmtx-table.hh", + "src/src/hb-ot-kern-table.hh", + "src/src/hb-ot-layout-base-table.hh", + "src/src/hb-ot-layout-common.hh", + "src/src/hb-ot-layout-gdef-table.hh", + "src/src/hb-ot-layout-gpos-table.hh", + "src/src/hb-ot-layout-gsub-table.hh", + "src/src/hb-ot-layout-gsubgpos.hh", + "src/src/hb-ot-layout-jstf-table.hh", + "src/src/hb-ot-layout.cc", + "src/src/hb-ot-layout.hh", + "src/src/hb-ot-map.cc", + "src/src/hb-ot-map.hh", + "src/src/hb-ot-math-table.hh", + "src/src/hb-ot-math.cc", + "src/src/hb-ot-maxp-table.hh", + "src/src/hb-ot-meta-table.hh", + "src/src/hb-ot-meta.cc", + "src/src/hb-ot-meta.h", + "src/src/hb-ot-metrics.cc", + "src/src/hb-ot-metrics.h", + "src/src/hb-ot-metrics.hh", + "src/src/hb-ot-name-language-static.hh", + "src/src/hb-ot-name-language.hh", + "src/src/hb-ot-name-table.hh", + "src/src/hb-ot-name.cc", + "src/src/hb-ot-name.h", + "src/src/hb-ot-os2-table.hh", + "src/src/hb-ot-os2-unicode-ranges.hh", + "src/src/hb-ot-post-macroman.hh", + "src/src/hb-ot-post-table-v2subset.hh", + "src/src/hb-ot-post-table.hh", + "src/src/hb-ot-shape-fallback.cc", + "src/src/hb-ot-shape-fallback.hh", + "src/src/hb-ot-shape-normalize.cc", + "src/src/hb-ot-shape-normalize.hh", + "src/src/hb-ot-shape.cc", + "src/src/hb-ot-shape.hh", + "src/src/hb-ot-shaper-arabic-fallback.hh", + "src/src/hb-ot-shaper-arabic-joining-list.hh", + "src/src/hb-ot-shaper-arabic-pua.hh", + "src/src/hb-ot-shaper-arabic-table.hh", + "src/src/hb-ot-shaper-arabic-win1256.hh", + "src/src/hb-ot-shaper-arabic.cc", + "src/src/hb-ot-shaper-arabic.hh", + "src/src/hb-ot-shaper-default.cc", + "src/src/hb-ot-shaper-hangul.cc", + "src/src/hb-ot-shaper-hebrew.cc", + "src/src/hb-ot-shaper-indic-machine.hh", + "src/src/hb-ot-shaper-indic-table.cc", + "src/src/hb-ot-shaper-indic.cc", + "src/src/hb-ot-shaper-indic.hh", + "src/src/hb-ot-shaper-khmer-machine.hh", + "src/src/hb-ot-shaper-khmer.cc", + "src/src/hb-ot-shaper-myanmar-machine.hh", + "src/src/hb-ot-shaper-myanmar.cc", + "src/src/hb-ot-shaper-syllabic.cc", + "src/src/hb-ot-shaper-syllabic.hh", + "src/src/hb-ot-shaper-thai.cc", + "src/src/hb-ot-shaper-use-machine.hh", + "src/src/hb-ot-shaper-use-table.hh", + "src/src/hb-ot-shaper-use.cc", + "src/src/hb-ot-shaper-vowel-constraints.cc", + "src/src/hb-ot-shaper-vowel-constraints.hh", + "src/src/hb-ot-shaper.hh", + "src/src/hb-ot-stat-table.hh", + "src/src/hb-ot-tag-table.hh", + "src/src/hb-ot-tag.cc", + "src/src/hb-ot-var-avar-table.hh", + "src/src/hb-ot-var-common.hh", + "src/src/hb-ot-var-cvar-table.hh", + "src/src/hb-ot-var-fvar-table.hh", + "src/src/hb-ot-var-gvar-table.hh", + "src/src/hb-ot-var-hvar-table.hh", + "src/src/hb-ot-var-mvar-table.hh", + "src/src/hb-ot-var.cc", + "src/src/hb-ot-vorg-table.hh", + "src/src/hb-paint-extents.cc", + "src/src/hb-paint-extents.hh", + "src/src/hb-pool.hh", + "src/src/hb-priority-queue.hh", + "src/src/hb-repacker.hh", + "src/src/hb-sanitize.hh", + "src/src/hb-serialize.hh", + "src/src/hb-set-digest.hh", + "src/src/hb-set.cc", + "src/src/hb-set.hh", + "src/src/hb-shape-plan.cc", + "src/src/hb-shape-plan.hh", + "src/src/hb-shape.cc", + "src/src/hb-shaper-impl.hh", + "src/src/hb-shaper-list.hh", + "src/src/hb-shaper.cc", + "src/src/hb-shaper.hh", + "src/src/hb-static.cc", + "src/src/hb-string-array.hh", + "src/src/hb-subset-accelerator.hh", + "src/src/hb-subset-cff-common.cc", + "src/src/hb-subset-cff-common.hh", + "src/src/hb-subset-cff1.cc", + "src/src/hb-subset-cff1.hh", + "src/src/hb-subset-cff2.cc", + "src/src/hb-subset-cff2.hh", + "src/src/hb-subset-input.cc", + "src/src/hb-subset-input.hh", + "src/src/hb-subset-plan.cc", + "src/src/hb-subset-plan.hh", + "src/src/hb-subset-repacker.cc", + "src/src/hb-subset-repacker.h", + "src/src/hb-subset.cc", + "src/src/hb-subset.hh", + "src/src/hb-ucd-table.hh", + "src/src/hb-ucd.cc", + "src/src/hb-unicode-emoji-table.hh", + "src/src/hb-unicode.cc", + "src/src/hb-unicode.hh", + "src/src/hb-utf.hh", + "src/src/hb-vector.hh", + "src/src/hb.hh", ] + # The following sources are explictly not used. + # They are referenced to aid in detecting previously uncategorized files. + unused_sources = [ + "src/src/hb-coretext.cc", + "src/src/hb-coretext.h", + "src/src/hb-directwrite.cc", + "src/src/hb-directwrite.h", + "src/src/hb-fallback-shape.cc", + "src/src/hb-gdi.cc", + "src/src/hb-gdi.h", + "src/src/hb-gobject-structs.cc", + "src/src/hb-gobject-structs.h", + "src/src/hb-gobject.h", + "src/src/hb-graphite2.cc", + "src/src/hb-graphite2.h", + "src/src/hb-style.cc", + "src/src/hb-style.h", + "src/src/hb-uniscribe.cc", + "src/src/hb-uniscribe.h", + ] + assert(unused_sources != []) + defines = [ "HAVE_OT", + "HAVE_FREETYPE", "HAVE_ICU", "HAVE_ICU_BUILTIN", - "HB_NO_MT", + "HB_NO_MMAP", + "HB_NO_PAINT", + "HB_NO_RESOURCE_FORK", + + # Size reductions by disabling parts that we do not currently require: + + # SkPDF needs subsetting but does not require subsetting of layout or CFF tables. + "HB_NO_SUBSET_LAYOUT", + "HB_NO_SUBSET_CFF", + + # Fallback shaper not required, we only use the HarfBuzz internal OT shaper. + "HB_NO_FALLBACK_SHAPE", + + # Tells HarfBuzz to use ICU instead of the own mini UCDN implementation + # that is part of HarfBuzz. + "HB_NO_UCD", + + # Disable .fon file support, not needed for Chrome, and code behind this + # flag produces warnings in Clang. Compare https://crbug.com/1002945. + "HB_NO_WIN1256", + + # TODO(https://crbug.com/949962): Remove once this is fixed upstream. + "U_DISABLE_VERSION_SUFFIX=0", + + # Buffer verification not used in production build. + "HB_NO_BUFFER_VERIFY", + + # We're not using HarfBuzz' drawing functions or debug tools in this build. + "HB_NO_DRAW", + + # Don't ship experimental extensions. + "HB_NO_BORING_EXPANSION", + + # Letting HarfBuzz enable warnings through pragmas can block compiler + # upgrades in situations where say a ToT compiler build adds a new + # stricter warning under -Wfoowarning-subgroup. HarfBuzz pragma-enables + # -Wfoowarning which default-enables -Wfoowarning-subgroup implicitly but + # HarfBuzz upstream is not yet clean of warnings produced for + # -Wfoowarning-subgroup. Hence disabling pragma warning control here. + # See also https:/crbug.com/1203071 + "HB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR", + "HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING", ] - if (is_starboard) { - # Ensure the below -= is ok even if chromium_code wasn't already added. - # The subsequent -= will remove all copies of the config. - configs += [ "//build/config/compiler:chromium_code" ] + if (!is_win && !is_mac) { + # Needed for HarfBuzz mutex implementation, see hb-mutex.hh + defines += [ "HAVE_PTHREAD" ] + } + + if (enable_paint_preview) { + # Paint Previews make use of CFF subsetting. However, enabling this is + # expensive for binary size so only compile it when Paint Previews are + # compiled. + defines -= [ "HB_NO_SUBSET_CFF" ] + } + + if (is_component_build) { + if (is_win) { + defines += [ "HB_EXTERN=__declspec (dllexport)" ] + } else { + defines += [ "HB_EXTERN=__attribute__((visibility(\"default\")))" ] + # Exposing symbols in component builds can cause a mixture of system + # harfbuzz symbols and //third_party harfbuzz symbols to be loaded at + # the same time. This can cause issues for libraries that indirectly + # load harfbuzz like pango (see https://crbug.com/1146397), so we need + # to include metrics symbols (i.e. have HB_NO_METRICS undefined) to + # prevent pango from using the system library. Currently, HB_NO_METRICS + # is always disabled, due to + # https://github.com/harfbuzz/harfbuzz/issues/3482 - if that changes + # "HB_NO_METRICS" needs to be removed from the defines list here. + # TODO(https://crbug.com/1148459): Remove this workaround once bug + # 1148459 is fixed. + } + } + + if (use_system_freetype) { + configs += [ "//build/linux:freetype_from_pkgconfig" ] + } else { + configs += [ "//third_party/freetype:freetype_component_config" ] } configs -= [ "//build/config/compiler:chromium_code" ] configs += [ @@ -194,39 +407,42 @@ if (use_system_harfbuzz) { # correctly. ":harfbuzz_warnings", ] - public_configs = [ ":harfbuzz-ng_config" ] - - deps = [ - "//third_party/icu:icuuc", - ] - if (!is_starboard) { - if (is_mac) { - sources += [ - "src/hb-coretext.cc", - "src/hb-coretext.h", - ] - defines += [ "HAVE_CORETEXT" ] + # This allows the compiler to do further optimizations in the code. + if (!is_debug) { + configs -= [ "//build/config/compiler:default_optimization" ] + configs += [ "//build/config/compiler:optimize_speed" ] } - # When without -fvisibility=hidden for pango to use the harfbuzz - # in the tree, all symbols pango needs must be included, or - # pango uses mixed versions of harfbuzz and leads to crash. - # See crbug.com/462689. - if (is_linux && use_pango && !is_chromeos && !is_official_build && - current_cpu != "arm" && current_cpu != "mipsel") { - deps += [ "//build/linux:freetype2" ] - configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] - configs += [ - "//build/config/linux:glib", - ] - sources += [ - "src/hb-ft.cc", - "src/hb-ft.h", - "src/hb-glib.cc", - "src/hb-glib.h", - ] - } + public_configs = [ ":harfbuzz_config" ] + + deps = [ "//third_party/icu:icuuc" ] + + if (use_glib) { + configs += [ "//build/config/linux:glib" ] + public += [ "src/src/hb-glib.h" ] + sources += [ "src/src/hb-glib.cc" ] } } } + +# Not all checkouts have a //base directory. +if (build_with_chromium) { + fuzzer_test("hb_shape_fuzzer") { + sources = [ "fuzz/hb_shape_fuzzer.cc" ] + deps = [ + "//base", + "//third_party:freetype_harfbuzz", + ] + seed_corpus = "fuzz/seed_corpus" + } + + fuzzer_test("hb_subset_fuzzer") { + sources = [ "fuzz/hb_subset_fuzzer.cc" ] + deps = [ + "//base", + "//third_party:freetype_harfbuzz", + ] + seed_corpus = "fuzz/seed_corpus" + } +} diff --git a/third_party/harfbuzz-ng/COPYING b/third_party/harfbuzz-ng/COPYING deleted file mode 100644 index 9d1056f40b1c..000000000000 --- a/third_party/harfbuzz-ng/COPYING +++ /dev/null @@ -1,36 +0,0 @@ -HarfBuzz is licensed under the so-called "Old MIT" license. Details follow. -For parts of HarfBuzz that are licensed under different licenses see individual -files names COPYING in subdirectories where applicable. - -Copyright © 2010,2011,2012 Google, Inc. -Copyright © 2012 Mozilla Foundation -Copyright © 2011 Codethink Limited -Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies) -Copyright © 2009 Keith Stribley -Copyright © 2009 Martin Hosken and SIL International -Copyright © 2007 Chris Wilson -Copyright © 2006 Behdad Esfahbod -Copyright © 2005 David Turner -Copyright © 2004,2007,2008,2009,2010 Red Hat, Inc. -Copyright © 1998-2004 David Turner and Werner Lemberg - -For full copyright notices consult the individual files in the package. - - -Permission is hereby granted, without written agreement and without -license or royalty fees, to use, copy, modify, and distribute this -software and its documentation for any purpose, provided that the -above copyright notice and the following two paragraphs appear in -all copies of this software. - -IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR -DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN -IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS -ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO -PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/third_party/harfbuzz-ng/DEPS b/third_party/harfbuzz-ng/DEPS new file mode 100644 index 000000000000..58cd3c381e87 --- /dev/null +++ b/third_party/harfbuzz-ng/DEPS @@ -0,0 +1,5 @@ +specific_include_rules = { + 'hb_.*_fuzzer\.cc': [ + '+base', + ], +} diff --git a/third_party/harfbuzz-ng/DIR_METADATA b/third_party/harfbuzz-ng/DIR_METADATA new file mode 100644 index 000000000000..38e8f0f1b011 --- /dev/null +++ b/third_party/harfbuzz-ng/DIR_METADATA @@ -0,0 +1,4 @@ +monorail { + component: "Blink>Fonts" +} +team_email: "layout-dev@chromium.org" diff --git a/third_party/harfbuzz-ng/METADATA b/third_party/harfbuzz-ng/METADATA index 429dca679488..7e41e63d40d4 100644 --- a/third_party/harfbuzz-ng/METADATA +++ b/third_party/harfbuzz-ng/METADATA @@ -1,30 +1,15 @@ -name: "harfbuzz-ng" -description: - "HarfBuzz (also formerly known as harfbuzz-ng) is a text shaping library and " - "a dependency of Cobalt's layout engine." - third_party { identifier { type: "ChromiumVersion" - value: "48.0.2564.116" # from https://chromereleases.googleblog.com/2016/02/stable-channel-update_18.html + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html } identifier { type: "Git" value: "https://chromium.googlesource.com/chromium/src.git" - version: "ba6eb95383b3c41f6b91ce448bdc2bd3e39e1b8b" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" } identifier { type: "UpstreamSubdir" value: "third_party/harfbuzz-ng" } - last_upgrade_date { - year: 2015 - month: 11 - day: 24 - } - license_type: NOTICE - local_modifications: - '11/11/21 - Added BUILD.gn as part of GN migration.' - 'Contents taken from https://chromium.googlesource.com/chromium/src/+/518b35929ff33d0dc2397a186eecbc3b536acb40/third_party/harfbuzz-ng/BUILD.gn' - 'and modified for Cobalt.' } diff --git a/third_party/harfbuzz-ng/NEWS b/third_party/harfbuzz-ng/NEWS deleted file mode 100644 index 9cfda32dafcd..000000000000 --- a/third_party/harfbuzz-ng/NEWS +++ /dev/null @@ -1,1268 +0,0 @@ -Overview of changes leading to 1.1.1 -Wednesday, November 24, 2015 -==================================== - -- Build fixes, specially for hb-coretext. - - -Overview of changes leading to 1.1.0 -Wednesday, November 18, 2015 -==================================== - -- Implement 'stch' stretch feature for Syriac Abbreviation Mark. - https://github.com/behdad/harfbuzz/issues/141 -- Disable use of decompose_compatibility() callback. -- Implement "shaping" of various Unicode space characters, even - if the font does not support them. - https://github.com/behdad/harfbuzz/issues/153 -- If font does not support U+2011 NO-BREAK HYPHEN, fallback to - U+2010 HYPHEN. -- Changes resulting from libFuzzer continuous fuzzing: - * Reject font tables that need more than 8 edits, - * Bound buffer growth during shaping to 32x, - * Fix assertions and other issues at OOM / buffer max-growth. -- Misc fixes and optimizations. -- API changes: - * All fonts created with hb_font_create() now inherit from - (ie. have parent) hb_font_get_empty(). - - -Overview of changes leading to 1.0.6 -Thursday, October 15, 2015 -==================================== - -- Reduce max nesting level in OT lookups from 8 to 6. - Should not affect any real font as far as I know. -- Fix memory access issue in ot-font. -- Revert default load-flags of fonts created using hb_ft_font_create() - back to FT_LOAD_DEFAULT|FT_LOAD_NO_HINTING. This was changed in - last release (1.0.5), but caused major issues, so revert. - https://github.com/behdad/harfbuzz/issues/143 - - -Overview of changes leading to 1.0.5 -Tuesday, October 13, 2015 -==================================== - -- Fix multiple memory access bugs discovered using libFuzzer. - https://github.com/behdad/harfbuzz/issues/139 - Everyone should upgrade to this version as soon as possible. - We now have continuous fuzzing set up, to avoid issues like - these creeping in again. -- Misc fixes. - -- New API: - * hb_font_set_parent(). - * hb_ft_font_[sg]et_load_flags() - The default flags for fonts created using hb_ft_font_create() - has changed to default to FT_LOAD_DEFAULT now. Previously it - was defaulting to FT_LOAD_DFEAULT|FT_LOAD_NO_HINTING. - -- API changes: - * Fonts now default to units-per-EM as their scale, instead of 0. - * hb_font_create_sub_font() does NOT make parent font immutable - anymore. hb_font_make_immutable() does. - - -Overview of changes leading to 1.0.4 -Wednesday, September 30, 2015 -==================================== - -- Fix minor out-of-bounds read error. - - -Overview of changes leading to 1.0.3 -Tuesday, September 1, 2015 -==================================== - -- Start of user documentation, from Simon Cozens! -- Implement glyph_extents() for TrueType fonts in hb-ot-font. -- Improve GPOS cursive attachments with conflicting lookups. -- More fixes for cluster-level = 1. -- Uniscribe positioning fix. - - -Overview of changes leading to 1.0.2 -Wednesday, August 19, 2015 -==================================== - -- Fix shaping with cluster-level > 0. -- Fix Uniscribe backend font-size scaling. -- Declare dependencies in harfbuzz.pc. - FreeType is not declared though, to avoid bugs in pkg-config - 0.26 with recursive dependencies. -- Slightly improved debug infrastructure. More to come later. -- Misc build fixes. - - -Overview of changes leading to 1.0.1 -Monday, July 27, 2015 -==================================== - -- Fix out-of-bounds access in USE shaper. - - -Overview of changes leading to 1.0.0 -Sunday, July 26, 2015 -==================================== - -- Implement Universal Shaping Engine: - https://www.microsoft.com/typography/OpenTypeDev/USE/intro.htm - http://blogs.windows.com/bloggingwindows/2015/02/23/windows-shapes-the-worlds-languages/ -- Bump version to 1.0.0. The soname was NOT bumped. - - -Overview of changes leading to 0.9.42 -Thursday, July 26, 2015 -===================================== - -- New API to allow for retrieving finer-grained cluster - mappings if the client desires to handle them. Default - behavior is unchanged. -- Fix cluster merging when removing default-ignorables. -- Update to Unicode 8.0 -- hb-graphite2 fixes. -- Misc fixes. -- Removed HB_NO_MERGE_CLUSTERS hack. -- New API: - hb_buffer_cluster_level_t enum - hb_buffer_get_cluster_level() - hb_buffer_set_cluster_level() - hb-shape / hb-view --cluster-level - - -Overview of changes leading to 0.9.41 -Thursday, June 18, 2015 -===================================== - -- Fix hb-coretext with trailing whitespace in right-to-left. -- New API: hb_buffer_reverse_range(). -- Allow implementing atomic ops in config.h. -- Fix hb_language_t in language bindings. -- Misc fixes. - - -Overview of changes leading to 0.9.40 -Friday, March 20, 2015 -===================================== - -- Another hb-coretext crasher fix. Ouch! -- Happy Norouz! - - -Overview of changes leading to 0.9.39 -Wednesday, March 4, 2015 -===================================== - -- Critical hb-coretext fixes. -- Optimizations and refactoring; no functional change - expected. -- Misc build fixes. - - -Overview of changes leading to 0.9.38 -Friday, January 23, 2015 -===================================== - -- Fix minor out-of-bounds access in Indic shaper. -- Change New Tai Lue shaping engine from South-East Asian to default, - reflecting change in Unicode encoding model. -- Add hb-shape --font-size. Can take up to two numbers for separate - x / y size. -- Fix CoreText and FreeType scale issues with negative scales. -- Reject blobs larger than 2GB. This might break some icu-le-hb clients - that need security fixes. See: - http://www.icu-project.org/trac/ticket/11450 -- Avoid accessing font tables during face destruction, in casce rogue - clients released face data already. -- Fix up gobject-introspection a bit. Python bindings kinda working. - See README.python. -- Misc fixes. -- API additions: - hb_ft_face_create_referenced() - hb_ft_font_create_referenced() - - -Overview of changes leading to 0.9.37 -Wednesday, December 17, 2014 -===================================== - -- Fix out-of-bounds access in Context lookup format 3. -- Indic: Allow ZWJ/ZWNJ before syllable modifiers. - - -Overview of changes leading to 0.9.36 -Thursday, November 20, 2014 -===================================== - -- First time that three months went by without a release since - 0.9.2 was released on August 10, 2012! -- Fix performance bug in hb_ot_collect_glyphs(): - https://bugzilla.mozilla.org/show_bug.cgi?id=1090869 -- Add basic vertical-text support to hb-ot-font. -- Misc build fixes. - - -Overview of changes leading to 0.9.35 -Saturday, August 13, 2014 -===================================== - -- Fix major shape-plan caching bug when more than one shaper were - provided to hb_shape_full() (as exercised by XeTeX). - http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1246370.html -- Fix Arabic fallback shaping regression. This was broken in 0.9.32. -- Major hb-coretext fixes. That backend is complete now, including - respecing buffer direction and language, down to vertical writing. -- Build fixes for Windows CE. Should build fine now. -- Misc fixes: - Use atexit() only if it's safe to call from shared library - https://bugs.freedesktop.org/show_bug.cgi?id=82246 - Mandaic had errors in its Unicode Joining_Type - https://bugs.freedesktop.org/show_bug.cgi?id=82306 -- API changes: - - * hb_buffer_clear_contents() does not reset buffer flags now. - - After 763e5466c0a03a7c27020e1e2598e488612529a7, one doesn't - need to set flags for different pieces of text. The flags now - are something the client sets up once, depending on how it - actually uses the buffer. As such, don't clear it in - clear_contents(). - - I don't expect any changes to be needed to any existing client. - - -Overview of changes leading to 0.9.34 -Saturday, August 2, 2014 -===================================== - -- hb_feature_from_string() now accepts CSS font-feature-settings format. -- As a result, hb-shape / hb-view --features also accept CSS-style strings. - Eg, "'liga' off" is accepted now. -- Add old-spec Myanmar shaper: - https://bugs.freedesktop.org/show_bug.cgi?id=81775 -- Don't apply 'calt' in Hangul shaper. -- Fix mark advance zeroing for Hebrew shaper: - https://bugs.freedesktop.org/show_bug.cgi?id=76767 -- Implement Windows-1256 custom Arabic shaping. Only built on Windows, - and requires help from get_glyph(). Used by Firefox. - https://bugzilla.mozilla.org/show_bug.cgi?id=1045139 -- Disable 'liga' in vertical text. -- Build fixes. -- API changes: - - * Make HB_BUFFER_FLAG_BOT/EOT easier to use. - - Previously, we expected users to provide BOT/EOT flags when the - text *segment* was at paragraph boundaries. This meant that for - clients that provide full paragraph to HarfBuzz (eg. Pango), they - had code like this: - - hb_buffer_set_flags (hb_buffer, - (item_offset == 0 ? HB_BUFFER_FLAG_BOT : 0) | - (item_offset + item_length == paragraph_length ? - HB_BUFFER_FLAG_EOT : 0)); - - hb_buffer_add_utf8 (hb_buffer, - paragraph_text, paragraph_length, - item_offset, item_length); - - After this change such clients can simply say: - - hb_buffer_set_flags (hb_buffer, - HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT); - - hb_buffer_add_utf8 (hb_buffer, - paragraph_text, paragraph_length, - item_offset, item_length); - - Ie, HarfBuzz itself checks whether the segment is at the beginning/end - of the paragraph. Clients that only pass item-at-a-time to HarfBuzz - continue not setting any flags whatsoever. - - Another way to put it is: if there's pre-context text in the buffer, - HarfBuzz ignores the BOT flag. If there's post-context, it ignores - EOT flag. - - -Overview of changes leading to 0.9.33 -Tuesday, July 22, 2014 -===================================== - -- Turn off ARabic 'cswh' feature that was accidentally turned on. -- Add HB_TAG_MAX_SIGNED. -- Make hb_face_make_immutable() really make face immutable! -- Windows build fixes. - - -Overview of changes leading to 0.9.32 -Thursday, July 17, 2014 -===================================== - -- Apply Arabic shaping features in spec order exactly. -- Another fix for Mongolian free variation selectors. -- For non-Arabic scripts in Arabic shaper apply 'rlig' and 'calt' - together. -- Minor adjustment to U+FFFD logic. -- Fix hb-coretext build. - - -Overview of changes leading to 0.9.31 -Wednesday, July 16, 2014 -===================================== - -- Only accept valid UTF-8/16/32; we missed many cases before. -- Better shaping of invalid UTF-8/16/32. Falls back to - U+FFFD REPLACEMENT CHARACTER now. -- With all changes in this release, the buffer will contain fully - valid Unicode after hb_buffer_add_utf8/16/32 no matter how - broken the input is. This can be overriden though. See below. -- Fix Mongolian Variation Selectors for fonts without GDEF. -- Fix minor invalid buffer access. -- Accept zh-Hant and zh-Hans language tags. hb_ot_tag_to_language() - now uses these instead of private tags. -- Build fixes. -- New API: - * hb_buffer_add_codepoints(). This does what hb_buffer_add_utf32() - used to do, ie. no validity check on the input at all. add_utf32 - now replaces invalid Unicode codepoints with the replacement - character (see below). - * hb_buffer_set_replacement_codepoint() - * hb_buffer_get_replacement_codepoint() - Previously, in hb_buffer_add_utf8 and hb_buffer_add_utf16, when - we detected broken input, we replaced that with (hb_codepoint_t)-1. - This has changed to use U+FFFD now, but can be changed using these - new API. - - -Overview of changes leading to 0.9.30 -Wednesday, July 9, 2014 -===================================== - -- Update to Unicode 7.0.0: - * New scripts Manichaean and Psalter Pahlavi are shaped using - Arabic shaper. - * All the other new scripts to through the generic shaper for - now. -- Minor Indic improvements. -- Fix graphite2 backend cluster mapping [crasher!] -- API changes: - * New HB_SCRIPT_* values for Unicode 7.0 scripts. - * New function hb_ot_layout_language_get_required_feature(). -- Build fixes. - - -Overview of changes leading to 0.9.29 -Thursday, May 29, 2014 -===================================== - -- Implement cmap in hb-ot-font.h. No variation-selectors yet. -- Myanmar: Allow MedialYa+Asat. -- Various Indic fixes: - * Support most characters in Extended Devanagary and Vedic - Unicode blocks. - * Allow digits and a some punctuation as consonant placeholders. -- Build fixes. - - -Overview of changes leading to 0.9.28 -Monday, April 28, 2014 -===================================== - -- Unbreak old-spec Indic shaping. (bug 76705) -- Fix shaping of U+17DD and U+0FC6. -- Add HB_NO_MERGE_CLUSTERS build option. NOT to be enabled by default - for shipping libraries. It's an option for further experimentation - right now. When we are sure how to do it properly, we will add - public run-time API for the functionality. -- Build fixes. - - -Overview of changes leading to 0.9.27 -Tuesday, March 18, 2014 -===================================== - -- Don't use "register" storage class specifier -- Wrap definition of free_langs() with HAVE_ATEXIT -- Add coretext_aat shaper and hb_coretext_face_create() constructor -- If HAVE_ICU_BUILTIN is defined, use hb-icu Unicode callbacks -- Add Myanmar test case from OpenType Myanmar spec -- Only do fallback Hebrew composition if no GPOS 'mark' available -- Allow bootstrapping without gtk-doc -- Use AM_MISSING_PROG for ragel and git -- Typo in ucdn's Makefile.am -- Improve MemoryBarrier() implementation - - -Overview of changes leading to 0.9.26 -Thursday, January 30, 2014 -===================================== - -- Misc fixes. -- Fix application of 'rtlm' feature. -- Automatically apply frac/numr/dnom around U+2044 FRACTION SLASH. -- New header: hb-ot-shape.h -- Uniscribe: fix scratch-buffer accounting. -- Reorder Tai Tham SAKOT to after tone-marks. -- Add Hangul shaper. -- New files: - hb-ot-shape-complex-hangul.cc - hb-ot-shape-complex-hebrew.cc - hb-ot-shape-complex-tibetan.cc -- Disable 'cswh' feature in Arabic shaper. -- Coretext: better handle surrogate pairs. -- Add HB_TAG_MAX and _HB_SCRIPT_MAX_VALUE. - - -Overview of changes leading to 0.9.25 -Wednesday, December 4, 2013 -===================================== - -- Myanmar shaper improvements. -- Avoid font fallback in CoreText backend. -- Additional OpenType language tag mappiongs. -- More aggressive shape-plan caching. -- Build with / require automake 1.13. -- Build with libtool 2.4.2.418 alpha to support ppc64le. - - -Overview of changes leading to 0.9.24 -Tuesday, November 13, 2013 -===================================== - -- Misc compiler warning fixes with clang. -- No functional changes. - - -Overview of changes leading to 0.9.23 -Monday, October 28, 2013 -===================================== - -- "Udupi HarfBuzz Hackfest", Paris, October 14..18 2013. -- Fix (Chain)Context recursion with non-monotone lookup positions. -- Misc Indic bug fixes. -- New Javanese / Buginese shaping, similar to Windows 8.1. - - -Overview of changes leading to 0.9.22 -Thursday, October 3, 2013 -===================================== - -- Fix use-after-end-of-scope in hb_language_from_string(). -- Fix hiding of default_ignorables if font doesn't have space glyph. -- Protect against out-of-range lookup indices. - -- API Changes: - - * Added hb_ot_layout_table_get_lookup_count() - - -Overview of changes leading to 0.9.21 -Monday, September 16, 2013 -===================================== - -- Rename gobject-introspection library name from harfbuzz to HarfBuzz. -- Remove (long disabled) hb-old and hb-icu-le test shapers. -- Misc gtk-doc and gobject-introspection annotations. -- Misc fixes. -- API changes: - - * Add HB_SET_VALUE_INVALID - -Overview of changes leading to 0.9.20 -Thursday, August 29, 2013 -===================================== - -General: -- Misc substitute_closure() fixes. -- Build fixes. - -Documentation: -- gtk-doc boilerplate integrated. Docs are built now, but - contain no contents. By next release hopefully we have - some content in. Enable using --enable-gtk-doc. - -GObject and Introspection: -- Added harfbuzz-gobject library (hb-gobject.h) that has type - bindings for all HarfBuzz objects and enums. Enable using - --with-gobject. -- Added gobject-introspection boilerplate. Nothing useful - right now. Work in progress. Gets enabled automatically if - --with-gobject is used. Override with --disable-introspection. - -OpenType shaper: -- Apply 'mark' in Myanmar shaper. -- Don't apply 'dlig' by default. - -Uniscribe shaper: -- Support user features. -- Fix loading of fonts that are also installed on the system. -- Fix shaping of Arabic Presentation Forms. -- Fix build with wide chars. - -CoreText shaper: -- Support user features. - -Source changes: -- hb_face_t code moved to hb-face.h / hb-face.cc. -- Added hb-deprecated.h. - -API changes: -- Added HB_DISABLE_DEPRECATED. -- Deprecated HB_SCRIPT_CANADIAN_ABORIGINAL; replaced by - HB_SCRIPT_CANADIAN_SYLLABICS. -- Deprecated HB_BUFFER_FLAGS_DEFAULT; replaced by - HB_BUFFER_FLAG_DEFAULT. -- Deprecated HB_BUFFER_SERIALIZE_FLAGS_DEFAULT; replaced by - HB_BUFFER_SERIALIZE_FLAG_DEFAULT. - - -Overview of changes leading to 0.9.19 -Tuesday, July 16, 2013 -===================================== - -- Build fixes. -- Better handling of multiple variation selectors in a row. -- Pass on variation selector to GSUB if not consumed by cmap. -- Fix undefined memory access. -- Add Javanese config to Indic shaper. -- Misc bug fixes. - -Overview of changes leading to 0.9.18 -Tuesday, May 28, 2013 -===================================== - -New build system: - -- All unneeded code is all disabled by default, - -- Uniscribe and CoreText shapers can be enabled with their --with options, - -- icu_le and old shapers cannot be enabled for now, - -- glib, freetype, and cairo will be detected automatically. - They can be force on/off'ed with their --with options, - -- icu and graphite2 are default off, can be enabled with their --with - options, - -Moreover, ICU support is now build into a separate library: -libharfbuzz-icu.so, and a new harfbuzz-icu.pc is shipped for it. -Distros can enable ICU now without every application on earth -getting linked to via libharfbuzz.so. - -For distros I recommend that they make sure they are building --with-glib ---with-freetype --with-cairo, --with-icu, and optionally --with-graphite2; -And package harfbuzz and harfbuzz-icu separately. - - -Overview of changes leading to 0.9.17 -Monday, May 20, 2013 -===================================== - -- Build fixes. -- Fix bug in hb_set_get_min(). -- Fix regression with Arabic mark positioning / width-zeroing. - -Overview of changes leading to 0.9.16 -Friday, April 19, 2013 -===================================== - -- Major speedup in OpenType lookup processing. With the Amiri - Arabic font, this release is over 3x faster than previous - release. All scripts / languages should see this speedup. - -- New --num-iterations option for hb-shape / hb-view; useful for - profiling. - -Overview of changes leading to 0.9.15 -Friday, April 05, 2013 -===================================== - -- Build fixes. -- Fix crasher in graphite2 shaper. -- Fix Arabic mark width zeroing regression. -- Don't compose Hangul jamo into Unicode syllables. - - -Overview of changes leading to 0.9.14 -Thursday, March 21, 2013 -===================================== - -- Build fixes. -- Fix time-consuming sanitize with malicious fonts. -- Implement hb_buffer_deserialize_glyphs() for both json and text. -- Do not ignore Hangul filler characters. -- Indic fixes: - * Fix Malayalam pre-base reordering interaction with post-forms. - * Further adjust ZWJ handling. Should fix known regressions from - 0.9.13. - - -Overview of changes leading to 0.9.13 -Thursday, February 25, 2013 -===================================== - -- Build fixes. -- Ngapi HarfBuzz Hackfest in London (February 2013): - * Fixed all known Indic bugs, - * New Win8-style Myanmar shaper, - * New South-East Asian shaper for Tai Tham, Cham, and New Tai Lue, - * Smartly ignore Default_Ignorable characters (joiners, etc) wheb - matching GSUB/GPOS lookups, - * Fix 'Phags-Pa U+A872 shaping, - * Fix partial disabling of default-on features, - * Allow disabling of TrueType kerning. -- Fix possible crasher with broken fonts with overlapping tables. -- Removed generated files from git again. So, one needs ragel to - bootstrap from the git tree. - -API changes: -- hb_shape() and related APIs now abort if buffer direction is - HB_DIRECTION_INVALID. Previously, hb_shape() was calling - hb_buffer_guess_segment_properties() on the buffer before - shaping. The heuristics in that function are fragile. If the - user really wants the old behvaior, they can call that function - right before calling hb_shape() to get the old behavior. -- hb_blob_create_sub_blob() always creates sub-blob with - HB_MEMORY_MODE_READONLY. See comments for the reason. - - -Overview of changes leading to 0.9.12 -Thursday, January 18, 2013 -===================================== - -- Build fixes for Sun compiler. -- Minor bug fix. - -Overview of changes leading to 0.9.11 -Thursday, January 10, 2013 -===================================== - -- Build fixes. -- Fix GPOS mark attachment with null Anchor offsets. -- [Indic] Fix old-spec reordering of viramas if sequence ends in one. -- Fix multi-threaded shaper data creation crash. -- Add atomic ops for Solaris. - -API changes: -- Rename hb_buffer_clear() to hb_buffer_clear_contents(). - - -Overview of changes leading to 0.9.10 -Thursday, January 3, 2013 -===================================== - -- [Indic] Fixed rendering of Malayalam dot-reph -- Updated OT language tags. -- Updated graphite2 backend. -- Improved hb_ot_layout_get_size_params() logic. -- Improve hb-shape/hb-view help output. -- Fixed hb-set.h implementation to not crash. -- Fixed various issues with hb_ot_layout_collect_lookups(). -- Various build fixes. - -New API: - -hb_graphite2_face_get_gr_face() -hb_graphite2_font_get_gr_font() -hb_coretext_face_get_cg_font() - -Modified API: - -hb_ot_layout_get_size_params() - - -Overview of changes leading to 0.9.9 -Wednesday, December 5, 2012 -==================================== - -- Fix build on Windows. -- Minor improvements. - - -Overview of changes leading to 0.9.8 -Tuesday, December 4, 2012 -==================================== - - -- Actually implement hb_shape_plan_get_shaper (). -- Make UCDB data tables const. -- Lots of internal refactoring in OTLayout tables. -- Flesh out hb_ot_layout_lookup_collect_glyphs(). - -New API: - -hb_ot_layout_collect_lookups() -hb_ot_layout_get_size_params() - - -Overview of changes leading to 0.9.7 -Sunday, November 21, 2012 -==================================== - - -HarfBuzz "All-You-Can-Eat-Sushi" (aka Vancouver) Hackfest and follow-on fixes. - -- Fix Arabic contextual joining using pre-context text. -- Fix Sinhala "split matra" mess. -- Fix Khmer shaping with broken fonts. -- Implement Thai "PUA" shaping for old fonts. -- Do NOT route Kharoshthi script through the Indic shaper. -- Disable fallback positioning for Indic and Thai shapers. -- Misc fixes. - - -hb-shape / hb-view changes: - -- Add --text-before and --text-after -- Add --bot / --eot / --preserve-default-ignorables -- hb-shape --output-format=json - - -New API: - -hb_buffer_clear() - -hb_buffer_flags_t - -HB_BUFFER_FLAGS_DEFAULT -HB_BUFFER_FLAG_BOT -HB_BUFFER_FLAG_EOT -HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES - -hb_buffer_set_flags() -hb_buffer_get_flags() - -HB_BUFFER_SERIALIZE_FLAGS -hb_buffer_serialize_glyphs() -hb_buffer_deserialize_glyphs() -hb_buffer_serialize_list_formats() - -hb_set_add_range() -hb_set_del_range() -hb_set_get_population() -hb_set_next_range() - -hb_face_[sg]et_glyph_count() - -hb_segment_properties_t -HB_SEGMENT_PROPERTIES_DEFAULT -hb_segment_properties_equal() -hb_segment_properties_hash() - -hb_buffer_set_segment_properties() -hb_buffer_get_segment_properties() - -hb_ot_layout_glyph_class_t -hb_ot_layout_get_glyph_class() -hb_ot_layout_get_glyphs_in_class() - -hb_shape_plan_t -hb_shape_plan_create() -hb_shape_plan_create_cached() -hb_shape_plan_get_empty() -hb_shape_plan_reference() -hb_shape_plan_destroy() -hb_shape_plan_set_user_data() -hb_shape_plan_get_user_data() -hb_shape_plan_execute() -hb_shape_plan_get_shaper() - -hb_ot_shape_plan_collect_lookups() - - -API changes: - -- Remove "mask" parameter from hb_buffer_add(). -- Rename hb_ot_layout_would_substitute_lookup() and hb_ot_layout_substitute_closure_lookup(). -- hb-set.h API const correction. -- Renamed hb_set_min/max() to hb_set_get_min/max(). -- Rename hb_ot_layout_feature_get_lookup_indexes() to hb_ot_layout_feature_get_lookups(). -- Rename hb_buffer_guess_properties() to hb_buffer_guess_segment_properties(). - - - -Overview of changes leading to 0.9.6 -Sunday, November 13, 2012 -==================================== - -- Don't clear pre-context text if no new context is provided. -- Fix ReverseChainingSubstLookup, which was totally borked. -- Adjust output format of hb-shape a bit. -- Include config.h.in in-tree. Makes it easier for alternate build systems. -- Fix hb_buffer_set_length(buffer, 0) invalid memory allocation. -- Use ICU LayoutEngine's C API instead of C++. Avoids much headache. -- Drop glyphs for all of Unicode Default_Ignorable characters. -- Misc build fixes. - -Arabic shaper: -- Enable 'dlig' and 'mset' features in Arabic shaper. -- Implement 'Phags-pa shaping, improve Mongolian. - -Indic shaper: -- Decompose Sinhala split matras the way old HarfBuzz / Pango did. -- Initial support for Consonant Medials. -- Start adding new-style Myanmar shaping. -- Make reph and 'pref' logic introspect the font. -- Route Meetei-Mayek through the Indic shaper. -- Don't apply 'liga' in Indic shaper. -- Improve Malayalam pre-base reordering Ra interaction with Chillus. - - - -Overview of changes leading to 0.9.5 -Sunday, October 14, 2012 -==================================== - -- Synthetic-GSUB Arabic fallback shaping. - -- Misc Indic improvements. - -- Add build system support for pthread. - -- Imported UCDN for in-tree Unicode callbacks implementation. - -- Context-aware Arabic joining. - -- Misc other fixes. - -- New API: - - hb_feature_to/from-string() - hb_buffer_[sg]et_content_type() - - - -Overview of changes leading to 0.9.4 -Tuesday, Sep 03, 2012 -==================================== - -- Indic improvements with old-spec Malayalam. - -- Better fallback glyph positioning, specially with Thai / Lao marks. - -- Implement dotted-circle insertion. - -- Better Arabic fallback shaping / ligation. - -- Added ICU LayoutEngine backend for testing. Call it by the 'icu_le' name. - -- Misc fixes. - - - -Overview of changes leading to 0.9.3 -Friday, Aug 18, 2012 -==================================== - -- Fixed fallback mark positioning for left-to-right text. - -- Improve mark positioning for the remaining combining classes. - -- Unbreak Thai and fallback Arabic shaping. - -- Port Arabic shaper to shape-plan caching. - -- Use new ICU normalizer functions. - - - -Overview of changes leading to 0.9.2 -Friday, Aug 10, 2012 -==================================== - -- Over a thousand commits! This is the first major release of HarfBuzz. - -- HarfBuzz is feature-complete now! It should be in par, or better, than - both Pango's shapers and old HarfBuzz / Qt shapers. - -- New Indic shaper, supporting main Indic scripts, Sinhala, and Khmer. - -- Improved Arabic shaper, with fallback Arabic shaping, supporting Arabic, - Sinhala, N'ko, Mongolian, and Mandaic. - -- New Thai / Lao shaper. - -- Tibetan / Hangul support in the generic shaper. - -- Synthetic GDEF support for fonts without a GDEF table. - -- Fallback mark positioning for fonts without a GPOS table. - -- Unicode normalization shaping heuristic during glyph mapping. - -- New experimental Graphite2 backend. - -- New Uniscribe backend (primarily for testing). - -- New CoreText backend (primarily for testing). - -- Major optimization and speedup. - -- Test suites and testing infrastructure (work in progress). - -- Greatly improved hb-view cmdline tool. - -- hb-shape cmdline tool. - -- Unicode 6.1 support. - -Summary of API changes: - -o Changed API: - - - Users are expected to only include main header files now (ie. hb.h, - hb-glib.h, hb-ft.h, ...) - - - All struct tag names had their initial underscore removed. - Ie. "struct _hb_buffer_t" is "struct hb_buffer_t" now. - - - All set_user_data() functions now take a "replace" boolean parameter. - - - hb_buffer_create() takes zero arguments now. - Use hb_buffer_pre_allocate() to pre-allocate. - - - hb_buffer_add_utf*() now accept -1 for length parameteres, - meaning "nul-terminated". - - - hb_direction_t enum values changed. - - - All *_from_string() APIs now take a length parameter to allow for - non-nul-terminated strings. A -1 length means "nul-terminated". - - - Typedef for hb_language_t changed. - - - hb_get_table_func_t renamed to hb_reference_table_func_t. - - - hb_ot_layout_table_choose_script() - - - Various renames in hb-unicode.h. - -o New API: - - - hb_buffer_guess_properties() - Automatically called by hb_shape(). - - - hb_buffer_normalize_glyphs() - - - hb_tag_from_string() - - - hb-coretext.h - - - hb-uniscribe.h - - - hb_face_reference_blob() - - hb_face_[sg]et_index() - - hb_face_set_upem() - - - hb_font_get_glyph_name_func_t - hb_font_get_glyph_from_name_func_t - hb_font_funcs_set_glyph_name_func() - hb_font_funcs_set_glyph_from_name_func() - hb_font_get_glyph_name() - hb_font_get_glyph_from_name() - hb_font_glyph_to_string() - hb_font_glyph_from_string() - - - hb_font_set_funcs_data() - - - hb_ft_font_set_funcs() - - hb_ft_font_get_face() - - - hb-gobject.h (work in progress) - - - hb_ot_shape_glyphs_closure() - hb_ot_layout_substitute_closure_lookup() - - - hb-set.h - - - hb_shape_full() - - - hb_unicode_combining_class_t - - - hb_unicode_compose_func_t - hb_unicode_decompose_func_t - hb_unicode_decompose_compatibility_func_t - hb_unicode_funcs_set_compose_func() - hb_unicode_funcs_set_decompose_func() - hb_unicode_funcs_set_decompose_compatibility_func() - hb_unicode_compose() - hb_unicode_decompose() - hb_unicode_decompose_compatibility() - -o Removed API: - - - hb_ft_get_font_funcs() - - - hb_ot_layout_substitute_start() - hb_ot_layout_substitute_lookup() - hb_ot_layout_substitute_finish() - hb_ot_layout_position_start() - hb_ot_layout_position_lookup() - hb_ot_layout_position_finish() - - - -Overview of changes leading to 0.6.0 -Friday, May 27, 2011 -==================================== - -- Vertical text support in GPOS -- Almost all API entries have unit tests now, under test/ -- All thread-safety issues are fixed - -Summary of API changes follows. - - -* Simple Types API: - - o New API: - HB_LANGUAGE_INVALID - hb_language_get_default() - hb_direction_to_string() - hb_direction_from_string() - hb_script_get_horizontal_direction() - HB_UNTAG() - - o Renamed API: - hb_category_t renamed to hb_unicode_general_category_t - - o Changed API: - hb_language_t is a typed pointers now - - o Removed API: - HB_TAG_STR() - - -* Use ISO 15924 tags for hb_script_t: - - o New API: - hb_script_from_iso15924_tag() - hb_script_to_iso15924_tag() - hb_script_from_string() - - o Changed API: - HB_SCRIPT_* enum members changed value. - - -* Buffer API streamlined: - - o New API: - hb_buffer_reset() - hb_buffer_set_length() - hb_buffer_allocation_successful() - - o Renamed API: - hb_buffer_ensure() renamed to hb_buffer_pre_allocate() - hb_buffer_add_glyph() renamed to hb_buffer_add() - - o Removed API: - hb_buffer_clear() - hb_buffer_clear_positions() - - o Changed API: - hb_buffer_get_glyph_infos() takes an out length parameter now - hb_buffer_get_glyph_positions() takes an out length parameter now - - -* Blob API streamlined: - - o New API: - hb_blob_get_data() - hb_blob_get_data_writable() - - o Renamed API: - hb_blob_create_empty() renamed to hb_blob_get_empty() - - o Removed API: - hb_blob_lock() - hb_blob_unlock() - hb_blob_is_writable() - hb_blob_try_writable() - - o Changed API: - hb_blob_create() takes user_data before destroy now - - -* Unicode functions API: - - o Unicode function vectors can subclass other unicode function vectors now. - Unimplemented callbacks in the subclass automatically chainup to the parent. - - o All hb_unicode_funcs_t callbacks take a user_data now. Their setters - take a user_data and its respective destroy callback. - - o New API: - hb_unicode_funcs_get_empty() - hb_unicode_funcs_get_default() - hb_unicode_funcs_get_parent() - - o Changed API: - hb_unicode_funcs_create() now takes a parent_funcs. - - o Removed func getter functions: - hb_unicode_funcs_get_mirroring_func() - hb_unicode_funcs_get_general_category_func() - hb_unicode_funcs_get_script_func() - hb_unicode_funcs_get_combining_class_func() - hb_unicode_funcs_get_eastasian_width_func() - - -* Face API: - - o Renamed API: - hb_face_get_table() renamed to hb_face_reference_table() - hb_face_create_for_data() renamed to hb_face_create() - - o Changed API: - hb_face_create_for_tables() takes user_data before destroy now - hb_face_reference_table() returns empty blob instead of NULL - hb_get_table_func_t accepts the face as first parameter now - -* Font API: - - o Fonts can subclass other fonts now. Unimplemented callbacks in the - subclass automatically chainup to the parent. When chaining up, - scale is adjusted if the parent font has a different scale. - - o All hb_font_funcs_t callbacks take a user_data now. Their setters - take a user_data and its respective destroy callback. - - o New API: - hb_font_get_parent() - hb_font_funcs_get_empty() - hb_font_create_sub_font() - - o Removed API: - hb_font_funcs_copy() - hb_font_unset_funcs() - - o Removed func getter functions: - hb_font_funcs_get_glyph_func() - hb_font_funcs_get_glyph_advance_func() - hb_font_funcs_get_glyph_extents_func() - hb_font_funcs_get_contour_point_func() - hb_font_funcs_get_kerning_func() - - o Changed API: - hb_font_create() takes a face and references it now - hb_font_set_funcs() takes user_data before destroy now - hb_font_set_scale() accepts signed integers now - hb_font_get_contour_point_func_t now takes glyph first, then point_index - hb_font_get_glyph_func_t returns a success boolean now - - -* Changed object model: - - o All object types have a _get_empty() now: - hb_blob_get_empty() - hb_buffer_get_empty() - hb_face_get_empty() - hb_font_get_empty() - hb_font_funcs_get_empty() - hb_unicode_funcs_get_empty() - - o Added _set_user_data() and _get_user_data() for all object types: - hb_blob_get_user_data() - hb_blob_set_user_data() - hb_buffer_get_user_data() - hb_buffer_set_user_data() - hb_face_get_user_data() - hb_face_set_user_data() - hb_font_funcs_get_user_data() - hb_font_funcs_set_user_data() - hb_font_get_user_data() - hb_font_set_user_data() - hb_unicode_funcs_get_user_data() - hb_unicode_funcs_set_user_data() - - o Removed the _get_reference_count() from all object types: - hb_blob_get_reference_count() - hb_buffer_get_reference_count() - hb_face_get_reference_count() - hb_font_funcs_get_reference_count() - hb_font_get_reference_count() - hb_unicode_funcs_get_reference_count() - - o Added _make_immutable() and _is_immutable() for all object types except for buffer: - hb_blob_make_immutable() - hb_blob_is_immutable() - hb_face_make_immutable() - hb_face_is_immutable() - - -* Changed API for vertical text support - - o The following callbacks where removed: - hb_font_get_glyph_advance_func_t - hb_font_get_kerning_func_t - - o The following new callbacks added instead: - hb_font_get_glyph_h_advance_func_t - hb_font_get_glyph_v_advance_func_t - hb_font_get_glyph_h_origin_func_t - hb_font_get_glyph_v_origin_func_t - hb_font_get_glyph_h_kerning_func_t - hb_font_get_glyph_v_kerning_func_t - - o The following API removed as such: - hb_font_funcs_set_glyph_advance_func() - hb_font_funcs_set_kerning_func() - hb_font_get_glyph_advance() - hb_font_get_kerning() - - o New API added instead: - hb_font_funcs_set_glyph_h_advance_func() - hb_font_funcs_set_glyph_v_advance_func() - hb_font_funcs_set_glyph_h_origin_func() - hb_font_funcs_set_glyph_v_origin_func() - hb_font_funcs_set_glyph_h_kerning_func() - hb_font_funcs_set_glyph_v_kerning_func() - hb_font_get_glyph_h_advance() - hb_font_get_glyph_v_advance() - hb_font_get_glyph_h_origin() - hb_font_get_glyph_v_origin() - hb_font_get_glyph_h_kerning() - hb_font_get_glyph_v_kerning() - - o The following higher-leve API added for convenience: - hb_font_get_glyph_advance_for_direction() - hb_font_get_glyph_origin_for_direction() - hb_font_add_glyph_origin_for_direction() - hb_font_subtract_glyph_origin_for_direction() - hb_font_get_glyph_kerning_for_direction() - hb_font_get_glyph_extents_for_origin() - hb_font_get_glyph_contour_point_for_origin() - - -* OpenType Layout API: - - o New API: - hb_ot_layout_position_start() - hb_ot_layout_substitute_start() - hb_ot_layout_substitute_finish() - - -* Glue code: - - o New API: - hb_glib_script_to_script() - hb_glib_script_from_script() - hb_icu_script_to_script() - hb_icu_script_from_script() - - -* Version API added: - - o New API: - HB_VERSION_MAJOR - HB_VERSION_MINOR - HB_VERSION_MICRO - HB_VERSION_STRING - HB_VERSION_CHECK() - hb_version() - hb_version_string() - hb_version_check() - - diff --git a/third_party/harfbuzz-ng/OWNERS b/third_party/harfbuzz-ng/OWNERS index 64cd17c20189..fcab37870f20 100644 --- a/third_party/harfbuzz-ng/OWNERS +++ b/third_party/harfbuzz-ng/OWNERS @@ -1,6 +1,5 @@ -bashi@chromium.org behdad@chromium.org -behdad@google.com +bungeman@chromium.org drott@chromium.org -eae@chromium.org jshin@chromium.org +kojii@chromium.org diff --git a/third_party/harfbuzz-ng/README b/third_party/harfbuzz-ng/README deleted file mode 100644 index dea10688f3f7..000000000000 --- a/third_party/harfbuzz-ng/README +++ /dev/null @@ -1,11 +0,0 @@ -[![Build Status](https://travis-ci.org/behdad/harfbuzz.svg)](https://travis-ci.org/behdad/harfbuzz) -[![Coverage Status](https://img.shields.io/coveralls/behdad/harfbuzz.svg)](https://coveralls.io/r/behdad/harfbuzz) -[![Coverity Scan](https://img.shields.io/coverity/scan/5450.svg)](https://scan.coverity.com/projects/5450) - -This is HarfBuzz, a text shaping library. - -For bug reports, mailing list, and other information please visit: - - http://harfbuzz.org/ - -For license information, see the file COPYING. diff --git a/third_party/harfbuzz-ng/README.chromium b/third_party/harfbuzz-ng/README.chromium index 1484e11718ec..ce071db04cb2 100644 --- a/third_party/harfbuzz-ng/README.chromium +++ b/third_party/harfbuzz-ng/README.chromium @@ -1,20 +1,50 @@ Name: harfbuzz-ng Short Name: harfbuzz-ng URL: http://harfbuzz.org -Version: 1.1.1 -Date: 20151124 +Version: 5.3.1-25 +CPEPrefix: cpe:/a:harfbuzz_project:harfbuzz:5.3.1 +Date: 20221104 +Revision: 2822b589bc837fae6f66233e2cf2eef0f6ce8470 Security Critical: yes License: MIT -License File: COPYING +License File: src/COPYING Description: This is harfbuzz-ng, a new implementation of harfbuzz with a different API from the old one. -This copy of harfbuzz is usually updated by downloading the release tarball -from http://www.freedesktop.org/software/harfbuzz/release/ , removing -files in src, copying *.h *.hh *.cc (except for hb-uniscribe*) from the -tarball's src folder over to src, then checking for removed or added files -and update our build recipes in BUILD.gn and harfbuzz.gyp accordingly, update -the NEWS file from HarfBuzz' release notes, and bump the version numbers -in README.chromium. +This copy of harfbuzz is usually updated by running + $ third_party/harfbuzz-ng/roll-harfbuzz.sh +from your Chromium ./src directory. + +This should update your checkout by putting the new upstream HarfBuzz ToT commit +hash top level DEPS file. In cases added or deleted files have been detected in +HarfBuzz' src directory, a step in the script will fail and you should edit the +BUILD.gn file accordingly and continue the roll manually. + +Chromium-local cherry picks or patches can be done by pushing new branches to +refs/heads/chromium/ of [1]. The set of HarfBuzz OWNERS has write rights to this +part of the tree. We suggest to follow a pattern of naming branches needed for +Chromium revisions by the chromium milestone number. For example, if a +cherry-pick is needed for M65, push to "refs/heads/chromium/m65" and reference +the new commit in DEPS. Take a look at +https://chromium-review.googlesource.com/c/chromium/src/+/937502 for an example. + +Currently we are intentionally not building the following files from +HarfBuzz. Specifically, we are not building hb-coretext any longer, as we rely +on HarfBuzz' built-in AAT shaping. + dump-indic-data.cc + dump-khmer-data.cc + dump-myanmar-data.cc + dump-use-data.cc + hb-coretext.h + hb-coretext.cc + hb-directwrite.cc + hb-directwrite.h + hb-fallback-shape.cc + hb-null.hh + hb-ot-color-sbix-table.hh + hb-ot-color-svg-table.hh + hb-uniscribe.cc + hb-uniscribe.h + test-unicode-ranges.cc diff --git a/third_party/harfbuzz-ng/fuzz/hb_shape_fuzzer.cc b/third_party/harfbuzz-ng/fuzz/hb_shape_fuzzer.cc new file mode 100644 index 000000000000..0323afd8a14b --- /dev/null +++ b/third_party/harfbuzz-ng/fuzz/hb_shape_fuzzer.cc @@ -0,0 +1,49 @@ +// Copyright 2016 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include + +// clang-format off +#include +#include +#include +// clang-format on + +#include + +constexpr size_t kMaxInputLength = 16800; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + if (size > kMaxInputLength) + return 0; + + const char* data_ptr = reinterpret_cast(data); + hb::unique_ptr blob(hb_blob_create( + data_ptr, size, HB_MEMORY_MODE_READONLY, nullptr, nullptr)); + hb::unique_ptr face(hb_face_create(blob.get(), 0)); + hb::unique_ptr font(hb_font_create(face.get())); + hb_ot_font_set_funcs(font.get()); + hb_font_set_scale(font.get(), 12, 12); + + { + const char text[] = "ABCDEXYZ123@_%&)*$!"; + hb::unique_ptr buffer(hb_buffer_create()); + hb_buffer_add_utf8(buffer.get(), text, -1, 0, -1); + hb_buffer_guess_segment_properties(buffer.get()); + hb_shape(font.get(), buffer.get(), nullptr, 0); + } + + uint32_t text32[16] = {0}; + if (size > sizeof(text32)) { + memcpy(text32, data + size - sizeof(text32), sizeof(text32)); + hb::unique_ptr buffer(hb_buffer_create()); + hb_buffer_add_utf32(buffer.get(), text32, std::size(text32), 0, -1); + hb_buffer_guess_segment_properties(buffer.get()); + hb_shape(font.get(), buffer.get(), nullptr, 0); + } + + return 0; +} diff --git a/third_party/harfbuzz-ng/fuzz/hb_subset_fuzzer.cc b/third_party/harfbuzz-ng/fuzz/hb_subset_fuzzer.cc new file mode 100644 index 000000000000..4d4cb58b4eca --- /dev/null +++ b/third_party/harfbuzz-ng/fuzz/hb_subset_fuzzer.cc @@ -0,0 +1,104 @@ +// Copyright 2020 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include + +// clang-format off +#include +#include +#include +// clang-format on + +#include + +#include "base/check.h" + +namespace { + +void TrySubset(hb_face_t* face, + const hb_codepoint_t text[], + const int text_length, + const uint8_t flags) { + bool drop_layout = flags & (1 << 1); + unsigned input_set_flags = + 0 // + | ((flags & (1 << 0)) ? HB_SUBSET_FLAGS_NO_HINTING : 0) // + | ((flags & (1 << 2)) ? HB_SUBSET_FLAGS_RETAIN_GIDS : 0); // + + hb::unique_ptr input(hb_subset_input_create_or_fail()); + hb_subset_input_set_flags(input.get(), input_set_flags); + hb_set_t* codepoints = hb_subset_input_unicode_set(input.get()); + + if (!drop_layout) { + hb_set_del(hb_subset_input_set(input.get(), HB_SUBSET_SETS_DROP_TABLE_TAG), + HB_TAG('G', 'S', 'U', 'B')); + hb_set_del(hb_subset_input_set(input.get(), HB_SUBSET_SETS_DROP_TABLE_TAG), + HB_TAG('G', 'P', 'O', 'S')); + hb_set_del(hb_subset_input_set(input.get(), HB_SUBSET_SETS_DROP_TABLE_TAG), + HB_TAG('G', 'D', 'E', 'F')); + } + + for (int i = 0; i < text_length; i++) { + hb_set_add(codepoints, text[i]); + } + + hb::unique_ptr result(hb_subset_or_fail(face, input.get())); + if (!result) { + // Subset failed, so nothing to check. + return; + } + hb::unique_ptr blob(hb_face_reference_blob(result.get())); + uint32_t length; + const char* data = hb_blob_get_data(blob.get(), &length); + + // Access all the blob data + uint32_t bytes_count = 0; + if (data) { + for (uint32_t i = 0; i < length; ++i) { + if (data[i]) + ++bytes_count; + } + } + CHECK(bytes_count || !length); +} + +} // namespace + +constexpr size_t kMaxInputLength = 16800; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + if (size > kMaxInputLength) + return 0; + + const char* data_ptr = reinterpret_cast(data); + hb::unique_ptr blob(hb_blob_create( + data_ptr, size, HB_MEMORY_MODE_READONLY, nullptr, nullptr)); + hb::unique_ptr face(hb_face_create(blob.get(), 0)); + + // Test hb_set API + { + hb::unique_ptr output(hb_set_create()); + hb_face_collect_unicodes(face.get(), output.get()); + } + + uint8_t subset_flags = 0; + const hb_codepoint_t text[] = {'A', 'B', 'C', 'D', 'E', 'X', 'Y', + 'Z', '1', '2', '3', '@', '_', '%', + '&', ')', '*', '$', '!'}; + + TrySubset(face.get(), text, std::size(text), subset_flags); + + hb_codepoint_t text_from_data[16]; + if (size > sizeof(text_from_data) + 1) { + memcpy(text_from_data, data + size - sizeof(text_from_data), + sizeof(text_from_data)); + subset_flags = data[size - sizeof(text_from_data) - 1]; + size_t text_size = std::size(text_from_data); + TrySubset(face.get(), text_from_data, text_size, subset_flags); + } + + return 0; +} diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/0509e80afb379d16560e9e47bdd7d888bebdebc6.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/0509e80afb379d16560e9e47bdd7d888bebdebc6.ttf new file mode 100644 index 000000000000..20360311092c Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/0509e80afb379d16560e9e47bdd7d888bebdebc6.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/051d92f8bc6ff724511b296c27623f824de256e9.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/051d92f8bc6ff724511b296c27623f824de256e9.ttf new file mode 100644 index 000000000000..419f8f3db0b5 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/051d92f8bc6ff724511b296c27623f824de256e9.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/07f054357ff8638bac3711b422a1e31180bba863.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/07f054357ff8638bac3711b422a1e31180bba863.ttf new file mode 100644 index 000000000000..fcd4f3232e9e Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/07f054357ff8638bac3711b422a1e31180bba863.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/191826b9643e3f124d865d617ae609db6a2ce203.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/191826b9643e3f124d865d617ae609db6a2ce203.ttf new file mode 100644 index 000000000000..dbc6e268117e Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/191826b9643e3f124d865d617ae609db6a2ce203.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/1a6f1687b7a221f9f2c834b0b360d3c8463b6daf.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/1a6f1687b7a221f9f2c834b0b360d3c8463b6daf.ttf new file mode 100644 index 000000000000..c71e85a84225 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/1a6f1687b7a221f9f2c834b0b360d3c8463b6daf.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/1c04a16f32a39c26c851b7fc014d2e8d298ba2b8.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/1c04a16f32a39c26c851b7fc014d2e8d298ba2b8.ttf new file mode 100644 index 000000000000..26d19ade2801 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/1c04a16f32a39c26c851b7fc014d2e8d298ba2b8.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf new file mode 100644 index 000000000000..213e7cedb96d Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2fb74c1b2aa173262734c1f616148f1648cfd6.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2fb74c1b2aa173262734c1f616148f1648cfd6.ttf new file mode 100644 index 000000000000..72106585f0d9 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2fb74c1b2aa173262734c1f616148f1648cfd6.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/205edd09bd3d141cc9580f650109556cc28b22cb.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/205edd09bd3d141cc9580f650109556cc28b22cb.ttf new file mode 100644 index 000000000000..4e0ce0a48c52 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/205edd09bd3d141cc9580f650109556cc28b22cb.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/226bc2deab3846f1a682085f70c67d0421014144.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/226bc2deab3846f1a682085f70c67d0421014144.ttf new file mode 100644 index 000000000000..70c0c0a83930 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/226bc2deab3846f1a682085f70c67d0421014144.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/270b89df543a7e48e206a2d830c0e10e5265c630.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/270b89df543a7e48e206a2d830c0e10e5265c630.ttf new file mode 100644 index 000000000000..fc2264917ab9 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/270b89df543a7e48e206a2d830c0e10e5265c630.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/298c9e1d955f10f6f72c6915c3c6ff9bf9695cec.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/298c9e1d955f10f6f72c6915c3c6ff9bf9695cec.ttf new file mode 100644 index 000000000000..0d677a873c8b Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/298c9e1d955f10f6f72c6915c3c6ff9bf9695cec.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/3511ff5c1647150595846ac414c595cccac34f18.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/3511ff5c1647150595846ac414c595cccac34f18.ttf new file mode 100644 index 000000000000..789abf7a8252 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/3511ff5c1647150595846ac414c595cccac34f18.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/37033cc5cf37bb223d7355153016b6ccece93b28.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/37033cc5cf37bb223d7355153016b6ccece93b28.ttf new file mode 100644 index 000000000000..14defeb7b5f1 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/37033cc5cf37bb223d7355153016b6ccece93b28.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/375d6ae32a3cbe52fbf81a4e5777e3377675d5a3.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/375d6ae32a3cbe52fbf81a4e5777e3377675d5a3.ttf new file mode 100644 index 000000000000..b284c9864455 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/375d6ae32a3cbe52fbf81a4e5777e3377675d5a3.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/43979b90b2dd929723cf4fe1715990bcb9c9a56b.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/43979b90b2dd929723cf4fe1715990bcb9c9a56b.ttf new file mode 100644 index 000000000000..a5c0156c10ec Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/43979b90b2dd929723cf4fe1715990bcb9c9a56b.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/43ef465752be9af900745f72fe29cb853a1401a5.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/43ef465752be9af900745f72fe29cb853a1401a5.ttf new file mode 100644 index 000000000000..649c156a9b00 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/43ef465752be9af900745f72fe29cb853a1401a5.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/45855bc8d46332b39c4ab9e2ee1a26b1f896da6b.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/45855bc8d46332b39c4ab9e2ee1a26b1f896da6b.ttf new file mode 100644 index 000000000000..6ef470c894bb Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/45855bc8d46332b39c4ab9e2ee1a26b1f896da6b.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/49c9f7485c1392fa09a1b801bc2ffea79275f22e.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/49c9f7485c1392fa09a1b801bc2ffea79275f22e.ttf new file mode 100644 index 000000000000..ea1326d2ab39 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/49c9f7485c1392fa09a1b801bc2ffea79275f22e.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf new file mode 100644 index 000000000000..dfaead72b4e6 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/5028afb650b1bb718ed2131e872fbcce57828fff.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/5028afb650b1bb718ed2131e872fbcce57828fff.ttf new file mode 100644 index 000000000000..8fb2f16264fb Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/5028afb650b1bb718ed2131e872fbcce57828fff.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/56cfd0e18d07f41c38e9598545a6d369127fc6f9.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/56cfd0e18d07f41c38e9598545a6d369127fc6f9.ttf new file mode 100644 index 000000000000..4795238b8903 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/56cfd0e18d07f41c38e9598545a6d369127fc6f9.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/57a9d9f83020155cbb1d2be1f43d82388cbecc88.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/57a9d9f83020155cbb1d2be1f43d82388cbecc88.ttf new file mode 100644 index 000000000000..746fc60389ae Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/57a9d9f83020155cbb1d2be1f43d82388cbecc88.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/5a5daf5eb5a4db77a2baa3ad9c7a6ed6e0655fa8.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/5a5daf5eb5a4db77a2baa3ad9c7a6ed6e0655fa8.ttf new file mode 100644 index 000000000000..9b4d23f5a686 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/5a5daf5eb5a4db77a2baa3ad9c7a6ed6e0655fa8.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/641bd9db850193064d17575053ae2bf8ec149ddc.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/641bd9db850193064d17575053ae2bf8ec149ddc.ttf new file mode 100644 index 000000000000..66cefd4d8c91 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/641bd9db850193064d17575053ae2bf8ec149ddc.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/6466d38c62e73a39202435a4f73bf5d6acbb73c0.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/6466d38c62e73a39202435a4f73bf5d6acbb73c0.ttf new file mode 100644 index 000000000000..33c4229cb1c3 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/6466d38c62e73a39202435a4f73bf5d6acbb73c0.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/6ff0fbead4462d9f229167b4e6839eceb8465058.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/6ff0fbead4462d9f229167b4e6839eceb8465058.ttf new file mode 100644 index 000000000000..67be52583272 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/6ff0fbead4462d9f229167b4e6839eceb8465058.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/706c5d7b625f207bc0d874c67237aad6f1e9cd6f.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/706c5d7b625f207bc0d874c67237aad6f1e9cd6f.ttf new file mode 100644 index 000000000000..eb5c50c664e0 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/706c5d7b625f207bc0d874c67237aad6f1e9cd6f.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/757ebd573617a24aa9dfbf0b885c54875c6fe06b.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/757ebd573617a24aa9dfbf0b885c54875c6fe06b.ttf new file mode 100644 index 000000000000..bbe22370ae64 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/757ebd573617a24aa9dfbf0b885c54875c6fe06b.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/7a37dc4d5bf018456aea291cee06daf004c0221c.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/7a37dc4d5bf018456aea291cee06daf004c0221c.ttf new file mode 100644 index 000000000000..a5787a8c0d2a Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/7a37dc4d5bf018456aea291cee06daf004c0221c.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/7e14e7883ed152baa158b80e207b66114c823a8b.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/7e14e7883ed152baa158b80e207b66114c823a8b.ttf new file mode 100644 index 000000000000..27efd7c90ee9 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/7e14e7883ed152baa158b80e207b66114c823a8b.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/7ef276fc886ea502a03b9b0e5c8b547d5dc2b61c.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/7ef276fc886ea502a03b9b0e5c8b547d5dc2b61c.ttf new file mode 100644 index 000000000000..fb4534abf4ac Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/7ef276fc886ea502a03b9b0e5c8b547d5dc2b61c.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/8099955657a54e9ee38a6ba1d6f950ce58e3cc25.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/8099955657a54e9ee38a6ba1d6f950ce58e3cc25.ttf new file mode 100644 index 000000000000..6bb13bd58ca7 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/8099955657a54e9ee38a6ba1d6f950ce58e3cc25.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/813c2f8e5512187fd982417a7fb4286728e6f4a8.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/813c2f8e5512187fd982417a7fb4286728e6f4a8.ttf new file mode 100644 index 000000000000..b728b277ce51 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/813c2f8e5512187fd982417a7fb4286728e6f4a8.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/8240789f6d12d4cfc4b5e8e6f246c3701bcf861f.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/8240789f6d12d4cfc4b5e8e6f246c3701bcf861f.ttf new file mode 100644 index 000000000000..8eed14d94e07 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/8240789f6d12d4cfc4b5e8e6f246c3701bcf861f.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/8454d22037f892e76614e1645d066689a0200e61.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/8454d22037f892e76614e1645d066689a0200e61.ttf new file mode 100644 index 000000000000..2cbb67a42c61 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/8454d22037f892e76614e1645d066689a0200e61.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/8a9fea2a7384f2116e5b84a9b31f83be7850ce21.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/8a9fea2a7384f2116e5b84a9b31f83be7850ce21.ttf new file mode 100644 index 000000000000..875c6998db05 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/8a9fea2a7384f2116e5b84a9b31f83be7850ce21.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf new file mode 100644 index 000000000000..74fceec894af Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/a919b33197965846f21074b24e30250d67277bce.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/a919b33197965846f21074b24e30250d67277bce.ttf new file mode 100644 index 000000000000..d2f116efa260 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/a919b33197965846f21074b24e30250d67277bce.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/a98e908e2ed21b22228ea59ebcc0f05034c86f2e.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/a98e908e2ed21b22228ea59ebcc0f05034c86f2e.ttf new file mode 100644 index 000000000000..8bbddb12b671 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/a98e908e2ed21b22228ea59ebcc0f05034c86f2e.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/b9e2aaa0d75fcef6971ec3a96d806ba4a6b31fe2.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/b9e2aaa0d75fcef6971ec3a96d806ba4a6b31fe2.ttf new file mode 100644 index 000000000000..500276df5bc1 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/b9e2aaa0d75fcef6971ec3a96d806ba4a6b31fe2.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/bb0c53752e85c3d28973ebc913287b8987d3dfe8.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/bb0c53752e85c3d28973ebc913287b8987d3dfe8.ttf new file mode 100644 index 000000000000..3b7c47074313 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/bb0c53752e85c3d28973ebc913287b8987d3dfe8.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/bb9473d2403488714043bcfb946c9f78b86ad627.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/bb9473d2403488714043bcfb946c9f78b86ad627.ttf new file mode 100644 index 000000000000..b16dae6c5756 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/bb9473d2403488714043bcfb946c9f78b86ad627.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/c4e48b0886ef460f532fb49f00047ec92c432ec0.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/c4e48b0886ef460f532fb49f00047ec92c432ec0.ttf new file mode 100644 index 000000000000..99cda1697f52 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/c4e48b0886ef460f532fb49f00047ec92c432ec0.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/cc5f3d2d717fb6bd4dfae1c16d48a2cb8e12233b.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/cc5f3d2d717fb6bd4dfae1c16d48a2cb8e12233b.ttf new file mode 100644 index 000000000000..a48d2a6811cb Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/cc5f3d2d717fb6bd4dfae1c16d48a2cb8e12233b.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/d629e7fedc0b350222d7987345fe61613fa3929a.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/d629e7fedc0b350222d7987345fe61613fa3929a.ttf new file mode 100644 index 000000000000..e674a78b6ef3 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/d629e7fedc0b350222d7987345fe61613fa3929a.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/df768b9c257e0c9c35786c47cae15c46571d56be.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/df768b9c257e0c9c35786c47cae15c46571d56be.ttf new file mode 100644 index 000000000000..c6d8b18e7f04 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/df768b9c257e0c9c35786c47cae15c46571d56be.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/e207635780b42f898d58654b65098763e340f5c7.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/e207635780b42f898d58654b65098763e340f5c7.ttf new file mode 100644 index 000000000000..d91df5726b3f Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/e207635780b42f898d58654b65098763e340f5c7.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf new file mode 100644 index 000000000000..629c470c2c49 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/f22416c692720a7d46fadf4af99f4c9e094f00b9.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/f22416c692720a7d46fadf4af99f4c9e094f00b9.ttf new file mode 100644 index 000000000000..1dbadde41157 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/f22416c692720a7d46fadf4af99f4c9e094f00b9.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/f499fbc23865022234775c43503bba2e63978fe1.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/f499fbc23865022234775c43503bba2e63978fe1.ttf new file mode 100644 index 000000000000..3c6059344ad8 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/f499fbc23865022234775c43503bba2e63978fe1.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/f518eb6f6b5eec2946c9fbbbde44e45d46f5e2ac.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/f518eb6f6b5eec2946c9fbbbde44e45d46f5e2ac.ttf new file mode 100644 index 000000000000..039f5e8ae53a Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/f518eb6f6b5eec2946c9fbbbde44e45d46f5e2ac.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/fab39d60d758cb586db5a504f218442cd1395725.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/fab39d60d758cb586db5a504f218442cd1395725.ttf new file mode 100644 index 000000000000..451ed0477a45 Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/fab39d60d758cb586db5a504f218442cd1395725.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/fbb6c84c9e1fe0c39e152fbe845e51fd81f6748e.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/fbb6c84c9e1fe0c39e152fbe845e51fd81f6748e.ttf new file mode 100644 index 000000000000..d49432dd824a Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/fbb6c84c9e1fe0c39e152fbe845e51fd81f6748e.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/fcdcffbdf1c4c97c05308d7600e4c283eb47dbca.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/fcdcffbdf1c4c97c05308d7600e4c283eb47dbca.ttf new file mode 100644 index 000000000000..c4e0253cb87d Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/fcdcffbdf1c4c97c05308d7600e4c283eb47dbca.ttf differ diff --git a/third_party/harfbuzz-ng/fuzz/seed_corpus/ffa0f5d2d9025486d8469d8b1fdd983e7632499b.ttf b/third_party/harfbuzz-ng/fuzz/seed_corpus/ffa0f5d2d9025486d8469d8b1fdd983e7632499b.ttf new file mode 100644 index 000000000000..224dbc63b26f Binary files /dev/null and b/third_party/harfbuzz-ng/fuzz/seed_corpus/ffa0f5d2d9025486d8469d8b1fdd983e7632499b.ttf differ diff --git a/third_party/harfbuzz-ng/harfbuzz.gni b/third_party/harfbuzz-ng/harfbuzz.gni new file mode 100644 index 000000000000..28a4cc3b2c9c --- /dev/null +++ b/third_party/harfbuzz-ng/harfbuzz.gni @@ -0,0 +1,12 @@ +# Copyright 2017 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +declare_args() { + # Blink uses a cutting-edge version of Harfbuzz; most Linux distros do not + # contain a new enough version of the code to work correctly. However, + # ChromeOS chroots (i.e, real ChromeOS builds for devices) do contain a + # new enough version of the library, and so this variable exists so that + # ChromeOS can build against the system lib and keep binary sizes smaller. + use_system_harfbuzz = false +} diff --git a/third_party/harfbuzz-ng/harfbuzz.gyp b/third_party/harfbuzz-ng/harfbuzz.gyp deleted file mode 100644 index b9be8ae2f6c4..000000000000 --- a/third_party/harfbuzz-ng/harfbuzz.gyp +++ /dev/null @@ -1,215 +0,0 @@ -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'includes': [ - '../../build/win_precompile.gypi', - ], - 'variables': { - 'conditions': [ - ['OS=="linux" and chromeos==1', { - # Since version 1.31.0, pangoft2 which we depend on pulls in harfbuzz - # anyways. However, we want to have control of the version of harfbuzz - # we use, so don't use system harfbuzz unless we are building for - # chrome os, where we have the system harfbuzz under control. - 'use_system_harfbuzz%': ' int, size_t -> unsigned int - 'msvs_disabled_warnings': [4267, 4334], - }], - ['OS=="mac"', { - 'defines': [ - 'HAVE_CORETEXT', - ], - 'sources': [ - 'src/hb-coretext.cc', - 'src/hb-coretext.h', - ], - }], - # When without -fvisibility=hidden for pango to use the harfbuzz - # in the tree, all symbols pango needs must be included, or - # pango uses mixed versions of harfbuzz and leads to crash. - # See crbug.com/462689. - ['use_pango==1 and OS=="linux" and chromeos==0 and buildtype!="Official" and target_arch!="arm" and target_arch!="mipsel"', { - 'cflags!': ['-fvisibility=hidden'], - 'sources': [ - 'src/hb-ft.cc', - 'src/hb-ft.h', - 'src/hb-glib.cc', - 'src/hb-glib.h', - ], - 'link_settings': { - 'ldflags': [ - # These symbols are referenced from libpangoft2, which will be - # dynamically linked later. - '-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs', - ], - }, - 'dependencies': [ - '../../build/linux/system.gyp:freetype2', - '../../build/linux/system.gyp:glib', - ], - }], - ], - }, - ], - }, { # use_system_harfbuzz==1 - 'targets': [ - { - 'target_name': 'harfbuzz-ng', - 'type': 'none', - 'cflags': [ - ' /dev/null; then + _GHR_VER=v0.14.0 + _GHR=ghr_${_GHR_VER}_linux_amd64 + mkdir -p $HOME/.local/bin + curl -sfL https://github.com/tcnksm/ghr/releases/download/$_GHR_VER/$_GHR.tar.gz | + tar xz -C $HOME/.local/bin --strip-components=1 $_GHR/ghr +fi + +ghr -replace \ + -u $CIRCLE_PROJECT_USERNAME \ + -r $CIRCLE_PROJECT_REPONAME \ + $CIRCLE_TAG \ + $1 diff --git a/third_party/harfbuzz-ng/src/.ci/win32-cross-file.txt b/third_party/harfbuzz-ng/src/.ci/win32-cross-file.txt new file mode 100644 index 000000000000..982a909b76ec --- /dev/null +++ b/third_party/harfbuzz-ng/src/.ci/win32-cross-file.txt @@ -0,0 +1,20 @@ +[host_machine] +system = 'windows' +cpu_family = 'x86' +cpu = 'i686' +endian = 'little' + +[properties] +c_args = [] +c_link_args = ['-static-libgcc', '-Wl,-Bstatic', '-lpthread'] +cpp_args = [] +cpp_link_args = ['-static-libgcc', '-static-libstdc++', '-Wl,-Bstatic', '-lpthread'] + +[binaries] +c = 'i686-w64-mingw32-gcc' +cpp = 'i686-w64-mingw32-g++' +ar = 'i686-w64-mingw32-ar' +ld = 'i686-w64-mingw32-ld' +objcopy = 'i686-w64-mingw32-objcopy' +strip = 'i686-w64-mingw32-strip' +windres = 'i686-w64-mingw32-windres' diff --git a/third_party/harfbuzz-ng/src/.ci/win64-cross-file.txt b/third_party/harfbuzz-ng/src/.ci/win64-cross-file.txt new file mode 100644 index 000000000000..e906e085e215 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.ci/win64-cross-file.txt @@ -0,0 +1,20 @@ +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' + +[properties] +c_args = [] +c_link_args = ['-static-libgcc', '-Wl,-Bstatic', '-lpthread'] +cpp_args = [] +cpp_link_args = ['-static-libgcc', '-static-libstdc++', '-Wl,-Bstatic', '-lpthread'] + +[binaries] +c = 'x86_64-w64-mingw32-gcc' +cpp = 'x86_64-w64-mingw32-g++' +ar = 'x86_64-w64-mingw32-ar' +ld = 'x86_64-w64-mingw32-ld' +objcopy = 'x86_64-w64-mingw32-objcopy' +strip = 'x86_64-w64-mingw32-strip' +windres = 'x86_64-w64-mingw32-windres' diff --git a/third_party/harfbuzz-ng/src/.circleci/config.yml b/third_party/harfbuzz-ng/src/.circleci/config.yml new file mode 100644 index 000000000000..a149b36104fd --- /dev/null +++ b/third_party/harfbuzz-ng/src/.circleci/config.yml @@ -0,0 +1,216 @@ +version: 2.1 + +executors: + win32-executor: + docker: + - image: cimg/base:edge-20.04 + win64-executor: + docker: + - image: cimg/base:edge-20.04 + autotools-executor: + docker: + - image: cimg/base:edge-20.04 + +jobs: + + macos-aat-fonts: + macos: + xcode: "12.5.1" + steps: + - checkout + - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config ragel freetype glib cairo python3 icu4c graphite2 gobject-introspection ninja + - run: pip3 install meson --upgrade + - run: PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig" meson setup build -Dcoretext=enabled -Dgraphite=enabled -Dauto_features=enabled -Dchafa=disabled -Ddocs=disabled + - run: meson compile -Cbuild + - run: meson test -Cbuild --print-errorlogs + - store_artifacts: + path: build/meson-logs/ + + # will be dropped with autotools removal + distcheck: + executor: autotools-executor + steps: + - checkout + - run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y git ninja-build binutils libtool autoconf automake make gcc g++ pkg-config ragel gtk-doc-tools gobject-introspection libfreetype6-dev libglib2.0-dev libgirepository1.0-dev libcairo2-dev libicu-dev libgraphite2-dev python3 python3-pip + - run: pip3 install fonttools meson --upgrade + - run: ./autogen.sh + - run: make -j2 distcheck + - run: rm harfbuzz-* && make distdir + - run: cd harfbuzz-* && meson build && ninja -j2 -Cbuild test + - run: make dist + - persist_to_workspace: + root: . + paths: harfbuzz-*.tar.xz + + publish-dist: + executor: autotools-executor + steps: + - checkout + - attach_workspace: + at: . + - run: | + .ci/publish_release_artifact.sh harfbuzz-$CIRCLE_TAG.tar.xz + + fedora-valgrind: + docker: + - image: fedora:36 + steps: + - checkout + - run: dnf install -y pkg-config ragel valgrind gcc gcc-c++ meson git glib2-devel freetype-devel cairo-devel libicu-devel gobject-introspection-devel graphite2-devel redhat-rpm-config python python-pip || true + - run: meson setup build --buildtype=debugoptimized + - run: meson compile -Cbuild -j9 + # TOOD: increase timeouts and remove --no-suite=slow + - run: RUN_VALGRIND=1 meson test -Cbuild --no-suite=slow --wrap='valgrind --leak-check=full --error-exitcode=1' --print-errorlogs --num-processes=$(($(nproc)/2 + 1)) + + alpine: + docker: + - image: alpine + steps: + - checkout + - run: apk update && apk add ragel gcc g++ glib-dev freetype-dev cairo-dev git py3-pip ninja + - run: pip3 install meson==0.56.0 + - run: meson setup build --buildtype=minsize + - run: meson compile -Cbuild -j9 + - run: meson test -Cbuild --print-errorlogs + + asan-ubsan: + docker: + - image: ubuntu:20.04 + steps: + - checkout + - run: apt update || true + - run: DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-pip ninja-build clang lld git binutils pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev + - run: pip3 install meson==0.56.0 + - run: CC=clang CXX=clang++ meson setup build --default-library=static -Db_sanitize=address,undefined --buildtype=debugoptimized --wrap-mode=nodownload -Dexperimental_api=true + - run: meson compile -Cbuild -j9 + - run: meson test -Cbuild --print-errorlogs | asan_symbolize | c++filt + + tsan: + docker: + - image: ubuntu:20.04 + steps: + - checkout + - run: apt update || true + - run: DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-pip ninja-build clang lld git binutils pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev + - run: pip3 install meson==0.56.0 + - run: CC=clang CXX=clang++ meson setup build --default-library=static -Db_sanitize=thread --buildtype=debugoptimized --wrap-mode=nodownload -Dexperimental_api=true + - run: meson compile -Cbuild -j9 + - run: meson test -Cbuild --print-errorlogs | asan_symbolize | c++filt + + msan: + docker: + - image: ubuntu:20.04 + steps: + - checkout + - run: apt update || true + - run: DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-pip ninja-build clang lld git binutils pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev + - run: pip3 install meson==0.56.0 + # msan, needs --force-fallback-for=glib,freetype2 also which doesn't work yet but runs fuzzer cases at least + - run: CC=clang CXX=clang++ meson setup build --default-library=static -Db_sanitize=memory --buildtype=debugoptimized --wrap-mode=nodownload -Dauto_features=disabled -Dtests=enabled -Dexperimental_api=true + - run: meson compile -Cbuild -j9 + - run: meson test -Cbuild --print-errorlogs | asan_symbolize | c++filt + + clang-cxx2a: + docker: + - image: ubuntu:20.04 + steps: + - checkout + - run: apt update || true + - run: DEBIAN_FRONTEND=noninteractive apt install -y clang lld git binutils + - run: clang -c src/harfbuzz-subset.cc -DHB_NO_MT -Werror -std=c++2a + + crossbuild-win32: + executor: win32-executor + steps: + - checkout + - run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y ninja-build python3 python3-pip git g++-mingw-w64-i686 zip + - run: pip3 install meson==0.60.0 + - run: .ci/build-win32.sh + - store_artifacts: + path: harfbuzz-win32.zip + - persist_to_workspace: + root: . + paths: harfbuzz-win32.zip + + publish-win32: + executor: win32-executor + steps: + - checkout + - attach_workspace: + at: . + - run: | + mv harfbuzz-win32{,-$CIRCLE_TAG}.zip + .ci/publish_release_artifact.sh harfbuzz-win32-$CIRCLE_TAG.zip + + crossbuild-win64: + executor: win64-executor + steps: + - checkout + - run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y ninja-build python3 python3-pip git g++-mingw-w64-x86-64 zip + - run: pip3 install meson==0.60.0 + - run: bash .ci/build-win64.sh + - store_artifacts: + path: harfbuzz-win64.zip + - persist_to_workspace: + root: . + paths: harfbuzz-win64.zip + + publish-win64: + executor: win64-executor + steps: + - checkout + - attach_workspace: + at: . + - run: | + mv harfbuzz-win64{,-$CIRCLE_TAG}.zip + .ci/publish_release_artifact.sh harfbuzz-win64-$CIRCLE_TAG.zip + + +workflows: + version: 2 + + build: + jobs: + - macos-aat-fonts + - distcheck: + filters: # must have filter or won't work as a dependency + tags: + only: /.*/ + - publish-dist: + requires: + - distcheck + filters: + tags: + only: /^\d+\.\d+\.\d+$/ + branches: + ignore: /.*/ + - fedora-valgrind + - alpine + - asan-ubsan + - tsan + - msan + - clang-cxx2a + - crossbuild-win32: + filters: # must have filter or won't work as a dependency + tags: + only: /.*/ + - crossbuild-win64: + filters: # must have filter or won't work as a dependency + tags: + only: /.*/ + - publish-win32: + requires: + - crossbuild-win32 + filters: + tags: + only: /^\d+\.\d+\.\d+$/ + branches: + ignore: /.*/ + - publish-win64: + requires: + - crossbuild-win64 + filters: + tags: + only: /^\d+\.\d+\.\d+$/ + branches: + ignore: /.*/ diff --git a/third_party/harfbuzz-ng/src/.clang-format b/third_party/harfbuzz-ng/src/.clang-format new file mode 100644 index 000000000000..259427cb0e33 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.clang-format @@ -0,0 +1,38 @@ +# The following tries to match the current code style, is imperfect for now +# but good for new codes be added + +IndentWidth: 2 +TabWidth: 8 +UseTab: Always +SpaceBeforeParens: Always +AllowShortLoopsOnASingleLine: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterEnum: true + AfterStruct: false + SplitEmptyFunction: false + AfterClass: true + AfterControlStatement: true + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterStruct: true + AfterUnion: true + BeforeElse: true +AlwaysBreakTemplateDeclarations: true +AlignTrailingComments: true +AlignEscapedNewlines: Left +AllowShortBlocksOnASingleLine: true +SpaceAfterCStyleCast: true +AlwaysBreakAfterDefinitionReturnType: TopLevel +BinPackParameters: false +AllowShortFunctionsOnASingleLine: Inline +AccessModifierOffset: 0 +AlignTrailingComments: true +AllowShortIfStatementsOnASingleLine: true +AlignAfterOpenBracket: Align +AlignOperands: true +AllowShortCaseLabelsOnASingleLine: true + +# We like to have this only for function parameters and structs fields, not always +# AlignConsecutiveDeclarations: true diff --git a/third_party/harfbuzz-ng/src/.codecov.yml b/third_party/harfbuzz-ng/src/.codecov.yml new file mode 100644 index 000000000000..40928b9325f1 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.codecov.yml @@ -0,0 +1,10 @@ +comment: false + +coverage: + status: + project: + default: + informational: true + patch: + default: + informational: true diff --git a/third_party/harfbuzz-ng/src/.editorconfig b/third_party/harfbuzz-ng/src/.editorconfig new file mode 100644 index 000000000000..cac917b91072 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.editorconfig @@ -0,0 +1,23 @@ +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true +end_of_line = lf +insert_final_newline = true + +[*.{c,cc,h,hh,rl}] +tab_width = 8 +indent_size = 2 +indent_style = tab # should be space + +[*.{py,sh}] +indent_style = tab + +[{Makefile.am,Makefile.sources,configure.ac}] +tab_width = 8 + +[{meson.build,meson_options.txt}] +tab_width = 8 +indent_style = space +indent_size = 2 diff --git a/third_party/harfbuzz-ng/src/.github/dependabot.yml b/third_party/harfbuzz-ng/src/.github/dependabot.yml new file mode 100644 index 000000000000..5ace4600a1f2 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/third_party/harfbuzz-ng/src/.github/workflows/arm-ci.yml b/third_party/harfbuzz-ng/src/.github/workflows/arm-ci.yml new file mode 100644 index 000000000000..3df13163f8e7 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/arm-ci.yml @@ -0,0 +1,25 @@ +name: arm + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + arm-none-eabi: + runs-on: ubuntu-22.04 + container: + image: devkitpro/devkitarm:latest + steps: + - uses: actions/checkout@v3 + - name: Configure CMake + run: | + cmake -S . -B build \ + -DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/3DS.cmake + - name: Build + run: make CXX_FLAGS="-w -DHB_NO_MT" + working-directory: build diff --git a/third_party/harfbuzz-ng/src/.github/workflows/cifuzz.yml b/third_party/harfbuzz-ng/src/.github/workflows/cifuzz.yml new file mode 100644 index 000000000000..7d6e24669654 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/cifuzz.yml @@ -0,0 +1,28 @@ +name: CIFuzz +on: [pull_request] + +permissions: + contents: read + +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + id: build + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'harfbuzz' + dry-run: false + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'harfbuzz' + fuzz-seconds: 600 + dry-run: false + - name: Upload Crash + uses: actions/upload-artifact@v3 + if: failure() && steps.build.outcome == 'success' + with: + name: artifacts + path: ./out/artifacts diff --git a/third_party/harfbuzz-ng/src/.github/workflows/configs-build.yml b/third_party/harfbuzz-ng/src/.github/workflows/configs-build.yml new file mode 100644 index 000000000000..b81ce92b0f30 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/configs-build.yml @@ -0,0 +1,27 @@ +name: configs-ci + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + - name: install dependencies + run: sudo apt-get install gcc + - name: HB_DISABLE_DEPRECATED + run: g++ -std=c++11 -c src/harfbuzz.cc -DHB_DISABLE_DEPRECATED + - name: HB_MINI + run: g++ -std=c++11 -c src/harfbuzz.cc -DHB_MINI + - name: HB_LEAN + run: g++ -std=c++11 -c src/harfbuzz.cc -DHB_LEAN + - name: HB_TINY + run: g++ -std=c++11 -c src/harfbuzz.cc -DHB_TINY diff --git a/third_party/harfbuzz-ng/src/.github/workflows/coverity-scan.yml b/third_party/harfbuzz-ng/src/.github/workflows/coverity-scan.yml new file mode 100644 index 000000000000..e9fc5435ef32 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/coverity-scan.yml @@ -0,0 +1,42 @@ +name: coverity-scan + +on: + schedule: + - cron: '0 10 * * *' # Daily at 10:00 UTC + +permissions: + contents: read + +jobs: + latest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - run: sudo apt-get install gcc clang wget git curl pkg-config libfreetype6-dev libglib2.0-dev libicu-dev libgraphite2-dev + + - name: Download Coverity + run: | + wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=HarfBuzz" -O cov-analysis-linux64.tar.gz + mkdir cov-analysis-linux64 + tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64 + env: + TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} + + # ideally we should've used meson and ninja here but it complains about coverage or something + - run: cov-analysis-linux64/bin/cov-build --dir cov-int clang src/hb-*.cc -DHAVE_FREETYPE -DHAVE_GRAPHITE2 -DHAVE_GLIB -DHAVE_ICU `pkg-config --cflags freetype2 graphite2 glib-2.0 icu-uc` -DHAVE_ROUNDF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H -DHAVE_GETPAGESIZE -DHB_EXPERIMENTAL_API -c + + - run: tar czvf harfbuzz.tgz cov-int + + - name: submit to coverity + run: | + curl \ + --form project=HarfBuzz \ + --form token=$TOKEN \ + --form email=harfbuzz-bots-chatter@googlegroups.com \ + --form file=@harfbuzz.tgz \ + --form version=trunk \ + --form description="`git rev-parse --short HEAD`" \ + https://scan.coverity.com/builds?project=HarfBuzz + env: + TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} diff --git a/third_party/harfbuzz-ng/src/.github/workflows/linux-ci.yml b/third_party/harfbuzz-ng/src/.github/workflows/linux-ci.yml new file mode 100644 index 000000000000..3ec2eea47317 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/linux-ci.yml @@ -0,0 +1,71 @@ +name: linux-ci + +on: + push: + branches: [ main ] + tags: ["*.*.*"] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }}-${{ runner.os }}-${{ runner.arch }} + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install \ + gcc \ + gobject-introspection \ + gtk-doc-tools \ + libcairo2-dev \ + libfreetype6-dev \ + libgirepository1.0-dev \ + libglib2.0-dev \ + libgraphite2-dev \ + libicu-dev \ + ninja-build \ + pkg-config \ + python3 \ + python3-setuptools + - name: Install Python Dependencies + run: sudo pip3 install fonttools meson==0.56.0 gcovr==5.0 + - name: Setup Meson + run: | + ccache --version + meson setup build \ + -Dauto_features=enabled \ + -Dchafa=disabled \ + -Dgraphite=enabled \ + -Doptimization=2 \ + -Db_coverage=true \ + -Ddoc_tests=true \ + -Dragel_subproject=true + - name: Build + run: meson compile -Cbuild + - name: Test + run: meson test --print-errorlogs -Cbuild + - name: Generate Documentations + run: ninja -Cbuild harfbuzz-doc + - name: Deploy Documentations + if: github.ref_type == 'tag' + run: .ci/deploy-docs.sh + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + REVISION: ${{ github.sha }} + - name: Generate Coverage + run: ninja -Cbuild coverage-xml + - name: Upload Coverage + uses: codecov/codecov-action@v3 + with: + file: build/meson-logs/coverage.xml diff --git a/third_party/harfbuzz-ng/src/.github/workflows/macos-ci.yml b/third_party/harfbuzz-ng/src/.github/workflows/macos-ci.yml new file mode 100644 index 000000000000..e84cb38b35f0 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/macos-ci.yml @@ -0,0 +1,60 @@ +name: macos-ci + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + build: + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }}-${{ runner.os }}-${{ runner.arch }} + - name: Install Dependencies + run: | + export HOMEBREW_NO_AUTO_UPDATE=1 + export HOMEBREW_NO_INSTALL_CLEANUP=1 + brew install \ + cairo \ + freetype \ + glib \ + gobject-introspection \ + graphite2 \ + icu4c \ + meson \ + ninja \ + pkg-config + - name: Install Python Dependencies + run: pip3 install fonttools gcovr==5.0 + - name: Setup Meson + run: | + export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig" + ccache --version + meson setup build \ + -Dauto_features=enabled \ + -Ddocs=disabled \ + -Dchafa=disabled \ + -Dcoretext=enabled \ + -Dgraphite=enabled \ + -Doptimization=2 \ + -Db_coverage=true \ + - name: Build + run: meson compile -Cbuild + - name: Test + run: meson test --print-errorlogs -Cbuild + - name: Generate Coverage + run: ninja -Cbuild coverage-xml + - name: Upload Coverage + uses: codecov/codecov-action@v3 + with: + file: build/meson-logs/coverage.xml diff --git a/third_party/harfbuzz-ng/src/.github/workflows/msvc-ci.yml b/third_party/harfbuzz-ng/src/.github/workflows/msvc-ci.yml new file mode 100644 index 000000000000..57ab3af2cea9 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/msvc-ci.yml @@ -0,0 +1,61 @@ +name: msvc + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + msvc: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [windows-2019, windows-latest] + include: + - name: msvc-2019-x86 + os: windows-2019 + ARCH: x86 + - name: msvc-2019-amd64 + os: windows-latest + ARCH: amd64 + name: ${{ matrix.name }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + variant: sccache + key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.ARCH }} + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch : ${{ matrix.ARCH }} + - name: Install Python Dependencies + run: | + pip install --upgrade meson ninja fonttools + - name: Setup Meson + run: | + sccache --version + meson setup build ` + --wrap-mode=forcefallback ` + --buildtype=release ` + -Dglib=enabled ` + -Dfreetype=enabled ` + -Dgdi=enabled ` + -Ddirectwrite=enabled + - name: Build + run: meson compile -Cbuild + - name: Test + run: meson test --print-errorlogs --suite=harfbuzz -Cbuild diff --git a/third_party/harfbuzz-ng/src/.github/workflows/msys2-ci.yml b/third_party/harfbuzz-ng/src/.github/workflows/msys2-ci.yml new file mode 100644 index 000000000000..d825fd043ad0 --- /dev/null +++ b/third_party/harfbuzz-ng/src/.github/workflows/msys2-ci.yml @@ -0,0 +1,73 @@ +name: msys2 + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + msys2: + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + include: + - MSYSTEM: MINGW32 + MSYS2_ARCH: i686 + - MSYSTEM: MINGW64 + MSYS2_ARCH: x86_64 + name: ${{ matrix.MSYSTEM }} + + env: + # XXX: For some reason enabling jit debugging "fixes" random python crashes + # see https://github.com/msys2/MINGW-packages/issues/11864 + MSYS: "winjitdebug" + + defaults: + run: + shell: msys2 {0} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.MSYSTEM }} + update: true + install: >- + mingw-w64-${{ matrix.MSYS2_ARCH }}-cairo + mingw-w64-${{ matrix.MSYS2_ARCH }}-freetype + mingw-w64-${{ matrix.MSYS2_ARCH }}-gcc + mingw-w64-${{ matrix.MSYS2_ARCH }}-gcc-libs + mingw-w64-${{ matrix.MSYS2_ARCH }}-gettext + mingw-w64-${{ matrix.MSYS2_ARCH }}-glib2 + mingw-w64-${{ matrix.MSYS2_ARCH }}-gobject-introspection + mingw-w64-${{ matrix.MSYS2_ARCH }}-graphite2 + mingw-w64-${{ matrix.MSYS2_ARCH }}-icu + mingw-w64-${{ matrix.MSYS2_ARCH }}-meson + mingw-w64-${{ matrix.MSYS2_ARCH }}-ninja + mingw-w64-${{ matrix.MSYS2_ARCH }}-pkg-config + mingw-w64-${{ matrix.MSYS2_ARCH }}-python + mingw-w64-${{ matrix.MSYS2_ARCH }}-python-pip + - name: Install Python Dependencies + run: | + pip install --upgrade fonttools + - name: Setup Meson + run: | + meson setup build \ + --wrap-mode=nodownload \ + --auto-features=enabled \ + -Ddocs=disabled \ + -Ddirectwrite=enabled \ + -Dgdi=enabled \ + -Dgraphite=enabled \ + -Dchafa=disabled + - name: Build + run: meson compile -Cbuild + - name: Test + run: meson test --print-errorlogs --suite=harfbuzz -Cbuild diff --git a/third_party/harfbuzz-ng/src/AUTHORS b/third_party/harfbuzz-ng/src/AUTHORS new file mode 100644 index 000000000000..83c0c66f99e9 --- /dev/null +++ b/third_party/harfbuzz-ng/src/AUTHORS @@ -0,0 +1,14 @@ +Behdad Esfahbod +David Corbett +David Turner +Ebrahim Byagowi +Garret Rieger +Jonathan Kew +Khaled Hosny +Lars Knoll +Martin Hosken +Owen Taylor +Roderick Sheeter +Roozbeh Pournader +Simon Hausmann +Werner Lemberg diff --git a/third_party/harfbuzz-ng/src/BUILD.md b/third_party/harfbuzz-ng/src/BUILD.md new file mode 100644 index 000000000000..8e822738c5ca --- /dev/null +++ b/third_party/harfbuzz-ng/src/BUILD.md @@ -0,0 +1,29 @@ +On Linux, install the development packages for FreeType, Cairo, and GLib. For +example, on Ubuntu / Debian, you would do: + +$ sudo apt-get install meson pkg-config ragel gtk-doc-tools gcc g++ libfreetype6-dev libglib2.0-dev libcairo2-dev + +whereas on Fedora, RHEL, CentOS, and other Red Hat based systems you would do: + +$ sudo dnf install meson pkgconfig gtk-doc gcc gcc-c++ freetype-devel glib2-devel cairo-devel + +and on ArchLinux and Manjaro: + +$ sudo pacman -Suy meson pkg-config ragel gcc freetype2 glib2 cairo + +then use meson to build the project like `meson build && meson test -Cbuild`. + +On macOS, `brew install pkg-config ragel gtk-doc freetype glib cairo meson` +then use meson like above. + +On Windows, meson can build the project like above if a working MSVC's cl.exe +(`vcvarsall.bat`) or gcc/clang is already on your path, and if you use +something like `meson build --wrap-mode=default` it fetches and compiles most +of the dependencies also. It is recommended to install CMake either manually +or via the Visual Studio installer when building with MSVC, using meson. + +Our CI configurations is also a good source of learning how to build HarfBuzz. + +There is also amalgam source provided with HarfBuzz which reduces whole process +of building HarfBuzz like `g++ src/harfbuzz.cc -fno-exceptions` but there is +not guarantee provided with buildability and reliability of features you get. diff --git a/third_party/harfbuzz-ng/src/CMakeLists.txt b/third_party/harfbuzz-ng/src/CMakeLists.txt new file mode 100644 index 000000000000..e22f2cfdd57c --- /dev/null +++ b/third_party/harfbuzz-ng/src/CMakeLists.txt @@ -0,0 +1,833 @@ +cmake_minimum_required(VERSION 3.12) +project(harfbuzz) + +message(WARN "HarfBuzz has a Meson port and tries to migrate all the other build systems to it, please consider using it as we might remove our cmake port soon.") + +## Limit framework build to Xcode generator +if (BUILD_FRAMEWORK) + # for a framework build on macOS, use: + # cmake -DBUILD_FRAMEWORK=ON -Bbuild -H. -GXcode && cmake --build build + if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") + message(FATAL_ERROR + "You should use Xcode generator with BUILD_FRAMEWORK enabled") + endif () + set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)") + set (CMAKE_MACOSX_RPATH ON) + set (BUILD_SHARED_LIBS ON) +endif () + + +## Disallow in-source builds, as CMake generated make files can collide with autotools ones +if (NOT MSVC AND "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") + message(FATAL_ERROR + " +In-source builds are not permitted! Make a separate folder for" + " building, e.g.," + " + mkdir build; cd build; cmake .." + " +Before that, remove the files created by this failed run with" + " + rm -rf CMakeCache.txt CMakeFiles") +endif () + + +## HarfBuzz build configurations +option(HB_HAVE_FREETYPE "Enable freetype interop helpers" OFF) +option(HB_HAVE_GRAPHITE2 "Enable Graphite2 complementary shaper" OFF) +option(HB_HAVE_GLIB "Enable glib unicode functions" OFF) +option(HB_HAVE_ICU "Enable icu unicode functions" OFF) +if (TARGET freetype) + set (HB_HAVE_FREETYPE ON) + add_definitions(-DHAVE_FREETYPE=1) +endif () +if (APPLE) + option(HB_HAVE_CORETEXT "Enable CoreText shaper backend on macOS" ON) + set (CMAKE_MACOSX_RPATH ON) +endif () +if (WIN32) + option(HB_HAVE_UNISCRIBE "Enable Uniscribe shaper backend on Windows" OFF) + option(HB_HAVE_GDI "Enable GDI integration helpers on Windows" OFF) + option(HB_HAVE_DIRECTWRITE "Enable DirectWrite shaper backend on Windows" OFF) +endif () +option(HB_BUILD_UTILS "Build harfbuzz utils, needs cairo, freetype, and glib properly be installed" OFF) +if (HB_BUILD_UTILS) + set (HB_HAVE_GLIB ON) + set (HB_HAVE_FREETYPE ON) +endif () + +option(HB_BUILD_SUBSET "Build harfbuzz-subset" ON) + +option(HB_HAVE_GOBJECT "Enable GObject Bindings" OFF) +if (HB_HAVE_GOBJECT) + set (HB_HAVE_GLIB ON) +endif () + +option(HB_HAVE_INTROSPECTION "Enable building introspection (.gir/.typelib) files" OFF) +if (HB_HAVE_INTROSPECTION) + set (HB_HAVE_GOBJECT ON) + set (HB_HAVE_GLIB ON) +endif () + +include_directories(AFTER + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_BINARY_DIR}/src +) + +# We need PYTHON_EXECUTABLE to be set for running the tests... +include (FindPythonInterp) + +## Functions and headers +include (CheckFunctionExists) +include (CheckIncludeFile) +include (CheckIncludeFiles) +macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools + foreach (func_name ${ARGN}) + string(TOUPPER ${func_name} definition_to_add) + check_function_exists(${func_name} HAVE_${definition_to_add}) + if (${HAVE_${definition_to_add}}) + add_definitions(-DHAVE_${definition_to_add}) + endif () + endforeach () +endmacro () +if (UNIX) + list(APPEND CMAKE_REQUIRED_LIBRARIES m) +endif () +check_funcs(atexit mprotect sysconf getpagesize mmap isatty) +check_include_file(unistd.h HAVE_UNISTD_H) +if (${HAVE_UNISTD_H}) + add_definitions(-DHAVE_UNISTD_H) +endif () +check_include_file(sys/mman.h HAVE_SYS_MMAN_H) +if (${HAVE_SYS_MMAN_H}) + add_definitions(-DHAVE_SYS_MMAN_H) +endif () +check_include_file(stdbool.h HAVE_STDBOOL_H) +if (${HAVE_STDBOOL_H}) + add_definitions(-DHAVE_STDBOOL_H) +endif () + +# These will be used while making pkg-config .pc files +set(PC_REQUIRES_PRIV "") +set(PC_LIBS_PRIV "") + +if (NOT MSVC) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + if (CMAKE_USE_PTHREADS_INIT) + add_definitions("-DHAVE_PTHREAD") + list(APPEND THIRD_PARTY_LIBS Threads::Threads) + list(APPEND PC_LIBS_PRIV -pthread) + endif () +endif () + +if (MSVC) + add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) +endif () + + +## Detect if we are running inside a distribution or regular repository folder +# if (EXISTS "${PROJECT_SOURCE_DIR}/ChangeLog") +# # perhaps we are on dist directory +# set (IN_HB_DIST TRUE) +# #set (HB_VERSION_H "${PROJECT_SOURCE_DIR}/src/hb-version.h") +# endif () + + +## Extract variables from Makefile files +function (extract_make_variable variable makefile_source) + string(REGEX MATCH "${variable} = ([^$]+)\\$" temp "${makefile_source}") + string(REGEX MATCHALL "[^ \n\t\\]+" listVar "${CMAKE_MATCH_1}") + set (${variable} ${listVar} PARENT_SCOPE) +endfunction () + +# https://stackoverflow.com/a/27630120 +function (add_prefix_to_list var prefix) + set (listVar "") + foreach (f ${${var}}) + list(APPEND listVar "${prefix}${f}") + endforeach () + set (${var} "${listVar}" PARENT_SCOPE) +endfunction () + +file(READ ${PROJECT_SOURCE_DIR}/src/Makefile.sources SRCSOURCES) +file(READ ${PROJECT_SOURCE_DIR}/util/Makefile.sources UTILSOURCES) + +extract_make_variable(HB_BASE_headers ${SRCSOURCES}) +add_prefix_to_list(HB_BASE_headers "${PROJECT_SOURCE_DIR}/src/") + +extract_make_variable(HB_SUBSET_sources ${SRCSOURCES}) +add_prefix_to_list(HB_SUBSET_sources "${PROJECT_SOURCE_DIR}/src/") + +extract_make_variable(HB_SUBSET_headers ${SRCSOURCES}) +add_prefix_to_list(HB_SUBSET_headers "${PROJECT_SOURCE_DIR}/src/") + +extract_make_variable(HB_BASE_RAGEL_GENERATED_sources ${SRCSOURCES}) +#if (IN_HB_DIST) + add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_SOURCE_DIR}/src/") +#else () +# add_prefix_to_list(HB_BASE_RAGEL_GENERATED_sources "${PROJECT_BINARY_DIR}/src/") +#endif () + +extract_make_variable(HB_VIEW_sources ${UTILSOURCES}) +add_prefix_to_list(HB_VIEW_sources "${PROJECT_SOURCE_DIR}/util/") +extract_make_variable(HB_SHAPE_sources ${UTILSOURCES}) +add_prefix_to_list(HB_SHAPE_sources "${PROJECT_SOURCE_DIR}/util/") +extract_make_variable(HB_SUBSET_CLI_sources ${UTILSOURCES}) +add_prefix_to_list(HB_SUBSET_CLI_sources "${PROJECT_SOURCE_DIR}/util/") +extract_make_variable(HB_OT_SHAPE_CLOSURE_sources ${UTILSOURCES}) +add_prefix_to_list(HB_OT_SHAPE_CLOSURE_sources "${PROJECT_SOURCE_DIR}/util/") + + +file(READ configure.ac CONFIGUREAC) +string(REGEX MATCH "\\[(([0-9]+)\\.([0-9]+)\\.([0-9]+))\\]" HB_VERSION_MATCH ${CONFIGUREAC}) +set (HB_VERSION ${CMAKE_MATCH_1}) +set (HB_VERSION_MAJOR ${CMAKE_MATCH_2}) +set (HB_VERSION_MINOR ${CMAKE_MATCH_3}) +set (HB_VERSION_MICRO ${CMAKE_MATCH_4}) + +## Define sources and headers of the project +set (project_sources ${PROJECT_SOURCE_DIR}/src/harfbuzz.cc) # use amalgam source +set (subset_project_sources ${HB_SUBSET_sources}) +set (project_extra_sources) +set (project_headers ${HB_BASE_headers}) +set (subset_project_headers ${HB_SUBSET_headers}) + +## Find and include needed header folders and libraries +if (HB_HAVE_FREETYPE AND NOT TARGET freetype) + include (FindFreetype) + if (NOT FREETYPE_FOUND) + message(FATAL_ERROR "HB_HAVE_FREETYPE was set, but we failed to find it. Maybe add a CMAKE_PREFIX_PATH= to your Freetype2 install prefix") + endif () + + list(APPEND THIRD_PARTY_LIBS ${FREETYPE_LIBRARIES}) + include_directories(AFTER ${FREETYPE_INCLUDE_DIRS}) + add_definitions(-DHAVE_FREETYPE=1) + + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-ft.h) + + # So check_funcs can find its headers + set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FREETYPE_INCLUDE_DIRS}) + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${FREETYPE_LIBRARIES}) + + check_funcs(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var) +endif () + +if (HB_HAVE_FREETYPE) + list(APPEND PC_REQUIRES_PRIV "freetype2 >= 12.0.6") +endif () + +if (HB_HAVE_GRAPHITE2) + add_definitions(-DHAVE_GRAPHITE2) + + find_path(GRAPHITE2_INCLUDE_DIR graphite2/Font.h) + find_library(GRAPHITE2_LIBRARY graphite2) + + include_directories(${GRAPHITE2_INCLUDE_DIR}) + + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-graphite2.h) + + list(APPEND THIRD_PARTY_LIBS ${GRAPHITE2_LIBRARY}) + + list(APPEND PC_REQUIRES_PRIV "graphite2 >= 1.2.0") + + mark_as_advanced(GRAPHITE2_INCLUDE_DIR GRAPHITE2_LIBRARY) +endif () + +if (HB_HAVE_GLIB) + add_definitions(-DHAVE_GLIB) + + # https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGLIB.cmake + find_package(PkgConfig) + pkg_check_modules(PC_GLIB QUIET glib-2.0) + + find_library(GLIB_LIBRARIES NAMES glib-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS}) + find_path(GLIBCONFIG_INCLUDE_DIR NAMES glibconfig.h HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0/include) + find_path(GLIB_INCLUDE_DIR NAMES glib.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0) + + include_directories(${GLIBCONFIG_INCLUDE_DIR} ${GLIB_INCLUDE_DIR}) + + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-glib.h) + + list(APPEND THIRD_PARTY_LIBS ${GLIB_LIBRARIES}) + + list(APPEND PC_REQUIRES_PRIV "glib-2.0 >= 2.19.1") + + mark_as_advanced(GLIB_LIBRARIES GLIBCONFIG_INCLUDE_DIR GLIB_INCLUDE_DIR) +endif () + +if (HB_HAVE_ICU) + add_definitions(-DHAVE_ICU) + + # https://github.com/WebKit/webkit/blob/fdd7733f2f30eab7fe096a9791f98c60f62f49c0/Source/cmake/FindICU.cmake + find_package(PkgConfig) + pkg_check_modules(PC_ICU QUIET icu-uc) + + find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR}) + find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR}) + + include_directories(${ICU_INCLUDE_DIR}) + + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-icu.h) + + list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY}) + + mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY) +endif () + +if (APPLE AND HB_HAVE_CORETEXT) + # Apple Advanced Typography + add_definitions(-DHAVE_CORETEXT) + + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-coretext.h) + + if (HB_IOS) + find_library(COREFOUNDATION CoreFoundation) + if (COREFOUNDATION) + list(APPEND THIRD_PARTY_LIBS ${COREFOUNDATION}) + list(APPEND PC_LIBS_PRIV "-framework CoreFoundation") + endif () + mark_as_advanced(COREFOUNDATION) + + find_library(CORETEXT CoreText) + if (CORETEXT) + list(APPEND THIRD_PARTY_LIBS ${CORETEXT}) + list(APPEND PC_LIBS_PRIV "-framework CoreText") + endif () + mark_as_advanced(CORETEXT) + + find_library(COREGRAPHICS CoreGraphics) + if (COREGRAPHICS) + list(APPEND THIRD_PARTY_LIBS ${COREGRAPHICS}) + list(APPEND PC_LIBS_PRIV "-framework CoreGraphics") + endif () + mark_as_advanced(COREGRAPHICS) + else () + find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices) + if (APPLICATION_SERVICES_FRAMEWORK) + list(APPEND THIRD_PARTY_LIBS ${APPLICATION_SERVICES_FRAMEWORK}) + list(APPEND PC_LIBS_PRIV "-framework ApplicationServices") + endif () + + mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK) + endif () +endif () + +if (WIN32 AND HB_HAVE_GDI) + add_definitions(-DHAVE_GDI) + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-gdi.h) + list(APPEND THIRD_PARTY_LIBS gdi32) + list(APPEND PC_LIBS_PRIV -lgdi32) +endif () + +if (WIN32 AND HB_HAVE_UNISCRIBE) + add_definitions(-DHAVE_UNISCRIBE) + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-uniscribe.h) + list(APPEND THIRD_PARTY_LIBS usp10 gdi32 rpcrt4) + list(APPEND PC_LIBS_PRIV -lusp10 -lgdi32 -lrpcrt4) +endif () + +if (WIN32 AND HB_HAVE_DIRECTWRITE) + if (CMAKE_VERSION VERSION_GREATER 3.12) + check_include_files("windows.h;dwrite_1.h" HAVE_DWRITE_1_H LANGUAGE CXX) + else () + check_include_files("windows.h;dwrite_1.h" HAVE_DWRITE_1_H) + endif () + if (NOT HAVE_DWRITE_1_H) + message(FATAL_ERROR "DirectWrite was enabled explicitly, but required header is missing") + endif () + add_definitions(-DHAVE_DIRECTWRITE) + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-directwrite.h) +endif () + +if (HB_HAVE_GOBJECT) + add_definitions(-DHAVE_GOBJECT) + include (FindPerl) + + # Use the hints from glib-2.0.pc to find glib-mkenums + find_package(PkgConfig) + pkg_check_modules(PC_GLIB QUIET glib-2.0) + find_program(GLIB_MKENUMS glib-mkenums + HINTS ${PC_glib_mkenums} + ) + set (GLIB_MKENUMS_CMD) + + if (WIN32 AND NOT MINGW) + # In Visual Studio builds, shebang lines are not supported + # in the standard cmd.exe shell that we use, so we need to + # first determine whether glib-mkenums is a Python or PERL + # script + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}" --version + RESULT_VARIABLE GLIB_MKENUMS_PYTHON + OUTPUT_QUIET ERROR_QUIET + ) + if (GLIB_MKENUMS_PYTHON EQUAL 0) + message("${GLIB_MKENUMS} is a Python script.") + set (GLIB_MKENUMS_CMD "${PYTHON_EXECUTABLE}" "${GLIB_MKENUMS}") + else () + execute_process(COMMAND "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}" --version + RESULT_VARIABLE GLIB_MKENUMS_PERL + OUTPUT_QUIET ERROR_QUIET + ) + if (GLIB_MKENUMS_PERL EQUAL 0) + message("${GLIB_MKENUMS} is a PERL script.") + set (GLIB_MKENUMS_CMD "${PERL_EXECUTABLE}" "${GLIB_MKENUMS}") + endif () + if (NOT GLIB_MKENUMS_PERL EQUAL 0 AND NOT GLIB_MKENUMS_PYTHON EQUAL 0) + message(FATAL_ERROR "Unable to determine type of glib-mkenums script") + endif () + endif () + else () + set (GLIB_MKENUMS_CMD "${GLIB_MKENUMS}") + endif () + if (NOT GLIB_MKENUMS_CMD) + message(FATAL_ERROR "HB_HAVE_GOBJECT was set, but we failed to find glib-mkenums, which is required") + endif () + + pkg_check_modules(PC_GOBJECT QUIET gobject-2.0) + + find_library(GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS}) + find_path(GOBJECT_INCLUDE_DIR NAMES glib-object.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0) + + include_directories(${GOBJECTCONFIG_INCLUDE_DIR} ${GOBJECT_INCLUDE_DIR}) + mark_as_advanced(GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR) + + list(APPEND hb_gobject_sources ${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.cc) + list(APPEND hb_gobject_gen_sources + ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc + ) + list(APPEND hb_gobject_structs_headers + ${PROJECT_SOURCE_DIR}/src/hb-gobject-structs.h + ) + list(APPEND hb_gobject_headers + ${PROJECT_SOURCE_DIR}/src/hb-gobject.h + ${hb_gobject_structs_headers} + ) + list(APPEND hb_gobject_gen_headers + ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h + COMMAND ${GLIB_MKENUMS_CMD} + --template=${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.h.tmpl + --identifier-prefix hb_ + --symbol-prefix hb_gobject + ${hb_gobject_structs_headers} + ${project_headers} + > ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h.tmp + COMMAND "${CMAKE_COMMAND}" + "-DENUM_INPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h.tmp" + "-DENUM_OUTPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h" + -P ${PROJECT_SOURCE_DIR}/replace-enum-strings.cmake + DEPENDS ${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.h.tmpl + ${hb_gobject_header} + ${project_headers} + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc + COMMAND ${GLIB_MKENUMS_CMD} + --template=${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.cc.tmpl + --identifier-prefix hb_ + --symbol-prefix hb_gobject + ${hb_gobject_header} + ${project_headers} + > ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc.tmp + COMMAND "${CMAKE_COMMAND}" + "-DENUM_INPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc.tmp" + "-DENUM_OUTPUT_SRC=${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.cc" + -P ${PROJECT_SOURCE_DIR}/replace-enum-strings.cmake + DEPENDS ${PROJECT_SOURCE_DIR}/src/hb-gobject-enums.cc.tmpl + ${CMAKE_CURRENT_BINARY_DIR}/src/hb-gobject-enums.h + ${hb_gobject_header} + ${project_headers} + ) +endif () + + +## Define harfbuzz library +add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers}) +target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) +target_include_directories(harfbuzz PUBLIC + "$" + "$") +if (HB_HAVE_FREETYPE AND TARGET freetype) + target_link_libraries(harfbuzz freetype) +endif () + + +## Define harfbuzz-icu library +if (HB_HAVE_ICU) + add_library(harfbuzz-icu ${PROJECT_SOURCE_DIR}/src/hb-icu.cc ${PROJECT_SOURCE_DIR}/src/hb-icu.h) + add_dependencies(harfbuzz-icu harfbuzz) + target_link_libraries(harfbuzz-icu harfbuzz ${THIRD_PARTY_LIBS}) + + if (BUILD_SHARED_LIBS) + set_target_properties(harfbuzz harfbuzz-icu PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) + endif () +endif () + + +## Define harfbuzz-subset library +if (HB_BUILD_SUBSET) + add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers}) + list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-subset.h) + add_dependencies(harfbuzz-subset harfbuzz) + target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS}) + + if (BUILD_SHARED_LIBS) + set_target_properties(harfbuzz harfbuzz-subset PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) + endif () +endif () + +if (UNIX OR MINGW) + # Make symbols link locally + include (CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG(-Bsymbolic-functions CXX_SUPPORTS_FLAG_BSYMB_FUNCS) + if (CXX_SUPPORTS_FLAG_BSYMB_FUNCS) + link_libraries(-Bsymbolic-functions) + endif () + + # As of CMake 3.0.0, the compiler id for Apple-provided Clang is now "AppleClang"; + # thus we use MATCHES instead of STREQUAL to include either regular Clang or AppleClang + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Make sure we don't link to libstdc++ + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") + set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm + set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "") + set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C) + if (HB_BUILD_SUBSET) + set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C) + endif () + + # No threadsafe statics as we do it ourselves + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics") + endif () + + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + if (COMPILER_SUPPORTS_CXX11) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + endif() +endif () + + +## Define harfbuzz-gobject library +if (HB_HAVE_GOBJECT) + add_library(harfbuzz-gobject + ${hb_gobject_sources} + ${hb_gobject_gen_sources} + ${hb_gobject_headers} + ${hb_gobject_gen_headers} + ) + include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src) + add_dependencies(harfbuzz-gobject harfbuzz) + target_link_libraries(harfbuzz-gobject harfbuzz ${GOBJECT_LIBRARIES} ${THIRD_PARTY_LIBS}) + + if (BUILD_SHARED_LIBS) + set_target_properties(harfbuzz-gobject PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE) + endif () +endif () + +if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW) + add_definitions("-DHB_DLL_EXPORT") +endif () + +# On Windows, g-ir-scanner requires a DLL build in order for it to work +if (WIN32) + if (NOT BUILD_SHARED_LIBS) + message("Building introspection files on Windows requires BUILD_SHARED_LIBS to be enabled.") + set (HB_HAVE_INTROSPECTION OFF) + endif () +endif () + +if (HB_HAVE_INTROSPECTION) + find_package(PkgConfig) + pkg_check_modules(PC_GI QUIET gobject-introspection-1.0) + + find_program(G_IR_SCANNER g-ir-scanner + HINTS ${PC_g_ir_scanner} + ) + + find_program(G_IR_COMPILER g-ir-compiler + HINTS ${PC_g_ir_compiler} + ) + + if (WIN32 AND NOT MINGW) + # Note that since we already enable HB_HAVE_GOBJECT + # we would already have PYTHON_EXECUTABLE handy + set (G_IR_SCANNER_CMD "${PYTHON_EXECUTABLE}" "${G_IR_SCANNER}") + else () + set (G_IR_SCANNER_CMD "${G_IR_SCANNER}") + endif () + + # We need to account for the varying output directories + # when we build using Visual Studio projects + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + set (hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$") + else () + set (hb_libpath "$") + endif () + + # Get the CFlags that we used to build HarfBuzz/HarfBuzz-GObject + set (hb_defines_cflags "") + foreach (hb_cflag ${hb_cflags}) + list(APPEND hb_defines_cflags "-D${hb_cflag}") + endforeach (hb_cflag) + + # Get the other dependent libraries we used to build HarfBuzz/HarfBuzz-GObject + set (extra_libs "") + foreach (extra_lib ${THIRD_PARTY_LIBS}) + # We don't want the .lib extension here... + string(REPLACE ".lib" "" extra_lib_stripped "${extra_lib}") + list(APPEND extra_libs "--extra-library=${extra_lib_stripped}") + endforeach () + + set (introspected_sources) + foreach (f + ${project_headers} + ${project_sources} + ${hb_gobject_gen_sources} + ${hb_gobject_gen_headers} + ${hb_gobject_sources} + ${hb_gobject_headers} + ) + if (WIN32) + # Nasty issue: We need to make drive letters lower case, + # otherwise g-ir-scanner won't like it and give us a bunch + # of invalid items and unresolved types... + STRING(SUBSTRING "${f}" 0 1 drive) + STRING(SUBSTRING "${f}" 1 -1 path) + if (drive MATCHES "[A-Z]") + STRING(TOLOWER ${drive} drive_lower) + list(APPEND introspected_sources "${drive_lower}${path}") + else () + list(APPEND introspected_sources "${f}") + endif () + else () + list(APPEND introspected_sources "${f}") + endif () + endforeach () + + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list) + foreach (s ${introspected_sources}) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list "${s}\n") + endforeach () + + # Finally, build the introspection files... + add_custom_command( + TARGET harfbuzz-gobject + POST_BUILD + COMMAND ${G_IR_SCANNER_CMD} + --warn-all --no-libtool --verbose + --namespace=HarfBuzz + --nsversion=0.0 + --symbol-prefix=hb + --symbol-prefix=hb_gobject + --identifier-prefix=hb_ + --include GObject-2.0 + --pkg-export=harfbuzz-gobject + --c-include=hb-gobject.h + --cflags-begin + -I${PROJECT_SOURCE_DIR}/src + -I${PROJECT_BINARY_DIR}/src + ${hb_includedir_cflags} + ${hb_defines_cflags} + -DHB_H + -DHB_H_IN + -DHB_OT_H + -DHB_OT_H_IN + -DHB_AAT_H + -DHB_AAT_H_IN + -DHB_GOBJECT_H + -DHB_GOBJECT_H_IN + -DHB_EXTERN= + --cflags-end + --library=harfbuzz-gobject + --library=harfbuzz + -L${hb_libpath} + ${extra_libs} + --filelist ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list + -o ${hb_libpath}/HarfBuzz-0.0.gir + DEPENDS harfbuzz-gobject harfbuzz ${CMAKE_CURRENT_BINARY_DIR}/src/hb_gir_list + ) + + add_custom_command( + TARGET harfbuzz-gobject + POST_BUILD + COMMAND "${G_IR_COMPILER}" + --verbose --debug + --includedir ${CMAKE_CURRENT_BINARY_DIR} + ${hb_libpath}/HarfBuzz-0.0.gir + -o ${hb_libpath}/HarfBuzz-0.0.typelib + DEPENDS ${hb_libpath}/HarfBuzz-0.0.gir harfbuzz-gobject + ) +endif () + + +## Additional framework build configs +if (BUILD_FRAMEWORK) + set (CMAKE_MACOSX_RPATH ON) + set_target_properties(harfbuzz PROPERTIES + FRAMEWORK TRUE + PUBLIC_HEADER "${project_headers}" + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + ) + set (MACOSX_FRAMEWORK_IDENTIFIER "harfbuzz") + set (MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${HB_VERSION}") + set (MACOSX_FRAMEWORK_BUNDLE_VERSION "${HB_VERSION}") +endif () + + +## Additional harfbuzz build artifacts +if (HB_BUILD_UTILS) + # https://github.com/WebKit/webkit/blob/master/Source/cmake/FindCairo.cmake + find_package(PkgConfig) + pkg_check_modules(PC_CAIRO QUIET cairo) + + find_path(CAIRO_INCLUDE_DIRS NAMES cairo.h HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIRS} PATH_SUFFIXES cairo) + find_library(CAIRO_LIBRARIESNAMES cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS}) + + add_definitions("-DPACKAGE_NAME=\"HarfBuzz\"") + add_definitions("-DPACKAGE_VERSION=\"${HB_VERSION}\"") + include_directories(${CAIRO_INCLUDE_DIRS}) + + add_executable(hb-view ${HB_VIEW_sources}) + target_link_libraries(hb-view harfbuzz ${CAIRO_LIBRARIESNAMES}) + + add_executable(hb-shape ${HB_SHAPE_sources}) + target_link_libraries(hb-shape harfbuzz) + + add_executable(hb-subset ${HB_SUBSET_CLI_sources}) + target_link_libraries(hb-subset harfbuzz harfbuzz-subset) + + add_executable(hb-ot-shape-closure ${HB_OT_SHAPE_CLOSURE_sources}) + target_link_libraries(hb-ot-shape-closure harfbuzz) + + mark_as_advanced(CAIRO_INCLUDE_DIRS CAIRO_LIBRARIESNAMES) +endif () + + +## Install +include (GNUInstallDirs) + +if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) + install(FILES ${project_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz) + if (HB_HAVE_GOBJECT) + install(FILES ${hb_gobject_headers} ${hb_gobject_gen_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/harfbuzz) + endif () +endif () + +# get these variables in the required format +list(REMOVE_DUPLICATES PC_REQUIRES_PRIV) +string(REPLACE ";" ", " PC_REQUIRES_PRIV "${PC_REQUIRES_PRIV}") +list(REMOVE_DUPLICATES PC_LIBS_PRIV) +string(REPLACE ";" " " PC_LIBS_PRIV "${PC_LIBS_PRIV}") + +# Macro to write pkg-config .pc configuration files +macro ( make_pkgconfig_pc_file name ) + file(READ "${PROJECT_SOURCE_DIR}/src/${name}.pc.in" FSTR) + + string(REPLACE "%prefix%" "${CMAKE_INSTALL_PREFIX}" FSTR ${FSTR}) + string(REPLACE "%exec_prefix%" "\${prefix}" FSTR ${FSTR}) + + if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + string(REPLACE "%includedir%" "${CMAKE_INSTALL_INCLUDEDIR}" FSTR ${FSTR}) + else () + string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}" FSTR ${FSTR}) + endif () + + if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + string(REPLACE "%libdir%" "${CMAKE_INSTALL_LIBDIR}" FSTR ${FSTR}) + else () + string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}" FSTR ${FSTR}) + endif () + + string(REPLACE "%VERSION%" "${HB_VERSION}" FSTR ${FSTR}) + string(REPLACE "%requires_private%" "${PC_REQUIRES_PRIV}" FSTR ${FSTR}) + string(REPLACE "%libs_private%" "${PC_LIBS_PRIV}" FSTR ${FSTR}) + + file(WRITE "${PROJECT_BINARY_DIR}/${name}.pc" ${FSTR}) + + install( + FILES "${PROJECT_BINARY_DIR}/${name}.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + COMPONENT pkgconfig + ) +endmacro ( make_pkgconfig_pc_file ) + +if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) + install(TARGETS harfbuzz + EXPORT harfbuzzConfig + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + FRAMEWORK DESTINATION Library/Frameworks + ) + make_pkgconfig_pc_file("harfbuzz") + install(EXPORT harfbuzzConfig + NAMESPACE harfbuzz:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/harfbuzz + ) + if (HB_HAVE_ICU) + install(TARGETS harfbuzz-icu + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + FRAMEWORK DESTINATION Library/Frameworks + ) + make_pkgconfig_pc_file("harfbuzz-icu") + endif () + if (HB_BUILD_SUBSET) + install(TARGETS harfbuzz-subset + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + make_pkgconfig_pc_file("harfbuzz-subset") + endif () + if (HB_BUILD_UTILS) + if (WIN32 AND BUILD_SHARED_LIBS) + install(TARGETS harfbuzz-subset + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + endif () + install(TARGETS hb-view + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + install(TARGETS hb-subset + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + + install(TARGETS hb-shape + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + + install(TARGETS hb-ot-shape-closure + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + endif () + if (HB_HAVE_GOBJECT) + install(TARGETS harfbuzz-gobject + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + make_pkgconfig_pc_file("harfbuzz-gobject") + if (HB_HAVE_INTROSPECTION) + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio*") + set (hb_libpath "${CMAKE_CURRENT_BINARY_DIR}/$") + else () + set (hb_libpath "$") + endif () + + install(FILES "${hb_libpath}/HarfBuzz-0.0.gir" + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0 + ) + + install(FILES "${hb_libpath}/HarfBuzz-0.0.typelib" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0 + ) + endif () + endif () +endif () diff --git a/third_party/harfbuzz-ng/src/CONFIG.md b/third_party/harfbuzz-ng/src/CONFIG.md new file mode 100644 index 000000000000..0faa359e6bb4 --- /dev/null +++ b/third_party/harfbuzz-ng/src/CONFIG.md @@ -0,0 +1,158 @@ +# Configuring HarfBuzz + +Most of the time you will not need any custom configuration. The configuration +options provided by `meson` should be enough. In particular, if you just want +HarfBuzz library plus hb-shape / hb-view utilities, make sure FreeType and Cairo +are available and found during configuration. + +If you are building for distribution, you should more carefully consider whether +you need Glib, ICU, Graphite2, as well as CoreText / Uniscribe / DWrite. Make +sure the relevant ones are enabled. + +If you are building for custom environment (embedded, downloadable app, etc) +where you mostly just want to call `hb_shape()` and the binary size of the +resulting library is very important to you, the rest of this file guides you +through your options to disable features you may not need, in exchange for +binary size savings. + +## Compiler Options + +Make sure you build with your compiler's "optimize for size" option. On `gcc` +this is `-Os`, and can be enabled by passing `CXXFLAGS=-Os`. On clang there +is an even more extreme flag, `-Oz`. Meson also provides `--buildtype=minsize` +for more convenience. + +HarfBuzz heavily uses inline functions and the optimize-size flag can make the +library smaller by 20% or more. Moreover, sometimes, based on the target CPU, +the optimize-size builds perform *faster* as well, thanks to lower code +footprint and caching effects. So, definitely try that even if size is not +extremely tight but you have a huge application. For example, Chrome does +that. Note that this configuration also automatically enables certain internal +optimizations. Search for `HB_OPTIMIZE_SIZE` for details, if you are using +other compilers, or continue reading. + +Another compiler option to consider is "link-time optimization", also known as +'lto'. To enable that, feel free to use `-Db_lto=true` of meson. +This, also, can have a huge impact on the final size, 20% or more. + +Finally, if you are making a static library build or otherwise linking the +library into your app, make sure your linker removes unused functions. This +can be tricky and differ from environment to environment, but you definitely +want to make sure this happens. Otherwise, every unused public function will +be adding unneeded bytes to your binary. The following pointers might come +handy: + + * https://lwn.net/Articles/741494/ (all of the four-part series) + * https://elinux.org/images/2/2d/ELC2010-gc-sections_Denys_Vlasenko.pdf + +Combining the above three build options should already shrink your library a lot. +The rest of this file shows you ways to shrink the library even further at the +expense of removing functionality (that may not be needed). The remaining +options are all enabled by defining pre-processor macros, which can be done +via `CXXFLAGS` or `CPPFLAGS` similarly. + + +## Unicode-functions + +Access to Unicode data can be configured at compile time as well as run-time. +By default, HarfBuzz ships with its own compact subset of properties from +Unicode Character Database that it needs. This is a highly-optimized +implementation that depending on compile settings (optimize-size or not) +takes around ~40kb or ~60kb. Using this implementation (default) is highly +recommended, as HarfBuzz always ships with data from latest version of Unicode. +This implementation can be disabled by defining `HB_NO_UCD`. + +For example, if you are enabling ICU as a built-in option, or GLib, those +can provide Unicode data as well, so defining `HB_NO_UCD` might save you +space without reducing functionality (to the extent that the Unicode version +of those implementations is recent.) + +If, however, you provide your own Unicode data to HarfBuzz at run-time by +calling `hb_buffer_set_unicode_funcs` on every buffer you create, and you do +not rely on `hb_unicode_funcs_get_default()` results, you can disable the +internal implementation by defining both `HB_NO_UCD` and `HB_NO_UNICODE_FUNCS`. +The latter is needed to guard against accidentally building a library without +any default Unicode implementations. + + +## Font-functions + +Access to certain font functionalities can also be configured at run-time. By +default, HarfBuzz uses an efficient internal implementation of OpenType +functionality for this. This internal implementation is called `hb-ot-font`. +All newly-created `hb_font_t` objects by default use `hb-ot-font`. Using this +is highly recommended, and is what fonts use by default when they are created. + +Most embedded uses will probably use HarfBuzz with FreeType using `hb-ft.h`. +In that case, or if you otherwise provide those functions by calling +`hb_font_set_funcs()` on every font you create, you can disable `hb-ot-font` +without loss of functionality by defining `HB_NO_OT_FONT`. + + +## Shapers + +Most HarfBuzz clients use it for the main shaper, called "ot". However, it +is legitimate to want to compile HarfBuzz with only another backend, eg. +CoreText, for example for an iOS app. For that, you want `HB_NO_OT_SHAPE`. +If you are going down that route, check if you want `HB_NO_OT`. + +This is very rarely what you need. Make sure you understand exactly what you +are doing. + +Defining `HB_NO_FALLBACK_SHAPE` however is pretty harmless. That removes the +(unused) "fallback" shaper. This is defined by the `HB_TINY` profile already +(more below). + + +## Thread-safety + +By default HarfBuzz builds as a thread-safe library. The exception is that +the `HB_TINY` predefined configuration (more below) disables thread-safety. + +If you do *not* need thread-safety in the library (eg. you always call into +HarfBuzz from the same thread), you can disable thread-safety by defining +`HB_NO_MT`. As noted already, this is enabled by `HB_TINY`. + + +## Pre-defined configurations + +The [`hb-config.hh`](src/hb-config.hh) internal header supports three +pre-defined configurations as well grouping of various configuration options. +The pre-defined configurations are: + + * `HB_MINI`: Disables shaping of AAT as well as legacy fonts. Ie. it produces + a capable OpenType shaper only. + + * `HB_LEAN`: Disables various non-shaping functionality in the library, as well + as esoteric or rarely-used shaping features. See the definition for details. + + * `HB_TINY`: Enables both `HB_MINI` and `HB_LEAN` configurations, as well as + disabling thread-safety and debugging, and use even more size-optimized data + tables. + + +## Tailoring configuration + +Most of the time, one of the pre-defined configuration is exactly what one needs. +Sometimes, however, the pre-defined configuration cuts out features that might +be desired in the library. Unfortunately there is no quick way to undo those +configurations from the command-line. + +However, configuration can still be overridden from a file. To do that, add your +override instructions (mostly `undef` instructions) to a header file and define +the macro `HB_CONFIG_OVERRIDE_H` to the string containing to that header file's +name. HarfBuzz will then include that file at the appropriate place during +configuration. + +Up until HarfBuzz 3.1.2 the the configuration override header file's name was +fixed and called `config-override.h`, and was activated by defining the macro +`HAVE_CONFIG_OVERRIDE_H`. That still works. + + +## Notes + +Note that the config option `HB_NO_CFF`, which is enabled by `HB_LEAN` and +`HB_TINY` does *not* mean that the resulting library won't work with CFF fonts. +The library can shape valid CFF fonts just fine, with or without this option. +This option disables (among other things) the code to calculate glyph extents +for CFF fonts, which many clients might not need. diff --git a/third_party/harfbuzz-ng/src/COPYING b/third_party/harfbuzz-ng/src/COPYING new file mode 100644 index 000000000000..1dd917e9f2e7 --- /dev/null +++ b/third_party/harfbuzz-ng/src/COPYING @@ -0,0 +1,42 @@ +HarfBuzz is licensed under the so-called "Old MIT" license. Details follow. +For parts of HarfBuzz that are licensed under different licenses see individual +files names COPYING in subdirectories where applicable. + +Copyright © 2010-2022 Google, Inc. +Copyright © 2015-2020 Ebrahim Byagowi +Copyright © 2019,2020 Facebook, Inc. +Copyright © 2012,2015 Mozilla Foundation +Copyright © 2011 Codethink Limited +Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies) +Copyright © 2009 Keith Stribley +Copyright © 2011 Martin Hosken and SIL International +Copyright © 2007 Chris Wilson +Copyright © 2005,2006,2020,2021,2022,2023 Behdad Esfahbod +Copyright © 2004,2007,2008,2009,2010,2013,2021,2022,2023 Red Hat, Inc. +Copyright © 1998-2005 David Turner and Werner Lemberg +Copyright © 2016 Igalia S.L. +Copyright © 2022 Matthias Clasen +Copyright © 2018,2021 Khaled Hosny +Copyright © 2018,2019,2020 Adobe, Inc +Copyright © 2013-2015 Alexei Podtelezhnikov + +For full copyright notices consult the individual files in the package. + + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that the +above copyright notice and the following two paragraphs appear in +all copies of this software. + +IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN +IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO +PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/third_party/harfbuzz-ng/src/METADATA b/third_party/harfbuzz-ng/src/METADATA new file mode 100644 index 000000000000..8a33eef7b3a3 --- /dev/null +++ b/third_party/harfbuzz-ng/src/METADATA @@ -0,0 +1,12 @@ +third_party { + identifier { + type: "ChromiumVersion" + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html + } + identifier { + type: "Git" + value: "https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git" + version: "2175f5d050743317c563ec9414e0f83a47f7fbc4" + # from https://chromium.googlesource.com/chromium/src/+/114.0.5735.358/DEPS#355 + } +} diff --git a/third_party/harfbuzz-ng/src/Makefile.am b/third_party/harfbuzz-ng/src/Makefile.am new file mode 100644 index 000000000000..c14b4b7c20c3 --- /dev/null +++ b/third_party/harfbuzz-ng/src/Makefile.am @@ -0,0 +1,82 @@ +# Process this file with automake to produce Makefile.in + +NULL = + +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = src util test perf docs + +EXTRA_DIST = \ + autogen.sh \ + harfbuzz.doap \ + README.md \ + README.python.md \ + BUILD.md \ + CONFIG.md \ + RELEASING.md \ + TESTING.md \ + CMakeLists.txt \ + replace-enum-strings.cmake \ + meson.build \ + meson_options.txt \ + subprojects/cairo.wrap \ + subprojects/freetype2.wrap \ + subprojects/glib.wrap \ + subprojects/google-benchmark.wrap \ + subprojects/ragel.wrap \ + subprojects/packagefiles/ragel/meson.build \ + mingw-configure.sh \ + $(NULL) + +MAINTAINERCLEANFILES = \ + $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \ + $(GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL) \ + $(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN) \ + $(srcdir)/INSTALL \ + $(srcdir)/ChangeLog \ + $(srcdir)/gtk-doc.make \ + $(srcdir)/m4/gtk-doc.m4 \ + $(NULL) + + +# +# ChangeLog generation +# +CHANGELOG_RANGE = +ChangeLog: $(srcdir)/ChangeLog +$(srcdir)/ChangeLog: + $(AM_V_GEN) if test -d "$(top_srcdir)/.git"; then \ + (GIT_DIR=$(top_srcdir)/.git \ + $(GIT) log $(CHANGELOG_RANGE) --stat) > $@.tmp \ + && mv -f $@.tmp "$(srcdir)/ChangeLog" \ + || ($(RM) $@.tmp; \ + echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ + (test -f $@ || echo git-log is required to generate this file >> "$(srcdir)/$@")); \ + else \ + test -f $@ || \ + (echo A git checkout and git-log is required to generate ChangeLog >&2 && \ + echo A git checkout and git-log is required to generate this file >> "$(srcdir)/$@"); \ + fi +.PHONY: ChangeLog $(srcdir)/ChangeLog + + +# +# Release engineering +# + +DISTCHECK_CONFIGURE_FLAGS = \ + --enable-gtk-doc \ + --disable-doc-cross-references \ + --with-gobject \ + --enable-introspection \ + $(NULL) + +# TAR_OPTIONS is not set as env var for 'make dist'. How to fix that? +TAR_OPTIONS = --owner=0 --group=0 + +dist-hook: dist-clear-sticky-bits +# Clean up any sticky bits we may inherit from parent dir +dist-clear-sticky-bits: + chmod -R a-s $(distdir) + +-include $(top_srcdir)/git.mk diff --git a/third_party/harfbuzz-ng/src/NEWS b/third_party/harfbuzz-ng/src/NEWS new file mode 100644 index 000000000000..5ed287822d00 --- /dev/null +++ b/third_party/harfbuzz-ng/src/NEWS @@ -0,0 +1,3227 @@ +Overview of changes leading to 7.1.0 +Friday, March 3, 2023 +==================================== +- New experimental hb_shape_justify() API that uses font variations to expand + or shrink the text to a given advance. (Behdad Esfahbod) +- Various build and bug fixes. (Behdad Esfahbod, Garret Rieger, Qunxin Liu) + +- New API: ++hb_font_set_variation() + +Overview of changes leading to 7.0.1 +Monday, February 20, 2023 +==================================== +- Various build and bug fixes. + + +Overview of changes leading to 7.0.0 +Saturday, February 11, 2023 +==================================== +- New hb-paint API that is designed mainly to paint “COLRv1†glyphs, but can be + also used as a unified API to paint any of the glyph representations + supported by HarfBuzz (B/W outlines, color layers, or color bitmaps). + (Behdad Esfahbod, Matthias Clasen) +- New hb-cairo API for integrating with cairo graphics library. This is provided + as a separate harfbuzz-cairo library. (Behdad Esfahbod, Matthias Clasen) +- Support for instancing “CFF2†table. (Behdad Esfahbod) +- Support font emboldening. (Behdad Esfahbod) +- Support feature ranges with AAT shaping. (Behdad Esfahbod) +- Experimental support to cubic curves in “glyf†table, see + https://github.com/harfbuzz/boring-expansion-spec/blob/main/glyf1-cubicOutlines.md + for spec. (Behdad Esfahbod) +- Various subsetter improvements. (Garret Rieger, Qunxin Liu, Behdad Esfahbod) +- Various documentation improvements. + (Behdad Esfahbod, Matthias Clasen, Khaled Hosny) +- Significantly reduced memory use during shaping. (Behdad Esfahbod) +- Greatly reduced memory use during subsetting “CFF†table. (Behdad Esfahbod) +- New command line utility, hb-info, for querying various font information. + (Behdad Esfahbod, Matthias Clasen) +- New hb-shape/hb-view options: --glyphs, --color-palette, --font-bold, + --font-grade, and --named-instance. (Behdad Esfahbod) +- Miscellaneous fixes and improvements. + (Amir Masoud Abdol, Andres Salomon, Behdad Esfahbod, Chun-wei Fan, + Garret Rieger, Jens Kutilek, Khaled Hosny, Konstantin Käfer, Matthias Clasen, + Nirbheek Chauhan, Pedro J. Estébanez, Qunxin Liu, Sergei Trofimovich) + +- New API: ++HB_FONT_NO_VAR_NAMED_INSTANCE ++HB_PAINT_IMAGE_FORMAT_BGRA ++HB_PAINT_IMAGE_FORMAT_PNG ++HB_PAINT_IMAGE_FORMAT_SVG ++hb_cairo_font_face_create_for_face ++hb_cairo_font_face_create_for_font ++hb_cairo_font_face_get_face ++hb_cairo_font_face_get_font ++hb_cairo_font_face_get_scale_factor ++hb_cairo_font_face_set_font_init_func ++hb_cairo_font_face_set_scale_factor ++hb_cairo_font_init_func_t ++hb_cairo_glyphs_from_buffer ++hb_cairo_scaled_font_get_font ++hb_color_line_get_color_stops ++hb_color_line_get_color_stops_func_t ++hb_color_line_get_extend ++hb_color_line_get_extend_func_t ++hb_color_line_t ++hb_color_stop_t ++hb_draw_funcs_get_empty ++hb_draw_funcs_get_user_data ++hb_draw_funcs_set_user_data ++hb_face_collect_nominal_glyph_mapping ++hb_font_draw_glyph ++hb_font_draw_glyph_func_t ++hb_font_funcs_set_draw_glyph_func ++hb_font_funcs_set_paint_glyph_func ++hb_font_get_synthetic_bold ++hb_font_get_var_named_instance ++hb_font_paint_glyph ++hb_font_paint_glyph_func_t ++hb_font_set_synthetic_bold ++hb_map_keys ++hb_map_next ++hb_map_update ++hb_map_values ++hb_ot_color_glyph_has_paint ++hb_ot_color_has_paint ++hb_ot_layout_script_select_language2 ++hb_ot_name_id_predefined_t ++hb_paint_color ++hb_paint_color_func_t ++hb_paint_composite_mode_t ++hb_paint_custom_palette_color ++hb_paint_custom_palette_color_func_t ++hb_paint_extend_t ++hb_paint_funcs_create ++hb_paint_funcs_destroy ++hb_paint_funcs_get_empty ++hb_paint_funcs_get_user_data ++hb_paint_funcs_is_immutable ++hb_paint_funcs_make_immutable ++hb_paint_funcs_reference ++hb_paint_funcs_set_color_func ++hb_paint_funcs_set_custom_palette_color_func ++hb_paint_funcs_set_image_func ++hb_paint_funcs_set_linear_gradient_func ++hb_paint_funcs_set_pop_clip_func ++hb_paint_funcs_set_pop_group_func ++hb_paint_funcs_set_pop_transform_func ++hb_paint_funcs_set_push_clip_glyph_func ++hb_paint_funcs_set_push_clip_rectangle_func ++hb_paint_funcs_set_push_group_func ++hb_paint_funcs_set_push_transform_func ++hb_paint_funcs_set_radial_gradient_func ++hb_paint_funcs_set_sweep_gradient_func ++hb_paint_funcs_set_user_data ++hb_paint_funcs_t ++hb_paint_image ++hb_paint_image_func_t ++hb_paint_linear_gradient ++hb_paint_linear_gradient_func_t ++hb_paint_pop_clip ++hb_paint_pop_clip_func_t ++hb_paint_pop_group ++hb_paint_pop_group_func_t ++hb_paint_pop_transform ++hb_paint_pop_transform_func_t ++hb_paint_push_clip_glyph ++hb_paint_push_clip_glyph_func_t ++hb_paint_push_clip_rectangle ++hb_paint_push_clip_rectangle_func_t ++hb_paint_push_group ++hb_paint_push_group_func_t ++hb_paint_push_transform ++hb_paint_push_transform_func_t ++hb_paint_radial_gradient ++hb_paint_radial_gradient_func_t ++hb_paint_sweep_gradient ++hb_paint_sweep_gradient_func_t ++hb_set_is_inverted ++hb_subset_input_keep_everything + +- Deprecated API: ++hb_font_funcs_set_glyph_shape_func ++hb_font_get_glyph_shape_func_t ++hb_font_get_glyph_shape + + +Overview of changes leading to 6.0.0 +Friday, December 16, 2022 +==================================== +- A new API have been added to pre-process the face and speed up future + subsetting operations on that face. Provides up to a 95% reduction in + subsetting times when the same face is subset more than once. + + For more details and benchmarks, see: + https://github.com/harfbuzz/harfbuzz/blob/main/docs/subset-preprocessing.md + + (Garret Rieger, Behdad Esfahbod) + +- Shaping have been speedup by skipping entire lookups when the buffer contents + don't intersect with the lookup. Shows up to a 10% speedup in shaping some + fonts. (Behdad Esfahbod) + +- A new experimental feature, “Variable Composites†(enabled by passing + -Dexperimental_api=true to meson), is also featured in this release. + This technology enables drastic compression of fonts in the Chinese, + Japanese, Korean, and other writing systems, by reusing the OpenType Font + Variations technology for encoding “smart components†into the font. + + The specification for these extensions to the font format can be found in: + https://github.com/harfbuzz/boring-expansion-spec/blob/glyf1/glyf1.md + + A test variable-font with ~7160 Hangul syllables derived from the + NotoSerifKR-VF font has been built, with existing OpenType technology, as + well as with the new Variable Composites (VarComposites) technology. The + VarComposites font is over 90% smaller than the OpenType version of the font! + Both fonts can be obtained from the “smarties†repository: + https://github.com/behdad/smarties/tree/3.0/fonts/hangul/serif + + When building HarfBuzz with experimental features enabled, you can test + the “smarties†font with a sample character like this: + + $ hb-view butchered-hangul-serif-smarties-variable.ttf -u AE01 --variations=wght=700 + + (Behdad Esfahbod) + +- The HarfBuzz subsetter can now drop axes by pinning them to specific values + (also referred to as instancing). There are a couple of restrictions + currently: + + - Only works with TrueType (“glyfâ€) based fonts. “CFF2†fonts are not yet + supported. + - Only supports the case where all axes in a font are pinned. + + (Garret Rieger, Qunxin Liu) + +- Miscellaneous fixes and improvements. + + (Behdad Esfahbod, Christoph Reiter, David Corbett, Eli Schwartz, Garret + Rieger, Joel Auterson, Jordan Petridis, Khaled Hosny, Lorenz Wildberg, + Marco Rebhan, Martin Storsjö, Matthias Clasen, Qunxin Liu, Satadru Pramanik) + + +- New API ++hb_subset_input_pin_axis_location() ++hb_subset_input_pin_axis_to_default() ++hb_subset_preprocess() + + +Overview of changes leading to 5.3.1 +Wednesday, October 19, 2022 +==================================== +- Subsetter repacker fixes. (Garret Rieger) +- Adjust Grapheme clusters for Katakana voiced sound marks. (Behdad Esfahbod) +- New “hb-subset†option “--preprocess-faceâ€. (Garret Rieger) + + +Overview of changes leading to 5.3.0 +Saturday, October 8, 2022 +"Women, Life, Freedom" #MahsaAmini +==================================== +- Don’t add glyphs from dropped MATH or COLR tables to the subset glyphs. + (Khaled Hosny) +- Map “rlig†to appropriate AAT feature selectors. (Jonathan Kew) +- Update USE data files to latest version. (David Corbett) +- Check “CBDT†extents first before outline tables, to help with fonts that + also include an empty “glyf†table. (Khaled Hosny) +- More work towards variable font instancing in the subsetter. (Qunxin Liu) +- Subsetter repacker improvements. (Garret Rieger) +- New API: ++hb_ot_layout_lookup_get_optical_bound() ++hb_face_builder_sort_tables() + + +Overview of changes leading to 5.2.0 +Saturday, September 17, 2022 +==================================== +- Fix regressions in hb-ft font functions for FT_Face’s with transformation + matrix. (Behdad Esfahbod) +- The experimental hb-repacker API now supports splitting several GPOS subtable + types when needed. (Garret Rieger) +- The HarfBuzz extensions to OpenType font format are now opt-in behind + build-time flags. (Behdad Esfahbod) +- The experimental hb-subset variable fonts instantiation API can now + instantiate more font tables and arbitrary axis locations. (Qunxin Liu) +- Unicode 15 support. (David Corbett) +- Various documentation improvements. (Behdad Esfahbod, Matthias Clasen) +- The hb-view command line tool now detects WezTerm inline images support. + (Wez Furlong) +- Fix FreeType and ICU dependency lookup with meson. (Xavier Claessens) + +- New API: ++HB_SCRIPT_KAWI ++HB_SCRIPT_NAG_MUNDARI + + +Overview of changes leading to 5.1.0 +Sunday, July 31, 2022 +==================================== +- More extensive buffer tracing messages. (Behdad Esfahbod) +- Fix hb-ft regression in bitmap fonts rendering. (Behdad Esfahbod) +- Support extension promotion of lookups in hb-subset-repacker. (Garret Rieger) +- A new HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL for scripts that use elongation + (e.g. Arabic) to signify where it is safe to insert tatweel glyph without + interrupting shaping. (Behdad Esfahbod) +- Add “--safe-to-insert-tatweel†to “hb-shape†tool. (Behdad Esfahbod) + +- New API ++HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL ++HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL + + +Overview of changes leading to 5.0.1 +Saturday, July 23, 2022 +==================================== +- Fix version 2 “avar†table with hb-ft. (Behdad Esfahbod) + + +Overview of changes leading to 5.0.0 +Saturday, July 23, 2022 +==================================== +- Support fonts with more than 65535 glyphs in “GDEFâ€, “GSUBâ€, and “GPOS†+ tables. This is part of https://github.com/be-fonts/boring-expansion-spec to + extend OpenType in a backward-compatible way. + (Behdad Esfahbod, Garret Rieger) +- Complete support for more than 65535 glyphs in “glyf†table that started in + 4.0.0 release. Part of boring-expansion-spec. (Behdad Esfahbod) +- Support version 2 of “avar†table. Part of boring-expansion-spec. + (Behdad Esfahbod) +- Fix mark attachment on multiple substitutions in some cases. + (Behdad Esfahbod) +- Fix application of “caltâ€, “rcltâ€, and “ccmp†features to better match + Uniscribe behaviour with some Arabic fonts. (Behdad Esfahbod) +- Improvement to interaction between multiple cursive attachments. + (Behdad Esfahbod) +- Improve multiple mark interactions in Hebrew. (Behdad Esfahbod) +- Implement language-specific forms in AAT shaping. (Behdad Esfahbod) +- Fix variation of “VORG†table. (Behdad Esfahbod) +- Support for specific script tags to be retained in the subsetter, and add + “--layout-scripts†option to “hb-subset†tool. (Garret Rieger) +- Accept space as delimiter for --features/--variations in command line tools. +- Improve subsetting of “COLR†table. (Qunxin Liu) +- Improved fuzzing coverage for ot-math API. (Frédéric Wang) +- Fix “kern†table version 2 (AAT) sanitization on 32-bit systems. + (Behdad Esfahbod) +- Allow negative glyph advances from “graphite2†shaper. (Stephan Bergmann) +- Implement loading (color) bitmap fonts with hb-ft. (Behdad Esfahbod) +- Fix regression in hb-ft when changing font size. (Behdad Esfahbod) +- Fix build on GCC < 7. (Kleis Auke Wolthuizen) +- Dynamically load dwrite.dll on windows if “directwrite†shaper is enabled. + (Luca Bacci) +- Provide a single-file harfbuzz-subset.cc file for easier alternate building + of hb-subset library, similar to harfbuzz.cc. (Khaled Hosny) + +- New API ++HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG ++hb_language_matches() + + +Overview of changes leading to 4.4.1 +Wednesday, June 29, 2022 +==================================== +- Fix test failure with some compilers. +- Fix Telugu and Kannada kerning regression. + + +Overview of changes leading to 4.4.0 +Monday, June 27, 2022 +==================================== +- Caching of variable fonts shaping, in particular when using HarfBuzz’s own + font loading functions (ot). Bringing performance of variable shaping in par + with non-variable fonts shaping. (Behdad Esfahbod) +- Caching of format 2 “Contextual Substitution†and “Chained Contexts + Substitution†lookups. Resulting in up to 20% speedup of lookup-heavy fonts + like Gulzar or Noto Nastaliq Urdu. (Behdad Esfahbod) +- Improved ANSI output from hb-view. (Behdad Esfahbod) +- Support for shaping legacy, pre-OpenType Windows 3.1-era, Arabic fonts that + relied on a fixed PUA encoding. (Khaled Hosny, Behdad Esfahbod) +- Sinhala script is now shaped by the USE shaper instead of “indic†one. + (Behdad Esfahbod, David Corbett) +- Thai shaper improvements. (David Corbett) +- hb-ot-name API supports approximate BCP-47 language matching, for example + asking for “en_US†in a font that has only “en†names will return them. + (Behdad Esfahbod) +- Optimized TrueType glyph shape loading. (Behdad Esfahbod) +- Fix subsetting of HarfBuzz faces created via hb_face_create_for_tables(). + (Garret Rieger) +- Add 32 bit var store support to the subsetter. (Garret Rieger) + +- New API ++HB_BUFFER_FLAG_DEFINED ++HB_BUFFER_SERIALIZE_FLAG_DEFINED ++hb_font_changed() ++hb_font_get_serial() ++hb_ft_hb_font_changed() ++hb_set_hash() ++hb_map_copy() ++hb_map_hash() + + +Overview of changes leading to 4.3.0 +Friday, May 20, 2022 +==================================== +- Major speed up in loading and subsetting fonts, especially in + handling CFF table. Subsetting some fonts is now 3 times faster. + (Behdad Esfahbod, Garret Rieger) +- Speed up blending CFF2 table. (Behdad Esfahbod) +- Speed up hb_ot_tags_from_language(). (Behdad Esfahbod, David Corbett) +- Fix USE classification of U+10A38 to fix multiple marks on single Kharoshthi + base. (David Corbett) +- Fix parsing of empty CFF Index. (Behdad Esfahbod) +- Fix subsetting CPAL table with partial palette overlaps. (Garret Rieger) + +- New API ++hb_map_is_equal() (Behdad Esfahbod) + + +Overview of changes leading to 4.2.1 +Sunday, April 24, 2022 +==================================== +- Make sure hb_blob_create_from_file_or_fail() always returns nullptr in case + of failure and not empty blob sometimes. (Khaled Hosny) +- Add --passthrough-tables option to hb-subset. (Cosimo Lupo) +- Reinstate a pause after basic features in Khmer shaper, fixing a regression + introduced in previous release. (Behdad Esfahbod) +- Better handling of Regional_Indicator when shaped with RTL-native scripts, + reverting earlier fix that caused regressions in AAT shaping. (Behdad Esfahbod) + + +Overview of changes leading to 4.2.0 +Wednesday, March 30, 2022 +==================================== +- Source code reorganization, splitting large hb-ot-layout files into smaller, + per-subtable ones under OT/Layout/*. Code for more tables will follow suit in + later releases. (Garret Rieger, Behdad Esfahbod) +- Revert Indic shaper change in previous release that broke some fonts and + instead make per-syllable restriction of “GSUB†application limited to + script-specific Indic features, while applying them and discretionary + features in one go. (Behdad Esfahbod) +- Fix decoding of private in gvar table. (Behdad Esfahbod) +- Fix handling of contextual lookups that delete too many glyphs. (Behdad Esfahbod) +- Make “morx†deleted glyphs don’t block “GPOS†application. (Behdad Esfahbod) +- Various build fixes. (Chun-wei Fan, Khaled Hosny) + +- New API ++hb_set_next_many() (Andrew John) + + +Overview of changes leading to 4.1.0 +Wednesday, March 23, 2022 +==================================== +- Various OSS-Fuzz fixes. (Behdad Esfahbod) +- Make fallback vertical-origin match FreeType’s. (Behdad Esfahbod) +- Treat visible viramas like dependent vowels in USE shaper. (David Corbett) +- Apply presentation forms features and discretionary features in one go in + Indic shaper, which seems to match Uniscribe and CoreText behaviour. + (Behdad Esfahbod, David Corbett) +- Various bug fixes. + +- New API ++hb_set_add_sorted_array() (Andrew John) + + +Overview of changes leading to 4.0.1 +Friday, March 11, 2022 +==================================== +- Update OpenType to AAT mappings for “hist†and “vrtr†features. + (Florian Pircher) +- Update IANA Language Subtag Registry to 2022-03-02. (David Corbett) +- Update USE shaper to allow any non-numeric tail in a symbol cluster, and + remove obsolete data overrides. (David Corbett) +- Fix handling of baseline variations to return correctly scaled values. + (Matthias Clasen) +- A new experimental hb_subset_repack_or_fail() to repack an array of objects, + eliminating offset overflows. The API is not available unless HarfBuzz is + built with experimental APIs enabled. (Qunxin Liu) + +- New experimental API ++hb_link_t ++hb_object_t ++hb_subset_repack_or_fail() + + +Overview of changes leading to 4.0.0 +Tuesday, March 1, 2022 +==================================== +- New public API to create subset plan and gather information on things like + glyph mappings in the final subset. The plan can then be passed on to perform + the subsetting operation. (Garret Rieger) +- Draw API for extracting glyph shapes have been extended and finalized and is + no longer an experimental API. The draw API supports glyf, CFF and CFF2 + glyph outlines tables, and applies variation settings set on the font as well + as synthetic slant. The new public API is not backward compatible with the + previous, non-public, experimental API. (Behdad Esfahbod) +- The hb-view tool will use HarfBuzz draw API to render the glyphs instead of + cairo-ft when compiled with Cairo 1.17.5 or newer, setting HB_DRAW + environment variable to 1 or 0 will force using or not use the draw API, + respectively. (Behdad Esfahbod) +- The hb-shape and hb-view tools now default to using HarfBuzz’s own font + loading functions (ot) instead of FreeType ones (ft). They also have a new + option, --font-slant, to apply synthetic slant to the font. (Behdad Esfahbod) +- HarfBuzz now supports more than 65535 (the OpenType limit) glyph shapes and + metrics. See https://github.com/be-fonts/boring-expansion-spec/issues/6 and + https://github.com/be-fonts/boring-expansion-spec/issues/7 for details. + (Behdad Esfahbod) +- New API to get the dominant horizontal baseline tag for a given script. + (Behdad Esfahbod) +- New API to get the baseline positions from the font, and synthesize missing + ones. As well as new API to get font metrics and synthesize missing ones. + (Matthias Clasen) +- Improvements to finding dependencies on Windows when building with Visual + Studio. (Chun-wei Fan) +- New buffer flag, HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT, that must be set + during shaping for HB_GLYPH_FLAG_UNSAFE_TO_CONCAT flag to be reliably + produced. This is to limit the performance hit of producing this flag to when + it is actually needed. (Behdad Esfahbod) +- Documentation improvements. (Matthias Clasen) + +- New API + - General: + +HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT + +hb_var_num_t + + - Draw: + +hb_draw_funcs_t + +hb_draw_funcs_create() + +hb_draw_funcs_reference() + +hb_draw_funcs_destroy() + +hb_draw_funcs_is_immutable() + +hb_draw_funcs_make_immutable() + +hb_draw_move_to_func_t + +hb_draw_funcs_set_move_to_func() + +hb_draw_line_to_func_t + +hb_draw_funcs_set_line_to_func() + +hb_draw_quadratic_to_func_t + +hb_draw_funcs_set_quadratic_to_func() + +hb_draw_cubic_to_func_t + +hb_draw_funcs_set_cubic_to_func() + +hb_draw_close_path_func_t + +hb_draw_funcs_set_close_path_func() + +hb_draw_state_t + +HB_DRAW_STATE_DEFAULT + +hb_draw_move_to() + +hb_draw_line_to() + +hb_draw_quadratic_to() + +hb_draw_cubic_to() + +hb_draw_close_path() + +hb_font_get_glyph_shape_func_t + +hb_font_funcs_set_glyph_shape_func() + +hb_font_get_glyph_shape() + + - OpenType layout + +HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_CENTRAL + +HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_CENTRAL + +hb_ot_layout_get_horizontal_baseline_tag_for_script() + +hb_ot_layout_get_baseline_with_fallback() + + - Metrics: + +hb_ot_metrics_get_position_with_fallback() + + - Subset: + +hb_subset_plan_t + +hb_subset_plan_create_or_fail() + +hb_subset_plan_reference() + +hb_subset_plan_destroy() + +hb_subset_plan_set_user_data() + +hb_subset_plan_get_user_data() + +hb_subset_plan_execute_or_fail() + +hb_subset_plan_unicode_to_old_glyph_mapping() + +hb_subset_plan_new_to_old_glyph_mapping() + +hb_subset_plan_old_to_new_glyph_mapping() + + +Overview of changes leading to 3.4.0 +Sunday, February 13, 2022 +==================================== +- Perform sanity checks on shaping results is now part of “harfbuzz†library + and can be enabled by setting the buffer flag HB_BUFFER_FLAG_VERIFY. + (Behdad Esfahbod) +- Arabic Mark Transient Reordering Algorithm have been updated to revision 6. + (Khaled Hosny) +- ISO 15924 code for mathematical notation, ‘Zmth’, now maps to the OpenType + ‘math’ tag. (Alexis King) +- It is now possible to get at once all math kerning values for a given glyph + at a given corner. (Alexis King) +- Fix locale_t portability issues on systems the typedef’s it to a void + pointer. (Behdad Esfahbod) + +- New API: ++HB_BUFFER_FLAG_VERIFY ++HB_OT_TAG_MATH_SCRIPT ++HB_SCRIPT_MATH ++hb_ot_math_kern_entry_t ++hb_ot_math_get_glyph_kernings() + +- Deprecated API ++HB_OT_MATH_SCRIPT + + +Overview of changes leading to 3.3.2 +Sunday, February 6, 2022 +==================================== +- Revert splitting of pair positioning values introduced in 3.3.0 as it proved + problematic. (Behdad Esfahbod) + + +Overview of changes leading to 3.3.1 +Monday, January 31, 2022 +==================================== +- Fix heap-use-after-free in harfbuzz-subset introduced in previous release. + (Garret Rieger) + + +Overview of changes leading to 3.3.0 +Monday, January 31, 2022 +==================================== +- Improved documentation. (Matthias Clasen) +- Internal code cleanup, using C++ standard library more. (Behdad Esfahbod) +- The low 16-bits of face index will be used by hb_face_create() to select a + face inside a font collection file format, while the high 16-bits will be + used by hb_font_create() to load the named instance. (Behdad Esfahbod) +- Glyph positions and other font metrics now apply synthetic slant set by + hb_font_set_synthetic_slant(), for improved positioning for synthetically + slanted fonts. (Behdad Esfahbod) +- Fixed unintentional locale dependency in hb_variation_to_string() for decimal + point representation. (Matthias Clasen) +- When applying pair positioning (kerning) the positioning value is split + between the two sides of the pair for improved cursor positioning between + such pairs. (Behdad Esfahbod) +- Introduced new HB_GLYPH_FLAG_UNSAFE_TO_CONCAT, to be used in conjunction + with HB_GLYPH_FLAG_UNSAFE_TO_BREAK for optimizing re-shaping during line + breaking. Check the documentation for further details. (Behdad Esfahbod) +- Improved handling of macrolanguages when mapping BCP 47 codes to OpenType + tags. (David Corbett) + +- New API: ++HB_GLYPH_FLAG_UNSAFE_TO_CONCAT ++hb_segment_properties_overlay() ++hb_buffer_create_similar() ++hb_font_set_synthetic_slant() ++hb_font_get_synthetic_slant() ++hb_font_get_var_coords_design() + + +Overview of changes leading to 3.2.0 +Friday, November 26, 2021 +==================================== +“harfbuzz†library improvements: +- Fixed shaping of Apple Color Emoji flags in right-to-left context. (Behdad Esfahbod) +- Fixed positioning of CFF fonts in HB_TINY profile. (Behdad Esfahbod) +- OpenType 1.9 language tags update. (David Corbett) +- Add HB_NO_VERTICAL config option. +- Add HB_CONFIG_OVERRIDE_H for easier configuration. (Behdad Esfahbod) + +“harfbuzz-subset†library improvements: +- Improved packing of cmap, loca, and Ligature tables. (Garret Rieger) +- Significantly improved overflow-resolution strategy in the repacker. (Garret Rieger) + + +Overview of changes leading to 3.1.2 +Friday, November 26, 2021 +==================================== +- hb-shape / hb-view: revert treating text on the commandline as single + paragraph (was introduced in 3.0.0); add new --single-par to do that. + (Behdad Esfahbod) +- Subsetter bug fixes. (Garret Rieger, Qunxin Liu, Behdad Esfahbod) + + +Overview of changes leading to 3.1.1 +Wednesday, November 8, 2021 +==================================== +- Work around GCC cast-align error/warning on some platforms. (Behdad Esfahbod) +- Documentation improvements. (Matthias Clasen) + + +Overview of changes leading to 3.1.0 +Wednesday, November 3, 2021 +==================================== +- Better offset-overflow handling in the subsetter library. (Garret Rieger) +- Improved Unicode 14 properties in the USE shaper, and various other USE + shaper fixes. (David Corbett) +- MATH and COLR v1 tables subsetting support, and various other subsetter fixes. + (Qunxin Liu) +- Support for Pwo Karen / Ason Chin medial la. (Simon Cozens) +- Apply GPOS positioning when substituting with morx table, if kerx is missing. + (Behdad Esfahbod) +- Apply calt and clig features across syllable boundaries in Indic shaper. + (Behdad Esfahbod) +- meson option for enabling Graphite 2 has been renamed to graphite2. +- Build and documentation fixes. + +- New API: ++hb_buffer_set_not_found_glyph() ++hb_buffer_get_not_found_glyph() + + +Overview of changes leading to 3.0.0 +Friday, September 17, 2021 +==================================== +- Unicode 14.0 support (David Corbett). +- The hb-subset API and the harfbuzz-subset library's ABI are now declared + stable. The harfbuzz-subset library would not have been possible without the + work of Garret Rieger and Qunxin Liu from Google Fonts, and the earlier work + of Michiharu Ariza from Adobe. +- The hb-style API is now stable and no longer experimental. + +- New API: ++hb_style_tag_t ++hb_style_get_value() ++hb_subset_input_t ++hb_subset_flags_t ++hb_subset_sets_t ++hb_subset_input_create_or_fail() ++hb_subset_input_reference() ++hb_subset_input_destroy() ++hb_subset_input_set_user_data() ++hb_subset_input_get_user_data() ++hb_subset_input_unicode_set() ++hb_subset_input_glyph_set() ++hb_subset_input_set() ++hb_subset_input_get_flags() ++hb_subset_input_set_flags() ++hb_subset_or_fail() + +- Removed old unstable harfbuzz-subset API: +-hb_subset_input_nameid_set() +-hb_subset_input_namelangid_set() +-hb_subset_input_layout_features_set() +-hb_subset_input_no_subset_tables_set() +-hb_subset_input_drop_tables_set() +-hb_subset_input_set_drop_hints() +-hb_subset_input_get_drop_hints() +-hb_subset_input_set_desubroutinize() +-hb_subset_input_get_desubroutinize() +-hb_subset_input_set_retain_gids() +-hb_subset_input_get_retain_gids() +-hb_subset_input_set_name_legacy() +-hb_subset_input_get_name_legacy() +-hb_subset_input_set_overlaps_flag() +-hb_subset_input_get_overlaps_flag() +-hb_subset_input_set_notdef_outline() +-hb_subset_input_get_notdef_outline() +-hb_subset_input_set_no_prune_unicode_ranges() +-hb_subset_input_get_no_prune_unicode_ranges() +-hb_subset() + + +Overview of changes leading to 2.9.1 +Tuesday, September 7, 2021 +==================================== +- Final subset API is in place and if no issues are discovered, it will be the + stable subset API of HarfBuzz 3.0.0. Old API is kept to ease transition, but + will be removed in 3.0.0. +- Various fuzzer-found bug fixes. +- hb_buffer_append() now handles the pre- and post-context which previously + were left unchanged in the destination buffer. +- hb-view / hb-shape now accept following new arguments: + o --unicodes-before/after: takes a list of hex numbers that represent Unicode + codepoints. +- Undeprecated API: + hb_set_invert() + + +Overview of changes leading to 2.9.0 +Wednesday, August 18, 2021 +History Repeats Itself (Afghanistan) +==================================== +- Subsetter API is being stabilized, with the first stable API to happen in + 3.0.0 release (https://github.com/harfbuzz/harfbuzz/issues/3078). +- Support multiple variation axes with same tag, aka HOI. +- The “coretext†testing shaper now passes font variations to CoreText. +- hb-shape/hb-view does not break line at new lines unless text is read from + file. +- hb-view and hb-subset has a --batch now, similar to hb-shape. +- The --batch mode now uses ; as argument separator instead of : used previously. +- The --batch in hb-shape does not expect 0th argument anymore. That is, the + lines read are interpreted as argv[1:], instead of argv[0:]. +- The --batch option has been undocumented. We are ready to document it; send + feedback if you find it useful. +- hb-subset got arguments revamps. Added much-requested --gids-file, --glyphs, + --glyphs-file, --unicodes-file, supporting ranges in --unicodes. +- Various bug fixes. + + +Overview of changes leading to 2.8.2 +Tuesday, July 8, 2021 +==================================== +- Shaping LTR digits for RTL scripts now makes the native direction of the + digits LTR, applying shaping and positioning rules on the same glyph order as + Uniscribe. (Jonathan Kew, Khaled Hosny). +- Subsetting COLR v1 and CPAL tables is now supported. (Garret Rieger, Qunxin Liu) +- Various fixes and improvements to the subsetter. (Garret Rieger, Qunxin Liu, Behdad) +- When applying morx table, mark glyph widths should not be zeroed. (Jonathan Kew) +- GPOS is preferred over kerx, if GSUB was applied. (Behdad) +- Regional_Indicator pairs are grouped together when clustering. (Behdad) +- New API: ++hb_blob_create_or_fail() ++hb_blob_create_from_file_or_fail() ++hb_set_copy() + + +Overview of changes leading to 2.8.1 +Tuesday, May 4, 2021 +==================================== +- Subsetter now fully supports GSUB/GPOS/GDEF tables (including variations); as + such, layout tables are retained by subsetter by default. (Garret Rieger, Qunxin Liu) +- Build scripts no longer check for FontConfig as HarfBuzz does not use it. +- hb-view supports iTerm2 and kitty inline image protocols (Khaled Hosny), + it can also use Chafa for terminal graphics if available (Hans Petter Jansson). + +Overview of changes leading to 2.8.0 +Tuesday, March 16, 2021 +==================================== +- Shape joining scripts other than Arabic/Syriac using the Universal Shaping Engine. + Previously these were shaped using the generalized Arabic shaper. (David Corbett) +- Fix regression in shaping of U+0B55 ORIYA SIGN OVERLINE. (David Corbett) +- Update language tags. (David Corbett) +- Variations: reduce error: do not round each interpolated delta. (Just van Rossum) +- Documentation improvements. (Khaled Hosny, Nathan Willis) +- Subsetter improvements: subsets most, if not all, lookup types now. (Garret Rieger, Qunxin Liu) +- Fuzzer-found fixes and other improvements when memory failures happen. (Behdad) +- Removed most atomic implementations now that we have C++11 atomic impl. (Behdad) +- General codebase upkeep; using more C++11 features: constexpr constructors, etc. (Behdad) + + +Overview of changes leading to 2.7.4 +Sunday, December 27, 2020 +==================================== +- Fix missing --enable-introspection configure option from previous release + tarball. +- Documentation updates. + + +Overview of changes leading to 2.7.3 +Wednesday, December 23, 2020 +==================================== +- Update USE shaper to 2020-08-13 specification, and other improvements. +- Don’t disable liga feature in myanmar shaper, to match Uniscribe. +- Improvements to language and script tags handling. +- Update language system tag registry to OpenType 1.8.4 +- Support for serializing and deserializing Unicode buffers. Serialized buffers + are now delimited with `<>` or `[]` based on whether it is a Unicode or + glyphs buffer. +- Increase buffer work limits to handle fonts with many complex lookups. +- Handle more shaping operations in trace output. +- Memory access fixes. +- More OOM fixes. +- Improved documentation. +- Build system improvements. +- New API: ++hb_buffer_has_positions() ++hb_buffer_serialize() ++hb_buffer_serialize_unicode() ++hb_buffer_deserialize_unicode() + + +Overview of changes leading to 2.7.2 +Saturday, August 29, 2020 +==================================== +- Fix a regression in the previous release that caused a crash with Kaithi. +- More OOM fixes. + + +Overview of changes leading to 2.7.1 +Thursday, August 13, 2020 +==================================== +- ot-funcs now handles variable empty glyphs better when hvar/vvar isn't present. +- Reverted a GDEF processing regression. +- A couple of fixes to handle OOM better. + + +Overview of changes leading to 2.7.0 +Saturday, July 25, 2020 +==================================== +- Use an implementation for round that always rounds up, some minor fluctuations + are expected on var font specially when hb-ot callback is used. +- Fix an AAT's `kerx` issue on broken rendering of Devanagari Sangam MN. +- Remove AAT's `lcar` table support from _get_ligature_carets API, not even much + use on macOS installed fonts (only two files). GDEF support is the recommended + one and expected to work properly after issues fixed two releases ago. +- Minor memory fixes to handle OOM better specially in hb-ft. +- Minor .so files versioning scheme change and remove stable/unstable scheme + differences, was never used in practice (always default to stable scheme). +- We are now suggesting careful packaging of the library using meson, + https://github.com/harfbuzz/harfbuzz/wiki/Notes-on-migration-to-meson + for more information. +- Distribution package URL is changed, either use GitHub generated tarballs, + `https://github.com/harfbuzz/harfbuzz/archive/$pkgver.tar.gz` + or, even more preferably use commit hash of the release and git checkouts like, + `git+https://github.com/harfbuzz/harfbuzz#commit=$commit` + + +Overview of changes leading to 2.6.8 +Monday, June 22, 2020 +==================================== +- New API to fetch glyph alternates from GSUB table. +- hb-coretext build fix for macOS < 10.10. +- Meson build fixes, cmake port removal is postponed but please prepare for + it and give us feedback. + Autotools is still our main build system however please consider + experimenting with meson also for packaging the library. +- New API: ++hb_ot_layout_lookup_get_glyph_alternates() + + +Overview of changes leading to 2.6.7 +Wednesday, June 3, 2020 +==================================== +- Update to Unicode 13.0.0. +- Fix hb_ot_layout_get_ligature_carets for fonts without lcar table, it was + completely broken for all the other fonts since 2.1.2. +- As a part of our migration to meson, this release will be the last one + to provide cmake port files but autotools still is our main build system. + There is a possibility that the next version or the after be released + using meson. + + +Overview of changes leading to 2.6.6 +Tuesday, May 12, 2020 +==================================== +- A fix in AAT kerning for Geeza Pro. +- Better support for resource fork fonts on macOS. + + +Overview of changes leading to 2.6.5 +Friday, April 17, 2020 +==================================== +- Add experimental meson build system. Autotools is still the primary + and supported build system. +- AAT is now always preferred for horizontal scripts when both AAT and OT + layout tables exist at the same time. +- Subsetter improvements. +- New API: ++hb_ft_font_lock_face() ++hb_ft_font_unlock_face() + + +Overview of changes leading to 2.6.4 +Monday, October 29, 2019 +==================================== +- Small bug fix. +- Build fixes. + + +Overview of changes leading to 2.6.3 +Monday, October 28, 2019 +==================================== +- Misc small fixes, mostly to build-related issues. +- New API: ++hb_font_get_nominal_glyphs() + + +Overview of changes leading to 2.6.2 +Monday, September 30, 2019 +==================================== +- Misc small fixes, mostly to build-related issues. + + +Overview of changes leading to 2.6.1 +Thursday, August 22, 2019 +==================================== +- Fix regression with hb_font_create_sub_font scaling introduced in 2.6.0. +- Change interpretation of font PTEM size / CoreText font size handling. + See https://github.com/harfbuzz/harfbuzz/pull/1484 +- hb-ot-font: Prefer symbol cmap subtable if present. +- Apply 'dist'/'abvm'/'blwm' features to all scripts. +- Drop experimental DirectWrite API. + + +Overview of changes leading to 2.6.0 +Tuesday, August 13, 2019 +==================================== +- New OpenType metrics, baseline, and metadata table access APIs. +- New API to set font variations to a named-instance. +- New hb-gdi.h header and API for creating hb_face_t from HFONT. +- Amalgam: Provide a single-file harfbuzz.cc file for easier alternate building. +- More size-reduction configurable options, enabled by HB_TINY. +- New API: ++hb_font_set_var_named_instance() ++hb_gdi_face_create() ++hb_ot_layout_baseline_tag_t ++hb_ot_layout_get_baseline() ++hb_ot_meta_tag_t ++hb_ot_meta_get_entry_tags() ++hb_ot_meta_reference_entry() ++hb_ot_metrics_tag_t ++hb_ot_metrics_get_position() ++hb_ot_metrics_get_variation() ++hb_ot_metrics_get_x_variation() ++hb_ot_metrics_get_y_variation() + + +Overview of changes leading to 2.5.3 +Wednesday, June 26, 2019 +==================================== +- Fix UCD script data for Unicode 10+ scripts. This was broken since 2.5.0. +- More optimizations for HB_TINY. + + +Overview of changes leading to 2.5.2 +Thursday, June 20, 2019 +==================================== +- More hb-config.hh facilities to shrink library size, namely when built as + HB_TINY. +- New documentation of custom configurations in CONFIG.md. +- Fix build on gcc 4.8. That's supported again. +- Universal Shaping Engine improvements thanks to David Corbett. +- API Changes: Undeprecate some horizontal-kerning API and re-enable in hb-ft, + such that Type1 fonts will continue kerning. + + +Overview of changes leading to 2.5.1 +Friday, May 31, 2019 +==================================== +- Fix build with various versions of Visual Studio. +- Improved documentation, thanks to Nathan Willis. +- Bugfix in subsetting glyf table. +- Improved scripts for cross-compiling for Windows using mingw. +- Rename HB_MATH_GLYPH_PART_FLAG_EXTENDER to HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER. + A deprecated macro is added for backwards-compatibility. + + +Overview of changes leading to 2.5.0 +Friday, May 24, 2019 +==================================== +- This release does not include much functional changes, but includes major internal + code-base changes. We now require C++11. Support for gcc 4.8 and earlier has been + dropped. +- New hb-config.hh facility for compiling smaller library for embedded and web usecases. +- New Unicode Character Database implementation that is half the size of previously-used + UCDN. +- Subsetter improvements. +- Improved documentation, thanks to Nathan Willis. +- Misc shaping fixes. + + +Overview of changes leading to 2.4.0 +Monday, March 25, 2019 +==================================== +- Unicode 12. +- Misc fixes. +- Subsetter improvements. +- New API: +HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE +hb_directwrite_face_create() + + +Overview of changes leading to 2.3.1 +Wednesday, January 30, 2019 +==================================== +- AAT bug fixes. +- Misc internal housekeeping cleanup. + + +Overview of changes leading to 2.3.0 +Thursday, December 20, 2018 +==================================== +- Fix regression on big-endian architectures. Ouch! +- Misc bug and build fixes. +- Fix subsetting of simple GSUB/GDEF. +- Merge CFF / CFF2 support contributed by Adobe. This mostly involves + the subsetter, but also get_glyph_extents on CFF fonts. + +New API in hb-aat.h: ++hb_aat_layout_has_substitution() ++hb_aat_layout_has_positioning() ++hb_aat_layout_has_tracking() + + +Overview of changes leading to 2.2.0 +Thursday, November 29, 2018 +==================================== +- Misc shaping bug fixes. +- Add font variations named-instance API. +- Deprecate font variations axis enumeration API and add replacement. +- AAT shaping improvements: + o Fixed 'kern' table Format 2 implementation. + o Implement 'feat' table API for feature detection. + o Blacklist 'GSUB' table of fonts from 'MUTF' foundry that also have 'morx'. + +New API: ++hb_aat_layout_feature_type_t ++hb_aat_layout_feature_selector_t ++hb_aat_layout_get_feature_types() ++hb_aat_layout_feature_type_get_name_id ++hb_aat_layout_feature_selector_info_t ++HB_AAT_LAYOUT_NO_SELECTOR_INDEX ++hb_aat_layout_feature_type_get_selector_infos() ++hb_ot_var_axis_flags_t ++hb_ot_var_axis_info_t ++hb_ot_var_get_axis_infos() ++hb_ot_var_find_axis_info() ++hb_ot_var_get_named_instance_count() ++hb_ot_var_named_instance_get_subfamily_name_id() ++hb_ot_var_named_instance_get_postscript_name_id() ++hb_ot_var_named_instance_get_design_coords() + +Deprecated API: ++HB_OT_VAR_NO_AXIS_INDEX ++hb_ot_var_axis_t ++hb_ot_var_get_axes() ++hb_ot_var_find_axis() + + +Overview of changes leading to 2.1.3 +Friday, November 16, 2018 +==================================== +- Fix AAT 'mort' shaping, which was broken in 2.1.2 + + +Overview of changes leading to 2.1.2 +Friday, November 16, 2018 +==================================== +- Various internal changes. +- AAT shaping improvements: + o Implement kern table Format 1 state-machine-based kerning. + o Implement cross-stream kerning (cursive positioning, etc). + o Ignore emptyish GSUB tables (zero scripts) if morx present. + o Don't apply GPOS if morx is being applied. Matches Apple. + + +-Overview of changes leading to 2.1.1 +Monday, November 5, 2018 +==================================== +- AAT improvements: + o Implement 'mort' table. + o Implement 'kern' subtables Format 1 and Format 3. + + +Overview of changes leading to 2.1.0 +Tuesday, October 30, 2018 +==================================== +- AAT shaping improvements: + o Allow user controlling AAT features, for whole buffer only currently. + o Several 'morx' fixes. + o Implement tuple-kerns in 'kerx'; Fixes kerning with Apple default + San Francisco fonts. +- Support for color fonts: + o COLR/CPAL API to fetch color layers. + o SVG table to fetch SVG documents. + o CBDT/sbix API to fetch PNG images. +- New 'name' table API. +- hb-ot-font now uses 'VORG' table to correctly position CFF glyphs + in vertical layout. +- Various fuzzer-found bug fixes. + +Changed API: + +A type and a macro added in 2.0.0 were renamed: + +hb_name_id_t -> hb_ot_name_id_t +HB_NAME_ID_INVALID -> HB_OT_NAME_ID_INVALID + +New API: + ++hb_color_t ++HB_COLOR ++hb_color_get_alpha() ++hb_color_get_red() ++hb_color_get_green() ++hb_color_get_blue() ++hb_ot_color_has_palettes() ++hb_ot_color_palette_get_count() ++hb_ot_color_palette_get_name_id() ++hb_ot_color_palette_color_get_name_id() ++hb_ot_color_palette_flags_t ++hb_ot_color_palette_get_flags() ++hb_ot_color_palette_get_colors() ++hb_ot_color_has_layers() ++hb_ot_color_layer_t ++hb_ot_color_glyph_get_layers() ++hb_ot_color_has_svg() ++hb_ot_color_glyph_reference_svg() ++hb_ot_color_has_png() ++hb_ot_color_glyph_reference_png() + ++hb_ot_name_id_t ++HB_OT_NAME_ID_INVALID ++HB_OT_NAME_ID_COPYRIGHT ++HB_OT_NAME_ID_FONT_FAMILY ++HB_OT_NAME_ID_FONT_SUBFAMILY ++HB_OT_NAME_ID_UNIQUE_ID ++HB_OT_NAME_ID_FULL_NAME ++HB_OT_NAME_ID_VERSION_STRING ++HB_OT_NAME_ID_POSTSCRIPT_NAME ++HB_OT_NAME_ID_TRADEMARK ++HB_OT_NAME_ID_MANUFACTURER ++HB_OT_NAME_ID_DESIGNER ++HB_OT_NAME_ID_DESCRIPTION ++HB_OT_NAME_ID_VENDOR_URL ++HB_OT_NAME_ID_DESIGNER_URL ++HB_OT_NAME_ID_LICENSE ++HB_OT_NAME_ID_LICENSE_URL ++HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY ++HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY ++HB_OT_NAME_ID_MAC_FULL_NAME ++HB_OT_NAME_ID_SAMPLE_TEXT ++HB_OT_NAME_ID_CID_FINDFONT_NAME ++HB_OT_NAME_ID_WWS_FAMILY ++HB_OT_NAME_ID_WWS_SUBFAMILY ++HB_OT_NAME_ID_LIGHT_BACKGROUND ++HB_OT_NAME_ID_DARK_BACKGROUND ++HB_OT_NAME_ID_VARIATIONS_PS_PREFIX ++hb_ot_name_entry_t ++hb_ot_name_list_names() ++hb_ot_name_get_utf8() ++hb_ot_name_get_utf16() ++hb_ot_name_get_utf32() + + +Overview of changes leading to 2.0.2 +Saturday, October 20, 2018 +==================================== +- Fix two minor memory access issues in AAT tables. + + +Overview of changes leading to 2.0.1 +Friday, October 19, 2018 +==================================== +- Fix hb-version.h reported release version that went wrong (1.8.0) + with previous release. +- Fix extrapolation in 'trak' table. +- Fix hb-font infinite-recursion issue with some font funcs and + subclassed fonts. +- Implement variation-kerning format in kerx table, although without + variation. +- Fix return value of hb_map_is_empty(). + + +Overview of changes leading to 2.0.0 +Thursday, October 18, 2018 +==================================== +- Added AAT shaping support (morx/kerx/trak). + Automatically used if GSUB/GPOS are not available respectively. + Set HB_OPTIONS=aat env var to have morx/kerx preferred over + GSUB/GPOS. +- Apply TrueType kern table internally, instead of relying on + hb_font_t callbacks. +- Khmer shaper significantly rewritten to better match Uniscribe. +- Indic3 tags ('dev3', etc) are passed to USE shaper. +- .dfont Mac font containers implemented. +- Script- and language-mapping revamped to better use BCP 47. +- Misc USE and Indic fixes. +- Misc everything fixes. +- Too many things to list. Biggest release since 0.9.1, with + over 500 commits in just over 5 weeks! Didn't intend it to + be a big release. Just happened to become. +- hb-ft now locks underlying FT_Face during use. + +API changes: + +- Newly-created hb_font_t's now have our internal "hb-ot-font" + callbacks set on them, so they should work out of the box + without any callbacks set. If callbacks are set, everything + is back to what it was before, the fallback callbacks are + null. If you to get the internal implementation modified, + sub_font it. + +- New hb_font_funcs_set_nominal_glyphs_func() allows speeding + up character to glyph mapping. + +New API: ++HB_FEATURE_GLOBAL_START ++HB_FEATURE_GLOBAL_END ++hb_buffer_set_invisible_glyph() ++hb_buffer_get_invisible_glyph() ++hb_font_funcs_set_nominal_glyphs_func() ++hb_ot_layout_table_select_script() ++hb_ot_layout_script_select_language() ++hb_ot_layout_feature_get_name_ids() ++hb_ot_layout_feature_get_characters() ++hb_name_id_t ++HB_NAME_ID_INVALID ++HB_OT_MAX_TAGS_PER_SCRIPT ++hb_ot_tags_from_script_and_language() ++hb_ot_tags_to_script_and_language() + +Deprecated API: +-hb_font_funcs_set_glyph_func() +-hb_unicode_eastasian_width_func_t +-hb_unicode_funcs_set_eastasian_width_func() +-hb_unicode_eastasian_width() +-hb_unicode_decompose_compatibility_func_t +-HB_UNICODE_MAX_DECOMPOSITION_LEN +-hb_unicode_funcs_set_decompose_compatibility_func() +-hb_unicode_decompose_compatibility() +-hb_font_funcs_set_glyph_h_kerning_func() +-hb_font_funcs_set_glyph_v_kerning_func() +-hb_font_get_glyph_h_kerning() +-hb_font_get_glyph_v_kerning() +-hb_font_get_glyph_kerning_for_direction() +-hb_ot_layout_table_choose_script() +-hb_ot_layout_script_find_language() +-hb_ot_tags_from_script() +-hb_ot_tag_from_language() + + +Overview of changes leading to 1.9.0 +Monday, September 10, 2018 +==================================== +- Added 'cmap' API to hb_face_t. +- Face-builder API. +- hb-ot-font re-creation should be much leaner now, as the + font tables it uses are cached on hb_face_t now. +- Internal source header file name changes: + hb-*-private.hh is renamed to hb-*.hh. + +New API: ++HB_UNICODE_MAX ++hb_face_collect_unicodes() ++hb_face_collect_variation_selectors() ++hb_face_collect_variation_unicodes() ++hb_face_builder_create() ++hb_face_builder_add_table() + + +Overview of changes leading to 1.8.8 +Tuesday, August 14, 2018 +==================================== +- Fix hb-icu crash on architectures where compare_exchange_weak() can + fail falsely. This bug was introduced in 1.8.4. + https://bugs.chromium.org/p/chromium/issues/detail?id=873568 +- More internal refactoring of atomic operations and singletons. +- API changes: + The following functions do NOT reference their return value before + returning: + * hb_unicode_funcs_get_default() + * hb_glib_get_unicode_funcs() + * hb_icu_get_unicode_funcs() + This is consistent with their naming ("get", instead of "reference") + as well as how they are used in the wild (ie. no one calls destroy() + on their return value.) + + +Overview of changes leading to 1.8.7 +Wednesday, August 8, 2018 +==================================== +- Fix assertion failure with GDEF-blacklisted fonts. + + +Overview of changes leading to 1.8.6 +Tuesday, August 7, 2018 +==================================== +- Internal code shuffling. +- New API to speed up getting advance widths for implementations + that have heavy overhead in get_h_advance callback: ++hb_font_funcs_set_glyph_h_advances_func ++hb_font_funcs_set_glyph_v_advances_func ++hb_font_get_glyph_advances_for_direction ++hb_font_get_glyph_h_advances ++hb_font_get_glyph_h_advances_func_t ++hb_font_get_glyph_v_advances ++hb_font_get_glyph_v_advances_func_t + + +Overview of changes leading to 1.8.5 +Wednesday, August 1, 2018 +==================================== +- Major Khmer shaper improvements to better match Microsoft. +- Indic bug fixes. +- Internal improvements to atomic operations. + + +Overview of changes leading to 1.8.4 +Tuesday, July 17, 2018 +==================================== +- Fix build on non-C++11. +- Use C++-style GCC atomics and C++11 atomics. + + +Overview of changes leading to 1.8.3 +Wednesday, July 11, 2018 +==================================== +- A couple of Indic / USE bug fixes. +- Disable vectorization, as it was causing unaligned access bus error on + certain 32bit architectures. + + +Overview of changes leading to 1.8.2 +Tuesday, July 3, 2018 +==================================== +- Fix infinite loop in Khmer shaper. +- Improve hb_blob_create_from_file() for streams. + + +Overview of changes leading to 1.8.1 +Tuesday, June 12, 2018 +==================================== +- Fix hb-version.h file generation; last two releases went out with wrong ones. +- Add correctness bug in hb_set_t operations, introduced in 1.7.7. +- Remove HB_SUBSET_BUILTIN build option. Not necessary. + + +Overview of changes leading to 1.8.0 +Tuesday, June 5, 2018 +==================================== +- Update to Unicode 11.0.0. + + +Overview of changes leading to 1.7.7 +Tuesday, June 5, 2018 +==================================== +- Lots of internal changes, but not yet exposed externally. +- All HarfBuzz objects are significantly smaller in size now. +- Sinhala: Position repha on top of post-consonant, not base. + This better matches Windows 10 behavior, which was changed + from previous Windows versions. +- New build options: + o New cpp macro HB_NO_ATEXIT + o New cpp macro HB_SUBSET_BUILTIN +- Significant libharfbuzz-subset changes. API subject to change. +- New API in libharfbuzz: + ++hb_blob_create_from_file() ++hb_face_count() + +A hashmap implementation: ++hb-map.h ++HB_MAP_VALUE_INVALID ++hb_map_t ++hb_map_create() ++hb_map_get_empty() ++hb_map_reference() ++hb_map_destroy() ++hb_map_set_user_data() ++hb_map_get_user_data() ++hb_map_allocation_successful() ++hb_map_clear() ++hb_map_is_empty() ++hb_map_get_population() ++hb_map_set() ++hb_map_get() ++hb_map_del() ++hb_map_has() + + +Overview of changes leading to 1.7.6 +Wednesday, March 7, 2018 +==================================== + +- Fix to hb_set_t binary operations. Ouch. +- New experimental harfbuzz-subset library. All of hb-subset.h + is experimental right now and API WILL change. + +- New API: +hb_blob_copy_writable_or_fail() +HB_OT_TAG_BASE +hb_set_previous() +hb_set_previous_range() + + +Overview of changes leading to 1.7.5 +Tuesday, January 30, 2018 +==================================== + +- Separate Khmer shaper from Indic. +- First stab at AAT morx. Not hooked up. +- Misc bug fixes. + + +Overview of changes leading to 1.7.4 +Wednesday, December 20, 2017 +==================================== + +- Fix collect_glyphs() regression caused by hb_set_t changes. + + +Overview of changes leading to 1.7.3 +Monday, December 18, 2017 +==================================== + +- hb_set_t performance tuning and optimizations. +- Speed up collect_glyphs() and reject garbage data. +- In hb_coretext_font_create() set font point-size (ptem). +- Misc fixes. + + +Overview of changes leading to 1.7.2 +Monday, December 4, 2017 +==================================== + +- Optimize hb_set_add_range(). +- Misc fixes. +- New API: +hb_coretext_font_create() + + +Overview of changes leading to 1.7.1 +Tuesday, November 14, 2017 +==================================== + +- Fix atexit object destruction regression. +- Fix minor integer-overflow. + + +Overview of changes leading to 1.7.0 +Monday, November 13, 2017 +==================================== + +- Minor Indic fixes. +- Implement kerning and glyph names in hb-ot-font. +- Various DSO optimization re .data and .bss sizes. +- Make C++11 optional; build fixes. +- Mark all other backends "unsafe-to-break". +- Graphite fix. + + +Overview of changes leading to 1.6.3 +Thursday, October 26th, 2017 +==================================== + +- Fix hb_set_t some more. Should be solid now. +- Implement get_glyph_name() for hb-ot-font. +- Misc fixes. + + +Overview of changes leading to 1.6.2 +Monday, October 23nd, 2017 +==================================== + +- Yesterday's release had a bad crasher; don't use it. That's what + happens when one works on Sunday... + https://github.com/harfbuzz/harfbuzz/issues/578 +- Build fixes for FreeBSD and Chrome Android. + + +Overview of changes leading to 1.6.1 +Sunday, October 22nd, 2017 +==================================== + +- Don't skip over COMBINING GRAPHEME JOINER when ligating, etc. + To be refined: https://github.com/harfbuzz/harfbuzz/issues/554 +- Faster hb_set_t implementation. +- Don't use deprecated ICU API. +- Fix undefined-behavior in Myanmar shaper, introduced in 1.6.0 +- Deprecated API: + hb_set_invert() + + +Overview of changes leading to 1.6.0 +Friday, October the 13th, 2017 +==================================== + +- Update to Unicode 10. + +- Various Indic and Universal Shaping Engine fixes as a result of + HarfBuzz Hackfest with Jonathan Kew at Web Engines Hackfest at + the Igalia offices in A Coruña, Spain. Thanks Igalia for having + us! + +- Implement Unicode Arabic Mark Ordering Algorithm UTR#53. + +- Implement optical sizing / tracking in CoreText backend, using + new API hb_font_set_ptem(). + +- Allow notifying hb_font_t that underlying FT_Face changed sizing, + using new API hb_ft_font_changed(). + +- More Graphite backend RTL fixes. + +- Fix caching of variable font shaping plans. + +- hb-view / hb-shape now accept following new arguments: + + o --unicodes: takes a list of hex numbers that represent Unicode + codepoints. + +New API: ++hb_face_get_table_tags() ++hb_font_set_ptem() ++hb_font_get_ptem() ++hb_ft_font_changed() + + +Overview of changes leading to 1.5.1 +Tuesday, September 5, 2017 +==================================== + +- Fix "unsafe-to-break" in fallback shaping and other corner cases. + All our tests pass with --verify now, meaning unsafe-to-break API + works as expected. +- Add --unicodes to hb-view / hb-shape. +- [indic] Treat Consonant_With_Stacker as consonant. This will need + further tweaking. +- hb_buffer_diff() tweaks. + + +Overview of changes leading to 1.5.0 +Wednesday, August 23, 2017 +==================================== + +- Misc new API, for appending a buffer to another, and for comparing + contents of two buffers for types of differences. + +- New "unsafe-to-break" API. Can be used to speed up reshaping + in line-breaking situations. Essentially, after shaping, it returns + positions in the input string (some of the cluster boundaries) that + are "safe to break" in that if the text is segmented at that position + and two sides reshaped and concatenated, the shaping result is + exactly the same as shaping the text in one piece. + + hb-view and hb-shape and hb-shape now take --verify, which verifies + the above property. + + Some corner cases of the implementation are still not quite working. + Those will be fixed in subsequent releases. + +- New API: + +hb_buffer_append() + +hb_glyph_flags_t +HB_GLYPH_FLAG_UNSAFE_TO_BREAK +HB_GLYPH_FLAG_DEFINED +hb_glyph_info_get_glyph_flags() + +HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS + +hb_buffer_diff_flags_t +HB_BUFFER_DIFF_FLAG_EQUAL +HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH +HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH +HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT +HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT +HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH +HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH +HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH +HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH +hb_buffer_diff + + +Overview of changes leading to 1.4.8 +Tuesday, August 8, 2017 +==================================== + +- Major fix to avar table handling. +- Rename hb-shape --show-message to --trace. +- Build fixes. + + +Overview of changes leading to 1.4.7 +Tuesday, July 18, 2017 +==================================== + +- Multiple Indic, Tibetan, and Cham fixes. +- CoreText: Allow disabling kerning. +- Adjust Arabic feature order again. +- Misc build fixes. + + +Overview of changes leading to 1.4.6 +Sunday, April 23, 2017 +==================================== + +- Graphite2: Fix RTL positioning issue. +- Backlist GDEF of more versions of Padauk and Tahoma. +- New, experimental, cmake alternative build system. + + +Overview of changes leading to 1.4.5 +Friday, March 10, 2017 +==================================== + +- Revert "Fix Context lookup application when moving back after a glyph..." + This introduced memory access problems. To be fixed properly soon. + + +Overview of changes leading to 1.4.4 +Sunday, March 5, 2017 +==================================== + +- Fix Context lookup application when moving back after a glyph deletion. +- Fix buffer-overrun in Bengali. + + +Overview of changes leading to 1.4.3 +Saturday, February 25, 2017 +==================================== + +- Route Adlam script to Arabic shaper. +- Misc fixes. +- New API: + hb_font_set_face() +- Deprecate API: + hb_graphite2_font_get_gr_font() + + +Overview of changes leading to 1.4.2 +Monday, January 23, 2017 +==================================== + +- Implement OpenType Font Variation tables avar/fvar/HVAR/VVAR. +- hb-shape and hb-view now accept --variations. +- New API: + +hb_variation_t +hb_variation_from_string() +hb_variation_to_string() + +hb_font_set_variations() +hb_font_set_var_coords_design() +hb_font_get_var_coords_normalized() + +hb-ot-var.h: +hb_ot_var_axis_t +hb_ot_var_has_data() +hb_ot_var_get_axis_count() +hb_ot_var_get_axes() +hb_ot_var_find_axis() +hb_ot_var_normalize_variations() +hb_ot_var_normalize_coords() + +- MVAR to be implemented later. Access to named instances to be + implemented later as well. + +- Misc fixes. + + +Overview of changes leading to 1.4.1 +Thursday, January 5, 2017 +==================================== + +- Always build and use UCDN for Unicode data by default. + Reduces dependence on version of Unicode data in glib, + specially in the Windows bundles we are shipping, which + have very old glib. + + +Overview of changes leading to 1.4.0 +Thursday, January 5, 2017 +==================================== + +- Merged "OpenType GX" branch which adds core of support for + OpenType 1.8 Font Variations. To that extent, the relevant + new API is: + +New API: +hb_font_set_var_coords_normalized() + + with supporting API: + +New API: +HB_OT_LAYOUT_NO_VARIATIONS_INDEX +hb_ot_layout_table_find_feature_variations() +hb_ot_layout_feature_with_variations_get_lookups() +hb_shape_plan_create2() +hb_shape_plan_create_cached2() + + Currently variations in GSUB/GPOS/GDEF are fully supported, + and no other tables are supported. In particular, fvar/avar + are NOT supported, hence the hb_font_set_var_coords_normalized() + taking normalized coordinates. API to take design coordinates + will be added in the future. + + HVAR/VVAR/MVAR support will also be added to hb-ot-font in the + future. + +- Fix regression in GDEF glyph class processing. +- Add decompositions for Chakma, Limbu, and Balinese in USE shaper. +- Misc fixes. + + +Overview of changes leading to 1.3.4 +Monday, December 5, 2016 +==================================== + +- Fix vertical glyph origin in hb-ot-font. +- Implement CBDT/CBLC color font glyph extents in hb-ot-font. + + +Overview of changes leading to 1.3.3 +Wednesday, September 28, 2016 +==================================== + +- Implement parsing of OpenType MATH table. +New API: +HB_OT_TAG_MATH +HB_OT_MATH_SCRIPT +hb_ot_math_constant_t +hb_ot_math_kern_t +hb_ot_math_glyph_variant_t +hb_ot_math_glyph_part_flags_t +hb_ot_math_glyph_part_t +hb_ot_math_has_data +hb_ot_math_get_constant +hb_ot_math_get_glyph_italics_correction +hb_ot_math_get_glyph_top_accent_attachment +hb_ot_math_get_glyph_kerning +hb_ot_math_is_glyph_extended_shape +hb_ot_math_get_glyph_variants +hb_ot_math_get_min_connector_overlap +hb_ot_math_get_glyph_assembly + + +Overview of changes leading to 1.3.2 +Wednesday, September 27, 2016 +==================================== + +- Fix build of hb-coretext on older OS X versions. + + +Overview of changes leading to 1.3.1 +Wednesday, September 7, 2016 +==================================== + +- Blacklist bad GDEF of more fonts (Padauk). +- More CoreText backend crash fixes with OS X 10.9.5. +- Misc fixes. + + +Overview of changes leading to 1.3.0 +Thursday, July 21, 2016 +==================================== + +- Update to Unicode 9.0.0 +- Move Javanese from Indic shaper to Universal Shaping Engine. +- Allow MultipleSubst to delete a glyph (matching Windows engine). +- Update Universal Shaping Engine to latest draft from Microsoft. +- DirectWrite backend improvements. Note: this backend is for testing ONLY. +- CoreText backend improvements with unreachable fonts. +- Implement symbol fonts (cmap 3.0.0) in hb-ft and hb-ot-font. +- Blacklist bad GDEF of more fonts (Tahoma & others). +- Misc fixes. + + +Overview of changes leading to 1.2.7 +Monday, May 2, 2016 +==================================== + +- Blacklist another version of Times New Roman (Bold) Italic from Windows 7. +- Fix Mongolian Free Variation Selectors shaping with certain fonts. +- Fix Tibetan shorthand contractions shaping. +- Improved list of language tag mappings. +- Unbreak build on Windows CE. +- Make 'glyf' table loading lazy in hb-ot-font. + + +Overview of changes leading to 1.2.6 +Friday, April 8, 2016 +==================================== + +- Blacklist GDEF table of another set of Times New Roman (Bold) Italic. +- DirectWrite backend improvements. Note: DirectWrite backend is + exclusively for our internal testing and should NOT be used in any + production system whatsoever. + + +Overview of changes leading to 1.2.5 +Monday, April 4, 2016 +==================================== + +- Fix GDEF mark-filtering-set, which was broken in 1.2.3. + + +Overview of changes leading to 1.2.4 +Thursday, March 17, 2016 +==================================== + +- Synthesize GDEF glyph class for any glyph that does not have one in GDEF. + I really hope we don't discover broken fonts that shape badly with this + change. +- Misc build and other minor fixes. +- API changes: + - Added HB_NDEBUG. It's fine for production systems to define this to + disable high-overhead debugging checks. However, I also reduced the + overhead of those checks, so it's a non-issue right now. You can + forget it. Just not defining anything at all is fine. + + +Overview of changes leading to 1.2.3 +Thursday, February 25, 2016 +==================================== + +- Blacklist GDEF table of certain versions of Times New Roman (Bold) Italic, + due to bug in glyph class of ASCII double-quote character. This should + address "regression" introduced in 1.2.0 when we switched mark zeroing + in most shapers from BY_UNICODE_LATE to BY_GDEF_LATE. + This fourth release in a week should finally stabilize things... + +- hb-ot-font's get_glyph() implementation saw some optimizations. Though, + might be really hard to measure in real-world situations. + +- Also, two rather small API changes: + +We now disable some time-consuming internal bookkeeping if built with NDEBUG +defined. This is a first time that we use NDEBUG to disable debug code. If +there exist production systems that do NOT want to enable NDEBUG, please let +me know and I'll add HB_NDEBUG. + +Added get_nominal_glyph() and get_variation_glyph() instead of get_glyph() + +New API: +- hb_font_get_nominal_glyph_func_t +- hb_font_get_variation_glyph_func_t +- hb_font_funcs_set_nominal_glyph_func() +- hb_font_funcs_set_variation_glyph_func() +- hb_font_get_nominal_glyph() +- hb_font_get_variation_glyph() + +Deprecated API: +- hb_font_get_glyph_func_t +- hb_font_funcs_set_glyph_func() + +Clients that implement their own font-funcs are encouraged to replace +their get_glyph() implementation with a get_nominal_glyph() and +get_variation_glyph() pair. The variation version can assume that +variation_selector argument is not zero. Old (deprecated) functions +will continue working indefinitely using internal gymnastics; it is +just more efficient to use the new functions. + + +Overview of changes leading to 1.2.2 +Wednesday, February 24, 2016 +==================================== + +- Fix regression with mark positioning with fonts that have + non-zero mark advances. This was introduced in 1.2.0 while + trying to make mark and cursive attachments to work together. + I have partially reverted that, so this version is much more + like what we had before. All clients who updated to 1.2.0 + should update to this version. + + +Overview of changes leading to 1.2.1 +Tuesday, February 23, 2016 +==================================== + +- CoreText: Fix bug with wrong scale if font scale was changed later. + https://github.com/libass/libass/issues/212 +- CoreText: Drastically speed up font initialization. +- CoreText: Fix tiny leak. +- Group ZWJ/ZWNJ with previous syllable under cluster-level=0. + https://github.com/harfbuzz/harfbuzz/issues/217 +- Add test/shaping/README.md about how to add tests to the suite. + + +Overview of changes leading to 1.2.0 +Friday, February 19, 2016 +==================================== + +- Fix various issues (hangs mostly) in case of memory allocation failure. +- Change mark zeroing types of most shapers from BY_UNICODE_LATE to + BY_GDEF_LATE. This seems to be what Uniscribe does. +- Change mark zeroing of USE shaper from NONE to BY_GDEF_EARLY. That's + what Windows does. +- Allow GPOS cursive connection on marks, and fix the interaction with + mark attachment. This work resulted in some changes to how mark + attachments work. See: + https://github.com/harfbuzz/harfbuzz/issues/211 + https://github.com/harfbuzz/harfbuzz/commit/86c68c7a2c971efe8e35b1f1bd99401dc8b688d2 +- Graphite2 shaper: improved negative advance handling (eg. Nastaliq). +- Add nmake-based build system for Windows. +- Minor speedup. +- Misc. improvements. + + +Overview of changes leading to 1.1.3 +Monday, January 11, 2016 +==================================== + +- Ported Indic shaper to Unicode 8.0 data. +- Universal Shaping Engine fixes. +- Speed up CoreText shaper when font fallback happens in CoreText. +- Documentation improvements, thanks to Khaled Hosny. +- Very rough directwrite shaper for testing, thanks to Ebrahim Byagowi. +- Misc bug fixes. +- New API: + + * Font extents: + hb_font_extents_t + hb_font_get_font_extents_func_t + hb_font_get_font_h_extents_func_t + hb_font_get_font_v_extents_func_t + hb_font_funcs_set_font_h_extents_func + hb_font_funcs_set_font_v_extents_func + hb_font_get_h_extents + hb_font_get_v_extents + hb_font_get_extents_for_direction + + * Buffer message (aka debug): + hb_buffer_message_func_t + hb_buffer_set_message_func() + Actual message protocol to be fleshed out later. + + +Overview of changes leading to 1.1.2 +Wednesday, November 26, 2015 +==================================== + +- Fix badly-broken fallback shaper that affected terminology. + https://github.com/harfbuzz/harfbuzz/issues/187 +- Fix y_scaling in Graphite shaper. +- API changes: + * An unset glyph_h_origin() function in font-funcs now (sensibly) + implies horizontal origin at 0,0. Ie, the nil callback returns + true instead of false. As such, implementations that have a + glyph_h_origin() that simply returns true, can remove that function + with HarfBuzz >= 1.1.2. This results in a tiny speedup. + + +Overview of changes leading to 1.1.1 +Wednesday, November 24, 2015 +==================================== + +- Build fixes, specially for hb-coretext. + + +Overview of changes leading to 1.1.0 +Wednesday, November 18, 2015 +==================================== + +- Implement 'stch' stretch feature for Syriac Abbreviation Mark. + https://github.com/harfbuzz/harfbuzz/issues/141 +- Disable use of decompose_compatibility() callback. +- Implement "shaping" of various Unicode space characters, even + if the font does not support them. + https://github.com/harfbuzz/harfbuzz/issues/153 +- If font does not support U+2011 NO-BREAK HYPHEN, fallback to + U+2010 HYPHEN. +- Changes resulting from libFuzzer continuous fuzzing: + * Reject font tables that need more than 8 edits, + * Bound buffer growth during shaping to 32x, + * Fix assertions and other issues at OOM / buffer max-growth. +- Misc fixes and optimizations. +- API changes: + * All fonts created with hb_font_create() now inherit from + (ie. have parent) hb_font_get_empty(). + + +Overview of changes leading to 1.0.6 +Thursday, October 15, 2015 +==================================== + +- Reduce max nesting level in OT lookups from 8 to 6. + Should not affect any real font as far as I know. +- Fix memory access issue in ot-font. +- Revert default load-flags of fonts created using hb_ft_font_create() + back to FT_LOAD_DEFAULT|FT_LOAD_NO_HINTING. This was changed in + last release (1.0.5), but caused major issues, so revert. + https://github.com/harfbuzz/harfbuzz/issues/143 + + +Overview of changes leading to 1.0.5 +Tuesday, October 13, 2015 +==================================== + +- Fix multiple memory access bugs discovered using libFuzzer. + https://github.com/harfbuzz/harfbuzz/issues/139 + Everyone should upgrade to this version as soon as possible. + We now have continuous fuzzing set up, to avoid issues like + these creeping in again. +- Misc fixes. + +- New API: + * hb_font_set_parent(). + * hb_ft_font_[sg]et_load_flags() + The default flags for fonts created using hb_ft_font_create() + has changed to default to FT_LOAD_DEFAULT now. Previously it + was defaulting to FT_LOAD_DFEAULT|FT_LOAD_NO_HINTING. + +- API changes: + * Fonts now default to units-per-EM as their scale, instead of 0. + * hb_font_create_sub_font() does NOT make parent font immutable + anymore. hb_font_make_immutable() does. + + +Overview of changes leading to 1.0.4 +Wednesday, September 30, 2015 +==================================== + +- Fix minor out-of-bounds read error. + + +Overview of changes leading to 1.0.3 +Tuesday, September 1, 2015 +==================================== + +- Start of user documentation, from Simon Cozens! +- Implement glyph_extents() for TrueType fonts in hb-ot-font. +- Improve GPOS cursive attachments with conflicting lookups. +- More fixes for cluster-level = 1. +- Uniscribe positioning fix. + + +Overview of changes leading to 1.0.2 +Wednesday, August 19, 2015 +==================================== + +- Fix shaping with cluster-level > 0. +- Fix Uniscribe backend font-size scaling. +- Declare dependencies in harfbuzz.pc. + FreeType is not declared though, to avoid bugs in pkg-config + 0.26 with recursive dependencies. +- Slightly improved debug infrastructure. More to come later. +- Misc build fixes. + + +Overview of changes leading to 1.0.1 +Monday, July 27, 2015 +==================================== + +- Fix out-of-bounds access in USE shaper. + + +Overview of changes leading to 1.0.0 +Sunday, July 26, 2015 +==================================== + +- Implement Universal Shaping Engine: + https://www.microsoft.com/typography/OpenTypeDev/USE/intro.htm + http://blogs.windows.com/bloggingwindows/2015/02/23/windows-shapes-the-worlds-languages/ +- Bump version to 1.0.0. The soname was NOT bumped. + + +Overview of changes leading to 0.9.42 +Thursday, July 26, 2015 +===================================== + +- New API to allow for retrieving finer-grained cluster + mappings if the client desires to handle them. Default + behavior is unchanged. +- Fix cluster merging when removing default-ignorables. +- Update to Unicode 8.0 +- hb-graphite2 fixes. +- Misc fixes. +- Removed HB_NO_MERGE_CLUSTERS hack. +- New API: + hb_buffer_cluster_level_t enum + hb_buffer_get_cluster_level() + hb_buffer_set_cluster_level() + hb-shape / hb-view --cluster-level + + +Overview of changes leading to 0.9.41 +Thursday, June 18, 2015 +===================================== + +- Fix hb-coretext with trailing whitespace in right-to-left. +- New API: hb_buffer_reverse_range(). +- Allow implementing atomic ops in config.h. +- Fix hb_language_t in language bindings. +- Misc fixes. + + +Overview of changes leading to 0.9.40 +Friday, March 20, 2015 +===================================== + +- Another hb-coretext crasher fix. Ouch! +- Happy Norouz! + + +Overview of changes leading to 0.9.39 +Wednesday, March 4, 2015 +===================================== + +- Critical hb-coretext fixes. +- Optimizations and refactoring; no functional change + expected. +- Misc build fixes. + + +Overview of changes leading to 0.9.38 +Friday, January 23, 2015 +===================================== + +- Fix minor out-of-bounds access in Indic shaper. +- Change New Tai Lue shaping engine from South-East Asian to default, + reflecting change in Unicode encoding model. +- Add hb-shape --font-size. Can take up to two numbers for separate + x / y size. +- Fix CoreText and FreeType scale issues with negative scales. +- Reject blobs larger than 2GB. This might break some icu-le-hb clients + that need security fixes. See: + http://www.icu-project.org/trac/ticket/11450 +- Avoid accessing font tables during face destruction, in casce rogue + clients released face data already. +- Fix up gobject-introspection a bit. Python bindings kinda working. + See README.python. +- Misc fixes. +- API additions: + hb_ft_face_create_referenced() + hb_ft_font_create_referenced() + + +Overview of changes leading to 0.9.37 +Wednesday, December 17, 2014 +===================================== + +- Fix out-of-bounds access in Context lookup format 3. +- Indic: Allow ZWJ/ZWNJ before syllable modifiers. + + +Overview of changes leading to 0.9.36 +Thursday, November 20, 2014 +===================================== + +- First time that three months went by without a release since + 0.9.2 was released on August 10, 2012! +- Fix performance bug in hb_ot_collect_glyphs(): + https://bugzilla.mozilla.org/show_bug.cgi?id=1090869 +- Add basic vertical-text support to hb-ot-font. +- Misc build fixes. + + +Overview of changes leading to 0.9.35 +Saturday, August 13, 2014 +===================================== + +- Fix major shape-plan caching bug when more than one shaper were + provided to hb_shape_full() (as exercised by XeTeX). + http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1246370.html +- Fix Arabic fallback shaping regression. This was broken in 0.9.32. +- Major hb-coretext fixes. That backend is complete now, including + respecing buffer direction and language, down to vertical writing. +- Build fixes for Windows CE. Should build fine now. +- Misc fixes: + Use atexit() only if it's safe to call from shared library + https://bugs.freedesktop.org/show_bug.cgi?id=82246 + Mandaic had errors in its Unicode Joining_Type + https://bugs.freedesktop.org/show_bug.cgi?id=82306 +- API changes: + + * hb_buffer_clear_contents() does not reset buffer flags now. + + After 763e5466c0a03a7c27020e1e2598e488612529a7, one doesn't + need to set flags for different pieces of text. The flags now + are something the client sets up once, depending on how it + actually uses the buffer. As such, don't clear it in + clear_contents(). + + I don't expect any changes to be needed to any existing client. + + +Overview of changes leading to 0.9.34 +Saturday, August 2, 2014 +===================================== + +- hb_feature_from_string() now accepts CSS font-feature-settings format. +- As a result, hb-shape / hb-view --features also accept CSS-style strings. + Eg, "'liga' off" is accepted now. +- Add old-spec Myanmar shaper: + https://bugs.freedesktop.org/show_bug.cgi?id=81775 +- Don't apply 'calt' in Hangul shaper. +- Fix mark advance zeroing for Hebrew shaper: + https://bugs.freedesktop.org/show_bug.cgi?id=76767 +- Implement Windows-1256 custom Arabic shaping. Only built on Windows, + and requires help from get_glyph(). Used by Firefox. + https://bugzilla.mozilla.org/show_bug.cgi?id=1045139 +- Disable 'liga' in vertical text. +- Build fixes. +- API changes: + + * Make HB_BUFFER_FLAG_BOT/EOT easier to use. + + Previously, we expected users to provide BOT/EOT flags when the + text *segment* was at paragraph boundaries. This meant that for + clients that provide full paragraph to HarfBuzz (eg. Pango), they + had code like this: + + hb_buffer_set_flags (hb_buffer, + (item_offset == 0 ? HB_BUFFER_FLAG_BOT : 0) | + (item_offset + item_length == paragraph_length ? + HB_BUFFER_FLAG_EOT : 0)); + + hb_buffer_add_utf8 (hb_buffer, + paragraph_text, paragraph_length, + item_offset, item_length); + + After this change such clients can simply say: + + hb_buffer_set_flags (hb_buffer, + HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT); + + hb_buffer_add_utf8 (hb_buffer, + paragraph_text, paragraph_length, + item_offset, item_length); + + Ie, HarfBuzz itself checks whether the segment is at the beginning/end + of the paragraph. Clients that only pass item-at-a-time to HarfBuzz + continue not setting any flags whatsoever. + + Another way to put it is: if there's pre-context text in the buffer, + HarfBuzz ignores the BOT flag. If there's post-context, it ignores + EOT flag. + + +Overview of changes leading to 0.9.33 +Tuesday, July 22, 2014 +===================================== + +- Turn off ARabic 'cswh' feature that was accidentally turned on. +- Add HB_TAG_MAX_SIGNED. +- Make hb_face_make_immutable() really make face immutable! +- Windows build fixes. + + +Overview of changes leading to 0.9.32 +Thursday, July 17, 2014 +===================================== + +- Apply Arabic shaping features in spec order exactly. +- Another fix for Mongolian free variation selectors. +- For non-Arabic scripts in Arabic shaper apply 'rlig' and 'calt' + together. +- Minor adjustment to U+FFFD logic. +- Fix hb-coretext build. + + +Overview of changes leading to 0.9.31 +Wednesday, July 16, 2014 +===================================== + +- Only accept valid UTF-8/16/32; we missed many cases before. +- Better shaping of invalid UTF-8/16/32. Falls back to + U+FFFD REPLACEMENT CHARACTER now. +- With all changes in this release, the buffer will contain fully + valid Unicode after hb_buffer_add_utf8/16/32 no matter how + broken the input is. This can be overridden though. See below. +- Fix Mongolian Variation Selectors for fonts without GDEF. +- Fix minor invalid buffer access. +- Accept zh-Hant and zh-Hans language tags. hb_ot_tag_to_language() + now uses these instead of private tags. +- Build fixes. +- New API: + * hb_buffer_add_codepoints(). This does what hb_buffer_add_utf32() + used to do, ie. no validity check on the input at all. add_utf32 + now replaces invalid Unicode codepoints with the replacement + character (see below). + * hb_buffer_set_replacement_codepoint() + * hb_buffer_get_replacement_codepoint() + Previously, in hb_buffer_add_utf8 and hb_buffer_add_utf16, when + we detected broken input, we replaced that with (hb_codepoint_t)-1. + This has changed to use U+FFFD now, but can be changed using these + new API. + + +Overview of changes leading to 0.9.30 +Wednesday, July 9, 2014 +===================================== + +- Update to Unicode 7.0.0: + * New scripts Manichaean and Psalter Pahlavi are shaped using + Arabic shaper. + * All the other new scripts to through the generic shaper for + now. +- Minor Indic improvements. +- Fix graphite2 backend cluster mapping [crasher!] +- API changes: + * New HB_SCRIPT_* values for Unicode 7.0 scripts. + * New function hb_ot_layout_language_get_required_feature(). +- Build fixes. + + +Overview of changes leading to 0.9.29 +Thursday, May 29, 2014 +===================================== + +- Implement cmap in hb-ot-font.h. No variation-selectors yet. +- Myanmar: Allow MedialYa+Asat. +- Various Indic fixes: + * Support most characters in Extended Devanagary and Vedic + Unicode blocks. + * Allow digits and a some punctuation as consonant placeholders. +- Build fixes. + + +Overview of changes leading to 0.9.28 +Monday, April 28, 2014 +===================================== + +- Unbreak old-spec Indic shaping. (bug 76705) +- Fix shaping of U+17DD and U+0FC6. +- Add HB_NO_MERGE_CLUSTERS build option. NOT to be enabled by default + for shipping libraries. It's an option for further experimentation + right now. When we are sure how to do it properly, we will add + public run-time API for the functionality. +- Build fixes. + + +Overview of changes leading to 0.9.27 +Tuesday, March 18, 2014 +===================================== + +- Don't use "register" storage class specifier +- Wrap definition of free_langs() with HAVE_ATEXIT +- Add coretext_aat shaper and hb_coretext_face_create() constructor +- If HAVE_ICU_BUILTIN is defined, use hb-icu Unicode callbacks +- Add Myanmar test case from OpenType Myanmar spec +- Only do fallback Hebrew composition if no GPOS 'mark' available +- Allow bootstrapping without gtk-doc +- Use AM_MISSING_PROG for ragel and git +- Typo in ucdn's Makefile.am +- Improve MemoryBarrier() implementation + + +Overview of changes leading to 0.9.26 +Thursday, January 30, 2014 +===================================== + +- Misc fixes. +- Fix application of 'rtlm' feature. +- Automatically apply frac/numr/dnom around U+2044 FRACTION SLASH. +- New header: hb-ot-shape.h +- Uniscribe: fix scratch-buffer accounting. +- Reorder Tai Tham SAKOT to after tone-marks. +- Add Hangul shaper. +- New files: + hb-ot-shape-complex-hangul.cc + hb-ot-shape-complex-hebrew.cc + hb-ot-shape-complex-tibetan.cc +- Disable 'cswh' feature in Arabic shaper. +- Coretext: better handle surrogate pairs. +- Add HB_TAG_MAX and _HB_SCRIPT_MAX_VALUE. + + +Overview of changes leading to 0.9.25 +Wednesday, December 4, 2013 +===================================== + +- Myanmar shaper improvements. +- Avoid font fallback in CoreText backend. +- Additional OpenType language tag mappiongs. +- More aggressive shape-plan caching. +- Build with / require automake 1.13. +- Build with libtool 2.4.2.418 alpha to support ppc64le. + + +Overview of changes leading to 0.9.24 +Tuesday, November 13, 2013 +===================================== + +- Misc compiler warning fixes with clang. +- No functional changes. + + +Overview of changes leading to 0.9.23 +Monday, October 28, 2013 +===================================== + +- "Udupi HarfBuzz Hackfest", Paris, October 14..18 2013. +- Fix (Chain)Context recursion with non-monotone lookup positions. +- Misc Indic bug fixes. +- New Javanese / Buginese shaping, similar to Windows 8.1. + + +Overview of changes leading to 0.9.22 +Thursday, October 3, 2013 +===================================== + +- Fix use-after-end-of-scope in hb_language_from_string(). +- Fix hiding of default_ignorables if font doesn't have space glyph. +- Protect against out-of-range lookup indices. + +- API Changes: + + * Added hb_ot_layout_table_get_lookup_count() + + +Overview of changes leading to 0.9.21 +Monday, September 16, 2013 +===================================== + +- Rename gobject-introspection library name from harfbuzz to HarfBuzz. +- Remove (long disabled) hb-old and hb-icu-le test shapers. +- Misc gtk-doc and gobject-introspection annotations. +- Misc fixes. +- API changes: + + * Add HB_SET_VALUE_INVALID + +Overview of changes leading to 0.9.20 +Thursday, August 29, 2013 +===================================== + +General: +- Misc substitute_closure() fixes. +- Build fixes. + +Documentation: +- gtk-doc boilerplate integrated. Docs are built now, but + contain no contents. By next release hopefully we have + some content in. Enable using --enable-gtk-doc. + +GObject and Introspection: +- Added harfbuzz-gobject library (hb-gobject.h) that has type + bindings for all HarfBuzz objects and enums. Enable using + --with-gobject. +- Added gobject-introspection boilerplate. Nothing useful + right now. Work in progress. Gets enabled automatically if + --with-gobject is used. Override with --disable-introspection. + +OpenType shaper: +- Apply 'mark' in Myanmar shaper. +- Don't apply 'dlig' by default. + +Uniscribe shaper: +- Support user features. +- Fix loading of fonts that are also installed on the system. +- Fix shaping of Arabic Presentation Forms. +- Fix build with wide chars. + +CoreText shaper: +- Support user features. + +Source changes: +- hb_face_t code moved to hb-face.h / hb-face.cc. +- Added hb-deprecated.h. + +API changes: +- Added HB_DISABLE_DEPRECATED. +- Deprecated HB_SCRIPT_CANADIAN_ABORIGINAL; replaced by + HB_SCRIPT_CANADIAN_SYLLABICS. +- Deprecated HB_BUFFER_FLAGS_DEFAULT; replaced by + HB_BUFFER_FLAG_DEFAULT. +- Deprecated HB_BUFFER_SERIALIZE_FLAGS_DEFAULT; replaced by + HB_BUFFER_SERIALIZE_FLAG_DEFAULT. + + +Overview of changes leading to 0.9.19 +Tuesday, July 16, 2013 +===================================== + +- Build fixes. +- Better handling of multiple variation selectors in a row. +- Pass on variation selector to GSUB if not consumed by cmap. +- Fix undefined memory access. +- Add Javanese config to Indic shaper. +- Misc bug fixes. + +Overview of changes leading to 0.9.18 +Tuesday, May 28, 2013 +===================================== + +New build system: + +- All unneeded code is all disabled by default, + +- Uniscribe and CoreText shapers can be enabled with their --with options, + +- icu_le and old shapers cannot be enabled for now, + +- glib, freetype, and cairo will be detected automatically. + They can be force on/off'ed with their --with options, + +- icu and graphite2 are default off, can be enabled with their --with + options, + +Moreover, ICU support is now build into a separate library: +libharfbuzz-icu.so, and a new harfbuzz-icu.pc is shipped for it. +Distros can enable ICU now without every application on earth +getting linked to via libharfbuzz.so. + +For distros I recommend that they make sure they are building --with-glib +--with-freetype --with-cairo, --with-icu, and optionally --with-graphite2; +And package harfbuzz and harfbuzz-icu separately. + + +Overview of changes leading to 0.9.17 +Monday, May 20, 2013 +===================================== + +- Build fixes. +- Fix bug in hb_set_get_min(). +- Fix regression with Arabic mark positioning / width-zeroing. + +Overview of changes leading to 0.9.16 +Friday, April 19, 2013 +===================================== + +- Major speedup in OpenType lookup processing. With the Amiri + Arabic font, this release is over 3x faster than previous + release. All scripts / languages should see this speedup. + +- New --num-iterations option for hb-shape / hb-view; useful for + profiling. + +Overview of changes leading to 0.9.15 +Friday, April 05, 2013 +===================================== + +- Build fixes. +- Fix crasher in graphite2 shaper. +- Fix Arabic mark width zeroing regression. +- Don't compose Hangul jamo into Unicode syllables. + + +Overview of changes leading to 0.9.14 +Thursday, March 21, 2013 +===================================== + +- Build fixes. +- Fix time-consuming sanitize with malicious fonts. +- Implement hb_buffer_deserialize_glyphs() for both json and text. +- Do not ignore Hangul filler characters. +- Indic fixes: + * Fix Malayalam pre-base reordering interaction with post-forms. + * Further adjust ZWJ handling. Should fix known regressions from + 0.9.13. + + +Overview of changes leading to 0.9.13 +Thursday, February 25, 2013 +===================================== + +- Build fixes. +- Ngapi HarfBuzz Hackfest in London (February 2013): + * Fixed all known Indic bugs, + * New Win8-style Myanmar shaper, + * New South-East Asian shaper for Tai Tham, Cham, and New Tai Lue, + * Smartly ignore Default_Ignorable characters (joiners, etc) wheb + matching GSUB/GPOS lookups, + * Fix 'Phags-Pa U+A872 shaping, + * Fix partial disabling of default-on features, + * Allow disabling of TrueType kerning. +- Fix possible crasher with broken fonts with overlapping tables. +- Removed generated files from git again. So, one needs ragel to + bootstrap from the git tree. + +API changes: +- hb_shape() and related APIs now abort if buffer direction is + HB_DIRECTION_INVALID. Previously, hb_shape() was calling + hb_buffer_guess_segment_properties() on the buffer before + shaping. The heuristics in that function are fragile. If the + user really wants the old behvaior, they can call that function + right before calling hb_shape() to get the old behavior. +- hb_blob_create_sub_blob() always creates sub-blob with + HB_MEMORY_MODE_READONLY. See comments for the reason. + + +Overview of changes leading to 0.9.12 +Thursday, January 18, 2013 +===================================== + +- Build fixes for Sun compiler. +- Minor bug fix. + +Overview of changes leading to 0.9.11 +Thursday, January 10, 2013 +===================================== + +- Build fixes. +- Fix GPOS mark attachment with null Anchor offsets. +- [Indic] Fix old-spec reordering of viramas if sequence ends in one. +- Fix multi-threaded shaper data creation crash. +- Add atomic ops for Solaris. + +API changes: +- Rename hb_buffer_clear() to hb_buffer_clear_contents(). + + +Overview of changes leading to 0.9.10 +Thursday, January 3, 2013 +===================================== + +- [Indic] Fixed rendering of Malayalam dot-reph +- Updated OT language tags. +- Updated graphite2 backend. +- Improved hb_ot_layout_get_size_params() logic. +- Improve hb-shape/hb-view help output. +- Fixed hb-set.h implementation to not crash. +- Fixed various issues with hb_ot_layout_collect_lookups(). +- Various build fixes. + +New API: + +hb_graphite2_face_get_gr_face() +hb_graphite2_font_get_gr_font() +hb_coretext_face_get_cg_font() + +Modified API: + +hb_ot_layout_get_size_params() + + +Overview of changes leading to 0.9.9 +Wednesday, December 5, 2012 +==================================== + +- Fix build on Windows. +- Minor improvements. + + +Overview of changes leading to 0.9.8 +Tuesday, December 4, 2012 +==================================== + + +- Actually implement hb_shape_plan_get_shaper (). +- Make UCDB data tables const. +- Lots of internal refactoring in OTLayout tables. +- Flesh out hb_ot_layout_lookup_collect_glyphs(). + +New API: + +hb_ot_layout_collect_lookups() +hb_ot_layout_get_size_params() + + +Overview of changes leading to 0.9.7 +Sunday, November 21, 2012 +==================================== + + +HarfBuzz "All-You-Can-Eat-Sushi" (aka Vancouver) Hackfest and follow-on fixes. + +- Fix Arabic contextual joining using pre-context text. +- Fix Sinhala "split matra" mess. +- Fix Khmer shaping with broken fonts. +- Implement Thai "PUA" shaping for old fonts. +- Do NOT route Kharoshthi script through the Indic shaper. +- Disable fallback positioning for Indic and Thai shapers. +- Misc fixes. + + +hb-shape / hb-view changes: + +- Add --text-before and --text-after +- Add --bot / --eot / --preserve-default-ignorables +- hb-shape --output-format=json + + +New API: + +hb_buffer_clear() + +hb_buffer_flags_t + +HB_BUFFER_FLAGS_DEFAULT +HB_BUFFER_FLAG_BOT +HB_BUFFER_FLAG_EOT +HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES + +hb_buffer_set_flags() +hb_buffer_get_flags() + +HB_BUFFER_SERIALIZE_FLAGS +hb_buffer_serialize_glyphs() +hb_buffer_deserialize_glyphs() +hb_buffer_serialize_list_formats() + +hb_set_add_range() +hb_set_del_range() +hb_set_get_population() +hb_set_next_range() + +hb_face_[sg]et_glyph_count() + +hb_segment_properties_t +HB_SEGMENT_PROPERTIES_DEFAULT +hb_segment_properties_equal() +hb_segment_properties_hash() + +hb_buffer_set_segment_properties() +hb_buffer_get_segment_properties() + +hb_ot_layout_glyph_class_t +hb_ot_layout_get_glyph_class() +hb_ot_layout_get_glyphs_in_class() + +hb_shape_plan_t +hb_shape_plan_create() +hb_shape_plan_create_cached() +hb_shape_plan_get_empty() +hb_shape_plan_reference() +hb_shape_plan_destroy() +hb_shape_plan_set_user_data() +hb_shape_plan_get_user_data() +hb_shape_plan_execute() +hb_shape_plan_get_shaper() + +hb_ot_shape_plan_collect_lookups() + + +API changes: + +- Remove "mask" parameter from hb_buffer_add(). +- Rename hb_ot_layout_would_substitute_lookup() and hb_ot_layout_substitute_closure_lookup(). +- hb-set.h API const correction. +- Renamed hb_set_min/max() to hb_set_get_min/max(). +- Rename hb_ot_layout_feature_get_lookup_indexes() to hb_ot_layout_feature_get_lookups(). +- Rename hb_buffer_guess_properties() to hb_buffer_guess_segment_properties(). + + + +Overview of changes leading to 0.9.6 +Sunday, November 13, 2012 +==================================== + +- Don't clear pre-context text if no new context is provided. +- Fix ReverseChainingSubstLookup, which was totally borked. +- Adjust output format of hb-shape a bit. +- Include config.h.in in-tree. Makes it easier for alternate build systems. +- Fix hb_buffer_set_length(buffer, 0) invalid memory allocation. +- Use ICU LayoutEngine's C API instead of C++. Avoids much headache. +- Drop glyphs for all of Unicode Default_Ignorable characters. +- Misc build fixes. + +Arabic shaper: +- Enable 'dlig' and 'mset' features in Arabic shaper. +- Implement 'Phags-pa shaping, improve Mongolian. + +Indic shaper: +- Decompose Sinhala split matras the way old HarfBuzz / Pango did. +- Initial support for Consonant Medials. +- Start adding new-style Myanmar shaping. +- Make reph and 'pref' logic introspect the font. +- Route Meetei-Mayek through the Indic shaper. +- Don't apply 'liga' in Indic shaper. +- Improve Malayalam pre-base reordering Ra interaction with Chillus. + + + +Overview of changes leading to 0.9.5 +Sunday, October 14, 2012 +==================================== + +- Synthetic-GSUB Arabic fallback shaping. + +- Misc Indic improvements. + +- Add build system support for pthread. + +- Imported UCDN for in-tree Unicode callbacks implementation. + +- Context-aware Arabic joining. + +- Misc other fixes. + +- New API: + + hb_feature_to/from-string() + hb_buffer_[sg]et_content_type() + + + +Overview of changes leading to 0.9.4 +Tuesday, Sep 03, 2012 +==================================== + +- Indic improvements with old-spec Malayalam. + +- Better fallback glyph positioning, specially with Thai / Lao marks. + +- Implement dotted-circle insertion. + +- Better Arabic fallback shaping / ligation. + +- Added ICU LayoutEngine backend for testing. Call it by the 'icu_le' name. + +- Misc fixes. + + + +Overview of changes leading to 0.9.3 +Friday, Aug 18, 2012 +==================================== + +- Fixed fallback mark positioning for left-to-right text. + +- Improve mark positioning for the remaining combining classes. + +- Unbreak Thai and fallback Arabic shaping. + +- Port Arabic shaper to shape-plan caching. + +- Use new ICU normalizer functions. + + + +Overview of changes leading to 0.9.2 +Friday, Aug 10, 2012 +==================================== + +- Over a thousand commits! This is the first major release of HarfBuzz. + +- HarfBuzz is feature-complete now! It should be in par, or better, than + both Pango's shapers and old HarfBuzz / Qt shapers. + +- New Indic shaper, supporting main Indic scripts, Sinhala, and Khmer. + +- Improved Arabic shaper, with fallback Arabic shaping, supporting Arabic, + Sinhala, N'ko, Mongolian, and Mandaic. + +- New Thai / Lao shaper. + +- Tibetan / Hangul support in the generic shaper. + +- Synthetic GDEF support for fonts without a GDEF table. + +- Fallback mark positioning for fonts without a GPOS table. + +- Unicode normalization shaping heuristic during glyph mapping. + +- New experimental Graphite2 backend. + +- New Uniscribe backend (primarily for testing). + +- New CoreText backend (primarily for testing). + +- Major optimization and speedup. + +- Test suites and testing infrastructure (work in progress). + +- Greatly improved hb-view cmdline tool. + +- hb-shape cmdline tool. + +- Unicode 6.1 support. + +Summary of API changes: + +o Changed API: + + - Users are expected to only include main header files now (ie. hb.h, + hb-glib.h, hb-ft.h, ...) + + - All struct tag names had their initial underscore removed. + Ie. "struct _hb_buffer_t" is "struct hb_buffer_t" now. + + - All set_user_data() functions now take a "replace" boolean parameter. + + - hb_buffer_create() takes zero arguments now. + Use hb_buffer_pre_allocate() to pre-allocate. + + - hb_buffer_add_utf*() now accept -1 for length parameters, + meaning "nul-terminated". + + - hb_direction_t enum values changed. + + - All *_from_string() APIs now take a length parameter to allow for + non-nul-terminated strings. A -1 length means "nul-terminated". + + - Typedef for hb_language_t changed. + + - hb_get_table_func_t renamed to hb_reference_table_func_t. + + - hb_ot_layout_table_choose_script() + + - Various renames in hb-unicode.h. + +o New API: + + - hb_buffer_guess_properties() + Automatically called by hb_shape(). + + - hb_buffer_normalize_glyphs() + + - hb_tag_from_string() + + - hb-coretext.h + + - hb-uniscribe.h + + - hb_face_reference_blob() + - hb_face_[sg]et_index() + - hb_face_set_upem() + + - hb_font_get_glyph_name_func_t + hb_font_get_glyph_from_name_func_t + hb_font_funcs_set_glyph_name_func() + hb_font_funcs_set_glyph_from_name_func() + hb_font_get_glyph_name() + hb_font_get_glyph_from_name() + hb_font_glyph_to_string() + hb_font_glyph_from_string() + + - hb_font_set_funcs_data() + + - hb_ft_font_set_funcs() + - hb_ft_font_get_face() + + - hb-gobject.h (work in progress) + + - hb_ot_shape_glyphs_closure() + hb_ot_layout_substitute_closure_lookup() + + - hb-set.h + + - hb_shape_full() + + - hb_unicode_combining_class_t + + - hb_unicode_compose_func_t + hb_unicode_decompose_func_t + hb_unicode_decompose_compatibility_func_t + hb_unicode_funcs_set_compose_func() + hb_unicode_funcs_set_decompose_func() + hb_unicode_funcs_set_decompose_compatibility_func() + hb_unicode_compose() + hb_unicode_decompose() + hb_unicode_decompose_compatibility() + +o Removed API: + + - hb_ft_get_font_funcs() + + - hb_ot_layout_substitute_start() + hb_ot_layout_substitute_lookup() + hb_ot_layout_substitute_finish() + hb_ot_layout_position_start() + hb_ot_layout_position_lookup() + hb_ot_layout_position_finish() + + + +Overview of changes leading to 0.6.0 +Friday, May 27, 2011 +==================================== + +- Vertical text support in GPOS +- Almost all API entries have unit tests now, under test/ +- All thread-safety issues are fixed + +Summary of API changes follows. + + +* Simple Types API: + + o New API: + HB_LANGUAGE_INVALID + hb_language_get_default() + hb_direction_to_string() + hb_direction_from_string() + hb_script_get_horizontal_direction() + HB_UNTAG() + + o Renamed API: + hb_category_t renamed to hb_unicode_general_category_t + + o Changed API: + hb_language_t is a typed pointers now + + o Removed API: + HB_TAG_STR() + + +* Use ISO 15924 tags for hb_script_t: + + o New API: + hb_script_from_iso15924_tag() + hb_script_to_iso15924_tag() + hb_script_from_string() + + o Changed API: + HB_SCRIPT_* enum members changed value. + + +* Buffer API streamlined: + + o New API: + hb_buffer_reset() + hb_buffer_set_length() + hb_buffer_allocation_successful() + + o Renamed API: + hb_buffer_ensure() renamed to hb_buffer_pre_allocate() + hb_buffer_add_glyph() renamed to hb_buffer_add() + + o Removed API: + hb_buffer_clear() + hb_buffer_clear_positions() + + o Changed API: + hb_buffer_get_glyph_infos() takes an out length parameter now + hb_buffer_get_glyph_positions() takes an out length parameter now + + +* Blob API streamlined: + + o New API: + hb_blob_get_data() + hb_blob_get_data_writable() + + o Renamed API: + hb_blob_create_empty() renamed to hb_blob_get_empty() + + o Removed API: + hb_blob_lock() + hb_blob_unlock() + hb_blob_is_writable() + hb_blob_try_writable() + + o Changed API: + hb_blob_create() takes user_data before destroy now + + +* Unicode functions API: + + o Unicode function vectors can subclass other unicode function vectors now. + Unimplemented callbacks in the subclass automatically chainup to the parent. + + o All hb_unicode_funcs_t callbacks take a user_data now. Their setters + take a user_data and its respective destroy callback. + + o New API: + hb_unicode_funcs_get_empty() + hb_unicode_funcs_get_default() + hb_unicode_funcs_get_parent() + + o Changed API: + hb_unicode_funcs_create() now takes a parent_funcs. + + o Removed func getter functions: + hb_unicode_funcs_get_mirroring_func() + hb_unicode_funcs_get_general_category_func() + hb_unicode_funcs_get_script_func() + hb_unicode_funcs_get_combining_class_func() + hb_unicode_funcs_get_eastasian_width_func() + + +* Face API: + + o Renamed API: + hb_face_get_table() renamed to hb_face_reference_table() + hb_face_create_for_data() renamed to hb_face_create() + + o Changed API: + hb_face_create_for_tables() takes user_data before destroy now + hb_face_reference_table() returns empty blob instead of NULL + hb_get_table_func_t accepts the face as first parameter now + +* Font API: + + o Fonts can subclass other fonts now. Unimplemented callbacks in the + subclass automatically chainup to the parent. When chaining up, + scale is adjusted if the parent font has a different scale. + + o All hb_font_funcs_t callbacks take a user_data now. Their setters + take a user_data and its respective destroy callback. + + o New API: + hb_font_get_parent() + hb_font_funcs_get_empty() + hb_font_create_sub_font() + + o Removed API: + hb_font_funcs_copy() + hb_font_unset_funcs() + + o Removed func getter functions: + hb_font_funcs_get_glyph_func() + hb_font_funcs_get_glyph_advance_func() + hb_font_funcs_get_glyph_extents_func() + hb_font_funcs_get_contour_point_func() + hb_font_funcs_get_kerning_func() + + o Changed API: + hb_font_create() takes a face and references it now + hb_font_set_funcs() takes user_data before destroy now + hb_font_set_scale() accepts signed integers now + hb_font_get_contour_point_func_t now takes glyph first, then point_index + hb_font_get_glyph_func_t returns a success boolean now + + +* Changed object model: + + o All object types have a _get_empty() now: + hb_blob_get_empty() + hb_buffer_get_empty() + hb_face_get_empty() + hb_font_get_empty() + hb_font_funcs_get_empty() + hb_unicode_funcs_get_empty() + + o Added _set_user_data() and _get_user_data() for all object types: + hb_blob_get_user_data() + hb_blob_set_user_data() + hb_buffer_get_user_data() + hb_buffer_set_user_data() + hb_face_get_user_data() + hb_face_set_user_data() + hb_font_funcs_get_user_data() + hb_font_funcs_set_user_data() + hb_font_get_user_data() + hb_font_set_user_data() + hb_unicode_funcs_get_user_data() + hb_unicode_funcs_set_user_data() + + o Removed the _get_reference_count() from all object types: + hb_blob_get_reference_count() + hb_buffer_get_reference_count() + hb_face_get_reference_count() + hb_font_funcs_get_reference_count() + hb_font_get_reference_count() + hb_unicode_funcs_get_reference_count() + + o Added _make_immutable() and _is_immutable() for all object types except for buffer: + hb_blob_make_immutable() + hb_blob_is_immutable() + hb_face_make_immutable() + hb_face_is_immutable() + + +* Changed API for vertical text support + + o The following callbacks where removed: + hb_font_get_glyph_advance_func_t + hb_font_get_kerning_func_t + + o The following new callbacks added instead: + hb_font_get_glyph_h_advance_func_t + hb_font_get_glyph_v_advance_func_t + hb_font_get_glyph_h_origin_func_t + hb_font_get_glyph_v_origin_func_t + hb_font_get_glyph_h_kerning_func_t + hb_font_get_glyph_v_kerning_func_t + + o The following API removed as such: + hb_font_funcs_set_glyph_advance_func() + hb_font_funcs_set_kerning_func() + hb_font_get_glyph_advance() + hb_font_get_kerning() + + o New API added instead: + hb_font_funcs_set_glyph_h_advance_func() + hb_font_funcs_set_glyph_v_advance_func() + hb_font_funcs_set_glyph_h_origin_func() + hb_font_funcs_set_glyph_v_origin_func() + hb_font_funcs_set_glyph_h_kerning_func() + hb_font_funcs_set_glyph_v_kerning_func() + hb_font_get_glyph_h_advance() + hb_font_get_glyph_v_advance() + hb_font_get_glyph_h_origin() + hb_font_get_glyph_v_origin() + hb_font_get_glyph_h_kerning() + hb_font_get_glyph_v_kerning() + + o The following higher-leve API added for convenience: + hb_font_get_glyph_advance_for_direction() + hb_font_get_glyph_origin_for_direction() + hb_font_add_glyph_origin_for_direction() + hb_font_subtract_glyph_origin_for_direction() + hb_font_get_glyph_kerning_for_direction() + hb_font_get_glyph_extents_for_origin() + hb_font_get_glyph_contour_point_for_origin() + + +* OpenType Layout API: + + o New API: + hb_ot_layout_position_start() + hb_ot_layout_substitute_start() + hb_ot_layout_substitute_finish() + + +* Glue code: + + o New API: + hb_glib_script_to_script() + hb_glib_script_from_script() + hb_icu_script_to_script() + hb_icu_script_from_script() + + +* Version API added: + + o New API: + HB_VERSION_MAJOR + HB_VERSION_MINOR + HB_VERSION_MICRO + HB_VERSION_STRING + HB_VERSION_CHECK() + hb_version() + hb_version_string() + hb_version_check() + + diff --git a/third_party/harfbuzz-ng/src/README b/third_party/harfbuzz-ng/src/README new file mode 120000 index 000000000000..42061c01a1c7 --- /dev/null +++ b/third_party/harfbuzz-ng/src/README @@ -0,0 +1 @@ +README.md \ No newline at end of file diff --git a/third_party/harfbuzz-ng/src/README.md b/third_party/harfbuzz-ng/src/README.md new file mode 100644 index 000000000000..4202961e04a0 --- /dev/null +++ b/third_party/harfbuzz-ng/src/README.md @@ -0,0 +1,99 @@ +[![Linux CI Status](https://github.com/harfbuzz/harfbuzz/workflows/linux-ci/badge.svg)](https://github.com/harfbuzz/harfbuzz/workflows/linux-ci/badge.svg) +[![CircleCI Build Status](https://circleci.com/gh/harfbuzz/harfbuzz/tree/main.svg?style=svg)](https://circleci.com/gh/harfbuzz/harfbuzz/tree/main) +[![OSS-Fuzz Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/harfbuzz.svg)](https://oss-fuzz-build-logs.storage.googleapis.com/index.html) +[![Coverity Scan Build Status](https://scan.coverity.com/projects/15166/badge.svg)](https://scan.coverity.com/projects/harfbuzz) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/89c872f5ce1c42af802602bfcd15d90a)](https://www.codacy.com/gh/harfbuzz/harfbuzz/dashboard?utm_source=github.com&utm_medium=referral&utm_content=harfbuzz/harfbuzz&utm_campaign=Badge_Grade) +[![Codecov Code Coverage](https://codecov.io/gh/harfbuzz/harfbuzz/branch/main/graph/badge.svg)](https://codecov.io/gh/harfbuzz/harfbuzz) +[![Packaging status](https://repology.org/badge/tiny-repos/harfbuzz.svg)](https://repology.org/project/harfbuzz/versions) + +# HarfBuzz + +HarfBuzz is a text shaping engine. It primarily supports [OpenType][1], but also +[Apple Advanced Typography][2]. HarfBuzz is used in Android, Chrome, +ChromeOS, Firefox, GNOME, GTK+, KDE, LibreOffice, OpenJDK, PlayStation, Qt, +XeTeX, and other places. + +For bug reports, mailing list, and other information please visit: + + http://harfbuzz.org/ + +For license information, see [COPYING](COPYING). + +## Documentation + +For user manual as well as API documentation, check: https://harfbuzz.github.io + +## Download + +For tarball releases of HarfBuzz, look [here][3]. At the same place you +will also find Win32/Win64 binary bundles that include libharfbuzz DLL, +hb-view.exe, hb-shape.exe, and all dependencies. + +The canonical source tree is available on [github][4]. + +The API that comes with `hb.h` will not change incompatibly. Other, peripheral, +headers are more likely to go through minor modifications, but again, we do our +best to never change API in an incompatible way. We will never break the ABI. + +If you are not sure whether Pango or HarfBuzz is right for you, read [Pango vs +HarfBuzz][5]. + +## Development + +For build information, see [BUILD.md](BUILD.md). + +For custom configurations, see [CONFIG.md](CONFIG.md). + +For testing and profiling, see [TESTING.md](TESTING.md). + +To get a better idea of where HarfBuzz stands in the text rendering stack you +may want to read [State of Text Rendering][6], though, that document is many +years old. Here are a few presentation slides about HarfBuzz at the +Internationalization and Unicode Conference over the years: + +* November 2014, [Unicode, OpenType, and HarfBuzz: Closing the Circle][7], +* October 2012, [HarfBuzz, The Free and Open Text Shaping Engine][8], +* October 2009, [HarfBuzz: the Free and Open Shaping Engine][9]. + +Both development and user support discussion around HarfBuzz happens on the +[github][4]. + +To report bugs or submit patches please use [github][4] issues and +pull-requests. + +For a comparison of old vs new HarfBuzz memory consumption see [this][10]. + + + +## Name + +HarfBuzz (حرÙ‌باز) is my Persian translation of “[OpenType][1]â€, +transliterated using the Latin script. It sports a second meaning, but that +ain’t translatable. + +> Background: Originally there was this font format called TrueType. People and +> companies started calling their type engines all things ending in Type: +> FreeType, CoolType, ClearType, etc. And then came OpenType, which is the +> successor of TrueType. So, for my OpenType implementation, I decided to stick +> with the concept but use the Persian translation. Which is fitting given that +> Persian is written in the Arabic script, and OpenType is an extension of +> TrueType that adds support for complex script rendering, and HarfBuzz is an +> implementation of OpenType complex text shaping. + +
      + Packaging status of HarfBuzz + +[![Packaging status](https://repology.org/badge/vertical-allrepos/harfbuzz.svg?header=harfbuzz)](https://repology.org/project/harfbuzz/versions) + +
      + +[1]: https://docs.microsoft.com/en-us/typography/opentype/spec/ +[2]: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6AATIntro.html +[3]: https://github.com/harfbuzz/harfbuzz/releases +[4]: https://github.com/harfbuzz/harfbuzz +[5]: http://mces.blogspot.com/2009/11/pango-vs-harfbuzz.html +[6]: http://behdad.org/text/ +[7]: https://goo.gl/FSIQuC +[8]: https://goo.gl/2wSRu +[9]: http://behdad.org/download/Presentations/slippy/harfbuzz_slides.pdf +[10]: https://goo.gl/woyty diff --git a/third_party/harfbuzz-ng/src/README.mingw.md b/third_party/harfbuzz-ng/src/README.mingw.md new file mode 100644 index 000000000000..60629f6fcd72 --- /dev/null +++ b/third_party/harfbuzz-ng/src/README.mingw.md @@ -0,0 +1,58 @@ +For the development of HarfBuzz, the Microsoft shaping technology, Uniscribe, +as a widely used and tested shaper is used as more-or-less OpenType reference +implementation and that specially is important where OpenType specification +is or wasn't that clear. For having access to Uniscribe on Linux/macOS these +steps are recommended: + +You want to follow the 32bit instructions. The 64bit equivalents are included +for reference. + +1. Install Wine. + - Fedora: `dnf install wine`. + +2. Install `mingw-w64` compiler. + - Fedora, 32bit: `dnf install mingw32-gcc-c++` + - Fedora, 64bit: `dnf install mingw64-gcc-c++` + - Debian: `apt install g++-mingw-w64` + - Mac: `brew install mingw-w64` + +3. If you have drank the `meson` koolaid, look at `.ci/build-win32.sh` to see how to + invoke `meson` now, or just run that script. Otherwise, here's how to use the + old trusty autotools instead: + + a) Install dependencies. + - Fedora, 32bit: `dnf install mingw32-glib2 mingw32-cairo mingw32-freetype` + - Fedora, 64bit: `dnf install mingw64-glib2 mingw64-cairo mingw64-freetype` + + b) Configure: + - `NOCONFIGURE=1 ./autogen.sh && mkdir winbuild && cd winbuild` + - 32bit: `../mingw-configure.sh i686` + - 64bit: `../mingw-configure.sh x86_64` + + c) Build as usual: + - make + + d) Configure your wine to find system mingw libraries. See: + https://fedoraproject.org/wiki/MinGW/Configure_wine + +Now you can use `hb-shape` by `(cd win32build/util && wine hb-shape.exe)` +but if you like to shape with the Microsoft Uniscribe: + +4. Bring a 32bit version of `usp10.dll` for yourself from `C:\Windows\SysWOW64\usp10.dll` of your + Windows installation (assuming you have a 64-bit installation, otherwise + `C:\Windows\System32\usp10.dll`) that it is not a DirectWrite proxy + ([for more info](https://en.wikipedia.org/wiki/Uniscribe)). + Rule of thumb, your `usp10.dll` should have a size more than 500kb, otherwise + it is designed to work with DirectWrite which Wine can't work with its original one. + You want a Uniscribe from Windows 7 or older. + + Put the DLL in the folder you are going to run the next command, + +5. `WINEDLLOVERRIDES="usp10=n" wine hb-shape.exe fontname.ttf -u 0061,0062,0063 --shaper=uniscribe` + +(`0061,0062,0063` means `abc`, use test/shaping/hb-unicode-decode to generate ones you need) + +When you have built that, you can test HarfBuzz's native shaper against Uniscribe +following these instructions: + + https://github.com/harfbuzz/harfbuzz/issues/3671 diff --git a/third_party/harfbuzz-ng/src/README.python.md b/third_party/harfbuzz-ng/src/README.python.md new file mode 100644 index 000000000000..7496f045ec92 --- /dev/null +++ b/third_party/harfbuzz-ng/src/README.python.md @@ -0,0 +1,31 @@ +To enable HarfBuzz bindings for Python among other languages, make sure +you have latest version of gobject-introspection available. On Ubuntu, +you can install that this way: + +```bash +sudo apt-get install libgirepository1.0-dev +``` + +And then run `meson setup` and make sure that `Introspection` is reported +enabled in output. + +Compile and install. + +Make sure you have the installation lib dir in `LD_LIBRARY_PATH`, as needed +for the linker to find the library. + +Then make sure you also have `GI_TYPELIB_PATH` pointing to the resulting +`$prefix/lib/girepository-*` directory. + +Make sure you have pygobject installed. Then check that the following +import works in your Python interpreter: + +```python +from gi.repository import HarfBuzz +``` + +If it does, you are ready to call HarfBuzz from Python! Congratulations. +See [`src/sample.py`](src/sample.py). + +The Python API will change. Let us know on the mailing list if you are +using it, and send lots of feedback. diff --git a/third_party/harfbuzz-ng/src/RELEASING.md b/third_party/harfbuzz-ng/src/RELEASING.md new file mode 100644 index 000000000000..2e5f2bd82ebd --- /dev/null +++ b/third_party/harfbuzz-ng/src/RELEASING.md @@ -0,0 +1,37 @@ +# HarfBuzz release walk-through checklist: + +- [ ] Open gitk and review changes since last release. + + - [ ] Print all public API changes: + `git diff $(git describe | sed 's/-.*//').. src/*.h` + + - [ ] Document them in NEWS. + All API and API semantic changes should be clearly marked as API additions, API changes, or API deletions. + + - [ ] Document deprecations. + Ensure all new API / deprecations are in listed correctly in docs/harfbuzz-sections.txt. + If release added new API, add entry for new API index at the end of docs/harfbuzz-docs.xml. + + If there's a backward-incompatible API change (including deletions for API used anywhere), that's a release blocker. + Do NOT release. + +- [ ] Based on severity of changes, decide whether it's a minor or micro release number bump. + +- [ ] Search for 'XSince: REPLACEME' on the repository and replace it with the chosen version for the release, e.g. 'Since: 1.4.7'. + +- [ ] Make sure you have correct date and new version at the top of NEWS file. + +- [ ] Bump version in line 3 of meson.build and configure.ac. + +- [ ] Do a `meson test -Cbuild` so it both checks the tests and updates hb-version.h (use `git diff` to see if is really updated). + +- [ ] Commit NEWS, meson.build, configure.ac, and src/hb-version.h, as well as any REPLACEME changes you made. + The commit message is simply the release number, e. g. "1.4.7" + +- [ ] Do a `meson dist -Cbuild` that runs the tests against the latest committed changes. + If doesn't pass, something fishy is going on, reset the repo and start over. + +- [ ] Tag the release and sign it: e.g. `git tag -s 1.4.7 -m 1.4.7`. + Enter your GPG password. + +- [ ] Push the commit and tag out: `git push --follow-tags`. diff --git a/third_party/harfbuzz-ng/src/SECURITY.md b/third_party/harfbuzz-ng/src/SECURITY.md new file mode 100644 index 000000000000..69bb04456caf --- /dev/null +++ b/third_party/harfbuzz-ng/src/SECURITY.md @@ -0,0 +1,20 @@ +# Security Policy + +If you have discovered a security vulnerability in this project, please report it +privately. **Do not disclose it as a public issue.** This gives me time to work with you +to fix the issue before public exposure, reducing the chance that the exploit will be +used before a patch is released. + +You may submit the report in the following ways: + +- send an email to behdad@behdad.org and harfbuzz-admin@googlegroups.com; and/or +- send me a [private vulnerability report](https://github.com/harfbuzz/harfbuzz/security/advisories/new) + +Please provide the following information in your report: + +- A description of the vulnerability and its impact +- How to reproduce the issue + +This project is mostly maintained by two developers, working on a reasonable effort +basis. As such, we ask that you give us 90 days to work on a fix before public +disclosure. diff --git a/third_party/harfbuzz-ng/src/TESTING.md b/third_party/harfbuzz-ng/src/TESTING.md new file mode 100644 index 000000000000..18d702027edf --- /dev/null +++ b/third_party/harfbuzz-ng/src/TESTING.md @@ -0,0 +1,47 @@ +## Build and Test + +```shell +meson build +ninja -Cbuild +meson test -Cbuild +``` + +### Debug with GDB + +```shell +meson test -Cbuild --gdb testname +``` + +## Build and Run + +Depending on what area you are working in change or add `HB_DEBUG_`. +Values defined in `hb-debug.hh`. + +```shell +CPPFLAGS='-DHB_DEBUG_SUBSET=100' meson setup build --reconfigure +meson test -C build +``` + +### Run tests with asan + +```shell +meson setup build -Db_sanitize=address --reconfigure +meson compile -C build +meson test -C build +``` + +### Enable Debug Logging + +```shell +CPPFLAGS=-DHB_DEBUG_SUBSET=100 meson build --reconfigure +ninja -C build +``` + +## Test with the Fuzzer + +FOr fuzzing, see `test/fuzzing/README.md`. + +## Profiling + +For profiling, see `perf/README.md`. + diff --git a/third_party/harfbuzz-ng/src/THANKS b/third_party/harfbuzz-ng/src/THANKS new file mode 100644 index 000000000000..88cb7e9ea129 --- /dev/null +++ b/third_party/harfbuzz-ng/src/THANKS @@ -0,0 +1,7 @@ +Bradley Grainger +Kenichi Ishibashi +Ivan Kuckir +Ryan Lortie +Jeff Muizelaar +suzuki toshiya +Philip Withnall diff --git a/third_party/harfbuzz-ng/src/autogen.sh b/third_party/harfbuzz-ng/src/autogen.sh new file mode 100755 index 000000000000..085b4d8632d1 --- /dev/null +++ b/third_party/harfbuzz-ng/src/autogen.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. + +olddir=`pwd` +cd $srcdir + +#printf "checking for ragel... " +#which ragel || { +# echo "You need to install ragel... See http://www.complang.org/ragel/" +# exit 1 +#} + +printf "checking for pkg-config... " +which pkg-config || { + echo "*** No pkg-config found, please install it ***" + exit 1 +} + +printf "checking for libtoolize... " +which glibtoolize || which libtoolize || { + echo "*** No libtoolize (libtool) found, please install it ***" + exit 1 +} +printf "checking for gtkdocize... " +if which gtkdocize ; then + gtkdocize --copy || exit 1 +else + echo "*** No gtkdocize (gtk-doc) found, skipping documentation ***" + echo "EXTRA_DIST = " > gtk-doc.make +fi + +printf "checking for autoreconf... " +which autoreconf || { + echo "*** No autoreconf (autoconf) found, please install it ***" + exit 1 +} + +echo "running autoreconf --force --install --verbose" +autoreconf --force --install --verbose || exit $? + +cd $olddir +test -n "$NOCONFIGURE" || { + echo "running configure $@" + "$srcdir/configure" "$@" +} diff --git a/third_party/harfbuzz-ng/src/configure.ac b/third_party/harfbuzz-ng/src/configure.ac new file mode 100644 index 000000000000..c863ab83b0b2 --- /dev/null +++ b/third_party/harfbuzz-ng/src/configure.ac @@ -0,0 +1,486 @@ +AC_PREREQ([2.64]) +AC_INIT([HarfBuzz], + [7.1.0], + [https://github.com/harfbuzz/harfbuzz/issues/new], + [harfbuzz], + [http://harfbuzz.org/]) + +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SRCDIR([src/harfbuzz.pc.in]) +AC_CONFIG_HEADERS([config.h]) + +AM_INIT_AUTOMAKE([1.13.0 gnits tar-ustar dist-xz no-dist-gzip -Wall no-define color-tests -Wno-portability]) +AM_SILENT_RULES([yes]) +AX_CODE_COVERAGE + +# Initialize libtool +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +LT_PREREQ([2.2]) +LT_INIT([disable-static]) + +# Check for programs +AC_PROG_CC +AC_PROG_CC_C99 +AM_PROG_CC_C_O +AC_PROG_CXX +AX_CXX_COMPILE_STDCXX(11) +AC_SYS_LARGEFILE +PKG_PROG_PKG_CONFIG([0.28]) +AM_MISSING_PROG([RAGEL], [ragel]) +AM_MISSING_PROG([GIT], [git]) + +# Version +m4_define(hb_version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]])) +m4_define(hb_version_major,m4_argn(1,hb_version_triplet)) +m4_define(hb_version_minor,m4_argn(2,hb_version_triplet)) +m4_define(hb_version_micro,m4_argn(3,hb_version_triplet)) +HB_VERSION_MAJOR=hb_version_major +HB_VERSION_MINOR=hb_version_minor +HB_VERSION_MICRO=hb_version_micro +HB_VERSION=AC_PACKAGE_VERSION +AC_SUBST(HB_VERSION_MAJOR) +AC_SUBST(HB_VERSION_MINOR) +AC_SUBST(HB_VERSION_MICRO) +AC_SUBST(HB_VERSION) + +# Libtool version +m4_define([hb_version_int], + m4_eval(60000 + hb_version_major*100 + hb_version_minor*10 + hb_version_micro)) +HB_LIBTOOL_VERSION_INFO=hb_version_int:0:hb_version_int +AC_SUBST(HB_LIBTOOL_VERSION_INFO) + +AC_ARG_WITH([libstdc++], + [AS_HELP_STRING([--with-libstdc++=@<:@yes/no@:>@], + [Allow linking with libstdc++ @<:@default=no@:>@])], + [with_libstdcxx=$withval], + [with_libstdcxx=no]) +AM_CONDITIONAL(WITH_LIBSTDCXX, [test "x$with_libstdcxx" = "xyes"]) + +# Documentation +have_gtk_doc=false +m4_ifdef([GTK_DOC_CHECK], [ +GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) + if test "x$enable_gtk_doc" = xyes; then + have_gtk_doc=true + fi +], [ + AM_CONDITIONAL([ENABLE_GTK_DOC], false) +]) + +# Functions and headers +AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale uselocale) +AC_CHECK_HEADERS(unistd.h sys/mman.h stdbool.h xlocale.h) + +# Compiler flags +AC_CANONICAL_HOST +AC_CHECK_ALIGNOF([struct{char;}]) +if test "x$GCC" = "xyes"; then + + # Make symbols link locally + AX_CHECK_LINK_FLAG([[-Bsymbolic-functions]], [LDFLAGS="$LDFLAGS -Bsymbolic-functions"]) + + # Make it possible to not link to libstdc++ + # No threadsafe statics in C++ as we do it ourselves. + # We don't use these features, so it's safe to disable them + # even in the cases where we DO link to libstdc++. + # Put -fno-rtti before $CXXFLAGS such that users can re-enable it + # by overriding CXXFLAGS. + CXXFLAGS="-fno-rtti $CXXFLAGS -fno-exceptions -fno-threadsafe-statics" + + case "$host" in + *-*-mingw*) + ;; + *) + # Hide inline methods + CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden" + ;; + esac + + case "$host" in + arm-*-*) + if test "x$ac_cv_alignof_struct_char__" != x1; then + # Request byte alignment + CXXFLAGS="$CXXFLAGS -mstructure-size-boundary=8" + fi + ;; + esac +fi + +AM_CONDITIONAL(HAVE_GCC, test "x$GCC" = "xyes") + +hb_os_win32=no +AC_MSG_CHECKING([for native Win32]) +case "$host" in + *-*-mingw*) + hb_os_win32=yes + ;; +esac +AC_MSG_RESULT([$hb_os_win32]) +AM_CONDITIONAL(OS_WIN32, test "$hb_os_win32" = "yes") + +have_pthread=false +AX_PTHREAD([have_pthread=true]) +if $have_pthread; then + AC_DEFINE(HAVE_PTHREAD, 1, [Have POSIX threads]) +fi +AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread) + +dnl ========================================================================== + +AC_ARG_WITH(glib, + [AS_HELP_STRING([--with-glib=@<:@yes/no/auto@:>@], + [Use glib @<:@default=auto@:>@])],, + [with_glib=auto]) +have_glib=false +GLIB_DEPS="glib-2.0 >= 2.19.1" +AC_SUBST(GLIB_DEPS) +if test "x$with_glib" = "xyes" -o "x$with_glib" = "xauto"; then + PKG_CHECK_MODULES(GLIB, $GLIB_DEPS, have_glib=true, :) +fi +if test "x$with_glib" = "xyes" -a "x$have_glib" != "xtrue"; then + AC_MSG_ERROR([glib support requested but glib-2.0 not found]) +fi +if $have_glib; then + AC_DEFINE(HAVE_GLIB, 1, [Have glib2 library]) +fi +AM_CONDITIONAL(HAVE_GLIB, $have_glib) + +dnl =========================================================================== + +AC_ARG_WITH(gobject, + [AS_HELP_STRING([--with-gobject=@<:@yes/no/auto@:>@], + [Use gobject @<:@default=no@:>@])],, + [with_gobject=no]) +have_gobject=false +if test "x$with_gobject" = "xyes" -o "x$with_gobject" = "xauto"; then + PKG_CHECK_MODULES(GOBJECT, gobject-2.0 glib-2.0, have_gobject=true, :) +fi +if test "x$with_gobject" = "xyes" -a "x$have_gobject" != "xtrue"; then + AC_MSG_ERROR([gobject support requested but gobject-2.0 / glib-2.0 not found]) +fi +if $have_gobject; then + AC_DEFINE(HAVE_GOBJECT, 1, [Have gobject2 library]) + GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` + AC_SUBST(GLIB_MKENUMS) +fi +AM_CONDITIONAL(HAVE_GOBJECT, $have_gobject) +AC_SUBST(have_gobject) + +dnl =========================================================================== + + +dnl =========================================================================== +# Gobject-Introspection +have_introspection=false +m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [ + if $have_gobject; then + GOBJECT_INTROSPECTION_CHECK([1.34.0]) + if test "x$found_introspection" = xyes; then + have_introspection=true + fi + else + AM_CONDITIONAL([HAVE_INTROSPECTION], false) + fi +], [ + AM_CONDITIONAL([HAVE_INTROSPECTION], false) +]) + +dnl ========================================================================== + +AC_ARG_WITH(cairo, + [AS_HELP_STRING([--with-cairo=@<:@yes/no/auto@:>@], + [Use cairo @<:@default=auto@:>@])],, + [with_cairo=auto]) +have_cairo=false +if test "x$with_cairo" = "xyes" -o "x$with_cairo" = "xauto"; then + PKG_CHECK_MODULES(CAIRO, cairo >= 1.8.0, have_cairo=true, :) + save_libs=$LIBS + LIBS="$LIBS $CAIRO_LIBS" + AC_CHECK_FUNCS(cairo_user_font_face_set_render_color_glyph_func) + LIBS=$save_libs +fi +if test "x$with_cairo" = "xyes" -a "x$have_cairo" != "xtrue"; then + AC_MSG_ERROR([cairo support requested but not found]) +fi +if $have_cairo; then + AC_DEFINE(HAVE_CAIRO, 1, [Have cairo graphics library]) +fi +AM_CONDITIONAL(HAVE_CAIRO, $have_cairo) + +have_cairo_ft=false +if $have_cairo; then + PKG_CHECK_MODULES(CAIRO_FT, cairo-ft, have_cairo_ft=true, :) +fi +if $have_cairo_ft; then + AC_DEFINE(HAVE_CAIRO_FT, 1, [Have cairo-ft support in cairo graphics library]) +fi +AM_CONDITIONAL(HAVE_CAIRO_FT, $have_cairo_ft) + +dnl ========================================================================== + +AC_ARG_WITH(chafa, + [AS_HELP_STRING([--with-chafa=@<:@yes/no/auto@:>@], + [Use chafa @<:@default=auto@:>@])],, + [with_chafa=auto]) +have_chafa=false +if test "x$with_chafa" = "xyes" -o "x$with_chafa" = "xauto"; then + PKG_CHECK_MODULES(CHAFA, chafa >= 1.6.0, have_chafa=true, :) +fi +if test "x$with_chafa" = "xyes" -a "x$have_chafa" != "xtrue"; then + AC_MSG_ERROR([chafa support requested but not found]) +fi +if $have_chafa; then + AC_DEFINE(HAVE_CHAFA, 1, [Have chafa terminal graphics library]) +fi +AM_CONDITIONAL(HAVE_CHAFA, $have_chafa) + +dnl ========================================================================== + +AC_ARG_WITH(icu, + [AS_HELP_STRING([--with-icu=@<:@yes/no/builtin/auto@:>@], + [Use ICU @<:@default=auto@:>@])],, + [with_icu=auto]) +have_icu=false +if test "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" -o "x$with_icu" = "xauto"; then + PKG_CHECK_MODULES(ICU, icu-uc, have_icu=true, :) +fi +if test \( "x$with_icu" = "xyes" -o "x$with_icu" = "xbuiltin" \) -a "x$have_icu" != "xtrue"; then + AC_MSG_ERROR([icu support requested but icu-uc not found]) +fi + +if $have_icu; then + CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`" + AC_DEFINE(HAVE_ICU, 1, [Have ICU library]) + if test "x$with_icu" = "xbuiltin"; then + AC_DEFINE(HAVE_ICU_BUILTIN, 1, [Use hb-icu Unicode callbacks]) + fi +fi +AM_CONDITIONAL(HAVE_ICU, $have_icu) +AM_CONDITIONAL(HAVE_ICU_BUILTIN, $have_icu && test "x$with_icu" = "xbuiltin") + +dnl =========================================================================== + +AC_ARG_WITH(graphite2, + [AS_HELP_STRING([--with-graphite2=@<:@yes/no/auto@:>@], + [Use the graphite2 library @<:@default=no@:>@])],, + [with_graphite2=no]) +have_graphite2=false +GRAPHITE2_DEPS="graphite2 >= 1.2.0" +AC_SUBST(GRAPHITE2_DEPS) +if test "x$with_graphite2" = "xyes" -o "x$with_graphite2" = "xauto"; then + PKG_CHECK_MODULES(GRAPHITE2, $GRAPHITE2_DEPS, have_graphite2=true, :) + if test "x$have_graphite2" != "xtrue"; then + # If pkg-config is not available, graphite2 can still be there + ac_save_CFLAGS="$CFLAGS" + ac_save_CPPFLAGS="$CPPFLAGS" + CFLAGS="$CFLAGS $GRAPHITE2_CFLAGS" + CPPFLAGS="$CPPFLAGS $GRAPHITE2_CFLAGS" + AC_CHECK_HEADER(graphite2/Segment.h, have_graphite2=true, :) + CPPFLAGS="$ac_save_CPPFLAGS" + CFLAGS="$ac_save_CFLAGS" + fi +fi +if test "x$with_graphite2" = "xyes" -a "x$have_graphite2" != "xtrue"; then + AC_MSG_ERROR([graphite2 support requested but libgraphite2 not found]) +fi +if $have_graphite2; then + AC_DEFINE(HAVE_GRAPHITE2, 1, [Have Graphite2 library]) +fi +AM_CONDITIONAL(HAVE_GRAPHITE2, $have_graphite2) + +dnl ========================================================================== + +AC_ARG_WITH(freetype, + [AS_HELP_STRING([--with-freetype=@<:@yes/no/auto@:>@], + [Use the FreeType library @<:@default=auto@:>@])],, + [with_freetype=auto]) +have_freetype=false +FREETYPE_DEPS="freetype2 >= 12.0.6" +AC_SUBST(FREETYPE_DEPS) +if test "x$with_freetype" = "xyes" -o "x$with_freetype" = "xauto"; then + # See freetype/docs/VERSION.DLL; 12.0.6 means freetype-2.4.2 + PKG_CHECK_MODULES(FREETYPE, $FREETYPE_DEPS, have_freetype=true, :) +fi +if test "x$with_freetype" = "xyes" -a "x$have_freetype" != "xtrue"; then + AC_MSG_ERROR([FreeType support requested but libfreetype2 not found]) +fi +if $have_freetype; then + AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library]) + save_libs=$LIBS + LIBS="$LIBS $FREETYPE_LIBS" + AC_CHECK_FUNCS(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var FT_Get_Transform) + LIBS=$save_libs +fi +AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype) + +dnl =========================================================================== + +AC_ARG_WITH(uniscribe, + [AS_HELP_STRING([--with-uniscribe=@<:@yes/no/auto@:>@], + [Use the Uniscribe library @<:@default=no@:>@])],, + [with_uniscribe=no]) +have_uniscribe=false +if test "x$with_uniscribe" = "xyes" -o "x$with_uniscribe" = "xauto"; then + AC_CHECK_HEADERS(usp10.h windows.h, have_uniscribe=true) +fi +if test "x$with_uniscribe" = "xyes" -a "x$have_uniscribe" != "xtrue"; then + AC_MSG_ERROR([uniscribe support requested but not found]) +fi +if $have_uniscribe; then + UNISCRIBE_CFLAGS= + UNISCRIBE_LIBS="-lusp10 -lgdi32 -lrpcrt4" + AC_SUBST(UNISCRIBE_CFLAGS) + AC_SUBST(UNISCRIBE_LIBS) + AC_DEFINE(HAVE_UNISCRIBE, 1, [Have Uniscribe library]) +fi +AM_CONDITIONAL(HAVE_UNISCRIBE, $have_uniscribe) + +dnl =========================================================================== + +AC_ARG_WITH(gdi, + [AS_HELP_STRING([--with-gdi=@<:@yes/no/auto@:>@], + [Provide GDI integration helpers @<:@default=no@:>@])],, + [with_gdi=no]) +have_gdi=false +if test "x$with_gdi" = "xyes" -o "x$with_gdi" = "xauto"; then + AC_CHECK_HEADERS(windows.h, have_gdi=true) +fi +if test "x$with_gdi" = "xyes" -a "x$have_gdi" != "xtrue"; then + AC_MSG_ERROR([gdi support requested but not found]) +fi +if $have_gdi; then + GDI_CFLAGS= + GDI_LIBS="-lgdi32" + AC_SUBST(GDI_CFLAGS) + AC_SUBST(GDI_LIBS) + AC_DEFINE(HAVE_GDI, 1, [Have GDI library]) +fi +AM_CONDITIONAL(HAVE_GDI, $have_gdi) + +dnl =========================================================================== + +AC_ARG_WITH(directwrite, + [AS_HELP_STRING([--with-directwrite=@<:@yes/no/auto@:>@], + [Use the DirectWrite library (experimental) @<:@default=no@:>@])],, + [with_directwrite=no]) +have_directwrite=false +AC_LANG_PUSH([C++]) +if test "x$with_directwrite" = "xyes" -o "x$with_directwrite" = "xauto"; then + AC_CHECK_HEADERS(dwrite_1.h, have_directwrite=true) +fi +AC_LANG_POP([C++]) +if test "x$with_directwrite" = "xyes" -a "x$have_directwrite" != "xtrue"; then + AC_MSG_ERROR([directwrite support requested but not found]) +fi +if $have_directwrite; then + AC_DEFINE(HAVE_DIRECTWRITE, 1, [Have DirectWrite library]) +fi +AM_CONDITIONAL(HAVE_DIRECTWRITE, $have_directwrite) + +dnl =========================================================================== + +AC_ARG_WITH(coretext, + [AS_HELP_STRING([--with-coretext=@<:@yes/no/auto@:>@], + [Use CoreText @<:@default=no@:>@])],, + [with_coretext=no]) +have_coretext=false +if test "x$with_coretext" = "xyes" -o "x$with_coretext" = "xauto"; then + AC_CHECK_TYPE(CTFontRef, have_coretext=true,, [#include ]) + + if $have_coretext; then + CORETEXT_CFLAGS= + CORETEXT_LIBS="-framework ApplicationServices" + AC_SUBST(CORETEXT_CFLAGS) + AC_SUBST(CORETEXT_LIBS) + else + # On iOS CoreText and CoreGraphics are stand-alone frameworks + if test "x$have_coretext" != "xtrue"; then + # Check for a different symbol to avoid getting cached result. + AC_CHECK_TYPE(CTRunRef, have_coretext=true,, [#include ]) + fi + + if $have_coretext; then + CORETEXT_CFLAGS= + CORETEXT_LIBS="-framework CoreText -framework CoreGraphics -framework CoreFoundation" + AC_SUBST(CORETEXT_CFLAGS) + AC_SUBST(CORETEXT_LIBS) + fi + fi +fi +if test "x$with_coretext" = "xyes" -a "x$have_coretext" != "xtrue"; then + AC_MSG_ERROR([CoreText support requested but libcoretext not found]) +fi +if $have_coretext; then + AC_DEFINE(HAVE_CORETEXT, 1, [Have Core Text backend]) +fi +AM_CONDITIONAL(HAVE_CORETEXT, $have_coretext) + +dnl =========================================================================== + +AC_CONFIG_FILES([ +Makefile +src/Makefile +src/harfbuzz-config.cmake +util/Makefile +test/Makefile +test/api/Makefile +test/fuzzing/Makefile +test/shape/Makefile +test/shape/data/Makefile +test/shape/data/aots/Makefile +test/shape/data/in-house/Makefile +test/shape/data/text-rendering-tests/Makefile +test/subset/Makefile +test/subset/data/Makefile +test/subset/data/repack_tests/Makefile +test/threads/Makefile +perf/Makefile +docs/Makefile +docs/version.xml +]) + +AC_OUTPUT + +echo +echo "C++ compiler version:" +$CXX --version +echo + +AC_MSG_NOTICE([ + +Autotools is no longer our supported build system for building the library +for *nix distributions, please migrate to meson. + +]) + + +AC_MSG_NOTICE([ + +Build configuration: + +Unicode callbacks (you want at least one): + Builtin true + Glib: ${have_glib} + ICU: ${have_icu} + +Font callbacks (the more the merrier): + FreeType: ${have_freetype} + +Tools used for command-line utilities: + Cairo: ${have_cairo} + Chafa: ${have_chafa} + +Additional shapers: + Graphite2: ${have_graphite2} + +Platform shapers (not normally needed): + CoreText: ${have_coretext} + DirectWrite: ${have_directwrite} + GDI: ${have_gdi} + Uniscribe: ${have_uniscribe} + +Other features: + Documentation: ${enable_gtk_doc} + GObject bindings: ${have_gobject} + Introspection: ${have_introspection} +]) diff --git a/third_party/harfbuzz-ng/src/docs/HarfBuzz.png b/third_party/harfbuzz-ng/src/docs/HarfBuzz.png new file mode 100644 index 000000000000..c9d2e7b6f5b6 Binary files /dev/null and b/third_party/harfbuzz-ng/src/docs/HarfBuzz.png differ diff --git a/third_party/harfbuzz-ng/src/docs/HarfBuzz.svg b/third_party/harfbuzz-ng/src/docs/HarfBuzz.svg new file mode 100644 index 000000000000..beb13addf359 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/HarfBuzz.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/third_party/harfbuzz-ng/src/docs/Makefile.am b/third_party/harfbuzz-ng/src/docs/Makefile.am new file mode 100644 index 000000000000..a9de8eb42181 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/Makefile.am @@ -0,0 +1,123 @@ +# Process this file with automake to produce Makefile.in + +# We require automake 1.6 at least. +AUTOMAKE_OPTIONS = 1.6 + +# This is a blank Makefile.am for using gtk-doc. +# Copy this to your project's API docs directory and modify the variables to +# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples +# of using the various options. + +# The name of the module, e.g. 'glib'. +DOC_MODULE=harfbuzz + +# Uncomment for versioned docs and specify the version of the module, e.g. '2'. +#DOC_MODULE_VERSION=$(HB_VERSION_MAJOR) + +# The top-level SGML file. You can change this if you want to. +DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml + +# Directories containing the source code. +# gtk-doc will search all .c and .h files beneath these paths +# for inline comments documenting functions and macros. +# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk +DOC_SOURCE_DIR=$(top_srcdir)/src $(top_builddir)/src + +# Extra options to pass to gtkdoc-scangobj. Not normally needed. +SCANGOBJ_OPTIONS= + +# Extra options to supply to gtkdoc-scan. +# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" +SCAN_OPTIONS=--rebuild-types --deprecated-guards="HB_DISABLE_DEPRECATED" \ + --ignore-decorators='HB_EXTERN|HB_DEPRECATED|HB_DEPRECATED_FOR()' + +# Header files or dirs to ignore when scanning. Use base file/dir names +# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code +IGNORE_HFILES=`cd $(top_srcdir)/src; find . -path './*/*.h' | sed 's@^.*/@@'` +IGNORE_HFILES+=hb-gobject.h hb-gobject-enums.h hb-gobject-structs.h + +# Extra options to supply to gtkdoc-mkdb. +# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml +MKDB_OPTIONS=--source-suffixes=h,cc --xml-mode --output-format=xml --ignore-files="$(IGNORE_HFILES)" + +# Extra options to supply to gtkdoc-mktmpl +# e.g. MKTMPL_OPTIONS=--only-section-tmpl +MKTMPL_OPTIONS= + +# Extra options to supply to gtkdoc-mkhtml +MKHTML_OPTIONS= + +# Extra options to supply to gtkdoc-fixref. Not normally needed. +# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html +FIXXREF_OPTIONS= + +# Used for dependencies. The docs will be rebuilt if any of these change. +# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h +# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c +HFILE_GLOB=$(top_srcdir)/src/hb.h $(top_srcdir)/src/hb-*.h +CFILE_GLOB=$(top_srcdir)/src/hb-*.cc + +# Extra header to include when scanning, which are not under DOC_SOURCE_DIR +# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h + +# Images to copy into HTML directory. +# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png +HTML_IMAGES= \ + HarfBuzz.png \ + HarfBuzz.svg + +# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). +# e.g. content_files=running.sgml building.sgml changes-2.0.sgml +content_files= \ + usermanual-what-is-harfbuzz.xml \ + usermanual-install-harfbuzz.xml \ + usermanual-getting-started.xml \ + usermanual-glyph-information.xml \ + usermanual-shaping-concepts.xml \ + usermanual-object-model.xml \ + usermanual-buffers-language-script-and-direction.xml \ + usermanual-fonts-and-faces.xml \ + usermanual-opentype-features.xml \ + usermanual-clusters.xml \ + usermanual-utilities.xml \ + usermanual-integration.xml \ + version.xml + +# SGML files where gtk-doc abbreviations (#GtkWidget) are expanded +# These files must be listed here *and* in content_files +# e.g. expand_content_files=running.sgml +expand_content_files= + +# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. +# Only needed if you are using gtkdoc-scangobj to dynamically query widget +# signals and properties. +# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) +# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) +GTKDOC_CFLAGS= +GTKDOC_LIBS=$(top_builddir)/src/libharfbuzz.la +if HAVE_GOBJECT +GTKDOC_LIBS+=$(top_builddir)/src/libharfbuzz-gobject.la +endif + +# This includes the standard gtk-doc make rules, copied by gtkdocize. +include $(top_srcdir)/gtk-doc.make + +# Other files to distribute +# e.g. EXTRA_DIST += version.xml.in +EXTRA_DIST += version.xml.in meson.build + +# Files not to distribute +# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types +# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt +#DISTCLEANFILES += + +# Comment this out if you don't want 'make check' to test you doc status +# and run some sanity checks +if ENABLE_GTK_DOC +TESTS_ENVIRONMENT = cd $(srcdir) && \ + DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ + SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) +#TESTS = $(GTKDOC_CHECK) +endif + +-include $(top_srcdir)/git.mk diff --git a/third_party/harfbuzz-ng/src/docs/features.dot b/third_party/harfbuzz-ng/src/docs/features.dot new file mode 100644 index 000000000000..88cb3faebdd5 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/features.dot @@ -0,0 +1,259 @@ +digraph { + graph [outputorder=edgefirst]; + node [shape="record", fontname="Noto Sans Mono SemiBold", fontsize=15]; + edge [fontname="Verdana", fontsize=12,labeldistance=7.5 ]; + fontname="Verdana"; + ranksep=0.02; nodesep=0.5; + +subgraph { + ranksep="0.02 equally"; + preprocessing[style=filled,fillcolor="lightgreen",fontname="Verdana",label="Glyph pre-processing"]; + orthographic[style=filled,fillcolor="lightblue",fontname="Verdana",label="Orthographic Unit Shaping"]; + reordering[style=filled, fillcolor="lightcoral",fontname="Verdana",label="Reordering group (USE)"]; + topographic[style=filled,fillcolor="lightgoldenrod",fontname="Verdana",label="Topographical Features‡"]; + typographic[style=filled,fillcolor="lightpink",fontname="Verdana",label="Typographic Presentation"]; + positioning[style=filled,fillcolor="lightsalmon",fontname="Verdana",label="Positioning"]; + preprocessing->reordering->orthographic->topographic->typographic->positioning; +} + + decision1 [shape="diamond", label="Script\ndirection?",fontname="Verdana"]; + rvrn->decision1; + + ltrfeatures [label="{ltra|ltrm}", fillcolor="lightgreen",style="filled"]; + { + rtlfeatures [label="{rtla|rtlm¹}", fillcolor="lightgreen",style="filled"]; + } + { + rank=same; + fracfeatures [label="frac²|numr³|dnomâ´", fillcolor="lightpink",style="filled"]; + fracnotes [fontname="Verdana",shape=plaintext,label=< + + + + +
      ¹ rtlm is scoped to characters with a Unicode mirroring property
      ² frac is scoped to numr + the slash + dnom
      ³ numr is scoped to all decimal numbers before a U+2044 FRACTION SLASH.
      â´ dnom is scoped to all decimal numbers after a U+2044 FRACTION SLASH.
      + >]; + + } + rand [fillcolor="lightpink",style="filled"]; + + decision1 -> ltrfeatures [label="Left-to-right"]; + decision1 -> rtlfeatures [label="Right-to-left"]; + + decision1 -> fracfeatures [label="Other"]; + + ltrfeatures -> fracfeatures; + rtlfeatures -> fracfeatures; + fracfeatures->rand; + + decision2 [shape="diamond", label="Script?",fontname="Verdana"]; + +{rank=same; HARF [label="{Harf|HARF}"]; notes;} + rand -> trak -> HARF -> decision2; + + commonfeatures [shape=none,label=< + + + + + + + + + +
      abvmblwmccmploclmarkmkmkrlig
      > + ]; + + decision3 [shape="diamond", label="Script\ndirection?",fontname="Verdana"]; + + BUZZ [label="{Buzz|BUZZ}"]; + BUZZ -> commonfeatures -> decision3; + + horizontalfeatures [ + shape=none,label=< + + + + + + + +
      calt (not Hangul)
      clig (not Khmer)
      curs
      dist
      kern
      liga (not Khmer)
      rclt
      > + ]; + vert [label="vert",style=filled,fillcolor="lightpink"]; + + decision3 -> horizontalfeatures [label="Horizontal"]; + decision3 -> vert [label="Vertical"]; + + discretionary [label="User-selected\ndiscretionary\nfeatures",fontname="Verdana"]; + + horizontalfeatures -> discretionary; + vert -> discretionary; + + decision2->stch; + + BUZZ; + +subgraph shapers { + subgraph cluster_arabic { + bgcolor="lightyellow" + label="Arabic, Syriac"; + stch [ style="filled", fillcolor="lightgreen",label="stch"]; + ccmplocl [ style="filled", label="ccmp|locl", fillcolor="lightgreen"]; + arabicfeatures [label="isol|fina|fin2|fin3|medi|med2|init", style="filled", fillcolor="lightgoldenrod"]; + arabicfeatures2 [label="rclt|calt", style="filled",fillcolor="lightpink"]; +rlig[style="filled",fillcolor="lightpink"]; +mset [fillcolor="lightpink",style="filled"] + stch->ccmplocl->arabicfeatures->rlig->arabicfeatures2->mset; + } + mset->BUZZ:n; + + subgraph cluster_hangul { + bgcolor="lightyellow" + label="Hangul"; + hangulfeatures [label="ljmo|vjmo|tjmo", style="filled",fillcolor="lightgoldenrod"] + } + hangulfeatures->BUZZ:n; + + subgraph cluster_indic { + label="Indic"; + bgcolor="lightyellow" + // Preprocessing + loclccmpindic [label="locl†|ccmp†",style=filled,fillcolor="lightgreen"]; + node[style=filled,fillcolor="lightgreen"]; + nukt [label="nukt†"]; + akhn [label="akhn†"]; + loclccmpindic->indic_reorder_1->nukt->akhn; + indic_reorder_1[label="Initial reordering", fontname="Verdana",fillcolor="lightgrey",shape=ellipse,style=filled] + + // Orthographic + node[style=filled,fillcolor="lightblue"] + rphf [label="rphfâµ"]; + rkpf [label="rkpf†"]; + pref [label="prefâ¶"]; + blwf [label="blwfâ·"]; + abvf [label="abvfâ¸"]; + half [label="halfâ¹"]; + pstf [label="pstfâ¸"]; + vatu [label="vatu†"]; + cjct [label="cjct†"]; + akhn ->rphf -> rkpf -> pref -> blwf -> abvf -> half -> pstf -> vatu -> cjct; + // Typographic presentation + indic_typographic[style=filled,fillcolor="lightpink",label="init|pres|abvs|blws|psts|haln"] + indic_reorder_2[label="Final reordering",fillcolor="lightgrey",fontname="Verdana", shape=ellipse,style=filled] + cjct->indic_reorder_2->indic_typographic; + + notes2 [fontname="Verdana",shape=plaintext,style="",label=< + + + + + +
      âµ rphf is scoped to pre-base ra+halant sequences
      ⶠpref is scoped to the two glyphs after the base; outputs are reordered
      â· blwf is usually scoped to the whole syllable, except in Telugu and Kannada where it is post-base
      ⸠abvf and pstf are scoped to post-base
      â¹ half is scoped to pre-base
      +>]; + indic_typographic -> notes2 [style=invis]; + } + + + subgraph cluster_khmer { + label="Khmer"; + bgcolor="lightyellow" + + khmerbasic [style=filled,fillcolor="lightgreen",label="locl†|ccmp†|pref†|bwlf†|abvf†|pstf†|cfar†"] + khmerother [style=filled,fillcolor="lightpink",label="pres|abvs|blws|psts"] + khmerbasic -> khmerother -> khmerclig; + khmerclig [label="clig",style=filled,fillcolor="lightpink"]; + } + + subgraph cluster_myanmar { + label="Myanmar"; + bgcolor="lightyellow" + loclccmpmyanmar [label="locl†|ccmp†",style=filled,fillcolor="lightgreen"]; + rphfmymr [label="rphf†",style=filled,fillcolor="lightblue"] + prefmymr [label="pref†",style=filled,fillcolor="lightblue"] + blwfmymr [label="blwf†",style=filled,fillcolor="lightblue"] + pstfmymr [label="pstf†",style=filled,fillcolor="lightblue"] + myanmarother [label="pres|abvs|blws|psts",style=filled,fillcolor="lightpink"]; + reorder_myanmar[label="Reordering", shape=ellipse,style=filled,fontname="Verdana"] + loclccmpmyanmar -> reorder_myanmar-> rphfmymr -> prefmymr -> blwfmymr -> pstfmymr -> myanmarother; + } + + subgraph cluster_use { + label="Universal Shaping Engine" + bgcolor="lightyellow" + use_preprocessing [style=filled, label="locl†|ccmp†|nukt†|akhn†", fillcolor="lightgreen"]; + // Reoredering + rphfuse [label="rphf¹â°", style=filled, fillcolor="lightcoral"]; + prefuse [label="pref¹¹", style=filled, fillcolor="lightcoral"]; + // Orthographic + orthographicuse [label="rkrf†|abvf†|blwf†|half†|pstf†|vatu†|cjct†", style="filled", fillcolor="lightblue"]; + topographicaluse [label="isol|init|medi|fina", style="filled", fillcolor="lightgoldenrod"]; + typographicaluse [label="abvs|blws|haln|pres|psts", style="filled", fillcolor="lightpink"]; + reorder_use[label="Reordering", shape=ellipse,style=filled,fontname="Verdana"] + use_preprocessing -> rphfuse -> prefuse->orthographicuse ->reorder_use -> topographicaluse -> typographicaluse; + notes3 [fontname="Verdana",shape=plaintext,label=< + + +
      ¹ⰠOutputs are reordered as category R
      ¹¹ Outputs are reordered to before base
      + >]; + typographicaluse -> notes3 [style=invis]; + } + +} + + indic_typographic->BUZZ:n; + typographicaluse->BUZZ:n; + khmerclig -> BUZZ:n; + myanmarother -> BUZZ:n; + + + decision2->hangulfeatures; + decision2->loclccmpindic; + decision2->khmerbasic; + decision2->loclccmpmyanmar; + decision2->use_preprocessing; + decision2->BUZZ [label=" Hebrew, Thai,\n Lao, other"]; + +notes [fontname="Verdana",shape=box,label=< + + + + + + + + + +
      +Indic scripts are: Bengali, Devanagari, + Gujarati, Gurmukhi, Kannada, + Malayalam, Oriya, Tamil, + Telugu +
      +USE scripts are: + Adlam, Ahom, Balinese, Batak, Bhaiksuki, Brahmi, Buginese, + Buhid, Chakma, Cham, Chorasmian, Dives Akuru, Dogra, Duployan, +
      +Egyptian hieroglyphs, Elymaic, Grantha, Gunjala Ggondi, Hanifi Rohingya, + Hanunoo, Javanese, Kaithi, Kayah li, Kharoshthi, Khojki, +
      +Khudawadi, Lepcha, Limbu, Mahajani, Makasar, Mandaic, Manichaean, + Marchen, Masaram Gondi, Medefaidrin, Meetei Mayek, Miao, Modi, +
      +Mongolian, Multani, Nandinagari, Newa, Nko, Nyiakeng Puachue Hmong, + Old Sogdian, Pahawh Hmong, Phags Pa, Psalter Pahlavi, Rejang, +
      +Saurashtra, Sharada, Siddham, Sinhala, Sogdian, Soyombo, Sundanese, + Syloti Nagri, Tagalog, Tagbanwa, Tai Le, Tai Tham, Tai Viet, +
      +Takri, Tibetan, Tifinagh, Tirhuta, Wancho, Zanabazar square, +
      >] + + + footnote[fontname="Verdana",label=< + + +
      † Feature is scoped to each syllable
      ‡ All topographic features are scoped based on topographic position
      >]; + notes3->footnote[style=invis]; + +} diff --git a/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml b/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml new file mode 100644 index 000000000000..e67ea8c39049 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/harfbuzz-docs.xml @@ -0,0 +1,219 @@ + + + +]> + + + HarfBuzz Manual + + HarfBuzz + + + HarfBuzz is a text shaping library. Using the HarfBuzz library allows + programs to convert a sequence of Unicode input into + properly formatted and positioned glyph output—for any writing + system and language. + + + + The canonical source-code tree is available at + github.com/harfbuzz/harfbuzz. + See for + release tarballs. + + + + + + User's manual + + + + + + + + + + + + + + + + + This document is for HarfBuzz &version;. + + + + + Reference manual + + Core API + + + + + + + + + + + + + + + + + + + OpenType API + + + + + + + + + + + + + Apple Advanced Typography API + + + + + Integration API + + + + + + + + + + + + + Style API + + + + + Subset API + + + + + + + API Index + Index of deprecated API + + Index of new symbols in 7.1.0 + Index of new symbols in 7.0.0 + Index of new symbols in 6.0.0 + Index of new symbols in 5.3.0 + Index of new symbols in 5.0.0 + Index of new symbols in 4.4.0 + Index of new symbols in 4.3.0 + Index of new symbols in 4.2.0 + Index of new symbols in 4.1.0 + Index of new symbols in 4.0.0 + Index of new symbols in 3.4.0 + Index of new symbols in 3.3.0 + Index of new symbols in 3.1.0 + Index of new symbols in 3.0.0 + Index of new symbols in 2.9.1 + Index of new symbols in 2.9.0 + Index of new symbols in 2.8.2 + Index of new symbols in 2.7.3 + Index of new symbols in 2.6.8 + Index of new symbols in 2.6.5 + Index of new symbols in 2.6.3 + Index of new symbols in 2.6.0 + Index of new symbols in 2.5.0 + Index of new symbols in 2.4.0 + Index of new symbols in 2.3.0 + Index of new symbols in 2.2.0 + Index of new symbols in 2.1.0 + Index of new symbols in 2.0.0 + Index of new symbols in 1.9.0 + Index of new symbols in 1.8.6 + Index of new symbols in 1.8.5 + Index of new symbols in 1.8.1 + Index of new symbols in 1.8.0 + Index of new symbols in 1.7.7 + Index of new symbols in 1.7.2 + Index of new symbols in 1.6.0 + Index of new symbols in 1.5.0 + Index of new symbols in 1.4.3 + Index of new symbols in 1.4.2 + Index of new symbols in 1.4.0 + Index of new symbols in 1.3.3 + Index of new symbols in 1.2.3 + Index of new symbols in 1.1.3 + Index of new symbols in 1.1.2 + Index of new symbols in 1.0.5 + Index of new symbols in 0.9.42 + Index of new symbols in 0.9.41 + Index of new symbols in 0.9.39 + Index of new symbols in 0.9.38 + Index of new symbols in 0.9.33 + Index of new symbols in 0.9.31 + Index of new symbols in 0.9.30 + Index of new symbols in 0.9.28 + Index of new symbols in 0.9.26 + Index of new symbols in 0.9.22 + Index of new symbols in 0.9.21 + Index of new symbols in 0.9.20 + Index of new symbols in 0.9.11 + Index of new symbols in 0.9.10 + Index of new symbols in 0.9.8 + Index of new symbols in 0.9.7 + Index of new symbols in 0.9.5 + Index of new symbols in 0.9.2 + Index of new symbols in 0.6.0 + + + + + + + The current HarfBuzz codebase is stable + and under active maintenance. This is what is used in latest + versions of Firefox, GNOME, ChromeOS, Chrome, LibreOffice, + XeTeX, Android, and KDE, among other places. + + + Prior to 2012, the original HarfBuzz codebase (which, these days, is + referred to as harfbuzz-old) was derived from code + in FreeType, + Pango, and + Qt. + It is not actively developed or maintained, and is + extremely buggy. All users of harfbuzz-old are encouraged to switch over + to the new HarfBuzz as soon as possible. + + + To make this distinction clearer in discussions, the current HarfBuzz + codebase is sometimes referred to as harfbuzz-ng. + + + For reference purposes, the harfbuzz-old source tree is archived + here. + There are no release tarballs of harfbuzz-old whatsoever. + + + + diff --git a/third_party/__init__.py b/third_party/harfbuzz-ng/src/docs/harfbuzz-overrides.txt similarity index 100% rename from third_party/__init__.py rename to third_party/harfbuzz-ng/src/docs/harfbuzz-overrides.txt diff --git a/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt b/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt new file mode 100644 index 000000000000..abed39fee8a2 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/harfbuzz-sections.txt @@ -0,0 +1,913 @@ +
      + +HB_H_IN +HB_OT_H_IN +HB_AAT_H_IN +
      + +
      +hb-aat-layout +HB_AAT_LAYOUT_NO_SELECTOR_INDEX +hb_aat_layout_feature_type_t +hb_aat_layout_feature_selector_t +hb_aat_layout_feature_selector_info_t +hb_aat_layout_feature_type_get_name_id +hb_aat_layout_feature_type_get_selector_infos +hb_aat_layout_get_feature_types +hb_aat_layout_has_positioning +hb_aat_layout_has_substitution +hb_aat_layout_has_tracking +
      + +
      +hb-blob +hb_blob_create +hb_blob_create_or_fail +hb_blob_create_from_file +hb_blob_create_from_file_or_fail +hb_blob_create_sub_blob +hb_blob_copy_writable_or_fail +hb_blob_get_empty +hb_blob_reference +hb_blob_destroy +hb_blob_set_user_data +hb_blob_get_user_data +hb_blob_make_immutable +hb_blob_is_immutable +hb_blob_get_data +hb_blob_get_data_writable +hb_blob_get_length +hb_blob_t +hb_memory_mode_t +
      + +
      +hb-buffer +hb_buffer_create +hb_buffer_allocation_successful +hb_buffer_create_similar +hb_buffer_get_empty +hb_buffer_reference +hb_buffer_destroy +hb_buffer_set_user_data +hb_buffer_get_user_data +hb_buffer_reset +hb_buffer_clear_contents +hb_buffer_pre_allocate +hb_buffer_add +hb_buffer_add_codepoints +hb_buffer_add_utf32 +hb_buffer_add_utf16 +hb_buffer_add_utf8 +hb_buffer_add_latin1 +hb_buffer_append +hb_buffer_set_content_type +hb_buffer_get_content_type +hb_buffer_set_direction +hb_buffer_get_direction +hb_buffer_set_script +hb_buffer_get_script +hb_buffer_set_language +hb_buffer_get_language +hb_buffer_set_flags +hb_buffer_get_flags +hb_buffer_set_cluster_level +hb_buffer_get_cluster_level +hb_buffer_set_length +hb_buffer_get_length +hb_buffer_set_segment_properties +hb_buffer_get_segment_properties +hb_buffer_guess_segment_properties +hb_buffer_set_unicode_funcs +hb_buffer_get_unicode_funcs +hb_buffer_get_glyph_infos +hb_glyph_info_get_glyph_flags +hb_buffer_get_glyph_positions +hb_buffer_has_positions +hb_buffer_set_invisible_glyph +hb_buffer_get_invisible_glyph +hb_buffer_set_not_found_glyph +hb_buffer_get_not_found_glyph +hb_buffer_set_replacement_codepoint +hb_buffer_get_replacement_codepoint +hb_buffer_normalize_glyphs +hb_buffer_reverse +hb_buffer_reverse_range +hb_buffer_reverse_clusters +hb_buffer_serialize +hb_buffer_serialize_glyphs +hb_buffer_deserialize_glyphs +hb_buffer_serialize_unicode +hb_buffer_deserialize_unicode +hb_buffer_serialize_format_from_string +hb_buffer_serialize_format_to_string +hb_buffer_serialize_list_formats +hb_segment_properties_equal +hb_segment_properties_hash +hb_segment_properties_overlay +hb_buffer_diff +hb_buffer_message_func_t +hb_buffer_set_message_func +HB_SEGMENT_PROPERTIES_DEFAULT +HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT +hb_buffer_t +hb_glyph_info_t +hb_glyph_flags_t +hb_glyph_position_t +hb_buffer_content_type_t +hb_buffer_flags_t +hb_buffer_cluster_level_t +hb_segment_properties_t +hb_buffer_serialize_format_t +hb_buffer_serialize_flags_t +hb_buffer_diff_flags_t +
      + +
      +hb-common +HB_TAG +HB_UNTAG +hb_tag_from_string +hb_tag_to_string +hb_direction_from_string +hb_direction_to_string +HB_DIRECTION_REVERSE +HB_DIRECTION_IS_BACKWARD +HB_DIRECTION_IS_FORWARD +HB_DIRECTION_IS_HORIZONTAL +HB_DIRECTION_IS_VALID +HB_DIRECTION_IS_VERTICAL +hb_script_from_iso15924_tag +hb_script_to_iso15924_tag +hb_script_from_string +hb_script_get_horizontal_direction +hb_language_from_string +hb_language_to_string +hb_language_get_default +hb_language_matches +hb_feature_from_string +hb_feature_to_string +hb_variation_from_string +hb_variation_to_string +hb_bool_t +hb_codepoint_t +hb_destroy_func_t +hb_direction_t +hb_language_t +hb_feature_t +hb_variation_t +hb_mask_t +hb_position_t +hb_tag_t +hb_script_t +hb_user_data_key_t +HB_TAG_NONE +HB_TAG_MAX +HB_TAG_MAX_SIGNED +HB_LANGUAGE_INVALID +HB_FEATURE_GLOBAL_END +HB_FEATURE_GLOBAL_START + +HB_BEGIN_DECLS +HB_END_DECLS +hb_var_int_t +hb_var_num_t +int16_t +int32_t +int64_t +int8_t +uint16_t +uint32_t +uint64_t +uint8_t +HB_EXTERN +HB_DEPRECATED +HB_DEPRECATED_FOR +
      + +
      +hb-features +HB_HAS_CAIRO +HB_HAS_CORETEXT +HB_HAS_DIRECTWRITE +HB_HAS_FREETYPE +HB_HAS_GDI +HB_HAS_GLIB +HB_HAS_GOBJECT +HB_HAS_GRAPHITE +HB_HAS_ICU +HB_HAS_UNISCRIBE +
      + +
      +hb-draw +hb_draw_funcs_create +hb_draw_funcs_get_empty +hb_draw_funcs_reference +hb_draw_funcs_destroy +hb_draw_funcs_set_user_data +hb_draw_funcs_get_user_data +hb_draw_funcs_make_immutable +hb_draw_funcs_is_immutable +hb_draw_move_to_func_t +hb_draw_funcs_set_move_to_func +hb_draw_line_to_func_t +hb_draw_funcs_set_line_to_func +hb_draw_quadratic_to_func_t +hb_draw_funcs_set_quadratic_to_func +hb_draw_cubic_to_func_t +hb_draw_funcs_set_cubic_to_func +hb_draw_close_path_func_t +hb_draw_funcs_set_close_path_func +hb_draw_move_to +hb_draw_line_to +hb_draw_quadratic_to +hb_draw_cubic_to +hb_draw_close_path +HB_DRAW_STATE_DEFAULT +hb_draw_funcs_t +hb_draw_state_t +
      + +
      +hb-paint +hb_paint_funcs_t +hb_paint_funcs_create +hb_paint_funcs_get_empty +hb_paint_funcs_reference +hb_paint_funcs_destroy +hb_paint_funcs_set_user_data +hb_paint_funcs_get_user_data +hb_paint_funcs_make_immutable +hb_paint_funcs_is_immutable + +hb_paint_push_transform_func_t +hb_paint_funcs_set_push_transform_func +hb_paint_pop_transform_func_t +hb_paint_funcs_set_pop_transform_func +hb_paint_push_clip_glyph_func_t +hb_paint_funcs_set_push_clip_glyph_func +hb_paint_push_clip_rectangle_func_t +hb_paint_funcs_set_push_clip_rectangle_func +hb_paint_pop_clip_func_t +hb_paint_funcs_set_pop_clip_func +hb_paint_color_func_t +hb_paint_funcs_set_color_func +HB_PAINT_IMAGE_FORMAT_PNG +HB_PAINT_IMAGE_FORMAT_SVG +HB_PAINT_IMAGE_FORMAT_BGRA +hb_paint_image_func_t +hb_paint_funcs_set_image_func +hb_color_line_t +hb_color_stop_t +hb_color_line_get_color_stops_func_t +hb_color_line_get_color_stops +hb_paint_extend_t +hb_color_line_get_extend_func_t +hb_color_line_get_extend +hb_paint_linear_gradient_func_t +hb_paint_funcs_set_linear_gradient_func +hb_paint_radial_gradient_func_t +hb_paint_funcs_set_radial_gradient_func +hb_paint_sweep_gradient_func_t +hb_paint_funcs_set_sweep_gradient_func +hb_paint_composite_mode_t +hb_paint_push_group_func_t +hb_paint_funcs_set_push_group_func +hb_paint_pop_group_func_t +hb_paint_funcs_set_pop_group_func +hb_paint_custom_palette_color_func_t +hb_paint_funcs_set_custom_palette_color_func + +hb_paint_push_transform +hb_paint_pop_transform +hb_paint_push_clip_glyph +hb_paint_push_clip_rectangle +hb_paint_pop_clip +hb_paint_color +hb_paint_image +hb_paint_linear_gradient +hb_paint_radial_gradient +hb_paint_sweep_gradient +hb_paint_push_group +hb_paint_pop_group +hb_paint_custom_palette_color +
      + +
      +hb-deprecated +HB_BUFFER_FLAGS_DEFAULT +HB_BUFFER_SERIALIZE_FLAGS_DEFAULT +HB_SCRIPT_CANADIAN_ABORIGINAL +hb_font_funcs_set_glyph_func +hb_font_get_glyph_func_t +HB_MATH_GLYPH_PART_FLAG_EXTENDER +HB_OT_MATH_SCRIPT +hb_ot_layout_table_choose_script +hb_ot_layout_table_find_script +hb_ot_tag_from_language +hb_ot_tags_from_script +HB_OT_VAR_NO_AXIS_INDEX +hb_ot_var_axis_t +hb_ot_var_find_axis +hb_ot_var_get_axes +hb_unicode_eastasian_width_func_t +hb_unicode_eastasian_width +hb_unicode_funcs_set_eastasian_width_func +HB_UNICODE_MAX_DECOMPOSITION_LEN +hb_unicode_decompose_compatibility_func_t +hb_unicode_decompose_compatibility +hb_unicode_funcs_set_decompose_compatibility_func +hb_font_funcs_set_glyph_v_kerning_func +hb_font_get_glyph_v_kerning +hb_font_get_glyph_v_kerning_func_t +
      + +
      +hb-coretext +HB_CORETEXT_TAG_KERX +HB_CORETEXT_TAG_MORT +HB_CORETEXT_TAG_MORX +hb_coretext_face_create +hb_coretext_font_create +hb_coretext_face_get_cg_font +hb_coretext_font_get_ct_font +
      + +
      +hb-directwrite +hb_directwrite_face_create +hb_directwrite_face_get_font_face +
      + +
      +hb-face +hb_face_count +hb_face_t +hb_face_create +hb_face_create_for_tables +hb_face_get_empty +hb_face_reference +hb_face_destroy +hb_face_set_user_data +hb_face_get_user_data +hb_face_make_immutable +hb_face_is_immutable +hb_face_get_table_tags +hb_face_set_glyph_count +hb_face_get_glyph_count +hb_face_set_index +hb_face_get_index +hb_face_set_upem +hb_face_get_upem +hb_face_reference_blob +hb_face_reference_table +hb_face_collect_unicodes +hb_face_collect_nominal_glyph_mapping +hb_face_collect_variation_selectors +hb_face_collect_variation_unicodes +hb_face_builder_create +hb_face_builder_add_table +hb_face_builder_sort_tables +
      + +
      +hb-font +hb_font_add_glyph_origin_for_direction +hb_font_create +hb_font_create_sub_font +hb_font_get_empty +hb_font_reference +hb_font_destroy +hb_font_set_user_data +hb_font_get_user_data +hb_font_make_immutable +hb_font_is_immutable +hb_font_set_face +hb_font_get_face +hb_font_get_glyph +hb_font_get_glyph_advance_for_direction +hb_font_get_glyph_advances_for_direction +hb_font_get_glyph_contour_point +hb_font_get_glyph_contour_point_for_origin +hb_font_get_glyph_extents +hb_font_get_glyph_extents_for_origin +hb_font_get_glyph_from_name +hb_font_get_glyph_h_advance +hb_font_get_glyph_v_advance +hb_font_get_glyph_h_advances +hb_font_get_glyph_v_advances +hb_font_get_glyph_h_kerning +hb_font_get_glyph_kerning_for_direction +hb_font_get_glyph_h_origin +hb_font_get_glyph_v_origin +hb_font_get_glyph_origin_for_direction +hb_font_get_glyph_name +hb_font_get_glyph_shape +hb_font_draw_glyph +hb_font_paint_glyph +hb_font_get_nominal_glyph +hb_font_get_nominal_glyphs +hb_font_get_variation_glyph +hb_font_set_parent +hb_font_get_parent +hb_font_set_ppem +hb_font_get_ppem +hb_font_set_ptem +hb_font_get_ptem +hb_font_set_scale +hb_font_get_scale +hb_font_get_synthetic_bold +hb_font_set_synthetic_bold +hb_font_set_synthetic_slant +hb_font_get_synthetic_slant +hb_font_set_variations +hb_font_set_variation +HB_FONT_NO_VAR_NAMED_INSTANCE +hb_font_set_var_named_instance +hb_font_get_var_named_instance +hb_font_set_var_coords_design +hb_font_get_var_coords_design +hb_font_set_var_coords_normalized +hb_font_get_var_coords_normalized +hb_font_glyph_from_string +hb_font_glyph_to_string +hb_font_get_serial +hb_font_changed +hb_font_set_funcs +hb_font_set_funcs_data +hb_font_subtract_glyph_origin_for_direction +hb_font_funcs_create +hb_font_funcs_get_empty +hb_font_funcs_reference +hb_font_funcs_destroy +hb_font_funcs_set_user_data +hb_font_funcs_get_user_data +hb_font_funcs_make_immutable +hb_font_funcs_is_immutable +hb_font_get_glyph_contour_point_func_t +hb_font_funcs_set_glyph_contour_point_func +hb_font_get_glyph_extents_func_t +hb_font_funcs_set_glyph_extents_func +hb_font_get_glyph_from_name_func_t +hb_font_funcs_set_glyph_from_name_func +hb_font_get_glyph_advance_func_t +hb_font_get_glyph_h_advance_func_t +hb_font_funcs_set_glyph_h_advance_func +hb_font_get_glyph_v_advance_func_t +hb_font_funcs_set_glyph_v_advance_func +hb_font_get_glyph_advances_func_t +hb_font_get_glyph_h_advances_func_t +hb_font_funcs_set_glyph_h_advances_func +hb_font_get_glyph_v_advances_func_t +hb_font_funcs_set_glyph_v_advances_func +hb_font_get_glyph_kerning_func_t +hb_font_get_glyph_h_kerning_func_t +hb_font_funcs_set_glyph_h_kerning_func +hb_font_get_glyph_origin_func_t +hb_font_get_glyph_h_origin_func_t +hb_font_funcs_set_glyph_h_origin_func +hb_font_get_glyph_v_origin_func_t +hb_font_funcs_set_glyph_v_origin_func +hb_font_get_glyph_name_func_t +hb_font_funcs_set_glyph_name_func +hb_font_get_glyph_shape_func_t +hb_font_funcs_set_glyph_shape_func +hb_font_draw_glyph_func_t +hb_font_funcs_set_draw_glyph_func +hb_font_paint_glyph_func_t +hb_font_funcs_set_paint_glyph_func +hb_font_get_nominal_glyph_func_t +hb_font_funcs_set_nominal_glyph_func +hb_font_get_nominal_glyphs_func_t +hb_font_funcs_set_nominal_glyphs_func +hb_font_get_variation_glyph_func_t +hb_font_funcs_set_variation_glyph_func +hb_font_funcs_t +hb_font_t +hb_reference_table_func_t +hb_font_get_font_extents_func_t +hb_font_get_font_h_extents_func_t +hb_font_funcs_set_font_h_extents_func +hb_font_get_font_v_extents_func_t +hb_font_funcs_set_font_v_extents_func +hb_font_get_h_extents +hb_font_get_v_extents +hb_font_get_extents_for_direction +hb_font_extents_t +hb_glyph_extents_t +
      + +
      +hb-ft +hb_ft_face_create +hb_ft_face_create_cached +hb_ft_face_create_referenced +hb_ft_font_create +hb_ft_font_create_referenced +hb_ft_font_changed +hb_ft_font_get_face +hb_ft_font_lock_face +hb_ft_font_unlock_face +hb_ft_font_set_load_flags +hb_ft_font_get_load_flags +hb_ft_font_set_funcs +hb_ft_hb_font_changed +
      + +
      +hb-gdi +hb_gdi_face_create +
      + +
      +hb-glib +hb_glib_get_unicode_funcs +hb_glib_script_from_script +hb_glib_script_to_script +hb_glib_blob_create +
      + +
      +hb-graphite2 +HB_GRAPHITE2_TAG_SILF +hb_graphite2_face_get_gr_face +hb_graphite2_font_get_gr_font +
      + +
      +hb-icu +hb_icu_get_unicode_funcs +hb_icu_script_from_script +hb_icu_script_to_script +
      + +
      +hb-map +hb_map_create +hb_map_allocation_successful +hb_map_copy +hb_map_clear +hb_map_get_empty +hb_map_reference +hb_map_destroy +hb_map_set_user_data +hb_map_get_user_data +hb_map_set +hb_map_get +hb_map_del +hb_map_has +hb_map_get_population +hb_map_is_empty +hb_map_is_equal +hb_map_hash +hb_map_update +hb_map_next +hb_map_keys +hb_map_values +HB_MAP_VALUE_INVALID +hb_map_t +
      + +
      +hb-ot-color +HB_COLOR +hb_color_get_alpha +hb_color_get_blue +hb_color_get_green +hb_color_get_red +hb_ot_color_glyph_get_layers +hb_ot_color_glyph_reference_png +hb_ot_color_glyph_reference_svg +hb_ot_color_has_layers +hb_ot_color_has_paint +hb_ot_color_glyph_has_paint +hb_ot_color_has_palettes +hb_ot_color_has_png +hb_ot_color_has_svg +hb_ot_color_palette_color_get_name_id +hb_ot_color_palette_get_colors +hb_ot_color_palette_get_count +hb_ot_color_palette_get_flags +hb_ot_color_palette_get_name_id +hb_color_t +hb_ot_color_layer_t +hb_ot_color_palette_flags_t +
      + +
      +hb-ot-font +hb_ot_font_set_funcs +
      + +
      +hb-ot-name +hb_ot_name_list_names +hb_ot_name_get_utf16 +hb_ot_name_get_utf32 +hb_ot_name_get_utf8 +hb_ot_name_id_t +hb_ot_name_id_predefined_t +hb_ot_name_entry_t +
      + +
      +hb-ot-layout +hb_ot_tag_to_language +hb_ot_tag_to_script +hb_ot_tags_from_script_and_language +hb_ot_tags_to_script_and_language +hb_ot_layout_collect_lookups +hb_ot_layout_collect_features +hb_ot_layout_feature_get_characters +hb_ot_layout_feature_get_lookups +hb_ot_layout_feature_get_name_ids +hb_ot_layout_feature_with_variations_get_lookups +hb_ot_layout_get_attach_points +hb_ot_layout_get_horizontal_baseline_tag_for_script +hb_ot_layout_get_baseline +hb_ot_layout_get_baseline_with_fallback +hb_ot_layout_get_glyph_class +hb_ot_layout_get_glyphs_in_class +hb_ot_layout_get_ligature_carets +hb_ot_layout_get_size_params +hb_ot_layout_has_glyph_classes +hb_ot_layout_has_positioning +hb_ot_layout_has_substitution +hb_ot_layout_language_find_feature +hb_ot_layout_language_get_feature_indexes +hb_ot_layout_language_get_feature_tags +hb_ot_layout_language_get_required_feature +hb_ot_layout_lookup_collect_glyphs +hb_ot_layout_lookup_get_glyph_alternates +hb_ot_layout_lookup_get_optical_bound +hb_ot_layout_lookup_substitute_closure +hb_ot_layout_lookups_substitute_closure +hb_ot_layout_lookup_would_substitute +hb_ot_layout_script_find_language +hb_ot_layout_script_get_language_tags +hb_ot_layout_script_select_language +hb_ot_layout_script_select_language2 +hb_ot_layout_table_find_feature_variations +hb_ot_layout_table_get_feature_tags +hb_ot_layout_table_get_script_tags +hb_ot_layout_table_get_lookup_count +hb_ot_layout_table_select_script +hb_ot_shape_plan_collect_lookups +hb_ot_layout_language_get_required_feature_index +HB_OT_MAX_TAGS_PER_LANGUAGE +HB_OT_MAX_TAGS_PER_SCRIPT +HB_OT_TAG_DEFAULT_LANGUAGE +HB_OT_TAG_DEFAULT_SCRIPT +HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX +HB_OT_LAYOUT_NO_FEATURE_INDEX +HB_OT_LAYOUT_NO_SCRIPT_INDEX +HB_OT_LAYOUT_NO_VARIATIONS_INDEX +HB_OT_TAG_BASE +HB_OT_TAG_GDEF +HB_OT_TAG_GPOS +HB_OT_TAG_GSUB +HB_OT_TAG_JSTF +hb_ot_layout_baseline_tag_t +hb_ot_layout_glyph_class_t +
      + +
      +hb-ot-math +hb_ot_math_has_data +hb_ot_math_get_constant +hb_ot_math_get_glyph_italics_correction +hb_ot_math_get_glyph_top_accent_attachment +hb_ot_math_get_glyph_kerning +hb_ot_math_get_glyph_kernings +hb_ot_math_is_glyph_extended_shape +hb_ot_math_get_glyph_variants +hb_ot_math_get_min_connector_overlap +hb_ot_math_get_glyph_assembly +HB_OT_TAG_MATH +HB_OT_TAG_MATH_SCRIPT +hb_ot_math_constant_t +hb_ot_math_kern_t +hb_ot_math_kern_entry_t +hb_ot_math_glyph_variant_t +hb_ot_math_glyph_part_flags_t +hb_ot_math_glyph_part_t +
      + +
      +hb-ot-meta +hb_ot_meta_get_entry_tags +hb_ot_meta_reference_entry +hb_ot_meta_tag_t +
      + +
      +hb-ot-metrics +hb_ot_metrics_get_position +hb_ot_metrics_get_position_with_fallback +hb_ot_metrics_get_variation +hb_ot_metrics_get_x_variation +hb_ot_metrics_get_y_variation +hb_ot_metrics_tag_t +
      + +
      +hb-ot-shape +hb_ot_shape_glyphs_closure +
      + +
      +hb-ot-var +hb_ot_var_has_data +hb_ot_var_find_axis_info +hb_ot_var_get_axis_count +hb_ot_var_get_axis_infos +hb_ot_var_get_named_instance_count +hb_ot_var_named_instance_get_subfamily_name_id +hb_ot_var_named_instance_get_postscript_name_id +hb_ot_var_named_instance_get_design_coords +hb_ot_var_normalize_variations +hb_ot_var_normalize_coords +HB_OT_TAG_VAR_AXIS_ITALIC +HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE +HB_OT_TAG_VAR_AXIS_SLANT +HB_OT_TAG_VAR_AXIS_WEIGHT +HB_OT_TAG_VAR_AXIS_WIDTH +hb_ot_var_axis_flags_t +hb_ot_var_axis_info_t +
      + +
      +hb-set +hb_set_create +hb_set_allocation_successful +hb_set_copy +hb_set_get_empty +hb_set_reference +hb_set_destroy +hb_set_set_user_data +hb_set_get_user_data +hb_set_clear +hb_set_set +hb_set_has +hb_set_add +hb_set_add_range +hb_set_add_sorted_array +hb_set_del +hb_set_del_range +hb_set_get_max +hb_set_get_min +hb_set_get_population +hb_set_is_empty +hb_set_hash +hb_set_subtract +hb_set_intersect +hb_set_union +hb_set_symmetric_difference +hb_set_invert +hb_set_is_inverted +hb_set_is_equal +hb_set_is_subset +hb_set_next +hb_set_next_range +hb_set_next_many +hb_set_previous +hb_set_previous_range +HB_SET_VALUE_INVALID +hb_set_t +
      + +
      +hb-shape +hb_shape +hb_shape_full +hb_shape_justify +hb_shape_list_shapers +
      + +
      +hb-shape-plan +hb_shape_plan_create +hb_shape_plan_create_cached +hb_shape_plan_create2 +hb_shape_plan_create_cached2 +hb_shape_plan_get_empty +hb_shape_plan_reference +hb_shape_plan_destroy +hb_shape_plan_set_user_data +hb_shape_plan_get_user_data +hb_shape_plan_execute +hb_shape_plan_get_shaper +hb_shape_plan_t +
      + +
      +hb-unicode +hb_unicode_general_category +hb_unicode_combining_class +hb_unicode_mirroring +hb_unicode_script +hb_unicode_compose +hb_unicode_decompose +hb_unicode_funcs_create +hb_unicode_funcs_get_empty +hb_unicode_funcs_reference +hb_unicode_funcs_destroy +hb_unicode_funcs_set_user_data +hb_unicode_funcs_get_user_data +hb_unicode_funcs_make_immutable +hb_unicode_funcs_is_immutable +hb_unicode_funcs_get_default +hb_unicode_funcs_get_parent +hb_unicode_general_category_func_t +hb_unicode_funcs_set_general_category_func +hb_unicode_combining_class_func_t +hb_unicode_funcs_set_combining_class_func +hb_unicode_mirroring_func_t +hb_unicode_funcs_set_mirroring_func +hb_unicode_script_func_t +hb_unicode_funcs_set_script_func +hb_unicode_compose_func_t +hb_unicode_funcs_set_compose_func +hb_unicode_decompose_func_t +hb_unicode_funcs_set_decompose_func +HB_UNICODE_MAX +hb_unicode_combining_class_t +hb_unicode_general_category_t +hb_unicode_funcs_t +
      + +
      +hb-uniscribe +hb_uniscribe_font_get_hfont +hb_uniscribe_font_get_logfontw +
      + +
      +hb-version +HB_VERSION_ATLEAST +hb_version +hb_version_atleast +hb_version_string +HB_VERSION_MAJOR +HB_VERSION_MICRO +HB_VERSION_MINOR +HB_VERSION_STRING +
      + +
      +hb-style +hb_style_tag_t +hb_style_get_value +
      + +
      +hb-subset +hb_subset_input_create_or_fail +hb_subset_input_reference +hb_subset_input_destroy +hb_subset_input_set_user_data +hb_subset_input_get_user_data +hb_subset_input_keep_everything +hb_subset_input_set_flags +hb_subset_input_get_flags +hb_subset_input_unicode_set +hb_subset_input_glyph_set +hb_subset_input_set +hb_subset_input_pin_axis_location +hb_subset_input_pin_axis_to_default +hb_subset_or_fail +hb_subset_plan_create_or_fail +hb_subset_plan_reference +hb_subset_plan_destroy +hb_subset_plan_set_user_data +hb_subset_plan_get_user_data +hb_subset_plan_execute_or_fail +hb_subset_plan_unicode_to_old_glyph_mapping +hb_subset_plan_new_to_old_glyph_mapping +hb_subset_plan_old_to_new_glyph_mapping +hb_subset_preprocess +hb_subset_flags_t +hb_subset_input_t +hb_subset_sets_t +hb_subset_plan_t + +hb_link_t +hb_object_t +hb_subset_repack_or_fail +hb_subset_input_override_name_table +
      + +
      +hb-cairo +hb_cairo_font_face_create_for_font +hb_cairo_font_face_get_font +hb_cairo_font_face_create_for_face +hb_cairo_font_face_get_face +hb_cairo_font_init_func_t +hb_cairo_font_face_set_font_init_func +hb_cairo_scaled_font_get_font +hb_cairo_font_face_set_scale_factor +hb_cairo_font_face_get_scale_factor +hb_cairo_glyphs_from_buffer +
      diff --git a/third_party/harfbuzz-ng/src/docs/meson.build b/third_party/harfbuzz-ng/src/docs/meson.build new file mode 100644 index 000000000000..faf558a7705f --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/meson.build @@ -0,0 +1,64 @@ +if not find_program('gtkdoc-scan', required: get_option('docs')).found() + message('Not building documentation as gtk-doc was not found') + subdir_done() +endif + +conf.set('HAVE_GTK_DOC', 1) + +gnome = import('gnome') + +docconf = configuration_data() +docconf.set('HB_VERSION', meson.project_version()) + +version_xml = configure_file(input: 'version.xml.in', + output: 'version.xml', + configuration: docconf) + +content_files = [ + 'usermanual-what-is-harfbuzz.xml', + 'usermanual-install-harfbuzz.xml', + 'usermanual-getting-started.xml', + 'usermanual-glyph-information.xml', + 'usermanual-shaping-concepts.xml', + 'usermanual-object-model.xml', + 'usermanual-buffers-language-script-and-direction.xml', + 'usermanual-fonts-and-faces.xml', + 'usermanual-opentype-features.xml', + 'usermanual-clusters.xml', + 'usermanual-utilities.xml', + 'usermanual-integration.xml', + version_xml, +] + +html_images = [ + 'HarfBuzz.png', + 'HarfBuzz.svg', +] + +ignore_headers = [ + 'hb-features.h', + 'hb-gobject.h', + 'hb-gobject-enums.h', + 'hb-gobject-enums-tmp.h', + 'hb-gobject-structs.h', +] + +gnome.gtkdoc('harfbuzz', + main_sgml: 'harfbuzz-docs.xml', + src_dir: [meson.current_source_dir() / '..' / 'src', + meson.current_build_dir() / '..' / 'src', + ], + scan_args: ['--deprecated-guards=HB_DISABLE_DEPRECATED', + '--ignore-decorators=HB_EXTERN|HB_DEPRECATED|HB_DEPRECATED_FOR()', + ], + mkdb_args: ['--source-suffixes=h,cc', + '--xml-mode', + '--output-format=xml', + ], + content_files: content_files, + html_assets: html_images, + ignore_headers: ignore_headers, + dependencies: [libharfbuzz_dep], + install: true, + check: get_option('doc_tests'), +) diff --git a/third_party/harfbuzz-ng/src/docs/repacker.md b/third_party/harfbuzz-ng/src/docs/repacker.md new file mode 100644 index 000000000000..397ce4fa6a6a --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/repacker.md @@ -0,0 +1,294 @@ +# Introduction + +Several tables in the opentype format are formed internally by a graph of subtables. Parent node's +reference their children through the use of positive offsets, which are typically 16 bits wide. +Since offsets are always positive this forms a directed acyclic graph. For storage in the font file +the graph must be given a topological ordering and then the subtables packed in serial according to +that ordering. Since 16 bit offsets have a maximum value of 65,535 if the distance between a parent +subtable and a child is more then 65,535 bytes then it's not possible for the offset to encode that +edge. + +For many fonts with complex layout rules (such as Arabic) it's not unusual for the tables containing +layout rules ([GSUB/GPOS](https://docs.microsoft.com/en-us/typography/opentype/spec/gsub)) to be +larger than 65kb. As a result these types of fonts are susceptible to offset overflows when +serializing to the binary font format. + +Offset overflows can happen for a variety of reasons and require different strategies to resolve: +* Simple overflows can often be resolved with a different topological ordering. +* If a subtable has many parents this can result in the link from furthest parent(s) + being at risk for overflows. In these cases it's possible to duplicate the shared subtable which + allows it to be placed closer to it's parent. +* If subtables exist which are themselves larger than 65kb it's not possible for any offsets to point + past them. In these cases the subtable can usually be split into two smaller subtables to allow + for more flexibility in the ordering. +* In GSUB/GPOS overflows from Lookup subtables can be resolved by changing the Lookup to an extension + lookup which uses a 32 bit offset instead of 16 bit offset. + +In general there isn't a simple solution to produce an optimal topological ordering for a given graph. +Finding an ordering which doesn't overflow is a NP hard problem. Existing solutions use heuristics +which attempt a combination of the above strategies to attempt to find a non-overflowing configuration. + +The harfbuzz subsetting library +[includes a repacking algorithm](https://github.com/harfbuzz/harfbuzz/blob/main/src/hb-repacker.hh) +which is used to resolve offset overflows that are present in the subsetted tables it produces. This +document provides a deep dive into how the harfbuzz repacking algorithm works. + +Other implementations exist, such as in +[fontTools](https://github.com/fonttools/fonttools/blob/7af43123d49c188fcef4e540fa94796b3b44e858/Lib/fontTools/ttLib/tables/otBase.py#L72), however these are not covered in this document. + +# Foundations + +There's four key pieces to the harfbuzz approach: + +* Subtable Graph: a table's internal structure is abstracted out into a lightweight graph + representation where each subtable is a node and each offset forms an edge. The nodes only need + to know how many bytes the corresponding subtable occupies. This lightweight representation can + be easily modified to test new ordering's and strategies as the repacking algorithm iterates. + +* [Topological sorting algorithm](https://en.wikipedia.org/wiki/Topological_sorting): an algorithm + which given a graph gives a linear sorting of the nodes such that all offsets will be positive. + +* Overflow check: given a graph and a topological sorting it checks if there will be any overflows + in any of the offsets. If there are overflows it returns a list of (parent, child) tuples that + will overflow. Since the graph has information on the size of each subtable it's straightforward + to calculate the final position of each subtable and then check if any offsets to it will + overflow. + +* Content Aware Preprocessing: if the overflow resolver is aware of the format of the underlying + tables (eg. GSUB, GPOS) then in some cases preprocessing can be done to increase the chance of + successfully packing the graph. For example for GSUB and GPOS we can preprocess the graph and + promote lookups to extension lookups (upgrades a 16 bit offset to 32 bits) or split large lookup + subtables into two or more pieces. + +* Offset resolution strategies: given a particular occurrence of an overflow these strategies + modify the graph to attempt to resolve the overflow. + +# High Level Algorithm + +``` +def repack(graph): + graph.topological_sort() + + if (graph.will_overflow()) + preprocess(graph) + assign_spaces(graph) + graph.topological_sort() + + while (overflows = graph.will_overflow()): + for overflow in overflows: + apply_offset_resolution_strategy (overflow, graph) + graph.topological_sort() +``` + +The actual code for this processing loop can be found in the function hb_resolve_overflows () of +[hb-repacker.hh](https://github.com/harfbuzz/harfbuzz/blob/main/src/hb-repacker.hh). + +# Topological Sorting Algorithms + +The harfbuzz repacker uses two different algorithms for topological sorting: +* [Kahn's Algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm) +* Sorting by shortest distance + +Kahn's algorithm is approximately twice as fast as the shortest distance sort so that is attempted +first (only on the first topological sort). If it fails to eliminate overflows then shortest distance +sort will be used for all subsequent topological sorting operations. + +## Shortest Distance Sort + +This algorithm orders the nodes based on total distance to each node. Nodes with a shorter distance +are ordered first. + +The "weight" of an edge is the sum of the size of the sub-table being pointed to plus 2^16 for a 16 bit +offset and 2^32 for a 32 bit offset. + +The distance of a node is the sum of all weights along the shortest path from the root to that node +plus a priority modifier (used to change where nodes are placed by moving increasing or +decreasing the effective distance). Ties between nodes with the same distance are broken based +on the order of the offset in the sub table bytes. + +The shortest distance to each node is determined using +[Djikstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm). Then the topological +ordering is produce by applying a modified version of Kahn's algorithm that uses a priority queue +based on the shortest distance to each node. + +## Optimizing the Sorting + +The topological sorting operation is the core of the repacker and is run on each iteration so it needs +to be as fast as possible. There's a few things that are done to speed up subsequent sorting +operations: + +* The number of incoming edges to each node is cached. This is required by the Kahn's algorithm + portion of both sorts. Where possible when the graph is modified we manually update the cached + edge counts of affected nodes. + +* The distance to each node is cached. Where possible when the graph is modified we manually update + the cached distances of any affected nodes. + +Caching these values allows the repacker to avoid recalculating them for the full graph on each +iteration. + +The other important factor to speed is a fast priority queue which is a core datastructure to +the topological sorting algorithm. Currently a basic heap based queue is used. Heap based queue's +don't support fast priority decreases, but that can be worked around by just adding redundant entries +to the priority queue and filtering the older ones out when poppping off entries. This is based +on the recommendations in +[a study of the practical performance of priority queues in Dijkstra's algorithm](https://www3.cs.stonybrook.edu/~rezaul/papers/TR-07-54.pdf) + +## Special Handling of 32 bit Offsets + +If a graph contains multiple 32 bit offsets then the shortest distance sorting will be likely be +suboptimal. For example consider the case where a graph contains two 32 bit offsets that each point +to a subgraph which are not connected to each other. The shortest distance sort will interleave the +subtables of the two subgraphs, potentially resulting in overflows. Since each of these subgraphs are +independent of each other, and 32 bit offsets can point extremely long distances a better strategy is +to pack the first subgraph in it's entirety and then have the second subgraph packed after with the 32 +bit offset pointing over the first subgraph. For example given the graph: + + +``` +a--- b -- d -- f + \ + \_ c -- e -- g +``` + +Where the links from a to b and a to c are 32 bit offsets, the shortest distance sort would be: + +``` +a, b, c, d, e, f, g + +``` + +If nodes d and e have a combined size greater than 65kb then the offset from d to f will overflow. +A better ordering is: + +``` +a, b, d, f, c, e, g +``` + +The ability for 32 bit offsets to point long distances is utilized to jump over the subgraph of +b which gives the remaining 16 bit offsets a better chance of not overflowing. + +The above is an ideal situation where the subgraphs are disconnected from each other, in practice +this is often not this case. So this idea can be generalized as follows: + +If there is a subgraph that is only reachable from one or more 32 bit offsets, then: +* That subgraph can be treated as an independent unit and all nodes of the subgraph packed in isolation + from the rest of the graph. +* In a table that occupies less than 4gb of space (in practice all fonts), that packed independent + subgraph can be placed anywhere after the parent nodes without overflowing the 32 bit offsets from + the parent nodes. + +The sorting algorithm incorporates this via a "space" modifier that can be applied to nodes in the +graph. By default all nodes are treated as being in space zero. If a node is given a non-zero space, n, +then the computed distance to the node will be modified by adding `n * 2^32`. This will cause that +node and it's descendants to be packed between all nodes in space n-1 and space n+1. Resulting in a +topological sort like: + +``` +| space 0 subtables | space 1 subtables | .... | space n subtables | +``` + +The assign_spaces() step in the high level algorithm is responsible for identifying independent +subgraphs and assigning unique spaces to each one. More information on the space assignment can be +found in the next section. + +# Graph Preprocessing + +For certain table types we can preprocess and modify the graph structure to reduce the occurences +of overflows. Currently the repacker implements preprocessing only for GPOS and GSUB tables. + +## GSUB/GPOS Table Splitting + +The GSUB/GPOS preprocessor scans each lookup subtable and determines if the subtable's children are +so large that no overflow resolution is possible (for example a single subtable that exceeds 65kb +cannot be pointed over). When such cases are detected table splitting is invoked: + +* The subtable is first analyzed to determine the smallest number of split points that will allow + for successful offset overflow resolution. + +* Then the subtable in the graph representation is modified to actually perform the split at the + previously computed split points. At a high level splits are done by inserting new subtables + which contain a subset of the data of the original subtable and then shrinking the original subtable. + +Table splitting must be aware of the underlying format of each subtable type and thus needs custom +code for each subtable type. Currently subtable splitting is only supported for GPOS subtable types. + +## GSUB/GPOS Extension Lookup Promotion + +In GSUB/GPOS tables lookups can be regular lookups which use 16 bit offsets to the children subtables +or extension lookups which use 32 bit offsets to the children subtables. If the sub graph of all +regular lookups is too large then it can be difficult to find an overflow free configuration. This +can be remedied by promoting one or more regular lookups to extension lookups. + +During preprocessing the graph is scanned to determine the size of the subgraph of regular lookups. +If the graph is found to be too big then the analysis finds a set of lookups to promote to reduce +the subgraph size. Lastly the graph is modified to convert those lookups to extension lookups. + +# Offset Resolution Strategies + +## Space Assignment + +The goal of space assignment is to find connected subgraphs that are only reachable via 32 bit offsets +and then assign each such subgraph to a unique non-zero space. The algorithm is roughly: + +1. Collect the set, `S`, of nodes that are children of 32 bit offsets. + +2. Do a directed traversal from each node in `S` and collect all encountered nodes into set `T`. + Mark all nodes in the graph that are not in `T` as being in space 0. + +3. Set `next_space = 1`. + +4. While set `S` is not empty: + + a. Pick a node `n` in set `S` then perform an undirected graph traversal and find the set `Q` of + nodes that are reachable from `n`. + + b. During traversal if a node, `m`, has a edge to a node in space 0 then `m` must be duplicated + to disconnect it from space 0. + + d. Remove all nodes in `Q` from `S` and assign all nodes in `Q` to `next_space`. + + + c. Increment `next_space` by one. + + +## Manual Iterative Resolutions + +For each overflow in each iteration the algorithm will attempt to apply offset overflow resolution +strategies to eliminate the overflow. The type of strategy applied is dependent on the characteristics +of the overflowing link: + +* If the overflowing offset is inside a space other than space 0 and the subgraph space has more + than one 32 bit offset pointing into the subgraph then subdivide the space by moving subgraph + from one of the 32 bit offsets into a new space via the duplication of shared nodes. + +* If the overflowing offset is pointing to a subtable with more than one incoming edge: duplicate + the node so that the overflowing offset is pointing at it's own copy of that node. + +* Otherwise, attempt to move the child subtable closer to it's parent. This is accomplished by + raising the priority of all children of the parent. Next time the topological sort is run the + children will be ordered closer to the parent. + +# Test Cases + +The harfbuzz repacker has tests defined using generic graphs: https://github.com/harfbuzz/harfbuzz/blob/main/src/test-repacker.cc + +# Future Improvements + +Currently for GPOS tables the repacker implementation is sufficient to handle both subsetting and the +general case of font compilation repacking. However for GSUB the repacker is only sufficient for +subsetting related overflows. To enable general case repacking of GSUB, support for splitting of +GSUB subtables will need to be added. Other table types such as COLRv1 shouldn't require table +splitting due to the wide use of 24 bit offsets throughout the table. + +Beyond subtable splitting there are a couple of "nice to have" improvements, but these are not required +to support the general case: + +* Extension demotion: currently extension promotion is supported but in some cases if the non-extension + subgraph is underfilled then packed size can be reduced by demoting extension lookups back to regular + lookups. + +* Currently only children nodes are moved to resolve offsets. However, in many cases moving a parent + node closer to it's children will have less impact on the size of other offsets. Thus the algorithm + should use a heuristic (based on parent and child subtable sizes) to decide if the children's + priority should be increased or the parent's priority decreased. diff --git a/third_party/harfbuzz-ng/src/docs/serializer.md b/third_party/harfbuzz-ng/src/docs/serializer.md new file mode 100644 index 000000000000..0efda8055066 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/serializer.md @@ -0,0 +1,178 @@ +# Introduction + +In hb-subset serialization is the process of writing the subsetted font +tables out to actual bytes in the final format. All serialization works +through an object called the serialize context +([hb_serialize_context_t](https://github.com/harfbuzz/harfbuzz/blob/main/src/hb-serialize.hh)). + +Internally the serialize context holds a fixed size memory buffer. For simple +tables the final bytes are written into the buffer sequentially to produce +the final serialized bytes. + +## Simple Tables + +Simple tables are tables that do not use offset graphs. + +To write a struct into the serialization context, first you call an +allocation method on the context which requests a writable array of bytes of +a fixed size. If the requested array will not exceed the bounds of the fixed +buffer the serializer will return a pointer to the next unwritten portion +of the buffer. Then the struct is cast onto the returned pointer and values +are written to the structs fields. + +Internally the serialization context ends up looking like: + +``` ++-------+-------+-----+-------+--------------+ +| Obj 1 | Obj 2 | ... | Obj N | Unused Space | ++-------+-------+-----+-------+--------------+ +``` + +Here Obj N, is the object currently being written. + +## Complex Tables + +Complex tables are made up of graphs of objects, where offset's are used +to form the edges of the graphs. Each object is a continuous slice of bytes +that contains zero or more offsets pointing to more objects. + +In this case the serialization buffer has a different layout: + +``` +|- in progress objects -| |--- packed objects --| ++-----------+-----------+--------------+-------+-----+-------+ +| Obj n+2 | Obj n+1 | Unused Space | Obj n | ... | Obj 0 | ++-----------+-----------+--------------+-------+-----+-------+ +|-----------------------> <---------------------| +``` + +The buffer holds two stacks: + +1. In progress objects are held in a stack starting from the start of buffer + that grows towards the end of the buffer. + +2. Packed objects are held in a stack that starts at the end of the buffer + and grows towards the start of the buffer. + +Once the object on the top of the in progress stack is finished being written +its bytes are popped from the in progress stack and copied to the top of +the packed objects stack. In the example above, finalizing Obj n+1 +would result in the following state: + +``` ++---------+--------------+---------+-------+-----+-------+ +| Obj n+2 | Unused Space | Obj n+1 | Obj n | ... | Obj 0 | ++---------+--------------+---------+-------+-----+-------+ +``` + +Each packed object is associated with an ID, it's zero based position in the packed +objects stack. In this example Obj 0, would have an ID of 0. + +During serialization offsets that link from one object to another are stored +using object ids. The serialize context maintains a list of links between +objects. Each link records the parent object id, the child object id, the position +of the offset field within the parent object, and the width of the offset. + +Links are always added to the current in progress object and you can only link too +objects that have been packed and thus have an ID. + +### Object De-duplication + +An important optimization in packing offset graphs is de-duplicating equivalent objects. If you +have two or more parent objects that point to child objects that are equivalent then you only need +to encode the child once and can have the parents point to the same child. This can significantly +reduce the final size of a serialized graph. + +During packing of an inprogress object the serialization context checks if any existing packed +objects are equivalent to the object being packed. Here equivalence means the object has the +exact same bytes and all of it's links are equivalent. If an equivalent object is found the +in progress object is discarded and not copied to the packed object stack. The object id of +the equivalent object is instead returned. Thus parent objects will then link to the existing +equivalent object. + +To find equivalent objects the serialization context maintains a hashmap from object to the canonical +object id. + +### Link Resolution + +Once all objects have been packed the next step is to assign actual values to all of the offset +fields. Prior to this point all links in the graph have been recorded using object id's. For each +link the resolver computes the offset between the parent and child and writes the offset into +the serialization buffer at the appropriate location. + +### Offset Overflow Resolution + +If during link resolution the resolver finds that an offsets value would exceed what can be encoded +in that offset field link resolution is aborted and the offset overflow resolver is invoked. +That process is documented [here](reapcker.md). + + +### Example of Complex Serialization + + +If we wanted to serialize the following graph: + +``` +a--b--d + \ / + c +``` + +Serializer would be called like this: + +```c++ +hb_serialize_context_t ctx; + +struct root { + char name; + Offset16To child_1; + Offset16To child_2; +} + +struct child { + char name; + Offset16To leaf; +} + +// Object A. +ctx->push(); +root* a = ctx->start_embed (); +ctx->extend_min (a); +a->name = 'a'; + +// Object B. +ctx->push(); +child* b = ctx->start_embed (); +ctx->extend_min (b); +b->name = 'b'; + +// Object D. +ctx->push(); +*ctx->allocate_size (1) = 'd'; +unsigned d_id = ctx->pop_pack (); + +ctx->add_link (b->leaf, d_id); +unsigned b_id = ctx->pop_pack (); + +// Object C +ctx->push(); +child* c = ctx->start_embed (); +ctx->extend_min (c); +c->name = 'c'; + +// Object D. +ctx->push(); +*ctx->allocate_size (1) = 'd'; +d_id = ctx->pop_pack (); // Serializer will automatically de-dup this with the previous 'd' + +ctx->add_link (c->leaf, d_id); +unsigned c_id = ctx->pop_pack (); + +// Object A's links: +ctx->add_link (a->child_1, b_id); +ctx->add_link (a->child_2, c_id); +ctx->pop_pack (); + +ctx->end_serialize (); + +``` diff --git a/third_party/harfbuzz-ng/src/docs/subset-preprocessing.md b/third_party/harfbuzz-ng/src/docs/subset-preprocessing.md new file mode 100644 index 000000000000..637da2865431 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/subset-preprocessing.md @@ -0,0 +1,228 @@ +# Introduction + +Subset preprocessing is a mechanism which can significantly speed up font subsetting operations. +It works by prepopulating datastructures from the source font which can be used in later subsetting +operations to more quickly produce the subset. Preprocessing is useful in cases where multiple subsets +will be cut from the same source font. + +# Usage + +```c++ +hb_face_t* preprocessed = hb_subset_preprocess (source_face); + +... + +hb_face_t* subset = hb_subset_or_fail (preprocessed, subset_input); +``` + +# Additional Details + +* A subset produced from a preprocessed face should be identical to a subset produced from only the + original face. The preprocessor does not change the functionality of the subsetter, just speeds + things up. + +* The preprocessing operation may take longer than the time it takes to produce a subset from the + source font. Thus the main performance gains are made when a preprocessed face is reused for + multiple subsetting operations. + +* Currently the largest performance gains are seen when using a preprocessed face for CFF subsetting. + +* The preprocessed face may contain references to the memory backing the source face. If this memory + is fully owned by a harfbuzz hb_blob_t* then it will automatically be kept alive for the lifetime + of the preprocessed face. However, if this memory is not fully owned by a harfbuzz hb_blob_t* then + it is necessary to ensure that the memory is kept alive for the lifetime of the preprocessed face. + + +# Performance Improvements + +Here is the performance difference of producing a subset with a preprocessed face vs producing +a subset with the source face: + +Benchmark | Delta Time (%) +----------|----------------- +BM_subset/subset_glyphs/Roboto-Regular.ttf/10_median|-56% +BM_subset/subset_glyphs/Roboto-Regular.ttf/64_median|-33% +BM_subset/subset_glyphs/Roboto-Regular.ttf/512_median|-28% +BM_subset/subset_glyphs/Roboto-Regular.ttf/1000_median|-11% +BM_subset/subset_glyphs/Roboto-Regular.ttf/nohinting/10_median|-56% +BM_subset/subset_glyphs/Roboto-Regular.ttf/nohinting/64_median|-33% +BM_subset/subset_glyphs/Roboto-Regular.ttf/nohinting/512_median|-21% +BM_subset/subset_glyphs/Roboto-Regular.ttf/nohinting/1000_median|-9% +BM_subset/subset_glyphs/Amiri-Regular.ttf/10_median|-67% +BM_subset/subset_glyphs/Amiri-Regular.ttf/64_median|-48% +BM_subset/subset_glyphs/Amiri-Regular.ttf/512_median|-21% +BM_subset/subset_glyphs/Amiri-Regular.ttf/4096_median|-9% +BM_subset/subset_glyphs/Amiri-Regular.ttf/nohinting/10_median|-66% +BM_subset/subset_glyphs/Amiri-Regular.ttf/nohinting/64_median|-50% +BM_subset/subset_glyphs/Amiri-Regular.ttf/nohinting/512_median|-8% +BM_subset/subset_glyphs/Amiri-Regular.ttf/nohinting/4096_median|-9% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/10_median|-85% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/64_median|-71% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/512_median|-3% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/1400_median|4% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/nohinting/10_median|-84% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/nohinting/64_median|-72% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/nohinting/512_median|0% +BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/nohinting/1400_median|0% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/10_median|-30% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/64_median|-24% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/512_median|-3% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/1000_median|-3% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/nohinting/10_median|-30% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/nohinting/64_median|-24% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/nohinting/512_median|-3% +BM_subset/subset_glyphs/NotoSansDevanagari-Regular.ttf/nohinting/1000_median|-5% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/10_median|-96% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/64_median|-90% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/512_median|-74% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/4096_median|-25% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/10000_median|-23% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/nohinting/10_median|-95% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/nohinting/64_median|-90% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/nohinting/512_median|-73% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/nohinting/4096_median|-24% +BM_subset/subset_glyphs/Mplus1p-Regular.ttf/nohinting/10000_median|-11% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/10_median|-84% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/64_median|-77% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/512_median|-70% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/4096_median|-80% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/10000_median|-86% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/10_median|-84% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/64_median|-78% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/512_median|-71% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/4096_median|-86% +BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/10000_median|-88% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/10_median|-59% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/64_median|-55% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/512_median|-67% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/2000_median|-68% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/nohinting/10_median|-60% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/nohinting/64_median|-58% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/nohinting/512_median|-72% +BM_subset/subset_glyphs/SourceSansPro-Regular.otf/nohinting/2000_median|-71% +BM_subset/subset_glyphs/AdobeVFPrototype.otf/10_median|-70% +BM_subset/subset_glyphs/AdobeVFPrototype.otf/64_median|-64% +BM_subset/subset_glyphs/AdobeVFPrototype.otf/300_median|-73% +BM_subset/subset_glyphs/AdobeVFPrototype.otf/nohinting/10_median|-71% +BM_subset/subset_glyphs/AdobeVFPrototype.otf/nohinting/64_median|-68% +BM_subset/subset_glyphs/AdobeVFPrototype.otf/nohinting/300_median|-72% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/10_median|-90% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/64_median|-82% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/512_median|-31% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/4096_median|-9% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/6000_median|-22% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/nohinting/10_median|-88% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/nohinting/64_median|-83% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/nohinting/512_median|-31% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/nohinting/4096_median|-16% +BM_subset/subset_glyphs/MPLUS1-Variable.ttf/nohinting/6000_median|-18% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/10_median|-44% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/64_median|-18% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/512_median|-2% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/900_median|-6% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/nohinting/10_median|-45% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/nohinting/64_median|-17% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/nohinting/512_median|-15% +BM_subset/subset_glyphs/RobotoFlex-Variable.ttf/nohinting/900_median|-3% +BM_subset/subset_codepoints/Roboto-Regular.ttf/10_median|-20% +BM_subset/subset_codepoints/Roboto-Regular.ttf/64_median|-16% +BM_subset/subset_codepoints/Roboto-Regular.ttf/512_median|-12% +BM_subset/subset_codepoints/Roboto-Regular.ttf/1000_median|-10% +BM_subset/subset_codepoints/Roboto-Regular.ttf/nohinting/10_median|-24% +BM_subset/subset_codepoints/Roboto-Regular.ttf/nohinting/64_median|-14% +BM_subset/subset_codepoints/Roboto-Regular.ttf/nohinting/512_median|-15% +BM_subset/subset_codepoints/Roboto-Regular.ttf/nohinting/1000_median|-9% +BM_subset/subset_codepoints/Amiri-Regular.ttf/10_median|-51% +BM_subset/subset_codepoints/Amiri-Regular.ttf/64_median|-37% +BM_subset/subset_codepoints/Amiri-Regular.ttf/512_median|-12% +BM_subset/subset_codepoints/Amiri-Regular.ttf/4096_median|-1% +BM_subset/subset_codepoints/Amiri-Regular.ttf/nohinting/10_median|-49% +BM_subset/subset_codepoints/Amiri-Regular.ttf/nohinting/64_median|-35% +BM_subset/subset_codepoints/Amiri-Regular.ttf/nohinting/512_median|-6% +BM_subset/subset_codepoints/Amiri-Regular.ttf/nohinting/4096_median|-1% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/10_median|-82% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/64_median|-9% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/512_median|0% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/1400_median|0% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/nohinting/10_median|-82% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/nohinting/64_median|-13% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/nohinting/512_median|-3% +BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/nohinting/1400_median|2% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/10_median|-40% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/64_median|-26% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/512_median|-5% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/1000_median|3% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/nohinting/10_median|-43% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/nohinting/64_median|-24% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/nohinting/512_median|-2% +BM_subset/subset_codepoints/NotoSansDevanagari-Regular.ttf/nohinting/1000_median|2% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/10_median|-83% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/64_median|-67% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/512_median|-39% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/4096_median|-20% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/10000_median|-25% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/nohinting/10_median|-83% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/nohinting/64_median|-65% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/nohinting/512_median|-42% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/nohinting/4096_median|-34% +BM_subset/subset_codepoints/Mplus1p-Regular.ttf/nohinting/10000_median|-21% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/10_median|-69% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/64_median|-69% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/512_median|-70% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/4096_median|-84% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/10000_median|-83% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/10_median|-71% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/64_median|-68% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/512_median|-70% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/4096_median|-86% +BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/nohinting/10000_median|-88% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/10_median|-45% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/64_median|-48% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/512_median|-57% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/2000_median|-66% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/nohinting/10_median|-43% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/nohinting/64_median|-50% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/nohinting/512_median|-63% +BM_subset/subset_codepoints/SourceSansPro-Regular.otf/nohinting/2000_median|-72% +BM_subset/subset_codepoints/AdobeVFPrototype.otf/10_median|-69% +BM_subset/subset_codepoints/AdobeVFPrototype.otf/64_median|-66% +BM_subset/subset_codepoints/AdobeVFPrototype.otf/300_median|-74% +BM_subset/subset_codepoints/AdobeVFPrototype.otf/nohinting/10_median|-70% +BM_subset/subset_codepoints/AdobeVFPrototype.otf/nohinting/64_median|-71% +BM_subset/subset_codepoints/AdobeVFPrototype.otf/nohinting/300_median|-75% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/10_median|-66% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/64_median|-46% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/512_median|-15% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/4096_median|-5% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/6000_median|-16% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/nohinting/10_median|-66% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/nohinting/64_median|-45% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/nohinting/512_median|-14% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/nohinting/4096_median|-11% +BM_subset/subset_codepoints/MPLUS1-Variable.ttf/nohinting/6000_median|-27% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/10_median|-38% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/64_median|-9% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/512_median|-3% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/900_median|-16% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/nohinting/10_median|-39% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/nohinting/64_median|-12% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/nohinting/512_median|-4% +BM_subset/subset_codepoints/RobotoFlex-Variable.ttf/nohinting/900_median|-2% +BM_subset/instance/MPLUS1-Variable.ttf/10_median|-68% +BM_subset/instance/MPLUS1-Variable.ttf/64_median|-45% +BM_subset/instance/MPLUS1-Variable.ttf/512_median|-18% +BM_subset/instance/MPLUS1-Variable.ttf/4096_median|-2% +BM_subset/instance/MPLUS1-Variable.ttf/6000_median|4% +BM_subset/instance/MPLUS1-Variable.ttf/nohinting/10_median|-69% +BM_subset/instance/MPLUS1-Variable.ttf/nohinting/64_median|-46% +BM_subset/instance/MPLUS1-Variable.ttf/nohinting/512_median|-11% +BM_subset/instance/MPLUS1-Variable.ttf/nohinting/4096_median|4% +BM_subset/instance/MPLUS1-Variable.ttf/nohinting/6000_median|-5% +BM_subset/instance/RobotoFlex-Variable.ttf/10_median|-34% +BM_subset/instance/RobotoFlex-Variable.ttf/64_median|-12% +BM_subset/instance/RobotoFlex-Variable.ttf/512_median|6% +BM_subset/instance/RobotoFlex-Variable.ttf/900_median|-6% +BM_subset/instance/RobotoFlex-Variable.ttf/nohinting/10_median|-33% +BM_subset/instance/RobotoFlex-Variable.ttf/nohinting/64_median|-11% +BM_subset/instance/RobotoFlex-Variable.ttf/nohinting/512_median|3% +BM_subset/instance/RobotoFlex-Variable.ttf/nohinting/900_median|0% diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml b/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml new file mode 100644 index 000000000000..0235d2d39712 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-buffers-language-script-and-direction.xml @@ -0,0 +1,412 @@ + + + +]> + + Buffers, language, script and direction + + The input to the HarfBuzz shaper is a series of Unicode characters, stored in a + buffer. In this chapter, we'll look at how to set up a buffer with + the text that we want and how to customize the properties of the + buffer. We'll also look at a piece of lower-level machinery that + you will need to understand before proceeding: the functions that + HarfBuzz uses to retrieve Unicode information. + + + After shaping is complete, HarfBuzz puts its output back + into the buffer. But getting that output requires setting up a + face and a font first, so we will look at that in the next chapter + instead of here. + +
      + Creating and destroying buffers + + As we saw in our Getting Started example, a + buffer is created and + initialized with hb_buffer_create(). This + produces a new, empty buffer object, instantiated with some + default values and ready to accept your Unicode strings. + + + HarfBuzz manages the memory of objects (such as buffers) that it + creates, so you don't have to. When you have finished working on + a buffer, you can call hb_buffer_destroy(): + + + hb_buffer_t *buf = hb_buffer_create(); + ... + hb_buffer_destroy(buf); + + + This will destroy the object and free its associated memory - + unless some other part of the program holds a reference to this + buffer. If you acquire a HarfBuzz buffer from another subsystem + and want to ensure that it is not garbage collected by someone + else destroying it, you should increase its reference count: + + + void somefunc(hb_buffer_t *buf) { + buf = hb_buffer_reference(buf); + ... + + + And then decrease it once you're done with it: + + + hb_buffer_destroy(buf); + } + + + While we are on the subject of reference-counting buffers, it is + worth noting that an individual buffer can only meaningfully be + used by one thread at a time. + + + To throw away all the data in your buffer and start from scratch, + call hb_buffer_reset(buf). If you want to + throw away the string in the buffer but keep the options, you can + instead call hb_buffer_clear_contents(buf). + +
      + +
      + Adding text to the buffer + + Now we have a brand new HarfBuzz buffer. Let's start filling it + with text! From HarfBuzz's perspective, a buffer is just a stream + of Unicode code points, but your input string is probably in one of + the standard Unicode character encodings (UTF-8, UTF-16, or + UTF-32). HarfBuzz provides convenience functions that accept + each of these encodings: + hb_buffer_add_utf8(), + hb_buffer_add_utf16(), and + hb_buffer_add_utf32(). Other than the + character encoding they accept, they function identically. + + + You can add UTF-8 text to a buffer by passing in the text array, + the array's length, an offset into the array for the first + character to add, and the length of the segment to add: + + + hb_buffer_add_utf8 (hb_buffer_t *buf, + const char *text, + int text_length, + unsigned int item_offset, + int item_length) + + + So, in practice, you can say: + + + hb_buffer_add_utf8(buf, text, strlen(text), 0, strlen(text)); + + + This will append your new characters to + buf, not replace its existing + contents. Also, note that you can use -1 in + place of the first instance of strlen(text) + if your text array is NULL-terminated. Similarly, you can also use + -1 as the final argument want to add its full + contents. + + + Whatever start item_offset and + item_length you provide, HarfBuzz will also + attempt to grab the five characters before + the offset point and the five characters + after the designated end. These are the + before and after "context" segments, which are used internally + for HarfBuzz to make shaping decisions. They will not be part of + the final output, but they ensure that HarfBuzz's + script-specific shaping operations are correct. If there are + fewer than five characters available for the before or after + contexts, HarfBuzz will just grab what is there. + + + For longer text runs, such as full paragraphs, it might be + tempting to only add smaller sub-segments to a buffer and + shape them in piecemeal fashion. Generally, this is not a good + idea, however, because a lot of shaping decisions are + dependent on this context information. For example, in Arabic + and other connected scripts, HarfBuzz needs to know the code + points before and after each character in order to correctly + determine which glyph to return. + + + The safest approach is to add all of the text available (even + if your text contains a mix of scripts, directions, languages + and fonts), then use item_offset and + item_length to indicate which characters you + want shaped (which must all have the same script, direction, + language and font), so that HarfBuzz has access to any context. + + + You can also add Unicode code points directly with + hb_buffer_add_codepoints(). The arguments + to this function are the same as those for the UTF + encodings. But it is particularly important to note that + HarfBuzz does not do validity checking on the text that is added + to a buffer. Invalid code points will be replaced, but it is up + to you to do any deep-sanity checking necessary. + + +
      + +
      + Setting buffer properties + + Buffers containing input characters still need several + properties set before HarfBuzz can shape their text correctly. + + + Initially, all buffers are set to the + HB_BUFFER_CONTENT_TYPE_INVALID content + type. After adding text, the buffer should be set to + HB_BUFFER_CONTENT_TYPE_UNICODE instead, which + indicates that it contains un-shaped input + characters. After shaping, the buffer will have the + HB_BUFFER_CONTENT_TYPE_GLYPHS content type. + + + hb_buffer_add_utf8() and the + other UTF functions set the content type of their buffer + automatically. But if you are reusing a buffer you may want to + check its state with + hb_buffer_get_content_type(buffer). If + necessary you can set the content type with + + + hb_buffer_set_content_type(buf, HB_BUFFER_CONTENT_TYPE_UNICODE); + + + to prepare for shaping. + + + Buffers also need to carry information about the script, + language, and text direction of their contents. You can set + these properties individually: + + + hb_buffer_set_direction(buf, HB_DIRECTION_LTR); + hb_buffer_set_script(buf, HB_SCRIPT_LATIN); + hb_buffer_set_language(buf, hb_language_from_string("en", -1)); + + + However, since these properties are often repeated for + multiple text runs, you can also save them in a + hb_segment_properties_t for reuse: + + + hb_segment_properties_t *savedprops; + hb_buffer_get_segment_properties (buf, savedprops); + ... + hb_buffer_set_segment_properties (buf2, savedprops); + + + HarfBuzz also provides getter functions to retrieve a buffer's + direction, script, and language properties individually. + + + HarfBuzz recognizes four text directions in + hb_direction_t: left-to-right + (HB_DIRECTION_LTR), right-to-left (HB_DIRECTION_RTL), + top-to-bottom (HB_DIRECTION_TTB), and + bottom-to-top (HB_DIRECTION_BTT). For the + script property, HarfBuzz uses identifiers based on the + ISO 15924 + standard. For languages, HarfBuzz uses tags based on the + IETF BCP 47 standard. + + + Helper functions are provided to convert character strings into + the necessary script and language tag types. + + + Two additional buffer properties to be aware of are the + "invisible glyph" and the replacement code point. The + replacement code point is inserted into buffer output in place of + any invalid code points encountered in the input. By default, it + is the Unicode REPLACEMENT CHARACTER code + point, U+FFFD "�". You can change this with + + + hb_buffer_set_replacement_codepoint(buf, replacement); + + + passing in the replacement Unicode code point as the + replacement parameter. + + + The invisible glyph is used to replace all output glyphs that + are invisible. By default, the standard space character + U+0020 is used; you can replace this (for + example, when using a font that provides script-specific + spaces) with + + + hb_buffer_set_invisible_glyph(buf, replacement_glyph); + + + Do note that in the replacement_glyph + parameter, you must provide the glyph ID of the replacement you + wish to use, not the Unicode code point. + + + HarfBuzz supports a few additional flags you might want to set + on your buffer under certain circumstances. The + HB_BUFFER_FLAG_BOT and + HB_BUFFER_FLAG_EOT flags tell HarfBuzz + that the buffer represents the beginning or end (respectively) + of a text element (such as a paragraph or other block). Knowing + this allows HarfBuzz to apply certain contextual font features + when shaping, such as initial or final variants in connected + scripts. + + + HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES + tells HarfBuzz not to hide glyphs with the + Default_Ignorable property in Unicode. This + property designates control characters and other non-printing + code points, such as joiners and variation selectors. Normally + HarfBuzz replaces them in the output buffer with zero-width + space glyphs (using the "invisible glyph" property discussed + above); setting this flag causes them to be printed, which can + be helpful for troubleshooting. + + + Conversely, setting the + HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES flag + tells HarfBuzz to remove Default_Ignorable + glyphs from the output buffer entirely. Finally, setting the + HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE + flag tells HarfBuzz not to insert the dotted-circle glyph + (U+25CC, "◌"), which is normally + inserted into buffer output when broken character sequences are + encountered (such as combining marks that are not attached to a + base character). + +
      + +
      + Customizing Unicode functions + + HarfBuzz requires some simple functions for accessing + information from the Unicode Character Database (such as the + General_Category (gc) and + Script (sc) properties) that is useful + for shaping, as well as some useful operations like composing and + decomposing code points. + + + HarfBuzz includes its own internal, lightweight set of Unicode + functions. At build time, it is also possible to compile support + for some other options, such as the Unicode functions provided + by GLib or the International Components for Unicode (ICU) + library. Generally, this option is only of interest for client + programs that have specific integration requirements or that do + a significant amount of customization. + + + If your program has access to other Unicode functions, however, + such as through a system library or application framework, you + might prefer to use those instead of the built-in + options. HarfBuzz supports this by implementing its Unicode + functions as a set of virtual methods that you can replace — + without otherwise affecting HarfBuzz's functionality. + + + The Unicode functions are specified in a structure called + unicode_funcs which is attached to each + buffer. But even though unicode_funcs is + associated with a hb_buffer_t, the functions + themselves are called by other HarfBuzz APIs that access + buffers, so it would be unwise for you to hook different + functions into different buffers. + + + In addition, you can mark your unicode_funcs + as immutable by calling + hb_unicode_funcs_make_immutable (ufuncs). + This is especially useful if your code is a + library or framework that will have its own client programs. By + marking your Unicode function choices as immutable, you prevent + your own client programs from changing the + unicode_funcs configuration and introducing + inconsistencies and errors downstream. + + + You can retrieve the Unicode-functions configuration for + your buffer by calling hb_buffer_get_unicode_funcs(): + + + hb_unicode_funcs_t *ufunctions; + ufunctions = hb_buffer_get_unicode_funcs(buf); + + + The current version of unicode_funcs uses six functions: + + + + + hb_unicode_combining_class_func_t: + returns the Canonical Combining Class of a code point. + + + + + hb_unicode_general_category_func_t: + returns the General Category (gc) of a code point. + + + + + hb_unicode_mirroring_func_t: returns + the Mirroring Glyph code point (for bi-directional + replacement) of a code point. + + + + + hb_unicode_script_func_t: returns the + Script (sc) property of a code point. + + + + + hb_unicode_compose_func_t: returns the + canonical composition of a sequence of two code points. + + + + + hb_unicode_decompose_func_t: returns + the canonical decomposition of a code point. + + + + + Note, however, that future HarfBuzz releases may alter this set. + + + Each Unicode function has a corresponding setter, with which you + can assign a callback to your replacement function. For example, + to replace + hb_unicode_general_category_func_t, you can call + + + hb_unicode_funcs_set_general_category_func (*ufuncs, func, *user_data, destroy) + + + Virtualizing this set of Unicode functions is primarily intended + to improve portability. There is no need for every client + program to make the effort to replace the default options, so if + you are unsure, do not feel any pressure to customize + unicode_funcs. + +
      + +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml b/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml new file mode 100644 index 000000000000..545afde89ed7 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-clusters.xml @@ -0,0 +1,701 @@ + + + +]> + + Clusters +
      + Clusters and shaping + + In text shaping, a cluster is a sequence of + characters that needs to be treated as a single, indivisible + unit. A single letter or symbol can be a cluster of its + own. Other clusters correspond to longer subsequences of the + input code points — such as a ligature or conjunct form + — and require the shaper to ensure that the cluster is not + broken during the shaping process. + + + A cluster is distinct from a grapheme, + which is the smallest unit of meaning in a writing system or + script. + + + The definitions of the two terms are similar. However, clusters + are only relevant for script shaping and glyph layout. In + contrast, graphemes are a property of the underlying script, and + are of interest when client programs implement orthographic + or linguistic functionality. + + + For example, two individual letters are often two separate + graphemes. When two letters form a ligature, however, they + combine into a single glyph. They are then part of the same + cluster and are treated as a unit by the shaping engine — + even though the two original, underlying letters remain separate + graphemes. + + + HarfBuzz is concerned with clusters, not + with graphemes — although client programs using HarfBuzz + may still care about graphemes for other reasons from time to time. + + + During the shaping process, there are several shaping operations + that may merge adjacent characters (for example, when two code + points form a ligature or a conjunct form and are replaced by a + single glyph) or split one character into several (for example, + when decomposing a code point through the + ccmp feature). Operations like these alter + clusters; HarfBuzz tracks the changes to ensure that no clusters + get lost or broken during shaping. + + + HarfBuzz records cluster information independently from how + shaping operations affect the individual glyphs returned in an + output buffer. Consequently, a client program using HarfBuzz can + utilize the cluster information to implement features such as: + + + + + Correctly positioning the cursor within a shaped text run, + even when characters have formed ligatures, composed or + decomposed, reordered, or undergone other shaping operations. + + + + + Correctly highlighting a text selection that includes some, + but not all, of the characters in a word. + + + + + Applying text attributes (such as color or underlining) to + part, but not all, of a word. + + + + + Generating output document formats (such as PDF) with + embedded text that can be fully extracted. + + + + + Determining the mapping between input characters and output + glyphs, such as which glyphs are ligatures. + + + + + Performing line-breaking, justification, and other + line-level or paragraph-level operations that must be done + after shaping is complete, but which require examining + character-level properties. + + + +
      +
      + Working with HarfBuzz clusters + + When you add text to a HarfBuzz buffer, each code point must be + assigned a cluster value. + + + This cluster value is an arbitrary number; HarfBuzz uses it only + to distinguish between clusters. Many client programs will use + the index of each code point in the input text stream as the + cluster value. This is for the sake of convenience; the actual + value does not matter. + + + Some of the shaping operations performed by HarfBuzz — + such as reordering, composition, decomposition, and substitution + — may alter the cluster values of some characters. The + final cluster values in the buffer at the end of the shaping + process will indicate to client programs which subsequences of + glyphs represent a cluster and, therefore, must not be + separated. + + + In addition, client programs can query the final cluster values + to discern other potentially important information about the + glyphs in the output buffer (such as whether or not a ligature + was formed). + + + For example, if the initial sequence of cluster values was: + + + 0,1,2,3,4 + + + and the final sequence of cluster values is: + + + 0,0,3,3 + + + then there are two clusters in the output buffer: the first + cluster includes the first two glyphs, and the second cluster + includes the third and fourth glyphs. It is also evident that a + ligature or conjunct has been formed, because there are fewer + glyphs in the output buffer (four) than there were code points + in the input buffer (five). + + + Although client programs using HarfBuzz are free to assign + initial cluster values in any manner they choose to, HarfBuzz + does offer some useful guarantees if the cluster values are + assigned in a monotonic (either non-decreasing or non-increasing) + order. + + + For buffers in the left-to-right (LTR) + or top-to-bottom (TTB) text flow direction, + HarfBuzz will preserve the monotonic property: client programs + are guaranteed that monotonically increasing initial cluster + values will be returned as monotonically increasing final + cluster values. + + + For buffers in the right-to-left (RTL) + or bottom-to-top (BTT) text flow direction, + the directionality of the buffer itself is reversed for final + output as a matter of design. Therefore, HarfBuzz inverts the + monotonic property: client programs are guaranteed that + monotonically increasing initial cluster values will be + returned as monotonically decreasing final + cluster values. + + + Client programs can adjust how HarfBuzz handles clusters during + shaping by setting the + cluster_level of the + buffer. HarfBuzz offers three levels of + clustering support for this property: + + + + Level 0 is the default. + + + The distinguishing feature of level 0 behavior is that, at + the beginning of processing the buffer, all code points that + are categorized as marks, + modifier symbols, or + Emoji extended pictographic modifiers, + as well as the Zero Width Joiner and + Zero Width Non-Joiner code points, are + assigned the cluster value of the closest preceding code + point from different category. + + + In essence, whenever a base character is followed by a mark + character or a sequence of mark characters, those marks are + reassigned to the same initial cluster value as the base + character. This reassignment is referred to as + "merging" the affected clusters. This behavior is based on + the Grapheme Cluster Boundary specification in Unicode + Technical Report 29. + + + This cluster level is suitable for code that likes to use + HarfBuzz cluster values as an approximation of the Unicode + Grapheme Cluster Boundaries as well. + + + Client programs can specify level 0 behavior for a buffer by + setting its cluster_level to + HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. + + + + + Level 1 tweaks the old behavior + slightly to produce better results. Therefore, level 1 + clustering is recommended for code that is not required to + implement backward compatibility with the old HarfBuzz. + + + Level 1 differs from level 0 by not merging the + clusters of marks and other modifier code points with the + preceding "base" code point's cluster. By preserving the + separate cluster values of these marks and modifier code + points, script shapers can perform additional operations + that might lead to improved results (for example, coloring + mark glyphs differently than their base). + + + Client programs can specify level 1 behavior for a buffer by + setting its cluster_level to + HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS. + + + + + Level 2 differs significantly in how it + treats cluster values. In level 2, HarfBuzz never merges + clusters. + + + This difference can be seen most clearly when HarfBuzz processes + ligature substitutions and glyph decompositions. In level 0 + and level 1, ligatures and glyph decomposition both involve + merging clusters; in level 2, neither of these operations + triggers a merge. + + + Client programs can specify level 2 behavior for a buffer by + setting its cluster_level to + HB_BUFFER_CLUSTER_LEVEL_CHARACTERS. + + + + + As mentioned earlier, client programs using HarfBuzz often + assign initial cluster values in a buffer by reusing the indices + of the code points in the input text. This gives a sequence of + cluster values that is monotonically increasing (for example, + 0,1,2,3,4). + + + It is not required that the cluster values + in a buffer be monotonically increasing. However, if the initial + cluster values in a buffer are monotonic and the buffer is + configured to use cluster level 0 or 1, then HarfBuzz + guarantees that the final cluster values in the shaped buffer + will also be monotonic. No such guarantee is made for cluster + level 2. + + + In levels 0 and 1, HarfBuzz implements the following conceptual + model for cluster values: + + + + + If the sequence of input cluster values is monotonic, the + sequence of cluster values will remain monotonic. + + + + + Each cluster value represents a single cluster. + + + + + Each cluster contains one or more glyphs and one or more + characters. + + + + + In practice, this model offers several benefits. Assuming that + the initial cluster values were monotonically increasing + and distinct before shaping began, then, in the final output: + + + + + All adjacent glyphs having the same final cluster + value belong to the same cluster. + + + + + Each character belongs to the cluster that has the highest + cluster value not larger than its + initial cluster value. + + + +
      + +
      + A clustering example for levels 0 and 1 + + The basic shaping operations affect clusters in a predictable + manner when using level 0 or level 1: + + + + + When two or more clusters merge, the + resulting merged cluster takes as its cluster value the + minimum of the incoming cluster values. + + + + + When a cluster decomposes, all of the + resulting child clusters inherit as their cluster value the + cluster value of the parent cluster. + + + + + When a character is reordered, the + reordered character and all clusters that the character + moves past as part of the reordering are merged into one cluster. + + + + + The functionality, guarantees, and benefits of level 0 and level + 1 behavior can be seen with some examples. First, let us examine + what happens with cluster values when shaping involves cluster + merging with ligatures and decomposition. + + + + Let's say we start with the following character sequence (top row) and + initial cluster values (bottom row): + + + A,B,C,D,E + 0,1,2,3,4 + + + During shaping, HarfBuzz maps these characters to glyphs from + the font. For simplicity, let us assume that each character maps + to the corresponding, identical-looking glyph: + + + A,B,C,D,E + 0,1,2,3,4 + + + Now if, for example, B and C + form a ligature, then the clusters to which they belong + "merge". This merged cluster takes for its cluster + value the minimum of all the cluster values of the clusters that + went in to the ligature. In this case, we get: + + + A,BC,D,E + 0,1 ,3,4 + + + because 1 is the minimum of the set {1,2}, which were the + cluster values of B and + C. + + + Next, let us say that the BC ligature glyph + decomposes into three components, and D also + decomposes into two components. Whenever a cluster decomposes, + its components each inherit the cluster value of their parent: + + + A,BC0,BC1,BC2,D0,D1,E + 0,1 ,1 ,1 ,3 ,3 ,4 + + + Next, if BC2 and D0 form a + ligature, then their clusters (cluster values 1 and 3) merge into + min(1,3) = 1: + + + A,BC0,BC1,BC2D0,D1,E + 0,1 ,1 ,1 ,1 ,4 + + + Note that the entirety of cluster 3 merges into cluster 1, not + just the D0 glyph. This reflects the fact + that the cluster must be treated as an + indivisible unit. + + + At this point, cluster 1 means: the character sequence + BCD is represented by glyphs + BC0,BC1,BC2D0,D1 and cannot be broken down any + further. + +
      +
      + Reordering in levels 0 and 1 + + Another common operation in some shapers is glyph + reordering. In order to maintain a monotonic cluster sequence + when glyph reordering takes place, HarfBuzz merges the clusters + of everything in the reordering sequence. + + + For example, let us again start with the character sequence (top + row) and initial cluster values (bottom row): + + + A,B,C,D,E + 0,1,2,3,4 + + + If D is reordered to the position immediately + before B, then HarfBuzz merges the + B, C, and + D clusters — all the clusters between + the final position of the reordered glyph and its original + position. This means that we get: + + + A,D,B,C,E + 0,1,1,1,4 + + + as the final cluster sequence. + + + Merging this many clusters is not ideal, but it is the only + sensible way for HarfBuzz to maintain the guarantee that the + sequence of cluster values remains monotonic and to retain the + true relationship between glyphs and characters. + +
      +
      + The distinction between levels 0 and 1 + + The preceding examples demonstrate the main effects of using + cluster levels 0 and 1. The only difference between the two + levels is this: in level 0, at the very beginning of the shaping + process, HarfBuzz merges the cluster of each base character + with the clusters of all Unicode marks (combining or not) and + modifiers that follow it. + + + For example, let us start with the following character sequence + (top row) and accompanying initial cluster values (bottom row): + + + A,acute,B + 0,1 ,2 + + + The acute is a Unicode mark. If HarfBuzz is + using cluster level 0 on this sequence, then the + A and acute clusters will + merge, and the result will become: + + + A,acute,B + 0,0 ,2 + + + This merger is performed before any other script-shaping + steps. + + + This initial cluster merging is the default behavior of the + Windows shaping engine, and the old HarfBuzz codebase copied + that behavior to maintain compatibility. Consequently, it has + remained the default behavior in the new HarfBuzz codebase. + + + But this initial cluster-merging behavior makes it impossible + for client programs to implement some features (such as to + color diacritic marks differently from their base + characters). That is why, in level 1, HarfBuzz does not perform + the initial merging step. + + + For client programs that rely on HarfBuzz cluster values to + perform cursor positioning, level 0 is more convenient. But + relying on cluster boundaries for cursor positioning is wrong: cursor + positions should be determined based on Unicode grapheme + boundaries, not on shaping-cluster boundaries. As such, using + level 1 clustering behavior is recommended. + + + One final facet of levels 0 and 1 is worth noting. HarfBuzz + currently does not allow any + multiple-substitution GSUB lookups to + replace a glyph with zero glyphs (in other words, to delete a + glyph). + + + But, in some other situations, glyphs can be deleted. In + those cases, if the glyph being deleted is the last glyph of its + cluster, HarfBuzz makes sure to merge the deleted glyph's + cluster with a neighboring cluster. + + + This is done primarily to make sure that the starting cluster of the + text always has the cluster index pointing to the start of the text + for the run; more than one client program currently relies on this + guarantee. + + + Incidentally, Apple's CoreText does something different to + maintain the same promise: it inserts a glyph with id 65535 at + the beginning of the glyph string if the glyph corresponding to + the first character in the run was deleted. HarfBuzz might do + something similar in the future. + +
      +
      + Level 2 + + HarfBuzz's level 2 cluster behavior uses a significantly + different model than that of level 0 and level 1. + + + The level 2 behavior is easy to describe, but it may be + difficult to understand in practical terms. In brief, level 2 + performs no merging of clusters whatsoever. + + + This means that there is no initial base-and-mark merging step + (as is done in level 0), and it means that reordering moves and + ligature substitutions do not trigger a cluster merge. + + + Only one shaping operation directly affects clusters when using + level 2: + + + + + When a cluster decomposes, all of the + resulting child clusters inherit as their cluster value the + cluster value of the parent cluster. + + + + + When glyphs do form a ligature (or when some other feature + substitutes multiple glyphs with one glyph) the cluster value + of the first glyph is retained as the cluster value for the + resulting ligature. + + + This occurrence sounds similar to a cluster merge, but it is + different. In particular, no subsequent characters — + including marks and modifiers — are affected. They retain + their previous cluster values. + + + Level 2 cluster behavior is ultimately less complex than level 0 + or level 1, but there are several cases for which processing + cluster values produced at level 2 may be tricky. + +
      + Ligatures with combining marks in level 2 + + The first example of how HarfBuzz's level 2 cluster behavior + can be tricky is when the text to be shaped includes combining + marks attached to ligatures. + + + Let us start with an input sequence with the following + characters (top row) and initial cluster values (bottom row): + + + A,acute,B,breve,C,circumflex + 0,1 ,2,3 ,4,5 + + + If the sequence A,B,C forms a ligature, + then these are the cluster values HarfBuzz will return under + the various cluster levels: + + + Level 0: + + + ABC,acute,breve,circumflex + 0 ,0 ,0 ,0 + + + Level 1: + + + ABC,acute,breve,circumflex + 0 ,0 ,0 ,5 + + + Level 2: + + + ABC,acute,breve,circumflex + 0 ,1 ,3 ,5 + + + Making sense of the level 2 result is the hardest for a client + program, because there is nothing in the cluster values that + indicates that B and C + formed a ligature with A. + + + In contrast, the "merged" cluster values of the mark glyphs + that are seen in the level 0 and level 1 output are evidence + that a ligature substitution took place. + +
      +
      + Reordering in level 2 + + Another example of how HarfBuzz's level 2 cluster behavior + can be tricky is when glyphs reorder. Consider an input sequence + with the following characters (top row) and initial cluster + values (bottom row): + + + A,B,C,D,E + 0,1,2,3,4 + + + Now imagine D moves before + B in a reordering operation. The cluster + values will then be: + + + A,D,B,C,E + 0,3,1,2,4 + + + Next, if D forms a ligature with + B, the output is: + + + A,DB,C,E + 0,3 ,2,4 + + + However, in a different scenario, in which the shaping rules + of the script instead caused A and + B to form a ligature + before the D reordered, the + result would be: + + + AB,D,C,E + 0 ,3,2,4 + + + There is no way for a client program to differentiate between + these two scenarios based on the cluster values + alone. Consequently, client programs that use level 2 might + need to undertake additional work in order to manage cursor + positioning, text attributes, or other desired features. + +
      +
      + Other considerations in level 2 + + There may be other problems encountered with ligatures under + level 2, such as if the direction of the text is forced to + the opposite of its natural direction (for example, Arabic text + that is forced into left-to-right directionality). But, + generally speaking, these other scenarios are minor corner + cases that are too obscure for most client programs to need to + worry about. + +
      +
      +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml b/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml new file mode 100644 index 000000000000..39233948bee5 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-fonts-and-faces.xml @@ -0,0 +1,518 @@ + + + +]> + + Fonts, faces, and output + + In the previous chapter, we saw how to set up a buffer and fill + it with text as Unicode code points. In order to shape this + buffer text with HarfBuzz, you will need also need a font + object. + + + HarfBuzz provides abstractions to help you cache and reuse the + heavier parts of working with binary fonts, so we will look at + how to do that. We will also look at how to work with the + FreeType font-rendering library and at how you can customize + HarfBuzz to work with other libraries. + + + Finally, we will look at how to work with OpenType variable + fonts, the latest update to the OpenType font format, and at + some other recent additions to OpenType. + + +
      + Font and face objects + + The outcome of shaping a run of text depends on the contents of + a specific font file (such as the substitutions and positioning + moves in the 'GSUB' and 'GPOS' tables), so HarfBuzz makes + accessing those internals fast. + + + An hb_face_t represents a face + in HarfBuzz. This data type is a wrapper around an + hb_blob_t blob that holds the contents of a binary + font file. Since HarfBuzz supports TrueType Collections and + OpenType Collections (each of which can include multiple + typefaces), a HarfBuzz face also requires an index number + specifying which typeface in the file you want to use. Most of + the font files you will encounter in the wild include just a + single face, however, so most of the time you would pass in + 0 as the index when you create a face: + + + hb_blob_t* blob = hb_blob_create_from_file(file); + ... + hb_face_t* face = hb_face_create(blob, 0); + + + On its own, a face object is not quite ready to use for + shaping. The typeface must be set to a specific point size in + order for some details (such as hinting) to work. In addition, + if the font file in question is an OpenType Variable Font, then + you may need to specify one or more variation-axis settings (or a + named instance) in order to get the output you need. + + + In HarfBuzz, you do this by creating a font + object from your face. + + + Font objects also have the advantage of being considerably + lighter-weight than face objects (remember that a face contains + the contents of a binary font file mapped into memory). As a + result, you can cache and reuse a font object, but you could + also create a new one for each additional size you needed. + Creating new fonts incurs some additional overhead, of course, + but whether or not it is excessive is your call in the end. In + contrast, face objects are substantially larger, and you really + should cache them and reuse them whenever possible. + + + You can create a font object from a face object: + + + hb_font_t* hb_font = hb_font_create(hb_face); + + + After creating a font, there are a few properties you should + set. Many fonts enable and disable hints based on the size it + is used at, so setting this is important for font + objects. hb_font_set_ppem(font, x_ppem, + y_ppem) sets the pixels-per-EM value of the font. You + can also set the point size of the font with + hb_font_set_ptem(font, ptem). HarfBuzz uses the + industry standard 72 points per inch. + + + HarfBuzz lets you specify the degree subpixel precision you want + through a scaling factor. You can set horizontal and + vertical scaling factors on the + font by calling hb_font_set_scale(font, x_scale, + y_scale). + + + There may be times when you are handed a font object and need to + access the face object that it comes from. For that, you can call + + + hb_face = hb_font_get_face(hb_font); + + + You can also create a font object from an existing font object + using the hb_font_create_sub_font() + function. This creates a child font object that is initiated + with the same attributes as its parent; it can be used to + quickly set up a new font for the purpose of overriding a specific + font-functions method. + + + All face objects and font objects are lifecycle-managed by + HarfBuzz. After creating a face, you increase its reference + count with hb_face_reference(face) and + decrease it with + hb_face_destroy(face). Likewise, you + increase the reference count on a font with + hb_font_reference(font) and decrease it + with hb_font_destroy(font). + + + You can also attach user data to face objects and font objects. + +
      + +
      + Customizing font functions + + During shaping, HarfBuzz frequently needs to query font objects + to get at the contents and parameters of the glyphs in a font + file. It includes a built-in set of functions that is tailored + to working with OpenType fonts. However, as was the case with + Unicode functions in the buffers chapter, HarfBuzz also wants to + make it easy for you to assign a substitute set of font + functions if you are developing a program to work with a library + or platform that provides its own font functions. + + + Therefore, the HarfBuzz API defines a set of virtual + methods for accessing font-object properties, and you can + replace the defaults with your own selections without + interfering with the shaping process. Each font object in + HarfBuzz includes a structure called + font_funcs that serves as a vtable for the + font object. The virtual methods in + font_funcs are: + + + + + hb_font_get_font_h_extents_func_t: returns + the extents of the font for horizontal text. + + + + + hb_font_get_font_v_extents_func_t: returns + the extents of the font for vertical text. + + + + + hb_font_get_nominal_glyph_func_t: returns + the font's nominal glyph for a given code point. + + + + + hb_font_get_variation_glyph_func_t: returns + the font's glyph for a given code point when it is followed by a + given Variation Selector. + + + + + hb_font_get_nominal_glyphs_func_t: returns + the font's nominal glyphs for a series of code points. + + + + + hb_font_get_glyph_advance_func_t: returns + the advance for a glyph. + + + + + hb_font_get_glyph_h_advance_func_t: returns + the advance for a glyph for horizontal text. + + + + + hb_font_get_glyph_v_advance_func_t:returns + the advance for a glyph for vertical text. + + + + + hb_font_get_glyph_advances_func_t: returns + the advances for a series of glyphs. + + + + + hb_font_get_glyph_h_advances_func_t: returns + the advances for a series of glyphs for horizontal text . + + + + + hb_font_get_glyph_v_advances_func_t: returns + the advances for a series of glyphs for vertical text. + + + + + hb_font_get_glyph_origin_func_t: returns + the origin coordinates of a glyph. + + + + + hb_font_get_glyph_h_origin_func_t: returns + the origin coordinates of a glyph for horizontal text. + + + + + hb_font_get_glyph_v_origin_func_t: returns + the origin coordinates of a glyph for vertical text. + + + + + hb_font_get_glyph_extents_func_t: returns + the extents for a glyph. + + + + + hb_font_get_glyph_contour_point_func_t: + returns the coordinates of a specific contour point from a glyph. + + + + + hb_font_get_glyph_name_func_t: returns the + name of a glyph (from its glyph index). + + + + + hb_font_get_glyph_from_name_func_t: returns + the glyph index that corresponds to a given glyph name. + + + + + hb_font_draw_glyph_func_t: gets the outlines + of a glyph (by calling #hb_draw_funcs_t callbacks). + + + + + hb_font_paint_glyph_func_t: paints a glyph + (by calling #hb_paint_funcs_t callbacks). + + + + + You can create new font-functions by calling + hb_font_funcs_create(): + + + hb_font_funcs_t *ffunctions = hb_font_funcs_create (); + hb_font_set_funcs (font, ffunctions, font_data, destroy); + + + The individual methods can each be set with their own setter + function, such as + hb_font_funcs_set_nominal_glyph_func(ffunctions, + func, user_data, destroy). + + + Font-functions structures can be reused for multiple font + objects, and can be reference counted with + hb_font_funcs_reference() and + hb_font_funcs_destroy(). Just like other + objects in HarfBuzz, you can set user-data for each + font-functions structure and assign a destroy callback for + it. + + + You can also mark a font-functions structure as immutable, + with hb_font_funcs_make_immutable(). This + is especially useful if your code is a library or framework that + will have its own client programs. By marking your + font-functions structures as immutable, you prevent your client + programs from changing the configuration and introducing + inconsistencies and errors downstream. + + + To override only some functions while using the default implementation + for the others, you will need to create a sub-font. By default, the + sub-font uses the font functions of its parent except for the functions + that were explicitly set. The following code will override only the + hb_font_get_nominal_glyph_func_t for the sub-font: + + + hb_font_t *subfont = hb_font_create_sub_font (font) + hb_font_funcs_t *ffunctions = hb_font_funcs_create (); + hb_font_funcs_set_nominal_glyph_func (ffunctions, func, user_data, destroy); + hb_font_set_funcs (subfont, ffunctions, font_data, destroy); + hb_font_funcs_destroy (ffunctions); + +
      + +
      + Font objects and HarfBuzz's native OpenType implementation + + By default, whenever HarfBuzz creates a font object, it will + configure the font to use a built-in set of font functions that + supports contemporary OpenType font internals. If you want to + work with OpenType or TrueType fonts, you should be able to use + these functions without difficulty. + + + Many of the methods in the font-functions structure deal with + the fundamental properties of glyphs that are required for + shaping text: extents (the maximums and minimums on each axis), + origins (the (0,0) coordinate point which + glyphs are drawn in reference to), and advances (the amount that + the cursor needs to be moved after drawing each glyph, including + any empty space for the glyph's side bearings). + + + As you can see in the list of functions, there are separate "horizontal" + and "vertical" variants depending on whether the text is set in + the horizontal or vertical direction. For some scripts, fonts + that are designed to support text set horizontally or vertically (for + example, in Japanese) may include metrics for both text + directions. When fonts don't include this information, HarfBuzz + does its best to transform what the font provides. + + + In addition to the direction-specific functions, HarfBuzz + provides some higher-level functions for fetching information + like extents and advances for a glyph. If you call + + + hb_font_get_glyph_advance_for_direction(font, direction, extents); + + + then you can provide any hb_direction_t as the + direction parameter, and HarfBuzz will + use the correct function variant for the text direction. There + are similar higher-level versions of the functions for fetching + extents, origin coordinates, and contour-point + coordinates. There are also addition and subtraction functions + for moving points with respect to the origin. + + + There are also methods for fetching the glyph ID that + corresponds to a Unicode code point (possibly when followed by a + variation-selector code point), fetching the glyph name from the + font, and fetching the glyph ID that corresponds to a glyph name + you already have. + + + HarfBuzz also provides functions for converting between glyph + names and string + variables. hb_font_glyph_to_string(font, glyph, s, + size) retrieves the name for the glyph ID + glyph from the font object. It generates a + generic name of the form gidDDD (where DDD is + the glyph index) if there is no name for the glyph in the + font. The hb_font_glyph_from_string(font, s, len, + glyph) takes an input string s + and looks for a glyph with that name in the font, returning its + glyph ID in the glyph + output parameter. It automatically parses + gidDDD and uniUUUU strings. + +
      + +
      + Working with OpenType Variable Fonts + + If you are working with OpenType Variable Fonts, there are a few + additional functions you should use to specify the + variation-axis settings of your font object. Without doing so, + your variable font's font object can still be used, but only at + the default setting for every axis (which, of course, is + sometimes what you want, but does not cover general usage). + + + HarfBuzz manages variation settings in the + hb_variation_t data type, which holds a tag for the + variation-axis identifier tag and a value for its + setting. You can retrieve the list of variation axes in a font + binary from the face object (not from a font object, notably) by + calling hb_ot_var_get_axis_count(face) to + find the number of axes, then using + hb_ot_var_get_axis_infos() to collect the + axis structures: + + + axes = hb_ot_var_get_axis_count(face); + ... + hb_ot_var_get_axis_infos(face, 0, axes, axes_array); + + + For each axis returned in the array, you can can access the + identifier in its tag. HarfBuzz also has + tag definitions predefined for the five standard axes specified + in OpenType (ital for italic, + opsz for optical size, + slnt for slant, wdth for + width, and wght for weight). Each axis also + has a min_value, a + default_value, and a max_value. + + + To set your font object's variation settings, you call the + hb_font_set_variations() function with an + array of hb_variation_t variation settings. Let's + say our font has weight and width axes. We need to specify each + of the axes by tag and assign a value on the axis: + + + unsigned int variation_count = 2; + hb_variation_t variation_data[variation_count]; + variation_data[0].tag = HB_OT_TAG_VAR_AXIS_WIDTH; + variation_data[1].tag = HB_OT_TAG_VAR_AXIS_WEIGHT; + variation_data[0].value = 80; + variation_data[1].value = 750; + ... + hb_font_set_variations(font, variation_data, variation_count); + + + That should give us a slightly condensed font ("normal" on the + wdth axis is 100) at a noticeably bolder + weight ("regular" is 400 on the wght axis). + + + In practice, though, you should always check that the value you + want to set on the axis is within the + [min_value,max_value] + range actually implemented in the font's variation axis. After + all, a font might only provide lighter-than-regular weights, and + setting a heavier value on the wght axis will + not change that. + + + Once your variation settings are specified on your font object, + however, shaping with a variable font is just like shaping a + static font. + + + In addition to providing the variation axes themselves, fonts may also + pre-define certain variation coordinates as named instances. HarfBuzz + makes these coordinates (and their associated names) available via + hb_ot_var_named_instance_get_design_coords() and + hb_ot_var_named_instance_get_subfamily_name_id(). + + + Applications should treat named instances like multiple independent, + static fonts. + +
      + +
      + Glyphs and rendering + + + The main purpose of HarfBuzz is shaping, which creates a list of positioned + glyphs as output. The remaining task for text layout is to convert this list + into rendered output. While HarfBuzz does not handle rasterization of glyphs + per se, it does have APIs that provide access to the font data that is needed + to perform this task. + + + Traditionally, the shapes of glyphs in scalable fonts are provided as quadratic + or cubic Beziér curves defining outlines to be filled. To obtain the outlines + for a glyph, call hb_font_draw_glyph() and pass a + hb_draw_funcs_t struct. The callbacks in that struct will be called + for each segment of the outline. Note that this API provides access to outlines + as they are defined in the font, without applying hinting to fit the curves + to the pixel grid. + + + Fonts may provide pre-rendered images for glyphs instead of or in addition to + outlines. This is most common for fonts that contain colored glyphs, such as + Emoji. To access these images, use hb_ot_color_reference_png() + or hb_ot_color_reference_svg(). + + + Another way in which fonts provide colored glyphs is via paint graphs that + combine glyph outlines with gradients and allow for transformations and + compositing. In its simplest form, this can be presented as a series of + layers that are rendered on top of each other, each with its own color. + HarfBuzz has the hb_ot_color_glyph_get_layers() to + access glyph data in this form. + + + In the general case, you have to use hb_font_paint_glyph() + and pass a hb_paint_funcs_t struct with callbacks to obtain paint + graphs for glyphs that have them. The hb_font_paint_glyph() + API can handle outline and image glyphs as well, so it provides a unified API for + access to glyph rendering information. + +
      + +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml b/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml new file mode 100644 index 000000000000..eb8c1d728385 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-getting-started.xml @@ -0,0 +1,312 @@ + + + +]> + + Getting started with HarfBuzz +
      + An overview of the HarfBuzz shaping API + + The core of the HarfBuzz shaping API is the function + hb_shape(). This function takes a font, a + buffer containing a string of Unicode codepoints and + (optionally) a list of font features as its input. It replaces + the codepoints in the buffer with the corresponding glyphs from + the font, correctly ordered and positioned, and with any of the + optional font features applied. + + + In addition to holding the pre-shaping input (the Unicode + codepoints that comprise the input string) and the post-shaping + output (the glyphs and positions), a HarfBuzz buffer has several + properties that affect shaping. The most important are the + text-flow direction (e.g., left-to-right, right-to-left, + top-to-bottom, or bottom-to-top), the script tag, and the + language tag. + + + + For input string buffers, flags are available to denote when the + buffer represents the beginning or end of a paragraph, to + indicate whether or not to visibly render Unicode Default + Ignorable codepoints, and to modify the cluster-merging + behavior for the buffer. For shaped output buffers, the + individual X and Y offsets and advances + (the logical dimensions) of each glyph are + accessible. HarfBuzz also flags glyphs as + UNSAFE_TO_BREAK if breaking the string at + that glyph (e.g., in a line-breaking or hyphenation process) + would require re-shaping the text. + + + + HarfBuzz also provides methods to compare the contents of + buffers, join buffers, normalize buffer contents, and handle + invalid codepoints, as well as to determine the state of a + buffer (e.g., input codepoints or output glyphs). Buffer + lifecycles are managed and all buffers are reference-counted. + + + + Although the default hb_shape() function is + sufficient for most use cases, a variant is also provided that + lets you specify which of HarfBuzz's shapers to use on a buffer. + + + + HarfBuzz can read TrueType fonts, TrueType collections, OpenType + fonts, and OpenType collections. Functions are provided to query + font objects about metrics, Unicode coverage, available tables and + features, and variation selectors. Individual glyphs can also be + queried for metrics, variations, and glyph names. OpenType + variable fonts are supported, and HarfBuzz allows you to set + variation-axis coordinates on font objects. + + + + HarfBuzz provides glue code to integrate with various other + libraries, including FreeType, GObject, and CoreText. Support + for integrating with Uniscribe and DirectWrite is experimental + at present. + +
      + +
      + Terminology + + + + + + + script + + + In text shaping, a script is a + writing system: a set of symbols, rules, and conventions + that is used to represent a language or multiple + languages. + + + In general computing lingo, the word "script" can also + be used to mean an executable program (usually one + written in a human-readable programming language). For + the sake of clarity, HarfBuzz documents will always use + more specific terminology when referring to this + meaning, such as "Python script" or "shell script." In + all other instances, "script" refers to a writing system. + + + For developers using HarfBuzz, it is important to note + the distinction between a script and a language. Most + scripts are used to write a variety of different + languages, and many languages may be written in more + than one script. + + + + + + shaper + + + In HarfBuzz, a shaper is a + handler for a specific script-shaping model. HarfBuzz + implements separate shapers for Indic, Arabic, Thai and + Lao, Khmer, Myanmar, Tibetan, Hangul, Hebrew, the + Universal Shaping Engine (USE), and a default shaper for + scripts with no script-specific shaping model. + + + + + + cluster + + + In text shaping, a cluster is a + sequence of codepoints that must be treated as an + indivisible unit. Clusters can include code-point + sequences that form a ligature or base-and-mark + sequences. Tracking and preserving clusters is important + when shaping operations might separate or reorder + code points. + + + HarfBuzz provides three cluster + levels that implement different + approaches to the problem of preserving clusters during + shaping operations. + + + + + + grapheme + + + In linguistics, a grapheme is one + of the indivisible units that make up a writing system or + script. Often, graphemes are individual symbols (letters, + numbers, punctuation marks, logograms, etc.) but, + depending on the writing system, a particular grapheme + might correspond to a sequence of several Unicode code + points. + + + In practice, HarfBuzz and other text-shaping engines + are not generally concerned with graphemes. However, it + is important for developers using HarfBuzz to recognize + that there is a difference between graphemes and shaping + clusters (see above). The two concepts may overlap + frequently, but there is no guarantee that they will be + identical. + + + + + + syllable + + + In linguistics, a syllable is an + a sequence of sounds that makes up a building block of a + particular language. Every language has its own set of + rules describing what constitutes a valid syllable. + + + For text-shaping purposes, the various definitions of + "syllable" are important because script-specific shaping + operations may be applied at the syllable level. For + example, a reordering rule might specify that a vowel + mark be reordered to the beginning of the syllable. + + + Syllables will consist of one or more Unicode code + points. The definition of a syllable for a particular + writing system might correspond to how HarfBuzz + identifies clusters (see above) for the same writing + system. However, it is important for developers using + HarfBuzz to recognize that there is a difference between + syllables and shaping clusters. The two concepts may + overlap frequently, but there is no guarantee that they + will be identical. + + + + + +
      + + +
      + A simple shaping example + + + Below is the simplest HarfBuzz shaping example possible. + + + + + Create a buffer and put your text in it. + + + + + #include <hb.h> + + hb_buffer_t *buf; + buf = hb_buffer_create(); + hb_buffer_add_utf8(buf, text, -1, 0, -1); + + + + + Set the script, language and direction of the buffer. + + + + + hb_buffer_set_direction(buf, HB_DIRECTION_LTR); + hb_buffer_set_script(buf, HB_SCRIPT_LATIN); + hb_buffer_set_language(buf, hb_language_from_string("en", -1)); + + + + + Create a face and a font from a font file. + + + + + hb_blob_t *blob = hb_blob_create_from_file(filename); /* or hb_blob_create_from_file_or_fail() */ + hb_face_t *face = hb_face_create(blob, 0); + hb_font_t *font = hb_font_create(face); + + + + + Shape! + + + + + hb_shape(font, buf, NULL, 0); + + + + + Get the glyph and position information. + + + + + unsigned int glyph_count; + hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count); + hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count); + + + + + Iterate over each glyph. + + + + + hb_position_t cursor_x = 0; + hb_position_t cursor_y = 0; + for (unsigned int i = 0; i < glyph_count; i++) { + hb_codepoint_t glyphid = glyph_info[i].codepoint; + hb_position_t x_offset = glyph_pos[i].x_offset; + hb_position_t y_offset = glyph_pos[i].y_offset; + hb_position_t x_advance = glyph_pos[i].x_advance; + hb_position_t y_advance = glyph_pos[i].y_advance; + /* draw_glyph(glyphid, cursor_x + x_offset, cursor_y + y_offset); */ + cursor_x += x_advance; + cursor_y += y_advance; + } + + + + + Tidy up. + + + + + hb_buffer_destroy(buf); + hb_font_destroy(font); + hb_face_destroy(face); + hb_blob_destroy(blob); + + + + This example shows enough to get us started using HarfBuzz. In + the sections that follow, we will use the remainder of + HarfBuzz's API to refine and extend the example and improve its + text-shaping capabilities. + +
      +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml b/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml new file mode 100644 index 000000000000..78f06c73912a --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-glyph-information.xml @@ -0,0 +1,14 @@ + + + +]> + + Glyph information + + Names and numbers + + + + diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml b/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml new file mode 100644 index 000000000000..760b9c5aad28 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-install-harfbuzz.xml @@ -0,0 +1,349 @@ + + + +]> + + Installing HarfBuzz + +
      + Downloading HarfBuzz + + The HarfBuzz source code is hosted at github.com/harfbuzz/harfbuzz. + + + Tarball releases and Win32 binary bundles (which include the + libharfbuzz DLL, hb-view.exe, hb-shape.exe, and all + dependencies) of HarfBuzz can be downloaded from github.com/harfbuzz/harfbuzz/releases. + + + Release notes are posted with each new release to provide an + overview of the changes. The project tracks bug + reports and other issues on GitHub. Discussion and + questions are welcome on GitHub as well. + + + The API included in the hb.h file will not change in a + compatibility-breaking way in any release. However, other, + peripheral headers are more likely to go through minor + modifications. We will do our best to never change APIs in an + incompatible way. We will never break the ABI. + +
      + +
      + Building HarfBuzz + +
      + Building on Linux + + (1) To build HarfBuzz on Linux, you must first install the + development packages for FreeType, Cairo, and GLib. The exact + commands required for this step will vary depending on + the Linux distribution you use. + + + For example, on an Ubuntu or Debian system, you would run: + sudo apt install gcc g++ libfreetype6-dev libglib2.0-dev libcairo2-dev + On Fedora, RHEL, CentOS, or other Red-Hat–based systems, you would run: + sudo yum install gcc gcc-c++ freetype-devel glib2-devel cairo-devel + + + + + (2) The next step depends on whether you + are building from the source in a downloaded release tarball or + from the source directly from the git repository. + + + (2)(a) If you downloaded the HarfBuzz + source code in a tarball, you can now extract the source. + + + From a shell in the top-level directory of the extracted source + code, you can run meson build followed by + meson compile -C build as with any other standard package. + + + This should leave you with a shared + library in the src/ directory, and a few + utility programs including hb-view and + hb-shape under the util/ + directory. + + + (2)(b) If you are building from the source in the HarfBuzz git + repository, rather than installing from a downloaded tarball + release, then you must install two more auxiliary tools before you + can build for the first time: pkg-config. + + + On Ubuntu or Debian, run: + sudo apt-get install meson pkg-config gtk-doc-tools + On Fedora, RHEL, CentOS, run: + sudo yum install meson pkgconfig gtk-doc + + + + With pkg-config installed, you can now run + meson build then + meson compile -C build to build HarfBuzz. + +
      + + +
      + Building on Windows + + + Install meson + and run (from the console) meson build (by default + bundled dependencies are not built, --wrap-mode=default + overrides this), then meson compile -C build to + build HarfBuzz. + +
      + + +
      + Building on macOS + + + There are two ways to build HarfBuzz on Mac systems: MacPorts + and Homebrew. The process is similar to the process used on a + Linux system. + + + (1) You must first install the + development packages for FreeType, Cairo, and GLib. If you are + using MacPorts, you should run: + sudo port install freetype glib2 cairo + + + If you are using Homebrew, you should run: + brew install freetype glib cairo + + + (2) The next step depends on whether you are building from the + source in a downloaded release tarball or from the source directly + from the git repository. + + + (2)(a) If you are installing HarfBuzz + from a downloaded tarball release, extract the tarball and + open a Terminal in the extracted source-code directory. Run: + meson build + followed by: + meson compile -C build + to build HarfBuzz. + + + (2)(b) Alternatively, if you are building + HarfBuzz from the source in the HarfBuzz git repository, then + you must install several built-time dependencies before + proceeding. + + If you are + using MacPorts, you should run: + sudo port install meson pkgconfig gtk-doc + to install the build dependencies. + + If you are using Homebrew, you should run: + brew install meson pkgconfig gtk-doc + Finally, you can run: + meson build + + + (3) You can now build HarfBuzz (on either + a MacPorts or a Homebrew system) by running: + meson build + followed by: + meson compile -C build + + + This should leave you with a shared + library in the src/ directory, and a few + utility programs including hb-view and + hb-shape under the util/ + directory. + + +
      + +
      + Configuration options + + + The instructions in the "Building HarfBuzz" section will build + the source code under its default configuration. If needed, + the following additional configuration options are available. + + + + + + -Dglib=enabled + + + Use GLib. (Default = auto) + + + This option enables or disables usage of the GLib + library. The default setting is to check for the + presence of GLib and, if it is found, build with + GLib support. GLib is native to GNU/Linux systems but is + available on other operating system as well. + + + + + + -Dgobject=enabled + + + Use GObject. (Default = no) + + + This option enables or disables usage of the GObject + library. The default setting is to check for the + presence of GObject and, if it is found, build with + GObject support. GObject is native to GNU/Linux systems but is + available on other operating system as well. + + + + + + -Dcairo=enabled + + + Use Cairo. (Default = auto) + + + This option enables or disables usage of the Cairo + graphics-rendering library. The default setting is to + check for the presence of Cairo and, if it is found, + build with Cairo support. + + + Note: Cairo is used only by the HarfBuzz + command-line utilities, and not by the HarfBuzz library. + + + + + + -Dicu=enabled + + + Use the ICU library. (Default = auto) + + + This option enables or disables usage of the + International Components for + Unicode (ICU) library, which provides access + to Unicode Character Database (UCD) properties as well + as normalization and conversion functions. The default + setting is to check for the presence of ICU and, if it + is found, build with ICU support. + + + + + + -Dgraphite=enabled + + + Use the Graphite2 library. (Default = no) + + + This option enables or disables usage of the Graphite2 + library, which provides support for the Graphite shaping + model. + + + + + + -Dfreetype=enabled + + + Use the FreeType library. (Default = auto) + + + This option enables or disables usage of the FreeType + font-rendering library. The default setting is to check for the + presence of FreeType and, if it is found, build with + FreeType support. + + + + + + -Dgdi=enabled + + + Use the Uniscribe + library (experimental). (Default = no) + + + This option enables or disables usage of the Uniscribe + font-rendering library. Uniscribe is available on + Windows systems. Uniscribe support is used only for + testing purposes and does not need to be enabled for + HarfBuzz to run on Windows systems. + + + + + + -Ddirectwrite=enabled + + + Use the DirectWrite library (experimental). (Default = no) + + + This option enables or disables usage of the DirectWrite + font-rendering library. DirectWrite is available on + Windows systems. DirectWrite support is used only for + testing purposes and does not need to be enabled for + HarfBuzz to run on Windows systems. + + + + + + -Dcoretext=enabled + + + Use the CoreText library. (Default = no) + + + This option enables or disables usage of the CoreText + library. CoreText is available on macOS and iOS systems. + + + + + + -Ddocs=enabled + + + Use GTK-Doc. (Default = no) + + + This option enables the building of the documentation. + + + + +
      + +
      +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-integration.xml b/third_party/harfbuzz-ng/src/docs/usermanual-integration.xml new file mode 100644 index 000000000000..e208370df31b --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-integration.xml @@ -0,0 +1,647 @@ + + + +]> + + Platform Integration Guide + + HarfBuzz was first developed for use with the GNOME and GTK + software stack commonly found in desktop Linux + distributions. Nevertheless, it can be used on other operating + systems and platforms, from iOS and macOS to Windows. It can also + be used with other application frameworks and components, such as + Android, Qt, or application-specific widget libraries. + + + This chapter will look at how HarfBuzz fits into a typical + text-rendering pipeline, and will discuss the APIs available to + integrate HarfBuzz with contemporary Linux, Mac, and Windows + software. It will also show how HarfBuzz integrates with popular + external libraries like FreeType and International Components for + Unicode (ICU) and describe the HarfBuzz language bindings for + Python. + + + On a GNOME system, HarfBuzz is designed to tie in with several + other common system libraries. The most common architecture uses + Pango at the layer directly "above" HarfBuzz; Pango is responsible + for text segmentation and for ensuring that each input + hb_buffer_t passed to HarfBuzz for shaping contains + Unicode code points that share the same segment properties + (namely, direction, language, and script, but also higher-level + properties like the active font, font style, and so on). + + + The layer directly "below" HarfBuzz is typically FreeType, which + is used to rasterize glyph outlines at the necessary optical size, + hinting settings, and pixel resolution. FreeType provides APIs for + accessing font and face information, so HarfBuzz includes + functions to create hb_face_t and + hb_font_t objects directly from FreeType + objects. HarfBuzz can use FreeType's built-in functions for + font_funcs vtable in an hb_font_t. + + + FreeType's output is bitmaps of the rasterized glyphs; on a + typical Linux system these will then be drawn by a graphics + library like Cairo, but those details are beyond HarfBuzz's + control. On the other hand, at the top end of the stack, Pango is + part of the larger GNOME framework, and HarfBuzz does include APIs + for working with key components of GNOME's higher-level libraries + — most notably GLib. + + + For other operating systems or application frameworks, the + critical integration points are where HarfBuzz gets font and face + information about the font used for shaping and where HarfBuzz + gets Unicode data about the input-buffer code points. + + + The font and face information is necessary for text shaping + because HarfBuzz needs to retrieve the glyph indices for + particular code points, and to know the extents and advances of + glyphs. Note that, in an OpenType variable font, both of those + types of information can change with different variation-axis + settings. + + + The Unicode information is necessary for shaping because the + properties of a code point (such as its General Category (gc), + Canonical Combining Class (ccc), and decomposition) can directly + impact the shaping moves that HarfBuzz performs. + + +
      + GNOME integration, GLib, and GObject + + As mentioned in the preceding section, HarfBuzz offers + integration APIs to help client programs using the + GNOME and GTK framework commonly found in desktop Linux + distributions. + + + GLib is the main utility library for GNOME applications. It + provides basic data types and conversions, file abstractions, + string manipulation, and macros, as well as facilities like + memory allocation and the main event loop. + + + Where text shaping is concerned, GLib provides several utilities + that HarfBuzz can take advantage of, including a set of + Unicode-data functions and a data type for script + information. Both are useful when working with HarfBuzz + buffers. To make use of them, you will need to include the + hb-glib.h header file. + + + GLib's Unicode + manipulation API includes all the functionality + necessary to retrieve Unicode data for the + unicode_funcs structure of a HarfBuzz + hb_buffer_t. + + + The function hb_glib_get_unicode_funcs() + sets up a hb_unicode_funcs_t structure configured + with the GLib Unicode functions and returns a pointer to it. + + + You can attach this Unicode-functions structure to your buffer, + and it will be ready for use with GLib: + + + #include <hb-glib.h> + ... + hb_unicode_funcs_t *glibufunctions; + glibufunctions = hb_glib_get_unicode_funcs(); + hb_buffer_set_unicode_funcs(buf, glibufunctions); + + + For script information, GLib uses the + GUnicodeScript type. Like HarfBuzz's own + hb_script_t, this data type is an enumeration + of Unicode scripts, but text segments passed in from GLib code + will be tagged with a GUnicodeScript. Therefore, + when setting the script property on a hb_buffer_t, + you will need to convert between the GUnicodeScript + of the input provided by GLib and HarfBuzz's + hb_script_t type. + + + The hb_glib_script_to_script() function + takes an GUnicodeScript script identifier as its + sole argument and returns the corresponding hb_script_t. + The hb_glib_script_from_script() does the + reverse, taking an hb_script_t and returning the + GUnicodeScript identifier for GLib. + + + Finally, GLib also provides a reference-counted object type called GBytes + that is used for accessing raw memory segments with the benefits + of GLib's lifecycle management. HarfBuzz provides a + hb_glib_blob_create() function that lets + you create an hb_blob_t directly from a + GBytes object. This function takes only the + GBytes object as its input; HarfBuzz registers the + GLib destroy callback automatically. + + + The GNOME platform also features an object system called + GObject. For HarfBuzz, the main advantage of GObject is a + feature called GObject + Introspection. This is a middleware facility that can be + used to generate language bindings for C libraries. HarfBuzz uses it + to build its Python bindings, which we will look at in a separate section. + +
      + +
      + FreeType integration + + FreeType is the free-software font-rendering engine included in + desktop Linux distributions, Android, ChromeOS, iOS, and multiple Unix + operating systems, and used by cross-platform programs like + Chrome, Java, and GhostScript. Used together, HarfBuzz can + perform shaping on Unicode text segments, outputting the glyph + IDs that FreeType should rasterize from the active font as well + as the positions at which those glyphs should be drawn. + + + HarfBuzz provides integration points with FreeType at the + face-object and font-object level and for the font-functions + virtual-method structure of a font object. These functions + make it easy for clients that use FreeType for rasterization + or font-loading, to use HarfBuzz for shaping. To use the + FreeType-integration API, include the + hb-ft.h header. + + + In a typical client program, you will create your + hb_face_t face object and hb_font_t + font object from a FreeType FT_Face. HarfBuzz + provides a suite of functions for doing this. + + + In the most common case, you will want to use + hb_ft_font_create_referenced(), which + creates both an hb_face_t face object and + hb_font_t font object (linked to that face object), + and provides lifecycle management. + + + It is important to note, + though, that while HarfBuzz makes a distinction between its face and + font objects, FreeType's FT_Face does not. After + you create your FT_Face, you must set its size + parameter using FT_Set_Char_Size(), because + an hb_font_t is defined as an instance of an + hb_face_t with size specified. + + + #include <hb-ft.h> + ... + FT_New_Face(ft_library, font_path, index, &face); + FT_Set_Char_Size(face, 0, 1000, 0, 0); + hb_font_t *font = hb_ft_font_create(face); + + + hb_ft_font_create_referenced() is + the recommended function for creating an hb_face_t face + object. This function calls FT_Reference_Face() + before using the FT_Face and calls + FT_Done_Face() when it is finished using the + FT_Face. Consequently, your client program does not need + to worry about destroying the FT_Face while HarfBuzz + is still using it. + + + Although hb_ft_font_create_referenced() is + the recommended function, there is another variant for client code + where special circumstances make it necessary. The simpler + version of the function is hb_ft_font_create(), + which takes an FT_Face and an optional destroy callback + as its arguments. Because hb_ft_font_create() + does not offer lifecycle management, however, your client code will + be responsible for tracking references to the FT_Face + objects and destroying them when they are no longer needed. If you + do not have a valid reason for doing this, use + hb_ft_font_create_referenced(). + + + After you have created your font object from your + FT_Face, you can set or retrieve the + load_flags of the + FT_Face through the hb_font_t + object. HarfBuzz provides + hb_ft_font_set_load_flags() and + hb_ft_font_get_load_flags() for this + purpose. The ability to set the + load_flags through the font object + could be useful for enabling or disabling hinting, for example, + or to activate vertical layout. + + + HarfBuzz also provides a utility function called + hb_ft_font_has_changed() that you should + call whenever you have altered the properties of your underlying + FT_Face, as well as a + hb_ft_get_face() that you can call on an + hb_font_t font object to fetch its underlying FT_Face. + + + With an hb_face_t and hb_font_t both linked + to your FT_Face, you will typically also want to + use FreeType for the font_funcs + vtable of your hb_font_t. As a reminder, this + font-functions structure is the set of methods that HarfBuzz + will use to fetch important information from the font, such as + the advances and extents of individual glyphs. + + + All you need to do is call + + + hb_ft_font_set_funcs(font); + + + and HarfBuzz will use FreeType for the font-functions in + font. + + + As we noted above, an hb_font_t is derived from an + hb_face_t with size (and, perhaps, other + parameters, such as variation-axis coordinates) + specified. Consequently, you can reuse an hb_face_t + with several hb_font_t objects, and HarfBuzz + provides functions to simplify this. + + + The hb_ft_face_create_referenced() + function creates just an hb_face_t from a FreeType + FT_Face and, as with + hb_ft_font_create_referenced() above, + provides lifecycle management for the FT_Face. + + + Similarly, there is an hb_ft_face_create() + function variant that does not provide the lifecycle-management + feature. As with the font-object case, if you use this version + of the function, it will be your client code's respsonsibility + to track usage of the FT_Face objects. + + + A third variant of this function is + hb_ft_face_create_cached(), which is the + same as hb_ft_face_create() except that it + also uses the generic field of the + FT_Face structure to save a pointer to the newly + created hb_face_t. Subsequently, function calls + that pass the same FT_Face will get the same + hb_face_t returned — and the + hb_face_t will be correctly reference + counted. Still, as with + hb_ft_face_create(), your client code must + track references to the FT_Face itself, and destroy + it when it is unneeded. + +
      + +
      + Cairo integration + + + Cairo is a 2D graphics library that is frequently used together + with GTK and Pango. Cairo supports rendering text using FreeType, or + by using callback-based 'user fonts'. + + + HarfBuzz provides integration points with cairo for fonts as well as + for buffers. To use the Cairo-integration API, link against libharfbuzz-cairo, + and include the hb-cairo.h header. For easy buildsystem + integration, HarfBuzz comes with a harfbuzz-cairo.pc + pkg-config file. + + + To create a cairo_scaled_font_t font from a HarfBuzz + hb_font_t, you can use hb_cairo_font_face_create_for_font() + or hb_cairo_font_face_create_for_face(). The former API + applies variations and synthetic slant from the hb_font_t when + rendering, the latter takes them from the cairo_font_options_t + that were passed when creating the cairo_scaled_font_t. + + + The Cairo fonts created in this way make use of Cairo's user-font facilities. + They can be used to render on any Cairo context, and provide full support for + font rendering features, including color. One current limitation of the + implementation is that it does not support hinting for glyph outlines. + + + When using color fonts with this API, the color palette index is taken from + the cairo_font_options_t (with new enough Cairo), and the foreground + color is extracted from the source of the Cairo context. + + + To render the results of shaping a piece of text, use + hb_cairo_glyphs_from_buffer() to obtain the glyphs in + a form that can be passed to cairo_show_text_glyphs() or + cairo_show_glyphs(). + +
      + +
      + Uniscribe integration + + If your client program is running on Windows, HarfBuzz offers + an additional API that can help integrate with Microsoft's + Uniscribe engine and the Windows GDI. + + + Overall, the Uniscribe API covers a broader set of typographic + layout functions than HarfBuzz implements, but HarfBuzz's + shaping API can serve as a drop-in replacement for Uniscribe's shaping + functionality. In fact, one of HarfBuzz's design goals is to + accurately reproduce the same output for shaping a given text + segment that Uniscribe produces — even to the point of + duplicating known shaping bugs or deviations from the + specification — so you can be confident that your users' + documents with their existing fonts will not be affected adversely by + switching to HarfBuzz. + + + At a basic level, HarfBuzz's hb_shape() + function replaces both the ScriptShape() + and ScriptPlace() + functions from Uniscribe. + + + However, whereas ScriptShape() returns the + glyphs and clusters for a shaped sequence and + ScriptPlace() returns the advances and + offsets for those glyphs, hb_shape() + handles both. After hb_shape() shapes a + buffer, the output glyph IDs and cluster IDs are returned as + an array of hb_glyph_info_t structures, and the + glyph advances and offsets are returned as an array of + hb_glyph_position_t structures. + + + Your client program only needs to ensure that it converts + correctly between HarfBuzz's low-level data types (such as + hb_position_t) and Windows's corresponding types + (such as GOFFSET and ABC). Be sure you + read the + chapter for a full explanation of how HarfBuzz input buffers are + used, and see for the + details of what hb_shape() returns in the + output buffer when shaping is complete. + + + Although hb_shape() itself is functionally + equivalent to Uniscribe's shaping routines, there are two + additional HarfBuzz functions you may want to use to integrate + the libraries in your code. Both are used to link HarfBuzz font + objects to the equivalent Windows structures. + + + The hb_uniscribe_font_get_logfontw() + function takes a hb_font_t font object and returns + a pointer to the LOGFONTW + "logical font" that corresponds to it. A LOGFONTW + structure holds font-wide attributes, including metrics, size, + and style information. + + + + The hb_uniscribe_font_get_hfont() function + also takes a hb_font_t font object, but it returns + an HFONT — a handle to the underlying logical + font — instead. + + + LOGFONTWs and HFONTs are both needed + by other Uniscribe functions. + + + As a final note, you may notice a reference to an optional + uniscribe shaper back-end in the section of the HarfBuzz manual. This + option is not a Uniscribe-integration facility. + + + Instead, it is a internal code path used in the + hb-shape command-line utility, which hands + shaping functionality over to Uniscribe entirely, when run on a + Windows system. That allows testing HarfBuzz's native output + against the Uniscribe engine, for tracking compatibility and + debugging. + + + Because this back-end is only used when testing HarfBuzz + functionality, it is disabled by default when building the + HarfBuzz binaries. + +
      + +
      + Core Text integration + + If your client program is running on macOS or iOS, HarfBuzz offers + an additional API that can help integrate with Apple's + Core Text engine and the underlying Core Graphics + framework. HarfBuzz does not attempt to offer the same + drop-in-replacement functionality for Core Text that it strives + for with Uniscribe on Windows, but you can still use HarfBuzz + to perform text shaping in native macOS and iOS applications. + + + Note, though, that if your interest is just in using fonts that + contain Apple Advanced Typography (AAT) features, then you do + not need to add Core Text integration. HarfBuzz natively + supports AAT features and will shape AAT fonts (on any platform) + automatically, without requiring additional work on your + part. This includes support for AAT-specific TrueType tables + such as mort, morx, and + kerx, which AAT fonts use instead of + GSUB and GPOS. + + + On a macOS or iOS system, the primary integration points offered + by HarfBuzz are for face objects and font objects. + + + The Apple APIs offer a pair of data structures that map well to + HarfBuzz's face and font objects. The Core Graphics API, which + is slightly lower-level than Core Text, provides + CGFontRef, which enables access to typeface + properties, but does not include size information. Core Text's + CTFontRef is analogous to a HarfBuzz font object, + with all of the properties required to render text at a specific + size and configuration. + Consequently, a HarfBuzz hb_font_t font object can + be hooked up to a Core Text CTFontRef, and a HarfBuzz + hb_face_t face object can be hooked up to a + CGFontRef. + + + You can create a hb_face_t from a + CGFontRef by using the + hb_coretext_face_create(). Subsequently, + you can retrieve the CGFontRef from a + hb_face_t with hb_coretext_face_get_cg_font(). + + + Likewise, you create a hb_font_t from a + CTFontRef by calling + hb_coretext_font_create(), and you can + fetch the associated CTFontRef from a + hb_font_t font object with + hb_coretext_face_get_ct_font(). + + + HarfBuzz also offers a hb_font_set_ptem() + that you an use to set the nominal point size on any + hb_font_t font object. Core Text uses this value to + implement optical scaling. + + + When integrating your client code with Core Text, it is + important to recognize that Core Text points + are not typographic points (standardized at 72 per inch) as the + term is used elsewhere in OpenType. Instead, Core Text points + are CSS points, which are standardized at 96 per inch. + + + HarfBuzz's font functions take this distinction into account, + but it can be an easy detail to miss in cross-platform + code. + + + As a final note, you may notice a reference to an optional + coretext shaper back-end in the section of the HarfBuzz manual. This + option is not a Core Text-integration facility. + + + Instead, it is a internal code path used in the + hb-shape command-line utility, which hands + shaping functionality over to Core Text entirely, when run on a + macOS system. That allows testing HarfBuzz's native output + against the Core Text engine, for tracking compatibility and debugging. + + + Because this back-end is only used when testing HarfBuzz + functionality, it is disabled by default when building the + HarfBuzz binaries. + +
      + +
      + ICU integration + + Although HarfBuzz includes its own Unicode-data functions, it + also provides integration APIs for using the International + Components for Unicode (ICU) library as a source of Unicode data + on any supported platform. + + + The principal integration point with ICU is the + hb_unicode_funcs_t Unicode-functions structure + attached to a buffer. This structure holds the virtual methods + used for retrieving Unicode character properties, such as + General Category, Script, Combining Class, decomposition + mappings, and mirroring information. + + + To use ICU in your client program, you need to call + hb_icu_get_unicode_funcs(), which creates a + Unicode-functions structure populated with the ICU function for + each included method. Subsequently, you can attach the + Unicode-functions structure to your buffer: + + + hb_unicode_funcs_t *icufunctions; + icufunctions = hb_icu_get_unicode_funcs(); + hb_buffer_set_unicode_funcs(buf, icufunctions); + + + and ICU will be used for Unicode-data access. + + + HarfBuzz also supplies a pair of functions + (hb_icu_script_from_script() and + hb_icu_script_to_script()) for converting + between ICU's and HarfBuzz's internal enumerations of Unicode + scripts. The hb_icu_script_from_script() + function converts from a HarfBuzz hb_script_t to an + ICU UScriptCode. The + hb_icu_script_to_script() function does the + reverse: converting from a UScriptCode identifier + to a hb_script_t. + + + By default, HarfBuzz's ICU support is built as a separate shared + library (libharfbuzz-icu.so) + when compiling HarfBuzz from source. This allows client programs + that do not need ICU to link against HarfBuzz without unnecessarily + adding ICU as a dependency. You can also build HarfBuzz with ICU + support built directly into the main HarfBuzz shared library + (libharfbuzz.so), + by specifying the --with-icu=builtin + compile-time option. + + +
      + +
      + Python bindings + + As noted in the section, + HarfBuzz uses a feature called GObject + Introspection (GI) to provide bindings for Python. + + + At compile time, the GI scanner analyzes the HarfBuzz C source + and builds metadata objects connecting the language bindings to + the C library. Your Python code can then use the HarfBuzz binary + through its Python interface. + + + HarfBuzz's Python bindings support Python 2 and Python 3. To use + them, you will need to have the pygobject + package installed. Then you should import + HarfBuzz from + gi.repository: + + + from gi.repository import HarfBuzz + + + and you can call HarfBuzz functions from Python. Sample code can + be found in the sample.py script in the + HarfBuzz src directory. + + + Do note, however, that the Python API is subject to change + without advance notice. GI allows the bindings to be + automatically updated, which is one of its advantages, but you + may need to update your Python code. + +
      + +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-object-model.xml b/third_party/harfbuzz-ng/src/docs/usermanual-object-model.xml new file mode 100644 index 000000000000..3c71a36906d9 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-object-model.xml @@ -0,0 +1,266 @@ + + + +]> + + The HarfBuzz object model +
      + An overview of data types in HarfBuzz + + HarfBuzz features two kinds of data types: non-opaque, + pass-by-value types and opaque, heap-allocated types. This kind + of separation is common in C libraries that have to provide + API/ABI compatibility (almost) indefinitely. + + + Value types: The non-opaque, pass-by-value + types include integer types, enums, and small structs. Exposing + a struct in the public API makes it impossible to expand the + struct in the future. As such, exposing structs is reserved for + cases where it’s extremely inefficient to do otherwise. + + + In HarfBuzz, several structs, like hb_glyph_info_t and + hb_glyph_position_t, fall into that efficiency-sensitive + category and are non-opaque. + + + For all non-opaque structs where future extensibility may be + necessary, reserved members are included to hold space for + possible future members. As such, it’s important to provide + equal(), and hash() + methods for such structs, allowing users of the API do + effectively deal with the type without having to + adapt their code to future changes. + + + Important value types provided by HarfBuzz include the structs + for working with Unicode code points, glyphs, and tags for font + tables and features, as well as the enums for many Unicode and + OpenType properties. + +
      + +
      + Objects in HarfBuzz + + Object types: Opaque struct types are used + for what HarfBuzz loosely calls "objects." This doesn’t have + much to do with the terminology from object-oriented programming + (OOP), although some of the concepts are similar. + + + In HarfBuzz, all object types provide certain + lifecycle-management APIs. Objects are reference-counted, and + constructed with various create() methods, referenced via + reference() and dereferenced using + destroy(). + + + For example, + the hb_buffer_t object has + hb_buffer_create() as its constructor, + hb_buffer_reference() to reference, and + hb_buffer_destroy() to dereference. + + + After construction, each object's properties are accessible only + through the setter and getter functions described in the API + Reference manual. + + + Note that many object types can be marked as read-only or immutable, + facilitating their use in multi-threaded environments. + + + Key object types provided by HarfBuzz include: + + + + + blobs, which act as low-level wrappers around binary + data. Blobs are typically used to hold the contents of a + binary font file. + + + + + faces, which represent typefaces from a + font file, but without specific parameters (such as size) set. + + + + + fonts, which represent instances of a + face with all of their parameters specified. + + + + + buffers, which hold Unicode code points + for characters (before shaping) and the shaped glyph output + (after shaping). + + + + + shape plans, which store the settings + that HarfBuzz will use when shaping a particular text + segment. Shape plans are not generally used by client + programs directly, but as we will see in a later chapter, + they are still valuable to understand. + + + + +
      + + + +
      + Object lifecycle management + + Each object type in HarfBuzz provides a + create() method. Some object types provide + additional variants of create() to handle + special cases or to speed up common tasks; those variants are + documented in the API reference. For example, + hb_blob_create_from_file() constructs a new + blob directly from the contents of a file. + + + All objects are created with an initial reference count of + 1. Client programs can increase the reference + count on an object by calling its + reference() method. Whenever a client + program is finished with an object, it should call its + corresponding destroy() method. The destroy + method will decrease the reference count on the object and, + whenever the reference count reaches zero, it will also destroy + the object and free all of the associated memory. + + + All of HarfBuzz's object-lifecycle-management APIs are + thread-safe (unless you compiled HarfBuzz from source with the + HB_NO_MT configuration flag), even when the + object as a whole is not thread-safe. + It is also permissible to reference() or to + destroy() the NULL + value. + + + Some objects are thread-safe after they have been constructed + and set up. The general pattern is to + create() the object, make a few + set_*() calls to set up the + object, and then use it without further modification. + + + To ensure that such an object is not modified, client programs + can explicitly mark an object as immutable. HarfBuzz provides + make_immutable() methods to mark an object + as immutable and is_immutable() methods to + test whether or not an object is immutable. Attempts to use + setter functions on immutable objects will fail silently; see the API + Reference manual for specifics. + + + Note also that there are no "make mutable" methods. If client + programs need to alter an object previously marked as immutable, + they will need to make a duplicate of the original. + + + Finally, object constructors (and, indeed, as much of the + shaping API as possible) will never return + NULL. Instead, if there is an allocation + error, each constructor will return an “empty†object + singleton. + + + These empty-object singletons are inert and safe (although + typically useless) to pass around. This design choice avoids + having to check for NULL pointers all + throughout the code. + + + In addition, this “empty†object singleton can also be accessed + using the get_empty() method of the object + type in question. + +
      + + +
      + User data + + To better integrate with client programs, HarfBuzz's objects + offer a "user data" mechanism that can be used to attach + arbitrary data to the object. User-data attachment can be + useful for tying the lifecycles of various pieces of data + together, or for creating language bindings. + + + Each object type has a set_user_data() + method and a get_user_data() method. The + set_user_data() methods take a client-provided + key and a pointer, + user_data, pointing to the data itself. Once + the key-data pair has been attached to the object, the + get_user_data() method can be called with + the key, returning the user_data pointer. + + + The set_user_data() methods also support an + optional destroy callback. Client programs + can set the destroy callback and receive + notification from HarfBuzz whenever the object is destructed. + + + Finally, each set_user_data() method allows + the client program to set a replace Boolean + indicating whether or not the function call should replace any + existing user_data + associated with the specified key. + +
      + + + +
      + Blobs + + While most of HarfBuzz's object types are specific to the + shaping process, blobs are somewhat + different. + + + Blobs are an abstraction designed to negotiate lifecycle and + permissions for raw pieces of data. For example, when you load + the raw font data into memory and want to pass it to HarfBuzz, + you do so in a hb_blob_t wrapper. + + + This allows you to take advantage of HarfBuzz's + reference-counting and destroy + callbacks. If you allocated the memory for the data using + malloc(), you would create the blob using + + + hb_blob_create (data, length, HB_MEMORY_MODE_WRITABLE, data, free) + + + That way, HarfBuzz will call free() on the + allocated memory whenever the blob drops its last reference and + is deconstructed. Consequently, the user code can stop worrying + about freeing memory and let the reference-counting machinery + take care of that. + + + Most of the time, blobs are read-only, facilitating their use in + immutable objects. + +
      + +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml b/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml new file mode 100644 index 000000000000..56eba617fa56 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-opentype-features.xml @@ -0,0 +1,336 @@ + + + +]> + + Shaping and shape plans + + Once you have your face and font objects configured as desired and + your input buffer is filled with the characters you need to shape, + all you need to do is call hb_shape(). + + + HarfBuzz will return the shaped version of the text in the same + buffer that you provided, but it will be in output mode. At that + point, you can iterate through the glyphs in the buffer, drawing + each one at the specified position or handing them off to the + appropriate graphics library. + + + For the most part, HarfBuzz's shaping step is straightforward from + the outside. But that doesn't mean there will never be cases where + you want to look under the hood and see what is happening on the + inside. HarfBuzz provides facilities for doing that, too. + + +
      + Shaping and buffer output + + The hb_shape() function call takes four arguments: the font + object to use, the buffer of characters to shape, an array of + user-specified features to apply, and the length of that feature + array. The feature array can be NULL, so for the sake of + simplicity we will start with that case. + + + Internally, HarfBuzz looks at the tables of the font file to + determine where glyph classes, substitutions, and positioning + are defined, using that information to decide which + shaper to use (ot for + OpenType fonts, aat for Apple Advanced + Typography fonts, and so on). It also looks at the direction, + script, and language properties of the segment to figure out + which script-specific shaping model is needed (at least, in + shapers that support multiple options). + + + If a font has a GDEF table, then that is used for + glyph classes; if not, HarfBuzz will fall back to Unicode + categorization by code point. If a font has an AAT morx table, + then it is used for substitutions; if not, but there is a GSUB + table, then the GSUB table is used. If the font has an AAT + kerx table, then it is used for positioning; if not, but + there is a GPOS table, then the GPOS table is used. If neither + table is found, but there is a kern table, then HarfBuzz will + use the kern table. If there is no kerx, no GPOS, and no + kern, HarfBuzz will fall back to positioning marks itself. + + + With a well-behaved OpenType font, you expect GDEF, GSUB, and + GPOS tables to all be applied. HarfBuzz implements the + script-specific shaping models in internal functions, rather + than in the public API. + + + The algorithms + used for shaping can be quite involved; HarfBuzz tries + to be compatible with the OpenType Layout specification + and, wherever there is any ambiguity, HarfBuzz attempts to replicate the + output of Microsoft's Uniscribe engine, to the extent that is feasible and desirable. See the Microsoft + Typography pages for more detail. + + + In general, though, all that you need to know is that + hb_shape() returns the results of shaping + in the same buffer that you provided. The buffer's content type + will now be set to + HB_BUFFER_CONTENT_TYPE_GLYPHS, indicating + that it contains shaped output, rather than input text. You can + now extract the glyph information and positioning arrays: + + + hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count); + hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count); + + + The glyph information array holds a hb_glyph_info_t + for each output glyph, which has two fields: + codepoint and + cluster. Whereas, in the input buffer, + the codepoint field contained the Unicode + code point, it now contains the glyph ID of the corresponding + glyph in the font. The cluster field is + an integer that you can use to help identify when shaping has + reordered, split, or combined code points; we will say more + about that in the next chapter. + + + The glyph positions array holds a corresponding + hb_glyph_position_t for each output glyph, + containing four fields: x_advance, + y_advance, + x_offset, and + y_offset. The advances tell you how far + you need to move the drawing point after drawing this glyph, + depending on whether you are setting horizontal text (in which + case you will have x advances) or vertical text (for which you + will have y advances). The x and y offsets tell you where to + move to start drawing the glyph; usually you will have both and + x and a y offset, regardless of the text direction. + + + Most of the time, you will rely on a font-rendering library or + other graphics library to do the actual drawing of glyphs, so + you will need to iterate through the glyphs in the buffer and + pass the corresponding values off. + +
      + +
      + OpenType features + + OpenType features enable fonts to include smart behavior, + implemented as "lookup" rules stored in the GSUB and GPOS + tables. The OpenType specification defines a long list of + standard features that fonts can use for these behaviors; each + feature has a four-character reserved name and a well-defined + semantic meaning. + + + Some OpenType features are defined for the purpose of supporting + script-specific shaping, and are automatically activated, but + only when a buffer's script property is set to a script that the + feature supports. + + + Other features are more generic and can apply to several (or + any) script, and shaping engines are expected to implement + them. By default, HarfBuzz activates several of these features + on every text run. They include abvm, + blwm, ccmp, + locl, mark, + mkmk, and rlig. + + + In addition, if the text direction is horizontal, HarfBuzz + also applies the calt, + clig, curs, + dist, kern, + liga and rclt, features. + + + Additionally, when HarfBuzz encounters a fraction slash + (U+2044), it looks backward and forward for decimal + digits (Unicode General Category = Nd), and enables features + numr on the sequence before the fraction slash, + dnom on the sequence after the fraction slash, + and frac on the whole sequence including the fraction + slash. + + + Some script-specific shaping models + (see ) disable some of the + features listed above: + + + + + Hangul: calt + + + + + Indic: liga + + + + + Khmer: liga + + + + + If the text direction is vertical, HarfBuzz applies + the vert feature by default. + + + Still other features are designed to be purely optional and left + up to the application or the end user to enable or disable as desired. + + + You can adjust the set of features that HarfBuzz applies to a + buffer by supplying an array of hb_feature_t + features as the third argument to + hb_shape(). For a simple case, let's just + enable the dlig feature, which turns on any + "discretionary" ligatures in the font: + + + hb_feature_t userfeatures[1]; + userfeatures[0].tag = HB_TAG('d','l','i','g'); + userfeatures[0].value = 1; + userfeatures[0].start = HB_FEATURE_GLOBAL_START; + userfeatures[0].end = HB_FEATURE_GLOBAL_END; + + + HB_FEATURE_GLOBAL_END and + HB_FEATURE_GLOBAL_END are macros we can use + to indicate that the features will be applied to the entire + buffer. We could also have used a literal 0 + for the start and a -1 to indicate the end of + the buffer (or have selected other start and end positions, if needed). + + + When we pass the userfeatures array to + hb_shape(), any discretionary ligature + substitutions from our font that match the text in our buffer + will get performed: + + + hb_shape(font, buf, userfeatures, num_features); + + + Just like we enabled the dlig feature by + setting its value to + 1, you would disable a feature by setting its + value to 0. Some + features can take other value settings; + be sure you read the full specification of each feature tag to + understand what it does and how to control it. + +
      + +
      + Shaper selection + + The basic version of hb_shape() determines + its shaping strategy based on examining the capabilities of the + font file. OpenType font tables cause HarfBuzz to try the + ot shaper, while AAT font tables cause HarfBuzz to try the + aat shaper. + + + In the real world, however, a font might include some unusual + mix of tables, or one of the tables might simply be broken for + the script you need to shape. So, sometimes, you might not + want to rely on HarfBuzz's process for deciding what to do, and + just tell hb_shape() what you want it to try. + + + hb_shape_full() is an alternate shaping + function that lets you supply a list of shapers for HarfBuzz to + try, in order, when shaping your buffer. For example, if you + have determined that HarfBuzz's attempts to work around broken + tables gives you better results than the AAT shaper itself does, + you might move the AAT shaper to the end of your list of + preferences and call hb_shape_full() + + + char *shaperprefs[3] = {"ot", "default", "aat"}; + ... + hb_shape_full(font, buf, userfeatures, num_features, shaperprefs); + + + to get results you are happier with. + + + You may also want to call + hb_shape_list_shapers() to get a list of + the shapers that were built at compile time in your copy of HarfBuzz. + +
      + +
      + Plans and caching + + Internally, HarfBuzz uses a structure called a shape plan to + track its decisions about how to shape the contents of a + buffer. The hb_shape() function builds up the shape plan by + examining segment properties and by inspecting the contents of + the font. + + + This process can involve some decision-making and + trade-offs — for example, HarfBuzz inspects the GSUB and GPOS + lookups for the script and language tags set on the segment + properties, but it falls back on the lookups under the + DFLT tag (and sometimes other common tags) + if there are actually no lookups for the tag requested. + + + HarfBuzz also includes some work-arounds for + handling well-known older font conventions that do not follow + OpenType or Unicode specifications, for buggy system fonts, and for + peculiarities of Microsoft Uniscribe. All of that means that a + shape plan, while not something that you should edit directly in + client code, still might be an object that you want to + inspect. Furthermore, if resources are tight, you might want to + cache the shape plan that HarfBuzz builds for your buffer and + font, so that you do not have to rebuild it for every shaping call. + + + You can create a cacheable shape plan with + hb_shape_plan_create_cached(face, props, + user_features, num_user_features, shaper_list), where + face is a face object (not a font object, + notably), props is an + hb_segment_properties_t, + user_features is an array of + hb_feature_ts (with length + num_user_features), and + shaper_list is a list of shapers to try. + + + Shape plans are objects in HarfBuzz, so there are + reference-counting functions and user-data attachment functions + you can + use. hb_shape_plan_reference(shape_plan) + increases the reference count on a shape plan, while + hb_shape_plan_destroy(shape_plan) decreases + the reference count, destroying the shape plan when the last + reference is dropped. + + + You can attach user data to a shaper (with a key) using the + hb_shape_plan_set_user_data(shape_plan,key,data,destroy,replace) + function, optionally supplying a destroy + callback to use. You can then fetch the user data attached to a + shape plan with + hb_shape_plan_get_user_data(shape_plan, key). + +
      + +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml b/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml new file mode 100644 index 000000000000..a95b0cbf6a78 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-shaping-concepts.xml @@ -0,0 +1,368 @@ + + + +]> + + Shaping concepts +
      + Text shaping + + Text shaping is the process of transforming a sequence of Unicode + codepoints that represent individual characters (letters, + diacritics, tone marks, numbers, symbols, etc.) into the + orthographically and linguistically correct two-dimensional layout + of glyph shapes taken from a specified font. + + + For some writing systems (or scripts) and + languages, the process is simple, requiring the shaper to do + little more than advance the horizontal position forward by the + correct amount for each successive glyph. + + + But, for other scripts (often unceremoniously called complex scripts), any combination of + several shaping operations may be required, and the rules for how + and when they are applied vary from script to script. HarfBuzz and + other shaping engines implement these rules. + + + The exact rules and necessary operations for a particular script + constitute a shaping model. OpenType + specifies a set of shaping models that covers all of + Unicode. Other shaping models are available, however, including + Graphite and Apple Advanced Typography (AAT). + +
      + +
      + Script-specific shaping + + In many scripts, transforming the input + sequence into the final layout often requires some combination of + operations—such as context-dependent substitutions, + context-dependent mark positioning, glyph-to-glyph joining, + glyph reordering, or glyph stacking. + + + In some scripts, the shaping rules require that a text + run be divided into syllables before the operations can be + applied. Other scripts may apply shaping operations over + entire words or over the entire text run, with no subdivision + required. + + + Other scripts, do not require these + operations. However, correctly shaping a text run in + any script may still involve Unicode normalization, + ligature substitutions, mark positioning, kerning, and applying + other font features. + +
      + +
      + Shaping operations + + Shaping a text run involves transforming the + input sequence of Unicode codepoints with some combination of + operations that is specified in the shaping model for the + script. + + + The specific conditions that trigger a given operation for a + text run varies from script to script, as do the order that the + operations are performed in and which codepoints are + affected. However, the same general set of shaping operations is + common to all of the script shaping models. + + + + + + A reordering operation moves a glyph + from its original ("logical") position in the sequence to + some other ("visual") position. + + + The shaping model for a given script might involve + more than one reordering step. + + + + + + A joining operation replaces a glyph + with an alternate form that is designed to connect with one + or more of the adjacent glyphs in the sequence. + + + + + + A contextual substitution operation + replaces either a single glyph or a subsequence of several + glyphs with an alternate glyph. This substitution is + performed when the original glyph or subsequence of glyphs + occurs in a specified position with respect to the + surrounding sequence. For example, one substitution might be + performed only when the target glyph is the first glyph in + the sequence, while another substitution is performed only + when a different target glyph occurs immediately after a + particular string pattern. + + + The shaping model for a given script might involve + multiple contextual-substitution operations, each applying + to different target glyphs and patterns, and which are + performed in separate steps. + + + + + + A contextual positioning operation + moves the horizontal and/or vertical position of a + glyph. This positioning move is performed when the glyph + occurs in a specified position with respect to the + surrounding sequence. + + + Many contextual positioning operations are used to place + mark glyphs (such as diacritics, vowel + signs, and tone markers) with respect to + base glyphs. However, some + scripts may use contextual positioning operations to + correctly place base glyphs as well, such as + when the script uses stacking characters. + + + + +
      + +
      + Unicode character categories + + Shaping models are typically specified with respect to how + scripts are defined in the Unicode standard. + + + Every codepoint in the Unicode Character Database (UCD) is + assigned a Unicode General Category (UGC), + which provides the most fundamental information about the + codepoint: whether the codepoint represents a + Letter, a Mark, a + Number, Punctuation, a + Symbol, a Separator, + or something else (Other). + + + These UGC properties are "Major" categories. Each codepoint is + further assigned to a "minor" category within its Major + category, such as "Letter, uppercase" (Lu) or + "Letter, modifier" (Lm). + + + Shaping models are concerned primarily with Letter and Mark + codepoints. The minor categories of Mark codepoints are + particularly important for shaping. Marks can be nonspacing + (Mn), spacing combining + (Mc), or enclosing (Me). + + + In addition to the UGC property, codepoints in the Indic and + Southeast Asian scripts are also assigned + Unicode Indic Syllabic Category (UISC) and + Unicode Indic Positional Category (UIPC) + properties that provide more detailed information needed for + shaping. + + + The UISC property sub-categorizes Letters and Marks according to + common script-shaping behaviors. For example, UISC distinguishes + between consonant letters, vowel letters, and vowel marks. The + UIPC property sub-categorizes Mark codepoints by the relative visual + position that they occupy (above, below, right, left, or in + multiple positions). + + + Some scripts require that the text run be split into + syllables. What constitutes a valid syllable in these + scripts is specified in regular expressions, formed from the + Letter and Mark codepoints, that take the UISC and UIPC + properties into account. + + +
      + +
      + Text runs + + Real-world text usually contains codepoints from a mixture of + different Unicode scripts (including punctuation, numbers, symbols, + white-space characters, and other codepoints that do not belong + to any script). Real-world text may also be marked up with + formatting that changes font properties (including the font, + font style, and font size). + + + For shaping purposes, all real-world text streams must be first + segmented into runs that have a uniform set of properties. + + + In particular, shaping models always assume that every codepoint + in a text run has the same direction, + script tag, and + language tag. + +
      + +
      + OpenType shaping models + + OpenType provides shaping models for the following scripts: + + + + + + The default shaping model handles all + scripts with no script-specific shaping model, and may also be used as a fallback for + handling unrecognized scripts. + + + + + + The Indic shaping model handles the Indic + scripts Bengali, Devanagari, Gujarati, Gurmukhi, Kannada, + Malayalam, Oriya, Tamil, and Telugu. + + + The Indic shaping model was revised significantly in + 2005. To denote the change, a new set of script + tags was assigned for Bengali, Devanagari, + Gujarati, Gurmukhi, Kannada, Malayalam, Oriya, Tamil, and + Telugu. For the sake of clarity, the term "Indic2" is + sometimes used to refer to the current, revised shaping + model. + + + + + + The Arabic shaping model supports + Arabic, Mongolian, N'Ko, Syriac, and several other connected + or cursive scripts. + + + + + + The Thai/Lao shaping model supports + the Thai and Lao scripts. + + + + + + The Khmer shaping model supports the + Khmer script. + + + + + + The Myanmar shaping model supports the + Myanmar (or Burmese) script. + + + + + + The Tibetan shaping model supports the + Tibetan script. + + + + + + The Hangul shaping model supports the + Hangul script. + + + + + + The Hebrew shaping model supports the + Hebrew script. + + + + + + The Universal Shaping Engine (USE) + shaping model supports scripts not covered by one of + the above, script-specific shaping models, including + Javanese, Balinese, Buginese, Batak, Chakma, Lepcha, Modi, + Phags-pa, Tagalog, Siddham, Sundanese, Tai Le, Tai Tham, Tai + Viet, and many others. + + + + + + Text runs that do not fall under one of the above shaping + models may still require processing by a shaping engine. Of + particular note is Emoji shaping, which + may involve variation-selector sequences and glyph + substitution. Emoji shaping is handled by the default + shaping model. + + + + + +
      + +
      + Graphite shaping + + In contrast to OpenType shaping, Graphite shaping does not + specify a predefined set of shaping models or a set of supported + scripts. + + + Instead, each Graphite font contains a complete set of rules that + implement the required shaping model for the intended + script. These rules include finite-state machines to match + sequences of codepoints to the shaping operations to perform. + + + Graphite shaping can perform the same shaping operations used in + OpenType shaping, as well as other functions that have not been + defined for OpenType shaping. + +
      + +
      + AAT shaping + + In contrast to OpenType shaping, AAT shaping does not specify a + predefined set of shaping models or a set of supported scripts. + + + Instead, each AAT font includes a complete set of rules that + implement the desired shaping model for the intended + script. These rules include finite-state machines to match glyph + sequences and the shaping operations to perform. + + + Notably, AAT shaping rules are expressed for glyphs in the font, + not for Unicode codepoints. AAT shaping can perform the same + shaping operations used in OpenType shaping, as well as other + functions that have not been defined for OpenType shaping. + +
      +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-utilities.xml b/third_party/harfbuzz-ng/src/docs/usermanual-utilities.xml new file mode 100644 index 000000000000..0208dbf70832 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-utilities.xml @@ -0,0 +1,218 @@ + + + +]> + + Utilities + + HarfBuzz includes several auxiliary components in addition to the + main APIs. These include a set of command-line tools, a set of + lower-level APIs for common data types that may be of interest to + client programs. + + +
      + Command-line tools + + HarfBuzz include three command-line tools: + hb-shape, hb-view, and + hb-subset. They can be used to examine + HarfBuzz's functionality, debug font binaries, or explore the + various shaping models and features from a terminal. + + +
      + hb-shape + + hb-shape allows you to run HarfBuzz's + hb_shape() function on an input string and + to examine the outcome, in human-readable form, as terminal + output. hb-shape does + not render the results of the shaping call + into rendered text (you can use hb-view, below, for + that). Instead, it prints out the final glyph indices and + positions, taking all shaping operations into account, as if the + input string were a HarfBuzz input buffer. + + + You can specify the font to be used for shaping and, with + command-line options, you can add various aspects of the + internal state to the output that is sent to the terminal. The + general format is + + + hb-shape [OPTIONS] + path/to/font/file.ttf + yourinputtext + + + The default output format is plain text (although JSON output + can be selected instead by specifying the option + --output-format=json). The default output + syntax reports each glyph name (or glyph index if there is no + name) followed by its cluster value, its horizontal and vertical + position displacement, and its horizontal and vertical advances. + + + Output options exist to skip any of these elements in the + output, and to include additional data, such as Unicode + code-point values, glyph extents, glyph flags, or interim + shaping results. + + + Output can also be redirected to a file, or input read from a + file. Additional options enable you to enable or disable + specific font features, to set variation-font axis values, to + alter the language, script, direction, and clustering settings + used, to enable sanity checks, or to change which shaping engine is used. + + + For a complete explanation of the options available, run + + + hb-shape --help + +
      + +
      + hb-view + + hb-view allows you to + see the shaped output of an input string in rendered + form. Like hb-shape, + hb-view takes a font file and a text string + as its arguments: + + + hb-view [OPTIONS] + path/to/font/file.ttf + yourinputtext + + + By default, hb-view renders the shaped + text in ASCII block-character images as terminal output. By + appending the + --output-file=filename + switch, you can write the output to a PNG, SVG, or PDF file + (among other formats). + + + As with hb-shape, a lengthy set of options + is available, with which you can enable or disable + specific font features, set variation-font axis values, + alter the language, script, direction, and clustering settings + used, enable sanity checks, or change which shaping engine is + used. + + + You can also set the foreground and background colors used for + the output, independently control the width of all four + margins, alter the line spacing, and annotate the output image + with + + + In general, hb-view is a quick way to + verify that the output of HarfBuzz's shaping operation looks + correct for a given text-and-font combination, but you may + want to use hb-shape to figure out exactly + why something does not appear as expected. + +
      + +
      + hb-subset + + hb-subset allows you + to generate a subset of a given font, with a limited set of + supported characters, features, and variation settings. + + + By default, you provide an input font and an input text string + as the arguments to hb-subset, and it will + generate a font that covers the input text exactly like the + input font does, but includes no other characters or features. + + + hb-subset [OPTIONS] + path/to/font/file.ttf + yourinputtext + + + For example, to create a subset of Noto Serif that just includes the + numerals and the lowercase Latin alphabet, you could run + + + hb-subset [OPTIONS] + NotoSerif-Regular.ttf + 0123456789abcdefghijklmnopqrstuvwxyz + + + There are options available to remove hinting from the + subsetted font and to specify a list of variation-axis settings. + +
      + +
      + +
      + Common data types and APIs + + HarfBuzz includes several APIs for working with general-purpose + data that you may find convenient to leverage in your own + software. They include set operations and integer-to-integer + mapping operations. + + + HarfBuzz uses set operations for internal bookkeeping, such as + when it collects all of the glyph IDs covered by a particular + font feature. You can also use the set API to build sets, add + and remove elements, test whether or not sets contain particular + elements, or compute the unions, intersections, or differences + between sets. + + + All set elements are integers (specifically, + hb_codepoint_t 32-bit unsigned ints), and there are + functions for fetching the minimum and maximum element from a + set. The set API also includes some functions that might not + be part of a generic set facility, such as the ability to add a + contiguous range of integer elements to a set in bulk, and the + ability to fetch the next-smallest or next-largest element. + + + The HarfBuzz set API includes some conveniences as well. All + sets are lifecycle-managed, just like other HarfBuzz + objects. You increase the reference count on a set with + hb_set_reference() and decrease it with + hb_set_destroy(). You can also attach + user data to a set, just like you can to blobs, buffers, faces, + fonts, and other objects, and set destroy callbacks. + + + HarfBuzz also provides an API for keeping track of + integer-to-integer mappings. As with the set API, each integer is + stored as an unsigned 32-bit hb_codepoint_t + element. Maps, like other objects, are reference counted with + reference and destroy functions, and you can attach user data to + them. The mapping operations include adding and deleting + integer-to-integer key:value pairs to the map, testing for the + presence of a key, fetching the population of the map, and so on. + + + There are several other internal HarfBuzz facilities that are + exposed publicly and which you may want to take advantage of + while processing text. HarfBuzz uses a common + hb_tag_t for a variety of OpenType tag identifiers (for + scripts, languages, font features, table names, variation-axis + names, and more), and provides functions for converting strings + to tags and vice-versa. + + + Finally, HarfBuzz also includes data type for Booleans, bit + masks, and other simple types. + +
      + +
      diff --git a/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml b/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml new file mode 100644 index 000000000000..fdf04b242305 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/usermanual-what-is-harfbuzz.xml @@ -0,0 +1,441 @@ + + + +]> + + What is HarfBuzz? + + HarfBuzz is a text-shaping engine. If you + give HarfBuzz a font and a string containing a sequence of Unicode + codepoints, HarfBuzz selects and positions the corresponding + glyphs from the font, applying all of the necessary layout rules + and font features. HarfBuzz then returns the string to you in the + form that is correctly arranged for the language and writing + system. + + + HarfBuzz can properly shape all of the world's major writing + systems. It runs on all major operating systems and software + platforms and it supports the major font formats in use + today. + +
      + What is text shaping? + + Text shaping is the process of translating a string of character + codes (such as Unicode codepoints) into a properly arranged + sequence of glyphs that can be rendered onto a screen or into + final output form for inclusion in a document. + + + The shaping process is dependent on the input string, the active + font, the script (or writing system) that the string is in, and + the language that the string is in. + + + Modern software systems generally only deal with strings in the + Unicode encoding scheme (although legacy systems and documents may + involve other encodings). + + + There are several font formats that a program might + encounter, each of which has a set of standard text-shaping + rules. + + The dominant format is OpenType. The + OpenType specification defines a series of shaping models for + various scripts from around the world. These shaping models depend on + the font incorporating certain features as + lookups in its GSUB + and GPOS tables. + + + Alternatively, OpenType fonts can include shaping features for + the Graphite shaping model. + + + TrueType fonts can also include OpenType shaping + features. Alternatively, TrueType fonts can also include Apple + Advanced Typography (AAT) tables to implement shaping + support. AAT fonts are generally only found on macOS and iOS systems. + + + Text strings will usually be tagged with a script and language + tag that provide the context needed to perform text shaping + correctly. The necessary script + and language + tags are defined by OpenType. + +
      + +
      + Why do I need a shaping engine? + + Text shaping is an integral part of preparing text for + display. Before a Unicode sequence can be rendered, the + codepoints in the sequence must be mapped to the corresponding + glyphs provided in the font, and those glyphs must be positioned + correctly relative to each other. For many of the scripts + supported in Unicode, these steps involve script-specific layout + rules, including complex joining, reordering, and positioning + behavior. Implementing these rules is the job of the shaping engine. + + + Text shaping is a fairly low-level operation. HarfBuzz is + used directly by text-handling libraries like Pango, as well as by the layout + engines in Firefox, LibreOffice, and Chromium. Unless you are + writing one of these layout engines + yourself, you will probably not need to use HarfBuzz: normally, + a layout engine, toolkit, or other library will turn text into + glyphs for you. + + + However, if you are writing a layout engine + or graphics library yourself, then you will need to perform text + shaping, and this is where HarfBuzz can help you. + + + Here are some specific scenarios where a text-shaping engine + like HarfBuzz helps you: + + + + + OpenType fonts contain a set of glyphs (that is, shapes + to represent the letters, numbers, punctuation marks, and + all other symbols), which are indexed by a glyph ID. + + + A particular glyph ID within the font does not necessarily + correlate to a predictable Unicode codepoint. For instance, + some fonts have the letter "a" as glyph ID 1, but + many others do not. In order to retrieve the right glyph + from the font to display "a", you need to consult + the table inside the font (the cmap + table) that maps Unicode codepoints to glyph IDs. In other + words, text shaping turns codepoints into glyph + IDs. + + + + + Many OpenType fonts contain ligatures: combinations of + characters that are rendered as a single unit. For instance, + it is common for the "f, i" letter + sequence to appear in print as the single ligature glyph + "ï¬". + + + Whether you should render an "f, i" sequence + as fi or as "ï¬" does not + depend on the input text. Instead, it depends on the whether + or not the font includes an "ï¬" glyph and on the + level of ligature application you wish to perform. The font + and the amount of ligature application used are under your + control. In other words, text shaping involves + querying the font's ligature tables and determining what + substitutions should be made. + + + + + While ligatures like "ï¬" are optional typographic + refinements, some languages require certain + substitutions to be made in order to display text correctly. + + + For example, in Tamil, when the letter "TTA" (ட) + letter is followed by the vowel sign "U" (à¯), the pair + must be replaced by the single glyph "டà¯". The + sequence of Unicode characters "ட,à¯" needs to be + substituted with a single "டà¯" glyph from the + font. + + + But "டà¯" does not have a Unicode codepoint. To + find this glyph, you need to consult the table inside + the font (the GSUB table) that contains + substitution information. In other words, text shaping + chooses the correct glyph for a sequence of characters + provided. + + + + + Similarly, each Arabic character has four different variants + corresponding to the different positions it might appear in + within a sequence. Inside a font, there will be separate + glyphs for the initial, medial, final, and isolated forms of + each letter, each at a different glyph ID. + + + Unicode only assigns one codepoint per character, so a + Unicode string will not tell you which glyph variant to use + for each character. To decide, you need to analyze the whole + string and determine the appropriate glyph for each character + based on its position. In other words, text + shaping chooses the correct form of the letter by its + position and returns the correct glyph from the font. + + + + + Other languages involve marks and accents that need to be + rendered in specific positions relative a base character. For + instance, the Moldovan language includes the Cyrillic letter + "zhe" (ж) with a breve accent, like so: "Ó‚". + + + Some fonts will provide this character as a single + zhe-with-breve glyph, but other fonts will not and, instead, + will expect the rendering engine to form the character by + superimposing the separate "ж" and "˘" + glyphs. + + + But exactly where you should draw the breve depends on the + height and width of the preceding zhe glyph. To find the + right position, you need to consult the table inside + the font (the GPOS table) that contains + positioning information. + In other words, text shaping tells you whether you + have a precomposed glyph within your font or if you need to + compose a glyph yourself out of combining marks—and, + if so, where to position those marks. + + + + + If tasks like these are something that you need to do, then you + need a text shaping engine. You could use Uniscribe if you are + writing Windows software; you could use CoreText on macOS; or + you could use HarfBuzz. + + + + In the rest of this manual, the text will assume that the reader + is that implementor of a text-layout engine. + + +
      + + +
      + What does HarfBuzz do? + + HarfBuzz provides text shaping through a cross-platform + C API that accepts sequences of Unicode codepoints as input. Currently, + the following OpenType shaping models are supported: + + + + + Indic (covering Devanagari, Bengali, Gujarati, + Gurmukhi, Kannada, Malayalam, Oriya, Tamil, and Telugu) + + + + + Arabic (covering Arabic, N'Ko, Syriac, and Mongolian) + + + + + Thai and Lao + + + + + Khmer + + + + + Myanmar + + + + + + Tibetan + + + + + + Hangul + + + + + + Hebrew + + + + + The Universal Shaping Engine or USE + (covering complex scripts not covered by the above shaping + models) + + + + + A default shaping model for non-complex scripts + (covering Latin, Cyrillic, Greek, Armenian, Georgian, Tifinagh, + and many others) + + + + + Emoji (including emoji modifier sequences, flag sequences, + and ZWJ sequences) + + + + + + In addition to OpenType shaping, HarfBuzz supports the latest + version of Graphite shaping (the "Graphite 2" model) and AAT + shaping. + + + + HarfBuzz can read and understand TrueType fonts (.ttf), TrueType + collections (.ttc), and OpenType fonts (.otf, including those + fonts that contain TrueType-style outlines and those that + contain PostScript CFF or CFF2 outlines). + + + + HarfBuzz is designed and tested to run on top of the FreeType + font renderer. It can run on Linux, Android, Windows, macOS, and + iOS systems. + + + + In addition to its core shaping functionality, HarfBuzz provides + functions for accessing other font features, including optional + GSUB and GPOS OpenType features, as well as + all color-font formats (CBDT, + sbix, COLR/CPAL, and + SVG-OT) and OpenType variable fonts. HarfBuzz + also includes a font-subsetting feature. HarfBuzz can perform + some low-level math-shaping operations, although it does not + currently perform full shaping for mathematical typesetting. + + + + A suite of command-line utilities is also provided in the + source-code tree, designed to help users test and debug + HarfBuzz's features on real-world fonts and input. + +
      + +
      + What HarfBuzz doesn't do + + HarfBuzz will take a Unicode string, shape it, and give you the + information required to lay it out correctly on a single + horizontal (or vertical) line using the font provided. That is the + extent of HarfBuzz's responsibility. + + + It is important to note that if you are implementing a complete + text-layout engine you may have other responsibilities that + HarfBuzz will not help you with. For example: + + + + + HarfBuzz won't help you with bidirectionality. If you want to + lay out text that includes a mix of Hebrew and English, you + will need to ensure that each buffer provided to HarfBuzz + has all of its characters in the same order and that the + directionality of the buffer is set correctly. This may mean + segmenting the text before it is placed into HarfBuzz buffers. In + other words, the user will hit the keys in the following + sequence: + + + A B C [space] ×’ ב × [space] D E F + + + but will expect to see in the output: + + + ABC ×בג DEF + + + This reordering is called bidi processing + ("bidi" is short for bidirectional), and there's an + algorithm as an annex to the Unicode Standard which tells you how + to process a string of mixed directionality. + Before sending your string to HarfBuzz, you may need to apply the + bidi algorithm to it. Libraries such as ICU and fribidi can do this for you. + + + + + HarfBuzz won't help you with text that contains different font + properties. For instance, if you have the string "a + huge breakfast", and you expect + "huge" to be italic, then you will need to send three + strings to HarfBuzz: a, in your Roman font; + huge using your italic font; and + breakfast using your Roman font again. + + + Similarly, if you change the font, font size, script, + language, or direction within your string, then you will + need to shape each run independently and output them + independently. HarfBuzz expects to shape a run of characters + that all share the same properties. + + + + + HarfBuzz won't help you with line breaking, hyphenation, or + justification. As mentioned above, HarfBuzz lays out the string + along a single line of, notionally, + infinite length. If you want to find out where the potential + word, sentence and line break points are in your text, you + could use the ICU library's break iterator functions. + + + HarfBuzz can tell you how wide a shaped piece of text is, which is + useful input to a justification algorithm, but it knows nothing + about paragraphs, lines or line lengths. Nor will it adjust the + space between words to fit them proportionally into a line. + + + + + As a layout-engine implementor, HarfBuzz will help you with the + interface between your text and your font, and that's something + that you'll need—what you then do with the glyphs that your font + returns is up to you. + +
      + +
      + Why is it called HarfBuzz? + + HarfBuzz began its life as text-shaping code within the FreeType + project (and you will see references to the FreeType authors + within the source code copyright declarations), but was then + extracted out to its own project. This project is maintained by + Behdad Esfahbod, who named it HarfBuzz. Originally, it was a + shaping engine for OpenType fonts—"HarfBuzz" is + the Persian for "open type". + +
      +
      diff --git a/third_party/harfbuzz-ng/src/docs/version.xml.in b/third_party/harfbuzz-ng/src/docs/version.xml.in new file mode 100644 index 000000000000..de213c2dc258 --- /dev/null +++ b/third_party/harfbuzz-ng/src/docs/version.xml.in @@ -0,0 +1 @@ +@HB_VERSION@ diff --git a/third_party/harfbuzz-ng/src/git.mk b/third_party/harfbuzz-ng/src/git.mk new file mode 100644 index 000000000000..cd52db1eb69d --- /dev/null +++ b/third_party/harfbuzz-ng/src/git.mk @@ -0,0 +1,401 @@ +# git.mk, a small Makefile to autogenerate .gitignore files +# for autotools-based projects. +# +# Copyright 2009, Red Hat, Inc. +# Copyright 2010,2011,2012,2013 Behdad Esfahbod +# Written by Behdad Esfahbod +# +# Copying and distribution of this file, with or without modification, +# is permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +# +# The latest version of this file can be downloaded from: +GIT_MK_URL = https://raw.githubusercontent.com/behdad/git.mk/master/git.mk +# +# Bugs, etc, should be reported upstream at: +# https://github.com/behdad/git.mk +# +# To use in your project, import this file in your git repo's toplevel, +# then do "make -f git.mk". This modifies all Makefile.am files in +# your project to -include git.mk. Remember to add that line to new +# Makefile.am files you create in your project, or just rerun the +# "make -f git.mk". +# +# This enables automatic .gitignore generation. If you need to ignore +# more files, add them to the GITIGNOREFILES variable in your Makefile.am. +# But think twice before doing that. If a file has to be in .gitignore, +# chances are very high that it's a generated file and should be in one +# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES. +# +# The only case that you need to manually add a file to GITIGNOREFILES is +# when remove files in one of mostlyclean-local, clean-local, distclean-local, +# or maintainer-clean-local make targets. +# +# Note that for files like editor backup, etc, there are better places to +# ignore them. See "man gitignore". +# +# If "make maintainer-clean" removes the files but they are not recognized +# by this script (that is, if "git status" shows untracked files still), send +# me the output of "git status" as well as your Makefile.am and Makefile for +# the directories involved and I'll diagnose. +# +# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see +# Makefile.am.sample in the git.mk git repo. +# +# Don't EXTRA_DIST this file. It is supposed to only live in git clones, +# not tarballs. It serves no useful purpose in tarballs and clutters the +# build dir. +# +# This file knows how to handle autoconf, automake, libtool, gtk-doc, +# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata, +# appstream, hotdoc. +# +# This makefile provides the following targets: +# +# - all: "make all" will build all gitignore files. +# - gitignore: makes all gitignore files in the current dir and subdirs. +# - .gitignore: make gitignore file for the current dir. +# - gitignore-recurse: makes all gitignore files in the subdirs. +# +# KNOWN ISSUES: +# +# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the +# submodule doesn't find us. If you have configure.{in,ac} files in +# subdirs, add a proxy git.mk file in those dirs that simply does: +# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste. +# And add those files to git. See vte/gnome-pty-helper/git.mk for +# example. +# + + + +############################################################################### +# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES: +############################################################################### + +# +# Most autotools-using modules should be fine including this variable in their +# toplevel MAINTAINERCLEANFILES: +GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \ + $(srcdir)/aclocal.m4 \ + $(srcdir)/autoscan.log \ + $(srcdir)/configure.scan \ + `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \ + test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \ + for x in \ + ar-lib \ + compile \ + config.guess \ + config.rpath \ + config.sub \ + depcomp \ + install-sh \ + ltmain.sh \ + missing \ + mkinstalldirs \ + test-driver \ + ylwrap \ + ; do echo "$$AUX_DIR/$$x"; done` \ + `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \ + head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done` +# +# All modules should also be fine including the following variable, which +# removes automake-generated Makefile.in files: +GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \ + `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \ + while read f; do \ + case $$f in Makefile|*/Makefile) \ + test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \ + done` +# +# Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this, +# though it's harmless to include regardless. +GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \ + `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \ + if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \ + for x in \ + libtool.m4 \ + ltoptions.m4 \ + ltsugar.m4 \ + ltversion.m4 \ + lt~obsolete.m4 \ + ; do echo "$$MACRO_DIR/$$x"; done; \ + fi` +# +# Modules that use gettext and use AC_CONFIG_MACRO_DIR() may also include this, +# though it's harmless to include regardless. +GITIGNORE_MAINTAINERCLEANFILES_M4_GETTEXT = \ + `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \ + if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \ + for x in \ + codeset.m4 \ + extern-inline.m4 \ + fcntl-o.m4 \ + gettext.m4 \ + glibc2.m4 \ + glibc21.m4 \ + iconv.m4 \ + intdiv0.m4 \ + intl.m4 \ + intldir.m4 \ + intlmacosx.m4 \ + intmax.m4 \ + inttypes-pri.m4 \ + inttypes_h.m4 \ + lcmessage.m4 \ + lib-ld.m4 \ + lib-link.m4 \ + lib-prefix.m4 \ + lock.m4 \ + longlong.m4 \ + nls.m4 \ + po.m4 \ + printf-posix.m4 \ + progtest.m4 \ + size_max.m4 \ + stdint_h.m4 \ + threadlib.m4 \ + uintmax_t.m4 \ + visibility.m4 \ + wchar_t.m4 \ + wint_t.m4 \ + xsize.m4 \ + ; do echo "$$MACRO_DIR/$$x"; done; \ + fi` + + + +############################################################################### +# Default rule is to install ourselves in all Makefile.am files: +############################################################################### + +git-all: git-mk-install + +git-mk-install: + @echo "Installing git makefile" + @any_failed=; \ + find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \ + if grep 'include .*/git.mk' $$x >/dev/null; then \ + echo "$$x already includes git.mk"; \ + else \ + failed=; \ + echo "Updating $$x"; \ + { cat $$x; \ + echo ''; \ + echo '-include $$(top_srcdir)/git.mk'; \ + } > $$x.tmp || failed=1; \ + if test x$$failed = x; then \ + mv $$x.tmp $$x || failed=1; \ + fi; \ + if test x$$failed = x; then : else \ + echo "Failed updating $$x"; >&2 \ + any_failed=1; \ + fi; \ + fi; done; test -z "$$any_failed" + +git-mk-update: + wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk + +.PHONY: git-all git-mk-install git-mk-update + + + +############################################################################### +# Actual .gitignore generation: +############################################################################### + +$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk $(top_srcdir)/configure.ac + @echo "git.mk: Generating $@" + @{ \ + if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \ + for x in \ + $(DOC_MODULE)-decl-list.txt \ + $(DOC_MODULE)-decl.txt \ + tmpl/$(DOC_MODULE)-unused.sgml \ + "tmpl/*.bak" \ + $(REPORT_FILES) \ + $(DOC_MODULE).pdf \ + xml html \ + ; do echo "/$$x"; done; \ + FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \ + case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \ + if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-types"; then \ + echo "/$(DOC_MODULE).types"; \ + fi; \ + if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-sections"; then \ + echo "/$(DOC_MODULE)-sections.txt"; \ + fi; \ + if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ + for x in \ + $(SETUP_FILES) \ + $(DOC_MODULE).types \ + ; do echo "/$$x"; done; \ + fi; \ + fi; \ + if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \ + for lc in $(DOC_LINGUAS); do \ + for x in \ + $(if $(DOC_MODULE),$(DOC_MODULE).xml) \ + $(DOC_PAGES) \ + $(DOC_INCLUDES) \ + ; do echo "/$$lc/$$x"; done; \ + done; \ + for x in \ + $(_DOC_OMF_ALL) \ + $(_DOC_DSK_ALL) \ + $(_DOC_HTML_ALL) \ + $(_DOC_MOFILES) \ + $(DOC_H_FILE) \ + "*/.xml2po.mo" \ + "*/*.omf.out" \ + ; do echo /$$x; done; \ + fi; \ + if test "x$(HOTDOC)" = x; then :; else \ + $(foreach project, $(HOTDOC_PROJECTS),echo "/$(call HOTDOC_TARGET,$(project))"; \ + echo "/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-conf-path output)" ; \ + echo "/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-private-folder)" ; \ + ) \ + for x in \ + .hotdoc.d \ + ; do echo "/$$x"; done; \ + fi; \ + if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \ + for lc in $(HELP_LINGUAS); do \ + for x in \ + $(HELP_FILES) \ + "$$lc.stamp" \ + "$$lc.mo" \ + ; do echo "/$$lc/$$x"; done; \ + done; \ + fi; \ + if test "x$(gsettings_SCHEMAS)" = x; then :; else \ + for x in \ + $(gsettings_SCHEMAS:.xml=.valid) \ + $(gsettings__enum_file) \ + ; do echo "/$$x"; done; \ + fi; \ + if test "x$(appdata_XML)" = x; then :; else \ + for x in \ + $(appdata_XML:.xml=.valid) \ + ; do echo "/$$x"; done; \ + fi; \ + if test "x$(appstream_XML)" = x; then :; else \ + for x in \ + $(appstream_XML:.xml=.valid) \ + ; do echo "/$$x"; done; \ + fi; \ + if test -f $(srcdir)/po/Makefile.in.in; then \ + for x in \ + ABOUT-NLS \ + po/Makefile.in.in \ + po/Makefile.in.in~ \ + po/Makefile.in \ + po/Makefile \ + po/Makevars.template \ + po/POTFILES \ + po/Rules-quot \ + po/stamp-it \ + po/stamp-po \ + po/.intltool-merge-cache \ + "po/*.gmo" \ + "po/*.header" \ + "po/*.mo" \ + "po/*.sed" \ + "po/*.sin" \ + po/$(GETTEXT_PACKAGE).pot \ + intltool-extract.in \ + intltool-merge.in \ + intltool-update.in \ + ; do echo "/$$x"; done; \ + fi; \ + if test -f $(srcdir)/configure; then \ + for x in \ + autom4te.cache \ + configure \ + config.h \ + stamp-h1 \ + libtool \ + config.lt \ + ; do echo "/$$x"; done; \ + fi; \ + if test "x$(DEJATOOL)" = x; then :; else \ + for x in \ + $(DEJATOOL) \ + ; do echo "/$$x.sum"; echo "/$$x.log"; done; \ + echo /site.exp; \ + fi; \ + if test "x$(am__dirstamp)" = x; then :; else \ + echo "$(am__dirstamp)"; \ + fi; \ + if test "x$(findstring libtool,$(LTCOMPILE))" = x -a "x$(findstring libtool,$(LTCXXCOMPILE))" = x -a "x$(GTKDOC_RUN)" = x; then :; else \ + for x in \ + "*.lo" \ + ".libs" "_libs" \ + ; do echo "$$x"; done; \ + fi; \ + for x in \ + .gitignore \ + $(GITIGNOREFILES) \ + $(CLEANFILES) \ + $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \ + $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \ + $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \ + so_locations \ + $(MOSTLYCLEANFILES) \ + $(TEST_LOGS) \ + $(TEST_LOGS:.log=.trs) \ + $(TEST_SUITE_LOG) \ + $(TESTS:=.test) \ + "*.gcda" \ + "*.gcno" \ + $(DISTCLEANFILES) \ + $(am__CONFIG_DISTCLEAN_FILES) \ + $(CONFIG_CLEAN_FILES) \ + TAGS ID GTAGS GRTAGS GSYMS GPATH tags \ + "*.tab.c" \ + $(MAINTAINERCLEANFILES) \ + $(BUILT_SOURCES) \ + $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \ + $(filter %_vala.stamp,$(DIST_COMMON)) \ + $(filter %.vapi,$(DIST_COMMON)) \ + $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \ + Makefile \ + Makefile.in \ + "*.orig" \ + "*.rej" \ + "*.bak" \ + "*~" \ + ".*.sw[nop]" \ + ".dirstamp" \ + ; do echo "/$$x"; done; \ + for x in \ + "*.$(OBJEXT)" \ + $(DEPDIR) \ + ; do echo "$$x"; done; \ + } | \ + sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \ + sed 's@/[.]/@/@g' | \ + LC_ALL=C sort | uniq > .gitignore.tmp && \ + (mv .gitignore.tmp $@ || (echo "WARNING: Cannot create $@ file; skipping"; \ + $(RM) .gitignore.tmp)); + +all: $(srcdir)/.gitignore gitignore-recurse-maybe +gitignore: $(srcdir)/.gitignore gitignore-recurse + +gitignore-recurse-maybe: + @for subdir in $(DIST_SUBDIRS); do \ + case " $(SUBDIRS) " in \ + *" $$subdir "*) :;; \ + *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \ + esac; \ + done +gitignore-recurse: + @for subdir in $(DIST_SUBDIRS); do \ + test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \ + done + +maintainer-clean: gitignore-clean +gitignore-clean: + -rm -f $(srcdir)/.gitignore + +.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe diff --git a/third_party/harfbuzz-ng/src/harfbuzz.doap b/third_party/harfbuzz-ng/src/harfbuzz.doap new file mode 100644 index 000000000000..2a5c0e62e6e5 --- /dev/null +++ b/third_party/harfbuzz-ng/src/harfbuzz.doap @@ -0,0 +1,24 @@ + + + harfbuzz + Text shaping library + + + + + + + + + Behdad Esfahbod + + + + diff --git a/third_party/harfbuzz-ng/src/hb-atomic-private.hh b/third_party/harfbuzz-ng/src/hb-atomic-private.hh deleted file mode 100644 index 8179571ad2da..000000000000 --- a/third_party/harfbuzz-ng/src/hb-atomic-private.hh +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright © 2007 Chris Wilson - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Contributor(s): - * Chris Wilson - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_ATOMIC_PRIVATE_HH -#define HB_ATOMIC_PRIVATE_HH - -#include "hb-private.hh" - - -/* atomic_int */ - -/* We need external help for these */ - -#if defined(hb_atomic_int_impl_add) \ - && defined(hb_atomic_ptr_impl_get) \ - && defined(hb_atomic_ptr_impl_cmpexch) - -/* Defined externally, i.e. in config.h; must have typedef'ed hb_atomic_int_impl_t as well. */ - - -#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) - -#include - -/* MinGW has a convoluted history of supporting MemoryBarrier - * properly. As such, define a function to wrap the whole - * thing. */ -static inline void _HBMemoryBarrier (void) { -#if !defined(MemoryBarrier) - long dummy = 0; - InterlockedExchange (&dummy, 1); -#else - MemoryBarrier (); -#endif -} - -typedef LONG hb_atomic_int_impl_t; -#define HB_ATOMIC_INT_IMPL_INIT(V) (V) -#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd (&(AI), (V)) - -#define hb_atomic_ptr_impl_get(P) (_HBMemoryBarrier (), (void *) *(P)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) - - -#elif !defined(HB_NO_MT) && defined(__APPLE__) - -#include -#ifdef __MAC_OS_X_MIN_REQUIRED -#include -#elif defined(__IPHONE_OS_MIN_REQUIRED) -#include -#endif - - -typedef int32_t hb_atomic_int_impl_t; -#define HB_ATOMIC_INT_IMPL_INIT(V) (V) -#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V)) - -#define hb_atomic_ptr_impl_get(P) (OSMemoryBarrier (), (void *) *(P)) -#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P)) -#else -#if __ppc64__ || __x86_64__ || __aarch64__ -#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P)) -#else -#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P)) -#endif -#endif - - -#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) - -typedef int hb_atomic_int_impl_t; -#define HB_ATOMIC_INT_IMPL_INIT(V) (V) -#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add (&(AI), (V)) - -#define hb_atomic_ptr_impl_get(P) (void *) (__sync_synchronize (), *(P)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N)) - - -#elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS) - -#include -#include - -typedef unsigned int hb_atomic_int_impl_t; -#define HB_ATOMIC_INT_IMPL_INIT(V) (V) -#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V)) - -#define hb_atomic_ptr_impl_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false) - - -#elif !defined(HB_NO_MT) - -#define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */ - -typedef volatile int hb_atomic_int_impl_t; -#define HB_ATOMIC_INT_IMPL_INIT(V) (V) -#define hb_atomic_int_impl_add(AI, V) (((AI) += (V)) - (V)) - -#define hb_atomic_ptr_impl_get(P) ((void *) *(P)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false) - - -#else /* HB_NO_MT */ - -typedef int hb_atomic_int_impl_t; -#define HB_ATOMIC_INT_IMPL_INIT(V) (V) -#define hb_atomic_int_impl_add(AI, V) (((AI) += (V)) - (V)) - -#define hb_atomic_ptr_impl_get(P) ((void *) *(P)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) - - -#endif - - -#define HB_ATOMIC_INT_INIT(V) {HB_ATOMIC_INT_IMPL_INIT(V)} - -struct hb_atomic_int_t -{ - hb_atomic_int_impl_t v; - - inline void set_unsafe (int v_) { v = v_; } - inline int get_unsafe (void) const { return v; } - inline int inc (void) { return hb_atomic_int_impl_add (const_cast (v), 1); } - inline int dec (void) { return hb_atomic_int_impl_add (const_cast (v), -1); } -}; - - -#define hb_atomic_ptr_get(P) hb_atomic_ptr_impl_get(P) -#define hb_atomic_ptr_cmpexch(P,O,N) hb_atomic_ptr_impl_cmpexch((P),(O),(N)) - - -#endif /* HB_ATOMIC_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-blob.cc b/third_party/harfbuzz-ng/src/hb-blob.cc deleted file mode 100644 index 1eb97c7be1ab..000000000000 --- a/third_party/harfbuzz-ng/src/hb-blob.cc +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - */ - -/* http://www.oracle.com/technetwork/articles/servers-storage-dev/standardheaderfiles-453865.html */ -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 199309L -#endif - -#include "hb-private.hh" - -#include "hb-object-private.hh" - -#if !defined(STARBOARD) -#ifdef HAVE_SYS_MMAN_H -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#include -#endif /* HAVE_SYS_MMAN_H */ - -#include -#include -#endif - - - -#ifndef HB_DEBUG_BLOB -#define HB_DEBUG_BLOB (HB_DEBUG+0) -#endif - - -struct hb_blob_t { - hb_object_header_t header; - ASSERT_POD (); - - bool immutable; - - const char *data; - unsigned int length; - hb_memory_mode_t mode; - - void *user_data; - hb_destroy_func_t destroy; -}; - - -static bool _try_writable (hb_blob_t *blob); - -static void -_hb_blob_destroy_user_data (hb_blob_t *blob) -{ - if (blob->destroy) { - blob->destroy (blob->user_data); - blob->user_data = NULL; - blob->destroy = NULL; - } -} - -/** - * hb_blob_create: (skip) - * @data: Pointer to blob data. - * @length: Length of @data in bytes. - * @mode: Memory mode for @data. - * @user_data: Data parameter to pass to @destroy. - * @destroy: Callback to call when @data is not needed anymore. - * - * Creates a new "blob" object wrapping @data. The @mode parameter is used - * to negotiate ownership and lifecycle of @data. - * - * Return value: New blob, or the empty blob if something failed or if @length is - * zero. Destroy with hb_blob_destroy(). - * - * Since: 0.9.2 - **/ -hb_blob_t * -hb_blob_create (const char *data, - unsigned int length, - hb_memory_mode_t mode, - void *user_data, - hb_destroy_func_t destroy) -{ - hb_blob_t *blob; - - if (!length || - length >= 1u << 31 || - data + length < data /* overflows */ || - !(blob = hb_object_create ())) { - if (destroy) - destroy (user_data); - return hb_blob_get_empty (); - } - - blob->data = data; - blob->length = length; - blob->mode = mode; - - blob->user_data = user_data; - blob->destroy = destroy; - - if (blob->mode == HB_MEMORY_MODE_DUPLICATE) { - blob->mode = HB_MEMORY_MODE_READONLY; - if (!_try_writable (blob)) { - hb_blob_destroy (blob); - return hb_blob_get_empty (); - } - } - - return blob; -} - -/** - * hb_blob_create_sub_blob: - * @parent: Parent blob. - * @offset: Start offset of sub-blob within @parent, in bytes. - * @length: Length of sub-blob. - * - * Returns a blob that represents a range of bytes in @parent. The new - * blob is always created with %HB_MEMORY_MODE_READONLY, meaning that it - * will never modify data in the parent blob. The parent data is not - * expected to be modified, and will result in undefined behavior if it - * is. - * - * Makes @parent immutable. - * - * Return value: New blob, or the empty blob if something failed or if - * @length is zero or @offset is beyond the end of @parent's data. Destroy - * with hb_blob_destroy(). - * - * Since: 0.9.2 - **/ -hb_blob_t * -hb_blob_create_sub_blob (hb_blob_t *parent, - unsigned int offset, - unsigned int length) -{ - hb_blob_t *blob; - - if (!length || offset >= parent->length) - return hb_blob_get_empty (); - - hb_blob_make_immutable (parent); - - blob = hb_blob_create (parent->data + offset, - MIN (length, parent->length - offset), - HB_MEMORY_MODE_READONLY, - hb_blob_reference (parent), - (hb_destroy_func_t) hb_blob_destroy); - - return blob; -} - -/** - * hb_blob_get_empty: - * - * Returns the singleton empty blob. - * - * See TODO:link object types for more information. - * - * Return value: (transfer full): the empty blob. - * - * Since: 0.9.2 - **/ -hb_blob_t * -hb_blob_get_empty (void) -{ - static const hb_blob_t _hb_blob_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - NULL, /* data */ - 0, /* length */ - HB_MEMORY_MODE_READONLY, /* mode */ - - NULL, /* user_data */ - NULL /* destroy */ - }; - - return const_cast (&_hb_blob_nil); -} - -/** - * hb_blob_reference: (skip) - * @blob: a blob. - * - * Increases the reference count on @blob. - * - * See TODO:link object types for more information. - * - * Return value: @blob. - * - * Since: 0.9.2 - **/ -hb_blob_t * -hb_blob_reference (hb_blob_t *blob) -{ - return hb_object_reference (blob); -} - -/** - * hb_blob_destroy: (skip) - * @blob: a blob. - * - * Descreases the reference count on @blob, and if it reaches zero, destroys - * @blob, freeing all memory, possibly calling the destroy-callback the blob - * was created for if it has not been called already. - * - * See TODO:link object types for more information. - * - * Since: 0.9.2 - **/ -void -hb_blob_destroy (hb_blob_t *blob) -{ - if (!hb_object_destroy (blob)) return; - - _hb_blob_destroy_user_data (blob); - - free (blob); -} - -/** - * hb_blob_set_user_data: (skip) - * @blob: a blob. - * @key: key for data to set. - * @data: data to set. - * @destroy: callback to call when @data is not needed anymore. - * @replace: whether to replace an existing data with the same key. - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_blob_set_user_data (hb_blob_t *blob, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - return hb_object_set_user_data (blob, key, data, destroy, replace); -} - -/** - * hb_blob_get_user_data: (skip) - * @blob: a blob. - * @key: key for data to get. - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -void * -hb_blob_get_user_data (hb_blob_t *blob, - hb_user_data_key_t *key) -{ - return hb_object_get_user_data (blob, key); -} - - -/** - * hb_blob_make_immutable: - * @blob: a blob. - * - * - * - * Since: 0.9.2 - **/ -void -hb_blob_make_immutable (hb_blob_t *blob) -{ - if (hb_object_is_inert (blob)) - return; - - blob->immutable = true; -} - -/** - * hb_blob_is_immutable: - * @blob: a blob. - * - * - * - * Return value: TODO - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_blob_is_immutable (hb_blob_t *blob) -{ - return blob->immutable; -} - - -/** - * hb_blob_get_length: - * @blob: a blob. - * - * - * - * Return value: the length of blob data in bytes. - * - * Since: 0.9.2 - **/ -unsigned int -hb_blob_get_length (hb_blob_t *blob) -{ - return blob->length; -} - -/** - * hb_blob_get_data: - * @blob: a blob. - * @length: (out): - * - * - * - * Returns: (transfer none) (array length=length): - * - * Since: 0.9.2 - **/ -const char * -hb_blob_get_data (hb_blob_t *blob, unsigned int *length) -{ - if (length) - *length = blob->length; - - return blob->data; -} - -/** - * hb_blob_get_data_writable: - * @blob: a blob. - * @length: (out): output length of the writable data. - * - * Tries to make blob data writable (possibly copying it) and - * return pointer to data. - * - * Fails if blob has been made immutable, or if memory allocation - * fails. - * - * Returns: (transfer none) (array length=length): Writable blob data, - * or %NULL if failed. - * - * Since: 0.9.2 - **/ -char * -hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length) -{ - if (!_try_writable (blob)) { - if (length) - *length = 0; - - return NULL; - } - - if (length) - *length = blob->length; - - return const_cast (blob->data); -} - - -static hb_bool_t -_try_make_writable_inplace_unix (hb_blob_t *blob) -{ -#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT) - uintptr_t pagesize = -1, mask, length; - const char *addr; - -#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) - pagesize = (uintptr_t) sysconf (_SC_PAGE_SIZE); -#elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) - pagesize = (uintptr_t) sysconf (_SC_PAGESIZE); -#elif defined(HAVE_GETPAGESIZE) - pagesize = (uintptr_t) getpagesize (); -#endif - - if ((uintptr_t) -1L == pagesize) { - DEBUG_MSG_FUNC (BLOB, blob, "failed to get pagesize: %s", strerror (errno)); - return false; - } - DEBUG_MSG_FUNC (BLOB, blob, "pagesize is %lu", (unsigned long) pagesize); - - mask = ~(pagesize-1); - addr = (const char *) (((uintptr_t) blob->data) & mask); - length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr; - DEBUG_MSG_FUNC (BLOB, blob, - "calling mprotect on [%p..%p] (%lu bytes)", - addr, addr+length, (unsigned long) length); - if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) { - DEBUG_MSG_FUNC (BLOB, blob, "mprotect failed: %s", strerror (errno)); - return false; - } - - blob->mode = HB_MEMORY_MODE_WRITABLE; - - DEBUG_MSG_FUNC (BLOB, blob, - "successfully made [%p..%p] (%lu bytes) writable\n", - addr, addr+length, (unsigned long) length); - return true; -#else - return false; -#endif -} - -static bool -_try_writable_inplace (hb_blob_t *blob) -{ - DEBUG_MSG_FUNC (BLOB, blob, "making writable inplace\n"); - - if (_try_make_writable_inplace_unix (blob)) - return true; - - DEBUG_MSG_FUNC (BLOB, blob, "making writable -> FAILED\n"); - - /* Failed to make writable inplace, mark that */ - blob->mode = HB_MEMORY_MODE_READONLY; - return false; -} - -static bool -_try_writable (hb_blob_t *blob) -{ - if (blob->immutable) - return false; - - if (blob->mode == HB_MEMORY_MODE_WRITABLE) - return true; - - if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE && _try_writable_inplace (blob)) - return true; - - if (blob->mode == HB_MEMORY_MODE_WRITABLE) - return true; - - - DEBUG_MSG_FUNC (BLOB, blob, "current data is -> %p\n", blob->data); - - char *new_data; - - new_data = (char *) malloc (blob->length); - if (unlikely (!new_data)) - return false; - - DEBUG_MSG_FUNC (BLOB, blob, "dupped successfully -> %p\n", blob->data); - - memcpy (new_data, blob->data, blob->length); - _hb_blob_destroy_user_data (blob); - blob->mode = HB_MEMORY_MODE_WRITABLE; - blob->data = new_data; - blob->user_data = new_data; - blob->destroy = free; - - return true; -} diff --git a/third_party/harfbuzz-ng/src/hb-blob.h b/third_party/harfbuzz-ng/src/hb-blob.h deleted file mode 100644 index b2419abfd2a5..000000000000 --- a/third_party/harfbuzz-ng/src/hb-blob.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - */ - -#ifndef HB_H_IN -#error "Include instead." -#endif - -#ifndef HB_BLOB_H -#define HB_BLOB_H - -#include "hb-common.h" - -HB_BEGIN_DECLS - - -/* - * Note re various memory-modes: - * - * - In no case shall the HarfBuzz client modify memory - * that is passed to HarfBuzz in a blob. If there is - * any such possibility, MODE_DUPLICATE should be used - * such that HarfBuzz makes a copy immediately, - * - * - Use MODE_READONLY otherse, unless you really really - * really know what you are doing, - * - * - MODE_WRITABLE is appropriate if you really made a - * copy of data solely for the purpose of passing to - * HarfBuzz and doing that just once (no reuse!), - * - * - If the font is mmap()ed, it's ok to use - * READONLY_MAY_MAKE_WRITABLE, however, using that mode - * correctly is very tricky. Use MODE_READONLY instead. - */ -typedef enum { - HB_MEMORY_MODE_DUPLICATE, - HB_MEMORY_MODE_READONLY, - HB_MEMORY_MODE_WRITABLE, - HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE -} hb_memory_mode_t; - -typedef struct hb_blob_t hb_blob_t; - -hb_blob_t * -hb_blob_create (const char *data, - unsigned int length, - hb_memory_mode_t mode, - void *user_data, - hb_destroy_func_t destroy); - -/* Always creates with MEMORY_MODE_READONLY. - * Even if the parent blob is writable, we don't - * want the user of the sub-blob to be able to - * modify the parent data as that data may be - * shared among multiple sub-blobs. - */ -hb_blob_t * -hb_blob_create_sub_blob (hb_blob_t *parent, - unsigned int offset, - unsigned int length); - -hb_blob_t * -hb_blob_get_empty (void); - -hb_blob_t * -hb_blob_reference (hb_blob_t *blob); - -void -hb_blob_destroy (hb_blob_t *blob); - -hb_bool_t -hb_blob_set_user_data (hb_blob_t *blob, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - - -void * -hb_blob_get_user_data (hb_blob_t *blob, - hb_user_data_key_t *key); - - -void -hb_blob_make_immutable (hb_blob_t *blob); - -hb_bool_t -hb_blob_is_immutable (hb_blob_t *blob); - - -unsigned int -hb_blob_get_length (hb_blob_t *blob); - -const char * -hb_blob_get_data (hb_blob_t *blob, unsigned int *length); - -char * -hb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length); - - -HB_END_DECLS - -#endif /* HB_BLOB_H */ diff --git a/third_party/harfbuzz-ng/src/hb-buffer-deserialize-json.hh b/third_party/harfbuzz-ng/src/hb-buffer-deserialize-json.hh deleted file mode 100644 index 3f626bda40d9..000000000000 --- a/third_party/harfbuzz-ng/src/hb-buffer-deserialize-json.hh +++ /dev/null @@ -1,643 +0,0 @@ - -#line 1 "hb-buffer-deserialize-json.rl" -/* - * Copyright © 2013 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_BUFFER_DESERIALIZE_JSON_HH -#define HB_BUFFER_DESERIALIZE_JSON_HH - -#include "hb-private.hh" - - -#line 36 "hb-buffer-deserialize-json.hh" -static const unsigned char _deserialize_json_trans_keys[] = { - 0u, 0u, 9u, 123u, 9u, 34u, 97u, 103u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, - 48u, 57u, 9u, 125u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, - 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u, - 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, - 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, - 65u, 122u, 34u, 122u, 9u, 125u, 9u, 125u, 9u, 93u, 9u, 123u, 0u, 0u, 0 -}; - -static const char _deserialize_json_key_spans[] = { - 0, 115, 26, 7, 2, 1, 50, 49, - 10, 117, 117, 117, 1, 50, 49, 10, - 117, 117, 1, 1, 50, 49, 117, 117, - 2, 1, 50, 49, 10, 117, 117, 1, - 50, 49, 10, 117, 117, 1, 50, 49, - 58, 89, 117, 117, 85, 115, 0 -}; - -static const short _deserialize_json_index_offsets[] = { - 0, 0, 116, 143, 151, 154, 156, 207, - 257, 268, 386, 504, 622, 624, 675, 725, - 736, 854, 972, 974, 976, 1027, 1077, 1195, - 1313, 1316, 1318, 1369, 1419, 1430, 1548, 1666, - 1668, 1719, 1769, 1780, 1898, 2016, 2018, 2069, - 2119, 2178, 2268, 2386, 2504, 2590, 2706 -}; - -static const char _deserialize_json_indicies[] = { - 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 1, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 1, 4, 1, - 5, 1, 6, 7, 1, 1, 8, 1, - 9, 10, 1, 11, 1, 11, 11, 11, - 11, 11, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 11, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 12, 1, - 12, 12, 12, 12, 12, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 12, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 13, 1, 1, 14, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 1, 16, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 1, 18, 18, 18, - 18, 18, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 18, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 19, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 20, 1, 21, 21, 21, 21, 21, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 21, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 22, - 1, 18, 18, 18, 18, 18, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 18, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 1, 1, 1, - 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 20, 1, 23, - 1, 23, 23, 23, 23, 23, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 23, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 24, 1, 24, 24, 24, 24, - 24, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 24, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 25, 1, 1, 26, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 1, 28, 29, - 29, 29, 29, 29, 29, 29, 29, 29, - 1, 30, 30, 30, 30, 30, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 30, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 31, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 32, 1, 30, - 30, 30, 30, 30, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 30, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 31, 1, 1, 1, 29, 29, - 29, 29, 29, 29, 29, 29, 29, 29, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 32, 1, 33, 1, 34, - 1, 34, 34, 34, 34, 34, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 34, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 35, 1, 35, 35, 35, 35, - 35, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 35, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 36, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 1, 38, 38, - 38, 38, 38, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 38, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 39, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 40, 1, 38, 38, 38, 38, - 38, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 38, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 39, - 1, 1, 1, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 40, 1, 42, 43, 1, 44, 1, 44, - 44, 44, 44, 44, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 44, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 45, 1, 45, 45, 45, 45, 45, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 45, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 46, 1, - 1, 47, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 1, 49, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 1, 51, - 51, 51, 51, 51, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 51, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 52, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 53, 1, 51, 51, 51, - 51, 51, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 51, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 52, 1, 1, 1, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 53, 1, 54, 1, 54, 54, 54, - 54, 54, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 54, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 55, 1, - 55, 55, 55, 55, 55, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 55, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 56, 1, 1, 57, - 58, 58, 58, 58, 58, 58, 58, 58, - 58, 1, 59, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 1, 61, 61, 61, - 61, 61, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 61, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 62, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 63, 1, 61, 61, 61, 61, 61, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 61, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 62, 1, - 1, 1, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 63, - 1, 64, 1, 64, 64, 64, 64, 64, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 64, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 65, 1, 65, 65, - 65, 65, 65, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 65, 1, 66, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 67, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 1, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 1, 1, 1, 1, 1, 1, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 1, 70, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 71, 71, - 1, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 1, 1, 1, 1, 1, - 1, 1, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 1, 1, 1, 1, - 71, 1, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 1, 72, 72, 72, - 72, 72, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 72, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 73, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 74, 1, 72, 72, 72, 72, 72, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 72, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 73, 1, - 1, 1, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 74, - 1, 76, 76, 76, 76, 76, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 76, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 77, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 78, 1, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 0 -}; - -static const char _deserialize_json_trans_targs[] = { - 1, 0, 2, 2, 3, 4, 18, 24, - 37, 5, 12, 6, 7, 8, 9, 11, - 9, 11, 10, 2, 44, 10, 44, 13, - 14, 15, 16, 17, 16, 17, 10, 2, - 44, 19, 20, 21, 22, 23, 10, 2, - 44, 23, 25, 31, 26, 27, 28, 29, - 30, 29, 30, 10, 2, 44, 32, 33, - 34, 35, 36, 35, 36, 10, 2, 44, - 38, 39, 40, 42, 43, 41, 10, 41, - 10, 2, 44, 43, 44, 45, 46 -}; - -static const char _deserialize_json_trans_actions[] = { - 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 2, 2, - 0, 0, 3, 3, 4, 0, 5, 0, - 0, 2, 2, 2, 0, 0, 6, 6, - 7, 0, 0, 0, 2, 2, 8, 8, - 9, 0, 0, 0, 0, 0, 2, 2, - 2, 0, 0, 10, 10, 11, 0, 0, - 2, 2, 2, 0, 0, 12, 12, 13, - 0, 0, 0, 2, 2, 2, 14, 0, - 15, 15, 16, 0, 0, 0, 0 -}; - -static const int deserialize_json_start = 1; -static const int deserialize_json_first_final = 44; -static const int deserialize_json_error = 0; - -static const int deserialize_json_en_main = 1; - - -#line 97 "hb-buffer-deserialize-json.rl" - - -static hb_bool_t -_hb_buffer_deserialize_glyphs_json (hb_buffer_t *buffer, - const char *buf, - unsigned int buf_len, - const char **end_ptr, - hb_font_t *font) -{ - const char *p = buf, *pe = buf + buf_len; - - /* Ensure we have positions. */ - (void) hb_buffer_get_glyph_positions (buffer, NULL); - - while (p < pe && ISSPACE (*p)) - p++; - if (p < pe && *p == (buffer->len ? ',' : '[')) - { - *end_ptr = ++p; - } - - const char *tok = NULL; - int cs; - hb_glyph_info_t info = {0}; - hb_glyph_position_t pos = {0}; - -#line 466 "hb-buffer-deserialize-json.hh" - { - cs = deserialize_json_start; - } - -#line 471 "hb-buffer-deserialize-json.hh" - { - int _slen; - int _trans; - const unsigned char *_keys; - const char *_inds; - if ( p == pe ) - goto _test_eof; - if ( cs == 0 ) - goto _out; -_resume: - _keys = _deserialize_json_trans_keys + (cs<<1); - _inds = _deserialize_json_indicies + _deserialize_json_index_offsets[cs]; - - _slen = _deserialize_json_key_spans[cs]; - _trans = _inds[ _slen > 0 && _keys[0] <=(*p) && - (*p) <= _keys[1] ? - (*p) - _keys[0] : _slen ]; - - cs = _deserialize_json_trans_targs[_trans]; - - if ( _deserialize_json_trans_actions[_trans] == 0 ) - goto _again; - - switch ( _deserialize_json_trans_actions[_trans] ) { - case 1: -#line 38 "hb-buffer-deserialize-json.rl" - { - memset (&info, 0, sizeof (info)); - memset (&pos , 0, sizeof (pos )); -} - break; - case 5: -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 2: -#line 51 "hb-buffer-deserialize-json.rl" - { - tok = p; -} - break; - case 14: -#line 55 "hb-buffer-deserialize-json.rl" - { - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} - break; - case 15: -#line 62 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.codepoint)) return false; } - break; - case 8: -#line 63 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } - break; - case 10: -#line 64 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_offset )) return false; } - break; - case 12: -#line 65 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } - break; - case 3: -#line 66 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } - break; - case 6: -#line 67 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } - break; - case 16: -#line 62 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.codepoint)) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 9: -#line 63 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 11: -#line 64 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_offset )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 13: -#line 65 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 4: -#line 66 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 7: -#line 67 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; -#line 624 "hb-buffer-deserialize-json.hh" - } - -_again: - if ( cs == 0 ) - goto _out; - if ( ++p != pe ) - goto _resume; - _test_eof: {} - _out: {} - } - -#line 125 "hb-buffer-deserialize-json.rl" - - - *end_ptr = p; - - return p == pe && *(p-1) != ']'; -} - -#endif /* HB_BUFFER_DESERIALIZE_JSON_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-buffer-deserialize-text.hh b/third_party/harfbuzz-ng/src/hb-buffer-deserialize-text.hh deleted file mode 100644 index d2d8daae7edd..000000000000 --- a/third_party/harfbuzz-ng/src/hb-buffer-deserialize-text.hh +++ /dev/null @@ -1,571 +0,0 @@ - -#line 1 "hb-buffer-deserialize-text.rl" -/* - * Copyright © 2013 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_BUFFER_DESERIALIZE_TEXT_HH -#define HB_BUFFER_DESERIALIZE_TEXT_HH - -#include "hb-private.hh" - - -#line 36 "hb-buffer-deserialize-text.hh" -static const unsigned char _deserialize_text_trans_keys[] = { - 0u, 0u, 9u, 122u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u, - 48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 9u, 124u, 9u, 124u, 0u, 0u, - 9u, 122u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, - 9u, 124u, 9u, 124u, 9u, 124u, 0 -}; - -static const char _deserialize_text_key_spans[] = { - 0, 114, 13, 10, 13, 10, 10, 13, - 10, 1, 13, 10, 14, 116, 116, 0, - 114, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116 -}; - -static const short _deserialize_text_index_offsets[] = { - 0, 0, 115, 129, 140, 154, 165, 176, - 190, 201, 203, 217, 228, 243, 360, 477, - 478, 593, 710, 827, 944, 1061, 1178, 1295, - 1412, 1529, 1646 -}; - -static const char _deserialize_text_indicies[] = { - 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 1, 1, - 1, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 1, 1, 1, 1, 1, - 1, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 1, 5, 1, 1, 6, - 7, 7, 7, 7, 7, 7, 7, 7, - 7, 1, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 1, 10, 1, 1, - 11, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 1, 13, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 1, 15, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 1, 17, 1, 1, 18, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 1, 20, - 21, 21, 21, 21, 21, 21, 21, 21, - 21, 1, 22, 1, 23, 1, 1, 24, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 1, 26, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 1, 22, 1, 1, - 1, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 1, 28, 28, 28, 28, - 28, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 28, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 29, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 30, 1, 1, 31, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 32, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 33, - 1, 34, 34, 34, 34, 34, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 34, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 35, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 36, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 3, - 3, 3, 3, 3, 3, 3, 3, 3, - 1, 1, 1, 1, 1, 1, 1, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 1, 1, 1, 1, 1, 1, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 1, 28, 28, 28, 28, 28, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 28, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 29, 1, 1, 1, - 1, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 1, 1, 1, 30, 1, - 1, 31, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 32, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 33, 1, 38, - 38, 38, 38, 38, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 38, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 39, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 40, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 41, 1, 42, 42, 42, 42, - 42, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 42, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 43, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 44, - 1, 42, 42, 42, 42, 42, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 42, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 43, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 44, 1, 38, 38, - 38, 38, 38, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 38, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 39, 1, 1, 1, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 40, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 41, 1, 45, 45, 45, 45, 45, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 45, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 46, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 47, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 48, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 49, 1, - 50, 50, 50, 50, 50, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 50, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 51, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 52, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 53, 1, 50, 50, 50, - 50, 50, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 50, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 51, - 1, 1, 1, 1, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 52, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 53, 1, 45, 45, 45, 45, 45, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 45, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 46, 1, 1, 1, - 1, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 1, 1, 1, 1, 1, - 1, 47, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 48, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 49, 1, 28, - 28, 28, 28, 28, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 28, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 29, 1, 55, 55, 1, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 1, 1, 1, 30, 1, 1, 31, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 1, 1, 32, 1, 55, 1, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, - 55, 1, 33, 1, 0 -}; - -static const char _deserialize_text_trans_targs[] = { - 1, 0, 13, 17, 26, 3, 18, 21, - 18, 21, 5, 19, 20, 19, 20, 22, - 25, 8, 9, 12, 9, 12, 10, 11, - 23, 24, 23, 24, 14, 2, 6, 7, - 15, 16, 14, 15, 16, 17, 14, 4, - 15, 16, 14, 15, 16, 14, 2, 7, - 15, 16, 14, 2, 15, 16, 25, 26 -}; - -static const char _deserialize_text_trans_actions[] = { - 0, 0, 1, 1, 1, 2, 2, 2, - 0, 0, 2, 2, 2, 0, 0, 2, - 2, 2, 2, 2, 0, 0, 3, 2, - 2, 2, 0, 0, 4, 5, 5, 5, - 4, 4, 0, 0, 0, 0, 6, 7, - 6, 6, 8, 8, 8, 9, 10, 10, - 9, 9, 11, 12, 11, 11, 0, 0 -}; - -static const char _deserialize_text_eof_actions[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4, 0, 0, - 0, 4, 6, 8, 8, 6, 9, 11, - 11, 9, 4 -}; - -static const int deserialize_text_start = 1; -static const int deserialize_text_first_final = 13; -static const int deserialize_text_error = 0; - -static const int deserialize_text_en_main = 1; - - -#line 91 "hb-buffer-deserialize-text.rl" - - -static hb_bool_t -_hb_buffer_deserialize_glyphs_text (hb_buffer_t *buffer, - const char *buf, - unsigned int buf_len, - const char **end_ptr, - hb_font_t *font) -{ - const char *p = buf, *pe = buf + buf_len; - - /* Ensure we have positions. */ - (void) hb_buffer_get_glyph_positions (buffer, NULL); - - while (p < pe && ISSPACE (*p)) - p++; - if (p < pe && *p == (buffer->len ? '|' : '[')) - { - *end_ptr = ++p; - } - - const char *eof = pe, *tok = NULL; - int cs; - hb_glyph_info_t info = {0}; - hb_glyph_position_t pos = {0}; - -#line 343 "hb-buffer-deserialize-text.hh" - { - cs = deserialize_text_start; - } - -#line 348 "hb-buffer-deserialize-text.hh" - { - int _slen; - int _trans; - const unsigned char *_keys; - const char *_inds; - if ( p == pe ) - goto _test_eof; - if ( cs == 0 ) - goto _out; -_resume: - _keys = _deserialize_text_trans_keys + (cs<<1); - _inds = _deserialize_text_indicies + _deserialize_text_index_offsets[cs]; - - _slen = _deserialize_text_key_spans[cs]; - _trans = _inds[ _slen > 0 && _keys[0] <=(*p) && - (*p) <= _keys[1] ? - (*p) - _keys[0] : _slen ]; - - cs = _deserialize_text_trans_targs[_trans]; - - if ( _deserialize_text_trans_actions[_trans] == 0 ) - goto _again; - - switch ( _deserialize_text_trans_actions[_trans] ) { - case 2: -#line 51 "hb-buffer-deserialize-text.rl" - { - tok = p; -} - break; - case 5: -#line 55 "hb-buffer-deserialize-text.rl" - { - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} - break; - case 10: -#line 62 "hb-buffer-deserialize-text.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } - break; - case 3: -#line 63 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.x_offset )) return false; } - break; - case 12: -#line 64 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } - break; - case 7: -#line 65 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } - break; - case 1: -#line 38 "hb-buffer-deserialize-text.rl" - { - memset (&info, 0, sizeof (info)); - memset (&pos , 0, sizeof (pos )); -} -#line 51 "hb-buffer-deserialize-text.rl" - { - tok = p; -} - break; - case 4: -#line 55 "hb-buffer-deserialize-text.rl" - { - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 9: -#line 62 "hb-buffer-deserialize-text.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 11: -#line 64 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 6: -#line 65 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 8: -#line 66 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; -#line 480 "hb-buffer-deserialize-text.hh" - } - -_again: - if ( cs == 0 ) - goto _out; - if ( ++p != pe ) - goto _resume; - _test_eof: {} - if ( p == eof ) - { - switch ( _deserialize_text_eof_actions[cs] ) { - case 4: -#line 55 "hb-buffer-deserialize-text.rl" - { - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 9: -#line 62 "hb-buffer-deserialize-text.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 11: -#line 64 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 6: -#line 65 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 8: -#line 66 "hb-buffer-deserialize-text.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } -#line 43 "hb-buffer-deserialize-text.rl" - { - buffer->add_info (info); - if (buffer->in_error) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; -#line 557 "hb-buffer-deserialize-text.hh" - } - } - - _out: {} - } - -#line 119 "hb-buffer-deserialize-text.rl" - - - *end_ptr = p; - - return p == pe && *(p-1) != ']'; -} - -#endif /* HB_BUFFER_DESERIALIZE_TEXT_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-buffer-private.hh b/third_party/harfbuzz-ng/src/hb-buffer-private.hh deleted file mode 100644 index 111078c240c0..000000000000 --- a/third_party/harfbuzz-ng/src/hb-buffer-private.hh +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright © 1998-2004 David Turner and Werner Lemberg - * Copyright © 2004,2007,2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Owen Taylor, Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_BUFFER_PRIVATE_HH -#define HB_BUFFER_PRIVATE_HH - -#include "hb-private.hh" -#include "hb-object-private.hh" -#include "hb-unicode-private.hh" - - -#ifndef HB_BUFFER_MAX_EXPANSION_FACTOR -#define HB_BUFFER_MAX_EXPANSION_FACTOR 32 -#endif -#ifndef HB_BUFFER_MAX_LEN_MIN -#define HB_BUFFER_MAX_LEN_MIN 8192 -#endif -#ifndef HB_BUFFER_MAX_LEN_DEFAULT -#define HB_BUFFER_MAX_LEN_DEFAULT 0x3FFFFFFF /* Shaping more than a billion chars? Let us know! */ -#endif - -ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); -ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); - -HB_MARK_AS_FLAG_T (hb_buffer_flags_t); -HB_MARK_AS_FLAG_T (hb_buffer_serialize_flags_t); - -enum hb_buffer_scratch_flags_t { - HB_BUFFER_SCRATCH_FLAG_DEFAULT = 0x00000000u, - HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII = 0x00000001u, - HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES = 0x00000002u, - HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u, - HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_CURSIVE = 0x00000008u, - HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000010u, - /* Reserved for complex shapers' internal use. */ - HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u, - HB_BUFFER_SCRATCH_FLAG_COMPLEX1 = 0x02000000u, - HB_BUFFER_SCRATCH_FLAG_COMPLEX2 = 0x04000000u, - HB_BUFFER_SCRATCH_FLAG_COMPLEX3 = 0x08000000u, -}; -HB_MARK_AS_FLAG_T (hb_buffer_scratch_flags_t); - - -/* - * hb_buffer_t - */ - -struct hb_buffer_t { - hb_object_header_t header; - ASSERT_POD (); - - /* Information about how the text in the buffer should be treated */ - hb_unicode_funcs_t *unicode; /* Unicode functions */ - hb_buffer_flags_t flags; /* BOT / EOT / etc. */ - hb_buffer_cluster_level_t cluster_level; - hb_codepoint_t replacement; /* U+FFFD or something else. */ - hb_buffer_scratch_flags_t scratch_flags; /* Have space-flallback, etc. */ - unsigned int max_len; /* Maximum allowed len. */ - - /* Buffer contents */ - hb_buffer_content_type_t content_type; - hb_segment_properties_t props; /* Script, language, direction */ - - bool in_error; /* Allocation failed */ - bool have_output; /* Whether we have an output buffer going on */ - bool have_positions; /* Whether we have positions */ - - unsigned int idx; /* Cursor into ->info and ->pos arrays */ - unsigned int len; /* Length of ->info and ->pos arrays */ - unsigned int out_len; /* Length of ->out array if have_output */ - - unsigned int allocated; /* Length of allocated arrays */ - hb_glyph_info_t *info; - hb_glyph_info_t *out_info; - hb_glyph_position_t *pos; - - inline hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; } - inline hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; } - - inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; } - inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; } - - inline hb_glyph_info_t &prev (void) { return out_info[out_len ? out_len - 1 : 0]; } - inline hb_glyph_info_t prev (void) const { return out_info[out_len ? out_len - 1 : 0]; } - - inline bool has_separate_output (void) const { return info != out_info; } - - unsigned int serial; - - /* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ - uint8_t allocated_var_bytes[8]; - const char *allocated_var_owner[8]; - - /* Text before / after the main buffer contents. - * Always in Unicode, and ordered outward. - * Index 0 is for "pre-context", 1 for "post-context". */ - static const unsigned int CONTEXT_LENGTH = 5; - hb_codepoint_t context[2][CONTEXT_LENGTH]; - unsigned int context_len[2]; - - - /* Methods */ - - HB_INTERNAL void reset (void); - HB_INTERNAL void clear (void); - - inline unsigned int backtrack_len (void) const - { return have_output? out_len : idx; } - inline unsigned int lookahead_len (void) const - { return len - idx; } - inline unsigned int next_serial (void) { return serial++; } - - HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const char *owner); - HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, const char *owner); - HB_INTERNAL void assert_var (unsigned int byte_i, unsigned int count, const char *owner); - HB_INTERNAL void deallocate_var_all (void); - - HB_INTERNAL void add (hb_codepoint_t codepoint, - unsigned int cluster); - HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info); - - HB_INTERNAL void reverse_range (unsigned int start, unsigned int end); - HB_INTERNAL void reverse (void); - HB_INTERNAL void reverse_clusters (void); - HB_INTERNAL void guess_segment_properties (void); - - HB_INTERNAL void swap_buffers (void); - HB_INTERNAL void remove_output (void); - HB_INTERNAL void clear_output (void); - HB_INTERNAL void clear_positions (void); - - HB_INTERNAL void replace_glyphs (unsigned int num_in, - unsigned int num_out, - const hb_codepoint_t *glyph_data); - - HB_INTERNAL void replace_glyph (hb_codepoint_t glyph_index); - /* Makes a copy of the glyph at idx to output and replace glyph_index */ - HB_INTERNAL void output_glyph (hb_codepoint_t glyph_index); - HB_INTERNAL void output_info (const hb_glyph_info_t &glyph_info); - /* Copies glyph at idx to output but doesn't advance idx */ - HB_INTERNAL void copy_glyph (void); - HB_INTERNAL bool move_to (unsigned int i); /* i is output-buffer index. */ - /* Copies glyph at idx to output and advance idx. - * If there's no output, just advance idx. */ - inline void - next_glyph (void) - { - if (have_output) - { - if (unlikely (out_info != info || out_len != idx)) { - if (unlikely (!make_room_for (1, 1))) return; - out_info[out_len] = info[idx]; - } - out_len++; - } - - idx++; - } - - /* Advance idx without copying to output. */ - inline void skip_glyph (void) { idx++; } - - inline void reset_masks (hb_mask_t mask) - { - for (unsigned int j = 0; j < len; j++) - info[j].mask = mask; - } - inline void add_masks (hb_mask_t mask) - { - for (unsigned int j = 0; j < len; j++) - info[j].mask |= mask; - } - HB_INTERNAL void set_masks (hb_mask_t value, - hb_mask_t mask, - unsigned int cluster_start, - unsigned int cluster_end); - - HB_INTERNAL void merge_clusters (unsigned int start, - unsigned int end) - { - if (end - start < 2) - return; - merge_clusters_impl (start, end); - } - HB_INTERNAL void merge_clusters_impl (unsigned int start, - unsigned int end); - HB_INTERNAL void merge_out_clusters (unsigned int start, - unsigned int end); - /* Merge clusters for deleting current glyph, and skip it. */ - HB_INTERNAL void delete_glyph (void); - - /* Internal methods */ - HB_INTERNAL bool enlarge (unsigned int size); - - inline bool ensure (unsigned int size) - { return likely (!size || size < allocated) ? true : enlarge (size); } - - inline bool ensure_inplace (unsigned int size) - { return likely (!size || size < allocated); } - - HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out); - HB_INTERNAL bool shift_forward (unsigned int count); - - typedef long scratch_buffer_t; - HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size); - - inline void clear_context (unsigned int side) { context_len[side] = 0; } - - HB_INTERNAL void sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *)); -}; - - -#define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \ - b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ - sizeof (b->info[0].var), owner) -#define HB_BUFFER_ALLOCATE_VAR(b, var) \ - HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var) -#define HB_BUFFER_DEALLOCATE_VAR(b, var) \ - HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var (), #var) -#define HB_BUFFER_ASSERT_VAR(b, var) \ - HB_BUFFER_XALLOCATE_VAR (b, assert_var, var (), #var) - - -#endif /* HB_BUFFER_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-buffer-serialize.cc b/third_party/harfbuzz-ng/src/hb-buffer-serialize.cc deleted file mode 100644 index e12bdeb291d4..000000000000 --- a/third_party/harfbuzz-ng/src/hb-buffer-serialize.cc +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright © 2012,2013 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-buffer-private.hh" - - -static const char *serialize_formats[] = { - "text", - "json", - NULL -}; - -/** - * hb_buffer_serialize_list_formats: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -const char ** -hb_buffer_serialize_list_formats (void) -{ - return serialize_formats; -} - -/** - * hb_buffer_serialize_format_from_string: - * @str: - * @len: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_buffer_serialize_format_t -hb_buffer_serialize_format_from_string (const char *str, int len) -{ - /* Upper-case it. */ - return (hb_buffer_serialize_format_t) (hb_tag_from_string (str, len) & ~0x20202020u); -} - -/** - * hb_buffer_serialize_format_to_string: - * @format: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -const char * -hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format) -{ - switch (format) - { - case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return serialize_formats[0]; - case HB_BUFFER_SERIALIZE_FORMAT_JSON: return serialize_formats[1]; - default: - case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return NULL; - } -} - -static unsigned int -_hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer, - unsigned int start, - unsigned int end, - char *buf, - unsigned int buf_size, - unsigned int *buf_consumed, - hb_font_t *font, - hb_buffer_serialize_flags_t flags) -{ - hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); - hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ? - NULL : hb_buffer_get_glyph_positions (buffer, NULL); - - *buf_consumed = 0; - for (unsigned int i = start; i < end; i++) - { - char b[1024]; - char *p = b; - - /* In the following code, we know b is large enough that no overflow can happen. */ - -#define APPEND(s) HB_STMT_START { strcpy (p, s); p += strlen (s); } HB_STMT_END - - if (i) - *p++ = ','; - - *p++ = '{'; - - APPEND ("\"g\":"); - if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES)) - { - char g[128]; - hb_font_glyph_to_string (font, info[i].codepoint, g, sizeof (g)); - *p++ = '"'; - for (char *q = g; *q; q++) { - if (*q == '"') - *p++ = '\\'; - *p++ = *q; - } - *p++ = '"'; - } - else - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint)); - - if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) { - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster)); - } - - if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS)) - { - p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d", - pos[i].x_offset, pos[i].y_offset); - p += snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d", - pos[i].x_advance, pos[i].y_advance); - } - - if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS) - { - hb_glyph_extents_t extents; - hb_font_get_glyph_extents(font, info[i].codepoint, &extents); - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"xb\":%d,\"yb\":%d", - extents.x_bearing, extents.y_bearing)); - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"w\":%d,\"h\":%d", - extents.width, extents.height)); - } - - *p++ = '}'; - - unsigned int l = p - b; - if (buf_size > l) - { - memcpy (buf, b, l); - buf += l; - buf_size -= l; - *buf_consumed += l; - *buf = '\0'; - } else - return i - start; - } - - return end - start; -} - -static unsigned int -_hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer, - unsigned int start, - unsigned int end, - char *buf, - unsigned int buf_size, - unsigned int *buf_consumed, - hb_font_t *font, - hb_buffer_serialize_flags_t flags) -{ - hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL); - hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ? - NULL : hb_buffer_get_glyph_positions (buffer, NULL); - - *buf_consumed = 0; - for (unsigned int i = start; i < end; i++) - { - char b[1024]; - char *p = b; - - /* In the following code, we know b is large enough that no overflow can happen. */ - - if (i) - *p++ = '|'; - - if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES)) - { - hb_font_glyph_to_string (font, info[i].codepoint, p, 128); - p += strlen (p); - } - else - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint)); - - if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) { - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster)); - } - - if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS)) - { - if (pos[i].x_offset || pos[i].y_offset) - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", pos[i].x_offset, pos[i].y_offset)); - - *p++ = '+'; - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance)); - if (pos[i].y_advance) - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance)); - } - - if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS) - { - hb_glyph_extents_t extents; - hb_font_get_glyph_extents(font, info[i].codepoint, &extents); - p += MAX (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "<%d,%d,%d,%d>", extents.x_bearing, extents.y_bearing, extents.width, extents.height)); - } - - unsigned int l = p - b; - if (buf_size > l) - { - memcpy (buf, b, l); - buf += l; - buf_size -= l; - *buf_consumed += l; - *buf = '\0'; - } else - return i - start; - } - - return end - start; -} - -/* Returns number of items, starting at start, that were serialized. */ -/** - * hb_buffer_serialize_glyphs: - * @buffer: a buffer. - * @start: - * @end: - * @buf: (array length=buf_size): - * @buf_size: - * @buf_consumed: (out): - * @font: - * @format: - * @flags: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -unsigned int -hb_buffer_serialize_glyphs (hb_buffer_t *buffer, - unsigned int start, - unsigned int end, - char *buf, - unsigned int buf_size, - unsigned int *buf_consumed, /* May be NULL */ - hb_font_t *font, /* May be NULL */ - hb_buffer_serialize_format_t format, - hb_buffer_serialize_flags_t flags) -{ - assert (start <= end && end <= buffer->len); - - unsigned int sconsumed; - if (!buf_consumed) - buf_consumed = &sconsumed; - *buf_consumed = 0; - - assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) || - buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); - - if (unlikely (start == end)) - return 0; - - if (!font) - font = hb_font_get_empty (); - - switch (format) - { - case HB_BUFFER_SERIALIZE_FORMAT_TEXT: - return _hb_buffer_serialize_glyphs_text (buffer, start, end, - buf, buf_size, buf_consumed, - font, flags); - - case HB_BUFFER_SERIALIZE_FORMAT_JSON: - return _hb_buffer_serialize_glyphs_json (buffer, start, end, - buf, buf_size, buf_consumed, - font, flags); - - default: - case HB_BUFFER_SERIALIZE_FORMAT_INVALID: - return 0; - - } -} - - -static hb_bool_t -parse_uint (const char *pp, const char *end, uint32_t *pv) -{ - char buf[32]; - unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp)); - strncpy (buf, pp, len); - buf[len] = '\0'; - - char *p = buf; - char *pend = p; - uint32_t v; - - _hb_clear_errno(); - v = strtol (p, &pend, 10); - if (_hb_get_errno() || p == pend || pend - p != end - pp) - return false; - - *pv = v; - return true; -} - -static hb_bool_t -parse_int (const char *pp, const char *end, int32_t *pv) -{ - char buf[32]; - unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - pp)); - strncpy (buf, pp, len); - buf[len] = '\0'; - - char *p = buf; - char *pend = p; - int32_t v; - - _hb_clear_errno(); - v = strtol (p, &pend, 10); - if (_hb_get_errno() || p == pend || pend - p != end - pp) - return false; - - *pv = v; - return true; -} - -#include "hb-buffer-deserialize-json.hh" -#include "hb-buffer-deserialize-text.hh" - -/** - * hb_buffer_deserialize_glyphs: - * @buffer: a buffer. - * @buf: (array length=buf_len): - * @buf_len: - * @end_ptr: (out): - * @font: - * @format: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, - const char *buf, - int buf_len, /* -1 means nul-terminated */ - const char **end_ptr, /* May be NULL */ - hb_font_t *font, /* May be NULL */ - hb_buffer_serialize_format_t format) -{ - const char *end; - if (!end_ptr) - end_ptr = &end; - *end_ptr = buf; - - assert ((!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID) || - buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); - - if (buf_len == -1) - buf_len = strlen (buf); - - if (!buf_len) - { - *end_ptr = buf; - return false; - } - - hb_buffer_set_content_type (buffer, HB_BUFFER_CONTENT_TYPE_GLYPHS); - - if (!font) - font = hb_font_get_empty (); - - switch (format) - { - case HB_BUFFER_SERIALIZE_FORMAT_TEXT: - return _hb_buffer_deserialize_glyphs_text (buffer, - buf, buf_len, end_ptr, - font); - - case HB_BUFFER_SERIALIZE_FORMAT_JSON: - return _hb_buffer_deserialize_glyphs_json (buffer, - buf, buf_len, end_ptr, - font); - - default: - case HB_BUFFER_SERIALIZE_FORMAT_INVALID: - return false; - - } -} diff --git a/third_party/harfbuzz-ng/src/hb-buffer.cc b/third_party/harfbuzz-ng/src/hb-buffer.cc deleted file mode 100644 index 5c71734b9de9..000000000000 --- a/third_party/harfbuzz-ng/src/hb-buffer.cc +++ /dev/null @@ -1,1711 +0,0 @@ -/* - * Copyright © 1998-2004 David Turner and Werner Lemberg - * Copyright © 2004,2007,2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Owen Taylor, Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-buffer-private.hh" -#include "hb-utf-private.hh" - - -#ifndef HB_DEBUG_BUFFER -#define HB_DEBUG_BUFFER (HB_DEBUG+0) -#endif - - -/** - * Since: 0.9.7 - **/ -hb_bool_t -hb_segment_properties_equal (const hb_segment_properties_t *a, - const hb_segment_properties_t *b) -{ - return a->direction == b->direction && - a->script == b->script && - a->language == b->language && - a->reserved1 == b->reserved1 && - a->reserved2 == b->reserved2; - -} - -/** - * Since: 0.9.7 - **/ -unsigned int -hb_segment_properties_hash (const hb_segment_properties_t *p) -{ - return (unsigned int) p->direction ^ - (unsigned int) p->script ^ - (intptr_t) (p->language); -} - - - -/* Here is how the buffer works internally: - * - * There are two info pointers: info and out_info. They always have - * the same allocated size, but different lengths. - * - * As an optimization, both info and out_info may point to the - * same piece of memory, which is owned by info. This remains the - * case as long as out_len doesn't exceed i at any time. - * In that case, swap_buffers() is no-op and the glyph operations operate - * mostly in-place. - * - * As soon as out_info gets longer than info, out_info is moved over - * to an alternate buffer (which we reuse the pos buffer for!), and its - * current contents (out_len entries) are copied to the new place. - * This should all remain transparent to the user. swap_buffers() then - * switches info and out_info. - */ - - - -/* Internal API */ - -bool -hb_buffer_t::enlarge (unsigned int size) -{ - if (unlikely (in_error)) - return false; - if (unlikely (size > max_len)) - { - in_error = true; - return false; - } - - unsigned int new_allocated = allocated; - hb_glyph_position_t *new_pos = NULL; - hb_glyph_info_t *new_info = NULL; - bool separate_out = out_info != info; - - if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) - goto done; - - while (size >= new_allocated) - new_allocated += (new_allocated >> 1) + 32; - - ASSERT_STATIC (sizeof (info[0]) == sizeof (pos[0])); - if (unlikely (_hb_unsigned_int_mul_overflows (new_allocated, sizeof (info[0])))) - goto done; - - new_pos = (hb_glyph_position_t *) realloc (pos, new_allocated * sizeof (pos[0])); - new_info = (hb_glyph_info_t *) realloc (info, new_allocated * sizeof (info[0])); - -done: - if (unlikely (!new_pos || !new_info)) - in_error = true; - - if (likely (new_pos)) - pos = new_pos; - - if (likely (new_info)) - info = new_info; - - out_info = separate_out ? (hb_glyph_info_t *) pos : info; - if (likely (!in_error)) - allocated = new_allocated; - - return likely (!in_error); -} - -bool -hb_buffer_t::make_room_for (unsigned int num_in, - unsigned int num_out) -{ - if (unlikely (!ensure (out_len + num_out))) return false; - - if (out_info == info && - out_len + num_out > idx + num_in) - { - assert (have_output); - - out_info = (hb_glyph_info_t *) pos; - memcpy (out_info, info, out_len * sizeof (out_info[0])); - } - - return true; -} - -bool -hb_buffer_t::shift_forward (unsigned int count) -{ - assert (have_output); - if (unlikely (!ensure (len + count))) return false; - - memmove (info + idx + count, info + idx, (len - idx) * sizeof (info[0])); - len += count; - idx += count; - - return true; -} - -hb_buffer_t::scratch_buffer_t * -hb_buffer_t::get_scratch_buffer (unsigned int *size) -{ - have_output = false; - have_positions = false; - - out_len = 0; - out_info = info; - - assert ((uintptr_t) pos % sizeof (scratch_buffer_t) == 0); - *size = allocated * sizeof (pos[0]) / sizeof (scratch_buffer_t); - return (scratch_buffer_t *) (void *) pos; -} - - - -/* HarfBuzz-Internal API */ - -void -hb_buffer_t::reset (void) -{ - if (unlikely (hb_object_is_inert (this))) - return; - - hb_unicode_funcs_destroy (unicode); - unicode = hb_unicode_funcs_get_default (); - flags = HB_BUFFER_FLAG_DEFAULT; - replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT; - - clear (); -} - -void -hb_buffer_t::clear (void) -{ - if (unlikely (hb_object_is_inert (this))) - return; - - hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; - props = default_props; - scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT; - - content_type = HB_BUFFER_CONTENT_TYPE_INVALID; - in_error = false; - have_output = false; - have_positions = false; - - idx = 0; - len = 0; - out_len = 0; - out_info = info; - - serial = 0; - memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); - memset (allocated_var_owner, 0, sizeof allocated_var_owner); - - memset (context, 0, sizeof context); - memset (context_len, 0, sizeof context_len); -} - -void -hb_buffer_t::add (hb_codepoint_t codepoint, - unsigned int cluster) -{ - hb_glyph_info_t *glyph; - - if (unlikely (!ensure (len + 1))) return; - - glyph = &info[len]; - - memset (glyph, 0, sizeof (*glyph)); - glyph->codepoint = codepoint; - glyph->mask = 1; - glyph->cluster = cluster; - - len++; -} - -void -hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) -{ - if (unlikely (!ensure (len + 1))) return; - - info[len] = glyph_info; - - len++; -} - - -void -hb_buffer_t::remove_output (void) -{ - if (unlikely (hb_object_is_inert (this))) - return; - - have_output = false; - have_positions = false; - - out_len = 0; - out_info = info; -} - -void -hb_buffer_t::clear_output (void) -{ - if (unlikely (hb_object_is_inert (this))) - return; - - have_output = true; - have_positions = false; - - out_len = 0; - out_info = info; -} - -void -hb_buffer_t::clear_positions (void) -{ - if (unlikely (hb_object_is_inert (this))) - return; - - have_output = false; - have_positions = true; - - out_len = 0; - out_info = info; - - memset (pos, 0, sizeof (pos[0]) * len); -} - -void -hb_buffer_t::swap_buffers (void) -{ - if (unlikely (in_error)) return; - - assert (have_output); - have_output = false; - - if (out_info != info) - { - hb_glyph_info_t *tmp_string; - tmp_string = info; - info = out_info; - out_info = tmp_string; - pos = (hb_glyph_position_t *) out_info; - } - - unsigned int tmp; - tmp = len; - len = out_len; - out_len = tmp; - - idx = 0; -} - - -void -hb_buffer_t::replace_glyphs (unsigned int num_in, - unsigned int num_out, - const uint32_t *glyph_data) -{ - if (unlikely (!make_room_for (num_in, num_out))) return; - - merge_clusters (idx, idx + num_in); - - hb_glyph_info_t orig_info = info[idx]; - hb_glyph_info_t *pinfo = &out_info[out_len]; - for (unsigned int i = 0; i < num_out; i++) - { - *pinfo = orig_info; - pinfo->codepoint = glyph_data[i]; - pinfo++; - } - - idx += num_in; - out_len += num_out; -} - -void -hb_buffer_t::output_glyph (hb_codepoint_t glyph_index) -{ - if (unlikely (!make_room_for (0, 1))) return; - - out_info[out_len] = info[idx]; - out_info[out_len].codepoint = glyph_index; - - out_len++; -} - -void -hb_buffer_t::output_info (const hb_glyph_info_t &glyph_info) -{ - if (unlikely (!make_room_for (0, 1))) return; - - out_info[out_len] = glyph_info; - - out_len++; -} - -void -hb_buffer_t::copy_glyph (void) -{ - if (unlikely (!make_room_for (0, 1))) return; - - out_info[out_len] = info[idx]; - - out_len++; -} - -bool -hb_buffer_t::move_to (unsigned int i) -{ - if (!have_output) - { - assert (i <= len); - idx = i; - return true; - } - - assert (i <= out_len + (len - idx)); - - if (out_len < i) - { - unsigned int count = i - out_len; - if (unlikely (!make_room_for (count, count))) return false; - - memmove (out_info + out_len, info + idx, count * sizeof (out_info[0])); - idx += count; - out_len += count; - } - else if (out_len > i) - { - /* Tricky part: rewinding... */ - unsigned int count = out_len - i; - - if (unlikely (idx < count && !shift_forward (count + 32))) return false; - - assert (idx >= count); - - idx -= count; - out_len -= count; - memmove (info + idx, out_info + out_len, count * sizeof (out_info[0])); - } - - return true; -} - -void -hb_buffer_t::replace_glyph (hb_codepoint_t glyph_index) -{ - if (unlikely (out_info != info || out_len != idx)) { - if (unlikely (!make_room_for (1, 1))) return; - out_info[out_len] = info[idx]; - } - out_info[out_len].codepoint = glyph_index; - - idx++; - out_len++; -} - - -void -hb_buffer_t::set_masks (hb_mask_t value, - hb_mask_t mask, - unsigned int cluster_start, - unsigned int cluster_end) -{ - hb_mask_t not_mask = ~mask; - value &= mask; - - if (!mask) - return; - - if (cluster_start == 0 && cluster_end == (unsigned int)-1) { - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - info[i].mask = (info[i].mask & not_mask) | value; - return; - } - - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) - info[i].mask = (info[i].mask & not_mask) | value; -} - -void -hb_buffer_t::reverse_range (unsigned int start, - unsigned int end) -{ - unsigned int i, j; - - if (end - start < 2) - return; - - for (i = start, j = end - 1; i < j; i++, j--) { - hb_glyph_info_t t; - - t = info[i]; - info[i] = info[j]; - info[j] = t; - } - - if (have_positions) { - for (i = start, j = end - 1; i < j; i++, j--) { - hb_glyph_position_t t; - - t = pos[i]; - pos[i] = pos[j]; - pos[j] = t; - } - } -} - -void -hb_buffer_t::reverse (void) -{ - if (unlikely (!len)) - return; - - reverse_range (0, len); -} - -void -hb_buffer_t::reverse_clusters (void) -{ - unsigned int i, start, count, last_cluster; - - if (unlikely (!len)) - return; - - reverse (); - - count = len; - start = 0; - last_cluster = info[0].cluster; - for (i = 1; i < count; i++) { - if (last_cluster != info[i].cluster) { - reverse_range (start, i); - start = i; - last_cluster = info[i].cluster; - } - } - reverse_range (start, i); -} - -void -hb_buffer_t::merge_clusters_impl (unsigned int start, - unsigned int end) -{ - if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS) - return; - - unsigned int cluster = info[start].cluster; - - for (unsigned int i = start + 1; i < end; i++) - cluster = MIN (cluster, info[i].cluster); - - /* Extend end */ - while (end < len && info[end - 1].cluster == info[end].cluster) - end++; - - /* Extend start */ - while (idx < start && info[start - 1].cluster == info[start].cluster) - start--; - - /* If we hit the start of buffer, continue in out-buffer. */ - if (idx == start) - for (unsigned int i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--) - out_info[i - 1].cluster = cluster; - - for (unsigned int i = start; i < end; i++) - info[i].cluster = cluster; -} -void -hb_buffer_t::merge_out_clusters (unsigned int start, - unsigned int end) -{ - if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS) - return; - - if (unlikely (end - start < 2)) - return; - - unsigned int cluster = out_info[start].cluster; - - for (unsigned int i = start + 1; i < end; i++) - cluster = MIN (cluster, out_info[i].cluster); - - /* Extend start */ - while (start && out_info[start - 1].cluster == out_info[start].cluster) - start--; - - /* Extend end */ - while (end < out_len && out_info[end - 1].cluster == out_info[end].cluster) - end++; - - /* If we hit the end of out-buffer, continue in buffer. */ - if (end == out_len) - for (unsigned int i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++) - info[i].cluster = cluster; - - for (unsigned int i = start; i < end; i++) - out_info[i].cluster = cluster; -} -void -hb_buffer_t::delete_glyph () -{ - unsigned int cluster = info[idx].cluster; - if (idx + 1 < len && cluster == info[idx + 1].cluster) - { - /* Cluster survives; do nothing. */ - goto done; - } - - if (out_len) - { - /* Merge cluster backward. */ - if (cluster < out_info[out_len - 1].cluster) - { - unsigned int old_cluster = out_info[out_len - 1].cluster; - for (unsigned i = out_len; i && out_info[i - 1].cluster == old_cluster; i--) - out_info[i - 1].cluster = cluster; - } - goto done; - } - - if (idx + 1 < len) - { - /* Merge cluster forward. */ - merge_clusters (idx, idx + 2); - goto done; - } - -done: - skip_glyph (); -} - -void -hb_buffer_t::guess_segment_properties (void) -{ - assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || - (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); - - /* If script is set to INVALID, guess from buffer contents */ - if (props.script == HB_SCRIPT_INVALID) { - for (unsigned int i = 0; i < len; i++) { - hb_script_t script = unicode->script (info[i].codepoint); - if (likely (script != HB_SCRIPT_COMMON && - script != HB_SCRIPT_INHERITED && - script != HB_SCRIPT_UNKNOWN)) { - props.script = script; - break; - } - } - } - - /* If direction is set to INVALID, guess from script */ - if (props.direction == HB_DIRECTION_INVALID) { - props.direction = hb_script_get_horizontal_direction (props.script); - } - - /* If language is not set, use default language from locale */ - if (props.language == HB_LANGUAGE_INVALID) { - /* TODO get_default_for_script? using $LANGUAGE */ - props.language = hb_language_get_default (); - } -} - - -static inline void -dump_var_allocation (const hb_buffer_t *buffer) -{ - char buf[80]; - for (unsigned int i = 0; i < 8; i++) - buf[i] = '0' + buffer->allocated_var_bytes[7 - i]; - buf[8] = '\0'; - DEBUG_MSG (BUFFER, buffer, - "Current var allocation: %s", - buf); -} - -void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner) -{ - assert (byte_i < 8 && byte_i + count <= 8); - - if (DEBUG_ENABLED (BUFFER)) - dump_var_allocation (this); - DEBUG_MSG (BUFFER, this, - "Allocating var bytes %d..%d for %s", - byte_i, byte_i + count - 1, owner); - - for (unsigned int i = byte_i; i < byte_i + count; i++) { - assert (!allocated_var_bytes[i]); - allocated_var_bytes[i]++; - allocated_var_owner[i] = owner; - } -} - -void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner) -{ - if (DEBUG_ENABLED (BUFFER)) - dump_var_allocation (this); - - DEBUG_MSG (BUFFER, this, - "Deallocating var bytes %d..%d for %s", - byte_i, byte_i + count - 1, owner); - - assert (byte_i < 8 && byte_i + count <= 8); - for (unsigned int i = byte_i; i < byte_i + count; i++) { - assert (allocated_var_bytes[i]); - assert (0 == strcmp (allocated_var_owner[i], owner)); - allocated_var_bytes[i]--; - } -} - -void hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner) -{ - if (DEBUG_ENABLED (BUFFER)) - dump_var_allocation (this); - - DEBUG_MSG (BUFFER, this, - "Asserting var bytes %d..%d for %s", - byte_i, byte_i + count - 1, owner); - - assert (byte_i < 8 && byte_i + count <= 8); - for (unsigned int i = byte_i; i < byte_i + count; i++) { - assert (allocated_var_bytes[i]); - assert (0 == strcmp (allocated_var_owner[i], owner)); - } -} - -void hb_buffer_t::deallocate_var_all (void) -{ - memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); - memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); -} - -/* Public API */ - -/** - * hb_buffer_create: (Xconstructor) - * - * - * - * Return value: (transfer full) - * - * Since: 0.9.2 - **/ -hb_buffer_t * -hb_buffer_create (void) -{ - hb_buffer_t *buffer; - - if (!(buffer = hb_object_create ())) - return hb_buffer_get_empty (); - - buffer->max_len = HB_BUFFER_MAX_LEN_DEFAULT; - - buffer->reset (); - - return buffer; -} - -/** - * hb_buffer_get_empty: - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_buffer_t * -hb_buffer_get_empty (void) -{ - static const hb_buffer_t _hb_buffer_nil = { - HB_OBJECT_HEADER_STATIC, - - const_cast (&_hb_unicode_funcs_nil), - HB_BUFFER_FLAG_DEFAULT, - HB_BUFFER_CLUSTER_LEVEL_DEFAULT, - HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, - HB_BUFFER_SCRATCH_FLAG_DEFAULT, - HB_BUFFER_MAX_LEN_DEFAULT, - - HB_BUFFER_CONTENT_TYPE_INVALID, - HB_SEGMENT_PROPERTIES_DEFAULT, - true, /* in_error */ - true, /* have_output */ - true /* have_positions */ - - /* Zero is good enough for everything else. */ - }; - - return const_cast (&_hb_buffer_nil); -} - -/** - * hb_buffer_reference: (skip) - * @buffer: a buffer. - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_buffer_t * -hb_buffer_reference (hb_buffer_t *buffer) -{ - return hb_object_reference (buffer); -} - -/** - * hb_buffer_destroy: (skip) - * @buffer: a buffer. - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_destroy (hb_buffer_t *buffer) -{ - if (!hb_object_destroy (buffer)) return; - - hb_unicode_funcs_destroy (buffer->unicode); - - free (buffer->info); - free (buffer->pos); - - free (buffer); -} - -/** - * hb_buffer_set_user_data: (skip) - * @buffer: a buffer. - * @key: - * @data: - * @destroy: - * @replace: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_buffer_set_user_data (hb_buffer_t *buffer, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - return hb_object_set_user_data (buffer, key, data, destroy, replace); -} - -/** - * hb_buffer_get_user_data: (skip) - * @buffer: a buffer. - * @key: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -void * -hb_buffer_get_user_data (hb_buffer_t *buffer, - hb_user_data_key_t *key) -{ - return hb_object_get_user_data (buffer, key); -} - - -/** - * hb_buffer_set_content_type: - * @buffer: a buffer. - * @content_type: - * - * - * - * Since: 0.9.5 - **/ -void -hb_buffer_set_content_type (hb_buffer_t *buffer, - hb_buffer_content_type_t content_type) -{ - buffer->content_type = content_type; -} - -/** - * hb_buffer_get_content_type: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.5 - **/ -hb_buffer_content_type_t -hb_buffer_get_content_type (hb_buffer_t *buffer) -{ - return buffer->content_type; -} - - -/** - * hb_buffer_set_unicode_funcs: - * @buffer: a buffer. - * @unicode_funcs: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, - hb_unicode_funcs_t *unicode_funcs) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - if (!unicode_funcs) - unicode_funcs = hb_unicode_funcs_get_default (); - - - hb_unicode_funcs_reference (unicode_funcs); - hb_unicode_funcs_destroy (buffer->unicode); - buffer->unicode = unicode_funcs; -} - -/** - * hb_buffer_get_unicode_funcs: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_unicode_funcs_t * -hb_buffer_get_unicode_funcs (hb_buffer_t *buffer) -{ - return buffer->unicode; -} - -/** - * hb_buffer_set_direction: - * @buffer: a buffer. - * @direction: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_set_direction (hb_buffer_t *buffer, - hb_direction_t direction) - -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->props.direction = direction; -} - -/** - * hb_buffer_get_direction: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_direction_t -hb_buffer_get_direction (hb_buffer_t *buffer) -{ - return buffer->props.direction; -} - -/** - * hb_buffer_set_script: - * @buffer: a buffer. - * @script: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_set_script (hb_buffer_t *buffer, - hb_script_t script) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->props.script = script; -} - -/** - * hb_buffer_get_script: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_script_t -hb_buffer_get_script (hb_buffer_t *buffer) -{ - return buffer->props.script; -} - -/** - * hb_buffer_set_language: - * @buffer: a buffer. - * @language: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_set_language (hb_buffer_t *buffer, - hb_language_t language) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->props.language = language; -} - -/** - * hb_buffer_get_language: - * @buffer: a buffer. - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -hb_language_t -hb_buffer_get_language (hb_buffer_t *buffer) -{ - return buffer->props.language; -} - -/** - * hb_buffer_set_segment_properties: - * @buffer: a buffer. - * @props: - * - * - * - * Since: 0.9.7 - **/ -void -hb_buffer_set_segment_properties (hb_buffer_t *buffer, - const hb_segment_properties_t *props) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->props = *props; -} - -/** - * hb_buffer_get_segment_properties: - * @buffer: a buffer. - * @props: (out): - * - * - * - * Since: 0.9.7 - **/ -void -hb_buffer_get_segment_properties (hb_buffer_t *buffer, - hb_segment_properties_t *props) -{ - *props = buffer->props; -} - - -/** - * hb_buffer_set_flags: - * @buffer: a buffer. - * @flags: - * - * - * - * Since: 0.9.7 - **/ -void -hb_buffer_set_flags (hb_buffer_t *buffer, - hb_buffer_flags_t flags) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->flags = flags; -} - -/** - * hb_buffer_get_flags: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.7 - **/ -hb_buffer_flags_t -hb_buffer_get_flags (hb_buffer_t *buffer) -{ - return buffer->flags; -} - -/** - * hb_buffer_set_cluster_level: - * @buffer: a buffer. - * @cluster_level: - * - * - * - * Since: 0.9.42 - **/ -void -hb_buffer_set_cluster_level (hb_buffer_t *buffer, - hb_buffer_cluster_level_t cluster_level) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->cluster_level = cluster_level; -} - -/** - * hb_buffer_get_cluster_level: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.42 - **/ -hb_buffer_cluster_level_t -hb_buffer_get_cluster_level (hb_buffer_t *buffer) -{ - return buffer->cluster_level; -} - - -/** - * hb_buffer_set_replacement_codepoint: - * @buffer: a buffer. - * @replacement: - * - * - * - * Since: 0.9.31 - **/ -void -hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, - hb_codepoint_t replacement) -{ - if (unlikely (hb_object_is_inert (buffer))) - return; - - buffer->replacement = replacement; -} - -/** - * hb_buffer_get_replacement_codepoint: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.31 - **/ -hb_codepoint_t -hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer) -{ - return buffer->replacement; -} - - -/** - * hb_buffer_reset: - * @buffer: a buffer. - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_reset (hb_buffer_t *buffer) -{ - buffer->reset (); -} - -/** - * hb_buffer_clear_contents: - * @buffer: a buffer. - * - * - * - * Since: 0.9.11 - **/ -void -hb_buffer_clear_contents (hb_buffer_t *buffer) -{ - buffer->clear (); -} - -/** - * hb_buffer_pre_allocate: - * @buffer: a buffer. - * @size: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) -{ - return buffer->ensure (size); -} - -/** - * hb_buffer_allocation_successful: - * @buffer: a buffer. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_buffer_allocation_successful (hb_buffer_t *buffer) -{ - return !buffer->in_error; -} - -/** - * hb_buffer_add: - * @buffer: a buffer. - * @codepoint: - * @cluster: - * - * - * - * Since: 0.9.7 - **/ -void -hb_buffer_add (hb_buffer_t *buffer, - hb_codepoint_t codepoint, - unsigned int cluster) -{ - buffer->add (codepoint, cluster); - buffer->clear_context (1); -} - -/** - * hb_buffer_set_length: - * @buffer: a buffer. - * @length: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_buffer_set_length (hb_buffer_t *buffer, - unsigned int length) -{ - if (unlikely (hb_object_is_inert (buffer))) - return length == 0; - - if (!buffer->ensure (length)) - return false; - - /* Wipe the new space */ - if (length > buffer->len) { - memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len)); - if (buffer->have_positions) - memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len)); - } - - buffer->len = length; - - if (!length) - { - buffer->content_type = HB_BUFFER_CONTENT_TYPE_INVALID; - buffer->clear_context (0); - } - buffer->clear_context (1); - - return true; -} - -/** - * hb_buffer_get_length: - * @buffer: a buffer. - * - * Returns the number of items in the buffer. - * - * Return value: buffer length. - * - * Since: 0.9.2 - **/ -unsigned int -hb_buffer_get_length (hb_buffer_t *buffer) -{ - return buffer->len; -} - -/** - * hb_buffer_get_glyph_infos: - * @buffer: a buffer. - * @length: (out): output array length. - * - * Returns buffer glyph information array. Returned pointer - * is valid as long as buffer contents are not modified. - * - * Return value: (transfer none) (array length=length): buffer glyph information array. - * - * Since: 0.9.2 - **/ -hb_glyph_info_t * -hb_buffer_get_glyph_infos (hb_buffer_t *buffer, - unsigned int *length) -{ - if (length) - *length = buffer->len; - - return (hb_glyph_info_t *) buffer->info; -} - -/** - * hb_buffer_get_glyph_positions: - * @buffer: a buffer. - * @length: (out): output length. - * - * Returns buffer glyph position array. Returned pointer - * is valid as long as buffer contents are not modified. - * - * Return value: (transfer none) (array length=length): buffer glyph position array. - * - * Since: 0.9.2 - **/ -hb_glyph_position_t * -hb_buffer_get_glyph_positions (hb_buffer_t *buffer, - unsigned int *length) -{ - if (!buffer->have_positions) - buffer->clear_positions (); - - if (length) - *length = buffer->len; - - return (hb_glyph_position_t *) buffer->pos; -} - -/** - * hb_buffer_reverse: - * @buffer: a buffer. - * - * Reverses buffer contents. - * - * Since: 0.9.2 - **/ -void -hb_buffer_reverse (hb_buffer_t *buffer) -{ - buffer->reverse (); -} - -/** - * hb_buffer_reverse_range: - * @buffer: a buffer. - * @start: start index. - * @end: end index. - * - * Reverses buffer contents between start to end. - * - * Since: 0.9.41 - **/ -void -hb_buffer_reverse_range (hb_buffer_t *buffer, - unsigned int start, unsigned int end) -{ - buffer->reverse_range (start, end); -} - -/** - * hb_buffer_reverse_clusters: - * @buffer: a buffer. - * - * Reverses buffer clusters. That is, the buffer contents are - * reversed, then each cluster (consecutive items having the - * same cluster number) are reversed again. - * - * Since: 0.9.2 - **/ -void -hb_buffer_reverse_clusters (hb_buffer_t *buffer) -{ - buffer->reverse_clusters (); -} - -/** - * hb_buffer_guess_segment_properties: - * @buffer: a buffer. - * - * Sets unset buffer segment properties based on buffer Unicode - * contents. If buffer is not empty, it must have content type - * %HB_BUFFER_CONTENT_TYPE_UNICODE. - * - * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it - * will be set to the Unicode script of the first character in - * the buffer that has a script other than %HB_SCRIPT_COMMON, - * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. - * - * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), - * it will be set to the natural horizontal direction of the - * buffer script as returned by hb_script_get_horizontal_direction(). - * - * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), - * it will be set to the process's default language as returned by - * hb_language_get_default(). This may change in the future by - * taking buffer script into consideration when choosing a language. - * - * Since: 0.9.7 - **/ -void -hb_buffer_guess_segment_properties (hb_buffer_t *buffer) -{ - buffer->guess_segment_properties (); -} - -template -static inline void -hb_buffer_add_utf (hb_buffer_t *buffer, - const typename utf_t::codepoint_t *text, - int text_length, - unsigned int item_offset, - int item_length) -{ - typedef typename utf_t::codepoint_t T; - const hb_codepoint_t replacement = buffer->replacement; - - assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || - (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); - - if (unlikely (hb_object_is_inert (buffer))) - return; - - if (text_length == -1) - text_length = utf_t::strlen (text); - - if (item_length == -1) - item_length = text_length - item_offset; - - buffer->ensure (buffer->len + item_length * sizeof (T) / 4); - - /* If buffer is empty and pre-context provided, install it. - * This check is written this way, to make sure people can - * provide pre-context in one add_utf() call, then provide - * text in a follow-up call. See: - * - * https://bugzilla.mozilla.org/show_bug.cgi?id=801410#c13 - */ - if (!buffer->len && item_offset > 0) - { - /* Add pre-context */ - buffer->clear_context (0); - const T *prev = text + item_offset; - const T *start = text; - while (start < prev && buffer->context_len[0] < buffer->CONTEXT_LENGTH) - { - hb_codepoint_t u; - prev = utf_t::prev (prev, start, &u, replacement); - buffer->context[0][buffer->context_len[0]++] = u; - } - } - - const T *next = text + item_offset; - const T *end = next + item_length; - while (next < end) - { - hb_codepoint_t u; - const T *old_next = next; - next = utf_t::next (next, end, &u, replacement); - buffer->add (u, old_next - (const T *) text); - } - - /* Add post-context */ - buffer->clear_context (1); - end = text + text_length; - while (next < end && buffer->context_len[1] < buffer->CONTEXT_LENGTH) - { - hb_codepoint_t u; - next = utf_t::next (next, end, &u, replacement); - buffer->context[1][buffer->context_len[1]++] = u; - } - - buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; -} - -/** - * hb_buffer_add_utf8: - * @buffer: a buffer. - * @text: (array length=text_length) (element-type uint8_t): - * @text_length: - * @item_offset: - * @item_length: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_add_utf8 (hb_buffer_t *buffer, - const char *text, - int text_length, - unsigned int item_offset, - int item_length) -{ - hb_buffer_add_utf (buffer, (const uint8_t *) text, text_length, item_offset, item_length); -} - -/** - * hb_buffer_add_utf16: - * @buffer: a buffer. - * @text: (array length=text_length): - * @text_length: - * @item_offset: - * @item_length: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_add_utf16 (hb_buffer_t *buffer, - const uint16_t *text, - int text_length, - unsigned int item_offset, - int item_length) -{ - hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); -} - -/** - * hb_buffer_add_utf32: - * @buffer: a buffer. - * @text: (array length=text_length): - * @text_length: - * @item_offset: - * @item_length: - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_add_utf32 (hb_buffer_t *buffer, - const uint32_t *text, - int text_length, - unsigned int item_offset, - int item_length) -{ - hb_buffer_add_utf > (buffer, text, text_length, item_offset, item_length); -} - -/** - * hb_buffer_add_latin1: - * @buffer: a buffer. - * @text: (array length=text_length) (element-type uint8_t): - * @text_length: - * @item_offset: - * @item_length: - * - * - * - * Since: 0.9.39 - **/ -void -hb_buffer_add_latin1 (hb_buffer_t *buffer, - const uint8_t *text, - int text_length, - unsigned int item_offset, - int item_length) -{ - hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); -} - -/** - * hb_buffer_add_codepoints: - * @buffer: a buffer. - * @text: (array length=text_length): - * @text_length: - * @item_offset: - * @item_length: - * - * - * - * Since: 0.9.31 - **/ -void -hb_buffer_add_codepoints (hb_buffer_t *buffer, - const hb_codepoint_t *text, - int text_length, - unsigned int item_offset, - int item_length) -{ - hb_buffer_add_utf > (buffer, text, text_length, item_offset, item_length); -} - - -static int -compare_info_codepoint (const hb_glyph_info_t *pa, - const hb_glyph_info_t *pb) -{ - return (int) pb->codepoint - (int) pa->codepoint; -} - -static inline void -normalize_glyphs_cluster (hb_buffer_t *buffer, - unsigned int start, - unsigned int end, - bool backward) -{ - hb_glyph_position_t *pos = buffer->pos; - - /* Total cluster advance */ - hb_position_t total_x_advance = 0, total_y_advance = 0; - for (unsigned int i = start; i < end; i++) - { - total_x_advance += pos[i].x_advance; - total_y_advance += pos[i].y_advance; - } - - hb_position_t x_advance = 0, y_advance = 0; - for (unsigned int i = start; i < end; i++) - { - pos[i].x_offset += x_advance; - pos[i].y_offset += y_advance; - - x_advance += pos[i].x_advance; - y_advance += pos[i].y_advance; - - pos[i].x_advance = 0; - pos[i].y_advance = 0; - } - - if (backward) - { - /* Transfer all cluster advance to the last glyph. */ - pos[end - 1].x_advance = total_x_advance; - pos[end - 1].y_advance = total_y_advance; - - hb_stable_sort (buffer->info + start, end - start - 1, compare_info_codepoint, buffer->pos + start); - } else { - /* Transfer all cluster advance to the first glyph. */ - pos[start].x_advance += total_x_advance; - pos[start].y_advance += total_y_advance; - for (unsigned int i = start + 1; i < end; i++) { - pos[i].x_offset -= total_x_advance; - pos[i].y_offset -= total_y_advance; - } - hb_stable_sort (buffer->info + start + 1, end - start - 1, compare_info_codepoint, buffer->pos + start + 1); - } -} - -/** - * hb_buffer_normalize_glyphs: - * @buffer: a buffer. - * - * - * - * Since: 0.9.2 - **/ -void -hb_buffer_normalize_glyphs (hb_buffer_t *buffer) -{ - assert (buffer->have_positions); - assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); - - bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); - - unsigned int count = buffer->len; - if (unlikely (!count)) return; - hb_glyph_info_t *info = buffer->info; - - unsigned int start = 0; - unsigned int end; - for (end = start + 1; end < count; end++) - if (info[start].cluster != info[end].cluster) { - normalize_glyphs_cluster (buffer, start, end, backward); - start = end; - } - normalize_glyphs_cluster (buffer, start, end, backward); -} - -void -hb_buffer_t::sort (unsigned int start, unsigned int end, int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *)) -{ - assert (!have_positions); - for (unsigned int i = start + 1; i < end; i++) - { - unsigned int j = i; - while (j > start && compar (&info[j - 1], &info[i]) > 0) - j--; - if (i == j) - continue; - /* Move item i to occupy place for item j, shift what's in between. */ - merge_clusters (j, i + 1); - { - hb_glyph_info_t t = info[i]; - memmove (&info[j + 1], &info[j], (i - j) * sizeof (hb_glyph_info_t)); - info[j] = t; - } - } -} diff --git a/third_party/harfbuzz-ng/src/hb-buffer.h b/third_party/harfbuzz-ng/src/hb-buffer.h deleted file mode 100644 index bb89dc3de744..000000000000 --- a/third_party/harfbuzz-ng/src/hb-buffer.h +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright © 1998-2004 David Turner and Werner Lemberg - * Copyright © 2004,2007,2009 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Owen Taylor, Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_H_IN -#error "Include instead." -#endif - -#ifndef HB_BUFFER_H -#define HB_BUFFER_H - -#include "hb-common.h" -#include "hb-unicode.h" -#include "hb-font.h" - -HB_BEGIN_DECLS - - -typedef struct hb_glyph_info_t { - hb_codepoint_t codepoint; - hb_mask_t mask; - uint32_t cluster; - - /*< private >*/ - hb_var_int_t var1; - hb_var_int_t var2; -} hb_glyph_info_t; - -typedef struct hb_glyph_position_t { - hb_position_t x_advance; - hb_position_t y_advance; - hb_position_t x_offset; - hb_position_t y_offset; - - /*< private >*/ - hb_var_int_t var; -} hb_glyph_position_t; - - -typedef struct hb_segment_properties_t { - hb_direction_t direction; - hb_script_t script; - hb_language_t language; - /*< private >*/ - void *reserved1; - void *reserved2; -} hb_segment_properties_t; - -#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ - HB_SCRIPT_INVALID, \ - HB_LANGUAGE_INVALID, \ - NULL, \ - NULL} - -hb_bool_t -hb_segment_properties_equal (const hb_segment_properties_t *a, - const hb_segment_properties_t *b); - -unsigned int -hb_segment_properties_hash (const hb_segment_properties_t *p); - - - -/* - * hb_buffer_t - */ - -typedef struct hb_buffer_t hb_buffer_t; - -hb_buffer_t * -hb_buffer_create (void); - -hb_buffer_t * -hb_buffer_get_empty (void); - -hb_buffer_t * -hb_buffer_reference (hb_buffer_t *buffer); - -void -hb_buffer_destroy (hb_buffer_t *buffer); - -hb_bool_t -hb_buffer_set_user_data (hb_buffer_t *buffer, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - -void * -hb_buffer_get_user_data (hb_buffer_t *buffer, - hb_user_data_key_t *key); - - -typedef enum { - HB_BUFFER_CONTENT_TYPE_INVALID = 0, - HB_BUFFER_CONTENT_TYPE_UNICODE, - HB_BUFFER_CONTENT_TYPE_GLYPHS -} hb_buffer_content_type_t; - -void -hb_buffer_set_content_type (hb_buffer_t *buffer, - hb_buffer_content_type_t content_type); - -hb_buffer_content_type_t -hb_buffer_get_content_type (hb_buffer_t *buffer); - - -void -hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, - hb_unicode_funcs_t *unicode_funcs); - -hb_unicode_funcs_t * -hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); - -void -hb_buffer_set_direction (hb_buffer_t *buffer, - hb_direction_t direction); - -hb_direction_t -hb_buffer_get_direction (hb_buffer_t *buffer); - -void -hb_buffer_set_script (hb_buffer_t *buffer, - hb_script_t script); - -hb_script_t -hb_buffer_get_script (hb_buffer_t *buffer); - -void -hb_buffer_set_language (hb_buffer_t *buffer, - hb_language_t language); - - -hb_language_t -hb_buffer_get_language (hb_buffer_t *buffer); - -void -hb_buffer_set_segment_properties (hb_buffer_t *buffer, - const hb_segment_properties_t *props); - -void -hb_buffer_get_segment_properties (hb_buffer_t *buffer, - hb_segment_properties_t *props); - -void -hb_buffer_guess_segment_properties (hb_buffer_t *buffer); - - -/* - * Since: 0.9.20 - */ -typedef enum { /*< flags >*/ - HB_BUFFER_FLAG_DEFAULT = 0x00000000u, - HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ - HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ - HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u -} hb_buffer_flags_t; - -void -hb_buffer_set_flags (hb_buffer_t *buffer, - hb_buffer_flags_t flags); - -hb_buffer_flags_t -hb_buffer_get_flags (hb_buffer_t *buffer); - -/* - * Since: 0.9.42 - */ -typedef enum { - HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, - HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, - HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, - HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES -} hb_buffer_cluster_level_t; - -void -hb_buffer_set_cluster_level (hb_buffer_t *buffer, - hb_buffer_cluster_level_t cluster_level); - -hb_buffer_cluster_level_t -hb_buffer_get_cluster_level (hb_buffer_t *buffer); - -#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu - -/* Sets codepoint used to replace invalid UTF-8/16/32 entries. - * Default is 0xFFFDu. */ -void -hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, - hb_codepoint_t replacement); - -hb_codepoint_t -hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer); - - -/* Resets the buffer. Afterwards it's as if it was just created, - * except that it has a larger buffer allocated perhaps... */ -void -hb_buffer_reset (hb_buffer_t *buffer); - -/* Like reset, but does NOT clear unicode_funcs and replacement_codepoint. */ -void -hb_buffer_clear_contents (hb_buffer_t *buffer); - -/* Returns false if allocation failed */ -hb_bool_t -hb_buffer_pre_allocate (hb_buffer_t *buffer, - unsigned int size); - - -/* Returns false if allocation has failed before */ -hb_bool_t -hb_buffer_allocation_successful (hb_buffer_t *buffer); - -void -hb_buffer_reverse (hb_buffer_t *buffer); - -void -hb_buffer_reverse_range (hb_buffer_t *buffer, - unsigned int start, unsigned int end); - -void -hb_buffer_reverse_clusters (hb_buffer_t *buffer); - - -/* Filling the buffer in */ - -void -hb_buffer_add (hb_buffer_t *buffer, - hb_codepoint_t codepoint, - unsigned int cluster); - -void -hb_buffer_add_utf8 (hb_buffer_t *buffer, - const char *text, - int text_length, - unsigned int item_offset, - int item_length); - -void -hb_buffer_add_utf16 (hb_buffer_t *buffer, - const uint16_t *text, - int text_length, - unsigned int item_offset, - int item_length); - -void -hb_buffer_add_utf32 (hb_buffer_t *buffer, - const uint32_t *text, - int text_length, - unsigned int item_offset, - int item_length); - -/* Allows only access to first 256 Unicode codepoints. */ -void -hb_buffer_add_latin1 (hb_buffer_t *buffer, - const uint8_t *text, - int text_length, - unsigned int item_offset, - int item_length); - -/* Like add_utf32 but does NOT check for invalid Unicode codepoints. */ -void -hb_buffer_add_codepoints (hb_buffer_t *buffer, - const hb_codepoint_t *text, - int text_length, - unsigned int item_offset, - int item_length); - - -/* Clears any new items added at the end */ -hb_bool_t -hb_buffer_set_length (hb_buffer_t *buffer, - unsigned int length); - -/* Return value valid as long as buffer not modified */ -unsigned int -hb_buffer_get_length (hb_buffer_t *buffer); - -/* Getting glyphs out of the buffer */ - -/* Return value valid as long as buffer not modified */ -hb_glyph_info_t * -hb_buffer_get_glyph_infos (hb_buffer_t *buffer, - unsigned int *length); - -/* Return value valid as long as buffer not modified */ -hb_glyph_position_t * -hb_buffer_get_glyph_positions (hb_buffer_t *buffer, - unsigned int *length); - - -/* Reorders a glyph buffer to have canonical in-cluster glyph order / position. - * The resulting clusters should behave identical to pre-reordering clusters. - * NOTE: This has nothing to do with Unicode normalization. */ -void -hb_buffer_normalize_glyphs (hb_buffer_t *buffer); - - -/* - * Serialize - */ - -/* - * Since: 0.9.20 - */ -typedef enum { /*< flags >*/ - HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, - HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, - HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, - HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, - HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u -} hb_buffer_serialize_flags_t; - -typedef enum { - HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), - HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), - HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE -} hb_buffer_serialize_format_t; - -/* len=-1 means str is NUL-terminated. */ -hb_buffer_serialize_format_t -hb_buffer_serialize_format_from_string (const char *str, int len); - -const char * -hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); - -const char ** -hb_buffer_serialize_list_formats (void); - -/* Returns number of items, starting at start, that were serialized. */ -unsigned int -hb_buffer_serialize_glyphs (hb_buffer_t *buffer, - unsigned int start, - unsigned int end, - char *buf, - unsigned int buf_size, - unsigned int *buf_consumed, /* May be NULL */ - hb_font_t *font, /* May be NULL */ - hb_buffer_serialize_format_t format, - hb_buffer_serialize_flags_t flags); - -hb_bool_t -hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, - const char *buf, - int buf_len, /* -1 means nul-terminated */ - const char **end_ptr, /* May be NULL */ - hb_font_t *font, /* May be NULL */ - hb_buffer_serialize_format_t format); - - -HB_END_DECLS - -#endif /* HB_BUFFER_H */ diff --git a/third_party/harfbuzz-ng/src/hb-cache-private.hh b/third_party/harfbuzz-ng/src/hb-cache-private.hh deleted file mode 100644 index 19b70b7e3958..000000000000 --- a/third_party/harfbuzz-ng/src/hb-cache-private.hh +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_CACHE_PRIVATE_HH -#define HB_CACHE_PRIVATE_HH - -#include "hb-private.hh" - - -/* Implements a lock-free cache for int->int functions. */ - -template -struct hb_cache_t -{ - ASSERT_STATIC (key_bits >= cache_bits); - ASSERT_STATIC (key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int)); - - inline void clear (void) - { - memset (values, 255, sizeof (values)); - } - - inline bool get (unsigned int key, unsigned int *value) - { - unsigned int k = key & ((1<> value_bits) != (key >> cache_bits)) - return false; - *value = v & ((1<> key_bits) || (value >> value_bits))) - return false; /* Overflows */ - unsigned int k = key & ((1<>cache_bits)< hb_cmap_cache_t; -typedef hb_cache_t<16, 24, 8> hb_advance_cache_t; - - -#endif /* HB_CACHE_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-common.cc b/third_party/harfbuzz-ng/src/hb-common.cc deleted file mode 100644 index cd6a9b8912a7..000000000000 --- a/third_party/harfbuzz-ng/src/hb-common.cc +++ /dev/null @@ -1,601 +0,0 @@ -/* - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -#include "hb-mutex-private.hh" -#include "hb-object-private.hh" - -#if defined(STARBOARD) -#include "starboard/system.h" -#else // !defined(STARBOARD) -#include -#endif // defined(STARBOARD) - - -/* hb_options_t */ - -hb_options_union_t _hb_options; - -void -_hb_options_init (void) -{ - hb_options_union_t u; - u.i = 0; - u.opts.initialized = 1; - - char *c = getenv ("HB_OPTIONS"); - u.opts.uniscribe_bug_compatible = c && strstr (c, "uniscribe-bug-compatible"); - - /* This is idempotent and threadsafe. */ - _hb_options = u; -} - - -/* hb_tag_t */ - -/** - * hb_tag_from_string: - * @str: (array length=len) (element-type uint8_t): - * @len: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_tag_t -hb_tag_from_string (const char *str, int len) -{ - char tag[4]; - unsigned int i; - - if (!str || !len || !*str) - return HB_TAG_NONE; - - if (len < 0 || len > 4) - len = 4; - for (i = 0; i < (unsigned) len && str[i]; i++) - tag[i] = str[i]; - for (; i < 4; i++) - tag[i] = ' '; - - return HB_TAG_CHAR4 (tag); -} - -/** - * hb_tag_to_string: - * @tag: - * @buf: (array fixed-size=4): - * - * - * - * Since: 0.9.5 - **/ -void -hb_tag_to_string (hb_tag_t tag, char *buf) -{ - buf[0] = (char) (uint8_t) (tag >> 24); - buf[1] = (char) (uint8_t) (tag >> 16); - buf[2] = (char) (uint8_t) (tag >> 8); - buf[3] = (char) (uint8_t) (tag >> 0); -} - - -/* hb_direction_t */ - -const char direction_strings[][4] = { - "ltr", - "rtl", - "ttb", - "btt" -}; - -/** - * hb_direction_from_string: - * @str: (array length=len) (element-type uint8_t): - * @len: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_direction_t -hb_direction_from_string (const char *str, int len) -{ - if (unlikely (!str || !len || !*str)) - return HB_DIRECTION_INVALID; - - /* Lets match loosely: just match the first letter, such that - * all of "ltr", "left-to-right", etc work! - */ - char c = TOLOWER (str[0]); - for (unsigned int i = 0; i < ARRAY_LENGTH (direction_strings); i++) - if (c == direction_strings[i][0]) - return (hb_direction_t) (HB_DIRECTION_LTR + i); - - return HB_DIRECTION_INVALID; -} - -/** - * hb_direction_to_string: - * @direction: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -const char * -hb_direction_to_string (hb_direction_t direction) -{ - if (likely ((unsigned int) (direction - HB_DIRECTION_LTR) - < ARRAY_LENGTH (direction_strings))) - return direction_strings[direction - HB_DIRECTION_LTR]; - - return "invalid"; -} - - -/* hb_language_t */ - -struct hb_language_impl_t { - const char s[1]; -}; - -static const char canon_map[256] = { - 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', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0, - '-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '-', - 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, 0 -}; - -static bool -lang_equal (hb_language_t v1, - const void *v2) -{ - const unsigned char *p1 = (const unsigned char *) v1; - const unsigned char *p2 = (const unsigned char *) v2; - - while (*p1 && *p1 == canon_map[*p2]) - p1++, p2++; - - return *p1 == canon_map[*p2]; -} - -#if 0 -static unsigned int -lang_hash (const void *key) -{ - const unsigned char *p = key; - unsigned int h = 0; - while (canon_map[*p]) - { - h = (h << 5) - h + canon_map[*p]; - p++; - } - - return h; -} -#endif - - -struct hb_language_item_t { - - struct hb_language_item_t *next; - hb_language_t lang; - - inline bool operator == (const char *s) const { - return lang_equal (lang, s); - } - - inline hb_language_item_t & operator = (const char *s) { - lang = (hb_language_t) strdup (s); - for (unsigned char *p = (unsigned char *) lang; *p; p++) - *p = canon_map[*p]; - - return *this; - } - - void finish (void) { free ((void *) lang); } -}; - - -/* Thread-safe lock-free language list */ - -static hb_language_item_t *langs; - -#ifdef HB_USE_ATEXIT -static -void free_langs (void) -{ - while (langs) { - hb_language_item_t *next = langs->next; - langs->finish (); - free (langs); - langs = next; - } -} -#endif - -static hb_language_item_t * -lang_find_or_insert (const char *key) -{ -retry: - hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs); - - for (hb_language_item_t *lang = first_lang; lang; lang = lang->next) - if (*lang == key) - return lang; - - /* Not found; allocate one. */ - hb_language_item_t *lang = (hb_language_item_t *) calloc (1, sizeof (hb_language_item_t)); - if (unlikely (!lang)) - return NULL; - lang->next = first_lang; - *lang = key; - - if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) { - lang->finish (); - free (lang); - goto retry; - } - -#ifdef HB_USE_ATEXIT - if (!first_lang) - atexit (free_langs); /* First person registers atexit() callback. */ -#endif - - return lang; -} - - -/** - * hb_language_from_string: - * @str: (array length=len) (element-type uint8_t): - * @len: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -hb_language_t -hb_language_from_string (const char *str, int len) -{ - if (!str || !len || !*str) - return HB_LANGUAGE_INVALID; - - hb_language_item_t *item = NULL; - if (len >= 0) - { - /* NUL-terminate it. */ - char strbuf[64]; - len = MIN (len, (int) sizeof (strbuf) - 1); - memcpy (strbuf, str, len); - strbuf[len] = '\0'; - item = lang_find_or_insert (strbuf); - } - else - item = lang_find_or_insert (str); - - return likely (item) ? item->lang : HB_LANGUAGE_INVALID; -} - -/** - * hb_language_to_string: - * @language: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -const char * -hb_language_to_string (hb_language_t language) -{ - /* This is actually NULL-safe! */ - return language->s; -} - -/** - * hb_language_get_default: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -hb_language_t -hb_language_get_default (void) -{ - static hb_language_t default_language = HB_LANGUAGE_INVALID; - - hb_language_t language = (hb_language_t) hb_atomic_ptr_get (&default_language); - if (unlikely (language == HB_LANGUAGE_INVALID)) { -#if defined(STARBOARD) - language = hb_language_from_string (SbSystemGetLocaleId(), -1); -#else // !defined(STARBOARD) - language = hb_language_from_string (setlocale (LC_CTYPE, NULL), -1); -#endif // defined(STARBOARD) - (void) hb_atomic_ptr_cmpexch (&default_language, HB_LANGUAGE_INVALID, language); - } - - return default_language; -} - - -/* hb_script_t */ - -/** - * hb_script_from_iso15924_tag: - * @tag: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_script_t -hb_script_from_iso15924_tag (hb_tag_t tag) -{ - if (unlikely (tag == HB_TAG_NONE)) - return HB_SCRIPT_INVALID; - - /* Be lenient, adjust case (one capital letter followed by three small letters) */ - tag = (tag & 0xDFDFDFDFu) | 0x00202020u; - - switch (tag) { - - /* These graduated from the 'Q' private-area codes, but - * the old code is still aliased by Unicode, and the Qaai - * one in use by ICU. */ - case HB_TAG('Q','a','a','i'): return HB_SCRIPT_INHERITED; - case HB_TAG('Q','a','a','c'): return HB_SCRIPT_COPTIC; - - /* Script variants from http://unicode.org/iso15924/ */ - case HB_TAG('C','y','r','s'): return HB_SCRIPT_CYRILLIC; - case HB_TAG('L','a','t','f'): return HB_SCRIPT_LATIN; - case HB_TAG('L','a','t','g'): return HB_SCRIPT_LATIN; - case HB_TAG('S','y','r','e'): return HB_SCRIPT_SYRIAC; - case HB_TAG('S','y','r','j'): return HB_SCRIPT_SYRIAC; - case HB_TAG('S','y','r','n'): return HB_SCRIPT_SYRIAC; - } - - /* If it looks right, just use the tag as a script */ - if (((uint32_t) tag & 0xE0E0E0E0u) == 0x40606060u) - return (hb_script_t) tag; - - /* Otherwise, return unknown */ - return HB_SCRIPT_UNKNOWN; -} - -/** - * hb_script_from_string: - * @s: (array length=len) (element-type uint8_t): - * @len: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_script_t -hb_script_from_string (const char *s, int len) -{ - return hb_script_from_iso15924_tag (hb_tag_from_string (s, len)); -} - -/** - * hb_script_to_iso15924_tag: - * @script: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_tag_t -hb_script_to_iso15924_tag (hb_script_t script) -{ - return (hb_tag_t) script; -} - -/** - * hb_script_get_horizontal_direction: - * @script: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_direction_t -hb_script_get_horizontal_direction (hb_script_t script) -{ - /* http://goo.gl/x9ilM */ - switch ((hb_tag_t) script) - { - /* Unicode-1.1 additions */ - case HB_SCRIPT_ARABIC: - case HB_SCRIPT_HEBREW: - - /* Unicode-3.0 additions */ - case HB_SCRIPT_SYRIAC: - case HB_SCRIPT_THAANA: - - /* Unicode-4.0 additions */ - case HB_SCRIPT_CYPRIOT: - - /* Unicode-4.1 additions */ - case HB_SCRIPT_KHAROSHTHI: - - /* Unicode-5.0 additions */ - case HB_SCRIPT_PHOENICIAN: - case HB_SCRIPT_NKO: - - /* Unicode-5.1 additions */ - case HB_SCRIPT_LYDIAN: - - /* Unicode-5.2 additions */ - case HB_SCRIPT_AVESTAN: - case HB_SCRIPT_IMPERIAL_ARAMAIC: - case HB_SCRIPT_INSCRIPTIONAL_PAHLAVI: - case HB_SCRIPT_INSCRIPTIONAL_PARTHIAN: - case HB_SCRIPT_OLD_SOUTH_ARABIAN: - case HB_SCRIPT_OLD_TURKIC: - case HB_SCRIPT_SAMARITAN: - - /* Unicode-6.0 additions */ - case HB_SCRIPT_MANDAIC: - - /* Unicode-6.1 additions */ - case HB_SCRIPT_MEROITIC_CURSIVE: - case HB_SCRIPT_MEROITIC_HIEROGLYPHS: - - /* Unicode-7.0 additions */ - case HB_SCRIPT_MANICHAEAN: - case HB_SCRIPT_MENDE_KIKAKUI: - case HB_SCRIPT_NABATAEAN: - case HB_SCRIPT_OLD_NORTH_ARABIAN: - case HB_SCRIPT_PALMYRENE: - case HB_SCRIPT_PSALTER_PAHLAVI: - - /* Unicode-8.0 additions */ - case HB_SCRIPT_OLD_HUNGARIAN: - - return HB_DIRECTION_RTL; - } - - return HB_DIRECTION_LTR; -} - - -/* hb_user_data_array_t */ - -bool -hb_user_data_array_t::set (hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - if (!key) - return false; - - if (replace) { - if (!data && !destroy) { - items.remove (key, lock); - return true; - } - } - hb_user_data_item_t item = {key, data, destroy}; - bool ret = !!items.replace_or_insert (item, lock, replace); - - return ret; -} - -void * -hb_user_data_array_t::get (hb_user_data_key_t *key) -{ - hb_user_data_item_t item = {NULL }; - - return items.find (key, &item, lock) ? item.data : NULL; -} - - -/* hb_version */ - -/** - * hb_version: - * @major: (out): Library major version component. - * @minor: (out): Library minor version component. - * @micro: (out): Library micro version component. - * - * Returns library version as three integer components. - * - * Since: 0.9.2 - **/ -void -hb_version (unsigned int *major, - unsigned int *minor, - unsigned int *micro) -{ - *major = HB_VERSION_MAJOR; - *minor = HB_VERSION_MINOR; - *micro = HB_VERSION_MICRO; -} - -/** - * hb_version_string: - * - * Returns library version as a string with three components. - * - * Return value: library version string. - * - * Since: 0.9.2 - **/ -const char * -hb_version_string (void) -{ - return HB_VERSION_STRING; -} - -/** - * hb_version_atleast: - * @major: - * @minor: - * @micro: - * - * - * - * Return value: - * - * Since: 0.9.30 - **/ -hb_bool_t -hb_version_atleast (unsigned int major, - unsigned int minor, - unsigned int micro) -{ - return HB_VERSION_ATLEAST (major, minor, micro); -} diff --git a/third_party/harfbuzz-ng/src/hb-common.h b/third_party/harfbuzz-ng/src/hb-common.h deleted file mode 100644 index c291dbbe9476..000000000000 --- a/third_party/harfbuzz-ng/src/hb-common.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright © 2007,2008,2009 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_H_IN -#error "Include instead." -#endif - -#ifndef HB_COMMON_H -#define HB_COMMON_H - -#ifndef HB_BEGIN_DECLS -# ifdef __cplusplus -# define HB_BEGIN_DECLS extern "C" { -# define HB_END_DECLS } -# else /* !__cplusplus */ -# define HB_BEGIN_DECLS -# define HB_END_DECLS -# endif /* !__cplusplus */ -#endif - -#if !defined (HB_DONT_DEFINE_STDINT) - -#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || \ - defined (_sgi) || defined (__sun) || defined (sun) || \ - defined (__digital__) || defined (__HP_cc) -# include -#elif defined (_AIX) -# include -/* VS 2010 (_MSC_VER 1600) has stdint.h */ -#elif defined (_MSC_VER) && _MSC_VER < 1600 -typedef __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -# include -#endif - -#endif - -HB_BEGIN_DECLS - - -typedef int hb_bool_t; - -typedef uint32_t hb_codepoint_t; -typedef int32_t hb_position_t; -typedef uint32_t hb_mask_t; - -typedef union _hb_var_int_t { - uint32_t u32; - int32_t i32; - uint16_t u16[2]; - int16_t i16[2]; - uint8_t u8[4]; - int8_t i8[4]; -} hb_var_int_t; - - -/* hb_tag_t */ - -typedef uint32_t hb_tag_t; - -#define HB_TAG(c1,c2,c3,c4) ((hb_tag_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4)))) -#define HB_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag)) - -#define HB_TAG_NONE HB_TAG(0,0,0,0) -#define HB_TAG_MAX HB_TAG(0xff,0xff,0xff,0xff) -#define HB_TAG_MAX_SIGNED HB_TAG(0x7f,0xff,0xff,0xff) - -/* len=-1 means str is NUL-terminated. */ -hb_tag_t -hb_tag_from_string (const char *str, int len); - -/* buf should have 4 bytes. */ -void -hb_tag_to_string (hb_tag_t tag, char *buf); - - -/* hb_direction_t */ - -typedef enum { - HB_DIRECTION_INVALID = 0, - HB_DIRECTION_LTR = 4, - HB_DIRECTION_RTL, - HB_DIRECTION_TTB, - HB_DIRECTION_BTT -} hb_direction_t; - -/* len=-1 means str is NUL-terminated */ -hb_direction_t -hb_direction_from_string (const char *str, int len); - -const char * -hb_direction_to_string (hb_direction_t direction); - -#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4) -/* Direction must be valid for the following */ -#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4) -#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6) -#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4) -#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5) -#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) - - -/* hb_language_t */ - -typedef const struct hb_language_impl_t *hb_language_t; - -/* len=-1 means str is NUL-terminated */ -hb_language_t -hb_language_from_string (const char *str, int len); - -const char * -hb_language_to_string (hb_language_t language); - -#define HB_LANGUAGE_INVALID ((hb_language_t) NULL) - -hb_language_t -hb_language_get_default (void); - - -/* hb_script_t */ - -/* http://unicode.org/iso15924/ */ -/* http://goo.gl/x9ilM */ -/* Unicode Character Database property: Script (sc) */ -typedef enum -{ - /*1.1*/ HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'), - /*1.1*/ HB_SCRIPT_INHERITED = HB_TAG ('Z','i','n','h'), - /*5.0*/ HB_SCRIPT_UNKNOWN = HB_TAG ('Z','z','z','z'), - - /*1.1*/ HB_SCRIPT_ARABIC = HB_TAG ('A','r','a','b'), - /*1.1*/ HB_SCRIPT_ARMENIAN = HB_TAG ('A','r','m','n'), - /*1.1*/ HB_SCRIPT_BENGALI = HB_TAG ('B','e','n','g'), - /*1.1*/ HB_SCRIPT_CYRILLIC = HB_TAG ('C','y','r','l'), - /*1.1*/ HB_SCRIPT_DEVANAGARI = HB_TAG ('D','e','v','a'), - /*1.1*/ HB_SCRIPT_GEORGIAN = HB_TAG ('G','e','o','r'), - /*1.1*/ HB_SCRIPT_GREEK = HB_TAG ('G','r','e','k'), - /*1.1*/ HB_SCRIPT_GUJARATI = HB_TAG ('G','u','j','r'), - /*1.1*/ HB_SCRIPT_GURMUKHI = HB_TAG ('G','u','r','u'), - /*1.1*/ HB_SCRIPT_HANGUL = HB_TAG ('H','a','n','g'), - /*1.1*/ HB_SCRIPT_HAN = HB_TAG ('H','a','n','i'), - /*1.1*/ HB_SCRIPT_HEBREW = HB_TAG ('H','e','b','r'), - /*1.1*/ HB_SCRIPT_HIRAGANA = HB_TAG ('H','i','r','a'), - /*1.1*/ HB_SCRIPT_KANNADA = HB_TAG ('K','n','d','a'), - /*1.1*/ HB_SCRIPT_KATAKANA = HB_TAG ('K','a','n','a'), - /*1.1*/ HB_SCRIPT_LAO = HB_TAG ('L','a','o','o'), - /*1.1*/ HB_SCRIPT_LATIN = HB_TAG ('L','a','t','n'), - /*1.1*/ HB_SCRIPT_MALAYALAM = HB_TAG ('M','l','y','m'), - /*1.1*/ HB_SCRIPT_ORIYA = HB_TAG ('O','r','y','a'), - /*1.1*/ HB_SCRIPT_TAMIL = HB_TAG ('T','a','m','l'), - /*1.1*/ HB_SCRIPT_TELUGU = HB_TAG ('T','e','l','u'), - /*1.1*/ HB_SCRIPT_THAI = HB_TAG ('T','h','a','i'), - - /*2.0*/ HB_SCRIPT_TIBETAN = HB_TAG ('T','i','b','t'), - - /*3.0*/ HB_SCRIPT_BOPOMOFO = HB_TAG ('B','o','p','o'), - /*3.0*/ HB_SCRIPT_BRAILLE = HB_TAG ('B','r','a','i'), - /*3.0*/ HB_SCRIPT_CANADIAN_SYLLABICS = HB_TAG ('C','a','n','s'), - /*3.0*/ HB_SCRIPT_CHEROKEE = HB_TAG ('C','h','e','r'), - /*3.0*/ HB_SCRIPT_ETHIOPIC = HB_TAG ('E','t','h','i'), - /*3.0*/ HB_SCRIPT_KHMER = HB_TAG ('K','h','m','r'), - /*3.0*/ HB_SCRIPT_MONGOLIAN = HB_TAG ('M','o','n','g'), - /*3.0*/ HB_SCRIPT_MYANMAR = HB_TAG ('M','y','m','r'), - /*3.0*/ HB_SCRIPT_OGHAM = HB_TAG ('O','g','a','m'), - /*3.0*/ HB_SCRIPT_RUNIC = HB_TAG ('R','u','n','r'), - /*3.0*/ HB_SCRIPT_SINHALA = HB_TAG ('S','i','n','h'), - /*3.0*/ HB_SCRIPT_SYRIAC = HB_TAG ('S','y','r','c'), - /*3.0*/ HB_SCRIPT_THAANA = HB_TAG ('T','h','a','a'), - /*3.0*/ HB_SCRIPT_YI = HB_TAG ('Y','i','i','i'), - - /*3.1*/ HB_SCRIPT_DESERET = HB_TAG ('D','s','r','t'), - /*3.1*/ HB_SCRIPT_GOTHIC = HB_TAG ('G','o','t','h'), - /*3.1*/ HB_SCRIPT_OLD_ITALIC = HB_TAG ('I','t','a','l'), - - /*3.2*/ HB_SCRIPT_BUHID = HB_TAG ('B','u','h','d'), - /*3.2*/ HB_SCRIPT_HANUNOO = HB_TAG ('H','a','n','o'), - /*3.2*/ HB_SCRIPT_TAGALOG = HB_TAG ('T','g','l','g'), - /*3.2*/ HB_SCRIPT_TAGBANWA = HB_TAG ('T','a','g','b'), - - /*4.0*/ HB_SCRIPT_CYPRIOT = HB_TAG ('C','p','r','t'), - /*4.0*/ HB_SCRIPT_LIMBU = HB_TAG ('L','i','m','b'), - /*4.0*/ HB_SCRIPT_LINEAR_B = HB_TAG ('L','i','n','b'), - /*4.0*/ HB_SCRIPT_OSMANYA = HB_TAG ('O','s','m','a'), - /*4.0*/ HB_SCRIPT_SHAVIAN = HB_TAG ('S','h','a','w'), - /*4.0*/ HB_SCRIPT_TAI_LE = HB_TAG ('T','a','l','e'), - /*4.0*/ HB_SCRIPT_UGARITIC = HB_TAG ('U','g','a','r'), - - /*4.1*/ HB_SCRIPT_BUGINESE = HB_TAG ('B','u','g','i'), - /*4.1*/ HB_SCRIPT_COPTIC = HB_TAG ('C','o','p','t'), - /*4.1*/ HB_SCRIPT_GLAGOLITIC = HB_TAG ('G','l','a','g'), - /*4.1*/ HB_SCRIPT_KHAROSHTHI = HB_TAG ('K','h','a','r'), - /*4.1*/ HB_SCRIPT_NEW_TAI_LUE = HB_TAG ('T','a','l','u'), - /*4.1*/ HB_SCRIPT_OLD_PERSIAN = HB_TAG ('X','p','e','o'), - /*4.1*/ HB_SCRIPT_SYLOTI_NAGRI = HB_TAG ('S','y','l','o'), - /*4.1*/ HB_SCRIPT_TIFINAGH = HB_TAG ('T','f','n','g'), - - /*5.0*/ HB_SCRIPT_BALINESE = HB_TAG ('B','a','l','i'), - /*5.0*/ HB_SCRIPT_CUNEIFORM = HB_TAG ('X','s','u','x'), - /*5.0*/ HB_SCRIPT_NKO = HB_TAG ('N','k','o','o'), - /*5.0*/ HB_SCRIPT_PHAGS_PA = HB_TAG ('P','h','a','g'), - /*5.0*/ HB_SCRIPT_PHOENICIAN = HB_TAG ('P','h','n','x'), - - /*5.1*/ HB_SCRIPT_CARIAN = HB_TAG ('C','a','r','i'), - /*5.1*/ HB_SCRIPT_CHAM = HB_TAG ('C','h','a','m'), - /*5.1*/ HB_SCRIPT_KAYAH_LI = HB_TAG ('K','a','l','i'), - /*5.1*/ HB_SCRIPT_LEPCHA = HB_TAG ('L','e','p','c'), - /*5.1*/ HB_SCRIPT_LYCIAN = HB_TAG ('L','y','c','i'), - /*5.1*/ HB_SCRIPT_LYDIAN = HB_TAG ('L','y','d','i'), - /*5.1*/ HB_SCRIPT_OL_CHIKI = HB_TAG ('O','l','c','k'), - /*5.1*/ HB_SCRIPT_REJANG = HB_TAG ('R','j','n','g'), - /*5.1*/ HB_SCRIPT_SAURASHTRA = HB_TAG ('S','a','u','r'), - /*5.1*/ HB_SCRIPT_SUNDANESE = HB_TAG ('S','u','n','d'), - /*5.1*/ HB_SCRIPT_VAI = HB_TAG ('V','a','i','i'), - - /*5.2*/ HB_SCRIPT_AVESTAN = HB_TAG ('A','v','s','t'), - /*5.2*/ HB_SCRIPT_BAMUM = HB_TAG ('B','a','m','u'), - /*5.2*/ HB_SCRIPT_EGYPTIAN_HIEROGLYPHS = HB_TAG ('E','g','y','p'), - /*5.2*/ HB_SCRIPT_IMPERIAL_ARAMAIC = HB_TAG ('A','r','m','i'), - /*5.2*/ HB_SCRIPT_INSCRIPTIONAL_PAHLAVI = HB_TAG ('P','h','l','i'), - /*5.2*/ HB_SCRIPT_INSCRIPTIONAL_PARTHIAN = HB_TAG ('P','r','t','i'), - /*5.2*/ HB_SCRIPT_JAVANESE = HB_TAG ('J','a','v','a'), - /*5.2*/ HB_SCRIPT_KAITHI = HB_TAG ('K','t','h','i'), - /*5.2*/ HB_SCRIPT_LISU = HB_TAG ('L','i','s','u'), - /*5.2*/ HB_SCRIPT_MEETEI_MAYEK = HB_TAG ('M','t','e','i'), - /*5.2*/ HB_SCRIPT_OLD_SOUTH_ARABIAN = HB_TAG ('S','a','r','b'), - /*5.2*/ HB_SCRIPT_OLD_TURKIC = HB_TAG ('O','r','k','h'), - /*5.2*/ HB_SCRIPT_SAMARITAN = HB_TAG ('S','a','m','r'), - /*5.2*/ HB_SCRIPT_TAI_THAM = HB_TAG ('L','a','n','a'), - /*5.2*/ HB_SCRIPT_TAI_VIET = HB_TAG ('T','a','v','t'), - - /*6.0*/ HB_SCRIPT_BATAK = HB_TAG ('B','a','t','k'), - /*6.0*/ HB_SCRIPT_BRAHMI = HB_TAG ('B','r','a','h'), - /*6.0*/ HB_SCRIPT_MANDAIC = HB_TAG ('M','a','n','d'), - - /*6.1*/ HB_SCRIPT_CHAKMA = HB_TAG ('C','a','k','m'), - /*6.1*/ HB_SCRIPT_MEROITIC_CURSIVE = HB_TAG ('M','e','r','c'), - /*6.1*/ HB_SCRIPT_MEROITIC_HIEROGLYPHS = HB_TAG ('M','e','r','o'), - /*6.1*/ HB_SCRIPT_MIAO = HB_TAG ('P','l','r','d'), - /*6.1*/ HB_SCRIPT_SHARADA = HB_TAG ('S','h','r','d'), - /*6.1*/ HB_SCRIPT_SORA_SOMPENG = HB_TAG ('S','o','r','a'), - /*6.1*/ HB_SCRIPT_TAKRI = HB_TAG ('T','a','k','r'), - - /* - * Since: 0.9.30 - */ - /*7.0*/ HB_SCRIPT_BASSA_VAH = HB_TAG ('B','a','s','s'), - /*7.0*/ HB_SCRIPT_CAUCASIAN_ALBANIAN = HB_TAG ('A','g','h','b'), - /*7.0*/ HB_SCRIPT_DUPLOYAN = HB_TAG ('D','u','p','l'), - /*7.0*/ HB_SCRIPT_ELBASAN = HB_TAG ('E','l','b','a'), - /*7.0*/ HB_SCRIPT_GRANTHA = HB_TAG ('G','r','a','n'), - /*7.0*/ HB_SCRIPT_KHOJKI = HB_TAG ('K','h','o','j'), - /*7.0*/ HB_SCRIPT_KHUDAWADI = HB_TAG ('S','i','n','d'), - /*7.0*/ HB_SCRIPT_LINEAR_A = HB_TAG ('L','i','n','a'), - /*7.0*/ HB_SCRIPT_MAHAJANI = HB_TAG ('M','a','h','j'), - /*7.0*/ HB_SCRIPT_MANICHAEAN = HB_TAG ('M','a','n','i'), - /*7.0*/ HB_SCRIPT_MENDE_KIKAKUI = HB_TAG ('M','e','n','d'), - /*7.0*/ HB_SCRIPT_MODI = HB_TAG ('M','o','d','i'), - /*7.0*/ HB_SCRIPT_MRO = HB_TAG ('M','r','o','o'), - /*7.0*/ HB_SCRIPT_NABATAEAN = HB_TAG ('N','b','a','t'), - /*7.0*/ HB_SCRIPT_OLD_NORTH_ARABIAN = HB_TAG ('N','a','r','b'), - /*7.0*/ HB_SCRIPT_OLD_PERMIC = HB_TAG ('P','e','r','m'), - /*7.0*/ HB_SCRIPT_PAHAWH_HMONG = HB_TAG ('H','m','n','g'), - /*7.0*/ HB_SCRIPT_PALMYRENE = HB_TAG ('P','a','l','m'), - /*7.0*/ HB_SCRIPT_PAU_CIN_HAU = HB_TAG ('P','a','u','c'), - /*7.0*/ HB_SCRIPT_PSALTER_PAHLAVI = HB_TAG ('P','h','l','p'), - /*7.0*/ HB_SCRIPT_SIDDHAM = HB_TAG ('S','i','d','d'), - /*7.0*/ HB_SCRIPT_TIRHUTA = HB_TAG ('T','i','r','h'), - /*7.0*/ HB_SCRIPT_WARANG_CITI = HB_TAG ('W','a','r','a'), - - /*8.0*/ HB_SCRIPT_AHOM = HB_TAG ('A','h','o','m'), - /*8.0*/ HB_SCRIPT_ANATOLIAN_HIEROGLYPHS = HB_TAG ('H','l','u','w'), - /*8.0*/ HB_SCRIPT_HATRAN = HB_TAG ('H','a','t','r'), - /*8.0*/ HB_SCRIPT_MULTANI = HB_TAG ('M','u','l','t'), - /*8.0*/ HB_SCRIPT_OLD_HUNGARIAN = HB_TAG ('H','u','n','g'), - /*8.0*/ HB_SCRIPT_SIGNWRITING = HB_TAG ('S','g','n','w'), - - /* No script set. */ - HB_SCRIPT_INVALID = HB_TAG_NONE, - - /* Dummy values to ensure any hb_tag_t value can be passed/stored as hb_script_t - * without risking undefined behavior. Include both a signed and unsigned max, - * since technically enums are int, and indeed, hb_script_t ends up being signed. - * See this thread for technicalities: - * - * http://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html - */ - _HB_SCRIPT_MAX_VALUE = HB_TAG_MAX, /*< skip >*/ - _HB_SCRIPT_MAX_VALUE_SIGNED = HB_TAG_MAX_SIGNED /*< skip >*/ - -} hb_script_t; - - -/* Script functions */ - -hb_script_t -hb_script_from_iso15924_tag (hb_tag_t tag); - -/* sugar for tag_from_string() then script_from_iso15924_tag */ -/* len=-1 means s is NUL-terminated */ -hb_script_t -hb_script_from_string (const char *s, int len); - -hb_tag_t -hb_script_to_iso15924_tag (hb_script_t script); - -hb_direction_t -hb_script_get_horizontal_direction (hb_script_t script); - - -/* User data */ - -typedef struct hb_user_data_key_t { - /*< private >*/ - char unused; -} hb_user_data_key_t; - -typedef void (*hb_destroy_func_t) (void *user_data); - - -HB_END_DECLS - -#endif /* HB_COMMON_H */ diff --git a/third_party/harfbuzz-ng/src/hb-coretext.cc b/third_party/harfbuzz-ng/src/hb-coretext.cc deleted file mode 100644 index 13ba5d94ef1d..000000000000 --- a/third_party/harfbuzz-ng/src/hb-coretext.cc +++ /dev/null @@ -1,1219 +0,0 @@ -/* - * Copyright © 2012,2013 Mozilla Foundation. - * Copyright © 2012,2013 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Mozilla Author(s): Jonathan Kew - * Google Author(s): Behdad Esfahbod - */ - -#define HB_SHAPER coretext -#define hb_coretext_shaper_face_data_t CGFont -#include "hb-shaper-impl-private.hh" - -#include "hb-coretext.h" - - -#ifndef HB_DEBUG_CORETEXT -#define HB_DEBUG_CORETEXT (HB_DEBUG+0) -#endif - - -static void -release_table_data (void *user_data) -{ - CFDataRef cf_data = reinterpret_cast (user_data); - CFRelease(cf_data); -} - -static hb_blob_t * -reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) -{ - CGFontRef cg_font = reinterpret_cast (user_data); - CFDataRef cf_data = CGFontCopyTableForTag (cg_font, tag); - if (unlikely (!cf_data)) - return NULL; - - const char *data = reinterpret_cast (CFDataGetBytePtr (cf_data)); - const size_t length = CFDataGetLength (cf_data); - if (!data || !length) - return NULL; - - return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY, - reinterpret_cast (const_cast<__CFData *> (cf_data)), - release_table_data); -} - -hb_face_t * -hb_coretext_face_create (CGFontRef cg_font) -{ - return hb_face_create_for_tables (reference_table, CGFontRetain (cg_font), (hb_destroy_func_t) CGFontRelease); -} - - -HB_SHAPER_DATA_ENSURE_DECLARE(coretext, face) -HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font) - - -/* - * shaper face data - */ - -static void -release_data (void *info, const void *data, size_t size) -{ - assert (hb_blob_get_length ((hb_blob_t *) info) == size && - hb_blob_get_data ((hb_blob_t *) info, NULL) == data); - - hb_blob_destroy ((hb_blob_t *) info); -} - -hb_coretext_shaper_face_data_t * -_hb_coretext_shaper_face_data_create (hb_face_t *face) -{ - hb_coretext_shaper_face_data_t *data = NULL; - - if (face->destroy == (hb_destroy_func_t) CGFontRelease) - { - data = CGFontRetain ((CGFontRef) face->user_data); - } - else - { - hb_blob_t *blob = hb_face_reference_blob (face); - unsigned int blob_length; - const char *blob_data = hb_blob_get_data (blob, &blob_length); - if (unlikely (!blob_length)) - DEBUG_MSG (CORETEXT, face, "Face has empty blob"); - - CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data); - if (likely (provider)) - { - data = CGFontCreateWithDataProvider (provider); - CGDataProviderRelease (provider); - } - } - - if (unlikely (!data)) { - DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed"); - } - - return data; -} - -void -_hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data) -{ - CFRelease (data); -} - -/* - * Since: 0.9.10 - */ -CGFontRef -hb_coretext_face_get_cg_font (hb_face_t *face) -{ - if (unlikely (!hb_coretext_shaper_face_data_ensure (face))) return NULL; - hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - return face_data; -} - - -/* - * shaper font data - */ - -struct hb_coretext_shaper_font_data_t { - CTFontRef ct_font; - CGFloat x_mult, y_mult; /* From CT space to HB space. */ -}; - -hb_coretext_shaper_font_data_t * -_hb_coretext_shaper_font_data_create (hb_font_t *font) -{ - if (unlikely (!hb_coretext_shaper_face_data_ensure (font->face))) return NULL; - - hb_coretext_shaper_font_data_t *data = (hb_coretext_shaper_font_data_t *) calloc (1, sizeof (hb_coretext_shaper_font_data_t)); - if (unlikely (!data)) - return NULL; - - hb_face_t *face = font->face; - hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - - /* Choose a CoreText font size and calculate multipliers to convert to HarfBuzz space. */ - /* TODO: use upem instead of 36? */ - CGFloat font_size = 36.; /* Default... */ - /* No idea if the following is even a good idea. */ - if (font->y_ppem) - font_size = font->y_ppem; - - if (font_size < 0) - font_size = -font_size; - data->x_mult = (CGFloat) font->x_scale / font_size; - data->y_mult = (CGFloat) font->y_scale / font_size; - data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL); - if (unlikely (!data->ct_font)) { - DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed"); - free (data); - return NULL; - } - - return data; -} - -void -_hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data) -{ - CFRelease (data->ct_font); - free (data); -} - - -/* - * shaper shape_plan data - */ - -struct hb_coretext_shaper_shape_plan_data_t {}; - -hb_coretext_shaper_shape_plan_data_t * -_hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, - const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) -{ - return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; -} - -void -_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_t *data HB_UNUSED) -{ -} - -CTFontRef -hb_coretext_font_get_ct_font (hb_font_t *font) -{ - if (unlikely (!hb_coretext_shaper_font_data_ensure (font))) return NULL; - hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); - return font_data->ct_font; -} - - -/* - * shaper - */ - -struct feature_record_t { - unsigned int feature; - unsigned int setting; -}; - -struct active_feature_t { - feature_record_t rec; - unsigned int order; - - static int cmp (const active_feature_t *a, const active_feature_t *b) { - return a->rec.feature < b->rec.feature ? -1 : a->rec.feature > b->rec.feature ? 1 : - a->order < b->order ? -1 : a->order > b->order ? 1 : - a->rec.setting < b->rec.setting ? -1 : a->rec.setting > b->rec.setting ? 1 : - 0; - } - bool operator== (const active_feature_t *f) { - return cmp (this, f) == 0; - } -}; - -struct feature_event_t { - unsigned int index; - bool start; - active_feature_t feature; - - static int cmp (const feature_event_t *a, const feature_event_t *b) { - return a->index < b->index ? -1 : a->index > b->index ? 1 : - a->start < b->start ? -1 : a->start > b->start ? 1 : - active_feature_t::cmp (&a->feature, &b->feature); - } -}; - -struct range_record_t { - CTFontRef font; - unsigned int index_first; /* == start */ - unsigned int index_last; /* == end - 1 */ -}; - - -/* The following enum members are added in OS X 10.8. */ -#define kAltHalfWidthTextSelector 6 -#define kAltProportionalTextSelector 5 -#define kAlternateHorizKanaOffSelector 1 -#define kAlternateHorizKanaOnSelector 0 -#define kAlternateKanaType 34 -#define kAlternateVertKanaOffSelector 3 -#define kAlternateVertKanaOnSelector 2 -#define kCaseSensitiveLayoutOffSelector 1 -#define kCaseSensitiveLayoutOnSelector 0 -#define kCaseSensitiveLayoutType 33 -#define kCaseSensitiveSpacingOffSelector 3 -#define kCaseSensitiveSpacingOnSelector 2 -#define kContextualAlternatesOffSelector 1 -#define kContextualAlternatesOnSelector 0 -#define kContextualAlternatesType 36 -#define kContextualLigaturesOffSelector 19 -#define kContextualLigaturesOnSelector 18 -#define kContextualSwashAlternatesOffSelector 5 -#define kContextualSwashAlternatesOnSelector 4 -#define kDefaultLowerCaseSelector 0 -#define kDefaultUpperCaseSelector 0 -#define kHistoricalLigaturesOffSelector 21 -#define kHistoricalLigaturesOnSelector 20 -#define kHojoCharactersSelector 12 -#define kJIS2004CharactersSelector 11 -#define kLowerCasePetiteCapsSelector 2 -#define kLowerCaseSmallCapsSelector 1 -#define kLowerCaseType 37 -#define kMathematicalGreekOffSelector 11 -#define kMathematicalGreekOnSelector 10 -#define kNLCCharactersSelector 13 -#define kQuarterWidthTextSelector 4 -#define kScientificInferiorsSelector 4 -#define kStylisticAltEightOffSelector 17 -#define kStylisticAltEightOnSelector 16 -#define kStylisticAltEighteenOffSelector 37 -#define kStylisticAltEighteenOnSelector 36 -#define kStylisticAltElevenOffSelector 23 -#define kStylisticAltElevenOnSelector 22 -#define kStylisticAltFifteenOffSelector 31 -#define kStylisticAltFifteenOnSelector 30 -#define kStylisticAltFiveOffSelector 11 -#define kStylisticAltFiveOnSelector 10 -#define kStylisticAltFourOffSelector 9 -#define kStylisticAltFourOnSelector 8 -#define kStylisticAltFourteenOffSelector 29 -#define kStylisticAltFourteenOnSelector 28 -#define kStylisticAltNineOffSelector 19 -#define kStylisticAltNineOnSelector 18 -#define kStylisticAltNineteenOffSelector 39 -#define kStylisticAltNineteenOnSelector 38 -#define kStylisticAltOneOffSelector 3 -#define kStylisticAltOneOnSelector 2 -#define kStylisticAltSevenOffSelector 15 -#define kStylisticAltSevenOnSelector 14 -#define kStylisticAltSeventeenOffSelector 35 -#define kStylisticAltSeventeenOnSelector 34 -#define kStylisticAltSixOffSelector 13 -#define kStylisticAltSixOnSelector 12 -#define kStylisticAltSixteenOffSelector 33 -#define kStylisticAltSixteenOnSelector 32 -#define kStylisticAltTenOffSelector 21 -#define kStylisticAltTenOnSelector 20 -#define kStylisticAltThirteenOffSelector 27 -#define kStylisticAltThirteenOnSelector 26 -#define kStylisticAltThreeOffSelector 7 -#define kStylisticAltThreeOnSelector 6 -#define kStylisticAltTwelveOffSelector 25 -#define kStylisticAltTwelveOnSelector 24 -#define kStylisticAltTwentyOffSelector 41 -#define kStylisticAltTwentyOnSelector 40 -#define kStylisticAltTwoOffSelector 5 -#define kStylisticAltTwoOnSelector 4 -#define kStylisticAlternativesType 35 -#define kSwashAlternatesOffSelector 3 -#define kSwashAlternatesOnSelector 2 -#define kThirdWidthTextSelector 3 -#define kTraditionalNamesCharactersSelector 14 -#define kUpperCasePetiteCapsSelector 2 -#define kUpperCaseSmallCapsSelector 1 -#define kUpperCaseType 38 - -/* Table data courtesy of Apple. */ -static const struct feature_mapping_t { - FourCharCode otFeatureTag; - uint16_t aatFeatureType; - uint16_t selectorToEnable; - uint16_t selectorToDisable; -} feature_mappings[] = { - { 'c2pc', kUpperCaseType, kUpperCasePetiteCapsSelector, kDefaultUpperCaseSelector }, - { 'c2sc', kUpperCaseType, kUpperCaseSmallCapsSelector, kDefaultUpperCaseSelector }, - { 'calt', kContextualAlternatesType, kContextualAlternatesOnSelector, kContextualAlternatesOffSelector }, - { 'case', kCaseSensitiveLayoutType, kCaseSensitiveLayoutOnSelector, kCaseSensitiveLayoutOffSelector }, - { 'clig', kLigaturesType, kContextualLigaturesOnSelector, kContextualLigaturesOffSelector }, - { 'cpsp', kCaseSensitiveLayoutType, kCaseSensitiveSpacingOnSelector, kCaseSensitiveSpacingOffSelector }, - { 'cswh', kContextualAlternatesType, kContextualSwashAlternatesOnSelector, kContextualSwashAlternatesOffSelector }, - { 'dlig', kLigaturesType, kRareLigaturesOnSelector, kRareLigaturesOffSelector }, - { 'expt', kCharacterShapeType, kExpertCharactersSelector, 16 }, - { 'frac', kFractionsType, kDiagonalFractionsSelector, kNoFractionsSelector }, - { 'fwid', kTextSpacingType, kMonospacedTextSelector, 7 }, - { 'halt', kTextSpacingType, kAltHalfWidthTextSelector, 7 }, - { 'hist', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector }, - { 'hkna', kAlternateKanaType, kAlternateHorizKanaOnSelector, kAlternateHorizKanaOffSelector, }, - { 'hlig', kLigaturesType, kHistoricalLigaturesOnSelector, kHistoricalLigaturesOffSelector }, - { 'hngl', kTransliterationType, kHanjaToHangulSelector, kNoTransliterationSelector }, - { 'hojo', kCharacterShapeType, kHojoCharactersSelector, 16 }, - { 'hwid', kTextSpacingType, kHalfWidthTextSelector, 7 }, - { 'ital', kItalicCJKRomanType, kCJKItalicRomanOnSelector, kCJKItalicRomanOffSelector }, - { 'jp04', kCharacterShapeType, kJIS2004CharactersSelector, 16 }, - { 'jp78', kCharacterShapeType, kJIS1978CharactersSelector, 16 }, - { 'jp83', kCharacterShapeType, kJIS1983CharactersSelector, 16 }, - { 'jp90', kCharacterShapeType, kJIS1990CharactersSelector, 16 }, - { 'liga', kLigaturesType, kCommonLigaturesOnSelector, kCommonLigaturesOffSelector }, - { 'lnum', kNumberCaseType, kUpperCaseNumbersSelector, 2 }, - { 'mgrk', kMathematicalExtrasType, kMathematicalGreekOnSelector, kMathematicalGreekOffSelector }, - { 'nlck', kCharacterShapeType, kNLCCharactersSelector, 16 }, - { 'onum', kNumberCaseType, kLowerCaseNumbersSelector, 2 }, - { 'ordn', kVerticalPositionType, kOrdinalsSelector, kNormalPositionSelector }, - { 'palt', kTextSpacingType, kAltProportionalTextSelector, 7 }, - { 'pcap', kLowerCaseType, kLowerCasePetiteCapsSelector, kDefaultLowerCaseSelector }, - { 'pkna', kTextSpacingType, kProportionalTextSelector, 7 }, - { 'pnum', kNumberSpacingType, kProportionalNumbersSelector, 4 }, - { 'pwid', kTextSpacingType, kProportionalTextSelector, 7 }, - { 'qwid', kTextSpacingType, kQuarterWidthTextSelector, 7 }, - { 'ruby', kRubyKanaType, kRubyKanaOnSelector, kRubyKanaOffSelector }, - { 'sinf', kVerticalPositionType, kScientificInferiorsSelector, kNormalPositionSelector }, - { 'smcp', kLowerCaseType, kLowerCaseSmallCapsSelector, kDefaultLowerCaseSelector }, - { 'smpl', kCharacterShapeType, kSimplifiedCharactersSelector, 16 }, - { 'ss01', kStylisticAlternativesType, kStylisticAltOneOnSelector, kStylisticAltOneOffSelector }, - { 'ss02', kStylisticAlternativesType, kStylisticAltTwoOnSelector, kStylisticAltTwoOffSelector }, - { 'ss03', kStylisticAlternativesType, kStylisticAltThreeOnSelector, kStylisticAltThreeOffSelector }, - { 'ss04', kStylisticAlternativesType, kStylisticAltFourOnSelector, kStylisticAltFourOffSelector }, - { 'ss05', kStylisticAlternativesType, kStylisticAltFiveOnSelector, kStylisticAltFiveOffSelector }, - { 'ss06', kStylisticAlternativesType, kStylisticAltSixOnSelector, kStylisticAltSixOffSelector }, - { 'ss07', kStylisticAlternativesType, kStylisticAltSevenOnSelector, kStylisticAltSevenOffSelector }, - { 'ss08', kStylisticAlternativesType, kStylisticAltEightOnSelector, kStylisticAltEightOffSelector }, - { 'ss09', kStylisticAlternativesType, kStylisticAltNineOnSelector, kStylisticAltNineOffSelector }, - { 'ss10', kStylisticAlternativesType, kStylisticAltTenOnSelector, kStylisticAltTenOffSelector }, - { 'ss11', kStylisticAlternativesType, kStylisticAltElevenOnSelector, kStylisticAltElevenOffSelector }, - { 'ss12', kStylisticAlternativesType, kStylisticAltTwelveOnSelector, kStylisticAltTwelveOffSelector }, - { 'ss13', kStylisticAlternativesType, kStylisticAltThirteenOnSelector, kStylisticAltThirteenOffSelector }, - { 'ss14', kStylisticAlternativesType, kStylisticAltFourteenOnSelector, kStylisticAltFourteenOffSelector }, - { 'ss15', kStylisticAlternativesType, kStylisticAltFifteenOnSelector, kStylisticAltFifteenOffSelector }, - { 'ss16', kStylisticAlternativesType, kStylisticAltSixteenOnSelector, kStylisticAltSixteenOffSelector }, - { 'ss17', kStylisticAlternativesType, kStylisticAltSeventeenOnSelector, kStylisticAltSeventeenOffSelector }, - { 'ss18', kStylisticAlternativesType, kStylisticAltEighteenOnSelector, kStylisticAltEighteenOffSelector }, - { 'ss19', kStylisticAlternativesType, kStylisticAltNineteenOnSelector, kStylisticAltNineteenOffSelector }, - { 'ss20', kStylisticAlternativesType, kStylisticAltTwentyOnSelector, kStylisticAltTwentyOffSelector }, - { 'subs', kVerticalPositionType, kInferiorsSelector, kNormalPositionSelector }, - { 'sups', kVerticalPositionType, kSuperiorsSelector, kNormalPositionSelector }, - { 'swsh', kContextualAlternatesType, kSwashAlternatesOnSelector, kSwashAlternatesOffSelector }, - { 'titl', kStyleOptionsType, kTitlingCapsSelector, kNoStyleOptionsSelector }, - { 'tnam', kCharacterShapeType, kTraditionalNamesCharactersSelector, 16 }, - { 'tnum', kNumberSpacingType, kMonospacedNumbersSelector, 4 }, - { 'trad', kCharacterShapeType, kTraditionalCharactersSelector, 16 }, - { 'twid', kTextSpacingType, kThirdWidthTextSelector, 7 }, - { 'unic', kLetterCaseType, 14, 15 }, - { 'valt', kTextSpacingType, kAltProportionalTextSelector, 7 }, - { 'vert', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector }, - { 'vhal', kTextSpacingType, kAltHalfWidthTextSelector, 7 }, - { 'vkna', kAlternateKanaType, kAlternateVertKanaOnSelector, kAlternateVertKanaOffSelector }, - { 'vpal', kTextSpacingType, kAltProportionalTextSelector, 7 }, - { 'vrt2', kVerticalSubstitutionType, kSubstituteVerticalFormsOnSelector, kSubstituteVerticalFormsOffSelector }, - { 'zero', kTypographicExtrasType, kSlashedZeroOnSelector, kSlashedZeroOffSelector }, -}; - -static int -_hb_feature_mapping_cmp (const void *key_, const void *entry_) -{ - unsigned int key = * (unsigned int *) key_; - const feature_mapping_t * entry = (const feature_mapping_t *) entry_; - return key < entry->otFeatureTag ? -1 : - key > entry->otFeatureTag ? 1 : - 0; -} - -hb_bool_t -_hb_coretext_shape (hb_shape_plan_t *shape_plan, - hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features, - unsigned int num_features) -{ - hb_face_t *face = font->face; - hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); - - /* Attach marks to their bases, to match the 'ot' shaper. - * Adapted from hb-ot-shape:hb_form_clusters(). - * Note that this only makes us be closer to the 'ot' shaper, - * but by no means the same. For example, if there's - * B1 M1 B2 M2, and B1-B2 form a ligature, M2's cluster will - * continue pointing to B2 even though B2 was merged into B1's - * cluster... */ - { - hb_unicode_funcs_t *unicode = buffer->unicode; - unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; - for (unsigned int i = 1; i < count; i++) - if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (unicode->general_category (info[i].codepoint))) - buffer->merge_clusters (i - 1, i + 1); - } - - hb_auto_array_t feature_records; - hb_auto_array_t range_records; - - /* - * Set up features. - * (copied + modified from code from hb-uniscribe.cc) - */ - if (num_features) - { - /* Sort features by start/end events. */ - hb_auto_array_t feature_events; - for (unsigned int i = 0; i < num_features; i++) - { - const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag, - feature_mappings, - ARRAY_LENGTH (feature_mappings), - sizeof (feature_mappings[0]), - _hb_feature_mapping_cmp); - if (!mapping) - continue; - - active_feature_t feature; - feature.rec.feature = mapping->aatFeatureType; - feature.rec.setting = features[i].value ? mapping->selectorToEnable : mapping->selectorToDisable; - feature.order = i; - - feature_event_t *event; - - event = feature_events.push (); - if (unlikely (!event)) - goto fail_features; - event->index = features[i].start; - event->start = true; - event->feature = feature; - - event = feature_events.push (); - if (unlikely (!event)) - goto fail_features; - event->index = features[i].end; - event->start = false; - event->feature = feature; - } - feature_events.qsort (); - /* Add a strategic final event. */ - { - active_feature_t feature; - feature.rec.feature = HB_TAG_NONE; - feature.rec.setting = 0; - feature.order = num_features + 1; - - feature_event_t *event = feature_events.push (); - if (unlikely (!event)) - goto fail_features; - event->index = 0; /* This value does magic. */ - event->start = false; - event->feature = feature; - } - - /* Scan events and save features for each range. */ - hb_auto_array_t active_features; - unsigned int last_index = 0; - for (unsigned int i = 0; i < feature_events.len; i++) - { - feature_event_t *event = &feature_events[i]; - - if (event->index != last_index) - { - /* Save a snapshot of active features and the range. */ - range_record_t *range = range_records.push (); - if (unlikely (!range)) - goto fail_features; - - if (active_features.len) - { - CFMutableArrayRef features_array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - - /* TODO sort and resolve conflicting features? */ - /* active_features.qsort (); */ - for (unsigned int j = 0; j < active_features.len; j++) - { - CFStringRef keys[2] = { - kCTFontFeatureTypeIdentifierKey, - kCTFontFeatureSelectorIdentifierKey - }; - CFNumberRef values[2] = { - CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature), - CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting) - }; - CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault, - (const void **) keys, - (const void **) values, - 2, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFRelease (values[0]); - CFRelease (values[1]); - - CFArrayAppendValue (features_array, dict); - CFRelease (dict); - - } - - CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault, - (const void **) &kCTFontFeatureSettingsAttribute, - (const void **) &features_array, - 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFRelease (features_array); - - CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes); - CFRelease (attributes); - - range->font = CTFontCreateCopyWithAttributes (font_data->ct_font, 0.0, NULL, font_desc); - CFRelease (font_desc); - } - else - { - range->font = NULL; - } - - range->index_first = last_index; - range->index_last = event->index - 1; - - last_index = event->index; - } - - if (event->start) { - active_feature_t *feature = active_features.push (); - if (unlikely (!feature)) - goto fail_features; - *feature = event->feature; - } else { - active_feature_t *feature = active_features.find (&event->feature); - if (feature) - active_features.remove (feature - active_features.array); - } - } - - if (!range_records.len) /* No active feature found. */ - goto fail_features; - } - else - { - fail_features: - num_features = 0; - } - - unsigned int scratch_size; - hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size); - -#define ALLOCATE_ARRAY(Type, name, len, on_no_room) \ - Type *name = (Type *) scratch; \ - { \ - unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \ - if (unlikely (_consumed > scratch_size)) \ - { \ - on_no_room; \ - assert (0); \ - } \ - scratch += _consumed; \ - scratch_size -= _consumed; \ - } - - ALLOCATE_ARRAY (UniChar, pchars, buffer->len * 2, /*nothing*/); - unsigned int chars_len = 0; - for (unsigned int i = 0; i < buffer->len; i++) { - hb_codepoint_t c = buffer->info[i].codepoint; - if (likely (c <= 0xFFFFu)) - pchars[chars_len++] = c; - else if (unlikely (c > 0x10FFFFu)) - pchars[chars_len++] = 0xFFFDu; - else { - pchars[chars_len++] = 0xD800u + ((c - 0x10000u) >> 10); - pchars[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1 << 10) - 1)); - } - } - - ALLOCATE_ARRAY (unsigned int, log_clusters, chars_len, /*nothing*/); - chars_len = 0; - for (unsigned int i = 0; i < buffer->len; i++) - { - hb_codepoint_t c = buffer->info[i].codepoint; - unsigned int cluster = buffer->info[i].cluster; - log_clusters[chars_len++] = cluster; - if (hb_in_range (c, 0x10000u, 0x10FFFFu)) - log_clusters[chars_len++] = cluster; /* Surrogates. */ - } - -#define FAIL(...) \ - HB_STMT_START { \ - DEBUG_MSG (CORETEXT, NULL, __VA_ARGS__); \ - ret = false; \ - goto fail; \ - } HB_STMT_END; - - bool ret = true; - CFStringRef string_ref = NULL; - CTLineRef line = NULL; - - if (0) - { -resize_and_retry: - DEBUG_MSG (CORETEXT, buffer, "Buffer resize"); - /* string_ref uses the scratch-buffer for backing store, and line references - * string_ref (via attr_string). We must release those before resizing buffer. */ - assert (string_ref); - assert (line); - CFRelease (string_ref); - CFRelease (line); - string_ref = NULL; - line = NULL; - - /* Get previous start-of-scratch-area, that we use later for readjusting - * our existing scratch arrays. */ - unsigned int old_scratch_used; - hb_buffer_t::scratch_buffer_t *old_scratch; - old_scratch = buffer->get_scratch_buffer (&old_scratch_used); - old_scratch_used = scratch - old_scratch; - - if (unlikely (!buffer->ensure (buffer->allocated * 2))) - FAIL ("Buffer resize failed"); - - /* Adjust scratch, pchars, and log_cluster arrays. This is ugly, but really the - * cleanest way to do without completely restructuring the rest of this shaper. */ - scratch = buffer->get_scratch_buffer (&scratch_size); - pchars = reinterpret_cast (((char *) scratch + ((char *) pchars - (char *) old_scratch))); - log_clusters = reinterpret_cast (((char *) scratch + ((char *) log_clusters - (char *) old_scratch))); - scratch += old_scratch_used; - scratch_size -= old_scratch_used; - } -retry: - { - string_ref = CFStringCreateWithCharactersNoCopy (NULL, - pchars, chars_len, - kCFAllocatorNull); - if (unlikely (!string_ref)) - FAIL ("CFStringCreateWithCharactersNoCopy failed"); - - /* Create an attributed string, populate it, and create a line from it, then release attributed string. */ - { - CFMutableAttributedStringRef attr_string = CFAttributedStringCreateMutable (kCFAllocatorDefault, - chars_len); - if (unlikely (!attr_string)) - FAIL ("CFAttributedStringCreateMutable failed"); - CFAttributedStringReplaceString (attr_string, CFRangeMake (0, 0), string_ref); - if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction)) - { - CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), - kCTVerticalFormsAttributeName, kCFBooleanTrue); - } - - if (buffer->props.language) - { -/* What's the iOS equivalent of this check? - * The symbols was introduced in iOS 7.0. - * At any rate, our fallback is safe and works fine. */ -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 -# define kCTLanguageAttributeName CFSTR ("NSLanguage") -#endif - CFStringRef lang = CFStringCreateWithCStringNoCopy (kCFAllocatorDefault, - hb_language_to_string (buffer->props.language), - kCFStringEncodingUTF8, - kCFAllocatorNull); - if (unlikely (!lang)) - FAIL ("CFStringCreateWithCStringNoCopy failed"); - CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), - kCTLanguageAttributeName, lang); - CFRelease (lang); - } - CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len), - kCTFontAttributeName, font_data->ct_font); - - if (num_features) - { - unsigned int start = 0; - range_record_t *last_range = &range_records[0]; - for (unsigned int k = 0; k < chars_len; k++) - { - range_record_t *range = last_range; - while (log_clusters[k] < range->index_first) - range--; - while (log_clusters[k] > range->index_last) - range++; - if (range != last_range) - { - if (last_range->font) - CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, k - start), - kCTFontAttributeName, last_range->font); - - start = k; - } - - last_range = range; - } - if (start != chars_len && last_range->font) - CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start), - kCTFontAttributeName, last_range->font); - } - - int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1; - CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level); - CFDictionaryRef options = CFDictionaryCreate (kCFAllocatorDefault, - (const void **) &kCTTypesetterOptionForcedEmbeddingLevel, - (const void **) &level_number, - 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - if (unlikely (!options)) - FAIL ("CFDictionaryCreate failed"); - - CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedStringAndOptions (attr_string, options); - CFRelease (options); - CFRelease (attr_string); - if (unlikely (!typesetter)) - FAIL ("CTTypesetterCreateWithAttributedStringAndOptions failed"); - - line = CTTypesetterCreateLine (typesetter, CFRangeMake(0, 0)); - CFRelease (typesetter); - if (unlikely (!line)) - FAIL ("CTTypesetterCreateLine failed"); - } - - CFArrayRef glyph_runs = CTLineGetGlyphRuns (line); - unsigned int num_runs = CFArrayGetCount (glyph_runs); - DEBUG_MSG (CORETEXT, NULL, "Num runs: %d", num_runs); - - buffer->len = 0; - uint32_t status_and = ~0, status_or = 0; - double advances_so_far = 0; - /* For right-to-left runs, CoreText returns the glyphs positioned such that - * any trailing whitespace is to the left of (0,0). Adjust coordinate system - * to fix for that. Test with any RTL string with trailing spaces. - * https://code.google.com/p/chromium/issues/detail?id=469028 - */ - if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) - { - advances_so_far -= CTLineGetTrailingWhitespaceWidth (line); - if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction)) - advances_so_far = -advances_so_far; - } - - const CFRange range_all = CFRangeMake (0, 0); - - for (unsigned int i = 0; i < num_runs; i++) - { - CTRunRef run = static_cast(CFArrayGetValueAtIndex (glyph_runs, i)); - CTRunStatus run_status = CTRunGetStatus (run); - status_or |= run_status; - status_and &= run_status; - DEBUG_MSG (CORETEXT, run, "CTRunStatus: %x", run_status); - double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL); - if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction)) - run_advance = -run_advance; - DEBUG_MSG (CORETEXT, run, "Run advance: %g", run_advance); - - /* CoreText does automatic font fallback (AKA "cascading") for characters - * not supported by the requested font, and provides no way to turn it off, - * so we must detect if the returned run uses a font other than the requested - * one and fill in the buffer with .notdef glyphs instead of random glyph - * indices from a different font. - */ - CFDictionaryRef attributes = CTRunGetAttributes (run); - CTFontRef run_ct_font = static_cast(CFDictionaryGetValue (attributes, kCTFontAttributeName)); - if (!CFEqual (run_ct_font, font_data->ct_font)) - { - /* The run doesn't use our main font instance. We have to figure out - * whether font fallback happened, or this is just CoreText giving us - * another CTFont using the same underlying CGFont. CoreText seems - * to do that in a variety of situations, one of which being vertical - * text, but also perhaps for caching reasons. - * - * First, see if it uses any of our subfonts created to set font features... - * - * Next, compare the CGFont to the one we used to create our fonts. - * Even this doesn't work all the time. - * - * Finally, we compare PS names, which I don't think are unique... - * - * Looks like if we really want to be sure here we have to modify the - * font to change the name table, similar to what we do in the uniscribe - * backend. - * - * However, even that wouldn't work if we were passed in the CGFont to - * begin with. - * - * Webkit uses a slightly different approach: it installs LastResort - * as fallback chain, and then checks PS name of used font against - * LastResort. That one is safe for any font except for LastResort, - * as opposed to ours, which can fail if we are using any uninstalled - * font that has the same name as an installed font. - * - * See: http://github.com/behdad/harfbuzz/pull/36 - */ - bool matched = false; - for (unsigned int i = 0; i < range_records.len; i++) - if (range_records[i].font && CFEqual (run_ct_font, range_records[i].font)) - { - matched = true; - break; - } - if (!matched) - { - CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0); - if (run_cg_font) - { - matched = CFEqual (run_cg_font, face_data); - CFRelease (run_cg_font); - } - } - if (!matched) - { - CFStringRef font_ps_name = CTFontCopyName (font_data->ct_font, kCTFontPostScriptNameKey); - CFStringRef run_ps_name = CTFontCopyName (run_ct_font, kCTFontPostScriptNameKey); - CFComparisonResult result = CFStringCompare (run_ps_name, font_ps_name, 0); - CFRelease (run_ps_name); - CFRelease (font_ps_name); - if (result == kCFCompareEqualTo) - matched = true; - } - if (!matched) - { - CFRange range = CTRunGetStringRange (run); - DEBUG_MSG (CORETEXT, run, "Run used fallback font: %ld..%ld", - range.location, range.location + range.length); - if (!buffer->ensure_inplace (buffer->len + range.length)) - goto resize_and_retry; - hb_glyph_info_t *info = buffer->info + buffer->len; - - hb_codepoint_t notdef = 0; - hb_direction_t dir = buffer->props.direction; - hb_position_t x_advance, y_advance, x_offset, y_offset; - hb_font_get_glyph_advance_for_direction (font, notdef, dir, &x_advance, &y_advance); - hb_font_get_glyph_origin_for_direction (font, notdef, dir, &x_offset, &y_offset); - hb_position_t advance = x_advance + y_advance; - x_offset = -x_offset; - y_offset = -y_offset; - - unsigned int old_len = buffer->len; - for (CFIndex j = range.location; j < range.location + range.length; j++) - { - UniChar ch = CFStringGetCharacterAtIndex (string_ref, j); - if (hb_in_range (ch, 0xDC00u, 0xDFFFu) && range.location < j) - { - ch = CFStringGetCharacterAtIndex (string_ref, j - 1); - if (hb_in_range (ch, 0xD800u, 0xDBFFu)) - /* This is the second of a surrogate pair. Don't need .notdef - * for this one. */ - continue; - } - if (buffer->unicode->is_default_ignorable (ch)) - continue; - - info->codepoint = notdef; - info->cluster = log_clusters[j]; - - info->mask = advance; - info->var1.i32 = x_offset; - info->var2.i32 = y_offset; - - info++; - buffer->len++; - } - if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) - buffer->reverse_range (old_len, buffer->len); - advances_so_far += run_advance; - continue; - } - } - - unsigned int num_glyphs = CTRunGetGlyphCount (run); - if (num_glyphs == 0) - continue; - - if (!buffer->ensure_inplace (buffer->len + num_glyphs)) - goto resize_and_retry; - - hb_glyph_info_t *run_info = buffer->info + buffer->len; - - /* Testing used to indicate that CTRunGetGlyphsPtr, etc (almost?) always - * succeed, and so copying data to our own buffer will be rare. Reports - * have it that this changed in OS X 10.10 Yosemite, and NULL is returned - * frequently. At any rate, we can test that codepath by setting USE_PTR - * to false. */ - -#define USE_PTR true - -#define SCRATCH_SAVE() \ - unsigned int scratch_size_saved = scratch_size; \ - hb_buffer_t::scratch_buffer_t *scratch_saved = scratch - -#define SCRATCH_RESTORE() \ - scratch_size = scratch_size_saved; \ - scratch = scratch_saved; - - { /* Setup glyphs */ - SCRATCH_SAVE(); - const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : NULL; - if (!glyphs) { - ALLOCATE_ARRAY (CGGlyph, glyph_buf, num_glyphs, goto resize_and_retry); - CTRunGetGlyphs (run, range_all, glyph_buf); - glyphs = glyph_buf; - } - const CFIndex* string_indices = USE_PTR ? CTRunGetStringIndicesPtr (run) : NULL; - if (!string_indices) { - ALLOCATE_ARRAY (CFIndex, index_buf, num_glyphs, goto resize_and_retry); - CTRunGetStringIndices (run, range_all, index_buf); - string_indices = index_buf; - } - hb_glyph_info_t *info = run_info; - for (unsigned int j = 0; j < num_glyphs; j++) - { - info->codepoint = glyphs[j]; - info->cluster = log_clusters[string_indices[j]]; - info++; - } - SCRATCH_RESTORE(); - } - { - /* Setup positions. - * Note that CoreText does not return advances for glyphs. As such, - * for all but last glyph, we use the delta position to next glyph as - * advance (in the advance direction only), and for last glyph we set - * whatever is needed to make the whole run's advance add up. */ - SCRATCH_SAVE(); - const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : NULL; - if (!positions) { - ALLOCATE_ARRAY (CGPoint, position_buf, num_glyphs, goto resize_and_retry); - CTRunGetPositions (run, range_all, position_buf); - positions = position_buf; - } - hb_glyph_info_t *info = run_info; - CGFloat x_mult = font_data->x_mult, y_mult = font_data->y_mult; - if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) - { - hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult; - for (unsigned int j = 0; j < num_glyphs; j++) - { - double advance; - if (likely (j + 1 < num_glyphs)) - advance = positions[j + 1].x - positions[j].x; - else /* last glyph */ - advance = run_advance - (positions[j].x - positions[0].x); - info->mask = advance * x_mult; - info->var1.i32 = x_offset; - info->var2.i32 = positions[j].y * y_mult; - info++; - } - } - else - { - hb_position_t y_offset = (positions[0].y - advances_so_far) * y_mult; - for (unsigned int j = 0; j < num_glyphs; j++) - { - double advance; - if (likely (j + 1 < num_glyphs)) - advance = positions[j + 1].y - positions[j].y; - else /* last glyph */ - advance = run_advance - (positions[j].y - positions[0].y); - info->mask = advance * y_mult; - info->var1.i32 = positions[j].x * x_mult; - info->var2.i32 = y_offset; - info++; - } - } - SCRATCH_RESTORE(); - advances_so_far += run_advance; - } -#undef SCRATCH_RESTORE -#undef SCRATCH_SAVE -#undef USE_PTR -#undef ALLOCATE_ARRAY - - buffer->len += num_glyphs; - } - - /* Mac OS 10.6 doesn't have kCTTypesetterOptionForcedEmbeddingLevel, - * or if it does, it doesn't resepct it. So we get runs with wrong - * directions. As such, disable the assert... It wouldn't crash, but - * cursoring will be off... - * - * http://crbug.com/419769 - */ - if (0) - { - /* Make sure all runs had the expected direction. */ - bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); - assert (bool (status_and & kCTRunStatusRightToLeft) == backward); - assert (bool (status_or & kCTRunStatusRightToLeft) == backward); - } - - buffer->clear_positions (); - - unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; - hb_glyph_position_t *pos = buffer->pos; - if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) - for (unsigned int i = 0; i < count; i++) - { - pos->x_advance = info->mask; - pos->x_offset = info->var1.i32; - pos->y_offset = info->var2.i32; - info++, pos++; - } - else - for (unsigned int i = 0; i < count; i++) - { - pos->y_advance = info->mask; - pos->x_offset = info->var1.i32; - pos->y_offset = info->var2.i32; - info++, pos++; - } - - /* Fix up clusters so that we never return out-of-order indices; - * if core text has reordered glyphs, we'll merge them to the - * beginning of the reordered cluster. CoreText is nice enough - * to tell us whenever it has produced nonmonotonic results... - * Note that we assume the input clusters were nonmonotonic to - * begin with. - * - * This does *not* mean we'll form the same clusters as Uniscribe - * or the native OT backend, only that the cluster indices will be - * monotonic in the output buffer. */ - if (count > 1 && (status_or & kCTRunStatusNonMonotonic)) - { - hb_glyph_info_t *info = buffer->info; - if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) - { - unsigned int cluster = info[count - 1].cluster; - for (unsigned int i = count - 1; i > 0; i--) - { - cluster = MIN (cluster, info[i - 1].cluster); - info[i - 1].cluster = cluster; - } - } - else - { - unsigned int cluster = info[0].cluster; - for (unsigned int i = 1; i < count; i++) - { - cluster = MIN (cluster, info[i].cluster); - info[i].cluster = cluster; - } - } - } - } - -#undef FAIL - -fail: - if (string_ref) - CFRelease (string_ref); - if (line) - CFRelease (line); - - for (unsigned int i = 0; i < range_records.len; i++) - if (range_records[i].font) - CFRelease (range_records[i].font); - - return ret; -} - - -/* - * AAT shaper - */ - -HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, face) -HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, font) - - -/* - * shaper face data - */ - -struct hb_coretext_aat_shaper_face_data_t {}; - -hb_coretext_aat_shaper_face_data_t * -_hb_coretext_aat_shaper_face_data_create (hb_face_t *face) -{ - hb_blob_t *mort_blob = face->reference_table (HB_CORETEXT_TAG_MORT); - /* Umm, we just reference the table to check whether it exists. - * Maybe add better API for this? */ - if (!hb_blob_get_length (mort_blob)) - { - hb_blob_destroy (mort_blob); - mort_blob = face->reference_table (HB_CORETEXT_TAG_MORX); - if (!hb_blob_get_length (mort_blob)) - { - hb_blob_destroy (mort_blob); - return NULL; - } - } - hb_blob_destroy (mort_blob); - - return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : NULL; -} - -void -_hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_shaper_face_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper font data - */ - -struct hb_coretext_aat_shaper_font_data_t {}; - -hb_coretext_aat_shaper_font_data_t * -_hb_coretext_aat_shaper_font_data_create (hb_font_t *font) -{ - return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : NULL; -} - -void -_hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_shaper_font_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper shape_plan data - */ - -struct hb_coretext_aat_shaper_shape_plan_data_t {}; - -hb_coretext_aat_shaper_shape_plan_data_t * -_hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, - const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) -{ - return (hb_coretext_aat_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; -} - -void -_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shaper_shape_plan_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper - */ - -hb_bool_t -_hb_coretext_aat_shape (hb_shape_plan_t *shape_plan, - hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features, - unsigned int num_features) -{ - return _hb_coretext_shape (shape_plan, font, buffer, features, num_features); -} diff --git a/third_party/harfbuzz-ng/src/hb-coretext.h b/third_party/harfbuzz-ng/src/hb-coretext.h deleted file mode 100644 index 25267bc9784a..000000000000 --- a/third_party/harfbuzz-ng/src/hb-coretext.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2012 Mozilla Foundation. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Mozilla Author(s): Jonathan Kew - */ - -#ifndef HB_CORETEXT_H -#define HB_CORETEXT_H - -#include "hb.h" - -#include -#if TARGET_OS_IPHONE -# include -# include -#else -# include -#endif - -HB_BEGIN_DECLS - - -#define HB_CORETEXT_TAG_MORT HB_TAG('m','o','r','t') -#define HB_CORETEXT_TAG_MORX HB_TAG('m','o','r','x') - - -hb_face_t * -hb_coretext_face_create (CGFontRef cg_font); - - -CGFontRef -hb_coretext_face_get_cg_font (hb_face_t *face); - -CTFontRef -hb_coretext_font_get_ct_font (hb_font_t *font); - - -HB_END_DECLS - -#endif /* HB_CORETEXT_H */ diff --git a/third_party/harfbuzz-ng/src/hb-deprecated.h b/third_party/harfbuzz-ng/src/hb-deprecated.h deleted file mode 100644 index 30ae4b1caf76..000000000000 --- a/third_party/harfbuzz-ng/src/hb-deprecated.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2013 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_H_IN -#error "Include instead." -#endif - -#ifndef HB_DEPRECATED_H -#define HB_DEPRECATED_H - -#include "hb-common.h" -#include "hb-unicode.h" -#include "hb-font.h" - -HB_BEGIN_DECLS - -#ifndef HB_DISABLE_DEPRECATED - -#define HB_SCRIPT_CANADIAN_ABORIGINAL HB_SCRIPT_CANADIAN_SYLLABICS - -#define HB_BUFFER_FLAGS_DEFAULT HB_BUFFER_FLAG_DEFAULT -#define HB_BUFFER_SERIALIZE_FLAGS_DEFAULT HB_BUFFER_SERIALIZE_FLAG_DEFAULT - -#endif - -HB_END_DECLS - -#endif /* HB_DEPRECATED_H */ diff --git a/third_party/harfbuzz-ng/src/hb-face-private.hh b/third_party/harfbuzz-ng/src/hb-face-private.hh deleted file mode 100644 index c4266fff4f02..000000000000 --- a/third_party/harfbuzz-ng/src/hb-face-private.hh +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_FACE_PRIVATE_HH -#define HB_FACE_PRIVATE_HH - -#include "hb-private.hh" - -#include "hb-object-private.hh" -#include "hb-shaper-private.hh" -#include "hb-shape-plan-private.hh" - - -/* - * hb_face_t - */ - -struct hb_face_t { - hb_object_header_t header; - ASSERT_POD (); - - hb_bool_t immutable; - - hb_reference_table_func_t reference_table_func; - void *user_data; - hb_destroy_func_t destroy; - - unsigned int index; - mutable unsigned int upem; - mutable unsigned int num_glyphs; - - struct hb_shaper_data_t shaper_data; - - struct plan_node_t { - hb_shape_plan_t *shape_plan; - plan_node_t *next; - } *shape_plans; - - - inline hb_blob_t *reference_table (hb_tag_t tag) const - { - hb_blob_t *blob; - - if (unlikely (!reference_table_func)) - return hb_blob_get_empty (); - - blob = reference_table_func (/*XXX*/const_cast (this), tag, user_data); - if (unlikely (!blob)) - return hb_blob_get_empty (); - - return blob; - } - - inline HB_PURE_FUNC unsigned int get_upem (void) const - { - if (unlikely (!upem)) - load_upem (); - return upem; - } - - inline unsigned int get_num_glyphs (void) const - { - if (unlikely (num_glyphs == (unsigned int) -1)) - load_num_glyphs (); - return num_glyphs; - } - - private: - HB_INTERNAL void load_upem (void) const; - HB_INTERNAL void load_num_glyphs (void) const; -}; - -extern HB_INTERNAL const hb_face_t _hb_face_nil; - -#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face); -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT -#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS - - -#endif /* HB_FACE_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-face.cc b/third_party/harfbuzz-ng/src/hb-face.cc deleted file mode 100644 index 79dfb000057b..000000000000 --- a/third_party/harfbuzz-ng/src/hb-face.cc +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -#include "hb-ot-layout-private.hh" - -#include "hb-font-private.hh" -#include "hb-open-file-private.hh" -#include "hb-ot-head-table.hh" -#include "hb-ot-maxp-table.hh" - -#include "hb-cache-private.hh" - -#if !defined(STARBOARD) -#include -#endif - - -/* - * hb_face_t - */ - -const hb_face_t _hb_face_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - NULL, /* reference_table_func */ - NULL, /* user_data */ - NULL, /* destroy */ - - 0, /* index */ - 1000, /* upem */ - 0, /* num_glyphs */ - - { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - }, - - NULL, /* shape_plans */ -}; - - -/** - * hb_face_create_for_tables: - * @reference_table_func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Return value: (transfer full) - * - * Since: 0.9.2 - **/ -hb_face_t * -hb_face_create_for_tables (hb_reference_table_func_t reference_table_func, - void *user_data, - hb_destroy_func_t destroy) -{ - hb_face_t *face; - - if (!reference_table_func || !(face = hb_object_create ())) { - if (destroy) - destroy (user_data); - return hb_face_get_empty (); - } - - face->reference_table_func = reference_table_func; - face->user_data = user_data; - face->destroy = destroy; - - face->upem = 0; - face->num_glyphs = (unsigned int) -1; - - return face; -} - - -typedef struct hb_face_for_data_closure_t { - hb_blob_t *blob; - unsigned int index; -} hb_face_for_data_closure_t; - -static hb_face_for_data_closure_t * -_hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index) -{ - hb_face_for_data_closure_t *closure; - - closure = (hb_face_for_data_closure_t *) calloc (1, sizeof (hb_face_for_data_closure_t)); - if (unlikely (!closure)) - return NULL; - - closure->blob = blob; - closure->index = index; - - return closure; -} - -static void -_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure) -{ - hb_blob_destroy (closure->blob); - free (closure); -} - -static hb_blob_t * -_hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) -{ - hb_face_for_data_closure_t *data = (hb_face_for_data_closure_t *) user_data; - - if (tag == HB_TAG_NONE) - return hb_blob_reference (data->blob); - - const OT::OpenTypeFontFile &ot_file = *OT::Sanitizer::lock_instance (data->blob); - const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index); - - const OT::OpenTypeTable &table = ot_face.get_table_by_tag (tag); - - hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.length); - - return blob; -} - -/** - * hb_face_create: (Xconstructor) - * @blob: - * @index: - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_face_t * -hb_face_create (hb_blob_t *blob, - unsigned int index) -{ - hb_face_t *face; - - if (unlikely (!blob)) - blob = hb_blob_get_empty (); - - hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sanitizer::sanitize (hb_blob_reference (blob)), index); - - if (unlikely (!closure)) - return hb_face_get_empty (); - - face = hb_face_create_for_tables (_hb_face_for_data_reference_table, - closure, - (hb_destroy_func_t) _hb_face_for_data_closure_destroy); - - hb_face_set_index (face, index); - - return face; -} - -/** - * hb_face_get_empty: - * - * - * - * Return value: (transfer full) - * - * Since: 0.9.2 - **/ -hb_face_t * -hb_face_get_empty (void) -{ - return const_cast (&_hb_face_nil); -} - - -/** - * hb_face_reference: (skip) - * @face: a face. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_face_t * -hb_face_reference (hb_face_t *face) -{ - return hb_object_reference (face); -} - -/** - * hb_face_destroy: (skip) - * @face: a face. - * - * - * - * Since: 0.9.2 - **/ -void -hb_face_destroy (hb_face_t *face) -{ - if (!hb_object_destroy (face)) return; - - for (hb_face_t::plan_node_t *node = face->shape_plans; node; ) - { - hb_face_t::plan_node_t *next = node->next; - hb_shape_plan_destroy (node->shape_plan); - free (node); - node = next; - } - -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face); -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - - if (face->destroy) - face->destroy (face->user_data); - - free (face); -} - -/** - * hb_face_set_user_data: (skip) - * @face: a face. - * @key: - * @data: - * @destroy: - * @replace: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_face_set_user_data (hb_face_t *face, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - return hb_object_set_user_data (face, key, data, destroy, replace); -} - -/** - * hb_face_get_user_data: (skip) - * @face: a face. - * @key: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -void * -hb_face_get_user_data (hb_face_t *face, - hb_user_data_key_t *key) -{ - return hb_object_get_user_data (face, key); -} - -/** - * hb_face_make_immutable: - * @face: a face. - * - * - * - * Since: 0.9.2 - **/ -void -hb_face_make_immutable (hb_face_t *face) -{ - if (unlikely (hb_object_is_inert (face))) - return; - - face->immutable = true; -} - -/** - * hb_face_is_immutable: - * @face: a face. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_face_is_immutable (hb_face_t *face) -{ - return face->immutable; -} - - -/** - * hb_face_reference_table: - * @face: a face. - * @tag: - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_blob_t * -hb_face_reference_table (hb_face_t *face, - hb_tag_t tag) -{ - return face->reference_table (tag); -} - -/** - * hb_face_reference_blob: - * @face: a face. - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_blob_t * -hb_face_reference_blob (hb_face_t *face) -{ - return face->reference_table (HB_TAG_NONE); -} - -/** - * hb_face_set_index: - * @face: a face. - * @index: - * - * - * - * Since: 0.9.2 - **/ -void -hb_face_set_index (hb_face_t *face, - unsigned int index) -{ - if (face->immutable) - return; - - face->index = index; -} - -/** - * hb_face_get_index: - * @face: a face. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -unsigned int -hb_face_get_index (hb_face_t *face) -{ - return face->index; -} - -/** - * hb_face_set_upem: - * @face: a face. - * @upem: - * - * - * - * Since: 0.9.2 - **/ -void -hb_face_set_upem (hb_face_t *face, - unsigned int upem) -{ - if (face->immutable) - return; - - face->upem = upem; -} - -/** - * hb_face_get_upem: - * @face: a face. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -unsigned int -hb_face_get_upem (hb_face_t *face) -{ - return face->get_upem (); -} - -void -hb_face_t::load_upem (void) const -{ - hb_blob_t *head_blob = OT::Sanitizer::sanitize (reference_table (HB_OT_TAG_head)); - const OT::head *head_table = OT::Sanitizer::lock_instance (head_blob); - upem = head_table->get_upem (); - hb_blob_destroy (head_blob); -} - -/** - * hb_face_set_glyph_count: - * @face: a face. - * @glyph_count: - * - * - * - * Since: 0.9.7 - **/ -void -hb_face_set_glyph_count (hb_face_t *face, - unsigned int glyph_count) -{ - if (face->immutable) - return; - - face->num_glyphs = glyph_count; -} - -/** - * hb_face_get_glyph_count: - * @face: a face. - * - * - * - * Return value: - * - * Since: 0.9.7 - **/ -unsigned int -hb_face_get_glyph_count (hb_face_t *face) -{ - return face->get_num_glyphs (); -} - -void -hb_face_t::load_num_glyphs (void) const -{ - hb_blob_t *maxp_blob = OT::Sanitizer::sanitize (reference_table (HB_OT_TAG_maxp)); - const OT::maxp *maxp_table = OT::Sanitizer::lock_instance (maxp_blob); - num_glyphs = maxp_table->get_num_glyphs (); - hb_blob_destroy (maxp_blob); -} - - diff --git a/third_party/harfbuzz-ng/src/hb-face.h b/third_party/harfbuzz-ng/src/hb-face.h deleted file mode 100644 index f682c468de58..000000000000 --- a/third_party/harfbuzz-ng/src/hb-face.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - */ - -#ifndef HB_H_IN -#error "Include instead." -#endif - -#ifndef HB_FACE_H -#define HB_FACE_H - -#include "hb-common.h" -#include "hb-blob.h" - -HB_BEGIN_DECLS - - -/* - * hb_face_t - */ - -typedef struct hb_face_t hb_face_t; - -hb_face_t * -hb_face_create (hb_blob_t *blob, - unsigned int index); - -typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag, void *user_data); - -/* calls destroy() when not needing user_data anymore */ -hb_face_t * -hb_face_create_for_tables (hb_reference_table_func_t reference_table_func, - void *user_data, - hb_destroy_func_t destroy); - -hb_face_t * -hb_face_get_empty (void); - -hb_face_t * -hb_face_reference (hb_face_t *face); - -void -hb_face_destroy (hb_face_t *face); - -hb_bool_t -hb_face_set_user_data (hb_face_t *face, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - - -void * -hb_face_get_user_data (hb_face_t *face, - hb_user_data_key_t *key); - -void -hb_face_make_immutable (hb_face_t *face); - -hb_bool_t -hb_face_is_immutable (hb_face_t *face); - - -hb_blob_t * -hb_face_reference_table (hb_face_t *face, - hb_tag_t tag); - -hb_blob_t * -hb_face_reference_blob (hb_face_t *face); - -void -hb_face_set_index (hb_face_t *face, - unsigned int index); - -unsigned int -hb_face_get_index (hb_face_t *face); - -void -hb_face_set_upem (hb_face_t *face, - unsigned int upem); - -unsigned int -hb_face_get_upem (hb_face_t *face); - -void -hb_face_set_glyph_count (hb_face_t *face, - unsigned int glyph_count); - -unsigned int -hb_face_get_glyph_count (hb_face_t *face); - - -HB_END_DECLS - -#endif /* HB_FACE_H */ diff --git a/third_party/harfbuzz-ng/src/hb-fallback-shape.cc b/third_party/harfbuzz-ng/src/hb-fallback-shape.cc deleted file mode 100644 index 9d061a9e8459..000000000000 --- a/third_party/harfbuzz-ng/src/hb-fallback-shape.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#define HB_SHAPER fallback -#include "hb-shaper-impl-private.hh" - - -/* - * shaper face data - */ - -struct hb_fallback_shaper_face_data_t {}; - -hb_fallback_shaper_face_data_t * -_hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED) -{ - return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; -} - -void -_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper font data - */ - -struct hb_fallback_shaper_font_data_t {}; - -hb_fallback_shaper_font_data_t * -_hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED) -{ - return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; -} - -void -_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper shape_plan data - */ - -struct hb_fallback_shaper_shape_plan_data_t {}; - -hb_fallback_shaper_shape_plan_data_t * -_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, - const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) -{ - return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; -} - -void -_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper - */ - -hb_bool_t -_hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, - hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features HB_UNUSED, - unsigned int num_features HB_UNUSED) -{ - /* TODO - * - * - Apply fallback kern. - * - Handle Variation Selectors? - * - Apply normalization? - * - * This will make the fallback shaper into a dumb "TrueType" - * shaper which many people unfortunately still request. - */ - - hb_codepoint_t space; - bool has_space = font->get_glyph (' ', 0, &space); - - buffer->clear_positions (); - - hb_direction_t direction = buffer->props.direction; - hb_unicode_funcs_t *unicode = buffer->unicode; - unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; - hb_glyph_position_t *pos = buffer->pos; - for (unsigned int i = 0; i < count; i++) - { - if (has_space && unicode->is_default_ignorable (info[i].codepoint)) { - info[i].codepoint = space; - pos[i].x_advance = 0; - pos[i].y_advance = 0; - continue; - } - font->get_glyph (info[i].codepoint, 0, &info[i].codepoint); - font->get_glyph_advance_for_direction (info[i].codepoint, - direction, - &pos[i].x_advance, - &pos[i].y_advance); - font->subtract_glyph_origin_for_direction (info[i].codepoint, - direction, - &pos[i].x_offset, - &pos[i].y_offset); - } - - if (HB_DIRECTION_IS_BACKWARD (direction)) - hb_buffer_reverse (buffer); - - return true; -} diff --git a/third_party/harfbuzz-ng/src/hb-font-private.hh b/third_party/harfbuzz-ng/src/hb-font-private.hh deleted file mode 100644 index 9ee9e5405576..000000000000 --- a/third_party/harfbuzz-ng/src/hb-font-private.hh +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_FONT_PRIVATE_HH -#define HB_FONT_PRIVATE_HH - -#include "hb-private.hh" - -#include "hb-object-private.hh" -#include "hb-face-private.hh" -#include "hb-shaper-private.hh" - - - -/* - * hb_font_funcs_t - */ - -#define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ - HB_FONT_FUNC_IMPLEMENT (glyph) \ - HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ - HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ - HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ - HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ - HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ - HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \ - HB_FONT_FUNC_IMPLEMENT (glyph_extents) \ - HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \ - HB_FONT_FUNC_IMPLEMENT (glyph_name) \ - HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ - /* ^--- Add new callbacks here */ - -struct hb_font_funcs_t { - hb_object_header_t header; - ASSERT_POD (); - - hb_bool_t immutable; - - struct { -#define HB_FONT_FUNC_IMPLEMENT(name) void *name; - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } user_data; - - struct { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name; - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } destroy; - - /* Don't access these directly. Call font->get_*() instead. */ - union get_t { - struct get_funcs_t { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name; - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } f; - void (*array[VAR]) (void); - } get; -}; - - - -/* - * hb_font_t - */ - -struct hb_font_t { - hb_object_header_t header; - ASSERT_POD (); - - hb_bool_t immutable; - - hb_font_t *parent; - hb_face_t *face; - - int x_scale; - int y_scale; - - unsigned int x_ppem; - unsigned int y_ppem; - - hb_font_funcs_t *klass; - void *user_data; - hb_destroy_func_t destroy; - - struct hb_shaper_data_t shaper_data; - - - /* Convert from font-space to user-space */ - inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); } - inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); } - - /* Convert from parent-font user-space to our user-space */ - inline hb_position_t parent_scale_x_distance (hb_position_t v) { - if (unlikely (parent && parent->x_scale != x_scale)) - return (hb_position_t) (v * (int64_t) this->x_scale / this->parent->x_scale); - return v; - } - inline hb_position_t parent_scale_y_distance (hb_position_t v) { - if (unlikely (parent && parent->y_scale != y_scale)) - return (hb_position_t) (v * (int64_t) this->y_scale / this->parent->y_scale); - return v; - } - inline hb_position_t parent_scale_x_position (hb_position_t v) { - return parent_scale_x_distance (v); - } - inline hb_position_t parent_scale_y_position (hb_position_t v) { - return parent_scale_y_distance (v); - } - - inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) { - *x = parent_scale_x_distance (*x); - *y = parent_scale_y_distance (*y); - } - inline void parent_scale_position (hb_position_t *x, hb_position_t *y) { - *x = parent_scale_x_position (*x); - *y = parent_scale_y_position (*y); - } - - - /* Public getters */ - - HB_INTERNAL bool has_func (unsigned int i); - - /* has_* ... */ -#define HB_FONT_FUNC_IMPLEMENT(name) \ - bool \ - has_##name##_func (void) \ - { \ - hb_font_funcs_t *funcs = this->klass; \ - unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \ - return has_func (i); \ - } - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - - inline hb_bool_t has_glyph (hb_codepoint_t unicode) - { - hb_codepoint_t glyph; - return get_glyph (unicode, 0, &glyph); - } - - inline hb_bool_t get_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) - { - *glyph = 0; - return klass->get.f.glyph (this, user_data, - unicode, variation_selector, glyph, - klass->user_data.glyph); - } - - inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) - { - return klass->get.f.glyph_h_advance (this, user_data, - glyph, - klass->user_data.glyph_h_advance); - } - - inline hb_position_t get_glyph_v_advance (hb_codepoint_t glyph) - { - return klass->get.f.glyph_v_advance (this, user_data, - glyph, - klass->user_data.glyph_v_advance); - } - - inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - *x = *y = 0; - return klass->get.f.glyph_h_origin (this, user_data, - glyph, x, y, - klass->user_data.glyph_h_origin); - } - - inline hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - *x = *y = 0; - return klass->get.f.glyph_v_origin (this, user_data, - glyph, x, y, - klass->user_data.glyph_v_origin); - } - - inline hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) - { - return klass->get.f.glyph_h_kerning (this, user_data, - left_glyph, right_glyph, - klass->user_data.glyph_h_kerning); - } - - inline hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph) - { - return klass->get.f.glyph_v_kerning (this, user_data, - top_glyph, bottom_glyph, - klass->user_data.glyph_v_kerning); - } - - inline hb_bool_t get_glyph_extents (hb_codepoint_t glyph, - hb_glyph_extents_t *extents) - { - memset (extents, 0, sizeof (*extents)); - return klass->get.f.glyph_extents (this, user_data, - glyph, - extents, - klass->user_data.glyph_extents); - } - - inline hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index, - hb_position_t *x, hb_position_t *y) - { - *x = *y = 0; - return klass->get.f.glyph_contour_point (this, user_data, - glyph, point_index, - x, y, - klass->user_data.glyph_contour_point); - } - - inline hb_bool_t get_glyph_name (hb_codepoint_t glyph, - char *name, unsigned int size) - { - if (size) *name = '\0'; - return klass->get.f.glyph_name (this, user_data, - glyph, - name, size, - klass->user_data.glyph_name); - } - - inline hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) - { - *glyph = 0; - if (len == -1) len = strlen (name); - return klass->get.f.glyph_from_name (this, user_data, - name, len, - glyph, - klass->user_data.glyph_from_name); - } - - - /* A bit higher-level, and with fallback */ - - inline void get_glyph_advance_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { - *x = get_glyph_h_advance (glyph); - *y = 0; - } else { - *x = 0; - *y = get_glyph_v_advance (glyph); - } - } - - /* Internal only */ - inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - *x = get_glyph_h_advance (glyph) / 2; - - /* TODO use font_metrics.ascent */ - *y = y_scale; - } - - inline void get_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) - { - if (!get_glyph_h_origin (glyph, x, y) && - get_glyph_v_origin (glyph, x, y)) - { - hb_position_t dx, dy; - guess_v_origin_minus_h_origin (glyph, &dx, &dy); - *x -= dx; *y -= dy; - } - } - else - { - if (!get_glyph_v_origin (glyph, x, y) && - get_glyph_h_origin (glyph, x, y)) - { - hb_position_t dx, dy; - guess_v_origin_minus_h_origin (glyph, &dx, &dy); - *x += dx; *y += dy; - } - } - } - - inline void add_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_h_origin (glyph, &origin_x, &origin_y); - - *x += origin_x; - *y += origin_y; - } - inline void add_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_v_origin (glyph, &origin_x, &origin_y); - - *x += origin_x; - *y += origin_y; - } - inline void add_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); - - *x += origin_x; - *y += origin_y; - } - - inline void subtract_glyph_h_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_h_origin (glyph, &origin_x, &origin_y); - - *x -= origin_x; - *y -= origin_y; - } - inline void subtract_glyph_v_origin (hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_v_origin (glyph, &origin_x, &origin_y); - - *x -= origin_x; - *y -= origin_y; - } - inline void subtract_glyph_origin_for_direction (hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - hb_position_t origin_x, origin_y; - - get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y); - - *x -= origin_x; - *y -= origin_y; - } - - inline void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { - *x = get_glyph_h_kerning (first_glyph, second_glyph); - *y = 0; - } else { - *x = 0; - *y = get_glyph_v_kerning (first_glyph, second_glyph); - } - } - - inline hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph, - hb_direction_t direction, - hb_glyph_extents_t *extents) - { - hb_bool_t ret = get_glyph_extents (glyph, extents); - - if (ret) - subtract_glyph_origin_for_direction (glyph, direction, &extents->x_bearing, &extents->y_bearing); - - return ret; - } - - inline hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) - { - hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y); - - if (ret) - subtract_glyph_origin_for_direction (glyph, direction, x, y); - - return ret; - } - - /* Generates gidDDD if glyph has no name. */ - inline void - glyph_to_string (hb_codepoint_t glyph, - char *s, unsigned int size) - { - if (get_glyph_name (glyph, s, size)) return; - - if (size && snprintf (s, size, "gid%u", glyph) < 0) - *s = '\0'; - } - - /* Parses gidDDD and uniUUUU strings automatically. */ - inline hb_bool_t - glyph_from_string (const char *s, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) - { - if (get_glyph_from_name (s, len, glyph)) return true; - - if (len == -1) len = strlen (s); - - /* Straight glyph index. */ - if (hb_codepoint_parse (s, len, 10, glyph)) - return true; - - if (len > 3) - { - /* gidDDD syntax for glyph indices. */ - if (0 == strncmp (s, "gid", 3) && - hb_codepoint_parse (s + 3, len - 3, 10, glyph)) - return true; - - /* uniUUUU and other Unicode character indices. */ - hb_codepoint_t unichar; - if (0 == strncmp (s, "uni", 3) && - hb_codepoint_parse (s + 3, len - 3, 16, &unichar) && - get_glyph (unichar, 0, glyph)) - return true; - } - - return false; - } - - private: - inline hb_position_t em_scale (int16_t v, int scale) { return (hb_position_t) (v * (int64_t) scale / face->get_upem ()); } -}; - -#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT -#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS - - -#endif /* HB_FONT_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-font.cc b/third_party/harfbuzz-ng/src/hb-font.cc deleted file mode 100644 index 92aecf79bbf6..000000000000 --- a/third_party/harfbuzz-ng/src/hb-font.cc +++ /dev/null @@ -1,1376 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -#include "hb-ot-layout-private.hh" - -#include "hb-font-private.hh" -#include "hb-open-file-private.hh" -#include "hb-ot-head-table.hh" -#include "hb-ot-maxp-table.hh" - -#include "hb-cache-private.hh" - -#if !defined(STARBOARD) -#include -#endif - - -/* - * hb_font_funcs_t - */ - -static hb_bool_t -hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) -{ - *glyph = 0; - return false; -} -static hb_bool_t -hb_font_get_glyph_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) -{ - return font->parent->get_glyph (unicode, variation_selector, glyph); -} - -static hb_position_t -hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - return font->x_scale; -} -static hb_position_t -hb_font_get_glyph_h_advance_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph)); -} - -static hb_position_t -hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - return font->y_scale; -} -static hb_position_t -hb_font_get_glyph_v_advance_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph)); -} - -static hb_bool_t -hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - *x = *y = 0; - return false; -} -static hb_bool_t -hb_font_get_glyph_h_origin_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); - if (ret) - font->parent_scale_position (x, y); - return ret; -} - -static hb_bool_t -hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - *x = *y = 0; - return false; -} -static hb_bool_t -hb_font_get_glyph_v_origin_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); - if (ret) - font->parent_scale_position (x, y); - return ret; -} - -static hb_position_t -hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t left_glyph, - hb_codepoint_t right_glyph, - void *user_data HB_UNUSED) -{ - return 0; -} -static hb_position_t -hb_font_get_glyph_h_kerning_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t left_glyph, - hb_codepoint_t right_glyph, - void *user_data HB_UNUSED) -{ - return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph)); -} - -static hb_position_t -hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t top_glyph, - hb_codepoint_t bottom_glyph, - void *user_data HB_UNUSED) -{ - return 0; -} -static hb_position_t -hb_font_get_glyph_v_kerning_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t top_glyph, - hb_codepoint_t bottom_glyph, - void *user_data HB_UNUSED) -{ - return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph)); -} - -static hb_bool_t -hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data HB_UNUSED) -{ - memset (extents, 0, sizeof (*extents)); - return false; -} -static hb_bool_t -hb_font_get_glyph_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data HB_UNUSED) -{ - hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); - if (ret) { - font->parent_scale_position (&extents->x_bearing, &extents->y_bearing); - font->parent_scale_distance (&extents->width, &extents->height); - } - return ret; -} - -static hb_bool_t -hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - unsigned int point_index, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - *x = *y = 0; - return false; -} -static hb_bool_t -hb_font_get_glyph_contour_point_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - unsigned int point_index, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y); - if (ret) - font->parent_scale_position (x, y); - return ret; -} - -static hb_bool_t -hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - char *name, unsigned int size, - void *user_data HB_UNUSED) -{ - if (size) *name = '\0'; - return false; -} -static hb_bool_t -hb_font_get_glyph_name_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - char *name, unsigned int size, - void *user_data HB_UNUSED) -{ - return font->parent->get_glyph_name (glyph, name, size); -} - -static hb_bool_t -hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED, - void *font_data HB_UNUSED, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) -{ - *glyph = 0; - return false; -} -static hb_bool_t -hb_font_get_glyph_from_name_parent (hb_font_t *font, - void *font_data HB_UNUSED, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) -{ - return font->parent->get_glyph_from_name (name, len, glyph); -} - - -static const hb_font_funcs_t _hb_font_funcs_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - }, - { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - }, - { - { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } - } -}; -static const hb_font_funcs_t _hb_font_funcs_parent = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - }, - { -#define HB_FONT_FUNC_IMPLEMENT(name) NULL, - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - }, - { - { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent, - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - } - } -}; - - -/** - * hb_font_funcs_create: (Xconstructor) - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_font_funcs_t * -hb_font_funcs_create (void) -{ - hb_font_funcs_t *ffuncs; - - if (!(ffuncs = hb_object_create ())) - return hb_font_funcs_get_empty (); - - ffuncs->get = _hb_font_funcs_parent.get; - - return ffuncs; -} - -/** - * hb_font_funcs_get_empty: - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_font_funcs_t * -hb_font_funcs_get_empty (void) -{ - return const_cast (&_hb_font_funcs_parent); -} - -/** - * hb_font_funcs_reference: (skip) - * @ffuncs: font functions. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_font_funcs_t * -hb_font_funcs_reference (hb_font_funcs_t *ffuncs) -{ - return hb_object_reference (ffuncs); -} - -/** - * hb_font_funcs_destroy: (skip) - * @ffuncs: font functions. - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) -{ - if (!hb_object_destroy (ffuncs)) return; - -#define HB_FONT_FUNC_IMPLEMENT(name) if (ffuncs->destroy.name) \ - ffuncs->destroy.name (ffuncs->user_data.name); - HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - - free (ffuncs); -} - -/** - * hb_font_funcs_set_user_data: (skip) - * @ffuncs: font functions. - * @key: - * @data: - * @destroy: - * @replace: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - return hb_object_set_user_data (ffuncs, key, data, destroy, replace); -} - -/** - * hb_font_funcs_get_user_data: (skip) - * @ffuncs: font functions. - * @key: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -void * -hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, - hb_user_data_key_t *key) -{ - return hb_object_get_user_data (ffuncs, key); -} - - -/** - * hb_font_funcs_make_immutable: - * @ffuncs: font functions. - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) -{ - if (unlikely (hb_object_is_inert (ffuncs))) - return; - - ffuncs->immutable = true; -} - -/** - * hb_font_funcs_is_immutable: - * @ffuncs: font functions. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs) -{ - return ffuncs->immutable; -} - - -#define HB_FONT_FUNC_IMPLEMENT(name) \ - \ -void \ -hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ - hb_font_get_##name##_func_t func, \ - void *user_data, \ - hb_destroy_func_t destroy) \ -{ \ - if (ffuncs->immutable) { \ - if (destroy) \ - destroy (user_data); \ - return; \ - } \ - \ - if (ffuncs->destroy.name) \ - ffuncs->destroy.name (ffuncs->user_data.name); \ - \ - if (func) { \ - ffuncs->get.f.name = func; \ - ffuncs->user_data.name = user_data; \ - ffuncs->destroy.name = destroy; \ - } else { \ - ffuncs->get.f.name = hb_font_get_##name##_parent; \ - ffuncs->user_data.name = NULL; \ - ffuncs->destroy.name = NULL; \ - } \ -} - -HB_FONT_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_FONT_FUNC_IMPLEMENT - -bool -hb_font_t::has_func (unsigned int i) -{ - if (parent && parent != hb_font_get_empty () && parent->has_func (i)) - return true; - return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i]; -} - -/* Public getters */ - -/** - * hb_font_get_glyph: - * @font: a font. - * @unicode: - * @variation_selector: - * @glyph: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph (hb_font_t *font, - hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) -{ - return font->get_glyph (unicode, variation_selector, glyph); -} - -/** - * hb_font_get_glyph_h_advance: - * @font: a font. - * @glyph: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_position_t -hb_font_get_glyph_h_advance (hb_font_t *font, - hb_codepoint_t glyph) -{ - return font->get_glyph_h_advance (glyph); -} - -/** - * hb_font_get_glyph_v_advance: - * @font: a font. - * @glyph: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_position_t -hb_font_get_glyph_v_advance (hb_font_t *font, - hb_codepoint_t glyph) -{ - return font->get_glyph_v_advance (glyph); -} - -/** - * hb_font_get_glyph_h_origin: - * @font: a font. - * @glyph: - * @x: (out): - * @y: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_h_origin (hb_font_t *font, - hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_h_origin (glyph, x, y); -} - -/** - * hb_font_get_glyph_v_origin: - * @font: a font. - * @glyph: - * @x: (out): - * @y: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_v_origin (hb_font_t *font, - hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_v_origin (glyph, x, y); -} - -/** - * hb_font_get_glyph_h_kerning: - * @font: a font. - * @left_glyph: - * @right_glyph: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_position_t -hb_font_get_glyph_h_kerning (hb_font_t *font, - hb_codepoint_t left_glyph, hb_codepoint_t right_glyph) -{ - return font->get_glyph_h_kerning (left_glyph, right_glyph); -} - -/** - * hb_font_get_glyph_v_kerning: - * @font: a font. - * @top_glyph: - * @bottom_glyph: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_position_t -hb_font_get_glyph_v_kerning (hb_font_t *font, - hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph) -{ - return font->get_glyph_v_kerning (top_glyph, bottom_glyph); -} - -/** - * hb_font_get_glyph_extents: - * @font: a font. - * @glyph: - * @extents: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_extents (hb_font_t *font, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents) -{ - return font->get_glyph_extents (glyph, extents); -} - -/** - * hb_font_get_glyph_contour_point: - * @font: a font. - * @glyph: - * @point_index: - * @x: (out): - * @y: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_contour_point (hb_font_t *font, - hb_codepoint_t glyph, unsigned int point_index, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_contour_point (glyph, point_index, x, y); -} - -/** - * hb_font_get_glyph_name: - * @font: a font. - * @glyph: - * @name: (array length=size): - * @size: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_name (hb_font_t *font, - hb_codepoint_t glyph, - char *name, unsigned int size) -{ - return font->get_glyph_name (glyph, name, size); -} - -/** - * hb_font_get_glyph_from_name: - * @font: a font. - * @name: (array length=len): - * @len: - * @glyph: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_from_name (hb_font_t *font, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) -{ - return font->get_glyph_from_name (name, len, glyph); -} - - -/* A bit higher-level, and with fallback */ - -/** - * hb_font_get_glyph_advance_for_direction: - * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_get_glyph_advance_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_advance_for_direction (glyph, direction, x, y); -} - -/** - * hb_font_get_glyph_origin_for_direction: - * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_get_glyph_origin_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_origin_for_direction (glyph, direction, x, y); -} - -/** - * hb_font_add_glyph_origin_for_direction: - * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_add_glyph_origin_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) -{ - return font->add_glyph_origin_for_direction (glyph, direction, x, y); -} - -/** - * hb_font_subtract_glyph_origin_for_direction: - * @font: a font. - * @glyph: - * @direction: - * @x: (out): - * @y: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) -{ - return font->subtract_glyph_origin_for_direction (glyph, direction, x, y); -} - -/** - * hb_font_get_glyph_kerning_for_direction: - * @font: a font. - * @first_glyph: - * @second_glyph: - * @direction: - * @x: (out): - * @y: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_get_glyph_kerning_for_direction (hb_font_t *font, - hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y); -} - -/** - * hb_font_get_glyph_extents_for_origin: - * @font: a font. - * @glyph: - * @direction: - * @extents: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_extents_for_origin (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_glyph_extents_t *extents) -{ - return font->get_glyph_extents_for_origin (glyph, direction, extents); -} - -/** - * hb_font_get_glyph_contour_point_for_origin: - * @font: a font. - * @glyph: - * @point_index: - * @direction: - * @x: (out): - * @y: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, - hb_codepoint_t glyph, unsigned int point_index, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y) -{ - return font->get_glyph_contour_point_for_origin (glyph, point_index, direction, x, y); -} - -/* Generates gidDDD if glyph has no name. */ -/** - * hb_font_glyph_to_string: - * @font: a font. - * @glyph: - * @s: (array length=size): - * @size: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_glyph_to_string (hb_font_t *font, - hb_codepoint_t glyph, - char *s, unsigned int size) -{ - font->glyph_to_string (glyph, s, size); -} - -/* Parses gidDDD and uniUUUU strings automatically. */ -/** - * hb_font_glyph_from_string: - * @font: a font. - * @s: (array length=len) (element-type uint8_t): - * @len: - * @glyph: (out): - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_glyph_from_string (hb_font_t *font, - const char *s, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph) -{ - return font->glyph_from_string (s, len, glyph); -} - - -/* - * hb_font_t - */ - -/** - * hb_font_create: (Xconstructor) - * @face: a face. - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_font_t * -hb_font_create (hb_face_t *face) -{ - hb_font_t *font; - - if (unlikely (!face)) - face = hb_face_get_empty (); - if (!(font = hb_object_create ())) - return hb_font_get_empty (); - - hb_face_make_immutable (face); - font->parent = hb_font_get_empty (); - font->face = hb_face_reference (face); - font->klass = hb_font_funcs_get_empty (); - - font->x_scale = font->y_scale = hb_face_get_upem (face); - - return font; -} - -/** - * hb_font_create_sub_font: - * @parent: parent font. - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_font_t * -hb_font_create_sub_font (hb_font_t *parent) -{ - if (unlikely (!parent)) - parent = hb_font_get_empty (); - - hb_font_t *font = hb_font_create (parent->face); - - if (unlikely (hb_object_is_inert (font))) - return font; - - font->parent = hb_font_reference (parent); - - font->x_scale = parent->x_scale; - font->y_scale = parent->y_scale; - font->x_ppem = parent->x_ppem; - font->y_ppem = parent->y_ppem; - - return font; -} - -/** - * hb_font_get_empty: - * - * - * - * Return value: (transfer full) - * - * Since: 0.9.2 - **/ -hb_font_t * -hb_font_get_empty (void) -{ - static const hb_font_t _hb_font_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - NULL, /* parent */ - const_cast (&_hb_face_nil), - - 1000, /* x_scale */ - 1000, /* y_scale */ - - 0, /* x_ppem */ - 0, /* y_ppem */ - - const_cast (&_hb_font_funcs_nil), /* klass */ - NULL, /* user_data */ - NULL, /* destroy */ - - { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - } - }; - - return const_cast (&_hb_font_nil); -} - -/** - * hb_font_reference: (skip) - * @font: a font. - * - * - * - * Return value: (transfer full): - * - * Since: 0.9.2 - **/ -hb_font_t * -hb_font_reference (hb_font_t *font) -{ - return hb_object_reference (font); -} - -/** - * hb_font_destroy: (skip) - * @font: a font. - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_destroy (hb_font_t *font) -{ - if (!hb_object_destroy (font)) return; - -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font); -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - - if (font->destroy) - font->destroy (font->user_data); - - hb_font_destroy (font->parent); - hb_face_destroy (font->face); - hb_font_funcs_destroy (font->klass); - - free (font); -} - -/** - * hb_font_set_user_data: (skip) - * @font: a font. - * @key: - * @data: - * @destroy: - * @replace: - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_set_user_data (hb_font_t *font, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - return hb_object_set_user_data (font, key, data, destroy, replace); -} - -/** - * hb_font_get_user_data: (skip) - * @font: a font. - * @key: - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -void * -hb_font_get_user_data (hb_font_t *font, - hb_user_data_key_t *key) -{ - return hb_object_get_user_data (font, key); -} - -/** - * hb_font_make_immutable: - * @font: a font. - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_make_immutable (hb_font_t *font) -{ - if (unlikely (hb_object_is_inert (font))) - return; - - if (font->parent) - hb_font_make_immutable (font->parent); - - font->immutable = true; -} - -/** - * hb_font_is_immutable: - * @font: a font. - * - * - * - * Return value: - * - * Since: 0.9.2 - **/ -hb_bool_t -hb_font_is_immutable (hb_font_t *font) -{ - return font->immutable; -} - -/** - * hb_font_set_parent: - * @font: a font. - * @parent: new parent. - * - * Sets parent font of @font. - * - * Since: 1.0.5 - **/ -void -hb_font_set_parent (hb_font_t *font, - hb_font_t *parent) -{ - if (font->immutable) - return; - - if (!parent) - parent = hb_font_get_empty (); - - hb_font_t *old = font->parent; - - font->parent = hb_font_reference (parent); - - hb_font_destroy (old); -} - -/** - * hb_font_get_parent: - * @font: a font. - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -hb_font_t * -hb_font_get_parent (hb_font_t *font) -{ - return font->parent; -} - -/** - * hb_font_get_face: - * @font: a font. - * - * - * - * Return value: (transfer none): - * - * Since: 0.9.2 - **/ -hb_face_t * -hb_font_get_face (hb_font_t *font) -{ - return font->face; -} - - -/** - * hb_font_set_funcs: - * @font: a font. - * @klass: (closure font_data) (destroy destroy) (scope notified): - * @font_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_set_funcs (hb_font_t *font, - hb_font_funcs_t *klass, - void *font_data, - hb_destroy_func_t destroy) -{ - if (font->immutable) { - if (destroy) - destroy (font_data); - return; - } - - if (font->destroy) - font->destroy (font->user_data); - - if (!klass) - klass = hb_font_funcs_get_empty (); - - hb_font_funcs_reference (klass); - hb_font_funcs_destroy (font->klass); - font->klass = klass; - font->user_data = font_data; - font->destroy = destroy; -} - -/** - * hb_font_set_funcs_data: - * @font: a font. - * @font_data: (destroy destroy) (scope notified): - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_set_funcs_data (hb_font_t *font, - void *font_data, - hb_destroy_func_t destroy) -{ - /* Destroy user_data? */ - if (font->immutable) { - if (destroy) - destroy (font_data); - return; - } - - if (font->destroy) - font->destroy (font->user_data); - - font->user_data = font_data; - font->destroy = destroy; -} - - -/** - * hb_font_set_scale: - * @font: a font. - * @x_scale: - * @y_scale: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_set_scale (hb_font_t *font, - int x_scale, - int y_scale) -{ - if (font->immutable) - return; - - font->x_scale = x_scale; - font->y_scale = y_scale; -} - -/** - * hb_font_get_scale: - * @font: a font. - * @x_scale: (out): - * @y_scale: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_get_scale (hb_font_t *font, - int *x_scale, - int *y_scale) -{ - if (x_scale) *x_scale = font->x_scale; - if (y_scale) *y_scale = font->y_scale; -} - -/** - * hb_font_set_ppem: - * @font: a font. - * @x_ppem: - * @y_ppem: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_set_ppem (hb_font_t *font, - unsigned int x_ppem, - unsigned int y_ppem) -{ - if (font->immutable) - return; - - font->x_ppem = x_ppem; - font->y_ppem = y_ppem; -} - -/** - * hb_font_get_ppem: - * @font: a font. - * @x_ppem: (out): - * @y_ppem: (out): - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_get_ppem (hb_font_t *font, - unsigned int *x_ppem, - unsigned int *y_ppem) -{ - if (x_ppem) *x_ppem = font->x_ppem; - if (y_ppem) *y_ppem = font->y_ppem; -} diff --git a/third_party/harfbuzz-ng/src/hb-font.h b/third_party/harfbuzz-ng/src/hb-font.h deleted file mode 100644 index fb4a0eab5a99..000000000000 --- a/third_party/harfbuzz-ng/src/hb-font.h +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - */ - -#ifndef HB_H_IN -#error "Include instead." -#endif - -#ifndef HB_FONT_H -#define HB_FONT_H - -#include "hb-common.h" -#include "hb-face.h" - -HB_BEGIN_DECLS - - -typedef struct hb_font_t hb_font_t; - - -/* - * hb_font_funcs_t - */ - -typedef struct hb_font_funcs_t hb_font_funcs_t; - -hb_font_funcs_t * -hb_font_funcs_create (void); - -hb_font_funcs_t * -hb_font_funcs_get_empty (void); - -hb_font_funcs_t * -hb_font_funcs_reference (hb_font_funcs_t *ffuncs); - -void -hb_font_funcs_destroy (hb_font_funcs_t *ffuncs); - -hb_bool_t -hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - - -void * -hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, - hb_user_data_key_t *key); - - -void -hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs); - -hb_bool_t -hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs); - - -/* glyph extents */ - -/* Note that height is negative in coordinate systems that grow up. */ -typedef struct hb_glyph_extents_t -{ - hb_position_t x_bearing; /* left side of glyph from origin. */ - hb_position_t y_bearing; /* top side of glyph from origin. */ - hb_position_t width; /* distance from left to right side. */ - hb_position_t height; /* distance from top to bottom side. */ -} hb_glyph_extents_t; - - -/* func types */ - -typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data); - - -typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t glyph, - void *user_data); -typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; -typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; - -typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y, - void *user_data); -typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t; -typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; - -typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, - void *user_data); -typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t; -typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; - - -typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data); -typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t glyph, unsigned int point_index, - hb_position_t *x, hb_position_t *y, - void *user_data); - - -typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t glyph, - char *name, unsigned int size, - void *user_data); -typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph, - void *user_data); - - -/* func setters */ - -/** - * hb_font_funcs_set_glyph_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_h_advance_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_h_advance_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_v_advance_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_v_advance_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_h_origin_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_h_origin_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_v_origin_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_v_origin_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_h_kerning_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_h_kerning_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_v_kerning_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_v_kerning_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_extents_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_extents_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_contour_point_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_contour_point_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_name_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_name_func_t func, - void *user_data, hb_destroy_func_t destroy); - -/** - * hb_font_funcs_set_glyph_from_name_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * - * - * - * Since: 0.9.2 - **/ -void -hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_from_name_func_t func, - void *user_data, hb_destroy_func_t destroy); - - -/* func dispatch */ - -hb_bool_t -hb_font_get_glyph (hb_font_t *font, - hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph); - -hb_position_t -hb_font_get_glyph_h_advance (hb_font_t *font, - hb_codepoint_t glyph); -hb_position_t -hb_font_get_glyph_v_advance (hb_font_t *font, - hb_codepoint_t glyph); - -hb_bool_t -hb_font_get_glyph_h_origin (hb_font_t *font, - hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y); -hb_bool_t -hb_font_get_glyph_v_origin (hb_font_t *font, - hb_codepoint_t glyph, - hb_position_t *x, hb_position_t *y); - -hb_position_t -hb_font_get_glyph_h_kerning (hb_font_t *font, - hb_codepoint_t left_glyph, hb_codepoint_t right_glyph); -hb_position_t -hb_font_get_glyph_v_kerning (hb_font_t *font, - hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph); - -hb_bool_t -hb_font_get_glyph_extents (hb_font_t *font, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents); - -hb_bool_t -hb_font_get_glyph_contour_point (hb_font_t *font, - hb_codepoint_t glyph, unsigned int point_index, - hb_position_t *x, hb_position_t *y); - -hb_bool_t -hb_font_get_glyph_name (hb_font_t *font, - hb_codepoint_t glyph, - char *name, unsigned int size); -hb_bool_t -hb_font_get_glyph_from_name (hb_font_t *font, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph); - - -/* high-level funcs, with fallback */ - -void -hb_font_get_glyph_advance_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y); -void -hb_font_get_glyph_origin_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y); -void -hb_font_add_glyph_origin_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y); -void -hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y); - -void -hb_font_get_glyph_kerning_for_direction (hb_font_t *font, - hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y); - -hb_bool_t -hb_font_get_glyph_extents_for_origin (hb_font_t *font, - hb_codepoint_t glyph, - hb_direction_t direction, - hb_glyph_extents_t *extents); - -hb_bool_t -hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, - hb_codepoint_t glyph, unsigned int point_index, - hb_direction_t direction, - hb_position_t *x, hb_position_t *y); - -/* Generates gidDDD if glyph has no name. */ -void -hb_font_glyph_to_string (hb_font_t *font, - hb_codepoint_t glyph, - char *s, unsigned int size); -/* Parses gidDDD and uniUUUU strings automatically. */ -hb_bool_t -hb_font_glyph_from_string (hb_font_t *font, - const char *s, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph); - - -/* - * hb_font_t - */ - -/* Fonts are very light-weight objects */ - -hb_font_t * -hb_font_create (hb_face_t *face); - -hb_font_t * -hb_font_create_sub_font (hb_font_t *parent); - -hb_font_t * -hb_font_get_empty (void); - -hb_font_t * -hb_font_reference (hb_font_t *font); - -void -hb_font_destroy (hb_font_t *font); - -hb_bool_t -hb_font_set_user_data (hb_font_t *font, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - - -void * -hb_font_get_user_data (hb_font_t *font, - hb_user_data_key_t *key); - -void -hb_font_make_immutable (hb_font_t *font); - -hb_bool_t -hb_font_is_immutable (hb_font_t *font); - -void -hb_font_set_parent (hb_font_t *font, - hb_font_t *parent); - -hb_font_t * -hb_font_get_parent (hb_font_t *font); - -hb_face_t * -hb_font_get_face (hb_font_t *font); - - -void -hb_font_set_funcs (hb_font_t *font, - hb_font_funcs_t *klass, - void *font_data, - hb_destroy_func_t destroy); - -/* Be *very* careful with this function! */ -void -hb_font_set_funcs_data (hb_font_t *font, - void *font_data, - hb_destroy_func_t destroy); - - -void -hb_font_set_scale (hb_font_t *font, - int x_scale, - int y_scale); - -void -hb_font_get_scale (hb_font_t *font, - int *x_scale, - int *y_scale); - -/* - * A zero value means "no hinting in that direction" - */ -void -hb_font_set_ppem (hb_font_t *font, - unsigned int x_ppem, - unsigned int y_ppem); - -void -hb_font_get_ppem (hb_font_t *font, - unsigned int *x_ppem, - unsigned int *y_ppem); - - -HB_END_DECLS - -#endif /* HB_FONT_H */ diff --git a/third_party/harfbuzz-ng/src/hb-ft.cc b/third_party/harfbuzz-ng/src/hb-ft.cc deleted file mode 100644 index 9b872ea58f0f..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ft.cc +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2009 Keith Stribley - * Copyright © 2015 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -#include "hb-ft.h" - -#include "hb-font-private.hh" - -#include FT_ADVANCES_H -#include FT_TRUETYPE_TABLES_H - - - -#ifndef HB_DEBUG_FT -#define HB_DEBUG_FT (HB_DEBUG+0) -#endif - - -/* TODO: - * - * In general, this file does a fine job of what it's supposed to do. - * There are, however, things that need more work: - * - * - I remember seeing FT_Get_Advance() without the NO_HINTING flag to be buggy. - * Have not investigated. - * - * - FreeType works in 26.6 mode. Clients can decide to use that mode, and everything - * would work fine. However, we also abuse this API for performing in font-space, - * but don't pass the correct flags to FreeType. We just abuse the no-hinting mode - * for that, such that no rounding etc happens. As such, we don't set ppem, and - * pass NO_HINTING as load_flags. Would be much better to use NO_SCALE, and scale - * ourselves, like we do in uniscribe, etc. - * - * - We don't handle / allow for emboldening / obliqueing. - * - * - In the future, we should add constructors to create fonts in font space? - * - * - FT_Load_Glyph() is exteremely costly. Do something about it? - */ - - -struct hb_ft_font_t -{ - FT_Face ft_face; - int load_flags; - bool unref; /* Whether to destroy ft_face when done. */ -}; - -static hb_ft_font_t * -_hb_ft_font_create (FT_Face ft_face, bool unref) -{ - hb_ft_font_t *ft_font = (hb_ft_font_t *) calloc (1, sizeof (hb_ft_font_t)); - - if (unlikely (!ft_font)) - return NULL; - - ft_font->ft_face = ft_face; - ft_font->unref = unref; - - ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING; - - return ft_font; -} - -static void -_hb_ft_font_destroy (hb_ft_font_t *ft_font) -{ - if (ft_font->unref) - FT_Done_Face (ft_font->ft_face); - - free (ft_font); -} - -/** - * hb_ft_font_set_load_flags: - * @font: - * @load_flags: - * - * - * - * Since: 1.0.5 - **/ -void -hb_ft_font_set_load_flags (hb_font_t *font, int load_flags) -{ - if (font->immutable) - return; - - if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy) - return; - - hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data; - - ft_font->load_flags = load_flags; -} - -/** - * hb_ft_font_get_load_flags: - * @font: - * - * - * - * Return value: - * Since: 1.0.5 - **/ -int -hb_ft_font_get_load_flags (hb_font_t *font) -{ - if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy) - return 0; - - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data; - - return ft_font->load_flags; -} - -FT_Face -hb_ft_font_get_face (hb_font_t *font) -{ - if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy) - return NULL; - - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data; - - return ft_font->ft_face; -} - - - -static hb_bool_t -hb_ft_get_glyph (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) - -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - unsigned int g; - - if (likely (!variation_selector)) - g = FT_Get_Char_Index (ft_font->ft_face, unicode); - else - g = FT_Face_GetCharVariantIndex (ft_font->ft_face, unicode, variation_selector); - - if (unlikely (!g)) - return false; - - *glyph = g; - return true; -} - -static hb_position_t -hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Fixed v; - - if (unlikely (FT_Get_Advance (ft_font->ft_face, glyph, ft_font->load_flags, &v))) - return 0; - - if (font->x_scale < 0) - v = -v; - - return (v + (1<<9)) >> 10; -} - -static hb_position_t -hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Fixed v; - - if (unlikely (FT_Get_Advance (ft_font->ft_face, glyph, ft_font->load_flags | FT_LOAD_VERTICAL_LAYOUT, &v))) - return 0; - - if (font->y_scale < 0) - v = -v; - - /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates - * have a Y growing upward. Hence the extra negation. */ - return (-v + (1<<9)) >> 10; -} - -static hb_bool_t -hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Face ft_face = ft_font->ft_face; - - if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) - return false; - - /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates - * have a Y growing upward. Hence the extra negation. */ - *x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBearingX; - *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY); - - if (font->x_scale < 0) - *x = -*x; - if (font->y_scale < 0) - *y = -*y; - - return true; -} - -static hb_position_t -hb_ft_get_glyph_h_kerning (hb_font_t *font, - void *font_data, - hb_codepoint_t left_glyph, - hb_codepoint_t right_glyph, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Vector kerningv; - - FT_Kerning_Mode mode = font->x_ppem ? FT_KERNING_DEFAULT : FT_KERNING_UNFITTED; - if (FT_Get_Kerning (ft_font->ft_face, left_glyph, right_glyph, mode, &kerningv)) - return 0; - - return kerningv.x; -} - -static hb_bool_t -hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Face ft_face = ft_font->ft_face; - - if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) - return false; - - extents->x_bearing = ft_face->glyph->metrics.horiBearingX; - extents->y_bearing = ft_face->glyph->metrics.horiBearingY; - extents->width = ft_face->glyph->metrics.width; - extents->height = -ft_face->glyph->metrics.height; - if (font->x_scale < 0) - { - extents->x_bearing = -extents->x_bearing; - extents->width = -extents->width; - } - if (font->y_scale < 0) - { - extents->y_bearing = -extents->y_bearing; - extents->height = -extents->height; - } - return true; -} - -static hb_bool_t -hb_ft_get_glyph_contour_point (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - unsigned int point_index, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Face ft_face = ft_font->ft_face; - - if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) - return false; - - if (unlikely (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)) - return false; - - if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) - return false; - - *x = ft_face->glyph->outline.points[point_index].x; - *y = ft_face->glyph->outline.points[point_index].y; - - return true; -} - -static hb_bool_t -hb_ft_get_glyph_name (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - char *name, unsigned int size, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - - hb_bool_t ret = !FT_Get_Glyph_Name (ft_font->ft_face, glyph, name, size); - if (ret && (size && !*name)) - ret = false; - - return ret; -} - -static hb_bool_t -hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED, - void *font_data, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) -{ - const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - FT_Face ft_face = ft_font->ft_face; - - if (len < 0) - *glyph = FT_Get_Name_Index (ft_face, (FT_String *) name); - else { - /* Make a nul-terminated version. */ - char buf[128]; - len = MIN (len, (int) sizeof (buf) - 1); - strncpy (buf, name, len); - buf[len] = '\0'; - *glyph = FT_Get_Name_Index (ft_face, buf); - } - - if (*glyph == 0) - { - /* Check whether the given name was actually the name of glyph 0. */ - char buf[128]; - if (!FT_Get_Glyph_Name(ft_face, 0, buf, sizeof (buf)) && - len < 0 ? !strcmp (buf, name) : !strncmp (buf, name, len)) - return true; - } - - return *glyph != 0; -} - - -static hb_font_funcs_t *static_ft_funcs = NULL; - -#ifdef HB_USE_ATEXIT -static -void free_static_ft_funcs (void) -{ - hb_font_funcs_destroy (static_ft_funcs); -} -#endif - -static void -_hb_ft_font_set_funcs (hb_font_t *font, FT_Face ft_face, bool unref) -{ -retry: - hb_font_funcs_t *funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ft_funcs); - - if (unlikely (!funcs)) - { - funcs = hb_font_funcs_create (); - - hb_font_funcs_set_glyph_func (funcs, hb_ft_get_glyph, NULL, NULL); - hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ft_get_glyph_h_advance, NULL, NULL); - hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ft_get_glyph_v_advance, NULL, NULL); - //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ft_get_glyph_h_origin, NULL, NULL); - hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ft_get_glyph_v_origin, NULL, NULL); - hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ft_get_glyph_h_kerning, NULL, NULL); - //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ft_get_glyph_v_kerning, NULL, NULL); - hb_font_funcs_set_glyph_extents_func (funcs, hb_ft_get_glyph_extents, NULL, NULL); - hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ft_get_glyph_contour_point, NULL, NULL); - hb_font_funcs_set_glyph_name_func (funcs, hb_ft_get_glyph_name, NULL, NULL); - hb_font_funcs_set_glyph_from_name_func (funcs, hb_ft_get_glyph_from_name, NULL, NULL); - - hb_font_funcs_make_immutable (funcs); - - if (!hb_atomic_ptr_cmpexch (&static_ft_funcs, NULL, funcs)) { - hb_font_funcs_destroy (funcs); - goto retry; - } - -#ifdef HB_USE_ATEXIT - atexit (free_static_ft_funcs); /* First person registers atexit() callback. */ -#endif - }; - - hb_font_set_funcs (font, - funcs, - _hb_ft_font_create (ft_face, unref), - (hb_destroy_func_t) _hb_ft_font_destroy); -} - - -static hb_blob_t * -reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) -{ - FT_Face ft_face = (FT_Face) user_data; - FT_Byte *buffer; - FT_ULong length = 0; - FT_Error error; - - /* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire blob */ - - error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length); - if (error) - return NULL; - - buffer = (FT_Byte *) malloc (length); - if (buffer == NULL) - return NULL; - - error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length); - if (error) - return NULL; - - return hb_blob_create ((const char *) buffer, length, - HB_MEMORY_MODE_WRITABLE, - buffer, free); -} - -/** - * hb_ft_face_create: - * @ft_face: (destroy destroy) (scope notified): - * @destroy: - * - * - * - * Return value: (transfer full): - * Since: 0.9.2 - **/ -hb_face_t * -hb_ft_face_create (FT_Face ft_face, - hb_destroy_func_t destroy) -{ - hb_face_t *face; - - if (ft_face->stream->read == NULL) { - hb_blob_t *blob; - - blob = hb_blob_create ((const char *) ft_face->stream->base, - (unsigned int) ft_face->stream->size, - HB_MEMORY_MODE_READONLY, - ft_face, destroy); - face = hb_face_create (blob, ft_face->face_index); - hb_blob_destroy (blob); - } else { - face = hb_face_create_for_tables (reference_table, ft_face, destroy); - } - - hb_face_set_index (face, ft_face->face_index); - hb_face_set_upem (face, ft_face->units_per_EM); - - return face; -} - -/** - * hb_ft_face_create_referenced: - * @ft_face: - * - * - * - * Return value: (transfer full): - * Since: 0.9.38 - **/ -hb_face_t * -hb_ft_face_create_referenced (FT_Face ft_face) -{ - FT_Reference_Face (ft_face); - return hb_ft_face_create (ft_face, (hb_destroy_func_t) FT_Done_Face); -} - -static void -hb_ft_face_finalize (FT_Face ft_face) -{ - hb_face_destroy ((hb_face_t *) ft_face->generic.data); -} - -/** - * hb_ft_face_create_cached: - * @ft_face: - * - * - * - * Return value: (transfer full): - * Since: 0.9.2 - **/ -hb_face_t * -hb_ft_face_create_cached (FT_Face ft_face) -{ - if (unlikely (!ft_face->generic.data || ft_face->generic.finalizer != (FT_Generic_Finalizer) hb_ft_face_finalize)) - { - if (ft_face->generic.finalizer) - ft_face->generic.finalizer (ft_face); - - ft_face->generic.data = hb_ft_face_create (ft_face, NULL); - ft_face->generic.finalizer = (FT_Generic_Finalizer) hb_ft_face_finalize; - } - - return hb_face_reference ((hb_face_t *) ft_face->generic.data); -} - - -/** - * hb_ft_font_create: - * @ft_face: (destroy destroy) (scope notified): - * @destroy: - * - * - * - * Return value: (transfer full): - * Since: 0.9.2 - **/ -hb_font_t * -hb_ft_font_create (FT_Face ft_face, - hb_destroy_func_t destroy) -{ - hb_font_t *font; - hb_face_t *face; - - face = hb_ft_face_create (ft_face, destroy); - font = hb_font_create (face); - hb_face_destroy (face); - _hb_ft_font_set_funcs (font, ft_face, false); - hb_font_set_scale (font, - (int) (((uint64_t) ft_face->size->metrics.x_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16), - (int) (((uint64_t) ft_face->size->metrics.y_scale * (uint64_t) ft_face->units_per_EM + (1<<15)) >> 16)); -#if 0 /* hb-ft works in no-hinting model */ - hb_font_set_ppem (font, - ft_face->size->metrics.x_ppem, - ft_face->size->metrics.y_ppem); -#endif - - return font; -} - -/** - * hb_ft_font_create_referenced: - * @ft_face: - * - * - * - * Return value: (transfer full): - * Since: 0.9.38 - **/ -hb_font_t * -hb_ft_font_create_referenced (FT_Face ft_face) -{ - FT_Reference_Face (ft_face); - return hb_ft_font_create (ft_face, (hb_destroy_func_t) FT_Done_Face); -} - - -/* Thread-safe, lock-free, FT_Library */ - -static FT_Library ft_library; - -#ifdef HB_USE_ATEXIT -static -void free_ft_library (void) -{ - FT_Done_FreeType (ft_library); -} -#endif - -static FT_Library -get_ft_library (void) -{ -retry: - FT_Library library = (FT_Library) hb_atomic_ptr_get (&ft_library); - - if (unlikely (!library)) - { - /* Not found; allocate one. */ - if (FT_Init_FreeType (&library)) - return NULL; - - if (!hb_atomic_ptr_cmpexch (&ft_library, NULL, library)) { - FT_Done_FreeType (library); - goto retry; - } - -#ifdef HB_USE_ATEXIT - atexit (free_ft_library); /* First person registers atexit() callback. */ -#endif - } - - return library; -} - -static void -_release_blob (FT_Face ft_face) -{ - hb_blob_destroy ((hb_blob_t *) ft_face->generic.data); -} - -void -hb_ft_font_set_funcs (hb_font_t *font) -{ - hb_blob_t *blob = hb_face_reference_blob (font->face); - unsigned int blob_length; - const char *blob_data = hb_blob_get_data (blob, &blob_length); - if (unlikely (!blob_length)) - DEBUG_MSG (FT, font, "Font face has empty blob"); - - FT_Face ft_face = NULL; - FT_Error err = FT_New_Memory_Face (get_ft_library (), - (const FT_Byte *) blob_data, - blob_length, - hb_face_get_index (font->face), - &ft_face); - - if (unlikely (err)) { - hb_blob_destroy (blob); - DEBUG_MSG (FT, font, "Font face FT_New_Memory_Face() failed"); - return; - } - - FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE); - - FT_Set_Char_Size (ft_face, - abs (font->x_scale), abs (font->y_scale), - 0, 0); -#if 0 - font->x_ppem * 72 * 64 / font->x_scale, - font->y_ppem * 72 * 64 / font->y_scale); -#endif - if (font->x_scale < 0 || font->y_scale < 0) - { - FT_Matrix matrix = { font->x_scale < 0 ? -1 : +1, 0, - 0, font->y_scale < 0 ? -1 : +1}; - FT_Set_Transform (ft_face, &matrix, NULL); - } - - ft_face->generic.data = blob; - ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob; - - _hb_ft_font_set_funcs (font, ft_face, true); - hb_ft_font_set_load_flags (font, FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING); -} diff --git a/third_party/harfbuzz-ng/src/hb-glib.cc b/third_party/harfbuzz-ng/src/hb-glib.cc deleted file mode 100644 index 7dbd83d29624..000000000000 --- a/third_party/harfbuzz-ng/src/hb-glib.cc +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -#include "hb-glib.h" - -#include "hb-unicode-private.hh" - - -#if !GLIB_CHECK_VERSION(2,29,14) -static const hb_script_t -glib_script_to_script[] = -{ - HB_SCRIPT_COMMON, - HB_SCRIPT_INHERITED, - HB_SCRIPT_ARABIC, - HB_SCRIPT_ARMENIAN, - HB_SCRIPT_BENGALI, - HB_SCRIPT_BOPOMOFO, - HB_SCRIPT_CHEROKEE, - HB_SCRIPT_COPTIC, - HB_SCRIPT_CYRILLIC, - HB_SCRIPT_DESERET, - HB_SCRIPT_DEVANAGARI, - HB_SCRIPT_ETHIOPIC, - HB_SCRIPT_GEORGIAN, - HB_SCRIPT_GOTHIC, - HB_SCRIPT_GREEK, - HB_SCRIPT_GUJARATI, - HB_SCRIPT_GURMUKHI, - HB_SCRIPT_HAN, - HB_SCRIPT_HANGUL, - HB_SCRIPT_HEBREW, - HB_SCRIPT_HIRAGANA, - HB_SCRIPT_KANNADA, - HB_SCRIPT_KATAKANA, - HB_SCRIPT_KHMER, - HB_SCRIPT_LAO, - HB_SCRIPT_LATIN, - HB_SCRIPT_MALAYALAM, - HB_SCRIPT_MONGOLIAN, - HB_SCRIPT_MYANMAR, - HB_SCRIPT_OGHAM, - HB_SCRIPT_OLD_ITALIC, - HB_SCRIPT_ORIYA, - HB_SCRIPT_RUNIC, - HB_SCRIPT_SINHALA, - HB_SCRIPT_SYRIAC, - HB_SCRIPT_TAMIL, - HB_SCRIPT_TELUGU, - HB_SCRIPT_THAANA, - HB_SCRIPT_THAI, - HB_SCRIPT_TIBETAN, - HB_SCRIPT_CANADIAN_SYLLABICS, - HB_SCRIPT_YI, - HB_SCRIPT_TAGALOG, - HB_SCRIPT_HANUNOO, - HB_SCRIPT_BUHID, - HB_SCRIPT_TAGBANWA, - - /* Unicode-4.0 additions */ - HB_SCRIPT_BRAILLE, - HB_SCRIPT_CYPRIOT, - HB_SCRIPT_LIMBU, - HB_SCRIPT_OSMANYA, - HB_SCRIPT_SHAVIAN, - HB_SCRIPT_LINEAR_B, - HB_SCRIPT_TAI_LE, - HB_SCRIPT_UGARITIC, - - /* Unicode-4.1 additions */ - HB_SCRIPT_NEW_TAI_LUE, - HB_SCRIPT_BUGINESE, - HB_SCRIPT_GLAGOLITIC, - HB_SCRIPT_TIFINAGH, - HB_SCRIPT_SYLOTI_NAGRI, - HB_SCRIPT_OLD_PERSIAN, - HB_SCRIPT_KHAROSHTHI, - - /* Unicode-5.0 additions */ - HB_SCRIPT_UNKNOWN, - HB_SCRIPT_BALINESE, - HB_SCRIPT_CUNEIFORM, - HB_SCRIPT_PHOENICIAN, - HB_SCRIPT_PHAGS_PA, - HB_SCRIPT_NKO, - - /* Unicode-5.1 additions */ - HB_SCRIPT_KAYAH_LI, - HB_SCRIPT_LEPCHA, - HB_SCRIPT_REJANG, - HB_SCRIPT_SUNDANESE, - HB_SCRIPT_SAURASHTRA, - HB_SCRIPT_CHAM, - HB_SCRIPT_OL_CHIKI, - HB_SCRIPT_VAI, - HB_SCRIPT_CARIAN, - HB_SCRIPT_LYCIAN, - HB_SCRIPT_LYDIAN, - - /* Unicode-5.2 additions */ - HB_SCRIPT_AVESTAN, - HB_SCRIPT_BAMUM, - HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, - HB_SCRIPT_IMPERIAL_ARAMAIC, - HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, - HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, - HB_SCRIPT_JAVANESE, - HB_SCRIPT_KAITHI, - HB_SCRIPT_TAI_THAM, - HB_SCRIPT_LISU, - HB_SCRIPT_MEETEI_MAYEK, - HB_SCRIPT_OLD_SOUTH_ARABIAN, - HB_SCRIPT_OLD_TURKIC, - HB_SCRIPT_SAMARITAN, - HB_SCRIPT_TAI_VIET, - - /* Unicode-6.0 additions */ - HB_SCRIPT_BATAK, - HB_SCRIPT_BRAHMI, - HB_SCRIPT_MANDAIC, - - /* Unicode-6.1 additions */ - HB_SCRIPT_CHAKMA, - HB_SCRIPT_MEROITIC_CURSIVE, - HB_SCRIPT_MEROITIC_HIEROGLYPHS, - HB_SCRIPT_MIAO, - HB_SCRIPT_SHARADA, - HB_SCRIPT_SORA_SOMPENG, - HB_SCRIPT_TAKRI -}; -#endif - -hb_script_t -hb_glib_script_to_script (GUnicodeScript script) -{ -#if GLIB_CHECK_VERSION(2,29,14) - return (hb_script_t) g_unicode_script_to_iso15924 (script); -#else - if (likely ((unsigned int) script < ARRAY_LENGTH (glib_script_to_script))) - return glib_script_to_script[script]; - - if (unlikely (script == G_UNICODE_SCRIPT_INVALID_CODE)) - return HB_SCRIPT_INVALID; - - return HB_SCRIPT_UNKNOWN; -#endif -} - -GUnicodeScript -hb_glib_script_from_script (hb_script_t script) -{ -#if GLIB_CHECK_VERSION(2,29,14) - return g_unicode_script_from_iso15924 (script); -#else - unsigned int count = ARRAY_LENGTH (glib_script_to_script); - for (unsigned int i = 0; i < count; i++) - if (glib_script_to_script[i] == script) - return (GUnicodeScript) i; - - if (unlikely (script == HB_SCRIPT_INVALID)) - return G_UNICODE_SCRIPT_INVALID_CODE; - - return G_UNICODE_SCRIPT_UNKNOWN; -#endif -} - - -static hb_unicode_combining_class_t -hb_glib_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) - -{ - return (hb_unicode_combining_class_t) g_unichar_combining_class (unicode); -} - -static unsigned int -hb_glib_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - return g_unichar_iswide (unicode) ? 2 : 1; -} - -static hb_unicode_general_category_t -hb_glib_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) - -{ - /* hb_unicode_general_category_t and GUnicodeType are identical */ - return (hb_unicode_general_category_t) g_unichar_type (unicode); -} - -static hb_codepoint_t -hb_glib_unicode_mirroring (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - g_unichar_get_mirror_char (unicode, &unicode); - return unicode; -} - -static hb_script_t -hb_glib_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - return hb_glib_script_to_script (g_unichar_get_script (unicode)); -} - -static hb_bool_t -hb_glib_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t a, - hb_codepoint_t b, - hb_codepoint_t *ab, - void *user_data HB_UNUSED) -{ -#if GLIB_CHECK_VERSION(2,29,12) - return g_unichar_compose (a, b, ab); -#endif - - /* We don't ifdef-out the fallback code such that compiler always - * sees it and makes sure it's compilable. */ - - gchar utf8[12]; - gchar *normalized; - int len; - hb_bool_t ret; - - len = g_unichar_to_utf8 (a, utf8); - len += g_unichar_to_utf8 (b, utf8 + len); - normalized = g_utf8_normalize (utf8, len, G_NORMALIZE_NFC); - len = g_utf8_strlen (normalized, -1); - if (unlikely (!len)) - return false; - - if (len == 1) { - *ab = g_utf8_get_char (normalized); - ret = true; - } else { - ret = false; - } - - g_free (normalized); - return ret; -} - -static hb_bool_t -hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t ab, - hb_codepoint_t *a, - hb_codepoint_t *b, - void *user_data HB_UNUSED) -{ -#if GLIB_CHECK_VERSION(2,29,12) - return g_unichar_decompose (ab, a, b); -#endif - - /* We don't ifdef-out the fallback code such that compiler always - * sees it and makes sure it's compilable. */ - - gchar utf8[6]; - gchar *normalized; - int len; - hb_bool_t ret; - - len = g_unichar_to_utf8 (ab, utf8); - normalized = g_utf8_normalize (utf8, len, G_NORMALIZE_NFD); - len = g_utf8_strlen (normalized, -1); - if (unlikely (!len)) - return false; - - if (len == 1) { - *a = g_utf8_get_char (normalized); - *b = 0; - ret = *a != ab; - } else if (len == 2) { - *a = g_utf8_get_char (normalized); - *b = g_utf8_get_char (g_utf8_next_char (normalized)); - /* Here's the ugly part: if ab decomposes to a single character and - * that character decomposes again, we have to detect that and undo - * the second part :-(. */ - gchar *recomposed = g_utf8_normalize (normalized, -1, G_NORMALIZE_NFC); - hb_codepoint_t c = g_utf8_get_char (recomposed); - if (c != ab && c != *a) { - *a = c; - *b = 0; - } - g_free (recomposed); - ret = true; - } else { - /* If decomposed to more than two characters, take the last one, - * and recompose the rest to get the first component. */ - gchar *end = g_utf8_offset_to_pointer (normalized, len - 1); - gchar *recomposed; - *b = g_utf8_get_char (end); - recomposed = g_utf8_normalize (normalized, end - normalized, G_NORMALIZE_NFC); - /* We expect that recomposed has exactly one character now. */ - *a = g_utf8_get_char (recomposed); - g_free (recomposed); - ret = true; - } - - g_free (normalized); - return ret; -} - -static unsigned int -hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t u, - hb_codepoint_t *decomposed, - void *user_data HB_UNUSED) -{ -#if GLIB_CHECK_VERSION(2,29,12) - return g_unichar_fully_decompose (u, true, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN); -#endif - - /* If the user doesn't have GLib >= 2.29.12 we have to perform - * a round trip to UTF-8 and the associated memory management dance. */ - gchar utf8[6]; - gchar *utf8_decomposed, *c; - gsize utf8_len, utf8_decomposed_len, i; - - /* Convert @u to UTF-8 and normalise it in NFKD mode. This performs the compatibility decomposition. */ - utf8_len = g_unichar_to_utf8 (u, utf8); - utf8_decomposed = g_utf8_normalize (utf8, utf8_len, G_NORMALIZE_NFKD); - utf8_decomposed_len = g_utf8_strlen (utf8_decomposed, -1); - - assert (utf8_decomposed_len <= HB_UNICODE_MAX_DECOMPOSITION_LEN); - - for (i = 0, c = utf8_decomposed; i < utf8_decomposed_len; i++, c = g_utf8_next_char (c)) - *decomposed++ = g_utf8_get_char (c); - - g_free (utf8_decomposed); - - return utf8_decomposed_len; -} - -hb_unicode_funcs_t * -hb_glib_get_unicode_funcs (void) -{ - static const hb_unicode_funcs_t _hb_glib_unicode_funcs = { - HB_OBJECT_HEADER_STATIC, - - NULL, /* parent */ - true, /* immutable */ - { -#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name, - HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_UNICODE_FUNC_IMPLEMENT - } - }; - - return const_cast (&_hb_glib_unicode_funcs); -} - -/** - * Since: 0.9.38 - **/ -hb_blob_t * -hb_glib_blob_create (GBytes *gbytes) -{ - gsize size = 0; - gconstpointer data = g_bytes_get_data (gbytes, &size); - return hb_blob_create ((const char *) data, - size, - HB_MEMORY_MODE_READONLY, - g_bytes_ref (gbytes), - (hb_destroy_func_t) g_bytes_unref); -} diff --git a/third_party/harfbuzz-ng/src/hb-gobject-structs.cc b/third_party/harfbuzz-ng/src/hb-gobject-structs.cc deleted file mode 100644 index 6bd63368b653..000000000000 --- a/third_party/harfbuzz-ng/src/hb-gobject-structs.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -/* g++ didn't like older gtype.h gcc-only code path. */ -#include -#if !GLIB_CHECK_VERSION(2,29,16) -#undef __GNUC__ -#undef __GNUC_MINOR__ -#define __GNUC__ 2 -#define __GNUC_MINOR__ 6 -#endif - -#include "hb-gobject.h" - -#define HB_DEFINE_BOXED_TYPE(name,copy_func,free_func) \ -GType \ -hb_gobject_##name##_get_type (void) \ -{ \ - static gsize type_id = 0; \ - if (g_once_init_enter (&type_id)) { \ - GType id = g_boxed_type_register_static (g_intern_static_string ("hb_" #name "_t"), \ - (GBoxedCopyFunc) copy_func, \ - (GBoxedFreeFunc) free_func); \ - g_once_init_leave (&type_id, id); \ - } \ - return type_id; \ -} - -#define HB_DEFINE_OBJECT_TYPE(name) \ - HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy); - -#define HB_DEFINE_VALUE_TYPE(name) \ - static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \ - { \ - hb_##name##_t *c = (hb_##name##_t *) calloc (1, sizeof (hb_##name##_t)); \ - if (unlikely (!c)) return NULL; \ - *c = *l; \ - return c; \ - } \ - static void _hb_##name##_destroy (hb_##name##_t *l) { free (l); } \ - HB_DEFINE_BOXED_TYPE (name, _hb_##name##_reference, _hb_##name##_destroy); - -HB_DEFINE_OBJECT_TYPE (buffer) -HB_DEFINE_OBJECT_TYPE (blob) -HB_DEFINE_OBJECT_TYPE (face) -HB_DEFINE_OBJECT_TYPE (font) -HB_DEFINE_OBJECT_TYPE (font_funcs) -HB_DEFINE_OBJECT_TYPE (set) -HB_DEFINE_OBJECT_TYPE (shape_plan) -HB_DEFINE_OBJECT_TYPE (unicode_funcs) -HB_DEFINE_VALUE_TYPE (feature) -HB_DEFINE_VALUE_TYPE (glyph_info) -HB_DEFINE_VALUE_TYPE (glyph_position) -HB_DEFINE_VALUE_TYPE (segment_properties) -HB_DEFINE_VALUE_TYPE (user_data_key) diff --git a/third_party/harfbuzz-ng/src/hb-gobject-structs.h b/third_party/harfbuzz-ng/src/hb-gobject-structs.h deleted file mode 100644 index 0a0387dce31f..000000000000 --- a/third_party/harfbuzz-ng/src/hb-gobject-structs.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_GOBJECT_H_IN -#error "Include instead." -#endif - -#ifndef HB_GOBJECT_STRUCTS_H -#define HB_GOBJECT_STRUCTS_H - -#include "hb.h" - -#include - -HB_BEGIN_DECLS - - -/* Object types */ - -/** - * Since: 0.9.2 - **/ -GType hb_gobject_blob_get_type (void); -#define HB_GOBJECT_TYPE_BLOB (hb_gobject_blob_get_type ()) - -/** - * Since: 0.9.2 - **/ -GType hb_gobject_buffer_get_type (void); -#define HB_GOBJECT_TYPE_BUFFER (hb_gobject_buffer_get_type ()) - -/** - * Since: 0.9.2 - **/ -GType hb_gobject_face_get_type (void); -#define HB_GOBJECT_TYPE_FACE (hb_gobject_face_get_type ()) - -/** - * Since: 0.9.2 - **/ -GType hb_gobject_font_get_type (void); -#define HB_GOBJECT_TYPE_FONT (hb_gobject_font_get_type ()) - -/** - * Since: 0.9.2 - **/ -GType hb_gobject_font_funcs_get_type (void); -#define HB_GOBJECT_TYPE_FONT_FUNCS (hb_gobject_font_funcs_get_type ()) - -GType hb_gobject_set_get_type (void); -#define HB_GOBJECT_TYPE_SET (hb_gobject_set_get_type ()) - -GType hb_gobject_shape_plan_get_type (void); -#define HB_GOBJECT_TYPE_SHAPE_PLAN (hb_gobject_shape_plan_get_type ()) - -/** - * Since: 0.9.2 - **/ -GType hb_gobject_unicode_funcs_get_type (void); -#define HB_GOBJECT_TYPE_UNICODE_FUNCS (hb_gobject_unicode_funcs_get_type ()) - -/* Value types */ - -GType hb_gobject_feature_get_type (void); -#define HB_GOBJECT_TYPE_FEATURE (hb_gobject_feature_get_type ()) - -GType hb_gobject_glyph_info_get_type (void); -#define HB_GOBJECT_TYPE_GLYPH_INFO (hb_gobject_glyph_info_get_type ()) - -GType hb_gobject_glyph_position_get_type (void); -#define HB_GOBJECT_TYPE_GLYPH_POSITION (hb_gobject_glyph_position_get_type ()) - -GType hb_gobject_segment_properties_get_type (void); -#define HB_GOBJECT_TYPE_SEGMENT_PROPERTIES (hb_gobject_segment_properties_get_type ()) - -GType hb_gobject_user_data_key_get_type (void); -#define HB_GOBJECT_TYPE_USER_DATA_KEY (hb_gobject_user_data_key_get_type ()) - - -HB_END_DECLS - -#endif /* HB_GOBJECT_H */ diff --git a/third_party/harfbuzz-ng/src/hb-graphite2.cc b/third_party/harfbuzz-ng/src/hb-graphite2.cc deleted file mode 100644 index cd694c140650..000000000000 --- a/third_party/harfbuzz-ng/src/hb-graphite2.cc +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright © 2011 Martin Hosken - * Copyright © 2011 SIL International - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#define HB_SHAPER graphite2 -#define hb_graphite2_shaper_font_data_t gr_font -#include "hb-shaper-impl-private.hh" - -#include "hb-graphite2.h" - -#include - - -HB_SHAPER_DATA_ENSURE_DECLARE(graphite2, face) -HB_SHAPER_DATA_ENSURE_DECLARE(graphite2, font) - - -/* - * shaper face data - */ - -typedef struct hb_graphite2_tablelist_t { - struct hb_graphite2_tablelist_t *next; - hb_blob_t *blob; - unsigned int tag; -} hb_graphite2_tablelist_t; - -struct hb_graphite2_shaper_face_data_t { - hb_face_t *face; - gr_face *grface; - hb_graphite2_tablelist_t *tlist; -}; - -static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len) -{ - hb_graphite2_shaper_face_data_t *face_data = (hb_graphite2_shaper_face_data_t *) data; - hb_graphite2_tablelist_t *tlist = face_data->tlist; - - hb_blob_t *blob = NULL; - - for (hb_graphite2_tablelist_t *p = tlist; p; p = p->next) - if (p->tag == tag) { - blob = p->blob; - break; - } - - if (unlikely (!blob)) - { - blob = face_data->face->reference_table (tag); - - hb_graphite2_tablelist_t *p = (hb_graphite2_tablelist_t *) calloc (1, sizeof (hb_graphite2_tablelist_t)); - if (unlikely (!p)) { - hb_blob_destroy (blob); - return NULL; - } - p->blob = blob; - p->tag = tag; - - /* TODO Not thread-safe, but fairly harmless. - * We can do the double-chcked pointer cmpexch thing here. */ - p->next = face_data->tlist; - face_data->tlist = p; - } - - unsigned int tlen; - const char *d = hb_blob_get_data (blob, &tlen); - *len = tlen; - return d; -} - -hb_graphite2_shaper_face_data_t * -_hb_graphite2_shaper_face_data_create (hb_face_t *face) -{ - hb_blob_t *silf_blob = face->reference_table (HB_GRAPHITE2_TAG_SILF); - /* Umm, we just reference the table to check whether it exists. - * Maybe add better API for this? */ - if (!hb_blob_get_length (silf_blob)) - { - hb_blob_destroy (silf_blob); - return NULL; - } - hb_blob_destroy (silf_blob); - - hb_graphite2_shaper_face_data_t *data = (hb_graphite2_shaper_face_data_t *) calloc (1, sizeof (hb_graphite2_shaper_face_data_t)); - if (unlikely (!data)) - return NULL; - - data->face = face; - data->grface = gr_make_face (data, &hb_graphite2_get_table, gr_face_preloadAll); - - if (unlikely (!data->grface)) { - free (data); - return NULL; - } - - return data; -} - -void -_hb_graphite2_shaper_face_data_destroy (hb_graphite2_shaper_face_data_t *data) -{ - hb_graphite2_tablelist_t *tlist = data->tlist; - - while (tlist) - { - hb_graphite2_tablelist_t *old = tlist; - hb_blob_destroy (tlist->blob); - tlist = tlist->next; - free (old); - } - - gr_face_destroy (data->grface); - - free (data); -} - -/* - * Since: 0.9.10 - */ -gr_face * -hb_graphite2_face_get_gr_face (hb_face_t *face) -{ - if (unlikely (!hb_graphite2_shaper_face_data_ensure (face))) return NULL; - return HB_SHAPER_DATA_GET (face)->grface; -} - - -/* - * shaper font data - */ - -static float hb_graphite2_get_advance (const void *hb_font, unsigned short gid) -{ - return ((hb_font_t *) hb_font)->get_glyph_h_advance (gid); -} - -hb_graphite2_shaper_font_data_t * -_hb_graphite2_shaper_font_data_create (hb_font_t *font) -{ - if (unlikely (!hb_graphite2_shaper_face_data_ensure (font->face))) return NULL; - - hb_face_t *face = font->face; - hb_graphite2_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - - return gr_make_font_with_advance_fn (font->x_scale, font, &hb_graphite2_get_advance, face_data->grface); -} - -void -_hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data) -{ - gr_font_destroy (data); -} - -/* - * Since: 0.9.10 - */ -gr_font * -hb_graphite2_font_get_gr_font (hb_font_t *font) -{ - if (unlikely (!hb_graphite2_shaper_font_data_ensure (font))) return NULL; - return HB_SHAPER_DATA_GET (font); -} - - -/* - * shaper shape_plan data - */ - -struct hb_graphite2_shaper_shape_plan_data_t {}; - -hb_graphite2_shaper_shape_plan_data_t * -_hb_graphite2_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, - const hb_feature_t *user_features HB_UNUSED, - unsigned int num_user_features HB_UNUSED) -{ - return (hb_graphite2_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; -} - -void -_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shaper_shape_plan_data_t *data HB_UNUSED) -{ -} - - -/* - * shaper - */ - -struct hb_graphite2_cluster_t { - unsigned int base_char; - unsigned int num_chars; - unsigned int base_glyph; - unsigned int num_glyphs; - unsigned int cluster; -}; - -hb_bool_t -_hb_graphite2_shape (hb_shape_plan_t *shape_plan, - hb_font_t *font, - hb_buffer_t *buffer, - const hb_feature_t *features, - unsigned int num_features) -{ - hb_face_t *face = font->face; - gr_face *grface = HB_SHAPER_DATA_GET (face)->grface; - gr_font *grfont = HB_SHAPER_DATA_GET (font); - - const char *lang = hb_language_to_string (hb_buffer_get_language (buffer)); - const char *lang_end = lang ? strchr (lang, '-') : NULL; - int lang_len = lang_end ? lang_end - lang : -1; - gr_feature_val *feats = gr_face_featureval_for_lang (grface, lang ? hb_tag_from_string (lang, lang_len) : 0); - - for (unsigned int i = 0; i < num_features; i++) - { - const gr_feature_ref *fref = gr_face_find_fref (grface, features[i].tag); - if (fref) - gr_fref_set_feature_value (fref, features[i].value, feats); - } - - gr_segment *seg = NULL; - const gr_slot *is; - unsigned int ci = 0, ic = 0; - float curradvx = 0., curradvy = 0.; - - unsigned int scratch_size; - hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size); - - uint32_t *chars = (uint32_t *) scratch; - - for (unsigned int i = 0; i < buffer->len; ++i) - chars[i] = buffer->info[i].codepoint; - - /* TODO ensure_native_direction. */ - - hb_tag_t script_tag[2]; - hb_ot_tags_from_script (hb_buffer_get_script (buffer), &script_tag[0], &script_tag[1]); - - seg = gr_make_seg (grfont, grface, - script_tag[1] == HB_TAG_NONE ? script_tag[0] : script_tag[1], - feats, - gr_utf32, chars, buffer->len, - 2 | (hb_buffer_get_direction (buffer) == HB_DIRECTION_RTL ? 1 : 0)); - - if (unlikely (!seg)) { - if (feats) gr_featureval_destroy (feats); - return false; - } - - unsigned int glyph_count = gr_seg_n_slots (seg); - if (unlikely (!glyph_count)) { - if (feats) gr_featureval_destroy (feats); - gr_seg_destroy (seg); - buffer->len = 0; - return true; - } - - buffer->ensure (glyph_count); - scratch = buffer->get_scratch_buffer (&scratch_size); - while ((DIV_CEIL (sizeof (hb_graphite2_cluster_t) * buffer->len, sizeof (*scratch)) + - DIV_CEIL (sizeof (hb_codepoint_t) * glyph_count, sizeof (*scratch))) > scratch_size) - { - if (unlikely (!buffer->ensure (buffer->allocated * 2))) - { - if (feats) gr_featureval_destroy (feats); - gr_seg_destroy (seg); - return false; - } - scratch = buffer->get_scratch_buffer (&scratch_size); - } - -#define ALLOCATE_ARRAY(Type, name, len) \ - Type *name = (Type *) scratch; \ - { \ - unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \ - assert (_consumed <= scratch_size); \ - scratch += _consumed; \ - scratch_size -= _consumed; \ - } - - ALLOCATE_ARRAY (hb_graphite2_cluster_t, clusters, buffer->len); - ALLOCATE_ARRAY (hb_codepoint_t, gids, glyph_count); - -#undef ALLOCATE_ARRAY - - memset (clusters, 0, sizeof (clusters[0]) * buffer->len); - - hb_codepoint_t *pg = gids; - clusters[0].cluster = buffer->info[0].cluster; - for (is = gr_seg_first_slot (seg), ic = 0; is; is = gr_slot_next_in_segment (is), ic++) - { - unsigned int before = gr_slot_before (is); - unsigned int after = gr_slot_after (is); - *pg = gr_slot_gid (is); - pg++; - while (clusters[ci].base_char > before && ci) - { - clusters[ci-1].num_chars += clusters[ci].num_chars; - clusters[ci-1].num_glyphs += clusters[ci].num_glyphs; - ci--; - } - - if (gr_slot_can_insert_before (is) && clusters[ci].num_chars && before >= clusters[ci].base_char + clusters[ci].num_chars) - { - hb_graphite2_cluster_t *c = clusters + ci + 1; - c->base_char = clusters[ci].base_char + clusters[ci].num_chars; - c->cluster = buffer->info[c->base_char].cluster; - c->num_chars = before - c->base_char; - c->base_glyph = ic; - c->num_glyphs = 0; - ci++; - } - clusters[ci].num_glyphs++; - - if (clusters[ci].base_char + clusters[ci].num_chars < after + 1) - clusters[ci].num_chars = after + 1 - clusters[ci].base_char; - } - ci++; - - for (unsigned int i = 0; i < ci; ++i) - { - for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j) - { - hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j]; - info->codepoint = gids[clusters[i].base_glyph + j]; - info->cluster = clusters[i].cluster; - } - } - buffer->len = glyph_count; - - /* Positioning. */ - if (!HB_DIRECTION_IS_BACKWARD(buffer->props.direction)) - { - hb_glyph_position_t *pPos; - for (pPos = hb_buffer_get_glyph_positions (buffer, NULL), is = gr_seg_first_slot (seg); - is; pPos++, is = gr_slot_next_in_segment (is)) - { - pPos->x_offset = gr_slot_origin_X (is) - curradvx; - pPos->y_offset = gr_slot_origin_Y (is) - curradvy; - pPos->x_advance = gr_slot_advance_X (is, grface, grfont); - pPos->y_advance = gr_slot_advance_Y (is, grface, grfont); - curradvx += pPos->x_advance; - curradvy += pPos->y_advance; - } - pPos[-1].x_advance += gr_seg_advance_X(seg) - curradvx; - } - else - { - hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, NULL) + buffer->len - 1; - const hb_glyph_info_t *info = buffer->info + buffer->len - 1; - const hb_glyph_info_t *tinfo; - const gr_slot *tis; - int currclus = -1; - float clusx = 0., clusy = 0.; - for (is = gr_seg_last_slot (seg); is; pPos--, info--, is = gr_slot_prev_in_segment (is)) - { - if (info->cluster != currclus) - { - curradvx += clusx; - curradvy += clusy; - currclus = info->cluster; - clusx = 0.; - clusy = 0.; - for (tis = is, tinfo = info; tis && tinfo->cluster == currclus; tis = gr_slot_prev_in_segment (tis), tinfo--) - { - clusx += gr_slot_advance_X (tis, grface, grfont); - clusy += gr_slot_advance_Y (tis, grface, grfont); - } - curradvx += clusx; - curradvy += clusy; - } - pPos->x_advance = gr_slot_advance_X (is, grface, grfont); - pPos->y_advance = gr_slot_advance_Y (is, grface, grfont); - curradvx -= pPos->x_advance; - curradvy -= pPos->y_advance; - pPos->x_offset = gr_slot_origin_X (is) - curradvx; - pPos->y_offset = gr_slot_origin_Y (is) - curradvy; - } - hb_buffer_reverse_clusters (buffer); - } - - if (feats) gr_featureval_destroy (feats); - gr_seg_destroy (seg); - - return true; -} diff --git a/third_party/harfbuzz-ng/src/hb-icu.cc b/third_party/harfbuzz-ng/src/hb-icu.cc deleted file mode 100644 index 24cec9d7266b..000000000000 --- a/third_party/harfbuzz-ng/src/hb-icu.cc +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright © 2009 Red Hat, Inc. - * Copyright © 2009 Keith Stribley - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#include "hb-private.hh" - -#include "hb-icu.h" - -#include "hb-unicode-private.hh" - -#include -#include -#include -#include - - -hb_script_t -hb_icu_script_to_script (UScriptCode script) -{ - if (unlikely (script == USCRIPT_INVALID_CODE)) - return HB_SCRIPT_INVALID; - - return hb_script_from_string (uscript_getShortName (script), -1); -} - -UScriptCode -hb_icu_script_from_script (hb_script_t script) -{ - if (unlikely (script == HB_SCRIPT_INVALID)) - return USCRIPT_INVALID_CODE; - - for (unsigned int i = 0; i < USCRIPT_CODE_LIMIT; i++) - if (unlikely (hb_icu_script_to_script ((UScriptCode) i) == script)) - return (UScriptCode) i; - - return USCRIPT_UNKNOWN; -} - - -static hb_unicode_combining_class_t -hb_icu_unicode_combining_class (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) - -{ - return (hb_unicode_combining_class_t) u_getCombiningClass (unicode); -} - -static unsigned int -hb_icu_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - switch (u_getIntPropertyValue(unicode, UCHAR_EAST_ASIAN_WIDTH)) - { - case U_EA_WIDE: - case U_EA_FULLWIDTH: - return 2; - case U_EA_NEUTRAL: - case U_EA_AMBIGUOUS: - case U_EA_HALFWIDTH: - case U_EA_NARROW: - return 1; - } - return 1; -} - -static hb_unicode_general_category_t -hb_icu_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - switch (u_getIntPropertyValue(unicode, UCHAR_GENERAL_CATEGORY)) - { - case U_UNASSIGNED: return HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED; - - case U_UPPERCASE_LETTER: return HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER; - case U_LOWERCASE_LETTER: return HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER; - case U_TITLECASE_LETTER: return HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER; - case U_MODIFIER_LETTER: return HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER; - case U_OTHER_LETTER: return HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER; - - case U_NON_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK; - case U_ENCLOSING_MARK: return HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK; - case U_COMBINING_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK; - - case U_DECIMAL_DIGIT_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER; - case U_LETTER_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER; - case U_OTHER_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER; - - case U_SPACE_SEPARATOR: return HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR; - case U_LINE_SEPARATOR: return HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR; - case U_PARAGRAPH_SEPARATOR: return HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR; - - case U_CONTROL_CHAR: return HB_UNICODE_GENERAL_CATEGORY_CONTROL; - case U_FORMAT_CHAR: return HB_UNICODE_GENERAL_CATEGORY_FORMAT; - case U_PRIVATE_USE_CHAR: return HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE; - case U_SURROGATE: return HB_UNICODE_GENERAL_CATEGORY_SURROGATE; - - - case U_DASH_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION; - case U_START_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION; - case U_END_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION; - case U_CONNECTOR_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION; - case U_OTHER_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION; - - case U_MATH_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL; - case U_CURRENCY_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL; - case U_MODIFIER_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL; - case U_OTHER_SYMBOL: return HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL; - - case U_INITIAL_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION; - case U_FINAL_PUNCTUATION: return HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION; - } - - return HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED; -} - -static hb_codepoint_t -hb_icu_unicode_mirroring (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - return u_charMirror(unicode); -} - -static hb_script_t -hb_icu_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t unicode, - void *user_data HB_UNUSED) -{ - UErrorCode status = U_ZERO_ERROR; - UScriptCode scriptCode = uscript_getScript(unicode, &status); - - if (unlikely (U_FAILURE (status))) - return HB_SCRIPT_UNKNOWN; - - return hb_icu_script_to_script (scriptCode); -} - -#if U_ICU_VERSION_MAJOR_NUM >= 49 -static const UNormalizer2 *normalizer; -#endif - -static hb_bool_t -hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t a, - hb_codepoint_t b, - hb_codepoint_t *ab, - void *user_data HB_UNUSED) -{ -#if U_ICU_VERSION_MAJOR_NUM >= 49 - { - UChar32 ret = unorm2_composePair (normalizer, a, b); - if (ret < 0) return false; - *ab = ret; - return true; - } -#endif - - /* We don't ifdef-out the fallback code such that compiler always - * sees it and makes sure it's compilable. */ - - UChar utf16[4], normalized[5]; - unsigned int len; - hb_bool_t ret, err; - UErrorCode icu_err; - - len = 0; - err = false; - U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), a, err); - if (err) return false; - U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), b, err); - if (err) return false; - - icu_err = U_ZERO_ERROR; - len = unorm_normalize (utf16, len, UNORM_NFC, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); - if (U_FAILURE (icu_err)) - return false; - if (u_countChar32 (normalized, len) == 1) { - U16_GET_UNSAFE (normalized, 0, *ab); - ret = true; - } else { - ret = false; - } - - return ret; -} - -static hb_bool_t -hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t ab, - hb_codepoint_t *a, - hb_codepoint_t *b, - void *user_data HB_UNUSED) -{ -#if U_ICU_VERSION_MAJOR_NUM >= 49 - { - UChar decomposed[4]; - int len; - UErrorCode icu_err = U_ZERO_ERROR; - len = unorm2_getRawDecomposition (normalizer, ab, decomposed, - ARRAY_LENGTH (decomposed), &icu_err); - if (U_FAILURE (icu_err) || len < 0) return false; - - len = u_countChar32 (decomposed, len); - if (len == 1) { - U16_GET_UNSAFE (decomposed, 0, *a); - *b = 0; - return *a != ab; - } else if (len == 2) { - len =0; - U16_NEXT_UNSAFE (decomposed, len, *a); - U16_NEXT_UNSAFE (decomposed, len, *b); - } - return true; - } -#endif - - /* We don't ifdef-out the fallback code such that compiler always - * sees it and makes sure it's compilable. */ - - UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; - unsigned int len; - hb_bool_t ret, err; - UErrorCode icu_err; - - /* This function is a monster! Maybe it wasn't a good idea adding a - * pairwise decompose API... */ - /* Watchout for the dragons. Err, watchout for macros changing len. */ - - len = 0; - err = false; - U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), ab, err); - if (err) return false; - - icu_err = U_ZERO_ERROR; - len = unorm_normalize (utf16, len, UNORM_NFD, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); - if (U_FAILURE (icu_err)) - return false; - - len = u_countChar32 (normalized, len); - - if (len == 1) { - U16_GET_UNSAFE (normalized, 0, *a); - *b = 0; - ret = *a != ab; - } else if (len == 2) { - len =0; - U16_NEXT_UNSAFE (normalized, len, *a); - U16_NEXT_UNSAFE (normalized, len, *b); - - /* Here's the ugly part: if ab decomposes to a single character and - * that character decomposes again, we have to detect that and undo - * the second part :-(. */ - UChar recomposed[20]; - icu_err = U_ZERO_ERROR; - unorm_normalize (normalized, len, UNORM_NFC, 0, recomposed, ARRAY_LENGTH (recomposed), &icu_err); - if (U_FAILURE (icu_err)) - return false; - hb_codepoint_t c; - U16_GET_UNSAFE (recomposed, 0, c); - if (c != *a && c != ab) { - *a = c; - *b = 0; - } - ret = true; - } else { - /* If decomposed to more than two characters, take the last one, - * and recompose the rest to get the first component. */ - U16_PREV_UNSAFE (normalized, len, *b); /* Changes len in-place. */ - UChar recomposed[18 * 2]; - icu_err = U_ZERO_ERROR; - len = unorm_normalize (normalized, len, UNORM_NFC, 0, recomposed, ARRAY_LENGTH (recomposed), &icu_err); - if (U_FAILURE (icu_err)) - return false; - /* We expect that recomposed has exactly one character now. */ - if (unlikely (u_countChar32 (recomposed, len) != 1)) - return false; - U16_GET_UNSAFE (recomposed, 0, *a); - ret = true; - } - - return ret; -} - -static unsigned int -hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, - hb_codepoint_t u, - hb_codepoint_t *decomposed, - void *user_data HB_UNUSED) -{ - UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; - unsigned int len; - int32_t utf32_len; - hb_bool_t err; - UErrorCode icu_err; - - /* Copy @u into a UTF-16 array to be passed to ICU. */ - len = 0; - err = false; - U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), u, err); - if (err) - return 0; - - /* Normalise the codepoint using NFKD mode. */ - icu_err = U_ZERO_ERROR; - len = unorm_normalize (utf16, len, UNORM_NFKD, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); - if (icu_err) - return 0; - - /* Convert the decomposed form from UTF-16 to UTF-32. */ - icu_err = U_ZERO_ERROR; - u_strToUTF32 ((UChar32*) decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN, &utf32_len, normalized, len, &icu_err); - if (icu_err) - return 0; - - return utf32_len; -} - - -hb_unicode_funcs_t * -hb_icu_get_unicode_funcs (void) -{ - static const hb_unicode_funcs_t _hb_icu_unicode_funcs = { - HB_OBJECT_HEADER_STATIC, - - NULL, /* parent */ - true, /* immutable */ - { -#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name, - HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS -#undef HB_UNICODE_FUNC_IMPLEMENT - } - }; - -#if U_ICU_VERSION_MAJOR_NUM >= 49 - if (!hb_atomic_ptr_get (&normalizer)) { - UErrorCode icu_err = U_ZERO_ERROR; - /* We ignore failure in getNFCInstace(). */ - (void) hb_atomic_ptr_cmpexch (&normalizer, NULL, unorm2_getNFCInstance (&icu_err)); - } -#endif - return const_cast (&_hb_icu_unicode_funcs); -} diff --git a/third_party/harfbuzz-ng/src/hb-mutex-private.hh b/third_party/harfbuzz-ng/src/hb-mutex-private.hh deleted file mode 100644 index ed2703571c19..000000000000 --- a/third_party/harfbuzz-ng/src/hb-mutex-private.hh +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright © 2007 Chris Wilson - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Contributor(s): - * Chris Wilson - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_MUTEX_PRIVATE_HH -#define HB_MUTEX_PRIVATE_HH - -#include "hb-private.hh" - - -/* mutex */ - -/* We need external help for these */ - -#if defined(HB_MUTEX_IMPL_INIT) \ - && defined(hb_mutex_impl_init) \ - && defined(hb_mutex_impl_lock) \ - && defined(hb_mutex_impl_unlock) \ - && defined(hb_mutex_impl_finish) - -/* Defined externally, i.e. in config.h; must have typedef'ed hb_mutex_impl_t as well. */ - - -#elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) - -#include -typedef CRITICAL_SECTION hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT {0} -#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) -#define hb_mutex_impl_init(M) InitializeCriticalSectionEx (M, 0, 0) -#else -#define hb_mutex_impl_init(M) InitializeCriticalSection (M) -#endif -#define hb_mutex_impl_lock(M) EnterCriticalSection (M) -#define hb_mutex_impl_unlock(M) LeaveCriticalSection (M) -#define hb_mutex_impl_finish(M) DeleteCriticalSection (M) - - -#elif !defined(HB_NO_MT) && (defined(HAVE_PTHREAD) || defined(__APPLE__)) - -#include -typedef pthread_mutex_t hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT PTHREAD_MUTEX_INITIALIZER -#define hb_mutex_impl_init(M) pthread_mutex_init (M, NULL) -#define hb_mutex_impl_lock(M) pthread_mutex_lock (M) -#define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M) -#define hb_mutex_impl_finish(M) pthread_mutex_destroy (M) - - -#elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) - -#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) -# include -# define HB_SCHED_YIELD() sched_yield () -#else -# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END -#endif - -/* This actually is not a totally awful implementation. */ -typedef volatile int hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT 0 -#define hb_mutex_impl_init(M) *(M) = 0 -#define hb_mutex_impl_lock(M) HB_STMT_START { while (__sync_lock_test_and_set((M), 1)) HB_SCHED_YIELD (); } HB_STMT_END -#define hb_mutex_impl_unlock(M) __sync_lock_release (M) -#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END - - -#elif !defined(HB_NO_MT) - -#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD) -# include -# define HB_SCHED_YIELD() sched_yield () -#else -# define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END -#endif - -#define HB_MUTEX_INT_NIL 1 /* Warn that fallback implementation is in use. */ -typedef volatile int hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT 0 -#define hb_mutex_impl_init(M) *(M) = 0 -#define hb_mutex_impl_lock(M) HB_STMT_START { while (*(M)) HB_SCHED_YIELD (); (*(M))++; } HB_STMT_END -#define hb_mutex_impl_unlock(M) (*(M))--; -#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END - - -#else /* HB_NO_MT */ - -typedef int hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT 0 -#define hb_mutex_impl_init(M) HB_STMT_START {} HB_STMT_END -#define hb_mutex_impl_lock(M) HB_STMT_START {} HB_STMT_END -#define hb_mutex_impl_unlock(M) HB_STMT_START {} HB_STMT_END -#define hb_mutex_impl_finish(M) HB_STMT_START {} HB_STMT_END - - -#endif - - -#define HB_MUTEX_INIT {HB_MUTEX_IMPL_INIT} - -struct hb_mutex_t -{ - /* TODO Add tracing. */ - - hb_mutex_impl_t m; - - inline void init (void) { hb_mutex_impl_init (&m); } - inline void lock (void) { hb_mutex_impl_lock (&m); } - inline void unlock (void) { hb_mutex_impl_unlock (&m); } - inline void finish (void) { hb_mutex_impl_finish (&m); } -}; - - -#endif /* HB_MUTEX_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-object-private.hh b/third_party/harfbuzz-ng/src/hb-object-private.hh deleted file mode 100644 index 6b73ff92d09b..000000000000 --- a/third_party/harfbuzz-ng/src/hb-object-private.hh +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright © 2007 Chris Wilson - * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Contributor(s): - * Chris Wilson - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OBJECT_PRIVATE_HH -#define HB_OBJECT_PRIVATE_HH - -#include "hb-private.hh" - -#include "hb-atomic-private.hh" -#include "hb-mutex-private.hh" - - -/* Debug */ - -#ifndef HB_DEBUG_OBJECT -#define HB_DEBUG_OBJECT (HB_DEBUG+0) -#endif - - -/* reference_count */ - -#define HB_REFERENCE_COUNT_INERT_VALUE -1 -#define HB_REFERENCE_COUNT_POISON_VALUE -0x0000DEAD -#define HB_REFERENCE_COUNT_INIT {HB_ATOMIC_INT_INIT(HB_REFERENCE_COUNT_INERT_VALUE)} - -struct hb_reference_count_t -{ - hb_atomic_int_t ref_count; - - inline void init (int v) { ref_count.set_unsafe (v); } - inline int get_unsafe (void) const { return ref_count.get_unsafe (); } - inline int inc (void) { return ref_count.inc (); } - inline int dec (void) { return ref_count.dec (); } - inline void finish (void) { ref_count.set_unsafe (HB_REFERENCE_COUNT_POISON_VALUE); } - - inline bool is_inert (void) const { return ref_count.get_unsafe () == HB_REFERENCE_COUNT_INERT_VALUE; } - inline bool is_valid (void) const { return ref_count.get_unsafe () > 0; } -}; - - -/* user_data */ - -#define HB_USER_DATA_ARRAY_INIT {HB_MUTEX_INIT, HB_LOCKABLE_SET_INIT} -struct hb_user_data_array_t -{ - struct hb_user_data_item_t { - hb_user_data_key_t *key; - void *data; - hb_destroy_func_t destroy; - - inline bool operator == (hb_user_data_key_t *other_key) const { return key == other_key; } - inline bool operator == (hb_user_data_item_t &other) const { return key == other.key; } - - void finish (void) { if (destroy) destroy (data); } - }; - - hb_mutex_t lock; - hb_lockable_set_t items; - - inline void init (void) { lock.init (); items.init (); } - - HB_INTERNAL bool set (hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - - HB_INTERNAL void *get (hb_user_data_key_t *key); - - inline void finish (void) { items.finish (lock); lock.finish (); } -}; - - -/* object_header */ - -struct hb_object_header_t -{ - hb_reference_count_t ref_count; - hb_user_data_array_t user_data; - -#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_USER_DATA_ARRAY_INIT} - - private: - ASSERT_POD (); -}; - - -/* object */ - -template -static inline void hb_object_trace (const Type *obj, const char *function) -{ - DEBUG_MSG (OBJECT, (void *) obj, - "%s refcount=%d", - function, - obj ? obj->header.ref_count.get_unsafe () : 0); -} - -template -static inline Type *hb_object_create (void) -{ - Type *obj = (Type *) calloc (1, sizeof (Type)); - - if (unlikely (!obj)) - return obj; - - hb_object_init (obj); - hb_object_trace (obj, HB_FUNC); - return obj; -} -template -static inline void hb_object_init (Type *obj) -{ - obj->header.ref_count.init (1); - obj->header.user_data.init (); -} -template -static inline bool hb_object_is_inert (const Type *obj) -{ - return unlikely (obj->header.ref_count.is_inert ()); -} -template -static inline bool hb_object_is_valid (const Type *obj) -{ - return likely (obj->header.ref_count.is_valid ()); -} -template -static inline Type *hb_object_reference (Type *obj) -{ - hb_object_trace (obj, HB_FUNC); - if (unlikely (!obj || hb_object_is_inert (obj))) - return obj; - assert (hb_object_is_valid (obj)); - obj->header.ref_count.inc (); - return obj; -} -template -static inline bool hb_object_destroy (Type *obj) -{ - hb_object_trace (obj, HB_FUNC); - if (unlikely (!obj || hb_object_is_inert (obj))) - return false; - assert (hb_object_is_valid (obj)); - if (obj->header.ref_count.dec () != 1) - return false; - - obj->header.ref_count.finish (); /* Do this before user_data */ - obj->header.user_data.finish (); - return true; -} -template -static inline bool hb_object_set_user_data (Type *obj, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) -{ - if (unlikely (!obj || hb_object_is_inert (obj))) - return false; - assert (hb_object_is_valid (obj)); - return obj->header.user_data.set (key, data, destroy, replace); -} - -template -static inline void *hb_object_get_user_data (Type *obj, - hb_user_data_key_t *key) -{ - if (unlikely (!obj || hb_object_is_inert (obj))) - return NULL; - assert (hb_object_is_valid (obj)); - return obj->header.user_data.get (key); -} - - -#endif /* HB_OBJECT_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-open-file-private.hh b/third_party/harfbuzz-ng/src/hb-open-file-private.hh deleted file mode 100644 index 152230a0e5f0..000000000000 --- a/third_party/harfbuzz-ng/src/hb-open-file-private.hh +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright © 2007,2008,2009 Red Hat, Inc. - * Copyright © 2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OPEN_FILE_PRIVATE_HH -#define HB_OPEN_FILE_PRIVATE_HH - -#include "hb-open-type-private.hh" - - -namespace OT { - - -/* - * - * The OpenType Font File - * - */ - - -/* - * Organization of an OpenType Font - */ - -struct OpenTypeFontFile; -struct OffsetTable; -struct TTCHeader; - - -typedef struct TableRecord -{ - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - Tag tag; /* 4-byte identifier. */ - CheckSum checkSum; /* CheckSum for this table. */ - ULONG offset; /* Offset from beginning of TrueType font - * file. */ - ULONG length; /* Length of this table. */ - public: - DEFINE_SIZE_STATIC (16); -} OpenTypeTable; - -typedef struct OffsetTable -{ - friend struct OpenTypeFontFile; - - inline unsigned int get_table_count (void) const - { return numTables; } - inline const TableRecord& get_table (unsigned int i) const - { - if (unlikely (i >= numTables)) return Null(TableRecord); - return tables[i]; - } - inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const - { - Tag t; - t.set (tag); - unsigned int count = numTables; - for (unsigned int i = 0; i < count; i++) - { - if (t == tables[i].tag) - { - if (table_index) *table_index = i; - return true; - } - } - if (table_index) *table_index = Index::NOT_FOUND_INDEX; - return false; - } - inline const TableRecord& get_table_by_tag (hb_tag_t tag) const - { - unsigned int table_index; - find_table_index (tag, &table_index); - return get_table (table_index); - } - - public: - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && c->check_array (tables, TableRecord::static_size, numTables)); - } - - protected: - Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */ - USHORT numTables; /* Number of tables. */ - USHORT searchRangeZ; /* (Maximum power of 2 <= numTables) x 16 */ - USHORT entrySelectorZ; /* Log2(maximum power of 2 <= numTables). */ - USHORT rangeShiftZ; /* NumTables x 16-searchRange. */ - TableRecord tables[VAR]; /* TableRecord entries. numTables items */ - public: - DEFINE_SIZE_ARRAY (12, tables); -} OpenTypeFontFace; - - -/* - * TrueType Collections - */ - -struct TTCHeaderVersion1 -{ - friend struct TTCHeader; - - inline unsigned int get_face_count (void) const { return table.len; } - inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (table.sanitize (c, this)); - } - - protected: - Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ - FixedVersion version; /* Version of the TTC Header (1.0), - * 0x00010000u */ - ArrayOf, ULONG> - table; /* Array of offsets to the OffsetTable for each font - * from the beginning of the file */ - public: - DEFINE_SIZE_ARRAY (12, table); -}; - -struct TTCHeader -{ - friend struct OpenTypeFontFile; - - private: - - inline unsigned int get_face_count (void) const - { - switch (u.header.version.major) { - case 2: /* version 2 is compatible with version 1 */ - case 1: return u.version1.get_face_count (); - default:return 0; - } - } - inline const OpenTypeFontFace& get_face (unsigned int i) const - { - switch (u.header.version.major) { - case 2: /* version 2 is compatible with version 1 */ - case 1: return u.version1.get_face (i); - default:return Null(OpenTypeFontFace); - } - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!u.header.version.sanitize (c))) return_trace (false); - switch (u.header.version.major) { - case 2: /* version 2 is compatible with version 1 */ - case 1: return_trace (u.version1.sanitize (c)); - default:return_trace (true); - } - } - - protected: - union { - struct { - Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ - FixedVersion version; /* Version of the TTC Header (1.0 or 2.0), - * 0x00010000u or 0x00020000u */ - } header; - TTCHeaderVersion1 version1; - } u; -}; - - -/* - * OpenType Font File - */ - -struct OpenTypeFontFile -{ - static const hb_tag_t tableTag = HB_TAG ('_','_','_','_'); /* Sanitizer needs this. */ - - static const hb_tag_t CFFTag = HB_TAG ('O','T','T','O'); /* OpenType with Postscript outlines */ - static const hb_tag_t TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ); /* OpenType with TrueType outlines */ - static const hb_tag_t TTCTag = HB_TAG ('t','t','c','f'); /* TrueType Collection */ - static const hb_tag_t TrueTag = HB_TAG ('t','r','u','e'); /* Obsolete Apple TrueType */ - static const hb_tag_t Typ1Tag = HB_TAG ('t','y','p','1'); /* Obsolete Apple Type1 font in SFNT container */ - - inline hb_tag_t get_tag (void) const { return u.tag; } - - inline unsigned int get_face_count (void) const - { - switch (u.tag) { - case CFFTag: /* All the non-collection tags */ - case TrueTag: - case Typ1Tag: - case TrueTypeTag: return 1; - case TTCTag: return u.ttcHeader.get_face_count (); - default: return 0; - } - } - inline const OpenTypeFontFace& get_face (unsigned int i) const - { - switch (u.tag) { - /* Note: for non-collection SFNT data we ignore index. This is because - * Apple dfont container is a container of SFNT's. So each SFNT is a - * non-TTC, but the index is more than zero. */ - case CFFTag: /* All the non-collection tags */ - case TrueTag: - case Typ1Tag: - case TrueTypeTag: return u.fontFace; - case TTCTag: return u.ttcHeader.get_face (i); - default: return Null(OpenTypeFontFace); - } - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!u.tag.sanitize (c))) return_trace (false); - switch (u.tag) { - case CFFTag: /* All the non-collection tags */ - case TrueTag: - case Typ1Tag: - case TrueTypeTag: return_trace (u.fontFace.sanitize (c)); - case TTCTag: return_trace (u.ttcHeader.sanitize (c)); - default: return_trace (true); - } - } - - protected: - union { - Tag tag; /* 4-byte identifier. */ - OpenTypeFontFace fontFace; - TTCHeader ttcHeader; - } u; - public: - DEFINE_SIZE_UNION (4, tag); -}; - - -} /* namespace OT */ - - -#endif /* HB_OPEN_FILE_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-open-type-private.hh b/third_party/harfbuzz-ng/src/hb-open-type-private.hh deleted file mode 100644 index 5ad850bd95b5..000000000000 --- a/third_party/harfbuzz-ng/src/hb-open-type-private.hh +++ /dev/null @@ -1,1046 +0,0 @@ -/* - * Copyright © 2007,2008,2009,2010 Red Hat, Inc. - * Copyright © 2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OPEN_TYPE_PRIVATE_HH -#define HB_OPEN_TYPE_PRIVATE_HH - -#include "hb-private.hh" - - -namespace OT { - - - -/* - * Casts - */ - -/* Cast to struct T, reference to reference */ -template -static inline const Type& CastR(const TObject &X) -{ return reinterpret_cast (X); } -template -static inline Type& CastR(TObject &X) -{ return reinterpret_cast (X); } - -/* Cast to struct T, pointer to pointer */ -template -static inline const Type* CastP(const TObject *X) -{ return reinterpret_cast (X); } -template -static inline Type* CastP(TObject *X) -{ return reinterpret_cast (X); } - -/* StructAtOffset(P,Ofs) returns the struct T& that is placed at memory - * location pointed to by P plus Ofs bytes. */ -template -static inline const Type& StructAtOffset(const void *P, unsigned int offset) -{ return * reinterpret_cast ((const char *) P + offset); } -template -static inline Type& StructAtOffset(void *P, unsigned int offset) -{ return * reinterpret_cast ((char *) P + offset); } - -/* StructAfter(X) returns the struct T& that is placed after X. - * Works with X of variable size also. X must implement get_size() */ -template -static inline const Type& StructAfter(const TObject &X) -{ return StructAtOffset(&X, X.get_size()); } -template -static inline Type& StructAfter(TObject &X) -{ return StructAtOffset(&X, X.get_size()); } - - - -/* - * Size checking - */ - -/* Check _assertion in a method environment */ -#define _DEFINE_INSTANCE_ASSERTION1(_line, _assertion) \ - inline void _instance_assertion_on_line_##_line (void) const \ - { \ - ASSERT_STATIC (_assertion); \ - ASSERT_INSTANCE_POD (*this); /* Make sure it's POD. */ \ - } -# define _DEFINE_INSTANCE_ASSERTION0(_line, _assertion) _DEFINE_INSTANCE_ASSERTION1 (_line, _assertion) -# define DEFINE_INSTANCE_ASSERTION(_assertion) _DEFINE_INSTANCE_ASSERTION0 (__LINE__, _assertion) - -/* Check that _code compiles in a method environment */ -#define _DEFINE_COMPILES_ASSERTION1(_line, _code) \ - inline void _compiles_assertion_on_line_##_line (void) const \ - { _code; } -# define _DEFINE_COMPILES_ASSERTION0(_line, _code) _DEFINE_COMPILES_ASSERTION1 (_line, _code) -# define DEFINE_COMPILES_ASSERTION(_code) _DEFINE_COMPILES_ASSERTION0 (__LINE__, _code) - - -#define DEFINE_SIZE_STATIC(size) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \ - static const unsigned int static_size = (size); \ - static const unsigned int min_size = (size) - -/* Size signifying variable-sized array */ -#define VAR 1 - -#define DEFINE_SIZE_UNION(size, _member) \ - DEFINE_INSTANCE_ASSERTION (this->u._member.static_size == (size)); \ - static const unsigned int min_size = (size) - -#define DEFINE_SIZE_MIN(size) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) >= (size)); \ - static const unsigned int min_size = (size) - -#define DEFINE_SIZE_ARRAY(size, array) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (array[0])); \ - DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \ - static const unsigned int min_size = (size) - -#define DEFINE_SIZE_ARRAY2(size, array1, array2) \ - DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + sizeof (this->array1[0]) + sizeof (this->array2[0])); \ - DEFINE_COMPILES_ASSERTION ((void) array1[0].static_size; (void) array2[0].static_size) \ - static const unsigned int min_size = (size) - - - -/* - * Null objects - */ - -/* Global nul-content Null pool. Enlarge as necessary. */ -/* TODO This really should be a extern HB_INTERNAL and defined somewhere... */ -static const void *_NullPool[(256+8) / sizeof (void *)]; - -/* Generic nul-content Null objects. */ -template -static inline const Type& Null (void) { - ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool)); - return *CastP (_NullPool); -} - -/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ -#define DEFINE_NULL_DATA(Type, data) \ -static const char _Null##Type[sizeof (Type) + 1] = data; /* +1 is for nul-termination in data */ \ -template <> \ -/*static*/ inline const Type& Null (void) { \ - return *CastP (_Null##Type); \ -} /* The following line really exists such that we end in a place needing semicolon */ \ -ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type)) - -/* Accessor macro. */ -#define Null(Type) Null() - - -/* - * Dispatch - */ - -template -struct hb_dispatch_context_t -{ - static const unsigned int max_debug_depth = MaxDebugDepth; - typedef Return return_t; - template - inline bool may_dispatch (const T *obj, const F *format) { return true; } - static return_t no_dispatch_return_value (void) { return Context::default_return_value (); } -}; - - -/* - * Sanitize - */ - -#ifndef HB_DEBUG_SANITIZE -#define HB_DEBUG_SANITIZE (HB_DEBUG+0) -#endif - - -#define TRACE_SANITIZE(this) \ - hb_auto_trace_t trace \ - (&c->debug_depth, c->get_name (), this, HB_FUNC, \ - ""); - -/* This limits sanitizing time on really broken fonts. */ -#ifndef HB_SANITIZE_MAX_EDITS -#define HB_SANITIZE_MAX_EDITS 8 -#endif - -struct hb_sanitize_context_t : - hb_dispatch_context_t -{ - inline hb_sanitize_context_t (void) : - debug_depth (0), - start (NULL), end (NULL), - writable (false), edit_count (0), - blob (NULL) {} - - inline const char *get_name (void) { return "SANITIZE"; } - template - inline bool may_dispatch (const T *obj, const F *format) - { return format->sanitize (this); } - template - inline return_t dispatch (const T &obj) { return obj.sanitize (this); } - static return_t default_return_value (void) { return true; } - static return_t no_dispatch_return_value (void) { return false; } - bool stop_sublookup_iteration (const return_t r) const { return !r; } - - inline void init (hb_blob_t *b) - { - this->blob = hb_blob_reference (b); - this->writable = false; - } - - inline void start_processing (void) - { - this->start = hb_blob_get_data (this->blob, NULL); - this->end = this->start + hb_blob_get_length (this->blob); - assert (this->start <= this->end); /* Must not overflow. */ - this->edit_count = 0; - this->debug_depth = 0; - - DEBUG_MSG_LEVEL (SANITIZE, start, 0, +1, - "start [%p..%p] (%lu bytes)", - this->start, this->end, - (unsigned long) (this->end - this->start)); - } - - inline void end_processing (void) - { - DEBUG_MSG_LEVEL (SANITIZE, this->start, 0, -1, - "end [%p..%p] %u edit requests", - this->start, this->end, this->edit_count); - - hb_blob_destroy (this->blob); - this->blob = NULL; - this->start = this->end = NULL; - } - - inline bool check_range (const void *base, unsigned int len) const - { - const char *p = (const char *) base; - bool ok = this->start <= p && p <= this->end && (unsigned int) (this->end - p) >= len; - - DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, - "check_range [%p..%p] (%d bytes) in [%p..%p] -> %s", - p, p + len, len, - this->start, this->end, - ok ? "OK" : "OUT-OF-RANGE"); - - return likely (ok); - } - - inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const - { - const char *p = (const char *) base; - bool overflows = _hb_unsigned_int_mul_overflows (len, record_size); - unsigned int array_size = record_size * len; - bool ok = !overflows && this->check_range (base, array_size); - - DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, - "check_array [%p..%p] (%d*%d=%d bytes) in [%p..%p] -> %s", - p, p + (record_size * len), record_size, len, (unsigned int) array_size, - this->start, this->end, - overflows ? "OVERFLOWS" : ok ? "OK" : "OUT-OF-RANGE"); - - return likely (ok); - } - - template - inline bool check_struct (const Type *obj) const - { - return likely (this->check_range (obj, obj->min_size)); - } - - inline bool may_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED) - { - if (this->edit_count >= HB_SANITIZE_MAX_EDITS) - return false; - - const char *p = (const char *) base; - this->edit_count++; - - DEBUG_MSG_LEVEL (SANITIZE, p, this->debug_depth+1, 0, - "may_edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s", - this->edit_count, - p, p + len, len, - this->start, this->end, - this->writable ? "GRANTED" : "DENIED"); - - return this->writable; - } - - template - inline bool try_set (const Type *obj, const ValueType &v) { - if (this->may_edit (obj, obj->static_size)) { - const_cast (obj)->set (v); - return true; - } - return false; - } - - mutable unsigned int debug_depth; - const char *start, *end; - bool writable; - unsigned int edit_count; - hb_blob_t *blob; -}; - - - -/* Template to sanitize an object. */ -template -struct Sanitizer -{ - static hb_blob_t *sanitize (hb_blob_t *blob) { - hb_sanitize_context_t c[1]; - bool sane; - - /* TODO is_sane() stuff */ - - c->init (blob); - - retry: - DEBUG_MSG_FUNC (SANITIZE, c->start, "start"); - - c->start_processing (); - - if (unlikely (!c->start)) { - c->end_processing (); - return blob; - } - - Type *t = CastP (const_cast (c->start)); - - sane = t->sanitize (c); - if (sane) { - if (c->edit_count) { - DEBUG_MSG_FUNC (SANITIZE, c->start, "passed first round with %d edits; going for second round", c->edit_count); - - /* sanitize again to ensure no toe-stepping */ - c->edit_count = 0; - sane = t->sanitize (c); - if (c->edit_count) { - DEBUG_MSG_FUNC (SANITIZE, c->start, "requested %d edits in second round; FAILLING", c->edit_count); - sane = false; - } - } - } else { - unsigned int edit_count = c->edit_count; - if (edit_count && !c->writable) { - c->start = hb_blob_get_data_writable (blob, NULL); - c->end = c->start + hb_blob_get_length (blob); - - if (c->start) { - c->writable = true; - /* ok, we made it writable by relocating. try again */ - DEBUG_MSG_FUNC (SANITIZE, c->start, "retry"); - goto retry; - } - } - } - - c->end_processing (); - - DEBUG_MSG_FUNC (SANITIZE, c->start, sane ? "PASSED" : "FAILED"); - if (sane) - return blob; - else { - hb_blob_destroy (blob); - return hb_blob_get_empty (); - } - } - - static const Type* lock_instance (hb_blob_t *blob) { - hb_blob_make_immutable (blob); - const char *base = hb_blob_get_data (blob, NULL); - return unlikely (!base) ? &Null(Type) : CastP (base); - } -}; - - - -/* - * Serialize - */ - -#ifndef HB_DEBUG_SERIALIZE -#define HB_DEBUG_SERIALIZE (HB_DEBUG+0) -#endif - - -#define TRACE_SERIALIZE(this) \ - hb_auto_trace_t trace \ - (&c->debug_depth, "SERIALIZE", c, HB_FUNC, \ - ""); - - -struct hb_serialize_context_t -{ - inline hb_serialize_context_t (void *start_, unsigned int size) - { - this->start = (char *) start_; - this->end = this->start + size; - - this->ran_out_of_room = false; - this->head = this->start; - this->debug_depth = 0; - } - - template - inline Type *start_serialize (void) - { - DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, +1, - "start [%p..%p] (%lu bytes)", - this->start, this->end, - (unsigned long) (this->end - this->start)); - - return start_embed (); - } - - inline void end_serialize (void) - { - DEBUG_MSG_LEVEL (SERIALIZE, this->start, 0, -1, - "end [%p..%p] serialized %d bytes; %s", - this->start, this->end, - (int) (this->head - this->start), - this->ran_out_of_room ? "RAN OUT OF ROOM" : "did not ran out of room"); - - } - - template - inline Type *copy (void) - { - assert (!this->ran_out_of_room); - unsigned int len = this->head - this->start; - void *p = malloc (len); - if (p) - memcpy (p, this->start, len); - return reinterpret_cast (p); - } - - template - inline Type *allocate_size (unsigned int size) - { - if (unlikely (this->ran_out_of_room || this->end - this->head < ptrdiff_t (size))) { - this->ran_out_of_room = true; - return NULL; - } - memset (this->head, 0, size); - char *ret = this->head; - this->head += size; - return reinterpret_cast (ret); - } - - template - inline Type *allocate_min (void) - { - return this->allocate_size (Type::min_size); - } - - template - inline Type *start_embed (void) - { - Type *ret = reinterpret_cast (this->head); - return ret; - } - - template - inline Type *embed (const Type &obj) - { - unsigned int size = obj.get_size (); - Type *ret = this->allocate_size (size); - if (unlikely (!ret)) return NULL; - memcpy (ret, obj, size); - return ret; - } - - template - inline Type *extend_min (Type &obj) - { - unsigned int size = obj.min_size; - assert (this->start <= (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return NULL; - return reinterpret_cast (&obj); - } - - template - inline Type *extend (Type &obj) - { - unsigned int size = obj.get_size (); - assert (this->start < (char *) &obj && (char *) &obj <= this->head && (char *) &obj + size >= this->head); - if (unlikely (!this->allocate_size (((char *) &obj) + size - this->head))) return NULL; - return reinterpret_cast (&obj); - } - - inline void truncate (void *new_head) - { - assert (this->start < new_head && new_head <= this->head); - this->head = (char *) new_head; - } - - unsigned int debug_depth; - char *start, *end, *head; - bool ran_out_of_room; -}; - -template -struct Supplier -{ - inline Supplier (const Type *array, unsigned int len_) - { - head = array; - len = len_; - } - inline const Type operator [] (unsigned int i) const - { - if (unlikely (i >= len)) return Type (); - return head[i]; - } - - inline void advance (unsigned int count) - { - if (unlikely (count > len)) - count = len; - len -= count; - head += count; - } - - private: - inline Supplier (const Supplier &); /* Disallow copy */ - inline Supplier& operator= (const Supplier &); /* Disallow copy */ - - unsigned int len; - const Type *head; -}; - - - - -/* - * - * The OpenType Font File: Data Types - */ - - -/* "The following data types are used in the OpenType font file. - * All OpenType fonts use Motorola-style byte ordering (Big Endian):" */ - -/* - * Int types - */ - - -template struct BEInt; - -template -struct BEInt -{ - public: - inline void set (Type V) - { - v = V; - } - inline operator Type (void) const - { - return v; - } - private: uint8_t v; -}; -template -struct BEInt -{ - public: - inline void set (Type V) - { - v[0] = (V >> 8) & 0xFF; - v[1] = (V ) & 0xFF; - } - inline operator Type (void) const - { - return (v[0] << 8) - + (v[1] ); - } - private: uint8_t v[2]; -}; -template -struct BEInt -{ - public: - inline void set (Type V) - { - v[0] = (V >> 16) & 0xFF; - v[1] = (V >> 8) & 0xFF; - v[2] = (V ) & 0xFF; - } - inline operator Type (void) const - { - return (v[0] << 16) - + (v[1] << 8) - + (v[2] ); - } - private: uint8_t v[3]; -}; -template -struct BEInt -{ - public: - inline void set (Type V) - { - v[0] = (V >> 24) & 0xFF; - v[1] = (V >> 16) & 0xFF; - v[2] = (V >> 8) & 0xFF; - v[3] = (V ) & 0xFF; - } - inline operator Type (void) const - { - return (v[0] << 24) - + (v[1] << 16) - + (v[2] << 8) - + (v[3] ); - } - private: uint8_t v[4]; -}; - -/* Integer types in big-endian order and no alignment requirement */ -template -struct IntType -{ - inline void set (Type i) { v.set (i); } - inline operator Type(void) const { return v; } - inline bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } - inline bool operator != (const IntType &o) const { return !(*this == o); } - static inline int cmp (const IntType *a, const IntType *b) { return b->cmp (*a); } - inline int cmp (Type a) const - { - Type b = v; - if (sizeof (Type) < sizeof (int)) - return (int) a - (int) b; - else - return a < b ? -1 : a == b ? 0 : +1; - } - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this))); - } - protected: - BEInt v; - public: - DEFINE_SIZE_STATIC (Size); -}; - -typedef IntType BYTE; /* 8-bit unsigned integer. */ -typedef IntType USHORT; /* 16-bit unsigned integer. */ -typedef IntType SHORT; /* 16-bit signed integer. */ -typedef IntType ULONG; /* 32-bit unsigned integer. */ -typedef IntType LONG; /* 32-bit signed integer. */ -typedef IntType UINT24; /* 24-bit unsigned integer. */ - -/* 16-bit signed integer (SHORT) that describes a quantity in FUnits. */ -typedef SHORT FWORD; - -/* 16-bit unsigned integer (USHORT) that describes a quantity in FUnits. */ -typedef USHORT UFWORD; - -/* Date represented in number of seconds since 12:00 midnight, January 1, - * 1904. The value is represented as a signed 64-bit integer. */ -struct LONGDATETIME -{ - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this))); - } - protected: - LONG major; - ULONG minor; - public: - DEFINE_SIZE_STATIC (8); -}; - -/* Array of four uint8s (length = 32 bits) used to identify a script, language - * system, feature, or baseline */ -struct Tag : ULONG -{ - /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ - inline operator const char* (void) const { return reinterpret_cast (&this->v); } - inline operator char* (void) { return reinterpret_cast (&this->v); } - public: - DEFINE_SIZE_STATIC (4); -}; -DEFINE_NULL_DATA (Tag, " "); - -/* Glyph index number, same as uint16 (length = 16 bits) */ -struct GlyphID : USHORT { - static inline int cmp (const GlyphID *a, const GlyphID *b) { return b->USHORT::cmp (*a); } - inline int cmp (hb_codepoint_t a) const { return (int) a - (int) *this; } -}; - -/* Script/language-system/feature index */ -struct Index : USHORT { - static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; -}; -DEFINE_NULL_DATA (Index, "\xff\xff"); - -/* Offset, Null offset = 0 */ -template -struct Offset : Type -{ - inline bool is_null (void) const { return 0 == *this; } - public: - DEFINE_SIZE_STATIC (sizeof(Type)); -}; - - -/* CheckSum */ -struct CheckSum : ULONG -{ - /* This is reference implementation from the spec. */ - static inline uint32_t CalcTableChecksum (const ULONG *Table, uint32_t Length) - { - uint32_t Sum = 0L; - const ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size; - - while (Table < EndPtr) - Sum += *Table++; - return Sum; - } - - /* Note: data should be 4byte aligned and have 4byte padding at the end. */ - inline void set_for_data (const void *data, unsigned int length) - { set (CalcTableChecksum ((const ULONG *) data, length)); } - - public: - DEFINE_SIZE_STATIC (4); -}; - - -/* - * Version Numbers - */ - -struct FixedVersion -{ - inline uint32_t to_int (void) const { return (major << 16) + minor; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - USHORT major; - USHORT minor; - public: - DEFINE_SIZE_STATIC (4); -}; - - - -/* - * Template subclasses of Offset that do the dereferencing. - * Use: (base+offset) - */ - -template -struct OffsetTo : Offset -{ - inline const Type& operator () (const void *base) const - { - unsigned int offset = *this; - if (unlikely (!offset)) return Null(Type); - return StructAtOffset (base, offset); - } - - inline Type& serialize (hb_serialize_context_t *c, const void *base) - { - Type *t = c->start_embed (); - this->set ((char *) t - (char *) base); /* TODO(serialize) Overflow? */ - return *t; - } - - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) return_trace (false); - unsigned int offset = *this; - if (unlikely (!offset)) return_trace (true); - const Type &obj = StructAtOffset (base, offset); - return_trace (likely (obj.sanitize (c)) || neuter (c)); - } - template - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) return_trace (false); - unsigned int offset = *this; - if (unlikely (!offset)) return_trace (true); - const Type &obj = StructAtOffset (base, offset); - return_trace (likely (obj.sanitize (c, user_data)) || neuter (c)); - } - - /* Set the offset to Null */ - inline bool neuter (hb_sanitize_context_t *c) const { - return c->try_set (this, 0); - } - DEFINE_SIZE_STATIC (sizeof(OffsetType)); -}; -template -static inline const Type& operator + (const Base &base, const OffsetTo &offset) { return offset (base); } -template -static inline Type& operator + (Base &base, OffsetTo &offset) { return offset (base); } - - -/* - * Array Types - */ - -/* An array with a number of elements. */ -template -struct ArrayOf -{ - const Type *sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const - { - unsigned int count = len; - if (unlikely (start_offset > count)) - count = 0; - else - count -= start_offset; - count = MIN (count, *pcount); - *pcount = count; - return array + start_offset; - } - - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= len)) return Null(Type); - return array[i]; - } - inline Type& operator [] (unsigned int i) - { - return array[i]; - } - inline unsigned int get_size (void) const - { return len.static_size + len * Type::static_size; } - - inline bool serialize (hb_serialize_context_t *c, - unsigned int items_len) - { - TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - len.set (items_len); /* TODO(serialize) Overflow? */ - if (unlikely (!c->extend (*this))) return_trace (false); - return_trace (true); - } - - inline bool serialize (hb_serialize_context_t *c, - Supplier &items, - unsigned int items_len) - { - TRACE_SERIALIZE (this); - if (unlikely (!serialize (c, items_len))) return_trace (false); - for (unsigned int i = 0; i < items_len; i++) - array[i] = items[i]; - items.advance (items_len); - return_trace (true); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && array[0].sanitize (c)); - - return_trace (true); - } - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (unlikely (!array[i].sanitize (c, base))) - return_trace (false); - return_trace (true); - } - template - inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (unlikely (!array[i].sanitize (c, base, user_data))) - return_trace (false); - return_trace (true); - } - - template - inline int lsearch (const SearchType &x) const - { - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!this->array[i].cmp (x)) - return i; - return -1; - } - - private: - inline bool sanitize_shallow (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && c->check_array (array, Type::static_size, len)); - } - - public: - LenType len; - Type array[VAR]; - public: - DEFINE_SIZE_ARRAY (sizeof (LenType), array); -}; - -/* Array of Offset's */ -template -struct OffsetArrayOf : ArrayOf > {}; - -/* Array of offsets relative to the beginning of the array itself. */ -template -struct OffsetListOf : OffsetArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= this->len)) return Null(Type); - return this+this->array[i]; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (OffsetArrayOf::sanitize (c, this)); - } - template - inline bool sanitize (hb_sanitize_context_t *c, T user_data) const - { - TRACE_SANITIZE (this); - return_trace (OffsetArrayOf::sanitize (c, this, user_data)); - } -}; - - -/* An array starting at second element. */ -template -struct HeadlessArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= len || !i)) return Null(Type); - return array[i-1]; - } - inline unsigned int get_size (void) const - { return len.static_size + (len ? len - 1 : 0) * Type::static_size; } - - inline bool serialize (hb_serialize_context_t *c, - Supplier &items, - unsigned int items_len) - { - TRACE_SERIALIZE (this); - if (unlikely (!c->extend_min (*this))) return_trace (false); - len.set (items_len); /* TODO(serialize) Overflow? */ - if (unlikely (!items_len)) return_trace (true); - if (unlikely (!c->extend (*this))) return_trace (false); - for (unsigned int i = 0; i < items_len - 1; i++) - array[i] = items[i]; - items.advance (items_len - 1); - return_trace (true); - } - - inline bool sanitize_shallow (hb_sanitize_context_t *c) const - { - return c->check_struct (this) - && c->check_array (this, Type::static_size, len); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && array[0].sanitize (c)); - - return_trace (true); - } - - LenType len; - Type array[VAR]; - public: - DEFINE_SIZE_ARRAY (sizeof (LenType), array); -}; - - -/* An array with sorted elements. Supports binary searching. */ -template -struct SortedArrayOf : ArrayOf -{ - template - inline int bsearch (const SearchType &x) const - { - /* Hand-coded bsearch here since this is in the hot inner loop. */ - int min = 0, max = (int) this->len - 1; - while (min <= max) - { - int mid = (min + max) / 2; - int c = this->array[mid].cmp (x); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - return mid; - } - return -1; - } -}; - - -} /* namespace OT */ - - -#endif /* HB_OPEN_TYPE_PRIVATE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-ot-cmap-table.hh b/third_party/harfbuzz-ng/src/hb-ot-cmap-table.hh deleted file mode 100644 index c9161f0ef4c6..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-cmap-table.hh +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright © 2014 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OT_CMAP_TABLE_HH -#define HB_OT_CMAP_TABLE_HH - -#include "hb-open-type-private.hh" - - -namespace OT { - - -/* - * cmap -- Character To Glyph Index Mapping Table - */ - -#define HB_OT_TAG_cmap HB_TAG('c','m','a','p') - - -struct CmapSubtableFormat0 -{ - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const - { - hb_codepoint_t gid = codepoint < 256 ? glyphIdArray[codepoint] : 0; - if (!gid) - return false; - *glyph = gid; - return true; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - protected: - USHORT format; /* Format number is set to 0. */ - USHORT lengthZ; /* Byte length of this subtable. */ - USHORT languageZ; /* Ignore. */ - BYTE glyphIdArray[256];/* An array that maps character - * code to glyph index values. */ - public: - DEFINE_SIZE_STATIC (6 + 256); -}; - -struct CmapSubtableFormat4 -{ - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const - { - unsigned int segCount; - const USHORT *endCount; - const USHORT *startCount; - const USHORT *idDelta; - const USHORT *idRangeOffset; - const USHORT *glyphIdArray; - unsigned int glyphIdArrayLength; - - segCount = this->segCountX2 / 2; - endCount = this->values; - startCount = endCount + segCount + 1; - idDelta = startCount + segCount; - idRangeOffset = idDelta + segCount; - glyphIdArray = idRangeOffset + segCount; - glyphIdArrayLength = (this->length - 16 - 8 * segCount) / 2; - - /* Custom two-array bsearch. */ - int min = 0, max = (int) segCount - 1; - unsigned int i; - while (min <= max) - { - int mid = (min + max) / 2; - if (codepoint < startCount[mid]) - max = mid - 1; - else if (codepoint > endCount[mid]) - min = mid + 1; - else - { - i = mid; - goto found; - } - } - return false; - - found: - hb_codepoint_t gid; - unsigned int rangeOffset = idRangeOffset[i]; - if (rangeOffset == 0) - gid = codepoint + idDelta[i]; - else - { - /* Somebody has been smoking... */ - unsigned int index = rangeOffset / 2 + (codepoint - startCount[i]) + i - segCount; - if (unlikely (index >= glyphIdArrayLength)) - return false; - gid = glyphIdArray[index]; - if (unlikely (!gid)) - return false; - gid += idDelta[i]; - } - - *glyph = gid & 0xFFFFu; - return true; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) - return_trace (false); - - if (unlikely (!c->check_range (this, length))) - { - /* Some broken fonts have too long of a "length" value. - * If that is the case, just change the value to truncate - * the subtable at the end of the blob. */ - uint16_t new_length = (uint16_t) MIN ((uintptr_t) 65535, - (uintptr_t) (c->end - - (char *) this)); - if (!c->try_set (&length, new_length)) - return_trace (false); - } - - return_trace (16 + 4 * (unsigned int) segCountX2 <= length); - } - - protected: - USHORT format; /* Format number is set to 4. */ - USHORT length; /* This is the length in bytes of the - * subtable. */ - USHORT languageZ; /* Ignore. */ - USHORT segCountX2; /* 2 x segCount. */ - USHORT searchRangeZ; /* 2 * (2**floor(log2(segCount))) */ - USHORT entrySelectorZ; /* log2(searchRange/2) */ - USHORT rangeShiftZ; /* 2 x segCount - searchRange */ - - USHORT values[VAR]; -#if 0 - USHORT endCount[segCount]; /* End characterCode for each segment, - * last=0xFFFFu. */ - USHORT reservedPad; /* Set to 0. */ - USHORT startCount[segCount]; /* Start character code for each segment. */ - SHORT idDelta[segCount]; /* Delta for all character codes in segment. */ - USHORT idRangeOffset[segCount];/* Offsets into glyphIdArray or 0 */ - USHORT glyphIdArray[VAR]; /* Glyph index array (arbitrary length) */ -#endif - - public: - DEFINE_SIZE_ARRAY (14, values); -}; - -struct CmapSubtableLongGroup -{ - friend struct CmapSubtableFormat12; - friend struct CmapSubtableFormat13; - - int cmp (hb_codepoint_t codepoint) const - { - if (codepoint < startCharCode) return -1; - if (codepoint > endCharCode) return +1; - return 0; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - private: - ULONG startCharCode; /* First character code in this group. */ - ULONG endCharCode; /* Last character code in this group. */ - ULONG glyphID; /* Glyph index; interpretation depends on - * subtable format. */ - public: - DEFINE_SIZE_STATIC (12); -}; - -template -struct CmapSubtableTrimmed -{ - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const - { - /* Rely on our implicit array bound-checking. */ - hb_codepoint_t gid = glyphIdArray[codepoint - startCharCode]; - if (!gid) - return false; - *glyph = gid; - return true; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && glyphIdArray.sanitize (c)); - } - - protected: - UINT formatReserved; /* Subtable format and (maybe) padding. */ - UINT lengthZ; /* Byte length of this subtable. */ - UINT languageZ; /* Ignore. */ - UINT startCharCode; /* First character code covered. */ - ArrayOf - glyphIdArray; /* Array of glyph index values for character - * codes in the range. */ - public: - DEFINE_SIZE_ARRAY (5 * sizeof (UINT), glyphIdArray); -}; - -struct CmapSubtableFormat6 : CmapSubtableTrimmed {}; -struct CmapSubtableFormat10 : CmapSubtableTrimmed {}; - -template -struct CmapSubtableLongSegmented -{ - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const - { - int i = groups.bsearch (codepoint); - if (i == -1) - return false; - *glyph = T::group_get_glyph (groups[i], codepoint); - return true; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && groups.sanitize (c)); - } - - protected: - USHORT format; /* Subtable format; set to 12. */ - USHORT reservedZ; /* Reserved; set to 0. */ - ULONG lengthZ; /* Byte length of this subtable. */ - ULONG languageZ; /* Ignore. */ - SortedArrayOf - groups; /* Groupings. */ - public: - DEFINE_SIZE_ARRAY (16, groups); -}; - -struct CmapSubtableFormat12 : CmapSubtableLongSegmented -{ - static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, - hb_codepoint_t u) - { return group.glyphID + (u - group.startCharCode); } -}; - -struct CmapSubtableFormat13 : CmapSubtableLongSegmented -{ - static inline hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, - hb_codepoint_t u HB_UNUSED) - { return group.glyphID; } -}; - -typedef enum -{ - GLYPH_VARIANT_NOT_FOUND = 0, - GLYPH_VARIANT_FOUND = 1, - GLYPH_VARIANT_USE_DEFAULT = 2 -} glyph_variant_t; - -struct UnicodeValueRange -{ - inline int cmp (const hb_codepoint_t &codepoint) const - { - if (codepoint < startUnicodeValue) return -1; - if (codepoint > startUnicodeValue + additionalCount) return +1; - return 0; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - UINT24 startUnicodeValue; /* First value in this range. */ - BYTE additionalCount; /* Number of additional values in this - * range. */ - public: - DEFINE_SIZE_STATIC (4); -}; - -typedef SortedArrayOf DefaultUVS; - -struct UVSMapping -{ - inline int cmp (const hb_codepoint_t &codepoint) const - { - return unicodeValue.cmp (codepoint); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - UINT24 unicodeValue; /* Base Unicode value of the UVS */ - GlyphID glyphID; /* Glyph ID of the UVS */ - public: - DEFINE_SIZE_STATIC (5); -}; - -typedef SortedArrayOf NonDefaultUVS; - -struct VariationSelectorRecord -{ - inline glyph_variant_t get_glyph (hb_codepoint_t codepoint, - hb_codepoint_t *glyph, - const void *base) const - { - int i; - const DefaultUVS &defaults = base+defaultUVS; - i = defaults.bsearch (codepoint); - if (i != -1) - return GLYPH_VARIANT_USE_DEFAULT; - const NonDefaultUVS &nonDefaults = base+nonDefaultUVS; - i = nonDefaults.bsearch (codepoint); - if (i != -1) - { - *glyph = nonDefaults[i].glyphID; - return GLYPH_VARIANT_FOUND; - } - return GLYPH_VARIANT_NOT_FOUND; - } - - inline int cmp (const hb_codepoint_t &variation_selector) const - { - return varSelector.cmp (variation_selector); - } - - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - defaultUVS.sanitize (c, base) && - nonDefaultUVS.sanitize (c, base)); - } - - UINT24 varSelector; /* Variation selector. */ - OffsetTo - defaultUVS; /* Offset to Default UVS Table. May be 0. */ - OffsetTo - nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */ - public: - DEFINE_SIZE_STATIC (11); -}; - -struct CmapSubtableFormat14 -{ - inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const - { - return record[record.bsearch(variation_selector)].get_glyph (codepoint, glyph, this); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - record.sanitize (c, this)); - } - - protected: - USHORT format; /* Format number is set to 0. */ - ULONG lengthZ; /* Byte length of this subtable. */ - SortedArrayOf - record; /* Variation selector records; sorted - * in increasing order of `varSelector'. */ - public: - DEFINE_SIZE_ARRAY (10, record); -}; - -struct CmapSubtable -{ - /* Note: We intentionally do NOT implement subtable formats 2 and 8. */ - - inline bool get_glyph (hb_codepoint_t codepoint, - hb_codepoint_t *glyph) const - { - switch (u.format) { - case 0: return u.format0 .get_glyph(codepoint, glyph); - case 4: return u.format4 .get_glyph(codepoint, glyph); - case 6: return u.format6 .get_glyph(codepoint, glyph); - case 10: return u.format10.get_glyph(codepoint, glyph); - case 12: return u.format12.get_glyph(codepoint, glyph); - case 13: return u.format13.get_glyph(codepoint, glyph); - case 14: - default: return false; - } - } - - inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const - { - switch (u.format) { - case 14: return u.format14.get_glyph_variant(codepoint, variation_selector, glyph); - default: return GLYPH_VARIANT_NOT_FOUND; - } - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (!u.format.sanitize (c)) return_trace (false); - switch (u.format) { - case 0: return_trace (u.format0 .sanitize (c)); - case 4: return_trace (u.format4 .sanitize (c)); - case 6: return_trace (u.format6 .sanitize (c)); - case 10: return_trace (u.format10.sanitize (c)); - case 12: return_trace (u.format12.sanitize (c)); - case 13: return_trace (u.format13.sanitize (c)); - case 14: return_trace (u.format14.sanitize (c)); - default:return_trace (true); - } - } - - protected: - union { - USHORT format; /* Format identifier */ - CmapSubtableFormat0 format0; - CmapSubtableFormat4 format4; - CmapSubtableFormat6 format6; - CmapSubtableFormat10 format10; - CmapSubtableFormat12 format12; - CmapSubtableFormat13 format13; - CmapSubtableFormat14 format14; - } u; - public: - DEFINE_SIZE_UNION (2, format); -}; - - -struct EncodingRecord -{ - inline int cmp (const EncodingRecord &other) const - { - int ret; - ret = platformID.cmp (other.platformID); - if (ret) return ret; - ret = encodingID.cmp (other.encodingID); - if (ret) return ret; - return 0; - } - - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - subtable.sanitize (c, base)); - } - - USHORT platformID; /* Platform ID. */ - USHORT encodingID; /* Platform-specific encoding ID. */ - OffsetTo - subtable; /* Byte offset from beginning of table to the subtable for this encoding. */ - public: - DEFINE_SIZE_STATIC (8); -}; - -struct cmap -{ - static const hb_tag_t tableTag = HB_OT_TAG_cmap; - - inline const CmapSubtable *find_subtable (unsigned int platform_id, - unsigned int encoding_id) const - { - EncodingRecord key; - key.platformID.set (platform_id); - key.encodingID.set (encoding_id); - - /* Note: We can use bsearch, but since it has no performance - * implications, we use lsearch and as such accept fonts with - * unsorted subtable list. */ - int result = encodingRecord./*bsearch*/lsearch (key); - if (result == -1 || !encodingRecord[result].subtable) - return NULL; - - return &(this+encodingRecord[result].subtable); - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - likely (version == 0) && - encodingRecord.sanitize (c, this)); - } - - USHORT version; /* Table version number (0). */ - SortedArrayOf - encodingRecord; /* Encoding tables. */ - public: - DEFINE_SIZE_ARRAY (4, encodingRecord); -}; - - -} /* namespace OT */ - - -#endif /* HB_OT_CMAP_TABLE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-ot-font.cc b/third_party/harfbuzz-ng/src/hb-ot-font.cc deleted file mode 100644 index 8d3330070b18..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-font.cc +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright © 2011,2014 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod, Roozbeh Pournader - */ - -#include "hb-private.hh" - -#include "hb-ot.h" - -#include "hb-font-private.hh" - -#include "hb-ot-cmap-table.hh" -#include "hb-ot-glyf-table.hh" -#include "hb-ot-head-table.hh" -#include "hb-ot-hhea-table.hh" -#include "hb-ot-hmtx-table.hh" - - -struct hb_ot_face_metrics_accelerator_t -{ - unsigned int num_metrics; - unsigned int num_advances; - unsigned int default_advance; - const OT::_mtx *table; - hb_blob_t *blob; - - inline void init (hb_face_t *face, - hb_tag_t _hea_tag, hb_tag_t _mtx_tag) - { - this->default_advance = face->get_upem (); - - hb_blob_t *_hea_blob = OT::Sanitizer::sanitize (face->reference_table (_hea_tag)); - const OT::_hea *_hea = OT::Sanitizer::lock_instance (_hea_blob); - this->num_advances = _hea->numberOfLongMetrics; - hb_blob_destroy (_hea_blob); - - this->blob = OT::Sanitizer::sanitize (face->reference_table (_mtx_tag)); - - /* Cap num_metrics() and num_advances() based on table length. */ - unsigned int len = hb_blob_get_length (this->blob); - if (unlikely (this->num_advances * 4 > len)) - this->num_advances = len / 4; - this->num_metrics = this->num_advances + (len - 4 * this->num_advances) / 2; - - /* We MUST set num_metrics to zero if num_advances is zero. - * Our get_advance() depends on that. */ - if (unlikely (!this->num_advances)) - { - this->num_metrics = this->num_advances = 0; - hb_blob_destroy (this->blob); - this->blob = hb_blob_get_empty (); - } - this->table = OT::Sanitizer::lock_instance (this->blob); - } - - inline void fini (void) - { - hb_blob_destroy (this->blob); - } - - inline unsigned int get_advance (hb_codepoint_t glyph) const - { - if (unlikely (glyph >= this->num_metrics)) - { - /* If this->num_metrics is zero, it means we don't have the metrics table - * for this direction: return default advance. Otherwise, it means that the - * glyph index is out of bound: return zero. */ - if (this->num_metrics) - return 0; - else - return this->default_advance; - } - - if (glyph >= this->num_advances) - glyph = this->num_advances - 1; - - return this->table->longMetric[glyph].advance; - } -}; - -struct hb_ot_face_glyf_accelerator_t -{ - bool short_offset; - unsigned int num_glyphs; - const OT::loca *loca; - const OT::glyf *glyf; - hb_blob_t *loca_blob; - hb_blob_t *glyf_blob; - unsigned int glyf_len; - - inline void init (hb_face_t *face) - { - hb_blob_t *head_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_head)); - const OT::head *head = OT::Sanitizer::lock_instance (head_blob); - if ((unsigned int) head->indexToLocFormat > 1 || head->glyphDataFormat != 0) - { - /* Unknown format. Leave num_glyphs=0, that takes care of disabling us. */ - hb_blob_destroy (head_blob); - return; - } - this->short_offset = 0 == head->indexToLocFormat; - hb_blob_destroy (head_blob); - - this->loca_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_loca)); - this->loca = OT::Sanitizer::lock_instance (this->loca_blob); - this->glyf_blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_glyf)); - this->glyf = OT::Sanitizer::lock_instance (this->glyf_blob); - - this->num_glyphs = MAX (1u, hb_blob_get_length (this->loca_blob) / (this->short_offset ? 2 : 4)) - 1; - this->glyf_len = hb_blob_get_length (this->glyf_blob); - } - - inline void fini (void) - { - hb_blob_destroy (this->loca_blob); - hb_blob_destroy (this->glyf_blob); - } - - inline bool get_extents (hb_codepoint_t glyph, - hb_glyph_extents_t *extents) const - { - if (unlikely (glyph >= this->num_glyphs)) - return false; - - unsigned int start_offset, end_offset; - if (this->short_offset) - { - start_offset = 2 * this->loca->u.shortsZ[glyph]; - end_offset = 2 * this->loca->u.shortsZ[glyph + 1]; - } - else - { - start_offset = this->loca->u.longsZ[glyph]; - end_offset = this->loca->u.longsZ[glyph + 1]; - } - - if (start_offset > end_offset || end_offset > this->glyf_len) - return false; - - if (end_offset - start_offset < OT::glyfGlyphHeader::static_size) - return true; /* Empty glyph; zero extents. */ - - const OT::glyfGlyphHeader &glyph_header = OT::StructAtOffset (this->glyf, start_offset); - - extents->x_bearing = MIN (glyph_header.xMin, glyph_header.xMax); - extents->y_bearing = MAX (glyph_header.yMin, glyph_header.yMax); - extents->width = MAX (glyph_header.xMin, glyph_header.xMax) - extents->x_bearing; - extents->height = MIN (glyph_header.yMin, glyph_header.yMax) - extents->y_bearing; - - return true; - } -}; - -struct hb_ot_face_cmap_accelerator_t -{ - const OT::CmapSubtable *table; - const OT::CmapSubtable *uvs_table; - hb_blob_t *blob; - - inline void init (hb_face_t *face) - { - this->blob = OT::Sanitizer::sanitize (face->reference_table (HB_OT_TAG_cmap)); - const OT::cmap *cmap = OT::Sanitizer::lock_instance (this->blob); - const OT::CmapSubtable *subtable = NULL; - const OT::CmapSubtable *subtable_uvs = NULL; - - /* 32-bit subtables. */ - if (!subtable) subtable = cmap->find_subtable (3, 10); - if (!subtable) subtable = cmap->find_subtable (0, 6); - if (!subtable) subtable = cmap->find_subtable (0, 4); - /* 16-bit subtables. */ - if (!subtable) subtable = cmap->find_subtable (3, 1); - if (!subtable) subtable = cmap->find_subtable (0, 3); - if (!subtable) subtable = cmap->find_subtable (0, 2); - if (!subtable) subtable = cmap->find_subtable (0, 1); - if (!subtable) subtable = cmap->find_subtable (0, 0); - if (!subtable) subtable = cmap->find_subtable (3, 0); - /* Meh. */ - if (!subtable) subtable = &OT::Null(OT::CmapSubtable); - - /* UVS subtable. */ - if (!subtable_uvs) subtable_uvs = cmap->find_subtable (0, 5); - /* Meh. */ - if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtable); - - this->table = subtable; - this->uvs_table = subtable_uvs; - } - - inline void fini (void) - { - hb_blob_destroy (this->blob); - } - - inline bool get_glyph (hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const - { - if (unlikely (variation_selector)) - { - switch (this->uvs_table->get_glyph_variant (unicode, - variation_selector, - glyph)) - { - case OT::GLYPH_VARIANT_NOT_FOUND: return false; - case OT::GLYPH_VARIANT_FOUND: return true; - case OT::GLYPH_VARIANT_USE_DEFAULT: break; - } - } - - return this->table->get_glyph (unicode, glyph); - } -}; - - -struct hb_ot_font_t -{ - hb_ot_face_cmap_accelerator_t cmap; - hb_ot_face_metrics_accelerator_t h_metrics; - hb_ot_face_metrics_accelerator_t v_metrics; - hb_ot_face_glyf_accelerator_t glyf; -}; - - -static hb_ot_font_t * -_hb_ot_font_create (hb_face_t *face) -{ - hb_ot_font_t *ot_font = (hb_ot_font_t *) calloc (1, sizeof (hb_ot_font_t)); - - if (unlikely (!ot_font)) - return NULL; - - ot_font->cmap.init (face); - ot_font->h_metrics.init (face, HB_OT_TAG_hhea, HB_OT_TAG_hmtx); - ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx); /* TODO Can we do this lazily? */ - ot_font->glyf.init (face); - - return ot_font; -} - -static void -_hb_ot_font_destroy (hb_ot_font_t *ot_font) -{ - ot_font->cmap.fini (); - ot_font->h_metrics.fini (); - ot_font->v_metrics.fini (); - ot_font->glyf.fini (); - - free (ot_font); -} - - -static hb_bool_t -hb_ot_get_glyph (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) - -{ - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return ot_font->cmap.get_glyph (unicode, variation_selector, glyph); -} - -static hb_position_t -hb_ot_get_glyph_h_advance (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return font->em_scale_x (ot_font->h_metrics.get_advance (glyph)); -} - -static hb_position_t -hb_ot_get_glyph_v_advance (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) -{ - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph)); -} - -static hb_bool_t -hb_ot_get_glyph_extents (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data HB_UNUSED) -{ - const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - bool ret = ot_font->glyf.get_extents (glyph, extents); - extents->x_bearing = font->em_scale_x (extents->x_bearing); - extents->y_bearing = font->em_scale_y (extents->y_bearing); - extents->width = font->em_scale_x (extents->width); - extents->height = font->em_scale_y (extents->height); - return ret; -} - - -static hb_font_funcs_t *static_ot_funcs = NULL; - -#ifdef HB_USE_ATEXIT -static -void free_static_ot_funcs (void) -{ - hb_font_funcs_destroy (static_ot_funcs); -} -#endif - -static hb_font_funcs_t * -_hb_ot_get_font_funcs (void) -{ -retry: - hb_font_funcs_t *funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ot_funcs); - - if (unlikely (!funcs)) - { - funcs = hb_font_funcs_create (); - - hb_font_funcs_set_glyph_func (funcs, hb_ot_get_glyph, NULL, NULL); - hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ot_get_glyph_h_advance, NULL, NULL); - hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ot_get_glyph_v_advance, NULL, NULL); - //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, NULL, NULL); - //hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, NULL, NULL); - //hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ot_get_glyph_h_kerning, NULL, NULL); TODO - //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ot_get_glyph_v_kerning, NULL, NULL); - hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, NULL, NULL); - //hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, NULL, NULL); TODO - //hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, NULL, NULL); TODO - //hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, NULL, NULL); TODO - - hb_font_funcs_make_immutable (funcs); - - if (!hb_atomic_ptr_cmpexch (&static_ot_funcs, NULL, funcs)) { - hb_font_funcs_destroy (funcs); - goto retry; - } - -#ifdef HB_USE_ATEXIT - atexit (free_static_ot_funcs); /* First person registers atexit() callback. */ -#endif - }; - - return funcs; -} - - -/** - * Since: 0.9.28 - **/ -void -hb_ot_font_set_funcs (hb_font_t *font) -{ - hb_ot_font_t *ot_font = _hb_ot_font_create (font->face); - if (unlikely (!ot_font)) - return; - - hb_font_set_funcs (font, - _hb_ot_get_font_funcs (), - ot_font, - (hb_destroy_func_t) _hb_ot_font_destroy); -} diff --git a/third_party/harfbuzz-ng/src/hb-ot-glyf-table.hh b/third_party/harfbuzz-ng/src/hb-ot-glyf-table.hh deleted file mode 100644 index 9e5af6d10df5..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-glyf-table.hh +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2015 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OT_GLYF_TABLE_HH -#define HB_OT_GLYF_TABLE_HH - -#include "hb-open-type-private.hh" - - -namespace OT { - - -/* - * loca -- Index to Location - */ - -#define HB_OT_TAG_loca HB_TAG('l','o','c','a') - - -struct loca -{ - static const hb_tag_t tableTag = HB_OT_TAG_loca; - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (true); - } - - public: - union { - USHORT shortsZ[VAR]; /* Location offset divided by 2. */ - ULONG longsZ[VAR]; /* Location offset. */ - } u; - DEFINE_SIZE_ARRAY (0, u.longsZ); -}; - - -/* - * glyf -- TrueType Glyph Data - */ - -#define HB_OT_TAG_glyf HB_TAG('g','l','y','f') - - -struct glyf -{ - static const hb_tag_t tableTag = HB_OT_TAG_glyf; - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - /* We don't check for anything specific here. The users of the - * struct do all the hard work... */ - return_trace (true); - } - - public: - BYTE dataX[VAR]; /* Glyphs data. */ - - DEFINE_SIZE_ARRAY (0, dataX); -}; - -struct glyfGlyphHeader -{ - SHORT numberOfContours; /* If the number of contours is - * greater than or equal to zero, - * this is a simple glyph; if negative, - * this is a composite glyph. */ - SHORT xMin; /* Minimum x for coordinate data. */ - SHORT yMin; /* Minimum y for coordinate data. */ - SHORT xMax; /* Maximum x for coordinate data. */ - SHORT yMax; /* Maximum y for coordinate data. */ - - DEFINE_SIZE_STATIC (10); -}; - -} /* namespace OT */ - - -#endif /* HB_OT_GLYF_TABLE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-ot-head-table.hh b/third_party/harfbuzz-ng/src/hb-ot-head-table.hh deleted file mode 100644 index fc351cfb48e9..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-head-table.hh +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright © 2010 Red Hat, Inc. - * Copyright © 2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OT_HEAD_TABLE_HH -#define HB_OT_HEAD_TABLE_HH - -#include "hb-open-type-private.hh" - - -namespace OT { - - -/* - * head -- Font Header - */ - -#define HB_OT_TAG_head HB_TAG('h','e','a','d') - -struct head -{ - static const hb_tag_t tableTag = HB_OT_TAG_head; - - inline unsigned int get_upem (void) const - { - unsigned int upem = unitsPerEm; - /* If no valid head table found, assume 1000, which matches typical Type1 usage. */ - return 16 <= upem && upem <= 16384 ? upem : 1000; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && likely (version.major == 1)); - } - - protected: - FixedVersion version; /* Version of the head table--currently - * 0x00010000u for version 1.0. */ - FixedVersion fontRevision; /* Set by font manufacturer. */ - ULONG checkSumAdjustment; /* To compute: set it to 0, sum the - * entire font as ULONG, then store - * 0xB1B0AFBAu - sum. */ - ULONG magicNumber; /* Set to 0x5F0F3CF5u. */ - USHORT flags; /* Bit 0: Baseline for font at y=0; - * Bit 1: Left sidebearing point at x=0; - * Bit 2: Instructions may depend on point size; - * Bit 3: Force ppem to integer values for all - * internal scaler math; may use fractional - * ppem sizes if this bit is clear; - * Bit 4: Instructions may alter advance width - * (the advance widths might not scale linearly); - - * Bits 5-10: These should be set according to - * Apple's specification. However, they are not - * implemented in OpenType. - * Bit 5: This bit should be set in fonts that are - * intended to e laid out vertically, and in - * which the glyphs have been drawn such that an - * x-coordinate of 0 corresponds to the desired - * vertical baseline. - * Bit 6: This bit must be set to zero. - * Bit 7: This bit should be set if the font - * requires layout for correct linguistic - * rendering (e.g. Arabic fonts). - * Bit 8: This bit should be set for a GX font - * which has one or more metamorphosis effects - * designated as happening by default. - * Bit 9: This bit should be set if the font - * contains any strong right-to-left glyphs. - * Bit 10: This bit should be set if the font - * contains Indic-style rearrangement effects. - - * Bit 11: Font data is 'lossless,' as a result - * of having been compressed and decompressed - * with the Agfa MicroType Express engine. - * Bit 12: Font converted (produce compatible metrics) - * Bit 13: Font optimized for ClearType™. - * Note, fonts that rely on embedded bitmaps (EBDT) - * for rendering should not be considered optimized - * for ClearType, and therefore should keep this bit - * cleared. - * Bit 14: Last Resort font. If set, indicates that - * the glyphs encoded in the cmap subtables are simply - * generic symbolic representations of code point - * ranges and don’t truly represent support for those - * code points. If unset, indicates that the glyphs - * encoded in the cmap subtables represent proper - * support for those code points. - * Bit 15: Reserved, set to 0. */ - USHORT unitsPerEm; /* Valid range is from 16 to 16384. This value - * should be a power of 2 for fonts that have - * TrueType outlines. */ - LONGDATETIME created; /* Number of seconds since 12:00 midnight, - January 1, 1904. 64-bit integer */ - LONGDATETIME modified; /* Number of seconds since 12:00 midnight, - January 1, 1904. 64-bit integer */ - SHORT xMin; /* For all glyph bounding boxes. */ - SHORT yMin; /* For all glyph bounding boxes. */ - SHORT xMax; /* For all glyph bounding boxes. */ - SHORT yMax; /* For all glyph bounding boxes. */ - USHORT macStyle; /* Bit 0: Bold (if set to 1); - * Bit 1: Italic (if set to 1) - * Bit 2: Underline (if set to 1) - * Bit 3: Outline (if set to 1) - * Bit 4: Shadow (if set to 1) - * Bit 5: Condensed (if set to 1) - * Bit 6: Extended (if set to 1) - * Bits 7-15: Reserved (set to 0). */ - USHORT lowestRecPPEM; /* Smallest readable size in pixels. */ - SHORT fontDirectionHint; /* Deprecated (Set to 2). - * 0: Fully mixed directional glyphs; - * 1: Only strongly left to right; - * 2: Like 1 but also contains neutrals; - * -1: Only strongly right to left; - * -2: Like -1 but also contains neutrals. */ - public: - SHORT indexToLocFormat; /* 0 for short offsets, 1 for long. */ - SHORT glyphDataFormat; /* 0 for current format. */ - - DEFINE_SIZE_STATIC (54); -}; - - -} /* namespace OT */ - - -#endif /* HB_OT_HEAD_TABLE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-ot-hhea-table.hh b/third_party/harfbuzz-ng/src/hb-ot-hhea-table.hh deleted file mode 100644 index 24114534a718..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-hhea-table.hh +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OT_HHEA_TABLE_HH -#define HB_OT_HHEA_TABLE_HH - -#include "hb-open-type-private.hh" - - -namespace OT { - - -/* - * hhea -- The Horizontal Header Table - * vhea -- The Vertical Header Table - */ - -#define HB_OT_TAG_hhea HB_TAG('h','h','e','a') -#define HB_OT_TAG_vhea HB_TAG('v','h','e','a') - - -struct _hea -{ - static const hb_tag_t tableTag = HB_TAG('_','h','e','a'); - - static const hb_tag_t hheaTag = HB_OT_TAG_hhea; - static const hb_tag_t vheaTag = HB_OT_TAG_vhea; - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && likely (version.major == 1)); - } - - public: - FixedVersion version; /* 0x00010000u for version 1.0. */ - FWORD ascender; /* Typographic ascent. */ - FWORD descender; /* Typographic descent. */ - FWORD lineGap; /* Typographic line gap. */ - UFWORD advanceMax; /* Maximum advance width/height value in - * metrics table. */ - FWORD minLeadingBearing; /* Minimum left/top sidebearing value in - * metrics table. */ - FWORD minTrailingBearing; /* Minimum right/bottom sidebearing value; - * calculated as Min(aw - lsb - - * (xMax - xMin)) for horizontal. */ - FWORD maxExtent; /* horizontal: Max(lsb + (xMax - xMin)), - * vertical: minLeadingBearing+(yMax-yMin). */ - SHORT caretSlopeRise; /* Used to calculate the slope of the - * cursor (rise/run); 1 for vertical caret, - * 0 for horizontal.*/ - SHORT caretSlopeRun; /* 0 for vertical caret, 1 for horizontal. */ - SHORT caretOffset; /* The amount by which a slanted - * highlight on a glyph needs - * to be shifted to produce the - * best appearance. Set to 0 for - * non-slanted fonts. */ - SHORT reserved1; /* Set to 0. */ - SHORT reserved2; /* Set to 0. */ - SHORT reserved3; /* Set to 0. */ - SHORT reserved4; /* Set to 0. */ - SHORT metricDataFormat; /* 0 for current format. */ - USHORT numberOfLongMetrics; /* Number of LongMetric entries in metric - * table. */ - public: - DEFINE_SIZE_STATIC (36); -}; - -struct hhea : _hea { - static const hb_tag_t tableTag = HB_OT_TAG_hhea; -}; -struct vhea : _hea { - static const hb_tag_t tableTag = HB_OT_TAG_vhea; -}; - - -} /* namespace OT */ - - -#endif /* HB_OT_HHEA_TABLE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-ot-hmtx-table.hh b/third_party/harfbuzz-ng/src/hb-ot-hmtx-table.hh deleted file mode 100644 index 49056e67691d..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-hmtx-table.hh +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2011,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OT_HMTX_TABLE_HH -#define HB_OT_HMTX_TABLE_HH - -#include "hb-open-type-private.hh" - - -namespace OT { - - -/* - * hmtx -- The Horizontal Metrics Table - * vmtx -- The Vertical Metrics Table - */ - -#define HB_OT_TAG_hmtx HB_TAG('h','m','t','x') -#define HB_OT_TAG_vmtx HB_TAG('v','m','t','x') - - -struct LongMetric -{ - USHORT advance; /* Advance width/height. */ - SHORT lsb; /* Leading (left/top) side bearing. */ - public: - DEFINE_SIZE_STATIC (4); -}; - -struct _mtx -{ - static const hb_tag_t tableTag = HB_TAG('_','m','t','x'); - - static const hb_tag_t hmtxTag = HB_OT_TAG_hmtx; - static const hb_tag_t vmtxTag = HB_OT_TAG_vmtx; - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - /* We don't check for anything specific here. The users of the - * struct do all the hard work... */ - return_trace (true); - } - - public: - LongMetric longMetric[VAR]; /* Paired advance width and leading - * bearing values for each glyph. The - * value numOfHMetrics comes from - * the 'hhea' table. If the font is - * monospaced, only one entry need - * be in the array, but that entry is - * required. The last entry applies to - * all subsequent glyphs. */ - SHORT leadingBearingX[VAR]; /* Here the advance is assumed - * to be the same as the advance - * for the last entry above. The - * number of entries in this array is - * derived from numGlyphs (from 'maxp' - * table) minus numberOfLongMetrics. - * This generally is used with a run - * of monospaced glyphs (e.g., Kanji - * fonts or Courier fonts). Only one - * run is allowed and it must be at - * the end. This allows a monospaced - * font to vary the side bearing - * values for each glyph. */ - public: - DEFINE_SIZE_ARRAY2 (0, longMetric, leadingBearingX); -}; - -struct hmtx : _mtx { - static const hb_tag_t tableTag = HB_OT_TAG_hmtx; -}; -struct vmtx : _mtx { - static const hb_tag_t tableTag = HB_OT_TAG_vmtx; -}; - -} /* namespace OT */ - - -#endif /* HB_OT_HMTX_TABLE_HH */ diff --git a/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh b/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh deleted file mode 100644 index 5b21f1427660..000000000000 --- a/third_party/harfbuzz-ng/src/hb-ot-layout-common-private.hh +++ /dev/null @@ -1,1235 +0,0 @@ -/* - * Copyright © 2007,2008,2009 Red Hat, Inc. - * Copyright © 2010,2012 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Red Hat Author(s): Behdad Esfahbod - * Google Author(s): Behdad Esfahbod - */ - -#ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH -#define HB_OT_LAYOUT_COMMON_PRIVATE_HH - -#include "hb-ot-layout-private.hh" -#include "hb-open-type-private.hh" -#include "hb-set-private.hh" - - -#ifndef HB_MAX_NESTING_LEVEL -#define HB_MAX_NESTING_LEVEL 6 -#endif -#ifndef HB_MAX_CONTEXT_LENGTH -#define HB_MAX_CONTEXT_LENGTH 64 -#endif - - -namespace OT { - - -#define TRACE_DISPATCH(this, format) \ - hb_auto_trace_t trace \ - (&c->debug_depth, c->get_name (), this, HB_FUNC, \ - "format %d", (int) format); - - -#define NOT_COVERED ((unsigned int) -1) - - - -/* - * - * OpenType Layout Common Table Formats - * - */ - - -/* - * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList - */ - -template -struct Record -{ - inline int cmp (hb_tag_t a) const { - return tag.cmp (a); - } - - struct sanitize_closure_t { - hb_tag_t tag; - const void *list_base; - }; - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - const sanitize_closure_t closure = {tag, base}; - return_trace (c->check_struct (this) && offset.sanitize (c, base, &closure)); - } - - Tag tag; /* 4-byte Tag identifier */ - OffsetTo - offset; /* Offset from beginning of object holding - * the Record */ - public: - DEFINE_SIZE_STATIC (6); -}; - -template -struct RecordArrayOf : SortedArrayOf > { - inline const Tag& get_tag (unsigned int i) const - { - /* We cheat slightly and don't define separate Null objects - * for Record types. Instead, we return the correct Null(Tag) - * here. */ - if (unlikely (i >= this->len)) return Null(Tag); - return (*this)[i].tag; - } - inline unsigned int get_tags (unsigned int start_offset, - unsigned int *record_count /* IN/OUT */, - hb_tag_t *record_tags /* OUT */) const - { - if (record_count) { - const Record *arr = this->sub_array (start_offset, record_count); - unsigned int count = *record_count; - for (unsigned int i = 0; i < count; i++) - record_tags[i] = arr[i].tag; - } - return this->len; - } - inline bool find_index (hb_tag_t tag, unsigned int *index) const - { - /* If we want to allow non-sorted data, we can lsearch(). */ - int i = this->/*lsearch*/bsearch (tag); - if (i != -1) { - if (index) *index = i; - return true; - } else { - if (index) *index = Index::NOT_FOUND_INDEX; - return false; - } - } -}; - -template -struct RecordListOf : RecordArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { return this+RecordArrayOf::operator [](i).offset; } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (RecordArrayOf::sanitize (c, this)); - } -}; - - -struct RangeRecord -{ - inline int cmp (hb_codepoint_t g) const { - return g < start ? -1 : g <= end ? 0 : +1 ; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this)); - } - - inline bool intersects (const hb_set_t *glyphs) const { - return glyphs->intersects (start, end); - } - - template - inline void add_coverage (set_t *glyphs) const { - glyphs->add_range (start, end); - } - - GlyphID start; /* First GlyphID in the range */ - GlyphID end; /* Last GlyphID in the range */ - USHORT value; /* Value */ - public: - DEFINE_SIZE_STATIC (6); -}; -DEFINE_NULL_DATA (RangeRecord, "\000\001"); - - -struct IndexArray : ArrayOf -{ - inline unsigned int get_indexes (unsigned int start_offset, - unsigned int *_count /* IN/OUT */, - unsigned int *_indexes /* OUT */) const - { - if (_count) { - const USHORT *arr = this->sub_array (start_offset, _count); - unsigned int count = *_count; - for (unsigned int i = 0; i < count; i++) - _indexes[i] = arr[i]; - } - return this->len; - } -}; - - -struct Script; -struct LangSys; -struct Feature; - - -struct LangSys -{ - inline unsigned int get_feature_count (void) const - { return featureIndex.len; } - inline hb_tag_t get_feature_index (unsigned int i) const - { return featureIndex[i]; } - inline unsigned int get_feature_indexes (unsigned int start_offset, - unsigned int *feature_count /* IN/OUT */, - unsigned int *feature_indexes /* OUT */) const - { return featureIndex.get_indexes (start_offset, feature_count, feature_indexes); } - - inline bool has_required_feature (void) const { return reqFeatureIndex != 0xFFFFu; } - inline unsigned int get_required_feature_index (void) const - { - if (reqFeatureIndex == 0xFFFFu) - return Index::NOT_FOUND_INDEX; - return reqFeatureIndex;; - } - - inline bool sanitize (hb_sanitize_context_t *c, - const Record::sanitize_closure_t * = NULL) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && featureIndex.sanitize (c)); - } - - Offset<> lookupOrderZ; /* = Null (reserved for an offset to a - * reordering table) */ - USHORT reqFeatureIndex;/* Index of a feature required for this - * language system--if no required features - * = 0xFFFFu */ - IndexArray featureIndex; /* Array of indices into the FeatureList */ - public: - DEFINE_SIZE_ARRAY (6, featureIndex); -}; -DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF"); - - -struct Script -{ - inline unsigned int get_lang_sys_count (void) const - { return langSys.len; } - inline const Tag& get_lang_sys_tag (unsigned int i) const - { return langSys.get_tag (i); } - inline unsigned int get_lang_sys_tags (unsigned int start_offset, - unsigned int *lang_sys_count /* IN/OUT */, - hb_tag_t *lang_sys_tags /* OUT */) const - { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } - inline const LangSys& get_lang_sys (unsigned int i) const - { - if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); - return this+langSys[i].offset; - } - inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const - { return langSys.find_index (tag, index); } - - inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } - inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } - - inline bool sanitize (hb_sanitize_context_t *c, - const Record