diff --git a/.github/workflows/authorship.yml b/.github/workflows/authorship.yml index 615267b6c0..857fb68023 100644 --- a/.github/workflows/authorship.yml +++ b/.github/workflows/authorship.yml @@ -7,7 +7,7 @@ on: push: branches: [main] workflow_run: - workflows: [Build APK] + workflows: [Build APK, Unit tests] types: [completed] workflow_dispatch: inputs: @@ -21,6 +21,12 @@ permissions: pull-requests: read statuses: write +# Build APK and Unit tests each trigger a validation, and the last one to post sets the status. Queued runs for a +# commit wait, so the newest one reads both results and posts last. +concurrency: + group: build-validation-${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha || inputs.pr_number || github.sha }} + cancel-in-progress: false + jobs: validate: name: Validate source and build result diff --git a/.github/workflows/build-bionic-runtime.yml b/.github/workflows/build-bionic-runtime.yml index 2bc5091fd9..b7d657a15b 100644 --- a/.github/workflows/build-bionic-runtime.yml +++ b/.github/workflows/build-bionic-runtime.yml @@ -23,6 +23,11 @@ jobs: sudo apt-get update -qq sudo apt-get install -y -qq --no-install-recommends libwayland-bin libwayland-dev libx11-dev libx11-xcb-dev \ libxcb1-dev libxcb-composite0-dev libglm-dev zstd + - name: llvm-mingw for dd-directcontroller + uses: actions/cache@v4 + with: + path: ~/.cache/llvm-mingw-bylaws-20250920 + key: llvm-mingw-bylaws-20250920-x86_64 - name: Build run: | set -euo pipefail diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b32d1b442..41845e8506 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build APK -run-name: ${{ github.event_name == 'pull_request' && format('building pr {0} on {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('building {0} on {1}', github.ref_name, github.sha) }} +run-name: ${{ github.event_name == 'pull_request' && format('building pr {0} on {1} against {2}', github.event.pull_request.number, github.event.pull_request.head.sha, github.event.pull_request.base.sha) || format('building {0} on {1}', github.ref_name, github.sha) }} on: push: @@ -57,15 +57,18 @@ jobs: - name: Pin and merge the APK source id: merge if: github.event_name == 'pull_request' + env: + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} run: | set -euo pipefail - git fetch --no-tags origin main - echo "base-sha=$(git rev-parse origin/main)" >> "$GITHUB_OUTPUT" + # Unit tests uses the same event snapshot, including when either workflow is rerun. + git fetch --no-tags origin "$PR_BASE_SHA" + echo "base-sha=$PR_BASE_SHA" >> "$GITHUB_OUTPUT" git config user.name "ci" git config user.email "ci@users.noreply.github.com" # Partial clone: a merged blob that only exists in a fork's history can't be lazily fetched (GitHub: "not our ref"); merge-tree writes it locally first. - git merge-tree --write-tree HEAD origin/main >/dev/null || true - git merge --no-ff --no-edit origin/main + git merge-tree --write-tree HEAD FETCH_HEAD >/dev/null || true + git merge --no-ff --no-edit FETCH_HEAD - name: Resolve trusted manifest base id: trusted if: github.event_name != 'pull_request' @@ -304,6 +307,9 @@ jobs: aarch64-linux-gnu-gcc -O2 -Wall -o "$D/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-glprobe" + - name: Build the LSE atomics emulator for ARMv8.0 CPUs + run: bash tools/linuxfs/lse-emu/build.sh app/src/main/assets/linuxfs + - name: Check the preloads run: | set -euo pipefail @@ -349,7 +355,7 @@ jobs: build: needs: [source, components, xbox, build-runner] - name: Compile APK and Android tests + name: Compile APK if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} runs-on: ${{ fromJSON(needs.build-runner.outputs.labels) }} timeout-minutes: 45 @@ -507,23 +513,7 @@ jobs: PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} BUILD_REF: ${{ github.ref_name }} BUILD_SHA: ${{ github.sha }} - run: | - if [[ -n "$(git status --porcelain)" ]]; then - tree_state=dirty - else - tree_state=clean - fi - echo "DROIDDECK_BUILD_TREE_STATE=$tree_state" >> "$GITHUB_ENV" - if [[ -n "$PR_NUMBER" ]]; then - label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}" - else - label="${BUILD_REF} at ${BUILD_SHA:0:7}" - fi - echo "label=$label" >> "$GITHUB_OUTPUT" - echo "DROIDDECK_SOURCE_COMMIT=${PR_HEAD_SHA:-$BUILD_SHA}" >> "$GITHUB_ENV" - echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV" - echo "DROIDDECK_PR_TITLE=${PR_TITLE//$'\n'/ }" >> "$GITHUB_ENV" - echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY" + run: bash tools/ci/build-label.sh - name: Rust toolchain for the store engines (aarch64-linux-android) id: rust @@ -734,89 +724,6 @@ jobs: if-no-files-found: ignore overwrite: true - - name: Resolve the Robolectric version - id: robolectric - run: | - echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT" - # Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes. - # The cache path sits beside the workspace because runner homes are at different depths from it, and - # actions/cache stores paths relative to the workspace. Runners that keep their own ~/.m2 skip the cache. - - name: Place Robolectric's Android jars beside the workspace - id: robolectric-jars - run: | - set -euo pipefail - jars="$GITHUB_WORKSPACE/../robolectric-jars" - m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented" - if [ -d "$m2" ] && [ ! -L "$m2" ]; then - echo "cache=false" >> "$GITHUB_OUTPUT" - else - mkdir -p "$jars" "$(dirname "$m2")" - ln -sfn "$(cd "$jars" && pwd)" "$m2" - echo "cache=true" >> "$GITHUB_OUTPUT" - fi - - name: Restore Robolectric's Android jars - id: robolectric-cache - if: steps.robolectric-jars.outputs.cache == 'true' - uses: actions/cache/restore@v4 - with: - path: ../robolectric-jars - key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }} - restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}- - - name: Count the restored Robolectric jars - if: steps.robolectric-jars.outputs.cache == 'true' - run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV" - - name: Unit tests - id: unit-tests - env: - DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }} - SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }} - run: | - set -o pipefail - mkdir -p app/build - ./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log - - # actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache. - # Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first. - - name: Save Robolectric's Android jars - id: robolectric-jars-final - if: always() && steps.robolectric-jars.outputs.cache == 'true' - run: | - python3 - <<'PY' - import glob, os, zipfile - root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars') - for f in glob.glob(os.path.join(root, '**', '*'), recursive=True): - if not os.path.isfile(f): - continue - try: - ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None - except Exception: - ok = False - if not ok: - os.remove(f) - PY - after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l) - [ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true - - name: Store Robolectric's Android jars - if: always() && steps.robolectric-jars-final.outputs.save == 'true' - uses: actions/cache/save@v4 - with: - path: ../robolectric-jars - key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }} - - - name: Upload unit test diagnostics - id: unit-test-diagnostics - if: always() && steps.unit-tests.outcome != 'skipped' - uses: actions/upload-artifact@v4 - with: - name: unit-test-results - path: | - app/build/unit-tests.log - app/build/test-results/testReleaseUnitTest/ - app/build/reports/tests/testReleaseUnitTest/ - if-no-files-found: ignore - retention-days: 14 - overwrite: true - - name: Sign with the testkey (v1 + v2 + v3) run: | set -euo pipefail @@ -872,8 +779,6 @@ jobs: PR: ${{ github.event.pull_request.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} BUILD_OUTCOME: ${{ steps.build.outcome }} - UNIT_TEST_OUTCOME: ${{ steps.unit-tests.outcome }} - TEST_DIAGNOSTICS_URL: ${{ steps.unit-test-diagnostics.outputs.artifact-url }} APK_OUTCOME: ${{ steps.apk-upload.outcome }} run: bash tools/release/report-build.sh @@ -1050,6 +955,7 @@ jobs: with: artifact: droiddeck-signed variant: standard + fail_on_detection: true secrets: inherit packs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eabc77a358..24fd2ffa9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,6 +47,13 @@ jobs: echo "::error::main ${GITHUB_SHA::7} has no successful Build APK run yet: wait for it, then release" exit 1 fi + tests=$(gh run list -R "$GITHUB_REPOSITORY" --workflow unit-tests.yml --branch main --commit "$GITHUB_SHA" \ + --json conclusion,event,headSha -L 20 | + jq -r --arg sha "$GITHUB_SHA" '[.[] | select(.headSha == $sha and (.event == "push" or .event == "workflow_dispatch"))][0].conclusion // empty') + if [ "$tests" != success ]; then + echo "::error::main ${GITHUB_SHA::7} has no passing Unit tests run (${tests:-none yet}): fix or wait for it, then release" + exit 1 + fi variants=$(awk '!/^#/ && NF { print $1 }' tools/release/variants.txt | jq -R . | jq -sc .) echo "run_id=$id" >> "$GITHUB_OUTPUT" echo "variants=$variants" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000..663bd30e6a --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,202 @@ +name: Unit tests +run-name: ${{ github.event_name == 'pull_request' && format('unit tests for pr {0} on {1} against {2}', github.event.pull_request.number, github.event.pull_request.head.sha, github.event.pull_request.base.sha) || format('unit tests for {0} on {1}', github.ref_name, github.sha) }} + +# Runs beside Build APK rather than inside it, so a test build is published as soon as the APK compiles. +# Build validation folds this workflow's result into the "Build APK" commit status, and Release APKs requires it. +on: + push: + branches: [ main ] + paths-ignore: + - '**/*.md' + - 'LICENSE' + - '.gitignore' + - 'docs/**' + - '.github/ISSUE_TEMPLATE/**' + pull_request: + branches: [ main ] + types: [ opened, synchronize, reopened, ready_for_review ] + paths-ignore: + - '**/*.md' + - 'LICENSE' + - '.gitignore' + - 'docs/**' + - '.github/ISSUE_TEMPLATE/**' + workflow_dispatch: + +permissions: + contents: read + actions: read + +concurrency: + group: unit-tests-${{ github.event.pull_request.number || (github.event_name == 'push' && 'main') || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }} + +jobs: + unit-tests: + name: Unit tests + if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} + runs-on: ubuntu-24.04 + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + fetch-depth: 0 + sparse-checkout: | + /* + !/docs/releases/media/ + sparse-checkout-cone-mode: false + persist-credentials: false + + - name: Merge the pinned APK base + if: github.event_name == 'pull_request' + env: + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + set -euo pipefail + git config user.name "ci" + git config user.email "ci@users.noreply.github.com" + git fetch --no-tags origin "$PR_BASE_SHA" + git merge-tree --write-tree HEAD FETCH_HEAD >/dev/null || true + git merge --no-ff --no-edit FETCH_HEAD || { echo "::error::the pull request conflicts with main; Build APK lists the files"; exit 1; } + + - name: Check out MaliBridge + run: git submodule update --init external/MaliBridge + + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + + - uses: gradle/actions/setup-gradle@v4 + with: + cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} + cache-cleanup: ${{ github.event_name == 'pull_request' && 'never' || 'on-success' }} + + - name: Resolve the pinned Android NDK + run: bash tools/ci/resolve-ndk.sh + + - name: Set the APK build label + id: build-label + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + BUILD_REF: ${{ github.ref_name }} + BUILD_SHA: ${{ github.sha }} + run: bash tools/ci/build-label.sh + + - name: Resolve the Robolectric version + id: robolectric + run: | + echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT" + # Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes. + # The cache path sits beside the workspace because runner homes are at different depths from it, and + # actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects + # "..". Runners that keep their own ~/.m2 skip the cache. + - name: Place Robolectric's Android jars beside the workspace + id: robolectric-jars + run: | + set -euo pipefail + jars="$GITHUB_WORKSPACE/../robolectric-jars" + m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented" + if [ -d "$m2" ] && [ ! -L "$m2" ]; then + echo "cache=false" >> "$GITHUB_OUTPUT" + else + mkdir -p "$jars" "$(dirname "$m2")" + jars=$(cd "$jars" && pwd) + ln -sfn "$jars" "$m2" + echo "path=$jars" >> "$GITHUB_OUTPUT" + echo "cache=true" >> "$GITHUB_OUTPUT" + fi + - name: Restore Robolectric's Android jars + id: robolectric-cache + if: steps.robolectric-jars.outputs.cache == 'true' + uses: actions/cache/restore@v4 + with: + path: ${{ steps.robolectric-jars.outputs.path }} + key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }} + restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}- + - name: Count the restored Robolectric jars + if: steps.robolectric-jars.outputs.cache == 'true' + run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV" + - name: Unit tests + id: unit-tests + env: + DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }} + SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }} + run: | + set -o pipefail + mkdir -p app/build + log=app/build/unit-tests.log + attempt_log=app/build/unit-tests-attempt.log + : > "$log" + mirror=() + central='https://(repo1\.maven\.org|repo\.maven\.apache\.org)/maven2/org/robolectric/' + gradle_error='((Caused by: )?org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: |>[[:space:]]+)?' + java_error='((Caused by: )?java\.io\.IOException: )?' + # A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next. + for wait in 60 180 0; do + status=0 + ./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PskipRust=true -PunitTestsOnly=true -PndkVersion="$NDK_VERSION" "${mirror[@]}" 2>&1 | tee "$attempt_log" || status=$? + cat "$attempt_log" >> "$log" + if [ "$status" = 0 ] || [ "$wait" = 0 ]; then + exit "$status" + fi + if [ "${#mirror[@]}" = 0 ] && grep -qE \ + -e "^[[:space:]]*${gradle_error}Could not (GET|HEAD) '?${central}[^'[:space:]]+'?\. Received status code 429([[:space:]]|$)" \ + -e "^[[:space:]]*${java_error}Server returned HTTP response code: 429 for URL: ${central}[^[:space:]]+" "$attempt_log"; then + mirror=(-ProbolectricMavenMirror=https://maven-central.storage-download.googleapis.com/maven2) + echo "::notice::Maven Central rate limited Robolectric. Retrying unit tests with the Google Cloud mirror." | tee -a "$log" + continue + fi + if ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://(repo\.maven\.apache\.org|repo1\.maven\.org)/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://(repo\.maven\.apache\.org|repo1\.maven\.org)/)' "$attempt_log"; then + exit "$status" + fi + echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s" | tee -a "$log" + sleep "$wait" + done + + # actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache. + # Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first. + - name: Save Robolectric's Android jars + id: robolectric-jars-final + if: always() && steps.robolectric-jars.outputs.cache == 'true' + run: | + python3 - <<'PY' + import glob, os, zipfile + root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars') + for f in glob.glob(os.path.join(root, '**', '*'), recursive=True): + if not os.path.isfile(f): + continue + try: + ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None + except Exception: + ok = False + if not ok: + os.remove(f) + PY + after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l) + [ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true + # A pull request's cache is visible only to that pull request, and each copy is hundreds of megabytes against the + # repository's 10 GB cache limit. Only main saves, so every pull request restores main's set. + - name: Store Robolectric's Android jars + if: always() && github.event_name != 'pull_request' && steps.robolectric-jars-final.outputs.save == 'true' + uses: actions/cache/save@v4 + with: + path: ${{ steps.robolectric-jars.outputs.path }} + key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }} + + - name: Upload unit test diagnostics + id: unit-test-diagnostics + if: always() && steps.unit-tests.outcome != 'skipped' + uses: actions/upload-artifact@v4 + with: + name: unit-test-results + path: | + app/build/unit-tests.log + app/build/test-results/testReleaseUnitTest/ + app/build/reports/tests/testReleaseUnitTest/ + if-no-files-found: ignore + retention-days: 14 + overwrite: true diff --git a/AGENTS.md b/AGENTS.md index 97930d6563..d89bdf632c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,7 @@ - For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step. - `tools/build_local.sh` reuses the components a main CI run prepared when every recipe identity matches the local tree (it prints `components: … reusing`). It builds them locally when no usable CI artifact matches (after you change their inputs, or when the lookup fails) or with `DROIDDECK_CI_COMPONENTS=0`. - Helper scripts (`tools/linuxfs/overlay`, `tools/linuxfs/desktop`) are staged on every Gradle build, so editing them needs no `build_local.sh`. After preloads or other runtime components change, the fast loop warns and reuses the old binaries; run `tools/build_local.sh` when those matter. "Missing or changed runtime input" means the prepared files themselves changed: run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` between checkouts; `tools/seed_worktree.sh` seeds a new worktree from the main checkout. -- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest`; when a test fails only in CI, run the release variant locally. +- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest` in the `Unit tests` workflow, beside Build APK; when a test fails only in CI, run the release variant locally. - Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests ''` and `python3 -m unittest discover -s tools/tests -p 'test_*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI. - For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape. - After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`. @@ -31,7 +31,7 @@ - CI builds the PR merged onto `main`. Before pushing, merge or rebase onto `origin/main` and compile: most "works locally" Kotlin failures come from that merge. - Before a PR that touches strings or resources, run `./gradlew :app:lintVitalRelease`. The fast loop skips lint, and lint catches `ExtraTranslation` and missing-locale errors. - Commit messages and PR bodies must not carry `Co-Authored-By` or other bot trailers. `tools/release/check_authorship.py` fails the build on them. -- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs//logs`, or `gh run download -n unit-test-results`. Don't call a failure a runner problem until you have read it. +- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs//logs`, or `gh run download -n unit-test-results` from the `Unit tests` workflow run. Don't call a failure a runner problem until you have read it. - Only these are known flakes worth a `gh run rerun --failed`: `ProtonMenuAutoTest` "Proton work did not finish", Robolectric `HTTP response code: 429` from Maven, `Gradle Test Executor N finished with non-zero exit value 2`, apt mirror and GitHub API rate-limit errors. Treat any other failure as real. - A workflow step that names a script your branch lacks means the branch predates a CI change. Rebase onto `main`. diff --git a/README.md b/README.md index 576cf61c59..d6616b1ab7 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V - Runtime, shim, input and controller work build on WinNative and Bannerlator by maxjivi05. - mmap ring buffer controller input by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). - [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT), and its GL thunk hands X errors to the program's own error handler. FEX's code disk cache was checked in its source. The fix for host stack left behind when a program leaves a signal handler without returning follows the approach suggested in [FEX-Emu/FEX#2487](https://github.com/FEX-Emu/FEX/issues/2487). The host stack fix for system calls that end a block is a backport of Ryan Houdek's [FEX-Emu/FEX#6122](https://github.com/FEX-Emu/FEX/pull/6122). +- Anti-cheat support under FEX is the work of [StonkGuy](https://github.com/StonkGuy): the x86-64 ptrace, seccomp and `/proc` emulation from his [FEX fork](https://github.com/StonkGuy/FEX) (`eac-2611` branch, MIT) is carried as build patch 0021 with his authorship, patches 0022 to 0029 build on it, and his `eac-tests` regression suite verifies them. - x86-64 programs on Wayland reach the GPU through FEX's Wayland client, wayland-egl and EGL thunks. The guest `wl_list` and `wl_array` helpers follow [libwayland](https://gitlab.freedesktop.org/wayland/wayland)'s `src/wayland-util.c` (MIT). The EGL extension table comes from the [Khronos EGL registry](https://github.com/KhronosGroup/EGL-Registry) (Apache-2.0) and Mesa's `egl_other.xml` (MIT). - x86 AppImages, and arm64 ones whose runtime can't unpack on Android, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence. - DwarFS AppImages are unpacked without proot by `dwarfsextract` from [DwarFS](https://github.com/mhx/dwarfs) by Marcus Holland-Moritz (MIT), the release binary uruntime embeds, taken out of its self-extracting wrapper and shipped with its licence. @@ -113,7 +114,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V - Steam audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink`. - The DroidDeck HUD is [@The412Banner](https://github.com/The412Banner)'s [FusionHUD](https://github.com/The412Banner/FusionHUD) (GPL-3.0 with an attribution term). Its readings match Valve's [MangoHud](https://github.com/flightlessmango/MangoHud) build (MIT), with frame times from gamescope patch 0125. - The HUD's CPU, GPU load, thermal and battery readers come from [@xXJSONDeruloXx](https://github.com/xXJSONDeruloXx)'s work. -- LSFG frame generation comes from Camille LaVey and the [Eden](https://eden-emu.dev) project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported by [@maxjivi05](https://github.com/maxjivi05). It needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. +- LSFG frame generation comes from Camille LaVey and the [Eden](https://eden-emu.dev) project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported by [@maxjivi05](https://github.com/maxjivi05). It requires [Lossless Scaling](https://store.steampowered.com/app/993090/) installed through Steam and ships none of its shaders. - Black frame insertion follows the design of [@artzox](https://github.com/artzox)'s [BFI Presenter](https://github.com/artzox/BFI-Presenter) (GPL-3.0): the strobe runs on the display's refresh clock and the game is paced to the lit refresh. Both build on [Blur Busters](https://blurbusters.com)' research on MPRT and motion blur. No BFI Presenter code is used. - Remote Play decodes through Android's MediaCodec or the [FFmpeg](https://ffmpeg.org) (LGPL-2.1-or-later) in Steam's runtime. Qualcomm low latency settings follow [Moonlight](https://github.com/moonlight-stream/moonlight-android) (GPL-3.0). - [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) sockets use the settings in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions. @@ -156,6 +157,13 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V +
+Setup and tools + +- The wireless debugging pairing keypad was inspired by Ryan Retro’s Handheld Toolkit. + +
+ ## Star history diff --git a/app/build.gradle b/app/build.gradle index e851dd0596..513fdef6aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,6 +82,8 @@ def buildBranch = providers.environmentVariable('GITHUB_HEAD_REF').getOrNull()?. ?: gitValue(['branch', '--show-current']) ?: '' def escapeJava = { String value -> value.replace('\\', '\\\\').replace('"', '\\"').replace('\n', ' ').replace('\r', ' ') } def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true' +// The Unit tests workflow compiles no APK, so it has no add-on packs to pin. +def unitTestsOnly = project.findProperty('unitTestsOnly')?.toString()?.toBoolean() ?: false def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim() def commitTime = (gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit]) ?: '0').with { it.isLong() ? it : '0' } def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines() @@ -96,10 +98,12 @@ def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines() def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name -> def pack = file("build/packs/${name}.tar.zst") if (!pack.isFile()) { - if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs") + if (ciBuild && !unitTestsOnly) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs") if (name == 'proot' && prootPackPin.PROOT_PACK_SHA256) { return [(name): [sha256: prootPackPin.PROOT_PACK_SHA256, size: (prootPackPin.PROOT_PACK_SIZE ?: '0') as long]] } + // A CI APK pins every pack, and CI_BUILD code assumes that, so the tests see a placeholder pin. + if (unitTestsOnly) return [(name): [sha256: '0' * 64, size: 0L]] return [(name): [sha256: '', size: 0L]] } def digest = java.security.MessageDigest.getInstance('SHA-256') @@ -238,6 +242,9 @@ android { doFirst { jvmTemp.mkdirs() } def logTarget = providers.systemProperty('robolectric.logging').orNull if (logTarget != null) systemProperty 'robolectric.logging', logTarget + // Robolectric resolves Android SDK jars inside the test JVM independently of Gradle. + def robolectricMirror = providers.gradleProperty('robolectricMavenMirror').orNull + if (robolectricMirror) systemProperty 'robolectric.dependency.repo.url', robolectricMirror } } @@ -284,6 +291,12 @@ def stageRuntimeAssets = tasks.register('stageRuntimeAssets', Sync) { into(runtimeAssetsDir) } android.sourceSets.main.assets.setSrcDirs([runtimeAssetsDir]) +def stageGraphicsNotices = tasks.register('stageGraphicsNotices', Copy) { + from(layout.projectDirectory.file('src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt')) + into(layout.buildDirectory.dir('graphicsNotices/licenses/graphics')) +} +android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('graphicsNotices')) +tasks.named('preBuild').configure { dependsOn(stageGraphicsNotices) } if (vitureSdkDir) android.sourceSets.main.assets.srcDir(layout.buildDirectory.dir('vitureAssets')) if (uvcDir) { def stageUvcNotices = tasks.register('stageUvcNotices', Copy) { diff --git a/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt b/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt index 681b32a10b..05d9559271 100644 --- a/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt +++ b/app/src/debug/java/com/droiddeck/launcher/ui/LauncherPreviews.kt @@ -1,10 +1,17 @@ package com.droiddeck.launcher.ui import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.material.icons.filled.Settings import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import com.droiddeck.launcher.R import com.droiddeck.launcher.input.SecondScreenMode @@ -23,6 +30,50 @@ private fun Launcher(tab: String, games: List Unit) = + DroidDeckTheme(frost = FrostChoice(transparency, cards, cardTransparency)) { + val wallpaper = Brush.linearGradient(listOf(Color(0xFFE2725B), Color(0xFF7A4BC2), Color(0xFF2A9D8F))) + Box(Modifier.fillMaxSize().background(wallpaper).background(LocalFrost.current ?: Color.Transparent)) { content() } + } + +@Composable +private fun FrostedLauncher(tab: String, transparency: Int = FROST_WALLPAPER_DEFAULT, cards: Boolean = false, cardTransparency: Int = FROST_DEFAULT) = + Frosted(transparency, cards, cardTransparency) { FrontEndScreen(sampleState(navigate = tab), sampleActions) } + +/** A settings step opened over frosted page text with see-through cards: the step is solid, so none of the text shows through it. */ +@Composable +private fun FrostedStepOut() = Frosted(cards = true) { + val text: @Composable (Int) -> String = { androidx.compose.ui.res.stringResource(it) } + Column(Modifier.padding(24.dp)) { + val line = List(8) { text(R.string.stores_shelf_new) }.joinToString(" ") + repeat(14) { androidx.compose.material3.Text(line, fontSize = 24.sp, color = LocalPalette.current.onBackground, maxLines = 1, softWrap = false) } + } + androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxSize()) { + val pill = with(androidx.compose.ui.platform.LocalDensity.current) { + androidx.compose.ui.geometry.Rect(androidx.compose.ui.geometry.Offset((maxWidth - 68.dp).toPx(), 16.dp.toPx()), androidx.compose.ui.geometry.Size(44.dp.toPx(), 44.dp.toPx())) + } + val accent = LocalPalette.current.signal + StepOut( + open = true, pill = pill, preferredSide = StepSide.Left, accent = accent, onDismiss = {}, onClosed = {}, items = 2, maxWidth = 440.dp, + handle = { androidx.compose.material3.Icon(androidx.compose.material.icons.Icons.Filled.Settings, null, tint = accent, modifier = Modifier.size(20.dp)) }, + ) { + StepTitle(text(R.string.stores_settings_eyebrow)) + Column(Modifier.stepItem(1)) { + SettingsRow(text(R.string.stores_show_mature), null) { ToggleSwitch(true, label = text(R.string.stores_show_mature)) {} } + SettingsRow(text(R.string.gog_achievements), text(R.string.gog_achievements_hint)) { ToggleSwitch(false, label = text(R.string.gog_achievements)) {} } + } + } + } +} + +@DroidDeckPreviews @Composable private fun FrostedSteamTabPreview() = FrostedLauncher("steam") +@DroidDeckPreviews @Composable private fun FrostedLibraryPreview() = FrostedLauncher("games") +@DroidDeckPreviews @Composable private fun FrostedSettingsCardsPreview() = FrostedLauncher("setup", cards = true) +@DroidDeckPreviews @Composable private fun FrostedSettingsClearestPreview() = FrostedLauncher("setup", transparency = FROST_MAX, cards = true, cardTransparency = FROST_MAX) +@DroidDeckPreviews @Composable private fun FrostedStepOutPreview() = FrostedStepOut() + /** The in-game menu on one page, as a session shows it. */ @Composable private fun SessionMenu(page: SessionDrawerPage, steam: Boolean = true, desktop: Boolean = false) = PreviewHost { @@ -69,6 +120,11 @@ internal val previewCases: List = listOf( PreviewCase("downloads") { Launcher("downloads") }, PreviewCase("settings") { Launcher("setup") }, PreviewCase("runtime-missing") { Launcher("setup", ready = false) }, + PreviewCase("frosted-steam-tab") { FrostedLauncher("steam") }, + PreviewCase("frosted-library", storesLoaded) { FrostedLauncher("games") }, + PreviewCase("frosted-settings-cards") { FrostedLauncher("setup", cards = true) }, + PreviewCase("frosted-settings-clearest") { FrostedLauncher("setup", transparency = FROST_MAX, cards = true, cardTransparency = FROST_MAX) }, + PreviewCase("frosted-step-out") { FrostedStepOut() }, PreviewCase("session-menu-controller") { SessionMenu(SessionDrawerPage.CONTROLLER) }, PreviewCase("session-menu-display") { SessionMenu(SessionDrawerPage.DISPLAY) }, PreviewCase("session-menu-hud") { SessionMenu(SessionDrawerPage.HUD) }, diff --git a/app/src/debug/java/com/droiddeck/launcher/ui/PreviewSupport.kt b/app/src/debug/java/com/droiddeck/launcher/ui/PreviewSupport.kt index 96a958e719..8a7da4c5d0 100644 --- a/app/src/debug/java/com/droiddeck/launcher/ui/PreviewSupport.kt +++ b/app/src/debug/java/com/droiddeck/launcher/ui/PreviewSupport.kt @@ -59,7 +59,7 @@ internal fun sampleState( internal val sampleActions: FrontEndActions = FrontEndActions( onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {}, onRom = {}, onResume = {}, onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, - onFrameGenPick = {}, onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {}, onRoms = {}, + onFrameGenPick = {}, onProtons = {}, onComponents = {}, onPerformance = {}, onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {}, onSetPhantomProcessLimit = { _, _ -> }, ) @@ -82,7 +82,7 @@ internal fun sampleDrawerActions( secondScreenDisplays = listOfNotNull(secondScreen?.let { SecondScreenDisplay(2, "Built-in · 1240×1080") }), selectedSecondScreenDisplay = if (secondScreen != null) 2 else -1, onSecondScreenDisplay = {}, gameSwapAvailable = secondScreen != null, dashboardAvailable = secondScreen != null, - onImportLossless = {}, onKeyboard = {}, onHardwareKeyboard = {}, + onKeyboard = {}, onHardwareKeyboard = {}, onSteamMenu = if (steam) ({}) else null, onQam = if (steam) ({}) else null, onLaunchAndroidApp = { _, _ -> }, onBackground = {}, onShareLogs = {}, onStop = {}, onClose = {}, ) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 55b75d36df..4211f6bbc5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,10 +33,15 @@ + + + + @@ -274,6 +279,17 @@ android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density" android:theme="@style/AppTheme" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/agent/dd-gh-login b/app/src/main/assets/agent/dd-gh-login index f9b0b7734a..e02054ffc1 100644 --- a/app/src/main/assets/agent/dd-gh-login +++ b/app/src/main/assets/agent/dd-gh-login @@ -28,6 +28,19 @@ float_code() { [ "$result" = ok ] } +# git pushes through gh's sign-in and commits as the signed-in account, with its no-reply address. +configure_git() { + gh auth setup-git || return 1 + [ -n "$(git config --global user.name)" ] && [ -n "$(git config --global user.email)" ] && return 0 + local user id login name + user=$(gh api user -q '"\(.id) \(.login) \(.name // .login)"') || return 1 + read -r id login name <<<"$user" + [ -n "$id" ] && [ -n "$login" ] || return 1 + [ -n "$(git config --global user.name)" ] || git config --global user.name "${name:-$login}" + [ -n "$(git config --global user.email)" ] || git config --global user.email "$id+$login@users.noreply.github.com" +} +if [ "${1:-}" = --git ]; then configure_git; exit; fi + coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; } gh_pid=$GH_PID exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}" @@ -48,5 +61,9 @@ while IFS= read -r line <&"$ghout"; do done wait "$gh_pid" status=$? +if [ $status = 0 ] && ! configure_git; then + echo "Signed in, but git could not be set up: run dd-gh-login --git" + status=1 +fi [ -n "$shown" ] && [ -n "$inbox" ] && [ -d "$inbox" ] && : > "$inbox/device-code" exit $status diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index a33cf37e49..01ae9fd830 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -10,6 +10,17 @@ add_subdirectory(adrenotools) add_subdirectory(thirdparty/dxbc) +# Pin ZeroFG to a fixed revision instead of vendoring thousands of generated shader lines. +include(FetchContent) +set(ZEROFG_VULKAN_HEADERS_DIR "${CMAKE_SYSROOT}/usr/include" CACHE PATH "" FORCE) +set(ZEROFG_PREBUILT_SHADERS ON CACHE STRING "" FORCE) +FetchContent_Declare(zerofg + GIT_REPOSITORY https://github.com/hy300leosquizz-ctrl/ZeroFG.git + GIT_TAG e6ca7ef9f9765db89847b6d8eed352e458f1a8bb + GIT_PROGRESS TRUE +) +FetchContent_MakeAvailable(zerofg) + set(DDFG_UPSTREAM "v0.3.0") set(DDFG_CHAIN_SRC framegen/ddfg/framegen.cpp diff --git a/app/src/main/cpp/fakeinput_steam.cpp b/app/src/main/cpp/fakeinput_steam.cpp index e6e4a2b6ac..4c592ded09 100644 --- a/app/src/main/cpp/fakeinput_steam.cpp +++ b/app/src/main/cpp/fakeinput_steam.cpp @@ -25,6 +25,7 @@ #include #endif #include +#include #include #include #include @@ -328,16 +329,28 @@ static constexpr int kWatchedFds = 1 << 16; static constexpr int kWatchedBits = sizeof(unsigned long) * 8; static std::atomic watched_fds[kWatchedFds / kWatchedBits]; static std::atomic watched_beyond{false}; +static std::atomic watched_count{0}; static void watch_fd(int fd) { if (fd < 0) return; - if (fd >= kWatchedFds) watched_beyond.store(true, std::memory_order_release); - else watched_fds[fd / kWatchedBits].fetch_or(1UL << (fd % kWatchedBits), std::memory_order_release); + if (fd >= kWatchedFds) { + watched_beyond.store(true, std::memory_order_release); + return; + } + const unsigned long bit = 1UL << (fd % kWatchedBits); + if (!(watched_fds[fd / kWatchedBits].fetch_or(bit, std::memory_order_acq_rel) & bit)) + watched_count.fetch_add(1, std::memory_order_acq_rel); } static void unwatch_fd(int fd) { - if (fd >= 0 && fd < kWatchedFds) - watched_fds[fd / kWatchedBits].fetch_and(~(1UL << (fd % kWatchedBits)), std::memory_order_release); + if (fd < 0 || fd >= kWatchedFds) return; + const unsigned long bit = 1UL << (fd % kWatchedBits); + if (watched_fds[fd / kWatchedBits].fetch_and(~bit, std::memory_order_acq_rel) & bit) + watched_count.fetch_sub(1, std::memory_order_acq_rel); +} + +static bool any_watched() { + return watched_count.load(std::memory_order_acquire) > 0 || watched_beyond.load(std::memory_order_acquire); } static bool watched(int fd) { @@ -711,6 +724,19 @@ ring_header_is_valid(const FakeInputRingHeader *ring) { ring->capacity == FAKE_INPUT_RING_CAPACITY; } +__attribute__((visibility("hidden"))) static int ring_wait(const FakeInputRingHeader *ring, uint64_t seen, long ns) { + struct timespec wait = {0, ns}; + if (syscall(SYS_futex, &ring->write_seq, FUTEX_WAIT, static_cast(seen), &wait, nullptr, 0) == 0 || + errno == EAGAIN || errno == ETIMEDOUT) + return 0; + if (errno == EINTR) return -1; + return nanosleep(&wait, nullptr); +} + +__attribute__((visibility("hidden"))) static void ring_wake(const FakeInputRingHeader *ring) { + syscall(SYS_futex, &ring->write_seq, FUTEX_WAKE, INT_MAX, nullptr, nullptr, 0); +} + struct SnapshotState { uint64_t sequence = 0; uint64_t write_seq = 0; @@ -1167,6 +1193,7 @@ __attribute__((visibility("hidden"))) static void flush_uinput(UinputWriter &w) __atomic_thread_fence(__ATOMIC_RELEASE); __atomic_store_n(&ring->snapshot_seq, sequence + 2, __ATOMIC_RELEASE); __atomic_store_n(&ring->write_seq, write_seq, __ATOMIC_RELEASE); + ring_wake(ring); } __attribute__((visibility("hidden"))) static ssize_t @@ -1540,6 +1567,12 @@ __attribute__((visibility("hidden"))) static void sleep_us(int us) { nanosleep(&interval, nullptr); } +__attribute__((visibility("hidden"))) static void +report_wait(const FakeInputRingHeader *ring, bool fresh, uint64_t seen, int us) { + if (fresh) ring_wait(ring, seen, us * 1000L); + else sleep_us(us); +} + __attribute__((visibility("hidden"))) static uint64_t monotonic_us() { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); @@ -1712,7 +1745,8 @@ __attribute__((visibility("hidden"))) static void *deck_report_thread(void *arg) int32_t axes[8] = {}; DeckExtras extras; while (live_pad_type() == PAD_TYPE_DECK) { - if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) { + bool fresh = read_snapshot(self->ring, snap); + if (fresh && snap.generation == ring_generation(self->ring)) { buttons = snap.buttons; memcpy(axes, snap.axes, sizeof(axes)); } @@ -1722,7 +1756,7 @@ __attribute__((visibility("hidden"))) static void *deck_report_thread(void *arg) if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) break; - sleep_us(controller_report_interval_us(DECK_REPORT_INTERVAL_US)); + report_wait(self->ring, fresh, snap.write_seq, controller_report_interval_us(DECK_REPORT_INTERVAL_US)); } syscall(SYS_close, self->peer); munmap(self->ring, self->mapping_size); @@ -1828,7 +1862,8 @@ __attribute__((visibility("hidden"))) static void *sony_report_thread(void *arg) SonyTouch touch; const uint64_t start_us = monotonic_us(); while (live_pad_type() == type) { - if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) { + bool fresh = read_snapshot(self->ring, snap); + if (fresh && snap.generation == ring_generation(self->ring)) { buttons = snap.buttons; memcpy(axes, snap.axes, sizeof(axes)); } @@ -1838,7 +1873,7 @@ __attribute__((visibility("hidden"))) static void *sony_report_thread(void *arg) if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) break; - sleep_us(controller_report_interval_us(DECK_REPORT_INTERVAL_US)); + report_wait(self->ring, fresh, snap.write_seq, controller_report_interval_us(DECK_REPORT_INTERVAL_US)); } syscall(SYS_close, self->peer); munmap(self->ring, self->mapping_size); @@ -2037,7 +2072,8 @@ __attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg) DeckExtras extras; const uint64_t start_us = monotonic_us(); while (live_pad_type() == PAD_TYPE_STEAM) { - if (read_snapshot(self->ring, snap) && snap.generation == ring_generation(self->ring)) { + bool fresh = read_snapshot(self->ring, snap); + if (fresh && snap.generation == ring_generation(self->ring)) { buttons = snap.buttons; memcpy(axes, snap.axes, sizeof(axes)); } @@ -2048,7 +2084,7 @@ __attribute__((visibility("hidden"))) static void *triton_pad_thread(void *arg) if (send(self->peer, report, sizeof(report), MSG_DONTWAIT | MSG_NOSIGNAL) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) break; - sleep_us(controller_report_interval_us(TRITON_REPORT_INTERVAL_US)); + report_wait(self->ring, fresh, snap.write_seq, controller_report_interval_us(TRITON_REPORT_INTERVAL_US)); } syscall(SYS_close, self->peer); munmap(self->ring, self->mapping_size); @@ -4016,6 +4052,7 @@ static ssize_t read_input(int fd, void *buf, size_t count) { errno = ENODEV; return -1; } + bool idle = false; for (int attempt = 0; attempt < 8; ++attempt) { size_t requested = count / sizeof(struct input_event); if (fake.keyframe_remaining == 0) { @@ -4037,7 +4074,10 @@ static ssize_t read_input(int fd, void *buf, size_t count) { capture_keyframe(fake, snap); } else { size_t events = std::min(requested, snap.write_seq - fake.read_seq); - if (events == 0) break; + if (events == 0) { + idle = true; + break; + } const uint8_t *ring_events = reinterpret_cast(fake.ring) + FAKE_INPUT_RING_HEADER_SIZE; std::vector input_events(events); @@ -4083,9 +4123,14 @@ static ssize_t read_input(int fd, void *buf, size_t count) { errno = EAGAIN; return -1; } + const FakeInputRingHeader *ring = fake.ring; + uint64_t seen = fake.read_seq; guard.unlock(); +#ifdef __GLIBC__ + pthread_testcancel(); +#endif struct timespec sleep_time = {0, backoff_ns}; - int result = nanosleep(&sleep_time, nullptr); + int result = idle ? ring_wait(ring, seen, backoff_ns) : nanosleep(&sleep_time, nullptr); guard.lock(); if (result < 0) return -1; if (low_latency(LATENCY_CONTROLLER)) backoff_ns = kLowLatencyRingWaitUs * 1000; @@ -4097,6 +4142,24 @@ EXPORT ssize_t read(int fd, void *buf, size_t count) { return read_input(fd, buf, count); } +// glibc's fortify failure; bionic (DroidDeck-Bionic preloads this library into its Wine processes) has no +// __chk_fail, and a library naming it there cannot be loaded, which stops every Wine program from starting. +#if defined(__BIONIC__) +[[noreturn]] static void fakeinput_chk_fail(void) { abort(); } +#else +extern "C" [[noreturn]] void __chk_fail(void); +[[noreturn]] static void fakeinput_chk_fail(void) { __chk_fail(); } +#endif + +/* Programs built with _FORTIFY_SOURCE (Flatpak runtimes among them) call these instead of read, poll + * and ppoll, and glibc's versions go straight to the kernel. */ +EXPORT ssize_t __read_chk(int fd, void *buf, size_t count, size_t buflen) { + static auto next_read_chk = reinterpret_cast(dlsym(RTLD_NEXT, "__read_chk")); + if (count > buflen) fakeinput_chk_fail(); + if (next_read_chk && !is_fake_input_fd(fd)) return next_read_chk(fd, buf, count, buflen); + return read_input(fd, buf, count); +} + EXPORT ssize_t readv(int fd, const struct iovec *iov, int iovcnt) { if (!is_fake_input_fd(fd)) return syscall(SYS_readv, fd, iov, iovcnt); if (iovcnt < 0 || iovcnt > IOV_MAX) { @@ -4218,7 +4281,7 @@ static int poll_fake(struct pollfd *fds, nfds_t nfds, int timeout, const auto my_poll = next_symbol(Next::poll); const auto my_ppoll = next_symbol(Next::ppoll); - nfds_t first = 0; + nfds_t first = any_watched() ? 0 : nfds; while (first < nfds && !watched(fds[first].fd)) first++; bool has_fake_fds = false; std::vector real_fds; @@ -4321,12 +4384,12 @@ EXPORT int poll(struct pollfd *fds, nfds_t nfds, int timeout) { EXPORT int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask) { const auto my_ppoll = next_symbol(Next::ppoll); - if (timeout && (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000L)) { - errno = EINVAL; - return -1; - } - for (nfds_t i = 0; i < nfds; ++i) { + for (nfds_t i = 0; any_watched() && i < nfds; ++i) { if (!is_fake_input_fd(fds[i].fd)) continue; + if (timeout && (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000L)) { + errno = EINVAL; + return -1; + } if (!sigmask) return poll_fake(fds, nfds, static_cast(timespec_to_ms(timeout)), nullptr); sigset_t all_signals, original_mask; @@ -4345,9 +4408,22 @@ EXPORT int ppoll(struct pollfd *fds, nfds_t nfds, return my_ppoll(fds, nfds, timeout, sigmask); } +EXPORT int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fdslen) { + if (fdslen / sizeof(*fds) < nfds) fakeinput_chk_fail(); + return poll(fds, nfds, timeout); +} + +EXPORT int __ppoll_chk(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, + const sigset_t *sigmask, size_t fdslen) { + if (fdslen / sizeof(*fds) < nfds) fakeinput_chk_fail(); + return ppoll(fds, nfds, timeout, sigmask); +} + EXPORT int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { const auto my_select = next_symbol(Next::select); + if (!any_watched()) + return my_select ? my_select(nfds, readfds, writefds, exceptfds, timeout) : -1; fd_set original_readfds; fd_set original_writefds; diff --git a/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp b/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp index 6e87890b3f..034f2c4d55 100644 --- a/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp +++ b/app/src/main/cpp/framegen/ddfg/ddfg_engine.cpp @@ -27,7 +27,31 @@ VkImageMemoryBarrier bar(VkImage img, VkImageLayout from, VkImageLayout to, } Engine::Engine() = default; -Engine::~Engine() { destroyRing(); fg_.destroy(); } +Engine::~Engine() { (void)destroy(); } + +bool Engine::destroy() { + if (!fg_.destroy()) { + DDFG_LOGE("native: retaining the input ring because GPU completion is unknown"); + return false; + } + if (!destroyRing(true)) { + DDFG_LOGE("native: could not release the input ring during teardown"); + return false; + } + dev_ = VK_NULL_HANDLE; + unavailable_ = true; + return true; +} + +void Engine::abandon() { + fg_.abandon(); + ring_[0] = Slot{}; + ring_[1] = Slot{}; + dev_ = VK_NULL_HANDLE; + queue_ = VK_NULL_HANDLE; + phys_ = VK_NULL_HANDLE; + unavailable_ = true; +} bool Engine::init(const VkTable& table, VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue) { @@ -59,15 +83,29 @@ bool Engine::prepare(uint32_t w, uint32_t h, VkFormat fmt) { if (unavailable_ || w == 0 || h == 0 || fmt == VK_FORMAT_UNDEFINED) return false; if (builtW_ == w && builtH_ == h && builtFmt_ == fmt && fg_.valid()) return true; - - if (!fg_.onResize(VkExtent2D{w, h}, fmt, false)) { + const bool formatChanged = fmt != builtFmt_; + if (!fg_.onResize(VkExtent2D{w, h}, fmt, formatChanged)) { DDFG_LOGE("native: onResize %ux%u failed; frame generation unavailable", w, h); unavailable_ = true; return false; } - destroyRing(); + bool deviceLost = false; + if (!destroyRing(false, &deviceLost)) { + DDFG_LOGE("native: could not safely release the previous input ring"); + unavailable_ = true; + return false; + } + if (deviceLost) { + DDFG_LOGE("native: device lost while releasing the input ring"); + unavailable_ = true; + return false; + } for (Slot& s : ring_) { - if (!makeSlot(s, w, h, fmt)) { destroyRing(); unavailable_ = true; return false; } + if (!makeSlot(s, w, h, fmt)) { + destroyRing(true); + unavailable_ = true; + return false; + } } builtW_ = w; builtH_ = h; builtFmt_ = fmt; history_ = 0; curr_ = 0; frames_ = 0; @@ -178,11 +216,37 @@ void Engine::destroySlot(Slot& s) { s = Slot{}; } -void Engine::destroyRing() { - if (dev_ == VK_NULL_HANDLE || !dd_.DeviceWaitIdle) return; - if (ring_[0].img || ring_[1].img) dd_.DeviceWaitIdle(dev_); - destroySlot(ring_[0]); destroySlot(ring_[1]); +bool Engine::destroyRing(bool deviceIdleConfirmed, bool* deviceLost) { + if (deviceLost) *deviceLost = false; + const bool hasResources = ring_[0].img || ring_[0].mem || ring_[0].view || + ring_[1].img || ring_[1].mem || ring_[1].view; + if (!hasResources) { + history_ = 0; + return true; + } + if (dev_ == VK_NULL_HANDLE) { + DDFG_LOGE("native: cannot release the input ring without a valid device"); + return false; + } + if (!deviceIdleConfirmed) { + if (!dd_.DeviceWaitIdle) { + DDFG_LOGE("native: cannot release the input ring without vkDeviceWaitIdle"); + return false; + } + const VkResult result = dd_.DeviceWaitIdle(dev_); + if (result == VK_ERROR_DEVICE_LOST) { + if (deviceLost) *deviceLost = true; + unavailable_ = true; + } else if (result != VK_SUCCESS) { + DDFG_LOGE("native: DeviceWaitIdle failed (%d); retaining the input ring", (int)result); + unavailable_ = true; + return false; + } + } + destroySlot(ring_[0]); + destroySlot(ring_[1]); history_ = 0; + return true; } } diff --git a/app/src/main/cpp/framegen/ddfg/ddfg_engine.h b/app/src/main/cpp/framegen/ddfg/ddfg_engine.h index 55c1ef8fa0..aff10a9033 100644 --- a/app/src/main/cpp/framegen/ddfg/ddfg_engine.h +++ b/app/src/main/cpp/framegen/ddfg/ddfg_engine.h @@ -36,13 +36,15 @@ public: uint32_t width, uint32_t height); void reset(); + bool destroy(); + void abandon(); private: struct Slot { VkImage img = VK_NULL_HANDLE; VkDeviceMemory mem = VK_NULL_HANDLE; VkImageView view = VK_NULL_HANDLE; bool valid = false; }; bool makeSlot(Slot& s, uint32_t w, uint32_t h, VkFormat fmt); void destroySlot(Slot& s); - void destroyRing(); + bool destroyRing(bool deviceIdleConfirmed = false, bool* deviceLost = nullptr); uint32_t memType(uint32_t bits, VkMemoryPropertyFlags props) const; DeviceDispatch dd_{}; diff --git a/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp b/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp index 61f5c154c7..af09e777d6 100644 --- a/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp +++ b/app/src/main/cpp/framegen/ddfg/embedded_shaders.hpp @@ -6,8 +6,216 @@ static const uint32_t OF3_LUMA_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00 static const size_t OF3_LUMA_LEN = 481; static const uint32_t OF3_DOWNSAMPLE_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x0000008au,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00030005u,0x00000009u,0x00646967u,0x00080005u,0x0000000du,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000016u,0x74734475u,0x00000000u,0x00040005u,0x00000030u,0x44637273u,0x00006d69u,0x00040005u,0x00000034u,0x63725375u,0x00000000u,0x00040005u,0x0000003au,0x65736162u,0x00000000u,0x00030005u,0x00000044u,0x00000068u,0x00030005u,0x0000004au,0x00000061u,0x00030005u,0x00000059u,0x00000062u,0x00030005u,0x00000065u,0x00000063u,0x00030005u,0x00000071u,0x00000064u,0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u,0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00040047u,0x00000034u,0x00000021u,0x00000020u,0x00040047u,0x00000034u,0x00000022u,0x00000000u,0x00040047u,0x00000089u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040015u,0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u,0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u,0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000003u,0x00040020u,0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u,0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x00040020u,0x0000001bu,0x00000007u,0x00000006u,0x0004002bu,0x0000000au,0x00000024u,0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x00040020u,0x0000002fu,0x00000007u,0x0000002eu,0x00090019u,0x00000031u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000032u,0x00000031u,0x00040020u,0x00000033u,0x00000000u,0x00000032u,0x0004003bu,0x00000033u,0x00000034u,0x00000000u,0x0004002bu,0x00000006u,0x00000036u,0x00000000u,0x0004002bu,0x00000013u,0x0000003du,0x40000000u,0x0004002bu,0x00000013u,0x0000003fu,0x3f800000u,0x0004002bu,0x00000013u,0x00000045u,0x3f000000u,0x00040020u,0x00000049u,0x00000007u,0x00000013u,0x0004002bu,0x00000013u,0x00000055u,0x00000000u,0x00040017u,0x00000056u,0x00000013u,0x00000004u,0x0004002bu,0x00000013u,0x00000085u,0x3e800000u,0x0004002bu,0x0000000au,0x00000088u,0x00000010u,0x0006002cu,0x0000000bu,0x00000089u,0x00000088u,0x00000088u,0x00000024u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000009u,0x00000007u,0x0004003bu,0x00000008u,0x00000012u,0x00000007u,0x0004003bu,0x0000002fu,0x00000030u,0x00000007u,0x0004003bu,0x0000002fu,0x0000003au,0x00000007u,0x0004003bu,0x0000002fu,0x00000044u,0x00000007u,0x0004003bu,0x00000049u,0x0000004au,0x00000007u,0x0004003bu,0x00000049u,0x00000059u,0x00000007u,0x0004003bu,0x00000049u,0x00000065u,0x00000007u,0x0004003bu,0x00000049u,0x00000071u,0x00000007u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu,0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u,0x00000010u,0x0003003eu,0x00000009u,0x00000011u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u,0x00000017u,0x0003003eu,0x00000012u,0x00000018u,0x00050041u,0x0000001bu,0x0000001cu,0x00000009u,0x0000001au,0x0004003du,0x00000006u,0x0000001du,0x0000001cu,0x00050041u,0x0000001bu,0x0000001eu,0x00000012u,0x0000001au,0x0004003du,0x00000006u,0x0000001fu,0x0000001eu,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu,0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau,0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050041u,0x0000001bu,0x00000025u,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000026u,0x00000025u,0x00050041u,0x0000001bu,0x00000027u,0x00000012u,0x00000024u,0x0004003du,0x00000006u,0x00000028u,0x00000027u,0x000500afu,0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x00000005u,0x00000029u,0x00000022u,0x000300f7u,0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu,0x000100fdu,0x000200f8u,0x0000002cu,0x0004003du,0x00000032u,0x00000035u,0x00000034u,0x00040064u,0x00000031u,0x00000037u,0x00000035u,0x00050067u,0x00000007u,0x00000038u,0x00000037u,0x00000036u,0x0004006fu,0x0000002eu,0x00000039u,0x00000038u,0x0003003eu,0x00000030u,0x00000039u,0x0004003du,0x00000007u,0x0000003bu,0x00000009u,0x0004006fu,0x0000002eu,0x0000003cu,0x0000003bu,0x0005008eu,0x0000002eu,0x0000003eu,0x0000003cu,0x0000003du,0x00050050u,0x0000002eu,0x00000040u,0x0000003fu,0x0000003fu,0x00050081u,0x0000002eu,0x00000041u,0x0000003eu,0x00000040u,0x0004003du,0x0000002eu,0x00000042u,0x00000030u,0x00050088u,0x0000002eu,0x00000043u,0x00000041u,0x00000042u,0x0003003eu,0x0000003au,0x00000043u,0x0004003du,0x0000002eu,0x00000046u,0x00000030u,0x00050050u,0x0000002eu,0x00000047u,0x00000045u,0x00000045u,0x00050088u,0x0000002eu,0x00000048u,0x00000047u,0x00000046u,0x0003003eu,0x00000044u,0x00000048u,0x0004003du,0x00000032u,0x0000004bu,0x00000034u,0x0004003du,0x0000002eu,0x0000004cu,0x0000003au,0x00050041u,0x00000049u,0x0000004du,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x0000004eu,0x0000004du,0x0004007fu,0x00000013u,0x0000004fu,0x0000004eu,0x00050041u,0x00000049u,0x00000050u,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x00000051u,0x00000050u,0x0004007fu,0x00000013u,0x00000052u,0x00000051u,0x00050050u,0x0000002eu,0x00000053u,0x0000004fu,0x00000052u,0x00050081u,0x0000002eu,0x00000054u,0x0000004cu,0x00000053u,0x00070058u,0x00000056u,0x00000057u,0x0000004bu,0x00000054u,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x00000058u,0x00000057u,0x00000000u,0x0003003eu,0x0000004au,0x00000058u,0x0004003du,0x00000032u,0x0000005au,0x00000034u,0x0004003du,0x0000002eu,0x0000005bu,0x0000003au,0x00050041u,0x00000049u,0x0000005cu,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x0000005du,0x0000005cu,0x00050041u,0x00000049u,0x0000005eu,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x0000005fu,0x0000005eu,0x0004007fu,0x00000013u,0x00000060u,0x0000005fu,0x00050050u,0x0000002eu,0x00000061u,0x0000005du,0x00000060u,0x00050081u,0x0000002eu,0x00000062u,0x0000005bu,0x00000061u,0x00070058u,0x00000056u,0x00000063u,0x0000005au,0x00000062u,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x00000064u,0x00000063u,0x00000000u,0x0003003eu,0x00000059u,0x00000064u,0x0004003du,0x00000032u,0x00000066u,0x00000034u,0x0004003du,0x0000002eu,0x00000067u,0x0000003au,0x00050041u,0x00000049u,0x00000068u,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x00000069u,0x00000068u,0x0004007fu,0x00000013u,0x0000006au,0x00000069u,0x00050041u,0x00000049u,0x0000006bu,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x0000006cu,0x0000006bu,0x00050050u,0x0000002eu,0x0000006du,0x0000006au,0x0000006cu,0x00050081u,0x0000002eu,0x0000006eu,0x00000067u,0x0000006du,0x00070058u,0x00000056u,0x0000006fu,0x00000066u,0x0000006eu,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x00000070u,0x0000006fu,0x00000000u,0x0003003eu,0x00000065u,0x00000070u,0x0004003du,0x00000032u,0x00000072u,0x00000034u,0x0004003du,0x0000002eu,0x00000073u,0x0000003au,0x00050041u,0x00000049u,0x00000074u,0x00000044u,0x0000001au,0x0004003du,0x00000013u,0x00000075u,0x00000074u,0x00050041u,0x00000049u,0x00000076u,0x00000044u,0x00000024u,0x0004003du,0x00000013u,0x00000077u,0x00000076u,0x00050050u,0x0000002eu,0x00000078u,0x00000075u,0x00000077u,0x00050081u,0x0000002eu,0x00000079u,0x00000073u,0x00000078u,0x00070058u,0x00000056u,0x0000007au,0x00000072u,0x00000079u,0x00000002u,0x00000055u,0x00050051u,0x00000013u,0x0000007bu,0x0000007au,0x00000000u,0x0003003eu,0x00000071u,0x0000007bu,0x0004003du,0x00000014u,0x0000007cu,0x00000016u,0x0004003du,0x00000007u,0x0000007du,0x00000009u,0x0004003du,0x00000013u,0x0000007eu,0x0000004au,0x0004003du,0x00000013u,0x0000007fu,0x00000059u,0x00050081u,0x00000013u,0x00000080u,0x0000007eu,0x0000007fu,0x0004003du,0x00000013u,0x00000081u,0x00000065u,0x00050081u,0x00000013u,0x00000082u,0x00000080u,0x00000081u,0x0004003du,0x00000013u,0x00000083u,0x00000071u,0x00050081u,0x00000013u,0x00000084u,0x00000082u,0x00000083u,0x00050085u,0x00000013u,0x00000086u,0x00000084u,0x00000085u,0x00070050u,0x00000056u,0x00000087u,0x00000086u,0x00000055u,0x00000055u,0x00000055u,0x00040063u,0x0000007cu,0x0000007du,0x00000087u,0x000100fdu,0x00010038u}; static const size_t OF3_DOWNSAMPLE_LEN = 753; -static const uint32_t OF3_FLOW_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000185u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00030005u,0x00000009u,0x00646967u,0x00080005u,0x0000000du,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000016u,0x6f6c4675u,0x00000077u,0x00040005u,0x00000030u,0x44766e69u,0x00006d69u,0x00030005u,0x00000036u,0x00007675u,0x00040005u,0x0000003fu,0x654c6f74u,0x006c6576u,0x00030005u,0x00000040u,0x00000055u,0x00060006u,0x00000040u,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x00000040u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u,0x00000040u,0x00000002u,0x30646170u,0x00000000u,0x00050006u,0x00000040u,0x00000003u,0x31646170u,0x00000000u,0x00030005u,0x00000042u,0x00000000u,0x00050005u,0x0000004au,0x64657270u,0x6c6c7546u,0x00000000u,0x00050005u,0x0000004eu,0x65725075u,0x74636964u,0x0000726fu,0x00050005u,0x00000055u,0x64657270u,0x6576654cu,0x0000006cu,0x00040005u,0x00000059u,0x74736562u,0x00646153u,0x00050005u,0x0000005bu,0x74736562u,0x70736944u,0x00000000u,0x00030005u,0x0000005du,0x00007973u,0x00030005u,0x00000067u,0x00007873u,0x00040005u,0x0000006fu,0x646e6163u,0x00000000u,0x00030005u,0x00000077u,0x00646173u,0x00030005u,0x00000078u,0x00007962u,0x00030005u,0x00000081u,0x00007862u,0x00030005u,0x00000089u,0x00006f62u,0x00030005u,0x0000008fu,0x00000070u,0x00050005u,0x00000090u,0x6d754c75u,0x65725061u,0x00000076u,0x00030005u,0x00000099u,0x00000063u,0x00050005u,0x0000009au,0x6d754c75u,0x72754361u,0x00000072u,0x00040005u,0x000000cau,0x43646173u,0x00000000u,0x00040005u,0x000000ccu,0x58646173u,0x0000006du,0x00040005u,0x000000cdu,0x58646173u,0x00000070u,0x00040005u,0x000000ceu,0x59646173u,0x0000006du,0x00040005u,0x000000cfu,0x59646173u,0x00000070u,0x00030005u,0x000000d0u,0x00007962u,0x00030005u,0x000000d8u,0x00007862u,0x00030005u,0x000000e0u,0x00006f62u,0x00030005u,0x000000e6u,0x00000070u,0x00040005u,0x000000efu,0x646e6163u,0x00006d58u,0x00040005u,0x000000f4u,0x646e6163u,0x00007058u,0x00040005u,0x000000f8u,0x646e6163u,0x00006d59u,0x00040005u,0x000000fcu,0x646e6163u,0x00007059u,0x00030005u,0x00000148u,0x00007864u,0x00030005u,0x00000149u,0x00007964u,0x00040005u,0x0000014au,0x6f6e6564u,0x0000586du,0x00040005u,0x00000152u,0x6f6e6564u,0x0000596du,0x00050005u,0x00000176u,0x776f6c66u,0x6c6c7546u,0x00000000u,0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u,0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00030047u,0x00000040u,0x00000002u,0x00050048u,0x00000040u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x00000040u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000040u,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x00000040u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000042u,0x00000021u,0x00000000u,0x00040047u,0x00000042u,0x00000022u,0x00000000u,0x00040047u,0x0000004eu,0x00000021u,0x00000022u,0x00040047u,0x0000004eu,0x00000022u,0x00000000u,0x00040047u,0x00000090u,0x00000021u,0x00000020u,0x00040047u,0x00000090u,0x00000022u,0x00000000u,0x00040047u,0x0000009au,0x00000021u,0x00000021u,0x00040047u,0x0000009au,0x00000022u,0x00000000u,0x00040047u,0x00000184u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040015u,0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u,0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u,0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u,0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x00040020u,0x0000001bu,0x00000007u,0x00000006u,0x0004002bu,0x0000000au,0x00000024u,0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x00040020u,0x0000002fu,0x00000007u,0x0000002eu,0x0004002bu,0x00000013u,0x00000031u,0x3f800000u,0x0004002bu,0x00000013u,0x00000039u,0x3f000000u,0x00040020u,0x0000003eu,0x00000007u,0x00000013u,0x0006001eu,0x00000040u,0x00000013u,0x0000000au,0x0000000au,0x0000000au,0x00040020u,0x00000041u,0x00000002u,0x00000040u,0x0004003bu,0x00000041u,0x00000042u,0x00000002u,0x0004002bu,0x00000006u,0x00000043u,0x00000001u,0x00040020u,0x00000044u,0x00000002u,0x0000000au,0x00090019u,0x0000004bu,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x0000004cu,0x0000004bu,0x00040020u,0x0000004du,0x00000000u,0x0000004cu,0x0004003bu,0x0000004du,0x0000004eu,0x00000000u,0x0004002bu,0x00000013u,0x00000051u,0x00000000u,0x00040017u,0x00000052u,0x00000013u,0x00000004u,0x0004002bu,0x00000013u,0x0000005au,0x7f7fffffu,0x0004002bu,0x00000006u,0x0000005eu,0xfffffffdu,0x0004002bu,0x00000006u,0x00000065u,0x00000003u,0x0004002bu,0x00000006u,0x00000079u,0xffffffffu,0x0004003bu,0x0000004du,0x00000090u,0x00000000u,0x0004003bu,0x0000004du,0x0000009au,0x00000000u,0x0004002bu,0x00000013u,0x000000afu,0x3bc49ba6u,0x0004002bu,0x00000013u,0x000000f1u,0xbf800000u,0x0005002cu,0x0000002eu,0x000000f2u,0x000000f1u,0x00000051u,0x0005002cu,0x0000002eu,0x000000f6u,0x00000031u,0x00000051u,0x0005002cu,0x0000002eu,0x000000fau,0x00000051u,0x000000f1u,0x0005002cu,0x0000002eu,0x000000feu,0x00000051u,0x00000031u,0x0004002bu,0x00000013u,0x0000014cu,0x40000000u,0x0004002bu,0x00000013u,0x0000015au,0x358637bdu,0x0004002bu,0x00000013u,0x00000164u,0xbf000000u,0x0004002bu,0x0000000au,0x00000183u,0x00000010u,0x0006002cu,0x0000000bu,0x00000184u,0x00000183u,0x00000183u,0x00000024u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000009u,0x00000007u,0x0004003bu,0x00000008u,0x00000012u,0x00000007u,0x0004003bu,0x0000002fu,0x00000030u,0x00000007u,0x0004003bu,0x0000002fu,0x00000036u,0x00000007u,0x0004003bu,0x0000003eu,0x0000003fu,0x00000007u,0x0004003bu,0x0000002fu,0x0000004au,0x00000007u,0x0004003bu,0x0000002fu,0x00000055u,0x00000007u,0x0004003bu,0x0000003eu,0x00000059u,0x00000007u,0x0004003bu,0x0000002fu,0x0000005bu,0x00000007u,0x0004003bu,0x0000001bu,0x0000005du,0x00000007u,0x0004003bu,0x0000001bu,0x00000067u,0x00000007u,0x0004003bu,0x0000002fu,0x0000006fu,0x00000007u,0x0004003bu,0x0000003eu,0x00000077u,0x00000007u,0x0004003bu,0x0000001bu,0x00000078u,0x00000007u,0x0004003bu,0x0000001bu,0x00000081u,0x00000007u,0x0004003bu,0x0000002fu,0x00000089u,0x00000007u,0x0004003bu,0x0000003eu,0x0000008fu,0x00000007u,0x0004003bu,0x0000003eu,0x00000099u,0x00000007u,0x0004003bu,0x0000003eu,0x000000cau,0x00000007u,0x0004003bu,0x0000003eu,0x000000ccu,0x00000007u,0x0004003bu,0x0000003eu,0x000000cdu,0x00000007u,0x0004003bu,0x0000003eu,0x000000ceu,0x00000007u,0x0004003bu,0x0000003eu,0x000000cfu,0x00000007u,0x0004003bu,0x0000001bu,0x000000d0u,0x00000007u,0x0004003bu,0x0000001bu,0x000000d8u,0x00000007u,0x0004003bu,0x0000002fu,0x000000e0u,0x00000007u,0x0004003bu,0x0000003eu,0x000000e6u,0x00000007u,0x0004003bu,0x0000002fu,0x000000efu,0x00000007u,0x0004003bu,0x0000002fu,0x000000f4u,0x00000007u,0x0004003bu,0x0000002fu,0x000000f8u,0x00000007u,0x0004003bu,0x0000002fu,0x000000fcu,0x00000007u,0x0004003bu,0x0000003eu,0x00000148u,0x00000007u,0x0004003bu,0x0000003eu,0x00000149u,0x00000007u,0x0004003bu,0x0000003eu,0x0000014au,0x00000007u,0x0004003bu,0x0000003eu,0x00000152u,0x00000007u,0x0004003bu,0x0000002fu,0x00000176u,0x00000007u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu,0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u,0x00000010u,0x0003003eu,0x00000009u,0x00000011u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u,0x00000017u,0x0003003eu,0x00000012u,0x00000018u,0x00050041u,0x0000001bu,0x0000001cu,0x00000009u,0x0000001au,0x0004003du,0x00000006u,0x0000001du,0x0000001cu,0x00050041u,0x0000001bu,0x0000001eu,0x00000012u,0x0000001au,0x0004003du,0x00000006u,0x0000001fu,0x0000001eu,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu,0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau,0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050041u,0x0000001bu,0x00000025u,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000026u,0x00000025u,0x00050041u,0x0000001bu,0x00000027u,0x00000012u,0x00000024u,0x0004003du,0x00000006u,0x00000028u,0x00000027u,0x000500afu,0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x00000005u,0x00000029u,0x00000022u,0x000300f7u,0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu,0x000100fdu,0x000200f8u,0x0000002cu,0x0004003du,0x00000007u,0x00000032u,0x00000012u,0x0004006fu,0x0000002eu,0x00000033u,0x00000032u,0x00050050u,0x0000002eu,0x00000034u,0x00000031u,0x00000031u,0x00050088u,0x0000002eu,0x00000035u,0x00000034u,0x00000033u,0x0003003eu,0x00000030u,0x00000035u,0x0004003du,0x00000007u,0x00000037u,0x00000009u,0x0004006fu,0x0000002eu,0x00000038u,0x00000037u,0x00050050u,0x0000002eu,0x0000003au,0x00000039u,0x00000039u,0x00050081u,0x0000002eu,0x0000003bu,0x00000038u,0x0000003au,0x0004003du,0x0000002eu,0x0000003cu,0x00000030u,0x00050085u,0x0000002eu,0x0000003du,0x0000003bu,0x0000003cu,0x0003003eu,0x00000036u,0x0000003du,0x00050041u,0x00000044u,0x00000045u,0x00000042u,0x00000043u,0x0004003du,0x0000000au,0x00000046u,0x00000045u,0x00040070u,0x00000013u,0x00000047u,0x00000046u,0x0004007fu,0x00000013u,0x00000048u,0x00000047u,0x0006000cu,0x00000013u,0x00000049u,0x00000001u,0x0000001du,0x00000048u,0x0003003eu,0x0000003fu,0x00000049u,0x0004003du,0x0000004cu,0x0000004fu,0x0000004eu,0x0004003du,0x0000002eu,0x00000050u,0x00000036u,0x00070058u,0x00000052u,0x00000053u,0x0000004fu,0x00000050u,0x00000002u,0x00000051u,0x0007004fu,0x0000002eu,0x00000054u,0x00000053u,0x00000053u,0x00000000u,0x00000001u,0x0003003eu,0x0000004au,0x00000054u,0x0004003du,0x0000002eu,0x00000056u,0x0000004au,0x0004003du,0x00000013u,0x00000057u,0x0000003fu,0x0005008eu,0x0000002eu,0x00000058u,0x00000056u,0x00000057u,0x0003003eu,0x00000055u,0x00000058u,0x0003003eu,0x00000059u,0x0000005au,0x0004003du,0x0000002eu,0x0000005cu,0x00000055u,0x0003003eu,0x0000005bu,0x0000005cu,0x0003003eu,0x0000005du,0x0000005eu,0x000200f9u,0x0000005fu,0x000200f8u,0x0000005fu,0x000400f6u,0x00000061u,0x00000062u,0x00000000u,0x000200f9u,0x00000063u,0x000200f8u,0x00000063u,0x0004003du,0x00000006u,0x00000064u,0x0000005du,0x000500b3u,0x00000019u,0x00000066u,0x00000064u,0x00000065u,0x000400fau,0x00000066u,0x00000060u,0x00000061u,0x000200f8u,0x00000060u,0x0003003eu,0x00000067u,0x0000005eu,0x000200f9u,0x00000068u,0x000200f8u,0x00000068u,0x000400f6u,0x0000006au,0x0000006bu,0x00000000u,0x000200f9u,0x0000006cu,0x000200f8u,0x0000006cu,0x0004003du,0x00000006u,0x0000006du,0x00000067u,0x000500b3u,0x00000019u,0x0000006eu,0x0000006du,0x00000065u,0x000400fau,0x0000006eu,0x00000069u,0x0000006au,0x000200f8u,0x00000069u,0x0004003du,0x0000002eu,0x00000070u,0x00000055u,0x0004003du,0x00000006u,0x00000071u,0x00000067u,0x0004006fu,0x00000013u,0x00000072u,0x00000071u,0x0004003du,0x00000006u,0x00000073u,0x0000005du,0x0004006fu,0x00000013u,0x00000074u,0x00000073u,0x00050050u,0x0000002eu,0x00000075u,0x00000072u,0x00000074u,0x00050081u,0x0000002eu,0x00000076u,0x00000070u,0x00000075u,0x0003003eu,0x0000006fu,0x00000076u,0x0003003eu,0x00000077u,0x00000051u,0x0003003eu,0x00000078u,0x00000079u,0x000200f9u,0x0000007au,0x000200f8u,0x0000007au,0x000400f6u,0x0000007cu,0x0000007du,0x00000000u,0x000200f9u,0x0000007eu,0x000200f8u,0x0000007eu,0x0004003du,0x00000006u,0x0000007fu,0x00000078u,0x000500b3u,0x00000019u,0x00000080u,0x0000007fu,0x00000043u,0x000400fau,0x00000080u,0x0000007bu,0x0000007cu,0x000200f8u,0x0000007bu,0x0003003eu,0x00000081u,0x00000079u,0x000200f9u,0x00000082u,0x000200f8u,0x00000082u,0x000400f6u,0x00000084u,0x00000085u,0x00000000u,0x000200f9u,0x00000086u,0x000200f8u,0x00000086u,0x0004003du,0x00000006u,0x00000087u,0x00000081u,0x000500b3u,0x00000019u,0x00000088u,0x00000087u,0x00000043u,0x000400fau,0x00000088u,0x00000083u,0x00000084u,0x000200f8u,0x00000083u,0x0004003du,0x00000006u,0x0000008au,0x00000081u,0x0004006fu,0x00000013u,0x0000008bu,0x0000008au,0x0004003du,0x00000006u,0x0000008cu,0x00000078u,0x0004006fu,0x00000013u,0x0000008du,0x0000008cu,0x00050050u,0x0000002eu,0x0000008eu,0x0000008bu,0x0000008du,0x0003003eu,0x00000089u,0x0000008eu,0x0004003du,0x0000004cu,0x00000091u,0x00000090u,0x0004003du,0x0000002eu,0x00000092u,0x00000036u,0x0004003du,0x0000002eu,0x00000093u,0x00000089u,0x0004003du,0x0000002eu,0x00000094u,0x00000030u,0x00050085u,0x0000002eu,0x00000095u,0x00000093u,0x00000094u,0x00050081u,0x0000002eu,0x00000096u,0x00000092u,0x00000095u,0x00070058u,0x00000052u,0x00000097u,0x00000091u,0x00000096u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000098u,0x00000097u,0x00000000u,0x0003003eu,0x0000008fu,0x00000098u,0x0004003du,0x0000004cu,0x0000009bu,0x0000009au,0x0004003du,0x0000002eu,0x0000009cu,0x00000036u,0x0004003du,0x0000002eu,0x0000009du,0x00000089u,0x0004003du,0x0000002eu,0x0000009eu,0x0000006fu,0x00050081u,0x0000002eu,0x0000009fu,0x0000009du,0x0000009eu,0x0004003du,0x0000002eu,0x000000a0u,0x00000030u,0x00050085u,0x0000002eu,0x000000a1u,0x0000009fu,0x000000a0u,0x00050081u,0x0000002eu,0x000000a2u,0x0000009cu,0x000000a1u,0x00070058u,0x00000052u,0x000000a3u,0x0000009bu,0x000000a2u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x000000a4u,0x000000a3u,0x00000000u,0x0003003eu,0x00000099u,0x000000a4u,0x0004003du,0x00000013u,0x000000a5u,0x0000008fu,0x0004003du,0x00000013u,0x000000a6u,0x00000099u,0x00050083u,0x00000013u,0x000000a7u,0x000000a5u,0x000000a6u,0x0006000cu,0x00000013u,0x000000a8u,0x00000001u,0x00000004u,0x000000a7u,0x0004003du,0x00000013u,0x000000a9u,0x00000077u,0x00050081u,0x00000013u,0x000000aau,0x000000a9u,0x000000a8u,0x0003003eu,0x00000077u,0x000000aau,0x000200f9u,0x00000085u,0x000200f8u,0x00000085u,0x0004003du,0x00000006u,0x000000abu,0x00000081u,0x00050080u,0x00000006u,0x000000acu,0x000000abu,0x00000043u,0x0003003eu,0x00000081u,0x000000acu,0x000200f9u,0x00000082u,0x000200f8u,0x00000084u,0x000200f9u,0x0000007du,0x000200f8u,0x0000007du,0x0004003du,0x00000006u,0x000000adu,0x00000078u,0x00050080u,0x00000006u,0x000000aeu,0x000000adu,0x00000043u,0x0003003eu,0x00000078u,0x000000aeu,0x000200f9u,0x0000007au,0x000200f8u,0x0000007cu,0x0004003du,0x00000006u,0x000000b0u,0x00000067u,0x0004006fu,0x00000013u,0x000000b1u,0x000000b0u,0x0006000cu,0x00000013u,0x000000b2u,0x00000001u,0x00000004u,0x000000b1u,0x0004003du,0x00000006u,0x000000b3u,0x0000005du,0x0004006fu,0x00000013u,0x000000b4u,0x000000b3u,0x0006000cu,0x00000013u,0x000000b5u,0x00000001u,0x00000004u,0x000000b4u,0x00050081u,0x00000013u,0x000000b6u,0x000000b2u,0x000000b5u,0x00050085u,0x00000013u,0x000000b7u,0x000000afu,0x000000b6u,0x0004003du,0x00000013u,0x000000b8u,0x00000077u,0x00050081u,0x00000013u,0x000000b9u,0x000000b8u,0x000000b7u,0x0003003eu,0x00000077u,0x000000b9u,0x0004003du,0x00000013u,0x000000bau,0x00000077u,0x0004003du,0x00000013u,0x000000bbu,0x00000059u,0x000500b8u,0x00000019u,0x000000bcu,0x000000bau,0x000000bbu,0x000300f7u,0x000000beu,0x00000000u,0x000400fau,0x000000bcu,0x000000bdu,0x000000beu,0x000200f8u,0x000000bdu,0x0004003du,0x00000013u,0x000000bfu,0x00000077u,0x0003003eu,0x00000059u,0x000000bfu,0x0004003du,0x0000002eu,0x000000c0u,0x0000006fu,0x0003003eu,0x0000005bu,0x000000c0u,0x000200f9u,0x000000beu,0x000200f8u,0x000000beu,0x000200f9u,0x0000006bu,0x000200f8u,0x0000006bu,0x0004003du,0x00000006u,0x000000c1u,0x00000067u,0x00050080u,0x00000006u,0x000000c2u,0x000000c1u,0x00000043u,0x0003003eu,0x00000067u,0x000000c2u,0x000200f9u,0x00000068u,0x000200f8u,0x0000006au,0x000200f9u,0x00000062u,0x000200f8u,0x00000062u,0x0004003du,0x00000006u,0x000000c3u,0x0000005du,0x00050080u,0x00000006u,0x000000c4u,0x000000c3u,0x00000043u,0x0003003eu,0x0000005du,0x000000c4u,0x000200f9u,0x0000005fu,0x000200f8u,0x00000061u,0x00050041u,0x00000044u,0x000000c5u,0x00000042u,0x00000043u,0x0004003du,0x0000000au,0x000000c6u,0x000000c5u,0x000500aau,0x00000019u,0x000000c7u,0x000000c6u,0x0000001au,0x000300f7u,0x000000c9u,0x00000000u,0x000400fau,0x000000c7u,0x000000c8u,0x000000c9u,0x000200f8u,0x000000c8u,0x0004003du,0x00000013u,0x000000cbu,0x00000059u,0x0003003eu,0x000000cau,0x000000cbu,0x0003003eu,0x000000ccu,0x00000051u,0x0003003eu,0x000000cdu,0x00000051u,0x0003003eu,0x000000ceu,0x00000051u,0x0003003eu,0x000000cfu,0x00000051u,0x0003003eu,0x000000d0u,0x00000079u,0x000200f9u,0x000000d1u,0x000200f8u,0x000000d1u,0x000400f6u,0x000000d3u,0x000000d4u,0x00000000u,0x000200f9u,0x000000d5u,0x000200f8u,0x000000d5u,0x0004003du,0x00000006u,0x000000d6u,0x000000d0u,0x000500b3u,0x00000019u,0x000000d7u,0x000000d6u,0x00000043u,0x000400fau,0x000000d7u,0x000000d2u,0x000000d3u,0x000200f8u,0x000000d2u,0x0003003eu,0x000000d8u,0x00000079u,0x000200f9u,0x000000d9u,0x000200f8u,0x000000d9u,0x000400f6u,0x000000dbu,0x000000dcu,0x00000000u,0x000200f9u,0x000000ddu,0x000200f8u,0x000000ddu,0x0004003du,0x00000006u,0x000000deu,0x000000d8u,0x000500b3u,0x00000019u,0x000000dfu,0x000000deu,0x00000043u,0x000400fau,0x000000dfu,0x000000dau,0x000000dbu,0x000200f8u,0x000000dau,0x0004003du,0x00000006u,0x000000e1u,0x000000d8u,0x0004006fu,0x00000013u,0x000000e2u,0x000000e1u,0x0004003du,0x00000006u,0x000000e3u,0x000000d0u,0x0004006fu,0x00000013u,0x000000e4u,0x000000e3u,0x00050050u,0x0000002eu,0x000000e5u,0x000000e2u,0x000000e4u,0x0003003eu,0x000000e0u,0x000000e5u,0x0004003du,0x0000004cu,0x000000e7u,0x00000090u,0x0004003du,0x0000002eu,0x000000e8u,0x00000036u,0x0004003du,0x0000002eu,0x000000e9u,0x000000e0u,0x0004003du,0x0000002eu,0x000000eau,0x00000030u,0x00050085u,0x0000002eu,0x000000ebu,0x000000e9u,0x000000eau,0x00050081u,0x0000002eu,0x000000ecu,0x000000e8u,0x000000ebu,0x00070058u,0x00000052u,0x000000edu,0x000000e7u,0x000000ecu,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x000000eeu,0x000000edu,0x00000000u,0x0003003eu,0x000000e6u,0x000000eeu,0x0004003du,0x0000002eu,0x000000f0u,0x0000005bu,0x00050081u,0x0000002eu,0x000000f3u,0x000000f0u,0x000000f2u,0x0003003eu,0x000000efu,0x000000f3u,0x0004003du,0x0000002eu,0x000000f5u,0x0000005bu,0x00050081u,0x0000002eu,0x000000f7u,0x000000f5u,0x000000f6u,0x0003003eu,0x000000f4u,0x000000f7u,0x0004003du,0x0000002eu,0x000000f9u,0x0000005bu,0x00050081u,0x0000002eu,0x000000fbu,0x000000f9u,0x000000fau,0x0003003eu,0x000000f8u,0x000000fbu,0x0004003du,0x0000002eu,0x000000fdu,0x0000005bu,0x00050081u,0x0000002eu,0x000000ffu,0x000000fdu,0x000000feu,0x0003003eu,0x000000fcu,0x000000ffu,0x0004003du,0x00000013u,0x00000100u,0x000000e6u,0x0004003du,0x0000004cu,0x00000101u,0x0000009au,0x0004003du,0x0000002eu,0x00000102u,0x00000036u,0x0004003du,0x0000002eu,0x00000103u,0x000000e0u,0x0004003du,0x0000002eu,0x00000104u,0x000000efu,0x00050081u,0x0000002eu,0x00000105u,0x00000103u,0x00000104u,0x0004003du,0x0000002eu,0x00000106u,0x00000030u,0x00050085u,0x0000002eu,0x00000107u,0x00000105u,0x00000106u,0x00050081u,0x0000002eu,0x00000108u,0x00000102u,0x00000107u,0x00070058u,0x00000052u,0x00000109u,0x00000101u,0x00000108u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x0000010au,0x00000109u,0x00000000u,0x00050083u,0x00000013u,0x0000010bu,0x00000100u,0x0000010au,0x0006000cu,0x00000013u,0x0000010cu,0x00000001u,0x00000004u,0x0000010bu,0x0004003du,0x00000013u,0x0000010du,0x000000ccu,0x00050081u,0x00000013u,0x0000010eu,0x0000010du,0x0000010cu,0x0003003eu,0x000000ccu,0x0000010eu,0x0004003du,0x00000013u,0x0000010fu,0x000000e6u,0x0004003du,0x0000004cu,0x00000110u,0x0000009au,0x0004003du,0x0000002eu,0x00000111u,0x00000036u,0x0004003du,0x0000002eu,0x00000112u,0x000000e0u,0x0004003du,0x0000002eu,0x00000113u,0x000000f4u,0x00050081u,0x0000002eu,0x00000114u,0x00000112u,0x00000113u,0x0004003du,0x0000002eu,0x00000115u,0x00000030u,0x00050085u,0x0000002eu,0x00000116u,0x00000114u,0x00000115u,0x00050081u,0x0000002eu,0x00000117u,0x00000111u,0x00000116u,0x00070058u,0x00000052u,0x00000118u,0x00000110u,0x00000117u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000119u,0x00000118u,0x00000000u,0x00050083u,0x00000013u,0x0000011au,0x0000010fu,0x00000119u,0x0006000cu,0x00000013u,0x0000011bu,0x00000001u,0x00000004u,0x0000011au,0x0004003du,0x00000013u,0x0000011cu,0x000000cdu,0x00050081u,0x00000013u,0x0000011du,0x0000011cu,0x0000011bu,0x0003003eu,0x000000cdu,0x0000011du,0x0004003du,0x00000013u,0x0000011eu,0x000000e6u,0x0004003du,0x0000004cu,0x0000011fu,0x0000009au,0x0004003du,0x0000002eu,0x00000120u,0x00000036u,0x0004003du,0x0000002eu,0x00000121u,0x000000e0u,0x0004003du,0x0000002eu,0x00000122u,0x000000f8u,0x00050081u,0x0000002eu,0x00000123u,0x00000121u,0x00000122u,0x0004003du,0x0000002eu,0x00000124u,0x00000030u,0x00050085u,0x0000002eu,0x00000125u,0x00000123u,0x00000124u,0x00050081u,0x0000002eu,0x00000126u,0x00000120u,0x00000125u,0x00070058u,0x00000052u,0x00000127u,0x0000011fu,0x00000126u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000128u,0x00000127u,0x00000000u,0x00050083u,0x00000013u,0x00000129u,0x0000011eu,0x00000128u,0x0006000cu,0x00000013u,0x0000012au,0x00000001u,0x00000004u,0x00000129u,0x0004003du,0x00000013u,0x0000012bu,0x000000ceu,0x00050081u,0x00000013u,0x0000012cu,0x0000012bu,0x0000012au,0x0003003eu,0x000000ceu,0x0000012cu,0x0004003du,0x00000013u,0x0000012du,0x000000e6u,0x0004003du,0x0000004cu,0x0000012eu,0x0000009au,0x0004003du,0x0000002eu,0x0000012fu,0x00000036u,0x0004003du,0x0000002eu,0x00000130u,0x000000e0u,0x0004003du,0x0000002eu,0x00000131u,0x000000fcu,0x00050081u,0x0000002eu,0x00000132u,0x00000130u,0x00000131u,0x0004003du,0x0000002eu,0x00000133u,0x00000030u,0x00050085u,0x0000002eu,0x00000134u,0x00000132u,0x00000133u,0x00050081u,0x0000002eu,0x00000135u,0x0000012fu,0x00000134u,0x00070058u,0x00000052u,0x00000136u,0x0000012eu,0x00000135u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000137u,0x00000136u,0x00000000u,0x00050083u,0x00000013u,0x00000138u,0x0000012du,0x00000137u,0x0006000cu,0x00000013u,0x00000139u,0x00000001u,0x00000004u,0x00000138u,0x0004003du,0x00000013u,0x0000013au,0x000000cfu,0x00050081u,0x00000013u,0x0000013bu,0x0000013au,0x00000139u,0x0003003eu,0x000000cfu,0x0000013bu,0x000200f9u,0x000000dcu,0x000200f8u,0x000000dcu,0x0004003du,0x00000006u,0x0000013cu,0x000000d8u,0x00050080u,0x00000006u,0x0000013du,0x0000013cu,0x00000043u,0x0003003eu,0x000000d8u,0x0000013du,0x000200f9u,0x000000d9u,0x000200f8u,0x000000dbu,0x000200f9u,0x000000d4u,0x000200f8u,0x000000d4u,0x0004003du,0x00000006u,0x0000013eu,0x000000d0u,0x00050080u,0x00000006u,0x0000013fu,0x0000013eu,0x00000043u,0x0003003eu,0x000000d0u,0x0000013fu,0x000200f9u,0x000000d1u,0x000200f8u,0x000000d3u,0x0004003du,0x00000013u,0x00000140u,0x000000ccu,0x00050081u,0x00000013u,0x00000141u,0x00000140u,0x000000afu,0x0003003eu,0x000000ccu,0x00000141u,0x0004003du,0x00000013u,0x00000142u,0x000000cdu,0x00050081u,0x00000013u,0x00000143u,0x00000142u,0x000000afu,0x0003003eu,0x000000cdu,0x00000143u,0x0004003du,0x00000013u,0x00000144u,0x000000ceu,0x00050081u,0x00000013u,0x00000145u,0x00000144u,0x000000afu,0x0003003eu,0x000000ceu,0x00000145u,0x0004003du,0x00000013u,0x00000146u,0x000000cfu,0x00050081u,0x00000013u,0x00000147u,0x00000146u,0x000000afu,0x0003003eu,0x000000cfu,0x00000147u,0x0003003eu,0x00000148u,0x00000051u,0x0003003eu,0x00000149u,0x00000051u,0x0004003du,0x00000013u,0x0000014bu,0x000000ccu,0x0004003du,0x00000013u,0x0000014du,0x000000cau,0x00050085u,0x00000013u,0x0000014eu,0x0000014cu,0x0000014du,0x00050083u,0x00000013u,0x0000014fu,0x0000014bu,0x0000014eu,0x0004003du,0x00000013u,0x00000150u,0x000000cdu,0x00050081u,0x00000013u,0x00000151u,0x0000014fu,0x00000150u,0x0003003eu,0x0000014au,0x00000151u,0x0004003du,0x00000013u,0x00000153u,0x000000ceu,0x0004003du,0x00000013u,0x00000154u,0x000000cau,0x00050085u,0x00000013u,0x00000155u,0x0000014cu,0x00000154u,0x00050083u,0x00000013u,0x00000156u,0x00000153u,0x00000155u,0x0004003du,0x00000013u,0x00000157u,0x000000cfu,0x00050081u,0x00000013u,0x00000158u,0x00000156u,0x00000157u,0x0003003eu,0x00000152u,0x00000158u,0x0004003du,0x00000013u,0x00000159u,0x0000014au,0x000500bau,0x00000019u,0x0000015bu,0x00000159u,0x0000015au,0x000300f7u,0x0000015du,0x00000000u,0x000400fau,0x0000015bu,0x0000015cu,0x0000015du,0x000200f8u,0x0000015cu,0x0004003du,0x00000013u,0x0000015eu,0x000000ccu,0x0004003du,0x00000013u,0x0000015fu,0x000000cdu,0x00050083u,0x00000013u,0x00000160u,0x0000015eu,0x0000015fu,0x00050085u,0x00000013u,0x00000161u,0x00000039u,0x00000160u,0x0004003du,0x00000013u,0x00000162u,0x0000014au,0x00050088u,0x00000013u,0x00000163u,0x00000161u,0x00000162u,0x0008000cu,0x00000013u,0x00000165u,0x00000001u,0x0000002bu,0x00000163u,0x00000164u,0x00000039u,0x0003003eu,0x00000148u,0x00000165u,0x000200f9u,0x0000015du,0x000200f8u,0x0000015du,0x0004003du,0x00000013u,0x00000166u,0x00000152u,0x000500bau,0x00000019u,0x00000167u,0x00000166u,0x0000015au,0x000300f7u,0x00000169u,0x00000000u,0x000400fau,0x00000167u,0x00000168u,0x00000169u,0x000200f8u,0x00000168u,0x0004003du,0x00000013u,0x0000016au,0x000000ceu,0x0004003du,0x00000013u,0x0000016bu,0x000000cfu,0x00050083u,0x00000013u,0x0000016cu,0x0000016au,0x0000016bu,0x00050085u,0x00000013u,0x0000016du,0x00000039u,0x0000016cu,0x0004003du,0x00000013u,0x0000016eu,0x00000152u,0x00050088u,0x00000013u,0x0000016fu,0x0000016du,0x0000016eu,0x0008000cu,0x00000013u,0x00000170u,0x00000001u,0x0000002bu,0x0000016fu,0x00000164u,0x00000039u,0x0003003eu,0x00000149u,0x00000170u,0x000200f9u,0x00000169u,0x000200f8u,0x00000169u,0x0004003du,0x00000013u,0x00000171u,0x00000148u,0x0004003du,0x00000013u,0x00000172u,0x00000149u,0x00050050u,0x0000002eu,0x00000173u,0x00000171u,0x00000172u,0x0004003du,0x0000002eu,0x00000174u,0x0000005bu,0x00050081u,0x0000002eu,0x00000175u,0x00000174u,0x00000173u,0x0003003eu,0x0000005bu,0x00000175u,0x000200f9u,0x000000c9u,0x000200f8u,0x000000c9u,0x0004003du,0x0000002eu,0x00000177u,0x0000005bu,0x00050041u,0x00000044u,0x00000178u,0x00000042u,0x00000043u,0x0004003du,0x0000000au,0x00000179u,0x00000178u,0x00040070u,0x00000013u,0x0000017au,0x00000179u,0x0006000cu,0x00000013u,0x0000017bu,0x00000001u,0x0000001du,0x0000017au,0x0005008eu,0x0000002eu,0x0000017cu,0x00000177u,0x0000017bu,0x0003003eu,0x00000176u,0x0000017cu,0x0004003du,0x00000014u,0x0000017du,0x00000016u,0x0004003du,0x00000007u,0x0000017eu,0x00000009u,0x0004003du,0x0000002eu,0x0000017fu,0x00000176u,0x00050051u,0x00000013u,0x00000180u,0x0000017fu,0x00000000u,0x00050051u,0x00000013u,0x00000181u,0x0000017fu,0x00000001u,0x00070050u,0x00000052u,0x00000182u,0x00000180u,0x00000181u,0x00000051u,0x00000051u,0x00040063u,0x0000017du,0x0000017eu,0x00000182u,0x000100fdu,0x00010038u}; -static const size_t OF3_FLOW_LEN = 2253; +static const uint32_t OF3_FLOW_SPV[] = { + 0x07230203u,0x00010300u,0x0008000bu,0x000001feu,0x00000000u,0x00020011u,0x00000001u,0x00020011u, + 0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu, + 0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du, + 0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u, + 0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00080005u,0x0000000du,0x475f6c67u, + 0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00040005u,0x00000016u,0x6f6c4675u, + 0x00000077u,0x00030005u,0x00000040u,0x00000055u,0x00060006u,0x00000040u,0x00000000u,0x776f6c66u, + 0x6c616353u,0x00000065u,0x00050006u,0x00000040u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u, + 0x00000040u,0x00000002u,0x30646170u,0x00000000u,0x00050006u,0x00000040u,0x00000003u,0x31646170u, + 0x00000000u,0x00030005u,0x00000042u,0x00000000u,0x00050005u,0x0000004eu,0x65725075u,0x74636964u, + 0x0000726fu,0x00050005u,0x0000007bu,0x76657270u,0x63746150u,0x00000068u,0x00050005u,0x0000007du, + 0x6d754c75u,0x65725061u,0x00000076u,0x00050005u,0x000000c9u,0x6d754c75u,0x72754361u,0x00000072u, + 0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u, + 0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00030047u, + 0x00000040u,0x00000002u,0x00050048u,0x00000040u,0x00000000u,0x00000023u,0x00000000u,0x00050048u, + 0x00000040u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000040u,0x00000002u,0x00000023u, + 0x00000008u,0x00050048u,0x00000040u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000042u, + 0x00000021u,0x00000000u,0x00040047u,0x00000042u,0x00000022u,0x00000000u,0x00040047u,0x0000004eu, + 0x00000021u,0x00000022u,0x00040047u,0x0000004eu,0x00000022u,0x00000000u,0x00040047u,0x0000007du, + 0x00000021u,0x00000020u,0x00040047u,0x0000007du,0x00000022u,0x00000000u,0x00040047u,0x000000c9u, + 0x00000021u,0x00000021u,0x00040047u,0x000000c9u,0x00000022u,0x00000000u,0x00040047u,0x000001b3u, + 0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u, + 0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040015u, + 0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u, + 0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u, + 0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u, + 0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u, + 0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u, + 0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x0004002bu,0x0000000au,0x00000024u, + 0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x0004002bu,0x00000013u,0x00000031u, + 0x3f800000u,0x0004002bu,0x00000013u,0x00000039u,0x3f000000u,0x00040020u,0x0000003eu,0x00000007u, + 0x00000013u,0x0006001eu,0x00000040u,0x00000013u,0x0000000au,0x0000000au,0x0000000au,0x00040020u, + 0x00000041u,0x00000002u,0x00000040u,0x0004003bu,0x00000041u,0x00000042u,0x00000002u,0x0004002bu, + 0x00000006u,0x00000043u,0x00000001u,0x00040020u,0x00000044u,0x00000002u,0x0000000au,0x00090019u, + 0x0000004bu,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u, + 0x0003001bu,0x0000004cu,0x0000004bu,0x00040020u,0x0000004du,0x00000000u,0x0000004cu,0x0004003bu, + 0x0000004du,0x0000004eu,0x00000000u,0x0004002bu,0x00000013u,0x00000051u,0x00000000u,0x00040017u, + 0x00000052u,0x00000013u,0x00000004u,0x0004002bu,0x00000006u,0x0000005au,0xffffffffu,0x0004002bu, + 0x00000006u,0x0000006du,0x00000003u,0x0004002bu,0x0000000au,0x00000078u,0x00000009u,0x0004001cu, + 0x00000079u,0x00000013u,0x00000078u,0x00040020u,0x0000007au,0x00000007u,0x00000079u,0x0004003bu, + 0x0000004du,0x0000007du,0x00000000u,0x0004002bu,0x00000013u,0x0000008cu,0x7f7fffffu,0x0004002bu, + 0x00000006u,0x00000090u,0xfffffffdu,0x0004003bu,0x0000004du,0x000000c9u,0x00000000u,0x0004002bu, + 0x00000013u,0x000000deu,0x3bc49ba6u,0x0004002bu,0x00000013u,0x00000120u,0xbf800000u,0x0005002cu, + 0x0000002eu,0x00000121u,0x00000120u,0x00000051u,0x0005002cu,0x0000002eu,0x00000125u,0x00000031u, + 0x00000051u,0x0005002cu,0x0000002eu,0x00000129u,0x00000051u,0x00000120u,0x0005002cu,0x0000002eu, + 0x0000012du,0x00000051u,0x00000031u,0x0004002bu,0x00000013u,0x0000017bu,0x40000000u,0x0004002bu, + 0x00000013u,0x00000189u,0x358637bdu,0x0004002bu,0x00000013u,0x00000193u,0xbf000000u,0x0004002bu, + 0x0000000au,0x000001b2u,0x00000010u,0x0006002cu,0x0000000bu,0x000001b3u,0x000001b2u,0x000001b2u, + 0x00000024u,0x0005002cu,0x0000002eu,0x000001efu,0x00000031u,0x00000031u,0x0005002cu,0x0000002eu, + 0x000001f0u,0x00000039u,0x00000039u,0x00040017u,0x000001fbu,0x00000019u,0x00000002u,0x00050036u, + 0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x0000007au, + 0x0000007bu,0x00000007u,0x000300f7u,0x000001b4u,0x00000000u,0x000300fbu,0x0000001au,0x000001b5u, + 0x000200f8u,0x000001b5u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu, + 0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u, + 0x00000010u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u, + 0x00000017u,0x00050051u,0x00000006u,0x0000001du,0x00000011u,0x00000000u,0x00050051u,0x00000006u, + 0x0000001fu,0x00000018u,0x00000000u,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu, + 0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau, + 0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050051u,0x00000006u,0x00000026u, + 0x00000011u,0x00000001u,0x00050051u,0x00000006u,0x00000028u,0x00000018u,0x00000001u,0x000500afu, + 0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u, + 0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x000001b5u,0x00000029u,0x00000022u,0x000300f7u, + 0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu, + 0x000200f9u,0x000001b4u,0x000200f8u,0x0000002cu,0x0004006fu,0x0000002eu,0x00000033u,0x00000018u, + 0x00050088u,0x0000002eu,0x00000035u,0x000001efu,0x00000033u,0x0004006fu,0x0000002eu,0x00000038u, + 0x00000011u,0x00050081u,0x0000002eu,0x0000003bu,0x00000038u,0x000001f0u,0x00050085u,0x0000002eu, + 0x0000003du,0x0000003bu,0x00000035u,0x00050041u,0x00000044u,0x00000045u,0x00000042u,0x00000043u, + 0x0004003du,0x0000000au,0x00000046u,0x00000045u,0x00040070u,0x00000013u,0x00000047u,0x00000046u, + 0x0004007fu,0x00000013u,0x00000048u,0x00000047u,0x0006000cu,0x00000013u,0x00000049u,0x00000001u, + 0x0000001du,0x00000048u,0x0004003du,0x0000004cu,0x0000004fu,0x0000004eu,0x00070058u,0x00000052u, + 0x00000053u,0x0000004fu,0x0000003du,0x00000002u,0x00000051u,0x0007004fu,0x0000002eu,0x00000054u, + 0x00000053u,0x00000053u,0x00000000u,0x00000001u,0x0005008eu,0x0000002eu,0x00000058u,0x00000054u, + 0x00000049u,0x000200f9u,0x0000005bu,0x000200f8u,0x0000005bu,0x000700f5u,0x00000006u,0x000001beu, + 0x0000005au,0x0000002cu,0x0000008au,0x0000005eu,0x000500b3u,0x00000019u,0x00000061u,0x000001beu, + 0x00000043u,0x000400f6u,0x0000005du,0x0000005eu,0x00000000u,0x000400fau,0x00000061u,0x0000005cu, + 0x0000005du,0x000200f8u,0x0000005cu,0x000200f9u,0x00000063u,0x000200f8u,0x00000063u,0x000700f5u, + 0x00000006u,0x000001e4u,0x0000005au,0x0000005cu,0x00000070u,0x00000064u,0x000500b3u,0x00000019u, + 0x00000069u,0x000001e4u,0x00000043u,0x000400f6u,0x00000065u,0x00000064u,0x00000000u,0x000400fau, + 0x00000069u,0x00000064u,0x00000065u,0x000200f8u,0x00000064u,0x00050080u,0x00000006u,0x0000006cu, + 0x000001beu,0x00000043u,0x00050084u,0x00000006u,0x0000006eu,0x0000006cu,0x0000006du,0x00050080u, + 0x00000006u,0x00000070u,0x000001e4u,0x00000043u,0x00050080u,0x00000006u,0x00000071u,0x0000006eu, + 0x00000070u,0x0004006fu,0x00000013u,0x00000074u,0x000001e4u,0x0004006fu,0x00000013u,0x00000076u, + 0x000001beu,0x00050050u,0x0000002eu,0x00000077u,0x00000074u,0x00000076u,0x0004003du,0x0000004cu, + 0x0000007eu,0x0000007du,0x00050085u,0x0000002eu,0x00000082u,0x00000077u,0x00000035u,0x00050081u, + 0x0000002eu,0x00000083u,0x0000003du,0x00000082u,0x00070058u,0x00000052u,0x00000084u,0x0000007eu, + 0x00000083u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000085u,0x00000084u,0x00000000u, + 0x00050041u,0x0000003eu,0x00000086u,0x0000007bu,0x00000071u,0x0003003eu,0x00000086u,0x00000085u, + 0x000200f9u,0x00000063u,0x000200f8u,0x00000065u,0x000200f9u,0x0000005eu,0x000200f8u,0x0000005eu, + 0x00050080u,0x00000006u,0x0000008au,0x000001beu,0x00000043u,0x000200f9u,0x0000005bu,0x000200f8u, + 0x0000005du,0x000200f9u,0x00000091u,0x000200f8u,0x00000091u,0x000700f5u,0x0000002eu,0x000001cfu, + 0x00000058u,0x0000005du,0x000001e6u,0x00000094u,0x000700f5u,0x00000013u,0x000001c0u,0x0000008cu, + 0x0000005du,0x000001dfu,0x00000094u,0x000700f5u,0x00000006u,0x000001bfu,0x00000090u,0x0000005du, + 0x000000f3u,0x00000094u,0x000500b3u,0x00000019u,0x00000097u,0x000001bfu,0x0000006du,0x000400f6u, + 0x00000093u,0x00000094u,0x00000000u,0x000400fau,0x00000097u,0x00000092u,0x00000093u,0x000200f8u, + 0x00000092u,0x000200f9u,0x00000099u,0x000200f8u,0x00000099u,0x000700f5u,0x00000013u,0x000001dfu, + 0x000001c0u,0x00000092u,0x000001fau,0x0000009cu,0x000700f5u,0x00000006u,0x000001d8u,0x00000090u, + 0x00000092u,0x000000f1u,0x0000009cu,0x000700f5u,0x0000002eu,0x000001e6u,0x000001cfu,0x00000092u, + 0x000001fdu,0x0000009cu,0x000500b3u,0x00000019u,0x0000009fu,0x000001d8u,0x0000006du,0x000400f6u, + 0x0000009bu,0x0000009cu,0x00000000u,0x000400fau,0x0000009fu,0x0000009au,0x0000009bu,0x000200f8u, + 0x0000009au,0x0004006fu,0x00000013u,0x000000a3u,0x000001d8u,0x0004006fu,0x00000013u,0x000000a5u, + 0x000001bfu,0x00050050u,0x0000002eu,0x000000a6u,0x000000a3u,0x000000a5u,0x00050081u,0x0000002eu, + 0x000000a7u,0x00000058u,0x000000a6u,0x000200f9u,0x000000aau,0x000200f8u,0x000000aau,0x000700f5u, + 0x00000013u,0x000001ddu,0x00000051u,0x0000009au,0x000001e3u,0x000000adu,0x000700f5u,0x00000006u, + 0x000001dau,0x0000005au,0x0000009au,0x000000ddu,0x000000adu,0x000500b3u,0x00000019u,0x000000b0u, + 0x000001dau,0x00000043u,0x000400f6u,0x000000acu,0x000000adu,0x00000000u,0x000400fau,0x000000b0u, + 0x000000abu,0x000000acu,0x000200f8u,0x000000abu,0x000200f9u,0x000000b2u,0x000200f8u,0x000000b2u, + 0x000700f5u,0x00000013u,0x000001e3u,0x000001ddu,0x000000abu,0x000000d9u,0x000000b3u,0x000700f5u, + 0x00000006u,0x000001e1u,0x0000005au,0x000000abu,0x000000c4u,0x000000b3u,0x000500b3u,0x00000019u, + 0x000000b8u,0x000001e1u,0x00000043u,0x000400f6u,0x000000b4u,0x000000b3u,0x00000000u,0x000400fau, + 0x000000b8u,0x000000b3u,0x000000b4u,0x000200f8u,0x000000b3u,0x0004006fu,0x00000013u,0x000000bbu, + 0x000001e1u,0x0004006fu,0x00000013u,0x000000bdu,0x000001dau,0x00050050u,0x0000002eu,0x000000beu, + 0x000000bbu,0x000000bdu,0x00050080u,0x00000006u,0x000000c1u,0x000001dau,0x00000043u,0x00050084u, + 0x00000006u,0x000000c2u,0x000000c1u,0x0000006du,0x00050080u,0x00000006u,0x000000c4u,0x000001e1u, + 0x00000043u,0x00050080u,0x00000006u,0x000000c5u,0x000000c2u,0x000000c4u,0x00050041u,0x0000003eu, + 0x000000c6u,0x0000007bu,0x000000c5u,0x0004003du,0x00000013u,0x000000c7u,0x000000c6u,0x0004003du, + 0x0000004cu,0x000000cau,0x000000c9u,0x00050081u,0x0000002eu,0x000000ceu,0x000000beu,0x000000a7u, + 0x00050085u,0x0000002eu,0x000000d0u,0x000000ceu,0x00000035u,0x00050081u,0x0000002eu,0x000000d1u, + 0x0000003du,0x000000d0u,0x00070058u,0x00000052u,0x000000d2u,0x000000cau,0x000000d1u,0x00000002u, + 0x00000051u,0x00050051u,0x00000013u,0x000000d3u,0x000000d2u,0x00000000u,0x00050083u,0x00000013u, + 0x000000d6u,0x000000c7u,0x000000d3u,0x0006000cu,0x00000013u,0x000000d7u,0x00000001u,0x00000004u, + 0x000000d6u,0x00050081u,0x00000013u,0x000000d9u,0x000001e3u,0x000000d7u,0x000200f9u,0x000000b2u, + 0x000200f8u,0x000000b4u,0x000200f9u,0x000000adu,0x000200f8u,0x000000adu,0x00050080u,0x00000006u, + 0x000000ddu,0x000001dau,0x00000043u,0x000200f9u,0x000000aau,0x000200f8u,0x000000acu,0x0006000cu, + 0x00000013u,0x000000e1u,0x00000001u,0x00000004u,0x000000a3u,0x0006000cu,0x00000013u,0x000000e4u, + 0x00000001u,0x00000004u,0x000000a5u,0x00050081u,0x00000013u,0x000000e5u,0x000000e1u,0x000000e4u, + 0x00050085u,0x00000013u,0x000000e6u,0x000000deu,0x000000e5u,0x00050081u,0x00000013u,0x000000e8u, + 0x000001ddu,0x000000e6u,0x000500b8u,0x00000019u,0x000000ebu,0x000000e8u,0x000001dfu,0x000600a9u, + 0x00000013u,0x000001fau,0x000000ebu,0x000000e8u,0x000001dfu,0x00050050u,0x000001fbu,0x000001fcu, + 0x000000ebu,0x000000ebu,0x000600a9u,0x0000002eu,0x000001fdu,0x000001fcu,0x000000a7u,0x000001e6u, + 0x000200f9u,0x0000009cu,0x000200f8u,0x0000009cu,0x00050080u,0x00000006u,0x000000f1u,0x000001d8u, + 0x00000043u,0x000200f9u,0x00000099u,0x000200f8u,0x0000009bu,0x000200f9u,0x00000094u,0x000200f8u, + 0x00000094u,0x00050080u,0x00000006u,0x000000f3u,0x000001bfu,0x00000043u,0x000200f9u,0x00000091u, + 0x000200f8u,0x00000093u,0x000500aau,0x00000019u,0x000000f6u,0x00000046u,0x0000001au,0x000300f7u, + 0x000000f8u,0x00000000u,0x000400fau,0x000000f6u,0x000000f7u,0x000000f8u,0x000200f8u,0x000000f7u, + 0x000200f9u,0x00000100u,0x000200f8u,0x00000100u,0x000700f5u,0x00000013u,0x000001c5u,0x00000051u, + 0x000000f7u,0x000001d7u,0x00000103u,0x000700f5u,0x00000013u,0x000001c4u,0x00000051u,0x000000f7u, + 0x000001d6u,0x00000103u,0x000700f5u,0x00000013u,0x000001c3u,0x00000051u,0x000000f7u,0x000001d5u, + 0x00000103u,0x000700f5u,0x00000013u,0x000001c2u,0x00000051u,0x000000f7u,0x000001d4u,0x00000103u, + 0x000700f5u,0x00000006u,0x000001c1u,0x0000005au,0x000000f7u,0x0000016eu,0x00000103u,0x000500b3u, + 0x00000019u,0x00000106u,0x000001c1u,0x00000043u,0x000400f6u,0x00000102u,0x00000103u,0x00000000u, + 0x000400fau,0x00000106u,0x00000101u,0x00000102u,0x000200f8u,0x00000101u,0x000200f9u,0x00000108u, + 0x000200f8u,0x00000108u,0x000700f5u,0x00000013u,0x000001d7u,0x000001c5u,0x00000101u,0x0000016au, + 0x00000109u,0x000700f5u,0x00000013u,0x000001d6u,0x000001c4u,0x00000101u,0x0000015bu,0x00000109u, + 0x000700f5u,0x00000013u,0x000001d5u,0x000001c3u,0x00000101u,0x0000014cu,0x00000109u,0x000700f5u, + 0x00000013u,0x000001d4u,0x000001c2u,0x00000101u,0x0000013du,0x00000109u,0x000700f5u,0x00000006u, + 0x000001d1u,0x0000005au,0x00000101u,0x0000011au,0x00000109u,0x000500b3u,0x00000019u,0x0000010eu, + 0x000001d1u,0x00000043u,0x000400f6u,0x0000010au,0x00000109u,0x00000000u,0x000400fau,0x0000010eu, + 0x00000109u,0x0000010au,0x000200f8u,0x00000109u,0x0004006fu,0x00000013u,0x00000111u,0x000001d1u, + 0x0004006fu,0x00000013u,0x00000113u,0x000001c1u,0x00050050u,0x0000002eu,0x00000114u,0x00000111u, + 0x00000113u,0x00050080u,0x00000006u,0x00000117u,0x000001c1u,0x00000043u,0x00050084u,0x00000006u, + 0x00000118u,0x00000117u,0x0000006du,0x00050080u,0x00000006u,0x0000011au,0x000001d1u,0x00000043u, + 0x00050080u,0x00000006u,0x0000011bu,0x00000118u,0x0000011au,0x00050041u,0x0000003eu,0x0000011cu, + 0x0000007bu,0x0000011bu,0x0004003du,0x00000013u,0x0000011du,0x0000011cu,0x00050081u,0x0000002eu, + 0x00000122u,0x000001cfu,0x00000121u,0x00050081u,0x0000002eu,0x00000126u,0x000001cfu,0x00000125u, + 0x00050081u,0x0000002eu,0x0000012au,0x000001cfu,0x00000129u,0x00050081u,0x0000002eu,0x0000012eu, + 0x000001cfu,0x0000012du,0x0004003du,0x0000004cu,0x00000130u,0x000000c9u,0x00050081u,0x0000002eu, + 0x00000134u,0x00000114u,0x00000122u,0x00050085u,0x0000002eu,0x00000136u,0x00000134u,0x00000035u, + 0x00050081u,0x0000002eu,0x00000137u,0x0000003du,0x00000136u,0x00070058u,0x00000052u,0x00000138u, + 0x00000130u,0x00000137u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000139u,0x00000138u, + 0x00000000u,0x00050083u,0x00000013u,0x0000013au,0x0000011du,0x00000139u,0x0006000cu,0x00000013u, + 0x0000013bu,0x00000001u,0x00000004u,0x0000013au,0x00050081u,0x00000013u,0x0000013du,0x000001d4u, + 0x0000013bu,0x0004003du,0x0000004cu,0x0000013fu,0x000000c9u,0x00050081u,0x0000002eu,0x00000143u, + 0x00000114u,0x00000126u,0x00050085u,0x0000002eu,0x00000145u,0x00000143u,0x00000035u,0x00050081u, + 0x0000002eu,0x00000146u,0x0000003du,0x00000145u,0x00070058u,0x00000052u,0x00000147u,0x0000013fu, + 0x00000146u,0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000148u,0x00000147u,0x00000000u, + 0x00050083u,0x00000013u,0x00000149u,0x0000011du,0x00000148u,0x0006000cu,0x00000013u,0x0000014au, + 0x00000001u,0x00000004u,0x00000149u,0x00050081u,0x00000013u,0x0000014cu,0x000001d5u,0x0000014au, + 0x0004003du,0x0000004cu,0x0000014eu,0x000000c9u,0x00050081u,0x0000002eu,0x00000152u,0x00000114u, + 0x0000012au,0x00050085u,0x0000002eu,0x00000154u,0x00000152u,0x00000035u,0x00050081u,0x0000002eu, + 0x00000155u,0x0000003du,0x00000154u,0x00070058u,0x00000052u,0x00000156u,0x0000014eu,0x00000155u, + 0x00000002u,0x00000051u,0x00050051u,0x00000013u,0x00000157u,0x00000156u,0x00000000u,0x00050083u, + 0x00000013u,0x00000158u,0x0000011du,0x00000157u,0x0006000cu,0x00000013u,0x00000159u,0x00000001u, + 0x00000004u,0x00000158u,0x00050081u,0x00000013u,0x0000015bu,0x000001d6u,0x00000159u,0x0004003du, + 0x0000004cu,0x0000015du,0x000000c9u,0x00050081u,0x0000002eu,0x00000161u,0x00000114u,0x0000012eu, + 0x00050085u,0x0000002eu,0x00000163u,0x00000161u,0x00000035u,0x00050081u,0x0000002eu,0x00000164u, + 0x0000003du,0x00000163u,0x00070058u,0x00000052u,0x00000165u,0x0000015du,0x00000164u,0x00000002u, + 0x00000051u,0x00050051u,0x00000013u,0x00000166u,0x00000165u,0x00000000u,0x00050083u,0x00000013u, + 0x00000167u,0x0000011du,0x00000166u,0x0006000cu,0x00000013u,0x00000168u,0x00000001u,0x00000004u, + 0x00000167u,0x00050081u,0x00000013u,0x0000016au,0x000001d7u,0x00000168u,0x000200f9u,0x00000108u, + 0x000200f8u,0x0000010au,0x000200f9u,0x00000103u,0x000200f8u,0x00000103u,0x00050080u,0x00000006u, + 0x0000016eu,0x000001c1u,0x00000043u,0x000200f9u,0x00000100u,0x000200f8u,0x00000102u,0x00050081u, + 0x00000013u,0x00000170u,0x000001c2u,0x000000deu,0x00050081u,0x00000013u,0x00000172u,0x000001c3u, + 0x000000deu,0x00050081u,0x00000013u,0x00000174u,0x000001c4u,0x000000deu,0x00050081u,0x00000013u, + 0x00000176u,0x000001c5u,0x000000deu,0x00050085u,0x00000013u,0x0000017du,0x0000017bu,0x000001c0u, + 0x00050083u,0x00000013u,0x0000017eu,0x00000170u,0x0000017du,0x00050081u,0x00000013u,0x00000180u, + 0x0000017eu,0x00000172u,0x00050083u,0x00000013u,0x00000185u,0x00000174u,0x0000017du,0x00050081u, + 0x00000013u,0x00000187u,0x00000185u,0x00000176u,0x000500bau,0x00000019u,0x0000018au,0x00000180u, + 0x00000189u,0x000300f7u,0x0000018cu,0x00000000u,0x000400fau,0x0000018au,0x0000018bu,0x0000018cu, + 0x000200f8u,0x0000018bu,0x00050083u,0x00000013u,0x000001f8u,0x000001c2u,0x000001c3u,0x00050085u, + 0x00000013u,0x00000190u,0x00000039u,0x000001f8u,0x00050088u,0x00000013u,0x00000192u,0x00000190u, + 0x00000180u,0x0008000cu,0x00000013u,0x00000194u,0x00000001u,0x0000002bu,0x00000192u,0x00000193u, + 0x00000039u,0x000200f9u,0x0000018cu,0x000200f8u,0x0000018cu,0x000700f5u,0x00000013u,0x000001c9u, + 0x00000051u,0x00000102u,0x00000194u,0x0000018bu,0x000500bau,0x00000019u,0x00000196u,0x00000187u, + 0x00000189u,0x000300f7u,0x00000198u,0x00000000u,0x000400fau,0x00000196u,0x00000197u,0x00000198u, + 0x000200f8u,0x00000197u,0x00050083u,0x00000013u,0x000001f9u,0x000001c4u,0x000001c5u,0x00050085u, + 0x00000013u,0x0000019cu,0x00000039u,0x000001f9u,0x00050088u,0x00000013u,0x0000019eu,0x0000019cu, + 0x00000187u,0x0008000cu,0x00000013u,0x0000019fu,0x00000001u,0x0000002bu,0x0000019eu,0x00000193u, + 0x00000039u,0x000200f9u,0x00000198u,0x000200f8u,0x00000198u,0x000700f5u,0x00000013u,0x000001cau, + 0x00000051u,0x0000018cu,0x0000019fu,0x00000197u,0x00050050u,0x0000002eu,0x000001a2u,0x000001c9u, + 0x000001cau,0x00050081u,0x0000002eu,0x000001a4u,0x000001cfu,0x000001a2u,0x000200f9u,0x000000f8u, + 0x000200f8u,0x000000f8u,0x000700f5u,0x0000002eu,0x000001d0u,0x000001cfu,0x00000093u,0x000001a4u, + 0x00000198u,0x0006000cu,0x00000013u,0x000001aau,0x00000001u,0x0000001du,0x00000047u,0x0005008eu, + 0x0000002eu,0x000001abu,0x000001d0u,0x000001aau,0x0004003du,0x00000014u,0x000001acu,0x00000016u, + 0x00050051u,0x00000013u,0x000001afu,0x000001abu,0x00000000u,0x00050051u,0x00000013u,0x000001b0u, + 0x000001abu,0x00000001u,0x00070050u,0x00000052u,0x000001b1u,0x000001afu,0x000001b0u,0x00000051u, + 0x00000051u,0x00040063u,0x000001acu,0x00000011u,0x000001b1u,0x000200f9u,0x000001b4u,0x000200f8u, + 0x000001b4u,0x000100fdu,0x00010038u +}; +static const size_t OF3_FLOW_LEN = sizeof(OF3_FLOW_SPV) / sizeof(OF3_FLOW_SPV[0]); static const uint32_t OF3_EXPAND_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000124u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x00000049u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00080005u,0x0000000eu,0x3564656du,0x3b316628u,0x663b3166u,0x31663b31u,0x3b31663bu,0x00000000u,0x00030005u,0x00000009u,0x00000061u,0x00030005u,0x0000000au,0x00000062u,0x00030005u,0x0000000bu,0x00000063u,0x00030005u,0x0000000cu,0x00000064u,0x00030005u,0x0000000du,0x00000065u,0x00030005u,0x00000010u,0x00000078u,0x00030005u,0x00000034u,0x00000079u,0x00030005u,0x00000045u,0x00646967u,0x00080005u,0x00000049u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x0000004eu,0x006d6964u,0x00040005u,0x00000051u,0x64774675u,0x00000000u,0x00030005u,0x0000006bu,0x00007675u,0x00030005u,0x00000074u,0x00007366u,0x00050005u,0x00000079u,0x6f6c4675u,0x6e694677u,0x00000065u,0x00030005u,0x00000081u,0x00000063u,0x00030005u,0x00000088u,0x00006d78u,0x00030005u,0x00000091u,0x00007078u,0x00030005u,0x0000009au,0x00006d79u,0x00030005u,0x000000a3u,0x00007079u,0x00030005u,0x000000acu,0x00000064u,0x00040005u,0x000000adu,0x61726170u,0x0000006du,0x00040005u,0x000000b0u,0x61726170u,0x0000006du,0x00040005u,0x000000b3u,0x61726170u,0x0000006du,0x00040005u,0x000000b6u,0x61726170u,0x0000006du,0x00040005u,0x000000b9u,0x61726170u,0x0000006du,0x00040005u,0x000000bdu,0x61726170u,0x0000006du,0x00040005u,0x000000c0u,0x61726170u,0x0000006du,0x00040005u,0x000000c3u,0x61726170u,0x0000006du,0x00040005u,0x000000c6u,0x61726170u,0x0000006du,0x00040005u,0x000000c9u,0x61726170u,0x0000006du,0x00030005u,0x000000ceu,0x00000071u,0x00030005u,0x000000d2u,0x00787067u,0x00030005u,0x000000d3u,0x00004d47u,0x00050006u,0x000000d3u,0x00000000u,0x694c6d67u,0x0000006eu,0x00050006u,0x000000d3u,0x00000001u,0x694c6d67u,0x0000546eu,0x00050006u,0x000000d3u,0x00000002u,0x70416d67u,0x00000070u,0x00050006u,0x000000d3u,0x00000003u,0x70416d67u,0x00005470u,0x00030005u,0x000000d5u,0x00000000u,0x00030005u,0x000000fdu,0x00003241u,0x00040005u,0x0000010bu,0x6c6c7566u,0x00000000u,0x00040005u,0x00000117u,0x64774275u,0x00000000u,0x00030005u,0x00000121u,0x00000055u,0x00060006u,0x00000121u,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x00000121u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u,0x00000121u,0x00000002u,0x30646170u,0x00000000u,0x00050006u,0x00000121u,0x00000003u,0x31646170u,0x00000000u,0x00030005u,0x00000123u,0x00000000u,0x00040047u,0x00000049u,0x0000000bu,0x0000001cu,0x00030047u,0x00000051u,0x00000019u,0x00040047u,0x00000051u,0x00000021u,0x00000030u,0x00040047u,0x00000051u,0x00000022u,0x00000000u,0x00040047u,0x00000079u,0x00000021u,0x00000020u,0x00040047u,0x00000079u,0x00000022u,0x00000000u,0x00030047u,0x000000d3u,0x00000002u,0x00050048u,0x000000d3u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x000000d3u,0x00000001u,0x00000023u,0x00000010u,0x00050048u,0x000000d3u,0x00000002u,0x00000023u,0x00000020u,0x00050048u,0x000000d3u,0x00000003u,0x00000023u,0x00000030u,0x00040047u,0x000000d5u,0x00000021u,0x00000001u,0x00040047u,0x000000d5u,0x00000022u,0x00000000u,0x00030047u,0x00000117u,0x00000019u,0x00040047u,0x00000117u,0x00000021u,0x00000031u,0x00040047u,0x00000117u,0x00000022u,0x00000000u,0x00040047u,0x00000120u,0x0000000bu,0x00000019u,0x00030047u,0x00000121u,0x00000002u,0x00050048u,0x00000121u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x00000121u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000121u,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x00000121u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000123u,0x00000021u,0x00000000u,0x00040047u,0x00000123u,0x00000022u,0x00000000u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00030016u,0x00000006u,0x00000020u,0x00040020u,0x00000007u,0x00000007u,0x00000006u,0x00080021u,0x00000008u,0x00000006u,0x00000007u,0x00000007u,0x00000007u,0x00000007u,0x00000007u,0x00040015u,0x00000042u,0x00000020u,0x00000001u,0x00040017u,0x00000043u,0x00000042u,0x00000002u,0x00040020u,0x00000044u,0x00000007u,0x00000043u,0x00040015u,0x00000046u,0x00000020u,0x00000000u,0x00040017u,0x00000047u,0x00000046u,0x00000003u,0x00040020u,0x00000048u,0x00000001u,0x00000047u,0x0004003bu,0x00000048u,0x00000049u,0x00000001u,0x00040017u,0x0000004au,0x00000046u,0x00000002u,0x00090019u,0x0000004fu,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x00000050u,0x00000000u,0x0000004fu,0x0004003bu,0x00000050u,0x00000051u,0x00000000u,0x00020014u,0x00000054u,0x0004002bu,0x00000046u,0x00000055u,0x00000000u,0x00040020u,0x00000056u,0x00000007u,0x00000042u,0x0004002bu,0x00000046u,0x0000005fu,0x00000001u,0x00040017u,0x00000069u,0x00000006u,0x00000002u,0x00040020u,0x0000006au,0x00000007u,0x00000069u,0x0004002bu,0x00000006u,0x0000006eu,0x3f000000u,0x0004002bu,0x00000006u,0x00000075u,0x3f800000u,0x00090019u,0x00000076u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000077u,0x00000076u,0x00040020u,0x00000078u,0x00000000u,0x00000077u,0x0004003bu,0x00000078u,0x00000079u,0x00000000u,0x0004002bu,0x00000042u,0x0000007bu,0x00000000u,0x0004002bu,0x00000006u,0x00000084u,0x00000000u,0x00040017u,0x00000085u,0x00000006u,0x00000004u,0x0006001eu,0x000000d3u,0x00000085u,0x00000085u,0x00000085u,0x00000085u,0x00040020u,0x000000d4u,0x00000002u,0x000000d3u,0x0004003bu,0x000000d4u,0x000000d5u,0x00000002u,0x0004002bu,0x00000042u,0x000000d6u,0x00000002u,0x00040020u,0x000000d7u,0x00000002u,0x00000006u,0x0004002bu,0x00000046u,0x000000ddu,0x00000002u,0x0004002bu,0x00000042u,0x000000e4u,0x00000003u,0x0004002bu,0x00000046u,0x000000edu,0x00000003u,0x00040018u,0x000000fbu,0x00000069u,0x00000002u,0x00040020u,0x000000fcu,0x00000007u,0x000000fbu,0x0004003bu,0x00000050u,0x00000117u,0x00000000u,0x0004002bu,0x00000046u,0x0000011fu,0x00000010u,0x0006002cu,0x00000047u,0x00000120u,0x0000011fu,0x0000011fu,0x0000005fu,0x0006001eu,0x00000121u,0x00000006u,0x00000046u,0x00000046u,0x00000046u,0x00040020u,0x00000122u,0x00000002u,0x00000121u,0x0004003bu,0x00000122u,0x00000123u,0x00000002u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000044u,0x00000045u,0x00000007u,0x0004003bu,0x00000044u,0x0000004eu,0x00000007u,0x0004003bu,0x0000006au,0x0000006bu,0x00000007u,0x0004003bu,0x0000006au,0x00000074u,0x00000007u,0x0004003bu,0x0000006au,0x00000081u,0x00000007u,0x0004003bu,0x0000006au,0x00000088u,0x00000007u,0x0004003bu,0x0000006au,0x00000091u,0x00000007u,0x0004003bu,0x0000006au,0x0000009au,0x00000007u,0x0004003bu,0x0000006au,0x000000a3u,0x00000007u,0x0004003bu,0x0000006au,0x000000acu,0x00000007u,0x0004003bu,0x00000007u,0x000000adu,0x00000007u,0x0004003bu,0x00000007u,0x000000b0u,0x00000007u,0x0004003bu,0x00000007u,0x000000b3u,0x00000007u,0x0004003bu,0x00000007u,0x000000b6u,0x00000007u,0x0004003bu,0x00000007u,0x000000b9u,0x00000007u,0x0004003bu,0x00000007u,0x000000bdu,0x00000007u,0x0004003bu,0x00000007u,0x000000c0u,0x00000007u,0x0004003bu,0x00000007u,0x000000c3u,0x00000007u,0x0004003bu,0x00000007u,0x000000c6u,0x00000007u,0x0004003bu,0x00000007u,0x000000c9u,0x00000007u,0x0004003bu,0x0000006au,0x000000ceu,0x00000007u,0x0004003bu,0x0000006au,0x000000d2u,0x00000007u,0x0004003bu,0x000000fcu,0x000000fdu,0x00000007u,0x0004003bu,0x0000006au,0x0000010bu,0x00000007u,0x0004003du,0x00000047u,0x0000004bu,0x00000049u,0x0007004fu,0x0000004au,0x0000004cu,0x0000004bu,0x0000004bu,0x00000000u,0x00000001u,0x0004007cu,0x00000043u,0x0000004du,0x0000004cu,0x0003003eu,0x00000045u,0x0000004du,0x0004003du,0x0000004fu,0x00000052u,0x00000051u,0x00040068u,0x00000043u,0x00000053u,0x00000052u,0x0003003eu,0x0000004eu,0x00000053u,0x00050041u,0x00000056u,0x00000057u,0x00000045u,0x00000055u,0x0004003du,0x00000042u,0x00000058u,0x00000057u,0x00050041u,0x00000056u,0x00000059u,0x0000004eu,0x00000055u,0x0004003du,0x00000042u,0x0000005au,0x00000059u,0x000500afu,0x00000054u,0x0000005bu,0x00000058u,0x0000005au,0x000400a8u,0x00000054u,0x0000005cu,0x0000005bu,0x000300f7u,0x0000005eu,0x00000000u,0x000400fau,0x0000005cu,0x0000005du,0x0000005eu,0x000200f8u,0x0000005du,0x00050041u,0x00000056u,0x00000060u,0x00000045u,0x0000005fu,0x0004003du,0x00000042u,0x00000061u,0x00000060u,0x00050041u,0x00000056u,0x00000062u,0x0000004eu,0x0000005fu,0x0004003du,0x00000042u,0x00000063u,0x00000062u,0x000500afu,0x00000054u,0x00000064u,0x00000061u,0x00000063u,0x000200f9u,0x0000005eu,0x000200f8u,0x0000005eu,0x000700f5u,0x00000054u,0x00000065u,0x0000005bu,0x00000005u,0x00000064u,0x0000005du,0x000300f7u,0x00000067u,0x00000000u,0x000400fau,0x00000065u,0x00000066u,0x00000067u,0x000200f8u,0x00000066u,0x000100fdu,0x000200f8u,0x00000067u,0x0004003du,0x00000043u,0x0000006cu,0x00000045u,0x0004006fu,0x00000069u,0x0000006du,0x0000006cu,0x00050050u,0x00000069u,0x0000006fu,0x0000006eu,0x0000006eu,0x00050081u,0x00000069u,0x00000070u,0x0000006du,0x0000006fu,0x0004003du,0x00000043u,0x00000071u,0x0000004eu,0x0004006fu,0x00000069u,0x00000072u,0x00000071u,0x00050088u,0x00000069u,0x00000073u,0x00000070u,0x00000072u,0x0003003eu,0x0000006bu,0x00000073u,0x0004003du,0x00000077u,0x0000007au,0x00000079u,0x00040064u,0x00000076u,0x0000007cu,0x0000007au,0x00050067u,0x00000043u,0x0000007du,0x0000007cu,0x0000007bu,0x0004006fu,0x00000069u,0x0000007eu,0x0000007du,0x00050050u,0x00000069u,0x0000007fu,0x00000075u,0x00000075u,0x00050088u,0x00000069u,0x00000080u,0x0000007fu,0x0000007eu,0x0003003eu,0x00000074u,0x00000080u,0x0004003du,0x00000077u,0x00000082u,0x00000079u,0x0004003du,0x00000069u,0x00000083u,0x0000006bu,0x00070058u,0x00000085u,0x00000086u,0x00000082u,0x00000083u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x00000087u,0x00000086u,0x00000086u,0x00000000u,0x00000001u,0x0003003eu,0x00000081u,0x00000087u,0x0004003du,0x00000077u,0x00000089u,0x00000079u,0x0004003du,0x00000069u,0x0000008au,0x0000006bu,0x00050041u,0x00000007u,0x0000008bu,0x00000074u,0x00000055u,0x0004003du,0x00000006u,0x0000008cu,0x0000008bu,0x00050050u,0x00000069u,0x0000008du,0x0000008cu,0x00000084u,0x00050083u,0x00000069u,0x0000008eu,0x0000008au,0x0000008du,0x00070058u,0x00000085u,0x0000008fu,0x00000089u,0x0000008eu,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x00000090u,0x0000008fu,0x0000008fu,0x00000000u,0x00000001u,0x0003003eu,0x00000088u,0x00000090u,0x0004003du,0x00000077u,0x00000092u,0x00000079u,0x0004003du,0x00000069u,0x00000093u,0x0000006bu,0x00050041u,0x00000007u,0x00000094u,0x00000074u,0x00000055u,0x0004003du,0x00000006u,0x00000095u,0x00000094u,0x00050050u,0x00000069u,0x00000096u,0x00000095u,0x00000084u,0x00050081u,0x00000069u,0x00000097u,0x00000093u,0x00000096u,0x00070058u,0x00000085u,0x00000098u,0x00000092u,0x00000097u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x00000099u,0x00000098u,0x00000098u,0x00000000u,0x00000001u,0x0003003eu,0x00000091u,0x00000099u,0x0004003du,0x00000077u,0x0000009bu,0x00000079u,0x0004003du,0x00000069u,0x0000009cu,0x0000006bu,0x00050041u,0x00000007u,0x0000009du,0x00000074u,0x0000005fu,0x0004003du,0x00000006u,0x0000009eu,0x0000009du,0x00050050u,0x00000069u,0x0000009fu,0x00000084u,0x0000009eu,0x00050083u,0x00000069u,0x000000a0u,0x0000009cu,0x0000009fu,0x00070058u,0x00000085u,0x000000a1u,0x0000009bu,0x000000a0u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x000000a2u,0x000000a1u,0x000000a1u,0x00000000u,0x00000001u,0x0003003eu,0x0000009au,0x000000a2u,0x0004003du,0x00000077u,0x000000a4u,0x00000079u,0x0004003du,0x00000069u,0x000000a5u,0x0000006bu,0x00050041u,0x00000007u,0x000000a6u,0x00000074u,0x0000005fu,0x0004003du,0x00000006u,0x000000a7u,0x000000a6u,0x00050050u,0x00000069u,0x000000a8u,0x00000084u,0x000000a7u,0x00050081u,0x00000069u,0x000000a9u,0x000000a5u,0x000000a8u,0x00070058u,0x00000085u,0x000000aau,0x000000a4u,0x000000a9u,0x00000002u,0x00000084u,0x0007004fu,0x00000069u,0x000000abu,0x000000aau,0x000000aau,0x00000000u,0x00000001u,0x0003003eu,0x000000a3u,0x000000abu,0x00050041u,0x00000007u,0x000000aeu,0x00000081u,0x00000055u,0x0004003du,0x00000006u,0x000000afu,0x000000aeu,0x0003003eu,0x000000adu,0x000000afu,0x00050041u,0x00000007u,0x000000b1u,0x00000088u,0x00000055u,0x0004003du,0x00000006u,0x000000b2u,0x000000b1u,0x0003003eu,0x000000b0u,0x000000b2u,0x00050041u,0x00000007u,0x000000b4u,0x00000091u,0x00000055u,0x0004003du,0x00000006u,0x000000b5u,0x000000b4u,0x0003003eu,0x000000b3u,0x000000b5u,0x00050041u,0x00000007u,0x000000b7u,0x0000009au,0x00000055u,0x0004003du,0x00000006u,0x000000b8u,0x000000b7u,0x0003003eu,0x000000b6u,0x000000b8u,0x00050041u,0x00000007u,0x000000bau,0x000000a3u,0x00000055u,0x0004003du,0x00000006u,0x000000bbu,0x000000bau,0x0003003eu,0x000000b9u,0x000000bbu,0x00090039u,0x00000006u,0x000000bcu,0x0000000eu,0x000000adu,0x000000b0u,0x000000b3u,0x000000b6u,0x000000b9u,0x00050041u,0x00000007u,0x000000beu,0x00000081u,0x0000005fu,0x0004003du,0x00000006u,0x000000bfu,0x000000beu,0x0003003eu,0x000000bdu,0x000000bfu,0x00050041u,0x00000007u,0x000000c1u,0x00000088u,0x0000005fu,0x0004003du,0x00000006u,0x000000c2u,0x000000c1u,0x0003003eu,0x000000c0u,0x000000c2u,0x00050041u,0x00000007u,0x000000c4u,0x00000091u,0x0000005fu,0x0004003du,0x00000006u,0x000000c5u,0x000000c4u,0x0003003eu,0x000000c3u,0x000000c5u,0x00050041u,0x00000007u,0x000000c7u,0x0000009au,0x0000005fu,0x0004003du,0x00000006u,0x000000c8u,0x000000c7u,0x0003003eu,0x000000c6u,0x000000c8u,0x00050041u,0x00000007u,0x000000cau,0x000000a3u,0x0000005fu,0x0004003du,0x00000006u,0x000000cbu,0x000000cau,0x0003003eu,0x000000c9u,0x000000cbu,0x00090039u,0x00000006u,0x000000ccu,0x0000000eu,0x000000bdu,0x000000c0u,0x000000c3u,0x000000c6u,0x000000c9u,0x00050050u,0x00000069u,0x000000cdu,0x000000bcu,0x000000ccu,0x0003003eu,0x000000acu,0x000000cdu,0x0004003du,0x00000069u,0x000000cfu,0x0000006bu,0x00050050u,0x00000069u,0x000000d0u,0x0000006eu,0x0000006eu,0x00050083u,0x00000069u,0x000000d1u,0x000000cfu,0x000000d0u,0x0003003eu,0x000000ceu,0x000000d1u,0x00060041u,0x000000d7u,0x000000d8u,0x000000d5u,0x000000d6u,0x00000055u,0x0004003du,0x00000006u,0x000000d9u,0x000000d8u,0x00050041u,0x00000007u,0x000000dau,0x000000ceu,0x00000055u,0x0004003du,0x00000006u,0x000000dbu,0x000000dau,0x00050085u,0x00000006u,0x000000dcu,0x000000d9u,0x000000dbu,0x00060041u,0x000000d7u,0x000000deu,0x000000d5u,0x000000d6u,0x000000ddu,0x0004003du,0x00000006u,0x000000dfu,0x000000deu,0x00050041u,0x00000007u,0x000000e0u,0x000000ceu,0x0000005fu,0x0004003du,0x00000006u,0x000000e1u,0x000000e0u,0x00050085u,0x00000006u,0x000000e2u,0x000000dfu,0x000000e1u,0x00050081u,0x00000006u,0x000000e3u,0x000000dcu,0x000000e2u,0x00060041u,0x000000d7u,0x000000e5u,0x000000d5u,0x000000e4u,0x00000055u,0x0004003du,0x00000006u,0x000000e6u,0x000000e5u,0x00050081u,0x00000006u,0x000000e7u,0x000000e3u,0x000000e6u,0x00060041u,0x000000d7u,0x000000e8u,0x000000d5u,0x000000d6u,0x0000005fu,0x0004003du,0x00000006u,0x000000e9u,0x000000e8u,0x00050041u,0x00000007u,0x000000eau,0x000000ceu,0x00000055u,0x0004003du,0x00000006u,0x000000ebu,0x000000eau,0x00050085u,0x00000006u,0x000000ecu,0x000000e9u,0x000000ebu,0x00060041u,0x000000d7u,0x000000eeu,0x000000d5u,0x000000d6u,0x000000edu,0x0004003du,0x00000006u,0x000000efu,0x000000eeu,0x00050041u,0x00000007u,0x000000f0u,0x000000ceu,0x0000005fu,0x0004003du,0x00000006u,0x000000f1u,0x000000f0u,0x00050085u,0x00000006u,0x000000f2u,0x000000efu,0x000000f1u,0x00050081u,0x00000006u,0x000000f3u,0x000000ecu,0x000000f2u,0x00060041u,0x000000d7u,0x000000f4u,0x000000d5u,0x000000e4u,0x0000005fu,0x0004003du,0x00000006u,0x000000f5u,0x000000f4u,0x00050081u,0x00000006u,0x000000f6u,0x000000f3u,0x000000f5u,0x00050050u,0x00000069u,0x000000f7u,0x000000e7u,0x000000f6u,0x0004003du,0x00000043u,0x000000f8u,0x0000004eu,0x0004006fu,0x00000069u,0x000000f9u,0x000000f8u,0x00050085u,0x00000069u,0x000000fau,0x000000f7u,0x000000f9u,0x0003003eu,0x000000d2u,0x000000fau,0x00060041u,0x000000d7u,0x000000feu,0x000000d5u,0x000000d6u,0x00000055u,0x0004003du,0x00000006u,0x000000ffu,0x000000feu,0x00050081u,0x00000006u,0x00000100u,0x00000075u,0x000000ffu,0x00060041u,0x000000d7u,0x00000101u,0x000000d5u,0x000000d6u,0x0000005fu,0x0004003du,0x00000006u,0x00000102u,0x00000101u,0x00060041u,0x000000d7u,0x00000103u,0x000000d5u,0x000000d6u,0x000000ddu,0x0004003du,0x00000006u,0x00000104u,0x00000103u,0x00060041u,0x000000d7u,0x00000105u,0x000000d5u,0x000000d6u,0x000000edu,0x0004003du,0x00000006u,0x00000106u,0x00000105u,0x00050081u,0x00000006u,0x00000107u,0x00000075u,0x00000106u,0x00050050u,0x00000069u,0x00000108u,0x00000100u,0x00000102u,0x00050050u,0x00000069u,0x00000109u,0x00000104u,0x00000107u,0x00050050u,0x000000fbu,0x0000010au,0x00000108u,0x00000109u,0x0003003eu,0x000000fdu,0x0000010au,0x0004003du,0x00000069u,0x0000010cu,0x000000d2u,0x0004003du,0x000000fbu,0x0000010du,0x000000fdu,0x0004003du,0x00000069u,0x0000010eu,0x000000acu,0x00050091u,0x00000069u,0x0000010fu,0x0000010du,0x0000010eu,0x00050081u,0x00000069u,0x00000110u,0x0000010cu,0x0000010fu,0x0003003eu,0x0000010bu,0x00000110u,0x0004003du,0x0000004fu,0x00000111u,0x00000051u,0x0004003du,0x00000043u,0x00000112u,0x00000045u,0x0004003du,0x00000069u,0x00000113u,0x0000010bu,0x00050051u,0x00000006u,0x00000114u,0x00000113u,0x00000000u,0x00050051u,0x00000006u,0x00000115u,0x00000113u,0x00000001u,0x00070050u,0x00000085u,0x00000116u,0x00000114u,0x00000115u,0x00000084u,0x00000075u,0x00040063u,0x00000111u,0x00000112u,0x00000116u,0x0004003du,0x0000004fu,0x00000118u,0x00000117u,0x0004003du,0x00000043u,0x00000119u,0x00000045u,0x0004003du,0x00000069u,0x0000011au,0x0000010bu,0x0004007fu,0x00000069u,0x0000011bu,0x0000011au,0x00050051u,0x00000006u,0x0000011cu,0x0000011bu,0x00000000u,0x00050051u,0x00000006u,0x0000011du,0x0000011bu,0x00000001u,0x00070050u,0x00000085u,0x0000011eu,0x0000011cu,0x0000011du,0x00000084u,0x00000075u,0x00040063u,0x00000118u,0x00000119u,0x0000011eu,0x000100fdu,0x00010038u,0x00050036u,0x00000006u,0x0000000eu,0x00000000u,0x00000008u,0x00030037u,0x00000007u,0x00000009u,0x00030037u,0x00000007u,0x0000000au,0x00030037u,0x00000007u,0x0000000bu,0x00030037u,0x00000007u,0x0000000cu,0x00030037u,0x00000007u,0x0000000du,0x000200f8u,0x0000000fu,0x0004003bu,0x00000007u,0x00000010u,0x00000007u,0x0004003bu,0x00000007u,0x00000034u,0x00000007u,0x0004003du,0x00000006u,0x00000011u,0x00000009u,0x0004003du,0x00000006u,0x00000012u,0x0000000au,0x0007000cu,0x00000006u,0x00000013u,0x00000001u,0x00000025u,0x00000011u,0x00000012u,0x0003003eu,0x00000010u,0x00000013u,0x0004003du,0x00000006u,0x00000014u,0x00000009u,0x0004003du,0x00000006u,0x00000015u,0x0000000au,0x0007000cu,0x00000006u,0x00000016u,0x00000001u,0x00000028u,0x00000014u,0x00000015u,0x0003003eu,0x00000009u,0x00000016u,0x0004003du,0x00000006u,0x00000017u,0x00000010u,0x0003003eu,0x0000000au,0x00000017u,0x0004003du,0x00000006u,0x00000018u,0x0000000bu,0x0004003du,0x00000006u,0x00000019u,0x0000000cu,0x0007000cu,0x00000006u,0x0000001au,0x00000001u,0x00000025u,0x00000018u,0x00000019u,0x0003003eu,0x00000010u,0x0000001au,0x0004003du,0x00000006u,0x0000001bu,0x0000000bu,0x0004003du,0x00000006u,0x0000001cu,0x0000000cu,0x0007000cu,0x00000006u,0x0000001du,0x00000001u,0x00000028u,0x0000001bu,0x0000001cu,0x0003003eu,0x0000000bu,0x0000001du,0x0004003du,0x00000006u,0x0000001eu,0x00000010u,0x0003003eu,0x0000000cu,0x0000001eu,0x0004003du,0x00000006u,0x0000001fu,0x00000009u,0x0004003du,0x00000006u,0x00000020u,0x0000000bu,0x0007000cu,0x00000006u,0x00000021u,0x00000001u,0x00000025u,0x0000001fu,0x00000020u,0x0003003eu,0x00000010u,0x00000021u,0x0004003du,0x00000006u,0x00000022u,0x00000009u,0x0004003du,0x00000006u,0x00000023u,0x0000000bu,0x0007000cu,0x00000006u,0x00000024u,0x00000001u,0x00000028u,0x00000022u,0x00000023u,0x0003003eu,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000025u,0x00000010u,0x0003003eu,0x0000000bu,0x00000025u,0x0004003du,0x00000006u,0x00000026u,0x0000000au,0x0004003du,0x00000006u,0x00000027u,0x0000000cu,0x0007000cu,0x00000006u,0x00000028u,0x00000001u,0x00000025u,0x00000026u,0x00000027u,0x0003003eu,0x00000010u,0x00000028u,0x0004003du,0x00000006u,0x00000029u,0x0000000au,0x0004003du,0x00000006u,0x0000002au,0x0000000cu,0x0007000cu,0x00000006u,0x0000002bu,0x00000001u,0x00000028u,0x00000029u,0x0000002au,0x0003003eu,0x0000000au,0x0000002bu,0x0004003du,0x00000006u,0x0000002cu,0x00000010u,0x0003003eu,0x0000000cu,0x0000002cu,0x0004003du,0x00000006u,0x0000002du,0x0000000au,0x0004003du,0x00000006u,0x0000002eu,0x0000000bu,0x0007000cu,0x00000006u,0x0000002fu,0x00000001u,0x00000025u,0x0000002du,0x0000002eu,0x0003003eu,0x00000010u,0x0000002fu,0x0004003du,0x00000006u,0x00000030u,0x0000000au,0x0004003du,0x00000006u,0x00000031u,0x0000000bu,0x0007000cu,0x00000006u,0x00000032u,0x00000001u,0x00000028u,0x00000030u,0x00000031u,0x0003003eu,0x0000000au,0x00000032u,0x0004003du,0x00000006u,0x00000033u,0x00000010u,0x0003003eu,0x0000000bu,0x00000033u,0x0004003du,0x00000006u,0x00000035u,0x0000000au,0x0004003du,0x00000006u,0x00000036u,0x0000000du,0x0007000cu,0x00000006u,0x00000037u,0x00000001u,0x00000025u,0x00000035u,0x00000036u,0x0003003eu,0x00000034u,0x00000037u,0x0004003du,0x00000006u,0x00000038u,0x0000000au,0x0004003du,0x00000006u,0x00000039u,0x0000000du,0x0007000cu,0x00000006u,0x0000003au,0x00000001u,0x00000028u,0x00000038u,0x00000039u,0x0003003eu,0x00000010u,0x0000003au,0x0004003du,0x00000006u,0x0000003bu,0x00000034u,0x0004003du,0x00000006u,0x0000003cu,0x0000000bu,0x0007000cu,0x00000006u,0x0000003du,0x00000001u,0x00000028u,0x0000003bu,0x0000003cu,0x0004003du,0x00000006u,0x0000003eu,0x00000010u,0x0007000cu,0x00000006u,0x0000003fu,0x00000001u,0x00000025u,0x0000003du,0x0000003eu,0x000200feu,0x0000003fu,0x00010038u}; static const size_t OF3_EXPAND_LEN = 1798; static const uint32_t OF3_FLOW_M4_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000151u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x000000f6u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00080005u,0x00000010u,0x636f6c62u,0x6461536bu,0x31327328u,0x3132733bu,0x3266763bu,0x0000003bu,0x00030005u,0x0000000du,0x00000061u,0x00030005u,0x0000000eu,0x00000062u,0x00040005u,0x0000000fu,0x646e6163u,0x00000000u,0x00070005u,0x00000016u,0x766c6f73u,0x32732865u,0x32733b31u,0x66763b31u,0x00003b32u,0x00030005u,0x00000013u,0x00000061u,0x00030005u,0x00000014u,0x00000062u,0x00040005u,0x00000015u,0x64657270u,0x00000000u,0x00030005u,0x00000019u,0x00646173u,0x00030005u,0x0000001du,0x00007962u,0x00030005u,0x00000028u,0x00007862u,0x00030005u,0x00000030u,0x00006f62u,0x00030005u,0x00000036u,0x00006170u,0x00030005u,0x00000039u,0x00765567u,0x00050005u,0x0000003cu,0x766e4967u,0x616d754cu,0x00000000u,0x00030005u,0x00000045u,0x00006270u,0x00040005u,0x0000005du,0x74736562u,0x00646153u,0x00050005u,0x0000005fu,0x74736562u,0x70736944u,0x00000000u,0x00030005u,0x00000061u,0x00007973u,0x00030005u,0x0000006bu,0x00007873u,0x00040005u,0x00000073u,0x646e6163u,0x00000000u,0x00030005u,0x0000007bu,0x00646173u,0x00040005u,0x0000007cu,0x61726170u,0x0000006du,0x00030005u,0x00000095u,0x00000055u,0x00060006u,0x00000095u,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x00000095u,0x00000001u,0x6576656cu,0x0000006cu,0x00050006u,0x00000095u,0x00000002u,0x6c63636fu,0x00006f4cu,0x00050006u,0x00000095u,0x00000003u,0x6c63636fu,0x00006948u,0x00030005u,0x00000097u,0x00000000u,0x00040005u,0x0000009eu,0x43646173u,0x00000000u,0x00040005u,0x000000a1u,0x58646173u,0x0000006du,0x00040005u,0x000000a6u,0x61726170u,0x0000006du,0x00040005u,0x000000a9u,0x58646173u,0x00000070u,0x00040005u,0x000000aeu,0x61726170u,0x0000006du,0x00040005u,0x000000b1u,0x59646173u,0x0000006du,0x00040005u,0x000000b5u,0x61726170u,0x0000006du,0x00040005u,0x000000b8u,0x59646173u,0x00000070u,0x00040005u,0x000000bcu,0x61726170u,0x0000006du,0x00030005u,0x000000bfu,0x00007864u,0x00030005u,0x000000c0u,0x00007964u,0x00040005u,0x000000c1u,0x6f6e6564u,0x0000586du,0x00040005u,0x000000c9u,0x6f6e6564u,0x0000596du,0x00030005u,0x000000f3u,0x00646967u,0x00080005u,0x000000f6u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x000000fbu,0x006d6964u,0x00040005u,0x000000feu,0x6f6c4675u,0x00000077u,0x00050005u,0x0000011au,0x6d754c75u,0x72754361u,0x00000072u,0x00040005u,0x00000122u,0x654c6f74u,0x006c6576u,0x00040005u,0x00000129u,0x64657270u,0x00000000u,0x00050005u,0x0000012au,0x65725075u,0x74636964u,0x0000726fu,0x00030005u,0x0000012eu,0x00647766u,0x00050005u,0x0000012fu,0x6d754c75u,0x65725061u,0x00000076u,0x00040005u,0x00000134u,0x61726170u,0x0000006du,0x00030005u,0x00000136u,0x00647762u,0x00040005u,0x0000013bu,0x61726170u,0x0000006du,0x00040005u,0x0000013du,0x75466f74u,0x00006c6cu,0x00030047u,0x00000095u,0x00000002u,0x00050048u,0x00000095u,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x00000095u,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x00000095u,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x00000095u,0x00000003u,0x00000023u,0x0000000cu,0x00040047u,0x00000097u,0x00000021u,0x00000000u,0x00040047u,0x00000097u,0x00000022u,0x00000000u,0x00040047u,0x000000f6u,0x0000000bu,0x0000001cu,0x00030047u,0x000000feu,0x00000019u,0x00040047u,0x000000feu,0x00000021u,0x00000030u,0x00040047u,0x000000feu,0x00000022u,0x00000000u,0x00040047u,0x0000011au,0x00000021u,0x00000021u,0x00040047u,0x0000011au,0x00000022u,0x00000000u,0x00040047u,0x0000012au,0x00000021u,0x00000022u,0x00040047u,0x0000012au,0x00000022u,0x00000000u,0x00040047u,0x0000012fu,0x00000021u,0x00000020u,0x00040047u,0x0000012fu,0x00000022u,0x00000000u,0x00040047u,0x00000150u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00030016u,0x00000006u,0x00000020u,0x00090019u,0x00000007u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000008u,0x00000007u,0x00040020u,0x00000009u,0x00000000u,0x00000008u,0x00040017u,0x0000000au,0x00000006u,0x00000002u,0x00040020u,0x0000000bu,0x00000007u,0x0000000au,0x00060021u,0x0000000cu,0x00000006u,0x00000009u,0x00000009u,0x0000000bu,0x00060021u,0x00000012u,0x0000000au,0x00000009u,0x00000009u,0x0000000bu,0x00040020u,0x00000018u,0x00000007u,0x00000006u,0x0004002bu,0x00000006u,0x0000001au,0x00000000u,0x00040015u,0x0000001bu,0x00000020u,0x00000001u,0x00040020u,0x0000001cu,0x00000007u,0x0000001bu,0x0004002bu,0x0000001bu,0x0000001eu,0xffffffffu,0x0004002bu,0x0000001bu,0x00000025u,0x00000001u,0x00020014u,0x00000026u,0x00040020u,0x00000038u,0x00000006u,0x0000000au,0x0004003bu,0x00000038u,0x00000039u,0x00000006u,0x0004003bu,0x00000038u,0x0000003cu,0x00000006u,0x00040017u,0x00000040u,0x00000006u,0x00000004u,0x00040015u,0x00000042u,0x00000020u,0x00000000u,0x0004002bu,0x00000042u,0x00000043u,0x00000000u,0x0004002bu,0x00000006u,0x0000005eu,0x7f7fffffu,0x0004002bu,0x0000001bu,0x00000062u,0xfffffffdu,0x0004002bu,0x0000001bu,0x00000069u,0x00000003u,0x0004002bu,0x00000006u,0x0000007fu,0x3b03126fu,0x0006001eu,0x00000095u,0x00000006u,0x00000042u,0x00000006u,0x00000006u,0x00040020u,0x00000096u,0x00000002u,0x00000095u,0x0004003bu,0x00000096u,0x00000097u,0x00000002u,0x00040020u,0x00000098u,0x00000002u,0x00000042u,0x0004002bu,0x00000006u,0x000000a3u,0xbf800000u,0x0005002cu,0x0000000au,0x000000a4u,0x000000a3u,0x0000001au,0x0004002bu,0x00000006u,0x000000abu,0x3f800000u,0x0005002cu,0x0000000au,0x000000acu,0x000000abu,0x0000001au,0x0005002cu,0x0000000au,0x000000b3u,0x0000001au,0x000000a3u,0x0005002cu,0x0000000au,0x000000bau,0x0000001au,0x000000abu,0x0004002bu,0x00000006u,0x000000c3u,0x40000000u,0x0004002bu,0x00000006u,0x000000d1u,0x358637bdu,0x0004002bu,0x00000006u,0x000000d5u,0x3f000000u,0x0004002bu,0x00000006u,0x000000dcu,0xbf000000u,0x00040017u,0x000000f1u,0x0000001bu,0x00000002u,0x00040020u,0x000000f2u,0x00000007u,0x000000f1u,0x00040017u,0x000000f4u,0x00000042u,0x00000003u,0x00040020u,0x000000f5u,0x00000001u,0x000000f4u,0x0004003bu,0x000000f5u,0x000000f6u,0x00000001u,0x00040017u,0x000000f7u,0x00000042u,0x00000002u,0x00090019u,0x000000fcu,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x000000fdu,0x00000000u,0x000000fcu,0x0004003bu,0x000000fdu,0x000000feu,0x00000000u,0x0004002bu,0x00000042u,0x00000109u,0x00000001u,0x0004003bu,0x00000009u,0x0000011au,0x00000000u,0x0004002bu,0x0000001bu,0x0000011cu,0x00000000u,0x00040020u,0x00000128u,0x00000007u,0x00000040u,0x0004003bu,0x00000009u,0x0000012au,0x00000000u,0x0004003bu,0x00000009u,0x0000012fu,0x00000000u,0x0004002bu,0x00000042u,0x0000014fu,0x00000010u,0x0006002cu,0x000000f4u,0x00000150u,0x0000014fu,0x0000014fu,0x00000109u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x000000f2u,0x000000f3u,0x00000007u,0x0004003bu,0x000000f2u,0x000000fbu,0x00000007u,0x0004003bu,0x00000018u,0x00000122u,0x00000007u,0x0004003bu,0x00000128u,0x00000129u,0x00000007u,0x0004003bu,0x0000000bu,0x0000012eu,0x00000007u,0x0004003bu,0x0000000bu,0x00000134u,0x00000007u,0x0004003bu,0x0000000bu,0x00000136u,0x00000007u,0x0004003bu,0x0000000bu,0x0000013bu,0x00000007u,0x0004003bu,0x00000018u,0x0000013du,0x00000007u,0x0004003du,0x000000f4u,0x000000f8u,0x000000f6u,0x0007004fu,0x000000f7u,0x000000f9u,0x000000f8u,0x000000f8u,0x00000000u,0x00000001u,0x0004007cu,0x000000f1u,0x000000fau,0x000000f9u,0x0003003eu,0x000000f3u,0x000000fau,0x0004003du,0x000000fcu,0x000000ffu,0x000000feu,0x00040068u,0x000000f1u,0x00000100u,0x000000ffu,0x0003003eu,0x000000fbu,0x00000100u,0x00050041u,0x0000001cu,0x00000101u,0x000000f3u,0x00000043u,0x0004003du,0x0000001bu,0x00000102u,0x00000101u,0x00050041u,0x0000001cu,0x00000103u,0x000000fbu,0x00000043u,0x0004003du,0x0000001bu,0x00000104u,0x00000103u,0x000500afu,0x00000026u,0x00000105u,0x00000102u,0x00000104u,0x000400a8u,0x00000026u,0x00000106u,0x00000105u,0x000300f7u,0x00000108u,0x00000000u,0x000400fau,0x00000106u,0x00000107u,0x00000108u,0x000200f8u,0x00000107u,0x00050041u,0x0000001cu,0x0000010au,0x000000f3u,0x00000109u,0x0004003du,0x0000001bu,0x0000010bu,0x0000010au,0x00050041u,0x0000001cu,0x0000010cu,0x000000fbu,0x00000109u,0x0004003du,0x0000001bu,0x0000010du,0x0000010cu,0x000500afu,0x00000026u,0x0000010eu,0x0000010bu,0x0000010du,0x000200f9u,0x00000108u,0x000200f8u,0x00000108u,0x000700f5u,0x00000026u,0x0000010fu,0x00000105u,0x00000005u,0x0000010eu,0x00000107u,0x000300f7u,0x00000111u,0x00000000u,0x000400fau,0x0000010fu,0x00000110u,0x00000111u,0x000200f8u,0x00000110u,0x000100fdu,0x000200f8u,0x00000111u,0x0004003du,0x000000f1u,0x00000113u,0x000000f3u,0x0004006fu,0x0000000au,0x00000114u,0x00000113u,0x00050050u,0x0000000au,0x00000115u,0x000000d5u,0x000000d5u,0x00050081u,0x0000000au,0x00000116u,0x00000114u,0x00000115u,0x0004003du,0x000000f1u,0x00000117u,0x000000fbu,0x0004006fu,0x0000000au,0x00000118u,0x00000117u,0x00050088u,0x0000000au,0x00000119u,0x00000116u,0x00000118u,0x0003003eu,0x00000039u,0x00000119u,0x0004003du,0x00000008u,0x0000011bu,0x0000011au,0x00040064u,0x00000007u,0x0000011du,0x0000011bu,0x00050067u,0x000000f1u,0x0000011eu,0x0000011du,0x0000011cu,0x0004006fu,0x0000000au,0x0000011fu,0x0000011eu,0x00050050u,0x0000000au,0x00000120u,0x000000abu,0x000000abu,0x00050088u,0x0000000au,0x00000121u,0x00000120u,0x0000011fu,0x0003003eu,0x0000003cu,0x00000121u,0x00050041u,0x00000098u,0x00000123u,0x00000097u,0x00000025u,0x0004003du,0x00000042u,0x00000124u,0x00000123u,0x00040070u,0x00000006u,0x00000125u,0x00000124u,0x0004007fu,0x00000006u,0x00000126u,0x00000125u,0x0006000cu,0x00000006u,0x00000127u,0x00000001u,0x0000001du,0x00000126u,0x0003003eu,0x00000122u,0x00000127u,0x0004003du,0x00000008u,0x0000012bu,0x0000012au,0x0004003du,0x0000000au,0x0000012cu,0x00000039u,0x00070058u,0x00000040u,0x0000012du,0x0000012bu,0x0000012cu,0x00000002u,0x0000001au,0x0003003eu,0x00000129u,0x0000012du,0x0004003du,0x00000040u,0x00000130u,0x00000129u,0x0007004fu,0x0000000au,0x00000131u,0x00000130u,0x00000130u,0x00000000u,0x00000001u,0x0004003du,0x00000006u,0x00000132u,0x00000122u,0x0005008eu,0x0000000au,0x00000133u,0x00000131u,0x00000132u,0x0003003eu,0x00000134u,0x00000133u,0x00070039u,0x0000000au,0x00000135u,0x00000016u,0x0000012fu,0x0000011au,0x00000134u,0x0003003eu,0x0000012eu,0x00000135u,0x0004003du,0x00000040u,0x00000137u,0x00000129u,0x0007004fu,0x0000000au,0x00000138u,0x00000137u,0x00000137u,0x00000002u,0x00000003u,0x0004003du,0x00000006u,0x00000139u,0x00000122u,0x0005008eu,0x0000000au,0x0000013au,0x00000138u,0x00000139u,0x0003003eu,0x0000013bu,0x0000013au,0x00070039u,0x0000000au,0x0000013cu,0x00000016u,0x0000011au,0x0000012fu,0x0000013bu,0x0003003eu,0x00000136u,0x0000013cu,0x00050041u,0x00000098u,0x0000013eu,0x00000097u,0x00000025u,0x0004003du,0x00000042u,0x0000013fu,0x0000013eu,0x00040070u,0x00000006u,0x00000140u,0x0000013fu,0x0006000cu,0x00000006u,0x00000141u,0x00000001u,0x0000001du,0x00000140u,0x0003003eu,0x0000013du,0x00000141u,0x0004003du,0x000000fcu,0x00000142u,0x000000feu,0x0004003du,0x000000f1u,0x00000143u,0x000000f3u,0x0004003du,0x0000000au,0x00000144u,0x0000012eu,0x0004003du,0x00000006u,0x00000145u,0x0000013du,0x0005008eu,0x0000000au,0x00000146u,0x00000144u,0x00000145u,0x0004003du,0x0000000au,0x00000147u,0x00000136u,0x0004003du,0x00000006u,0x00000148u,0x0000013du,0x0005008eu,0x0000000au,0x00000149u,0x00000147u,0x00000148u,0x00050051u,0x00000006u,0x0000014au,0x00000146u,0x00000000u,0x00050051u,0x00000006u,0x0000014bu,0x00000146u,0x00000001u,0x00050051u,0x00000006u,0x0000014cu,0x00000149u,0x00000000u,0x00050051u,0x00000006u,0x0000014du,0x00000149u,0x00000001u,0x00070050u,0x00000040u,0x0000014eu,0x0000014au,0x0000014bu,0x0000014cu,0x0000014du,0x00040063u,0x00000142u,0x00000143u,0x0000014eu,0x000100fdu,0x00010038u,0x00050036u,0x00000006u,0x00000010u,0x00000000u,0x0000000cu,0x00030037u,0x00000009u,0x0000000du,0x00030037u,0x00000009u,0x0000000eu,0x00030037u,0x0000000bu,0x0000000fu,0x000200f8u,0x00000011u,0x0004003bu,0x00000018u,0x00000019u,0x00000007u,0x0004003bu,0x0000001cu,0x0000001du,0x00000007u,0x0004003bu,0x0000001cu,0x00000028u,0x00000007u,0x0004003bu,0x0000000bu,0x00000030u,0x00000007u,0x0004003bu,0x00000018u,0x00000036u,0x00000007u,0x0004003bu,0x00000018u,0x00000045u,0x00000007u,0x0003003eu,0x00000019u,0x0000001au,0x0003003eu,0x0000001du,0x0000001eu,0x000200f9u,0x0000001fu,0x000200f8u,0x0000001fu,0x000400f6u,0x00000021u,0x00000022u,0x00000000u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x0004003du,0x0000001bu,0x00000024u,0x0000001du,0x000500b3u,0x00000026u,0x00000027u,0x00000024u,0x00000025u,0x000400fau,0x00000027u,0x00000020u,0x00000021u,0x000200f8u,0x00000020u,0x0003003eu,0x00000028u,0x0000001eu,0x000200f9u,0x00000029u,0x000200f8u,0x00000029u,0x000400f6u,0x0000002bu,0x0000002cu,0x00000000u,0x000200f9u,0x0000002du,0x000200f8u,0x0000002du,0x0004003du,0x0000001bu,0x0000002eu,0x00000028u,0x000500b3u,0x00000026u,0x0000002fu,0x0000002eu,0x00000025u,0x000400fau,0x0000002fu,0x0000002au,0x0000002bu,0x000200f8u,0x0000002au,0x0004003du,0x0000001bu,0x00000031u,0x00000028u,0x0004006fu,0x00000006u,0x00000032u,0x00000031u,0x0004003du,0x0000001bu,0x00000033u,0x0000001du,0x0004006fu,0x00000006u,0x00000034u,0x00000033u,0x00050050u,0x0000000au,0x00000035u,0x00000032u,0x00000034u,0x0003003eu,0x00000030u,0x00000035u,0x0004003du,0x00000008u,0x00000037u,0x0000000du,0x0004003du,0x0000000au,0x0000003au,0x00000039u,0x0004003du,0x0000000au,0x0000003bu,0x00000030u,0x0004003du,0x0000000au,0x0000003du,0x0000003cu,0x00050085u,0x0000000au,0x0000003eu,0x0000003bu,0x0000003du,0x00050081u,0x0000000au,0x0000003fu,0x0000003au,0x0000003eu,0x00070058u,0x00000040u,0x00000041u,0x00000037u,0x0000003fu,0x00000002u,0x0000001au,0x00050051u,0x00000006u,0x00000044u,0x00000041u,0x00000000u,0x0003003eu,0x00000036u,0x00000044u,0x0004003du,0x00000008u,0x00000046u,0x0000000eu,0x0004003du,0x0000000au,0x00000047u,0x00000039u,0x0004003du,0x0000000au,0x00000048u,0x00000030u,0x0004003du,0x0000000au,0x00000049u,0x0000000fu,0x00050081u,0x0000000au,0x0000004au,0x00000048u,0x00000049u,0x0004003du,0x0000000au,0x0000004bu,0x0000003cu,0x00050085u,0x0000000au,0x0000004cu,0x0000004au,0x0000004bu,0x00050081u,0x0000000au,0x0000004du,0x00000047u,0x0000004cu,0x00070058u,0x00000040u,0x0000004eu,0x00000046u,0x0000004du,0x00000002u,0x0000001au,0x00050051u,0x00000006u,0x0000004fu,0x0000004eu,0x00000000u,0x0003003eu,0x00000045u,0x0000004fu,0x0004003du,0x00000006u,0x00000050u,0x00000036u,0x0004003du,0x00000006u,0x00000051u,0x00000045u,0x00050083u,0x00000006u,0x00000052u,0x00000050u,0x00000051u,0x0006000cu,0x00000006u,0x00000053u,0x00000001u,0x00000004u,0x00000052u,0x0004003du,0x00000006u,0x00000054u,0x00000019u,0x00050081u,0x00000006u,0x00000055u,0x00000054u,0x00000053u,0x0003003eu,0x00000019u,0x00000055u,0x000200f9u,0x0000002cu,0x000200f8u,0x0000002cu,0x0004003du,0x0000001bu,0x00000056u,0x00000028u,0x00050080u,0x0000001bu,0x00000057u,0x00000056u,0x00000025u,0x0003003eu,0x00000028u,0x00000057u,0x000200f9u,0x00000029u,0x000200f8u,0x0000002bu,0x000200f9u,0x00000022u,0x000200f8u,0x00000022u,0x0004003du,0x0000001bu,0x00000058u,0x0000001du,0x00050080u,0x0000001bu,0x00000059u,0x00000058u,0x00000025u,0x0003003eu,0x0000001du,0x00000059u,0x000200f9u,0x0000001fu,0x000200f8u,0x00000021u,0x0004003du,0x00000006u,0x0000005au,0x00000019u,0x000200feu,0x0000005au,0x00010038u,0x00050036u,0x0000000au,0x00000016u,0x00000000u,0x00000012u,0x00030037u,0x00000009u,0x00000013u,0x00030037u,0x00000009u,0x00000014u,0x00030037u,0x0000000bu,0x00000015u,0x000200f8u,0x00000017u,0x0004003bu,0x00000018u,0x0000005du,0x00000007u,0x0004003bu,0x0000000bu,0x0000005fu,0x00000007u,0x0004003bu,0x0000001cu,0x00000061u,0x00000007u,0x0004003bu,0x0000001cu,0x0000006bu,0x00000007u,0x0004003bu,0x0000000bu,0x00000073u,0x00000007u,0x0004003bu,0x00000018u,0x0000007bu,0x00000007u,0x0004003bu,0x0000000bu,0x0000007cu,0x00000007u,0x0004003bu,0x00000018u,0x0000009eu,0x00000007u,0x0004003bu,0x00000018u,0x000000a1u,0x00000007u,0x0004003bu,0x0000000bu,0x000000a6u,0x00000007u,0x0004003bu,0x00000018u,0x000000a9u,0x00000007u,0x0004003bu,0x0000000bu,0x000000aeu,0x00000007u,0x0004003bu,0x00000018u,0x000000b1u,0x00000007u,0x0004003bu,0x0000000bu,0x000000b5u,0x00000007u,0x0004003bu,0x00000018u,0x000000b8u,0x00000007u,0x0004003bu,0x0000000bu,0x000000bcu,0x00000007u,0x0004003bu,0x00000018u,0x000000bfu,0x00000007u,0x0004003bu,0x00000018u,0x000000c0u,0x00000007u,0x0004003bu,0x00000018u,0x000000c1u,0x00000007u,0x0004003bu,0x00000018u,0x000000c9u,0x00000007u,0x0003003eu,0x0000005du,0x0000005eu,0x0004003du,0x0000000au,0x00000060u,0x00000015u,0x0003003eu,0x0000005fu,0x00000060u,0x0003003eu,0x00000061u,0x00000062u,0x000200f9u,0x00000063u,0x000200f8u,0x00000063u,0x000400f6u,0x00000065u,0x00000066u,0x00000000u,0x000200f9u,0x00000067u,0x000200f8u,0x00000067u,0x0004003du,0x0000001bu,0x00000068u,0x00000061u,0x000500b3u,0x00000026u,0x0000006au,0x00000068u,0x00000069u,0x000400fau,0x0000006au,0x00000064u,0x00000065u,0x000200f8u,0x00000064u,0x0003003eu,0x0000006bu,0x00000062u,0x000200f9u,0x0000006cu,0x000200f8u,0x0000006cu,0x000400f6u,0x0000006eu,0x0000006fu,0x00000000u,0x000200f9u,0x00000070u,0x000200f8u,0x00000070u,0x0004003du,0x0000001bu,0x00000071u,0x0000006bu,0x000500b3u,0x00000026u,0x00000072u,0x00000071u,0x00000069u,0x000400fau,0x00000072u,0x0000006du,0x0000006eu,0x000200f8u,0x0000006du,0x0004003du,0x0000000au,0x00000074u,0x00000015u,0x0004003du,0x0000001bu,0x00000075u,0x0000006bu,0x0004006fu,0x00000006u,0x00000076u,0x00000075u,0x0004003du,0x0000001bu,0x00000077u,0x00000061u,0x0004006fu,0x00000006u,0x00000078u,0x00000077u,0x00050050u,0x0000000au,0x00000079u,0x00000076u,0x00000078u,0x00050081u,0x0000000au,0x0000007au,0x00000074u,0x00000079u,0x0003003eu,0x00000073u,0x0000007au,0x0004003du,0x0000000au,0x0000007du,0x00000073u,0x0003003eu,0x0000007cu,0x0000007du,0x00070039u,0x00000006u,0x0000007eu,0x00000010u,0x00000013u,0x00000014u,0x0000007cu,0x0003003eu,0x0000007bu,0x0000007eu,0x0004003du,0x0000001bu,0x00000080u,0x0000006bu,0x0004006fu,0x00000006u,0x00000081u,0x00000080u,0x0006000cu,0x00000006u,0x00000082u,0x00000001u,0x00000004u,0x00000081u,0x0004003du,0x0000001bu,0x00000083u,0x00000061u,0x0004006fu,0x00000006u,0x00000084u,0x00000083u,0x0006000cu,0x00000006u,0x00000085u,0x00000001u,0x00000004u,0x00000084u,0x00050081u,0x00000006u,0x00000086u,0x00000082u,0x00000085u,0x00050085u,0x00000006u,0x00000087u,0x0000007fu,0x00000086u,0x0004003du,0x00000006u,0x00000088u,0x0000007bu,0x00050081u,0x00000006u,0x00000089u,0x00000088u,0x00000087u,0x0003003eu,0x0000007bu,0x00000089u,0x0004003du,0x00000006u,0x0000008au,0x0000007bu,0x0004003du,0x00000006u,0x0000008bu,0x0000005du,0x000500b8u,0x00000026u,0x0000008cu,0x0000008au,0x0000008bu,0x000300f7u,0x0000008eu,0x00000000u,0x000400fau,0x0000008cu,0x0000008du,0x0000008eu,0x000200f8u,0x0000008du,0x0004003du,0x00000006u,0x0000008fu,0x0000007bu,0x0003003eu,0x0000005du,0x0000008fu,0x0004003du,0x0000000au,0x00000090u,0x00000073u,0x0003003eu,0x0000005fu,0x00000090u,0x000200f9u,0x0000008eu,0x000200f8u,0x0000008eu,0x000200f9u,0x0000006fu,0x000200f8u,0x0000006fu,0x0004003du,0x0000001bu,0x00000091u,0x0000006bu,0x00050080u,0x0000001bu,0x00000092u,0x00000091u,0x00000025u,0x0003003eu,0x0000006bu,0x00000092u,0x000200f9u,0x0000006cu,0x000200f8u,0x0000006eu,0x000200f9u,0x00000066u,0x000200f8u,0x00000066u,0x0004003du,0x0000001bu,0x00000093u,0x00000061u,0x00050080u,0x0000001bu,0x00000094u,0x00000093u,0x00000025u,0x0003003eu,0x00000061u,0x00000094u,0x000200f9u,0x00000063u,0x000200f8u,0x00000065u,0x00050041u,0x00000098u,0x00000099u,0x00000097u,0x00000025u,0x0004003du,0x00000042u,0x0000009au,0x00000099u,0x000500aau,0x00000026u,0x0000009bu,0x0000009au,0x00000043u,0x000300f7u,0x0000009du,0x00000000u,0x000400fau,0x0000009bu,0x0000009cu,0x0000009du,0x000200f8u,0x0000009cu,0x0004003du,0x00000006u,0x0000009fu,0x0000005du,0x00050083u,0x00000006u,0x000000a0u,0x0000009fu,0x0000001au,0x0003003eu,0x0000009eu,0x000000a0u,0x0004003du,0x0000000au,0x000000a2u,0x0000005fu,0x00050081u,0x0000000au,0x000000a5u,0x000000a2u,0x000000a4u,0x0003003eu,0x000000a6u,0x000000a5u,0x00070039u,0x00000006u,0x000000a7u,0x00000010u,0x00000013u,0x00000014u,0x000000a6u,0x00050081u,0x00000006u,0x000000a8u,0x000000a7u,0x0000007fu,0x0003003eu,0x000000a1u,0x000000a8u,0x0004003du,0x0000000au,0x000000aau,0x0000005fu,0x00050081u,0x0000000au,0x000000adu,0x000000aau,0x000000acu,0x0003003eu,0x000000aeu,0x000000adu,0x00070039u,0x00000006u,0x000000afu,0x00000010u,0x00000013u,0x00000014u,0x000000aeu,0x00050081u,0x00000006u,0x000000b0u,0x000000afu,0x0000007fu,0x0003003eu,0x000000a9u,0x000000b0u,0x0004003du,0x0000000au,0x000000b2u,0x0000005fu,0x00050081u,0x0000000au,0x000000b4u,0x000000b2u,0x000000b3u,0x0003003eu,0x000000b5u,0x000000b4u,0x00070039u,0x00000006u,0x000000b6u,0x00000010u,0x00000013u,0x00000014u,0x000000b5u,0x00050081u,0x00000006u,0x000000b7u,0x000000b6u,0x0000007fu,0x0003003eu,0x000000b1u,0x000000b7u,0x0004003du,0x0000000au,0x000000b9u,0x0000005fu,0x00050081u,0x0000000au,0x000000bbu,0x000000b9u,0x000000bau,0x0003003eu,0x000000bcu,0x000000bbu,0x00070039u,0x00000006u,0x000000bdu,0x00000010u,0x00000013u,0x00000014u,0x000000bcu,0x00050081u,0x00000006u,0x000000beu,0x000000bdu,0x0000007fu,0x0003003eu,0x000000b8u,0x000000beu,0x0003003eu,0x000000bfu,0x0000001au,0x0003003eu,0x000000c0u,0x0000001au,0x0004003du,0x00000006u,0x000000c2u,0x000000a1u,0x0004003du,0x00000006u,0x000000c4u,0x0000009eu,0x00050085u,0x00000006u,0x000000c5u,0x000000c3u,0x000000c4u,0x00050083u,0x00000006u,0x000000c6u,0x000000c2u,0x000000c5u,0x0004003du,0x00000006u,0x000000c7u,0x000000a9u,0x00050081u,0x00000006u,0x000000c8u,0x000000c6u,0x000000c7u,0x0003003eu,0x000000c1u,0x000000c8u,0x0004003du,0x00000006u,0x000000cau,0x000000b1u,0x0004003du,0x00000006u,0x000000cbu,0x0000009eu,0x00050085u,0x00000006u,0x000000ccu,0x000000c3u,0x000000cbu,0x00050083u,0x00000006u,0x000000cdu,0x000000cau,0x000000ccu,0x0004003du,0x00000006u,0x000000ceu,0x000000b8u,0x00050081u,0x00000006u,0x000000cfu,0x000000cdu,0x000000ceu,0x0003003eu,0x000000c9u,0x000000cfu,0x0004003du,0x00000006u,0x000000d0u,0x000000c1u,0x000500bau,0x00000026u,0x000000d2u,0x000000d0u,0x000000d1u,0x000300f7u,0x000000d4u,0x00000000u,0x000400fau,0x000000d2u,0x000000d3u,0x000000d4u,0x000200f8u,0x000000d3u,0x0004003du,0x00000006u,0x000000d6u,0x000000a1u,0x0004003du,0x00000006u,0x000000d7u,0x000000a9u,0x00050083u,0x00000006u,0x000000d8u,0x000000d6u,0x000000d7u,0x00050085u,0x00000006u,0x000000d9u,0x000000d5u,0x000000d8u,0x0004003du,0x00000006u,0x000000dau,0x000000c1u,0x00050088u,0x00000006u,0x000000dbu,0x000000d9u,0x000000dau,0x0008000cu,0x00000006u,0x000000ddu,0x00000001u,0x0000002bu,0x000000dbu,0x000000dcu,0x000000d5u,0x0003003eu,0x000000bfu,0x000000ddu,0x000200f9u,0x000000d4u,0x000200f8u,0x000000d4u,0x0004003du,0x00000006u,0x000000deu,0x000000c9u,0x000500bau,0x00000026u,0x000000dfu,0x000000deu,0x000000d1u,0x000300f7u,0x000000e1u,0x00000000u,0x000400fau,0x000000dfu,0x000000e0u,0x000000e1u,0x000200f8u,0x000000e0u,0x0004003du,0x00000006u,0x000000e2u,0x000000b1u,0x0004003du,0x00000006u,0x000000e3u,0x000000b8u,0x00050083u,0x00000006u,0x000000e4u,0x000000e2u,0x000000e3u,0x00050085u,0x00000006u,0x000000e5u,0x000000d5u,0x000000e4u,0x0004003du,0x00000006u,0x000000e6u,0x000000c9u,0x00050088u,0x00000006u,0x000000e7u,0x000000e5u,0x000000e6u,0x0008000cu,0x00000006u,0x000000e8u,0x00000001u,0x0000002bu,0x000000e7u,0x000000dcu,0x000000d5u,0x0003003eu,0x000000c0u,0x000000e8u,0x000200f9u,0x000000e1u,0x000200f8u,0x000000e1u,0x0004003du,0x00000006u,0x000000e9u,0x000000bfu,0x0004003du,0x00000006u,0x000000eau,0x000000c0u,0x00050050u,0x0000000au,0x000000ebu,0x000000e9u,0x000000eau,0x0004003du,0x0000000au,0x000000ecu,0x0000005fu,0x00050081u,0x0000000au,0x000000edu,0x000000ecu,0x000000ebu,0x0003003eu,0x0000005fu,0x000000edu,0x000200f9u,0x0000009du,0x000200f8u,0x0000009du,0x0004003du,0x0000000au,0x000000eeu,0x0000005fu,0x000200feu,0x000000eeu,0x00010038u}; @@ -18,8 +226,8 @@ static const uint32_t OF3_GM_REDUCE_SPV[] = {0x07230203u,0x00010300u,0x0008000bu static const size_t OF3_GM_REDUCE_LEN = 2584; static const uint32_t OF3_GM_PREWARP_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000074u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000000du,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00030005u,0x00000009u,0x00646967u,0x00080005u,0x0000000du,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000016u,0x74734475u,0x00000000u,0x00030005u,0x00000030u,0x00007675u,0x00030005u,0x00000039u,0x00000071u,0x00040005u,0x0000003du,0x6c6f6370u,0x00000030u,0x00030005u,0x0000003fu,0x00004d47u,0x00050006u,0x0000003fu,0x00000000u,0x694c6d67u,0x0000006eu,0x00050006u,0x0000003fu,0x00000001u,0x694c6d67u,0x0000546eu,0x00050006u,0x0000003fu,0x00000002u,0x70416d67u,0x00000070u,0x00050006u,0x0000003fu,0x00000003u,0x70416d67u,0x00005470u,0x00030005u,0x00000041u,0x00000000u,0x00040005u,0x00000049u,0x6c6f6370u,0x00000031u,0x00040005u,0x00000051u,0x72537675u,0x00000063u,0x00030005u,0x00000064u,0x00000076u,0x00040005u,0x00000068u,0x72754375u,0x00000072u,0x00040047u,0x0000000du,0x0000000bu,0x0000001cu,0x00030047u,0x00000016u,0x00000019u,0x00040047u,0x00000016u,0x00000021u,0x00000030u,0x00040047u,0x00000016u,0x00000022u,0x00000000u,0x00030047u,0x0000003fu,0x00000002u,0x00050048u,0x0000003fu,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x0000003fu,0x00000001u,0x00000023u,0x00000010u,0x00050048u,0x0000003fu,0x00000002u,0x00000023u,0x00000020u,0x00050048u,0x0000003fu,0x00000003u,0x00000023u,0x00000030u,0x00040047u,0x00000041u,0x00000021u,0x00000001u,0x00040047u,0x00000041u,0x00000022u,0x00000000u,0x00040047u,0x00000068u,0x00000021u,0x00000020u,0x00040047u,0x00000068u,0x00000022u,0x00000000u,0x00040047u,0x00000073u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040015u,0x0000000au,0x00000020u,0x00000000u,0x00040017u,0x0000000bu,0x0000000au,0x00000003u,0x00040020u,0x0000000cu,0x00000001u,0x0000000bu,0x0004003bu,0x0000000cu,0x0000000du,0x00000001u,0x00040017u,0x0000000eu,0x0000000au,0x00000002u,0x00030016u,0x00000013u,0x00000020u,0x00090019u,0x00000014u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000003u,0x00040020u,0x00000015u,0x00000000u,0x00000014u,0x0004003bu,0x00000015u,0x00000016u,0x00000000u,0x00020014u,0x00000019u,0x0004002bu,0x0000000au,0x0000001au,0x00000000u,0x00040020u,0x0000001bu,0x00000007u,0x00000006u,0x0004002bu,0x0000000au,0x00000024u,0x00000001u,0x00040017u,0x0000002eu,0x00000013u,0x00000002u,0x00040020u,0x0000002fu,0x00000007u,0x0000002eu,0x0004002bu,0x00000013u,0x00000033u,0x3f000000u,0x00040017u,0x0000003eu,0x00000013u,0x00000004u,0x0006001eu,0x0000003fu,0x0000003eu,0x0000003eu,0x0000003eu,0x0000003eu,0x00040020u,0x00000040u,0x00000002u,0x0000003fu,0x0004003bu,0x00000040u,0x00000041u,0x00000002u,0x0004002bu,0x00000006u,0x00000042u,0x00000002u,0x00040020u,0x00000043u,0x00000002u,0x00000013u,0x0004002bu,0x0000000au,0x0000004au,0x00000002u,0x0004002bu,0x0000000au,0x0000004du,0x00000003u,0x00040020u,0x00000054u,0x00000007u,0x00000013u,0x0004002bu,0x00000006u,0x0000005eu,0x00000003u,0x00040020u,0x0000005fu,0x00000002u,0x0000003eu,0x00090019u,0x00000065u,0x00000013u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000066u,0x00000065u,0x00040020u,0x00000067u,0x00000000u,0x00000066u,0x0004003bu,0x00000067u,0x00000068u,0x00000000u,0x0004002bu,0x00000013u,0x0000006bu,0x00000000u,0x0004002bu,0x0000000au,0x00000072u,0x00000010u,0x0006002cu,0x0000000bu,0x00000073u,0x00000072u,0x00000072u,0x00000024u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000009u,0x00000007u,0x0004003bu,0x00000008u,0x00000012u,0x00000007u,0x0004003bu,0x0000002fu,0x00000030u,0x00000007u,0x0004003bu,0x0000002fu,0x00000039u,0x00000007u,0x0004003bu,0x0000002fu,0x0000003du,0x00000007u,0x0004003bu,0x0000002fu,0x00000049u,0x00000007u,0x0004003bu,0x0000002fu,0x00000051u,0x00000007u,0x0004003bu,0x00000054u,0x00000064u,0x00000007u,0x0004003du,0x0000000bu,0x0000000fu,0x0000000du,0x0007004fu,0x0000000eu,0x00000010u,0x0000000fu,0x0000000fu,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x00000011u,0x00000010u,0x0003003eu,0x00000009u,0x00000011u,0x0004003du,0x00000014u,0x00000017u,0x00000016u,0x00040068u,0x00000007u,0x00000018u,0x00000017u,0x0003003eu,0x00000012u,0x00000018u,0x00050041u,0x0000001bu,0x0000001cu,0x00000009u,0x0000001au,0x0004003du,0x00000006u,0x0000001du,0x0000001cu,0x00050041u,0x0000001bu,0x0000001eu,0x00000012u,0x0000001au,0x0004003du,0x00000006u,0x0000001fu,0x0000001eu,0x000500afu,0x00000019u,0x00000020u,0x0000001du,0x0000001fu,0x000400a8u,0x00000019u,0x00000021u,0x00000020u,0x000300f7u,0x00000023u,0x00000000u,0x000400fau,0x00000021u,0x00000022u,0x00000023u,0x000200f8u,0x00000022u,0x00050041u,0x0000001bu,0x00000025u,0x00000009u,0x00000024u,0x0004003du,0x00000006u,0x00000026u,0x00000025u,0x00050041u,0x0000001bu,0x00000027u,0x00000012u,0x00000024u,0x0004003du,0x00000006u,0x00000028u,0x00000027u,0x000500afu,0x00000019u,0x00000029u,0x00000026u,0x00000028u,0x000200f9u,0x00000023u,0x000200f8u,0x00000023u,0x000700f5u,0x00000019u,0x0000002au,0x00000020u,0x00000005u,0x00000029u,0x00000022u,0x000300f7u,0x0000002cu,0x00000000u,0x000400fau,0x0000002au,0x0000002bu,0x0000002cu,0x000200f8u,0x0000002bu,0x000100fdu,0x000200f8u,0x0000002cu,0x0004003du,0x00000007u,0x00000031u,0x00000009u,0x0004006fu,0x0000002eu,0x00000032u,0x00000031u,0x00050050u,0x0000002eu,0x00000034u,0x00000033u,0x00000033u,0x00050081u,0x0000002eu,0x00000035u,0x00000032u,0x00000034u,0x0004003du,0x00000007u,0x00000036u,0x00000012u,0x0004006fu,0x0000002eu,0x00000037u,0x00000036u,0x00050088u,0x0000002eu,0x00000038u,0x00000035u,0x00000037u,0x0003003eu,0x00000030u,0x00000038u,0x0004003du,0x0000002eu,0x0000003au,0x00000030u,0x00050050u,0x0000002eu,0x0000003bu,0x00000033u,0x00000033u,0x00050083u,0x0000002eu,0x0000003cu,0x0000003au,0x0000003bu,0x0003003eu,0x00000039u,0x0000003cu,0x00060041u,0x00000043u,0x00000044u,0x00000041u,0x00000042u,0x0000001au,0x0004003du,0x00000013u,0x00000045u,0x00000044u,0x00060041u,0x00000043u,0x00000046u,0x00000041u,0x00000042u,0x00000024u,0x0004003du,0x00000013u,0x00000047u,0x00000046u,0x00050050u,0x0000002eu,0x00000048u,0x00000045u,0x00000047u,0x0003003eu,0x0000003du,0x00000048u,0x00060041u,0x00000043u,0x0000004bu,0x00000041u,0x00000042u,0x0000004au,0x0004003du,0x00000013u,0x0000004cu,0x0000004bu,0x00060041u,0x00000043u,0x0000004eu,0x00000041u,0x00000042u,0x0000004du,0x0004003du,0x00000013u,0x0000004fu,0x0000004eu,0x00050050u,0x0000002eu,0x00000050u,0x0000004cu,0x0000004fu,0x0003003eu,0x00000049u,0x00000050u,0x0004003du,0x0000002eu,0x00000052u,0x00000030u,0x0004003du,0x0000002eu,0x00000053u,0x0000003du,0x00050041u,0x00000054u,0x00000055u,0x00000039u,0x0000001au,0x0004003du,0x00000013u,0x00000056u,0x00000055u,0x0005008eu,0x0000002eu,0x00000057u,0x00000053u,0x00000056u,0x00050081u,0x0000002eu,0x00000058u,0x00000052u,0x00000057u,0x0004003du,0x0000002eu,0x00000059u,0x00000049u,0x00050041u,0x00000054u,0x0000005au,0x00000039u,0x00000024u,0x0004003du,0x00000013u,0x0000005bu,0x0000005au,0x0005008eu,0x0000002eu,0x0000005cu,0x00000059u,0x0000005bu,0x00050081u,0x0000002eu,0x0000005du,0x00000058u,0x0000005cu,0x00050041u,0x0000005fu,0x00000060u,0x00000041u,0x0000005eu,0x0004003du,0x0000003eu,0x00000061u,0x00000060u,0x0007004fu,0x0000002eu,0x00000062u,0x00000061u,0x00000061u,0x00000000u,0x00000001u,0x00050081u,0x0000002eu,0x00000063u,0x0000005du,0x00000062u,0x0003003eu,0x00000051u,0x00000063u,0x0004003du,0x00000066u,0x00000069u,0x00000068u,0x0004003du,0x0000002eu,0x0000006au,0x00000051u,0x00070058u,0x0000003eu,0x0000006cu,0x00000069u,0x0000006au,0x00000002u,0x0000006bu,0x00050051u,0x00000013u,0x0000006du,0x0000006cu,0x00000000u,0x0003003eu,0x00000064u,0x0000006du,0x0004003du,0x00000014u,0x0000006eu,0x00000016u,0x0004003du,0x00000007u,0x0000006fu,0x00000009u,0x0004003du,0x00000013u,0x00000070u,0x00000064u,0x00070050u,0x0000003eu,0x00000071u,0x00000070u,0x0000006bu,0x0000006bu,0x0000006bu,0x00040063u,0x0000006eu,0x0000006fu,0x00000071u,0x000100fdu,0x00010038u}; static const size_t OF3_GM_PREWARP_LEN = 706; -static const uint32_t OF3_FLOWREG_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000144u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x00000037u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00060005u,0x0000000eu,0x63746566u,0x76285568u,0x763b3269u,0x003b3269u,0x00030005u,0x0000000cu,0x00000070u,0x00030005u,0x0000000du,0x006d6964u,0x00060005u,0x00000013u,0x63746566u,0x76284c68u,0x763b3269u,0x003b3269u,0x00030005u,0x00000011u,0x00000070u,0x00030005u,0x00000012u,0x006d6964u,0x00040005u,0x00000018u,0x6f6c4675u,0x006e4977u,0x00040005u,0x00000026u,0x6d754c75u,0x00000061u,0x00030005u,0x00000034u,0x00646967u,0x00080005u,0x00000037u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x0000003cu,0x006d6964u,0x00030005u,0x00000055u,0x00007464u,0x00030005u,0x00000056u,0x00000055u,0x00050006u,0x00000056u,0x00000000u,0x61726170u,0x0000736du,0x00030005u,0x00000058u,0x00000000u,0x00040005u,0x0000005cu,0x626d616cu,0x00006164u,0x00050005u,0x0000005fu,0x65676465u,0x68706c41u,0x00000061u,0x00040005u,0x00000063u,0x54737065u,0x00000056u,0x00030005u,0x00000068u,0x00004375u,0x00040005u,0x00000069u,0x61726170u,0x0000006du,0x00040005u,0x0000006bu,0x61726170u,0x0000006du,0x00030005u,0x0000006eu,0x00004c75u,0x00040005u,0x00000073u,0x61726170u,0x0000006du,0x00040005u,0x00000074u,0x61726170u,0x0000006du,0x00030005u,0x00000077u,0x00005275u,0x00040005u,0x0000007bu,0x61726170u,0x0000006du,0x00040005u,0x0000007cu,0x61726170u,0x0000006du,0x00030005u,0x0000007fu,0x00005575u,0x00040005u,0x00000083u,0x61726170u,0x0000006du,0x00040005u,0x00000084u,0x61726170u,0x0000006du,0x00030005u,0x00000087u,0x00004475u,0x00040005u,0x0000008bu,0x61726170u,0x0000006du,0x00040005u,0x0000008cu,0x61726170u,0x0000006du,0x00040005u,0x0000008fu,0x6d69646cu,0x00000000u,0x00030005u,0x00000093u,0x00004c6cu,0x00040005u,0x00000096u,0x61726170u,0x0000006du,0x00040005u,0x00000097u,0x61726170u,0x0000006du,0x00030005u,0x0000009au,0x0000526cu,0x00040005u,0x0000009du,0x61726170u,0x0000006du,0x00040005u,0x0000009eu,0x61726170u,0x0000006du,0x00030005u,0x000000a1u,0x0000556cu,0x00040005u,0x000000a4u,0x61726170u,0x0000006du,0x00040005u,0x000000a5u,0x61726170u,0x0000006du,0x00030005u,0x000000a8u,0x0000446cu,0x00040005u,0x000000abu,0x61726170u,0x0000006du,0x00040005u,0x000000acu,0x61726170u,0x0000006du,0x00040005u,0x000000afu,0x67616d67u,0x00000000u,0x00030005u,0x000000bbu,0x00000067u,0x00030005u,0x000000c4u,0x00004c64u,0x00030005u,0x000000c8u,0x00005264u,0x00030005u,0x000000ccu,0x00005564u,0x00030005u,0x000000d0u,0x00004464u,0x00030005u,0x000000d4u,0x00003265u,0x00030005u,0x000000d8u,0x00004c77u,0x00030005u,0x000000e1u,0x00005277u,0x00030005u,0x000000eau,0x00005577u,0x00030005u,0x000000f3u,0x00004477u,0x00040005u,0x000000fcu,0x576d7573u,0x00000000u,0x00040005u,0x00000104u,0x576d7573u,0x00000055u,0x00040005u,0x00000114u,0x66694475u,0x00000066u,0x00030005u,0x00000120u,0x00003066u,0x00050005u,0x00000121u,0x6f6c4675u,0x73624f77u,0x00000000u,0x00040005u,0x0000012au,0x74656874u,0x00000061u,0x00030005u,0x0000012eu,0x00000072u,0x00040005u,0x00000132u,0x77654e75u,0x00000000u,0x00050005u,0x0000013eu,0x6f6c4675u,0x74754f77u,0x00000000u,0x00040047u,0x00000018u,0x00000021u,0x00000020u,0x00040047u,0x00000018u,0x00000022u,0x00000000u,0x00040047u,0x00000026u,0x00000021u,0x00000022u,0x00040047u,0x00000026u,0x00000022u,0x00000000u,0x00040047u,0x00000037u,0x0000000bu,0x0000001cu,0x00030047u,0x00000056u,0x00000002u,0x00050048u,0x00000056u,0x00000000u,0x00000023u,0x00000000u,0x00040047u,0x00000058u,0x00000021u,0x00000000u,0x00040047u,0x00000058u,0x00000022u,0x00000000u,0x00040047u,0x00000121u,0x00000021u,0x00000021u,0x00040047u,0x00000121u,0x00000022u,0x00000000u,0x00030047u,0x0000013eu,0x00000019u,0x00040047u,0x0000013eu,0x00000021u,0x00000030u,0x00040047u,0x0000013eu,0x00000022u,0x00000000u,0x00040047u,0x00000143u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00030016u,0x00000009u,0x00000020u,0x00040017u,0x0000000au,0x00000009u,0x00000004u,0x00050021u,0x0000000bu,0x0000000au,0x00000008u,0x00000008u,0x00050021u,0x00000010u,0x00000009u,0x00000008u,0x00000008u,0x00090019u,0x00000015u,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000016u,0x00000015u,0x00040020u,0x00000017u,0x00000000u,0x00000016u,0x0004003bu,0x00000017u,0x00000018u,0x00000000u,0x0004002bu,0x00000006u,0x0000001bu,0x00000000u,0x0005002cu,0x00000007u,0x0000001cu,0x0000001bu,0x0000001bu,0x0004002bu,0x00000006u,0x0000001eu,0x00000001u,0x0004003bu,0x00000017u,0x00000026u,0x00000000u,0x00040015u,0x0000002fu,0x00000020u,0x00000000u,0x0004002bu,0x0000002fu,0x00000030u,0x00000000u,0x00040017u,0x00000035u,0x0000002fu,0x00000003u,0x00040020u,0x00000036u,0x00000001u,0x00000035u,0x0004003bu,0x00000036u,0x00000037u,0x00000001u,0x00040017u,0x00000038u,0x0000002fu,0x00000002u,0x00020014u,0x00000040u,0x00040020u,0x00000041u,0x00000007u,0x00000006u,0x0004002bu,0x0000002fu,0x0000004au,0x00000001u,0x00040020u,0x00000054u,0x00000007u,0x00000009u,0x0003001eu,0x00000056u,0x0000000au,0x00040020u,0x00000057u,0x00000002u,0x00000056u,0x0004003bu,0x00000057u,0x00000058u,0x00000002u,0x00040020u,0x00000059u,0x00000002u,0x00000009u,0x0004002bu,0x0000002fu,0x00000060u,0x00000002u,0x0004002bu,0x0000002fu,0x00000064u,0x00000003u,0x00040020u,0x00000067u,0x00000007u,0x0000000au,0x0004002bu,0x00000006u,0x00000070u,0xffffffffu,0x0005002cu,0x00000007u,0x00000071u,0x00000070u,0x0000001bu,0x0005002cu,0x00000007u,0x00000079u,0x0000001eu,0x0000001bu,0x0005002cu,0x00000007u,0x00000081u,0x0000001bu,0x00000070u,0x0005002cu,0x00000007u,0x00000089u,0x0000001bu,0x0000001eu,0x0004002bu,0x00000009u,0x000000b0u,0x3f000000u,0x00040017u,0x000000b7u,0x00000009u,0x00000002u,0x0004002bu,0x00000009u,0x000000c1u,0x3d4ccccdu,0x0004002bu,0x00000009u,0x000000c2u,0x3f800000u,0x0004003bu,0x00000017u,0x00000121u,0x00000000u,0x00090019u,0x0000013cu,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x0000013du,0x00000000u,0x0000013cu,0x0004003bu,0x0000013du,0x0000013eu,0x00000000u,0x0004002bu,0x0000002fu,0x00000142u,0x00000010u,0x0006002cu,0x00000035u,0x00000143u,0x00000142u,0x00000142u,0x0000004au,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000008u,0x00000034u,0x00000007u,0x0004003bu,0x00000008u,0x0000003cu,0x00000007u,0x0004003bu,0x00000054u,0x00000055u,0x00000007u,0x0004003bu,0x00000054u,0x0000005cu,0x00000007u,0x0004003bu,0x00000054u,0x0000005fu,0x00000007u,0x0004003bu,0x00000054u,0x00000063u,0x00000007u,0x0004003bu,0x00000067u,0x00000068u,0x00000007u,0x0004003bu,0x00000008u,0x00000069u,0x00000007u,0x0004003bu,0x00000008u,0x0000006bu,0x00000007u,0x0004003bu,0x00000067u,0x0000006eu,0x00000007u,0x0004003bu,0x00000008u,0x00000073u,0x00000007u,0x0004003bu,0x00000008u,0x00000074u,0x00000007u,0x0004003bu,0x00000067u,0x00000077u,0x00000007u,0x0004003bu,0x00000008u,0x0000007bu,0x00000007u,0x0004003bu,0x00000008u,0x0000007cu,0x00000007u,0x0004003bu,0x00000067u,0x0000007fu,0x00000007u,0x0004003bu,0x00000008u,0x00000083u,0x00000007u,0x0004003bu,0x00000008u,0x00000084u,0x00000007u,0x0004003bu,0x00000067u,0x00000087u,0x00000007u,0x0004003bu,0x00000008u,0x0000008bu,0x00000007u,0x0004003bu,0x00000008u,0x0000008cu,0x00000007u,0x0004003bu,0x00000008u,0x0000008fu,0x00000007u,0x0004003bu,0x00000054u,0x00000093u,0x00000007u,0x0004003bu,0x00000008u,0x00000096u,0x00000007u,0x0004003bu,0x00000008u,0x00000097u,0x00000007u,0x0004003bu,0x00000054u,0x0000009au,0x00000007u,0x0004003bu,0x00000008u,0x0000009du,0x00000007u,0x0004003bu,0x00000008u,0x0000009eu,0x00000007u,0x0004003bu,0x00000054u,0x000000a1u,0x00000007u,0x0004003bu,0x00000008u,0x000000a4u,0x00000007u,0x0004003bu,0x00000008u,0x000000a5u,0x00000007u,0x0004003bu,0x00000054u,0x000000a8u,0x00000007u,0x0004003bu,0x00000008u,0x000000abu,0x00000007u,0x0004003bu,0x00000008u,0x000000acu,0x00000007u,0x0004003bu,0x00000054u,0x000000afu,0x00000007u,0x0004003bu,0x00000054u,0x000000bbu,0x00000007u,0x0004003bu,0x00000067u,0x000000c4u,0x00000007u,0x0004003bu,0x00000067u,0x000000c8u,0x00000007u,0x0004003bu,0x00000067u,0x000000ccu,0x00000007u,0x0004003bu,0x00000067u,0x000000d0u,0x00000007u,0x0004003bu,0x00000054u,0x000000d4u,0x00000007u,0x0004003bu,0x00000054u,0x000000d8u,0x00000007u,0x0004003bu,0x00000054u,0x000000e1u,0x00000007u,0x0004003bu,0x00000054u,0x000000eau,0x00000007u,0x0004003bu,0x00000054u,0x000000f3u,0x00000007u,0x0004003bu,0x00000054u,0x000000fcu,0x00000007u,0x0004003bu,0x00000067u,0x00000104u,0x00000007u,0x0004003bu,0x00000067u,0x00000114u,0x00000007u,0x0004003bu,0x00000067u,0x00000120u,0x00000007u,0x0004003bu,0x00000054u,0x0000012au,0x00000007u,0x0004003bu,0x00000067u,0x0000012eu,0x00000007u,0x0004003bu,0x00000067u,0x00000132u,0x00000007u,0x0004003du,0x00000035u,0x00000039u,0x00000037u,0x0007004fu,0x00000038u,0x0000003au,0x00000039u,0x00000039u,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x0000003bu,0x0000003au,0x0003003eu,0x00000034u,0x0000003bu,0x0004003du,0x00000016u,0x0000003du,0x00000018u,0x00040064u,0x00000015u,0x0000003eu,0x0000003du,0x00050067u,0x00000007u,0x0000003fu,0x0000003eu,0x0000001bu,0x0003003eu,0x0000003cu,0x0000003fu,0x00050041u,0x00000041u,0x00000042u,0x00000034u,0x00000030u,0x0004003du,0x00000006u,0x00000043u,0x00000042u,0x00050041u,0x00000041u,0x00000044u,0x0000003cu,0x00000030u,0x0004003du,0x00000006u,0x00000045u,0x00000044u,0x000500afu,0x00000040u,0x00000046u,0x00000043u,0x00000045u,0x000400a8u,0x00000040u,0x00000047u,0x00000046u,0x000300f7u,0x00000049u,0x00000000u,0x000400fau,0x00000047u,0x00000048u,0x00000049u,0x000200f8u,0x00000048u,0x00050041u,0x00000041u,0x0000004bu,0x00000034u,0x0000004au,0x0004003du,0x00000006u,0x0000004cu,0x0000004bu,0x00050041u,0x00000041u,0x0000004du,0x0000003cu,0x0000004au,0x0004003du,0x00000006u,0x0000004eu,0x0000004du,0x000500afu,0x00000040u,0x0000004fu,0x0000004cu,0x0000004eu,0x000200f9u,0x00000049u,0x000200f8u,0x00000049u,0x000700f5u,0x00000040u,0x00000050u,0x00000046u,0x00000005u,0x0000004fu,0x00000048u,0x000300f7u,0x00000052u,0x00000000u,0x000400fau,0x00000050u,0x00000051u,0x00000052u,0x000200f8u,0x00000051u,0x000100fdu,0x000200f8u,0x00000052u,0x00060041u,0x00000059u,0x0000005au,0x00000058u,0x0000001bu,0x00000030u,0x0004003du,0x00000009u,0x0000005bu,0x0000005au,0x0003003eu,0x00000055u,0x0000005bu,0x00060041u,0x00000059u,0x0000005du,0x00000058u,0x0000001bu,0x0000004au,0x0004003du,0x00000009u,0x0000005eu,0x0000005du,0x0003003eu,0x0000005cu,0x0000005eu,0x00060041u,0x00000059u,0x00000061u,0x00000058u,0x0000001bu,0x00000060u,0x0004003du,0x00000009u,0x00000062u,0x00000061u,0x0003003eu,0x0000005fu,0x00000062u,0x00060041u,0x00000059u,0x00000065u,0x00000058u,0x0000001bu,0x00000064u,0x0004003du,0x00000009u,0x00000066u,0x00000065u,0x0003003eu,0x00000063u,0x00000066u,0x0004003du,0x00000007u,0x0000006au,0x00000034u,0x0003003eu,0x00000069u,0x0000006au,0x0004003du,0x00000007u,0x0000006cu,0x0000003cu,0x0003003eu,0x0000006bu,0x0000006cu,0x00060039u,0x0000000au,0x0000006du,0x0000000eu,0x00000069u,0x0000006bu,0x0003003eu,0x00000068u,0x0000006du,0x0004003du,0x00000007u,0x0000006fu,0x00000034u,0x00050080u,0x00000007u,0x00000072u,0x0000006fu,0x00000071u,0x0003003eu,0x00000073u,0x00000072u,0x0004003du,0x00000007u,0x00000075u,0x0000003cu,0x0003003eu,0x00000074u,0x00000075u,0x00060039u,0x0000000au,0x00000076u,0x0000000eu,0x00000073u,0x00000074u,0x0003003eu,0x0000006eu,0x00000076u,0x0004003du,0x00000007u,0x00000078u,0x00000034u,0x00050080u,0x00000007u,0x0000007au,0x00000078u,0x00000079u,0x0003003eu,0x0000007bu,0x0000007au,0x0004003du,0x00000007u,0x0000007du,0x0000003cu,0x0003003eu,0x0000007cu,0x0000007du,0x00060039u,0x0000000au,0x0000007eu,0x0000000eu,0x0000007bu,0x0000007cu,0x0003003eu,0x00000077u,0x0000007eu,0x0004003du,0x00000007u,0x00000080u,0x00000034u,0x00050080u,0x00000007u,0x00000082u,0x00000080u,0x00000081u,0x0003003eu,0x00000083u,0x00000082u,0x0004003du,0x00000007u,0x00000085u,0x0000003cu,0x0003003eu,0x00000084u,0x00000085u,0x00060039u,0x0000000au,0x00000086u,0x0000000eu,0x00000083u,0x00000084u,0x0003003eu,0x0000007fu,0x00000086u,0x0004003du,0x00000007u,0x00000088u,0x00000034u,0x00050080u,0x00000007u,0x0000008au,0x00000088u,0x00000089u,0x0003003eu,0x0000008bu,0x0000008au,0x0004003du,0x00000007u,0x0000008du,0x0000003cu,0x0003003eu,0x0000008cu,0x0000008du,0x00060039u,0x0000000au,0x0000008eu,0x0000000eu,0x0000008bu,0x0000008cu,0x0003003eu,0x00000087u,0x0000008eu,0x0004003du,0x00000016u,0x00000090u,0x00000026u,0x00040064u,0x00000015u,0x00000091u,0x00000090u,0x00050067u,0x00000007u,0x00000092u,0x00000091u,0x0000001bu,0x0003003eu,0x0000008fu,0x00000092u,0x0004003du,0x00000007u,0x00000094u,0x00000034u,0x00050080u,0x00000007u,0x00000095u,0x00000094u,0x00000071u,0x0003003eu,0x00000096u,0x00000095u,0x0004003du,0x00000007u,0x00000098u,0x0000008fu,0x0003003eu,0x00000097u,0x00000098u,0x00060039u,0x00000009u,0x00000099u,0x00000013u,0x00000096u,0x00000097u,0x0003003eu,0x00000093u,0x00000099u,0x0004003du,0x00000007u,0x0000009bu,0x00000034u,0x00050080u,0x00000007u,0x0000009cu,0x0000009bu,0x00000079u,0x0003003eu,0x0000009du,0x0000009cu,0x0004003du,0x00000007u,0x0000009fu,0x0000008fu,0x0003003eu,0x0000009eu,0x0000009fu,0x00060039u,0x00000009u,0x000000a0u,0x00000013u,0x0000009du,0x0000009eu,0x0003003eu,0x0000009au,0x000000a0u,0x0004003du,0x00000007u,0x000000a2u,0x00000034u,0x00050080u,0x00000007u,0x000000a3u,0x000000a2u,0x00000081u,0x0003003eu,0x000000a4u,0x000000a3u,0x0004003du,0x00000007u,0x000000a6u,0x0000008fu,0x0003003eu,0x000000a5u,0x000000a6u,0x00060039u,0x00000009u,0x000000a7u,0x00000013u,0x000000a4u,0x000000a5u,0x0003003eu,0x000000a1u,0x000000a7u,0x0004003du,0x00000007u,0x000000a9u,0x00000034u,0x00050080u,0x00000007u,0x000000aau,0x000000a9u,0x00000089u,0x0003003eu,0x000000abu,0x000000aau,0x0004003du,0x00000007u,0x000000adu,0x0000008fu,0x0003003eu,0x000000acu,0x000000adu,0x00060039u,0x00000009u,0x000000aeu,0x00000013u,0x000000abu,0x000000acu,0x0003003eu,0x000000a8u,0x000000aeu,0x0004003du,0x00000009u,0x000000b1u,0x0000009au,0x0004003du,0x00000009u,0x000000b2u,0x00000093u,0x00050083u,0x00000009u,0x000000b3u,0x000000b1u,0x000000b2u,0x0004003du,0x00000009u,0x000000b4u,0x000000a8u,0x0004003du,0x00000009u,0x000000b5u,0x000000a1u,0x00050083u,0x00000009u,0x000000b6u,0x000000b4u,0x000000b5u,0x00050050u,0x000000b7u,0x000000b8u,0x000000b3u,0x000000b6u,0x0006000cu,0x00000009u,0x000000b9u,0x00000001u,0x00000042u,0x000000b8u,0x00050085u,0x00000009u,0x000000bau,0x000000b0u,0x000000b9u,0x0003003eu,0x000000afu,0x000000bau,0x0004003du,0x00000009u,0x000000bcu,0x0000005fu,0x0004007fu,0x00000009u,0x000000bdu,0x000000bcu,0x0004003du,0x00000009u,0x000000beu,0x000000afu,0x00050085u,0x00000009u,0x000000bfu,0x000000bdu,0x000000beu,0x0006000cu,0x00000009u,0x000000c0u,0x00000001u,0x0000001bu,0x000000bfu,0x0008000cu,0x00000009u,0x000000c3u,0x00000001u,0x0000002bu,0x000000c0u,0x000000c1u,0x000000c2u,0x0003003eu,0x000000bbu,0x000000c3u,0x0004003du,0x0000000au,0x000000c5u,0x0000006eu,0x0004003du,0x0000000au,0x000000c6u,0x00000068u,0x00050083u,0x0000000au,0x000000c7u,0x000000c5u,0x000000c6u,0x0003003eu,0x000000c4u,0x000000c7u,0x0004003du,0x0000000au,0x000000c9u,0x00000077u,0x0004003du,0x0000000au,0x000000cau,0x00000068u,0x00050083u,0x0000000au,0x000000cbu,0x000000c9u,0x000000cau,0x0003003eu,0x000000c8u,0x000000cbu,0x0004003du,0x0000000au,0x000000cdu,0x0000007fu,0x0004003du,0x0000000au,0x000000ceu,0x00000068u,0x00050083u,0x0000000au,0x000000cfu,0x000000cdu,0x000000ceu,0x0003003eu,0x000000ccu,0x000000cfu,0x0004003du,0x0000000au,0x000000d1u,0x00000087u,0x0004003du,0x0000000au,0x000000d2u,0x00000068u,0x00050083u,0x0000000au,0x000000d3u,0x000000d1u,0x000000d2u,0x0003003eu,0x000000d0u,0x000000d3u,0x0004003du,0x00000009u,0x000000d5u,0x00000063u,0x0004003du,0x00000009u,0x000000d6u,0x00000063u,0x00050085u,0x00000009u,0x000000d7u,0x000000d5u,0x000000d6u,0x0003003eu,0x000000d4u,0x000000d7u,0x0004003du,0x00000009u,0x000000d9u,0x000000bbu,0x0004003du,0x0000000au,0x000000dau,0x000000c4u,0x0004003du,0x0000000au,0x000000dbu,0x000000c4u,0x00050094u,0x00000009u,0x000000dcu,0x000000dau,0x000000dbu,0x0004003du,0x00000009u,0x000000ddu,0x000000d4u,0x00050081u,0x00000009u,0x000000deu,0x000000dcu,0x000000ddu,0x0006000cu,0x00000009u,0x000000dfu,0x00000001u,0x00000020u,0x000000deu,0x00050085u,0x00000009u,0x000000e0u,0x000000d9u,0x000000dfu,0x0003003eu,0x000000d8u,0x000000e0u,0x0004003du,0x00000009u,0x000000e2u,0x000000bbu,0x0004003du,0x0000000au,0x000000e3u,0x000000c8u,0x0004003du,0x0000000au,0x000000e4u,0x000000c8u,0x00050094u,0x00000009u,0x000000e5u,0x000000e3u,0x000000e4u,0x0004003du,0x00000009u,0x000000e6u,0x000000d4u,0x00050081u,0x00000009u,0x000000e7u,0x000000e5u,0x000000e6u,0x0006000cu,0x00000009u,0x000000e8u,0x00000001u,0x00000020u,0x000000e7u,0x00050085u,0x00000009u,0x000000e9u,0x000000e2u,0x000000e8u,0x0003003eu,0x000000e1u,0x000000e9u,0x0004003du,0x00000009u,0x000000ebu,0x000000bbu,0x0004003du,0x0000000au,0x000000ecu,0x000000ccu,0x0004003du,0x0000000au,0x000000edu,0x000000ccu,0x00050094u,0x00000009u,0x000000eeu,0x000000ecu,0x000000edu,0x0004003du,0x00000009u,0x000000efu,0x000000d4u,0x00050081u,0x00000009u,0x000000f0u,0x000000eeu,0x000000efu,0x0006000cu,0x00000009u,0x000000f1u,0x00000001u,0x00000020u,0x000000f0u,0x00050085u,0x00000009u,0x000000f2u,0x000000ebu,0x000000f1u,0x0003003eu,0x000000eau,0x000000f2u,0x0004003du,0x00000009u,0x000000f4u,0x000000bbu,0x0004003du,0x0000000au,0x000000f5u,0x000000d0u,0x0004003du,0x0000000au,0x000000f6u,0x000000d0u,0x00050094u,0x00000009u,0x000000f7u,0x000000f5u,0x000000f6u,0x0004003du,0x00000009u,0x000000f8u,0x000000d4u,0x00050081u,0x00000009u,0x000000f9u,0x000000f7u,0x000000f8u,0x0006000cu,0x00000009u,0x000000fau,0x00000001u,0x00000020u,0x000000f9u,0x00050085u,0x00000009u,0x000000fbu,0x000000f4u,0x000000fau,0x0003003eu,0x000000f3u,0x000000fbu,0x0004003du,0x00000009u,0x000000fdu,0x000000d8u,0x0004003du,0x00000009u,0x000000feu,0x000000e1u,0x00050081u,0x00000009u,0x000000ffu,0x000000fdu,0x000000feu,0x0004003du,0x00000009u,0x00000100u,0x000000eau,0x00050081u,0x00000009u,0x00000101u,0x000000ffu,0x00000100u,0x0004003du,0x00000009u,0x00000102u,0x000000f3u,0x00050081u,0x00000009u,0x00000103u,0x00000101u,0x00000102u,0x0003003eu,0x000000fcu,0x00000103u,0x0004003du,0x00000009u,0x00000105u,0x000000d8u,0x0004003du,0x0000000au,0x00000106u,0x0000006eu,0x0005008eu,0x0000000au,0x00000107u,0x00000106u,0x00000105u,0x0004003du,0x00000009u,0x00000108u,0x000000e1u,0x0004003du,0x0000000au,0x00000109u,0x00000077u,0x0005008eu,0x0000000au,0x0000010au,0x00000109u,0x00000108u,0x00050081u,0x0000000au,0x0000010bu,0x00000107u,0x0000010au,0x0004003du,0x00000009u,0x0000010cu,0x000000eau,0x0004003du,0x0000000au,0x0000010du,0x0000007fu,0x0005008eu,0x0000000au,0x0000010eu,0x0000010du,0x0000010cu,0x00050081u,0x0000000au,0x0000010fu,0x0000010bu,0x0000010eu,0x0004003du,0x00000009u,0x00000110u,0x000000f3u,0x0004003du,0x0000000au,0x00000111u,0x00000087u,0x0005008eu,0x0000000au,0x00000112u,0x00000111u,0x00000110u,0x00050081u,0x0000000au,0x00000113u,0x0000010fu,0x00000112u,0x0003003eu,0x00000104u,0x00000113u,0x0004003du,0x0000000au,0x00000115u,0x00000068u,0x0004003du,0x00000009u,0x00000116u,0x00000055u,0x0004003du,0x0000000au,0x00000117u,0x00000104u,0x0005008eu,0x0000000au,0x00000118u,0x00000117u,0x00000116u,0x00050081u,0x0000000au,0x00000119u,0x00000115u,0x00000118u,0x0004003du,0x00000009u,0x0000011au,0x00000055u,0x0004003du,0x00000009u,0x0000011bu,0x000000fcu,0x00050085u,0x00000009u,0x0000011cu,0x0000011au,0x0000011bu,0x00050081u,0x00000009u,0x0000011du,0x000000c2u,0x0000011cu,0x00070050u,0x0000000au,0x0000011eu,0x0000011du,0x0000011du,0x0000011du,0x0000011du,0x00050088u,0x0000000au,0x0000011fu,0x00000119u,0x0000011eu,0x0003003eu,0x00000114u,0x0000011fu,0x0004003du,0x00000016u,0x00000122u,0x00000121u,0x0004003du,0x00000007u,0x00000123u,0x00000034u,0x0004003du,0x00000007u,0x00000124u,0x0000003cu,0x00050050u,0x00000007u,0x00000125u,0x0000001eu,0x0000001eu,0x00050082u,0x00000007u,0x00000126u,0x00000124u,0x00000125u,0x0008000cu,0x00000007u,0x00000127u,0x00000001u,0x0000002du,0x00000123u,0x0000001cu,0x00000126u,0x00040064u,0x00000015u,0x00000128u,0x00000122u,0x0007005fu,0x0000000au,0x00000129u,0x00000128u,0x00000127u,0x00000002u,0x0000001bu,0x0003003eu,0x00000120u,0x00000129u,0x0004003du,0x00000009u,0x0000012bu,0x00000055u,0x0004003du,0x00000009u,0x0000012cu,0x0000005cu,0x00050085u,0x00000009u,0x0000012du,0x0000012bu,0x0000012cu,0x0003003eu,0x0000012au,0x0000012du,0x0004003du,0x0000000au,0x0000012fu,0x00000114u,0x0004003du,0x0000000au,0x00000130u,0x00000120u,0x00050083u,0x0000000au,0x00000131u,0x0000012fu,0x00000130u,0x0003003eu,0x0000012eu,0x00000131u,0x0004003du,0x0000000au,0x00000133u,0x00000114u,0x0004003du,0x0000000au,0x00000134u,0x0000012eu,0x0004003du,0x00000009u,0x00000135u,0x0000012au,0x0004007fu,0x00000009u,0x00000136u,0x00000135u,0x00070050u,0x0000000au,0x00000137u,0x00000136u,0x00000136u,0x00000136u,0x00000136u,0x0004003du,0x00000009u,0x00000138u,0x0000012au,0x00070050u,0x0000000au,0x00000139u,0x00000138u,0x00000138u,0x00000138u,0x00000138u,0x0008000cu,0x0000000au,0x0000013au,0x00000001u,0x0000002bu,0x00000134u,0x00000137u,0x00000139u,0x00050083u,0x0000000au,0x0000013bu,0x00000133u,0x0000013au,0x0003003eu,0x00000132u,0x0000013bu,0x0004003du,0x0000013cu,0x0000013fu,0x0000013eu,0x0004003du,0x00000007u,0x00000140u,0x00000034u,0x0004003du,0x0000000au,0x00000141u,0x00000132u,0x00040063u,0x0000013fu,0x00000140u,0x00000141u,0x000100fdu,0x00010038u,0x00050036u,0x0000000au,0x0000000eu,0x00000000u,0x0000000bu,0x00030037u,0x00000008u,0x0000000cu,0x00030037u,0x00000008u,0x0000000du,0x000200f8u,0x0000000fu,0x0004003du,0x00000016u,0x00000019u,0x00000018u,0x0004003du,0x00000007u,0x0000001au,0x0000000cu,0x0004003du,0x00000007u,0x0000001du,0x0000000du,0x00050050u,0x00000007u,0x0000001fu,0x0000001eu,0x0000001eu,0x00050082u,0x00000007u,0x00000020u,0x0000001du,0x0000001fu,0x0008000cu,0x00000007u,0x00000021u,0x00000001u,0x0000002du,0x0000001au,0x0000001cu,0x00000020u,0x00040064u,0x00000015u,0x00000022u,0x00000019u,0x0007005fu,0x0000000au,0x00000023u,0x00000022u,0x00000021u,0x00000002u,0x0000001bu,0x000200feu,0x00000023u,0x00010038u,0x00050036u,0x00000009u,0x00000013u,0x00000000u,0x00000010u,0x00030037u,0x00000008u,0x00000011u,0x00030037u,0x00000008u,0x00000012u,0x000200f8u,0x00000014u,0x0004003du,0x00000016u,0x00000027u,0x00000026u,0x0004003du,0x00000007u,0x00000028u,0x00000011u,0x0004003du,0x00000007u,0x00000029u,0x00000012u,0x00050050u,0x00000007u,0x0000002au,0x0000001eu,0x0000001eu,0x00050082u,0x00000007u,0x0000002bu,0x00000029u,0x0000002au,0x0008000cu,0x00000007u,0x0000002cu,0x00000001u,0x0000002du,0x00000028u,0x0000001cu,0x0000002bu,0x00040064u,0x00000015u,0x0000002du,0x00000027u,0x0007005fu,0x0000000au,0x0000002eu,0x0000002du,0x0000002cu,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x00000031u,0x0000002eu,0x00000000u,0x000200feu,0x00000031u,0x00010038u}; -static const size_t OF3_FLOWREG_LEN = 1936; +static const uint32_t OF3_FLOWREG_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000196u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x00000037u,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00040005u,0x00000018u,0x6f6c4675u,0x006e4977u,0x00040005u,0x00000026u,0x6d754c75u,0x00000061u,0x00080005u,0x00000037u,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000056u,0x00000055u,0x00050006u,0x00000056u,0x00000000u,0x61726170u,0x0000736du,0x00030005u,0x00000058u,0x00000000u,0x00050005u,0x00000118u,0x6f6c4675u,0x73624f77u,0x00000000u,0x00050005u,0x00000131u,0x6f6c4675u,0x74754f77u,0x00000000u,0x00040047u,0x00000018u,0x00000021u,0x00000020u,0x00040047u,0x00000018u,0x00000022u,0x00000000u,0x00040047u,0x00000026u,0x00000021u,0x00000022u,0x00040047u,0x00000026u,0x00000022u,0x00000000u,0x00040047u,0x00000037u,0x0000000bu,0x0000001cu,0x00030047u,0x00000056u,0x00000002u,0x00050048u,0x00000056u,0x00000000u,0x00000023u,0x00000000u,0x00040047u,0x00000058u,0x00000021u,0x00000000u,0x00040047u,0x00000058u,0x00000022u,0x00000000u,0x00040047u,0x00000118u,0x00000021u,0x00000021u,0x00040047u,0x00000118u,0x00000022u,0x00000000u,0x00030047u,0x00000131u,0x00000019u,0x00040047u,0x00000131u,0x00000021u,0x00000030u,0x00040047u,0x00000131u,0x00000022u,0x00000000u,0x00040047u,0x00000136u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00040015u,0x00000006u,0x00000020u,0x00000001u,0x00040017u,0x00000007u,0x00000006u,0x00000002u,0x00030016u,0x00000009u,0x00000020u,0x00040017u,0x0000000au,0x00000009u,0x00000004u,0x00090019u,0x00000015u,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x00000016u,0x00000015u,0x00040020u,0x00000017u,0x00000000u,0x00000016u,0x0004003bu,0x00000017u,0x00000018u,0x00000000u,0x0004002bu,0x00000006u,0x0000001bu,0x00000000u,0x0005002cu,0x00000007u,0x0000001cu,0x0000001bu,0x0000001bu,0x0004002bu,0x00000006u,0x0000001eu,0x00000001u,0x0004003bu,0x00000017u,0x00000026u,0x00000000u,0x00040015u,0x0000002fu,0x00000020u,0x00000000u,0x0004002bu,0x0000002fu,0x00000030u,0x00000000u,0x00040017u,0x00000035u,0x0000002fu,0x00000003u,0x00040020u,0x00000036u,0x00000001u,0x00000035u,0x0004003bu,0x00000036u,0x00000037u,0x00000001u,0x00040017u,0x00000038u,0x0000002fu,0x00000002u,0x00020014u,0x00000040u,0x0004002bu,0x0000002fu,0x0000004au,0x00000001u,0x0003001eu,0x00000056u,0x0000000au,0x00040020u,0x00000057u,0x00000002u,0x00000056u,0x0004003bu,0x00000057u,0x00000058u,0x00000002u,0x00040020u,0x00000059u,0x00000002u,0x00000009u,0x0004002bu,0x0000002fu,0x00000060u,0x00000002u,0x0004002bu,0x0000002fu,0x00000064u,0x00000003u,0x0004002bu,0x00000006u,0x0000006fu,0xffffffffu,0x0005002cu,0x00000007u,0x00000070u,0x0000006fu,0x0000001bu,0x0005002cu,0x00000007u,0x00000078u,0x0000001eu,0x0000001bu,0x0005002cu,0x00000007u,0x00000080u,0x0000001bu,0x0000006fu,0x0005002cu,0x00000007u,0x00000088u,0x0000001bu,0x0000001eu,0x0004002bu,0x00000009u,0x000000abu,0x3f000000u,0x00040017u,0x000000b2u,0x00000009u,0x00000002u,0x0004002bu,0x00000009u,0x000000bcu,0x3d4ccccdu,0x0004002bu,0x00000009u,0x000000bdu,0x3f800000u,0x0004003bu,0x00000017u,0x00000118u,0x00000000u,0x00090019u,0x0000012fu,0x00000009u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000002u,0x00040020u,0x00000130u,0x00000000u,0x0000012fu,0x0004003bu,0x00000130u,0x00000131u,0x00000000u,0x0004002bu,0x0000002fu,0x00000135u,0x00000010u,0x0006002cu,0x00000035u,0x00000136u,0x00000135u,0x00000135u,0x0000004au,0x0005002cu,0x00000007u,0x00000195u,0x0000001eu,0x0000001eu,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x000300f7u,0x00000137u,0x00000000u,0x000300fbu,0x00000030u,0x00000138u,0x000200f8u,0x00000138u,0x0004003du,0x00000035u,0x00000039u,0x00000037u,0x0007004fu,0x00000038u,0x0000003au,0x00000039u,0x00000039u,0x00000000u,0x00000001u,0x0004007cu,0x00000007u,0x0000003bu,0x0000003au,0x0004003du,0x00000016u,0x0000003du,0x00000018u,0x00040064u,0x00000015u,0x0000003eu,0x0000003du,0x00050067u,0x00000007u,0x0000003fu,0x0000003eu,0x0000001bu,0x00050051u,0x00000006u,0x00000043u,0x0000003bu,0x00000000u,0x00050051u,0x00000006u,0x00000045u,0x0000003fu,0x00000000u,0x000500afu,0x00000040u,0x00000046u,0x00000043u,0x00000045u,0x000400a8u,0x00000040u,0x00000047u,0x00000046u,0x000300f7u,0x00000049u,0x00000000u,0x000400fau,0x00000047u,0x00000048u,0x00000049u,0x000200f8u,0x00000048u,0x00050051u,0x00000006u,0x0000004cu,0x0000003bu,0x00000001u,0x00050051u,0x00000006u,0x0000004eu,0x0000003fu,0x00000001u,0x000500afu,0x00000040u,0x0000004fu,0x0000004cu,0x0000004eu,0x000200f9u,0x00000049u,0x000200f8u,0x00000049u,0x000700f5u,0x00000040u,0x00000050u,0x00000046u,0x00000138u,0x0000004fu,0x00000048u,0x000300f7u,0x00000052u,0x00000000u,0x000400fau,0x00000050u,0x00000051u,0x00000052u,0x000200f8u,0x00000051u,0x000200f9u,0x00000137u,0x000200f8u,0x00000052u,0x00060041u,0x00000059u,0x0000005au,0x00000058u,0x0000001bu,0x00000030u,0x0004003du,0x00000009u,0x0000005bu,0x0000005au,0x00060041u,0x00000059u,0x0000005du,0x00000058u,0x0000001bu,0x0000004au,0x0004003du,0x00000009u,0x0000005eu,0x0000005du,0x00060041u,0x00000059u,0x00000061u,0x00000058u,0x0000001bu,0x00000060u,0x0004003du,0x00000009u,0x00000062u,0x00000061u,0x00060041u,0x00000059u,0x00000065u,0x00000058u,0x0000001bu,0x00000064u,0x0004003du,0x00000009u,0x00000066u,0x00000065u,0x0004003du,0x00000016u,0x00000069u,0x00000018u,0x00040064u,0x00000015u,0x0000006bu,0x00000069u,0x0007005fu,0x0000000au,0x0000006cu,0x0000006bu,0x0000003bu,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000071u,0x0000003bu,0x00000070u,0x0004003du,0x00000016u,0x0000013fu,0x00000018u,0x00050082u,0x00000007u,0x00000143u,0x0000003fu,0x00000195u,0x0008000cu,0x00000007u,0x00000144u,0x00000001u,0x0000002du,0x00000071u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x00000145u,0x0000013fu,0x0007005fu,0x0000000au,0x00000146u,0x00000145u,0x00000144u,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000079u,0x0000003bu,0x00000078u,0x0004003du,0x00000016u,0x00000149u,0x00000018u,0x0008000cu,0x00000007u,0x0000014eu,0x00000001u,0x0000002du,0x00000079u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x0000014fu,0x00000149u,0x0007005fu,0x0000000au,0x00000150u,0x0000014fu,0x0000014eu,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000081u,0x0000003bu,0x00000080u,0x0004003du,0x00000016u,0x00000153u,0x00000018u,0x0008000cu,0x00000007u,0x00000158u,0x00000001u,0x0000002du,0x00000081u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x00000159u,0x00000153u,0x0007005fu,0x0000000au,0x0000015au,0x00000159u,0x00000158u,0x00000002u,0x0000001bu,0x00050080u,0x00000007u,0x00000089u,0x0000003bu,0x00000088u,0x0004003du,0x00000016u,0x0000015du,0x00000018u,0x0008000cu,0x00000007u,0x00000162u,0x00000001u,0x0000002du,0x00000089u,0x0000001cu,0x00000143u,0x00040064u,0x00000015u,0x00000163u,0x0000015du,0x0007005fu,0x0000000au,0x00000164u,0x00000163u,0x00000162u,0x00000002u,0x0000001bu,0x0004003du,0x00000016u,0x00000167u,0x00000026u,0x00040064u,0x00000015u,0x0000016du,0x00000167u,0x0007005fu,0x0000000au,0x0000016eu,0x0000016du,0x00000144u,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x0000016fu,0x0000016eu,0x00000000u,0x0004003du,0x00000016u,0x00000172u,0x00000026u,0x00040064u,0x00000015u,0x00000178u,0x00000172u,0x0007005fu,0x0000000au,0x00000179u,0x00000178u,0x0000014eu,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x0000017au,0x00000179u,0x00000000u,0x0004003du,0x00000016u,0x0000017du,0x00000026u,0x00040064u,0x00000015u,0x00000183u,0x0000017du,0x0007005fu,0x0000000au,0x00000184u,0x00000183u,0x00000158u,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x00000185u,0x00000184u,0x00000000u,0x0004003du,0x00000016u,0x00000188u,0x00000026u,0x00040064u,0x00000015u,0x0000018eu,0x00000188u,0x0007005fu,0x0000000au,0x0000018fu,0x0000018eu,0x00000162u,0x00000002u,0x0000001bu,0x00050051u,0x00000009u,0x00000190u,0x0000018fu,0x00000000u,0x00050083u,0x00000009u,0x000000aeu,0x0000017au,0x0000016fu,0x00050083u,0x00000009u,0x000000b1u,0x00000190u,0x00000185u,0x00050050u,0x000000b2u,0x000000b3u,0x000000aeu,0x000000b1u,0x0006000cu,0x00000009u,0x000000b4u,0x00000001u,0x00000042u,0x000000b3u,0x00050085u,0x00000009u,0x000000b5u,0x000000abu,0x000000b4u,0x0004007fu,0x00000009u,0x000000b8u,0x00000062u,0x00050085u,0x00000009u,0x000000bau,0x000000b8u,0x000000b5u,0x0006000cu,0x00000009u,0x000000bbu,0x00000001u,0x0000001bu,0x000000bau,0x0008000cu,0x00000009u,0x000000beu,0x00000001u,0x0000002bu,0x000000bbu,0x000000bcu,0x000000bdu,0x00050083u,0x0000000au,0x000000c2u,0x00000146u,0x0000006cu,0x00050083u,0x0000000au,0x000000c6u,0x00000150u,0x0000006cu,0x00050083u,0x0000000au,0x000000cau,0x0000015au,0x0000006cu,0x00050083u,0x0000000au,0x000000ceu,0x00000164u,0x0000006cu,0x00050085u,0x00000009u,0x000000d2u,0x00000066u,0x00000066u,0x00050094u,0x00000009u,0x000000d6u,0x000000c2u,0x000000c2u,0x00050081u,0x00000009u,0x000000d8u,0x000000d6u,0x000000d2u,0x0006000cu,0x00000009u,0x000000d9u,0x00000001u,0x00000020u,0x000000d8u,0x00050094u,0x00000009u,0x000000ddu,0x000000c6u,0x000000c6u,0x00050081u,0x00000009u,0x000000dfu,0x000000ddu,0x000000d2u,0x0006000cu,0x00000009u,0x000000e0u,0x00000001u,0x00000020u,0x000000dfu,0x00050094u,0x00000009u,0x000000e4u,0x000000cau,0x000000cau,0x00050081u,0x00000009u,0x000000e6u,0x000000e4u,0x000000d2u,0x0006000cu,0x00000009u,0x000000e7u,0x00000001u,0x00000020u,0x000000e6u,0x00050094u,0x00000009u,0x000000ebu,0x000000ceu,0x000000ceu,0x00050081u,0x00000009u,0x000000edu,0x000000ebu,0x000000d2u,0x0006000cu,0x00000009u,0x000000eeu,0x00000001u,0x00000020u,0x000000edu,0x00050081u,0x00000009u,0x000000f3u,0x000000d9u,0x000000e0u,0x00050081u,0x00000009u,0x000000f5u,0x000000f3u,0x000000e7u,0x00050081u,0x00000009u,0x000000f7u,0x000000f5u,0x000000eeu,0x00050085u,0x00000009u,0x000000f8u,0x000000beu,0x000000f7u,0x0005008eu,0x0000000au,0x000000fdu,0x00000146u,0x000000d9u,0x0005008eu,0x0000000au,0x00000100u,0x00000150u,0x000000e0u,0x00050081u,0x0000000au,0x00000101u,0x000000fdu,0x00000100u,0x0005008eu,0x0000000au,0x00000104u,0x0000015au,0x000000e7u,0x00050081u,0x0000000au,0x00000105u,0x00000101u,0x00000104u,0x0005008eu,0x0000000au,0x00000108u,0x00000164u,0x000000eeu,0x00050081u,0x0000000au,0x00000109u,0x00000105u,0x00000108u,0x0005008eu,0x0000000au,0x0000010au,0x00000109u,0x000000beu,0x0005008eu,0x0000000au,0x0000010fu,0x0000010au,0x0000005bu,0x00050081u,0x0000000au,0x00000110u,0x0000006cu,0x0000010fu,0x00050085u,0x00000009u,0x00000113u,0x0000005bu,0x000000f8u,0x00050081u,0x00000009u,0x00000114u,0x000000bdu,0x00000113u,0x00070050u,0x0000000au,0x00000115u,0x00000114u,0x00000114u,0x00000114u,0x00000114u,0x00050088u,0x0000000au,0x00000116u,0x00000110u,0x00000115u,0x0004003du,0x00000016u,0x00000119u,0x00000118u,0x00040064u,0x00000015u,0x0000011bu,0x00000119u,0x0007005fu,0x0000000au,0x0000011cu,0x0000011bu,0x0000003bu,0x00000002u,0x0000001bu,0x00050085u,0x00000009u,0x00000120u,0x0000005bu,0x0000005eu,0x00050083u,0x0000000au,0x00000124u,0x00000116u,0x0000011cu,0x0004007fu,0x00000009u,0x00000129u,0x00000120u,0x00070050u,0x0000000au,0x0000012au,0x00000129u,0x00000129u,0x00000129u,0x00000129u,0x00070050u,0x0000000au,0x0000012cu,0x00000120u,0x00000120u,0x00000120u,0x00000120u,0x0008000cu,0x0000000au,0x0000012du,0x00000001u,0x0000002bu,0x00000124u,0x0000012au,0x0000012cu,0x00050083u,0x0000000au,0x0000012eu,0x00000116u,0x0000012du,0x0004003du,0x0000012fu,0x00000132u,0x00000131u,0x00040063u,0x00000132u,0x0000003bu,0x0000012eu,0x000200f9u,0x00000137u,0x000200f8u,0x00000137u,0x000100fdu,0x00010038u}; +static const size_t OF3_FLOWREG_LEN = 981; static const uint32_t DDFG_SYNTH_SPV[] = {0x07230203u,0x00010300u,0x0008000bu,0x00000208u,0x00000000u,0x00020011u,0x00000001u,0x00020011u,0x00000032u,0x0006000bu,0x00000001u,0x4c534c47u,0x6474732eu,0x3035342eu,0x00000000u,0x0003000eu,0x00000000u,0x00000001u,0x0006000fu,0x00000005u,0x00000004u,0x6e69616du,0x00000000u,0x0000001cu,0x00060010u,0x00000004u,0x00000011u,0x00000010u,0x00000010u,0x00000001u,0x00030003u,0x00000002u,0x000001c2u,0x00040005u,0x00000004u,0x6e69616du,0x00000000u,0x00050005u,0x0000000bu,0x616d756cu,0x33667628u,0x0000003bu,0x00030005u,0x0000000au,0x00000063u,0x00030005u,0x00000018u,0x00646967u,0x00080005u,0x0000001cu,0x475f6c67u,0x61626f6cu,0x766e496cu,0x7461636fu,0x496e6f69u,0x00000044u,0x00030005u,0x00000021u,0x006d6964u,0x00040005u,0x00000024u,0x74754f75u,0x00000000u,0x00040005u,0x0000003eu,0x44766e69u,0x00006d69u,0x00030005u,0x00000044u,0x00007675u,0x00030005u,0x0000004du,0x00000055u,0x00060006u,0x0000004du,0x00000000u,0x776f6c66u,0x6c616353u,0x00000065u,0x00050006u,0x0000004du,0x00000001u,0x68706c61u,0x00000061u,0x00050006u,0x0000004du,0x00000002u,0x61746562u,0x00000000u,0x00050006u,0x0000004du,0x00000003u,0x626d616cu,0x00006164u,0x00050006u,0x0000004du,0x00000004u,0x69737065u,0x006e6f6cu,0x00060006u,0x0000004du,0x00000005u,0x746f6870u,0x6163536fu,0x0000656cu,0x00050006u,0x0000004du,0x00000006u,0x30646170u,0x00000000u,0x00050006u,0x0000004du,0x00000007u,0x31646170u,0x00000000u,0x00050006u,0x0000004du,0x00000008u,0x52647568u,0x00746365u,0x00030005u,0x0000004fu,0x00000000u,0x00040005u,0x0000008cu,0x72754375u,0x00000072u,0x00030005u,0x00000098u,0x00676264u,0x00030005u,0x0000009fu,0x00007366u,0x00040005u,0x000000a9u,0x64774273u,0x00000000u,0x00050005u,0x000000aau,0x6f6c4675u,0x64774277u,0x00000000u,0x00040005u,0x000000aeu,0x64774673u,0x00000000u,0x00050005u,0x000000afu,0x6f6c4675u,0x64774677u,0x00000000u,0x00030005u,0x000000b3u,0x00313046u,0x00030005u,0x000000bau,0x00303146u,0x00040005u,0x000000c1u,0x31306663u,0x00000000u,0x00040005u,0x000000c5u,0x30316663u,0x00000000u,0x00030005u,0x000000c9u,0x0031306du,0x00030005u,0x000000d5u,0x0030316du,0x00030005u,0x000000e0u,0x00004170u,0x00030005u,0x000000e8u,0x00004270u,0x00030005u,0x000000f0u,0x00003043u,0x00040005u,0x000000f1u,0x65725075u,0x00000076u,0x00030005u,0x000000f6u,0x00003143u,0x00030005u,0x000000fbu,0x00004165u,0x00040005u,0x000000fcu,0x61726170u,0x0000006du,0x00040005u,0x0000010cu,0x61726170u,0x0000006du,0x00030005u,0x00000111u,0x00004265u,0x00040005u,0x00000112u,0x61726170u,0x0000006du,0x00040005u,0x00000122u,0x61726170u,0x0000006du,0x00040005u,0x00000127u,0x76556266u,0x00000000u,0x00040005u,0x0000012bu,0x65526266u,0x00646973u,0x00040005u,0x00000138u,0x736e6f63u,0x00747369u,0x00030005u,0x00000149u,0x0000305au,0x00030005u,0x00000157u,0x0000315au,0x00040005u,0x00000163u,0x30756174u,0x00000000u,0x00040005u,0x00000167u,0x31756174u,0x00000000u,0x00040005u,0x0000016au,0x78616d7au,0x00000000u,0x00030005u,0x0000016eu,0x00003057u,0x00030005u,0x00000179u,0x00003157u,0x00040005u,0x00000183u,0x6d757357u,0x00000000u,0x00040005u,0x00000187u,0x70726177u,0x00006465u,0x00050005u,0x000001a0u,0x736f7263u,0x64616673u,0x00000065u,0x00050005u,0x000001adu,0x746f6870u,0x7272456fu,0x00000000u,0x00050005u,0x000001b1u,0x746f6870u,0x7572546fu,0x00007473u,0x00040005u,0x000001b7u,0x73757274u,0x00000074u,0x00040005u,0x000001c3u,0x76657270u,0x00000043u,0x00040005u,0x000001c8u,0x72727563u,0x00000043u,0x00050005u,0x000001cdu,0x746e6f63u,0x44746e65u,0x00666669u,0x00050005u,0x000001d2u,0x72746e75u,0x65747375u,0x00000064u,0x00040005u,0x000001d7u,0x44676962u,0x00666669u,0x00050005u,0x000001dcu,0x70616e73u,0x75436f54u,0x00007272u,0x00040005u,0x000001e5u,0x6374756fu,0x00000000u,0x00030005u,0x000001eeu,0x0067616du,0x00030005u,0x000001f2u,0x0000006eu,0x00030005u,0x000001f6u,0x00746173u,0x00040047u,0x0000001cu,0x0000000bu,0x0000001cu,0x00030047u,0x00000024u,0x00000019u,0x00040047u,0x00000024u,0x00000021u,0x00000030u,0x00040047u,0x00000024u,0x00000022u,0x00000000u,0x00030047u,0x0000004du,0x00000002u,0x00050048u,0x0000004du,0x00000000u,0x00000023u,0x00000000u,0x00050048u,0x0000004du,0x00000001u,0x00000023u,0x00000004u,0x00050048u,0x0000004du,0x00000002u,0x00000023u,0x00000008u,0x00050048u,0x0000004du,0x00000003u,0x00000023u,0x0000000cu,0x00050048u,0x0000004du,0x00000004u,0x00000023u,0x00000010u,0x00050048u,0x0000004du,0x00000005u,0x00000023u,0x00000014u,0x00050048u,0x0000004du,0x00000006u,0x00000023u,0x00000018u,0x00050048u,0x0000004du,0x00000007u,0x00000023u,0x0000001cu,0x00050048u,0x0000004du,0x00000008u,0x00000023u,0x00000020u,0x00040047u,0x0000004fu,0x00000021u,0x00000000u,0x00040047u,0x0000004fu,0x00000022u,0x00000000u,0x00040047u,0x0000008cu,0x00000021u,0x00000021u,0x00040047u,0x0000008cu,0x00000022u,0x00000000u,0x00040047u,0x000000aau,0x00000021u,0x00000023u,0x00040047u,0x000000aau,0x00000022u,0x00000000u,0x00040047u,0x000000afu,0x00000021u,0x00000022u,0x00040047u,0x000000afu,0x00000022u,0x00000000u,0x00040047u,0x000000f1u,0x00000021u,0x00000020u,0x00040047u,0x000000f1u,0x00000022u,0x00000000u,0x00040047u,0x00000207u,0x0000000bu,0x00000019u,0x00020013u,0x00000002u,0x00030021u,0x00000003u,0x00000002u,0x00030016u,0x00000006u,0x00000020u,0x00040017u,0x00000007u,0x00000006u,0x00000003u,0x00040020u,0x00000008u,0x00000007u,0x00000007u,0x00040021u,0x00000009u,0x00000006u,0x00000008u,0x0004002bu,0x00000006u,0x0000000eu,0x3e59b3d0u,0x0004002bu,0x00000006u,0x0000000fu,0x3f371759u,0x0004002bu,0x00000006u,0x00000010u,0x3d93dd98u,0x0006002cu,0x00000007u,0x00000011u,0x0000000eu,0x0000000fu,0x00000010u,0x00040015u,0x00000015u,0x00000020u,0x00000001u,0x00040017u,0x00000016u,0x00000015u,0x00000002u,0x00040020u,0x00000017u,0x00000007u,0x00000016u,0x00040015u,0x00000019u,0x00000020u,0x00000000u,0x00040017u,0x0000001au,0x00000019u,0x00000003u,0x00040020u,0x0000001bu,0x00000001u,0x0000001au,0x0004003bu,0x0000001bu,0x0000001cu,0x00000001u,0x00040017u,0x0000001du,0x00000019u,0x00000002u,0x00090019u,0x00000022u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000002u,0x00000004u,0x00040020u,0x00000023u,0x00000000u,0x00000022u,0x0004003bu,0x00000023u,0x00000024u,0x00000000u,0x00020014u,0x00000027u,0x0004002bu,0x00000019u,0x00000028u,0x00000000u,0x00040020u,0x00000029u,0x00000007u,0x00000015u,0x0004002bu,0x00000019u,0x00000032u,0x00000001u,0x00040017u,0x0000003cu,0x00000006u,0x00000002u,0x00040020u,0x0000003du,0x00000007u,0x0000003cu,0x0004002bu,0x00000006u,0x0000003fu,0x3f800000u,0x0004002bu,0x00000006u,0x00000047u,0x3f000000u,0x00040017u,0x0000004cu,0x00000006u,0x00000004u,0x000b001eu,0x0000004du,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x00000006u,0x0000004cu,0x00040020u,0x0000004eu,0x00000002u,0x0000004du,0x0004003bu,0x0000004eu,0x0000004fu,0x00000002u,0x0004002bu,0x00000015u,0x00000050u,0x00000008u,0x00040020u,0x00000051u,0x00000002u,0x00000006u,0x0004002bu,0x00000019u,0x00000054u,0x00000002u,0x0004002bu,0x00000019u,0x0000005cu,0x00000003u,0x00090019u,0x00000089u,0x00000006u,0x00000001u,0x00000000u,0x00000000u,0x00000000u,0x00000001u,0x00000000u,0x0003001bu,0x0000008au,0x00000089u,0x00040020u,0x0000008bu,0x00000000u,0x0000008au,0x0004003bu,0x0000008bu,0x0000008cu,0x00000000u,0x0004002bu,0x00000006u,0x0000008fu,0x00000000u,0x00040020u,0x00000097u,0x00000007u,0x00000027u,0x0004002bu,0x00000015u,0x00000099u,0x00000000u,0x0004002bu,0x00000006u,0x0000009cu,0x40600000u,0x00040020u,0x0000009eu,0x00000007u,0x00000006u,0x00040020u,0x000000a8u,0x00000007u,0x0000004cu,0x0004003bu,0x0000008bu,0x000000aau,0x00000000u,0x0004003bu,0x0000008bu,0x000000afu,0x00000000u,0x0004002bu,0x00000006u,0x000000cdu,0x3dcccccdu,0x0004002bu,0x00000015u,0x000000e2u,0x00000001u,0x0004003bu,0x0000008bu,0x000000f1u,0x00000000u,0x0004002bu,0x00000015u,0x0000014au,0x00000005u,0x0004002bu,0x00000015u,0x0000014fu,0x00000003u,0x0004002bu,0x00000015u,0x00000170u,0x00000002u,0x0004002bu,0x00000006u,0x00000189u,0x322bcc77u,0x0004002bu,0x00000006u,0x000001b2u,0x3d23d70au,0x0004002bu,0x00000006u,0x000001b3u,0x3e3851ecu,0x0004002bu,0x00000015u,0x000001bcu,0x00000004u,0x0004002bu,0x00000006u,0x000001d3u,0x3e800000u,0x0004002bu,0x00000006u,0x000001d8u,0x3e4ccccdu,0x0004002bu,0x00000006u,0x000001d9u,0x3ecccccdu,0x0004002bu,0x00000019u,0x00000206u,0x00000010u,0x0006002cu,0x0000001au,0x00000207u,0x00000206u,0x00000206u,0x00000032u,0x00050036u,0x00000002u,0x00000004u,0x00000000u,0x00000003u,0x000200f8u,0x00000005u,0x0004003bu,0x00000017u,0x00000018u,0x00000007u,0x0004003bu,0x00000017u,0x00000021u,0x00000007u,0x0004003bu,0x0000003du,0x0000003eu,0x00000007u,0x0004003bu,0x0000003du,0x00000044u,0x00000007u,0x0004003bu,0x00000097u,0x00000098u,0x00000007u,0x0004003bu,0x0000009eu,0x0000009fu,0x00000007u,0x0004003bu,0x0000009eu,0x000000a1u,0x00000007u,0x0004003bu,0x000000a8u,0x000000a9u,0x00000007u,0x0004003bu,0x000000a8u,0x000000aeu,0x00000007u,0x0004003bu,0x0000003du,0x000000b3u,0x00000007u,0x0004003bu,0x0000003du,0x000000bau,0x00000007u,0x0004003bu,0x0000009eu,0x000000c1u,0x00000007u,0x0004003bu,0x0000009eu,0x000000c5u,0x00000007u,0x0004003bu,0x0000009eu,0x000000c9u,0x00000007u,0x0004003bu,0x0000009eu,0x000000d5u,0x00000007u,0x0004003bu,0x0000003du,0x000000e0u,0x00000007u,0x0004003bu,0x0000003du,0x000000e8u,0x00000007u,0x0004003bu,0x00000008u,0x000000f0u,0x00000007u,0x0004003bu,0x00000008u,0x000000f6u,0x00000007u,0x0004003bu,0x0000009eu,0x000000fbu,0x00000007u,0x0004003bu,0x00000008u,0x000000fcu,0x00000007u,0x0004003bu,0x00000008u,0x0000010cu,0x00000007u,0x0004003bu,0x0000009eu,0x00000111u,0x00000007u,0x0004003bu,0x00000008u,0x00000112u,0x00000007u,0x0004003bu,0x00000008u,0x00000122u,0x00000007u,0x0004003bu,0x0000003du,0x00000127u,0x00000007u,0x0004003bu,0x0000009eu,0x0000012bu,0x00000007u,0x0004003bu,0x0000009eu,0x00000138u,0x00000007u,0x0004003bu,0x0000009eu,0x00000149u,0x00000007u,0x0004003bu,0x0000009eu,0x00000157u,0x00000007u,0x0004003bu,0x0000009eu,0x00000163u,0x00000007u,0x0004003bu,0x0000009eu,0x00000167u,0x00000007u,0x0004003bu,0x0000009eu,0x0000016au,0x00000007u,0x0004003bu,0x0000009eu,0x0000016eu,0x00000007u,0x0004003bu,0x0000009eu,0x00000179u,0x00000007u,0x0004003bu,0x0000009eu,0x00000183u,0x00000007u,0x0004003bu,0x00000008u,0x00000187u,0x00000007u,0x0004003bu,0x00000008u,0x0000018bu,0x00000007u,0x0004003bu,0x00000008u,0x000001a0u,0x00000007u,0x0004003bu,0x0000009eu,0x000001adu,0x00000007u,0x0004003bu,0x0000009eu,0x000001b1u,0x00000007u,0x0004003bu,0x0000009eu,0x000001b7u,0x00000007u,0x0004003bu,0x00000008u,0x000001c3u,0x00000007u,0x0004003bu,0x00000008u,0x000001c8u,0x00000007u,0x0004003bu,0x0000009eu,0x000001cdu,0x00000007u,0x0004003bu,0x0000009eu,0x000001d2u,0x00000007u,0x0004003bu,0x0000009eu,0x000001d7u,0x00000007u,0x0004003bu,0x0000009eu,0x000001dcu,0x00000007u,0x0004003bu,0x00000008u,0x000001e5u,0x00000007u,0x0004003bu,0x0000009eu,0x000001eeu,0x00000007u,0x0004003bu,0x0000009eu,0x000001f2u,0x00000007u,0x0004003bu,0x0000009eu,0x000001f6u,0x00000007u,0x0004003du,0x0000001au,0x0000001eu,0x0000001cu,0x0007004fu,0x0000001du,0x0000001fu,0x0000001eu,0x0000001eu,0x00000000u,0x00000001u,0x0004007cu,0x00000016u,0x00000020u,0x0000001fu,0x0003003eu,0x00000018u,0x00000020u,0x0004003du,0x00000022u,0x00000025u,0x00000024u,0x00040068u,0x00000016u,0x00000026u,0x00000025u,0x0003003eu,0x00000021u,0x00000026u,0x00050041u,0x00000029u,0x0000002au,0x00000018u,0x00000028u,0x0004003du,0x00000015u,0x0000002bu,0x0000002au,0x00050041u,0x00000029u,0x0000002cu,0x00000021u,0x00000028u,0x0004003du,0x00000015u,0x0000002du,0x0000002cu,0x000500afu,0x00000027u,0x0000002eu,0x0000002bu,0x0000002du,0x000400a8u,0x00000027u,0x0000002fu,0x0000002eu,0x000300f7u,0x00000031u,0x00000000u,0x000400fau,0x0000002fu,0x00000030u,0x00000031u,0x000200f8u,0x00000030u,0x00050041u,0x00000029u,0x00000033u,0x00000018u,0x00000032u,0x0004003du,0x00000015u,0x00000034u,0x00000033u,0x00050041u,0x00000029u,0x00000035u,0x00000021u,0x00000032u,0x0004003du,0x00000015u,0x00000036u,0x00000035u,0x000500afu,0x00000027u,0x00000037u,0x00000034u,0x00000036u,0x000200f9u,0x00000031u,0x000200f8u,0x00000031u,0x000700f5u,0x00000027u,0x00000038u,0x0000002eu,0x00000005u,0x00000037u,0x00000030u,0x000300f7u,0x0000003au,0x00000000u,0x000400fau,0x00000038u,0x00000039u,0x0000003au,0x000200f8u,0x00000039u,0x000100fdu,0x000200f8u,0x0000003au,0x0004003du,0x00000016u,0x00000040u,0x00000021u,0x0004006fu,0x0000003cu,0x00000041u,0x00000040u,0x00050050u,0x0000003cu,0x00000042u,0x0000003fu,0x0000003fu,0x00050088u,0x0000003cu,0x00000043u,0x00000042u,0x00000041u,0x0003003eu,0x0000003eu,0x00000043u,0x0004003du,0x00000016u,0x00000045u,0x00000018u,0x0004006fu,0x0000003cu,0x00000046u,0x00000045u,0x00050050u,0x0000003cu,0x00000048u,0x00000047u,0x00000047u,0x00050081u,0x0000003cu,0x00000049u,0x00000046u,0x00000048u,0x0004003du,0x0000003cu,0x0000004au,0x0000003eu,0x00050085u,0x0000003cu,0x0000004bu,0x00000049u,0x0000004au,0x0003003eu,0x00000044u,0x0000004bu,0x00060041u,0x00000051u,0x00000052u,0x0000004fu,0x00000050u,0x00000028u,0x0004003du,0x00000006u,0x00000053u,0x00000052u,0x00060041u,0x00000051u,0x00000055u,0x0000004fu,0x00000050u,0x00000054u,0x0004003du,0x00000006u,0x00000056u,0x00000055u,0x000500b8u,0x00000027u,0x00000057u,0x00000053u,0x00000056u,0x000300f7u,0x00000059u,0x00000000u,0x000400fau,0x00000057u,0x00000058u,0x00000059u,0x000200f8u,0x00000058u,0x00060041u,0x00000051u,0x0000005au,0x0000004fu,0x00000050u,0x00000032u,0x0004003du,0x00000006u,0x0000005bu,0x0000005au,0x00060041u,0x00000051u,0x0000005du,0x0000004fu,0x00000050u,0x0000005cu,0x0004003du,0x00000006u,0x0000005eu,0x0000005du,0x000500b8u,0x00000027u,0x0000005fu,0x0000005bu,0x0000005eu,0x000200f9u,0x00000059u,0x000200f8u,0x00000059u,0x000700f5u,0x00000027u,0x00000060u,0x00000057u,0x0000003au,0x0000005fu,0x00000058u,0x000300f7u,0x00000062u,0x00000000u,0x000400fau,0x00000060u,0x00000061u,0x00000062u,0x000200f8u,0x00000061u,0x00050041u,0x00000029u,0x00000063u,0x00000018u,0x00000028u,0x0004003du,0x00000015u,0x00000064u,0x00000063u,0x0004006fu,0x00000006u,0x00000065u,0x00000064u,0x00060041u,0x00000051u,0x00000066u,0x0000004fu,0x00000050u,0x00000028u,0x0004003du,0x00000006u,0x00000067u,0x00000066u,0x000500beu,0x00000027u,0x00000068u,0x00000065u,0x00000067u,0x000200f9u,0x00000062u,0x000200f8u,0x00000062u,0x000700f5u,0x00000027u,0x00000069u,0x00000060u,0x00000059u,0x00000068u,0x00000061u,0x000300f7u,0x0000006bu,0x00000000u,0x000400fau,0x00000069u,0x0000006au,0x0000006bu,0x000200f8u,0x0000006au,0x00050041u,0x00000029u,0x0000006cu,0x00000018u,0x00000028u,0x0004003du,0x00000015u,0x0000006du,0x0000006cu,0x0004006fu,0x00000006u,0x0000006eu,0x0000006du,0x00060041u,0x00000051u,0x0000006fu,0x0000004fu,0x00000050u,0x00000054u,0x0004003du,0x00000006u,0x00000070u,0x0000006fu,0x000500b8u,0x00000027u,0x00000071u,0x0000006eu,0x00000070u,0x000200f9u,0x0000006bu,0x000200f8u,0x0000006bu,0x000700f5u,0x00000027u,0x00000072u,0x00000069u,0x00000062u,0x00000071u,0x0000006au,0x000300f7u,0x00000074u,0x00000000u,0x000400fau,0x00000072u,0x00000073u,0x00000074u,0x000200f8u,0x00000073u,0x00050041u,0x00000029u,0x00000075u,0x00000018u,0x00000032u,0x0004003du,0x00000015u,0x00000076u,0x00000075u,0x0004006fu,0x00000006u,0x00000077u,0x00000076u,0x00060041u,0x00000051u,0x00000078u,0x0000004fu,0x00000050u,0x00000032u,0x0004003du,0x00000006u,0x00000079u,0x00000078u,0x000500beu,0x00000027u,0x0000007au,0x00000077u,0x00000079u,0x000200f9u,0x00000074u,0x000200f8u,0x00000074u,0x000700f5u,0x00000027u,0x0000007bu,0x00000072u,0x0000006bu,0x0000007au,0x00000073u,0x000300f7u,0x0000007du,0x00000000u,0x000400fau,0x0000007bu,0x0000007cu,0x0000007du,0x000200f8u,0x0000007cu,0x00050041u,0x00000029u,0x0000007eu,0x00000018u,0x00000032u,0x0004003du,0x00000015u,0x0000007fu,0x0000007eu,0x0004006fu,0x00000006u,0x00000080u,0x0000007fu,0x00060041u,0x00000051u,0x00000081u,0x0000004fu,0x00000050u,0x0000005cu,0x0004003du,0x00000006u,0x00000082u,0x00000081u,0x000500b8u,0x00000027u,0x00000083u,0x00000080u,0x00000082u,0x000200f9u,0x0000007du,0x000200f8u,0x0000007du,0x000700f5u,0x00000027u,0x00000084u,0x0000007bu,0x00000074u,0x00000083u,0x0000007cu,0x000300f7u,0x00000086u,0x00000000u,0x000400fau,0x00000084u,0x00000085u,0x00000086u,0x000200f8u,0x00000085u,0x0004003du,0x00000022u,0x00000087u,0x00000024u,0x0004003du,0x00000016u,0x00000088u,0x00000018u,0x0004003du,0x0000008au,0x0000008du,0x0000008cu,0x0004003du,0x0000003cu,0x0000008eu,0x00000044u,0x00070058u,0x0000004cu,0x00000090u,0x0000008du,0x0000008eu,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x00000091u,0x00000090u,0x00000090u,0x00000000u,0x00000001u,0x00000002u,0x00050051u,0x00000006u,0x00000092u,0x00000091u,0x00000000u,0x00050051u,0x00000006u,0x00000093u,0x00000091u,0x00000001u,0x00050051u,0x00000006u,0x00000094u,0x00000091u,0x00000002u,0x00070050u,0x0000004cu,0x00000095u,0x00000092u,0x00000093u,0x00000094u,0x0000003fu,0x00040063u,0x00000087u,0x00000088u,0x00000095u,0x000100fdu,0x000200f8u,0x00000086u,0x00050041u,0x00000051u,0x0000009au,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x0000009bu,0x0000009au,0x000500bau,0x00000027u,0x0000009du,0x0000009bu,0x0000009cu,0x0003003eu,0x00000098u,0x0000009du,0x0004003du,0x00000027u,0x000000a0u,0x00000098u,0x000300f7u,0x000000a3u,0x00000000u,0x000400fau,0x000000a0u,0x000000a2u,0x000000a4u,0x000200f8u,0x000000a2u,0x0003003eu,0x000000a1u,0x0000003fu,0x000200f9u,0x000000a3u,0x000200f8u,0x000000a4u,0x00050041u,0x00000051u,0x000000a5u,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x000000a6u,0x000000a5u,0x0003003eu,0x000000a1u,0x000000a6u,0x000200f9u,0x000000a3u,0x000200f8u,0x000000a3u,0x0004003du,0x00000006u,0x000000a7u,0x000000a1u,0x0003003eu,0x0000009fu,0x000000a7u,0x0004003du,0x0000008au,0x000000abu,0x000000aau,0x0004003du,0x0000003cu,0x000000acu,0x00000044u,0x00070058u,0x0000004cu,0x000000adu,0x000000abu,0x000000acu,0x00000002u,0x0000008fu,0x0003003eu,0x000000a9u,0x000000adu,0x0004003du,0x0000008au,0x000000b0u,0x000000afu,0x0004003du,0x0000003cu,0x000000b1u,0x00000044u,0x00070058u,0x0000004cu,0x000000b2u,0x000000b0u,0x000000b1u,0x00000002u,0x0000008fu,0x0003003eu,0x000000aeu,0x000000b2u,0x0004003du,0x0000004cu,0x000000b4u,0x000000a9u,0x0007004fu,0x0000003cu,0x000000b5u,0x000000b4u,0x000000b4u,0x00000000u,0x00000001u,0x0004003du,0x00000006u,0x000000b6u,0x0000009fu,0x0005008eu,0x0000003cu,0x000000b7u,0x000000b5u,0x000000b6u,0x0004003du,0x0000003cu,0x000000b8u,0x0000003eu,0x00050085u,0x0000003cu,0x000000b9u,0x000000b7u,0x000000b8u,0x0003003eu,0x000000b3u,0x000000b9u,0x0004003du,0x0000004cu,0x000000bbu,0x000000aeu,0x0007004fu,0x0000003cu,0x000000bcu,0x000000bbu,0x000000bbu,0x00000000u,0x00000001u,0x0004003du,0x00000006u,0x000000bdu,0x0000009fu,0x0005008eu,0x0000003cu,0x000000beu,0x000000bcu,0x000000bdu,0x0004003du,0x0000003cu,0x000000bfu,0x0000003eu,0x00050085u,0x0000003cu,0x000000c0u,0x000000beu,0x000000bfu,0x0003003eu,0x000000bau,0x000000c0u,0x00050041u,0x0000009eu,0x000000c2u,0x000000a9u,0x0000005cu,0x0004003du,0x00000006u,0x000000c3u,0x000000c2u,0x0008000cu,0x00000006u,0x000000c4u,0x00000001u,0x0000002bu,0x000000c3u,0x0000008fu,0x0000003fu,0x0003003eu,0x000000c1u,0x000000c4u,0x00050041u,0x0000009eu,0x000000c6u,0x000000aeu,0x0000005cu,0x0004003du,0x00000006u,0x000000c7u,0x000000c6u,0x0008000cu,0x00000006u,0x000000c8u,0x00000001u,0x0000002bu,0x000000c7u,0x0000008fu,0x0000003fu,0x0003003eu,0x000000c5u,0x000000c8u,0x0004003du,0x0000003cu,0x000000cau,0x000000b3u,0x0006000cu,0x00000006u,0x000000cbu,0x00000001u,0x00000042u,0x000000cau,0x0003003eu,0x000000c9u,0x000000cbu,0x0004003du,0x00000006u,0x000000ccu,0x000000c9u,0x000500bau,0x00000027u,0x000000ceu,0x000000ccu,0x000000cdu,0x000300f7u,0x000000d0u,0x00000000u,0x000400fau,0x000000ceu,0x000000cfu,0x000000d0u,0x000200f8u,0x000000cfu,0x0004003du,0x00000006u,0x000000d1u,0x000000c9u,0x00050088u,0x00000006u,0x000000d2u,0x000000cdu,0x000000d1u,0x0004003du,0x0000003cu,0x000000d3u,0x000000b3u,0x0005008eu,0x0000003cu,0x000000d4u,0x000000d3u,0x000000d2u,0x0003003eu,0x000000b3u,0x000000d4u,0x000200f9u,0x000000d0u,0x000200f8u,0x000000d0u,0x0004003du,0x0000003cu,0x000000d6u,0x000000bau,0x0006000cu,0x00000006u,0x000000d7u,0x00000001u,0x00000042u,0x000000d6u,0x0003003eu,0x000000d5u,0x000000d7u,0x0004003du,0x00000006u,0x000000d8u,0x000000d5u,0x000500bau,0x00000027u,0x000000d9u,0x000000d8u,0x000000cdu,0x000300f7u,0x000000dbu,0x00000000u,0x000400fau,0x000000d9u,0x000000dau,0x000000dbu,0x000200f8u,0x000000dau,0x0004003du,0x00000006u,0x000000dcu,0x000000d5u,0x00050088u,0x00000006u,0x000000ddu,0x000000cdu,0x000000dcu,0x0004003du,0x0000003cu,0x000000deu,0x000000bau,0x0005008eu,0x0000003cu,0x000000dfu,0x000000deu,0x000000ddu,0x0003003eu,0x000000bau,0x000000dfu,0x000200f9u,0x000000dbu,0x000200f8u,0x000000dbu,0x0004003du,0x0000003cu,0x000000e1u,0x00000044u,0x00050041u,0x00000051u,0x000000e3u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x000000e4u,0x000000e3u,0x0004003du,0x0000003cu,0x000000e5u,0x000000b3u,0x0005008eu,0x0000003cu,0x000000e6u,0x000000e5u,0x000000e4u,0x00050083u,0x0000003cu,0x000000e7u,0x000000e1u,0x000000e6u,0x0003003eu,0x000000e0u,0x000000e7u,0x0004003du,0x0000003cu,0x000000e9u,0x00000044u,0x00050041u,0x00000051u,0x000000eau,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x000000ebu,0x000000eau,0x00050083u,0x00000006u,0x000000ecu,0x0000003fu,0x000000ebu,0x0004003du,0x0000003cu,0x000000edu,0x000000bau,0x0005008eu,0x0000003cu,0x000000eeu,0x000000edu,0x000000ecu,0x00050083u,0x0000003cu,0x000000efu,0x000000e9u,0x000000eeu,0x0003003eu,0x000000e8u,0x000000efu,0x0004003du,0x0000008au,0x000000f2u,0x000000f1u,0x0004003du,0x0000003cu,0x000000f3u,0x000000e0u,0x00070058u,0x0000004cu,0x000000f4u,0x000000f2u,0x000000f3u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000000f5u,0x000000f4u,0x000000f4u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000000f0u,0x000000f5u,0x0004003du,0x0000008au,0x000000f7u,0x0000008cu,0x0004003du,0x0000003cu,0x000000f8u,0x000000e8u,0x00070058u,0x0000004cu,0x000000f9u,0x000000f7u,0x000000f8u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000000fau,0x000000f9u,0x000000f9u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000000f6u,0x000000fau,0x0004003du,0x00000007u,0x000000fdu,0x000000f0u,0x0003003eu,0x000000fcu,0x000000fdu,0x00050039u,0x00000006u,0x000000feu,0x0000000bu,0x000000fcu,0x0004003du,0x0000008au,0x000000ffu,0x0000008cu,0x0004003du,0x0000003cu,0x00000100u,0x000000e0u,0x0004003du,0x0000008au,0x00000101u,0x000000aau,0x0004003du,0x0000003cu,0x00000102u,0x000000e0u,0x00070058u,0x0000004cu,0x00000103u,0x00000101u,0x00000102u,0x00000002u,0x0000008fu,0x0007004fu,0x0000003cu,0x00000104u,0x00000103u,0x00000103u,0x00000000u,0x00000001u,0x00050041u,0x00000051u,0x00000105u,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x00000106u,0x00000105u,0x0005008eu,0x0000003cu,0x00000107u,0x00000104u,0x00000106u,0x0004003du,0x0000003cu,0x00000108u,0x0000003eu,0x00050085u,0x0000003cu,0x00000109u,0x00000107u,0x00000108u,0x00050081u,0x0000003cu,0x0000010au,0x00000100u,0x00000109u,0x00070058u,0x0000004cu,0x0000010bu,0x000000ffu,0x0000010au,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x0000010du,0x0000010bu,0x0000010bu,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x0000010cu,0x0000010du,0x00050039u,0x00000006u,0x0000010eu,0x0000000bu,0x0000010cu,0x00050083u,0x00000006u,0x0000010fu,0x000000feu,0x0000010eu,0x0006000cu,0x00000006u,0x00000110u,0x00000001u,0x00000004u,0x0000010fu,0x0003003eu,0x000000fbu,0x00000110u,0x0004003du,0x00000007u,0x00000113u,0x000000f6u,0x0003003eu,0x00000112u,0x00000113u,0x00050039u,0x00000006u,0x00000114u,0x0000000bu,0x00000112u,0x0004003du,0x0000008au,0x00000115u,0x000000f1u,0x0004003du,0x0000003cu,0x00000116u,0x000000e8u,0x0004003du,0x0000008au,0x00000117u,0x000000afu,0x0004003du,0x0000003cu,0x00000118u,0x000000e8u,0x00070058u,0x0000004cu,0x00000119u,0x00000117u,0x00000118u,0x00000002u,0x0000008fu,0x0007004fu,0x0000003cu,0x0000011au,0x00000119u,0x00000119u,0x00000000u,0x00000001u,0x00050041u,0x00000051u,0x0000011bu,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x0000011cu,0x0000011bu,0x0005008eu,0x0000003cu,0x0000011du,0x0000011au,0x0000011cu,0x0004003du,0x0000003cu,0x0000011eu,0x0000003eu,0x00050085u,0x0000003cu,0x0000011fu,0x0000011du,0x0000011eu,0x00050081u,0x0000003cu,0x00000120u,0x00000116u,0x0000011fu,0x00070058u,0x0000004cu,0x00000121u,0x00000115u,0x00000120u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x00000123u,0x00000121u,0x00000121u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x00000122u,0x00000123u,0x00050039u,0x00000006u,0x00000124u,0x0000000bu,0x00000122u,0x00050083u,0x00000006u,0x00000125u,0x00000114u,0x00000124u,0x0006000cu,0x00000006u,0x00000126u,0x00000001u,0x00000004u,0x00000125u,0x0003003eu,0x00000111u,0x00000126u,0x0004003du,0x0000003cu,0x00000128u,0x00000044u,0x0004003du,0x0000003cu,0x00000129u,0x000000b3u,0x00050081u,0x0000003cu,0x0000012au,0x00000128u,0x00000129u,0x0003003eu,0x00000127u,0x0000012au,0x0004003du,0x0000003cu,0x0000012cu,0x000000b3u,0x0004003du,0x0000008au,0x0000012du,0x000000afu,0x0004003du,0x0000003cu,0x0000012eu,0x00000127u,0x00070058u,0x0000004cu,0x0000012fu,0x0000012du,0x0000012eu,0x00000002u,0x0000008fu,0x0007004fu,0x0000003cu,0x00000130u,0x0000012fu,0x0000012fu,0x00000000u,0x00000001u,0x00050041u,0x00000051u,0x00000131u,0x0000004fu,0x00000099u,0x0004003du,0x00000006u,0x00000132u,0x00000131u,0x0005008eu,0x0000003cu,0x00000133u,0x00000130u,0x00000132u,0x0004003du,0x0000003cu,0x00000134u,0x0000003eu,0x00050085u,0x0000003cu,0x00000135u,0x00000133u,0x00000134u,0x00050081u,0x0000003cu,0x00000136u,0x0000012cu,0x00000135u,0x0006000cu,0x00000006u,0x00000137u,0x00000001u,0x00000042u,0x00000136u,0x0003003eu,0x0000012bu,0x00000137u,0x0004003du,0x00000006u,0x00000139u,0x000000c1u,0x0004003du,0x00000006u,0x0000013au,0x000000c5u,0x0007000cu,0x00000006u,0x0000013bu,0x00000001u,0x00000025u,0x00000139u,0x0000013au,0x0004003du,0x00000006u,0x0000013cu,0x0000012bu,0x0004007fu,0x00000006u,0x0000013du,0x0000013cu,0x0004003du,0x0000003cu,0x0000013eu,0x000000b3u,0x0006000cu,0x00000006u,0x0000013fu,0x00000001u,0x00000042u,0x0000013eu,0x0004003du,0x0000003cu,0x00000140u,0x000000bau,0x0006000cu,0x00000006u,0x00000141u,0x00000001u,0x00000042u,0x00000140u,0x00050081u,0x00000006u,0x00000142u,0x0000013fu,0x00000141u,0x00050041u,0x0000009eu,0x00000143u,0x0000003eu,0x00000028u,0x0004003du,0x00000006u,0x00000144u,0x00000143u,0x00050081u,0x00000006u,0x00000145u,0x00000142u,0x00000144u,0x00050088u,0x00000006u,0x00000146u,0x0000013du,0x00000145u,0x0006000cu,0x00000006u,0x00000147u,0x00000001u,0x0000001bu,0x00000146u,0x00050085u,0x00000006u,0x00000148u,0x0000013bu,0x00000147u,0x0003003eu,0x00000138u,0x00000148u,0x00050041u,0x00000051u,0x0000014bu,0x0000004fu,0x0000014au,0x0004003du,0x00000006u,0x0000014cu,0x0000014bu,0x0004003du,0x00000006u,0x0000014du,0x000000fbu,0x00050085u,0x00000006u,0x0000014eu,0x0000014cu,0x0000014du,0x00050041u,0x00000051u,0x00000150u,0x0000004fu,0x0000014fu,0x0004003du,0x00000006u,0x00000151u,0x00000150u,0x0004003du,0x00000006u,0x00000152u,0x00000138u,0x00050083u,0x00000006u,0x00000153u,0x0000003fu,0x00000152u,0x00050085u,0x00000006u,0x00000154u,0x00000151u,0x00000153u,0x00050081u,0x00000006u,0x00000155u,0x0000014eu,0x00000154u,0x0004007fu,0x00000006u,0x00000156u,0x00000155u,0x0003003eu,0x00000149u,0x00000156u,0x00050041u,0x00000051u,0x00000158u,0x0000004fu,0x0000014au,0x0004003du,0x00000006u,0x00000159u,0x00000158u,0x0004003du,0x00000006u,0x0000015au,0x00000111u,0x00050085u,0x00000006u,0x0000015bu,0x00000159u,0x0000015au,0x00050041u,0x00000051u,0x0000015cu,0x0000004fu,0x0000014fu,0x0004003du,0x00000006u,0x0000015du,0x0000015cu,0x0004003du,0x00000006u,0x0000015eu,0x00000138u,0x00050083u,0x00000006u,0x0000015fu,0x0000003fu,0x0000015eu,0x00050085u,0x00000006u,0x00000160u,0x0000015du,0x0000015fu,0x00050081u,0x00000006u,0x00000161u,0x0000015bu,0x00000160u,0x0004007fu,0x00000006u,0x00000162u,0x00000161u,0x0003003eu,0x00000157u,0x00000162u,0x00050041u,0x00000051u,0x00000164u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x00000165u,0x00000164u,0x00050083u,0x00000006u,0x00000166u,0x0000003fu,0x00000165u,0x0003003eu,0x00000163u,0x00000166u,0x00050041u,0x00000051u,0x00000168u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x00000169u,0x00000168u,0x0003003eu,0x00000167u,0x00000169u,0x0004003du,0x00000006u,0x0000016bu,0x00000149u,0x0004003du,0x00000006u,0x0000016cu,0x00000157u,0x0007000cu,0x00000006u,0x0000016du,0x00000001u,0x00000028u,0x0000016bu,0x0000016cu,0x0003003eu,0x0000016au,0x0000016du,0x0004003du,0x00000006u,0x0000016fu,0x00000163u,0x00050041u,0x00000051u,0x00000171u,0x0000004fu,0x00000170u,0x0004003du,0x00000006u,0x00000172u,0x00000171u,0x0004003du,0x00000006u,0x00000173u,0x00000149u,0x0004003du,0x00000006u,0x00000174u,0x0000016au,0x00050083u,0x00000006u,0x00000175u,0x00000173u,0x00000174u,0x00050085u,0x00000006u,0x00000176u,0x00000172u,0x00000175u,0x0006000cu,0x00000006u,0x00000177u,0x00000001u,0x0000001bu,0x00000176u,0x00050085u,0x00000006u,0x00000178u,0x0000016fu,0x00000177u,0x0003003eu,0x0000016eu,0x00000178u,0x0004003du,0x00000006u,0x0000017au,0x00000167u,0x00050041u,0x00000051u,0x0000017bu,0x0000004fu,0x00000170u,0x0004003du,0x00000006u,0x0000017cu,0x0000017bu,0x0004003du,0x00000006u,0x0000017du,0x00000157u,0x0004003du,0x00000006u,0x0000017eu,0x0000016au,0x00050083u,0x00000006u,0x0000017fu,0x0000017du,0x0000017eu,0x00050085u,0x00000006u,0x00000180u,0x0000017cu,0x0000017fu,0x0006000cu,0x00000006u,0x00000181u,0x00000001u,0x0000001bu,0x00000180u,0x00050085u,0x00000006u,0x00000182u,0x0000017au,0x00000181u,0x0003003eu,0x00000179u,0x00000182u,0x0004003du,0x00000006u,0x00000184u,0x0000016eu,0x0004003du,0x00000006u,0x00000185u,0x00000179u,0x00050081u,0x00000006u,0x00000186u,0x00000184u,0x00000185u,0x0003003eu,0x00000183u,0x00000186u,0x0004003du,0x00000006u,0x00000188u,0x00000183u,0x000500bau,0x00000027u,0x0000018au,0x00000188u,0x00000189u,0x000300f7u,0x0000018du,0x00000000u,0x000400fau,0x0000018au,0x0000018cu,0x00000198u,0x000200f8u,0x0000018cu,0x0004003du,0x00000006u,0x0000018eu,0x0000016eu,0x0004003du,0x00000007u,0x0000018fu,0x000000f0u,0x0005008eu,0x00000007u,0x00000190u,0x0000018fu,0x0000018eu,0x0004003du,0x00000006u,0x00000191u,0x00000179u,0x0004003du,0x00000007u,0x00000192u,0x000000f6u,0x0005008eu,0x00000007u,0x00000193u,0x00000192u,0x00000191u,0x00050081u,0x00000007u,0x00000194u,0x00000190u,0x00000193u,0x0004003du,0x00000006u,0x00000195u,0x00000183u,0x00060050u,0x00000007u,0x00000196u,0x00000195u,0x00000195u,0x00000195u,0x00050088u,0x00000007u,0x00000197u,0x00000194u,0x00000196u,0x0003003eu,0x0000018bu,0x00000197u,0x000200f9u,0x0000018du,0x000200f8u,0x00000198u,0x0004003du,0x00000007u,0x00000199u,0x000000f0u,0x0004003du,0x00000007u,0x0000019au,0x000000f6u,0x00050041u,0x00000051u,0x0000019bu,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x0000019cu,0x0000019bu,0x00060050u,0x00000007u,0x0000019du,0x0000019cu,0x0000019cu,0x0000019cu,0x0008000cu,0x00000007u,0x0000019eu,0x00000001u,0x0000002eu,0x00000199u,0x0000019au,0x0000019du,0x0003003eu,0x0000018bu,0x0000019eu,0x000200f9u,0x0000018du,0x000200f8u,0x0000018du,0x0004003du,0x00000007u,0x0000019fu,0x0000018bu,0x0003003eu,0x00000187u,0x0000019fu,0x0004003du,0x0000008au,0x000001a1u,0x000000f1u,0x0004003du,0x0000003cu,0x000001a2u,0x00000044u,0x00070058u,0x0000004cu,0x000001a3u,0x000001a1u,0x000001a2u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001a4u,0x000001a3u,0x000001a3u,0x00000000u,0x00000001u,0x00000002u,0x0004003du,0x0000008au,0x000001a5u,0x0000008cu,0x0004003du,0x0000003cu,0x000001a6u,0x00000044u,0x00070058u,0x0000004cu,0x000001a7u,0x000001a5u,0x000001a6u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001a8u,0x000001a7u,0x000001a7u,0x00000000u,0x00000001u,0x00000002u,0x00050041u,0x00000051u,0x000001a9u,0x0000004fu,0x000000e2u,0x0004003du,0x00000006u,0x000001aau,0x000001a9u,0x00060050u,0x00000007u,0x000001abu,0x000001aau,0x000001aau,0x000001aau,0x0008000cu,0x00000007u,0x000001acu,0x00000001u,0x0000002eu,0x000001a4u,0x000001a8u,0x000001abu,0x0003003eu,0x000001a0u,0x000001acu,0x0004003du,0x00000006u,0x000001aeu,0x000000fbu,0x0004003du,0x00000006u,0x000001afu,0x00000111u,0x0007000cu,0x00000006u,0x000001b0u,0x00000001u,0x00000025u,0x000001aeu,0x000001afu,0x0003003eu,0x000001adu,0x000001b0u,0x0004003du,0x00000006u,0x000001b4u,0x000001adu,0x0008000cu,0x00000006u,0x000001b5u,0x00000001u,0x00000031u,0x000001b2u,0x000001b3u,0x000001b4u,0x00050083u,0x00000006u,0x000001b6u,0x0000003fu,0x000001b5u,0x0003003eu,0x000001b1u,0x000001b6u,0x0004003du,0x00000006u,0x000001b8u,0x00000138u,0x0008000cu,0x00000006u,0x000001b9u,0x00000001u,0x0000002bu,0x000001b8u,0x0000008fu,0x0000003fu,0x0004003du,0x00000006u,0x000001bau,0x000001b1u,0x00050085u,0x00000006u,0x000001bbu,0x000001b9u,0x000001bau,0x0003003eu,0x000001b7u,0x000001bbu,0x00050041u,0x00000051u,0x000001bdu,0x0000004fu,0x000001bcu,0x0004003du,0x00000006u,0x000001beu,0x000001bdu,0x0004003du,0x00000006u,0x000001bfu,0x00000183u,0x0008000cu,0x00000006u,0x000001c0u,0x00000001u,0x00000031u,0x0000008fu,0x000001beu,0x000001bfu,0x0004003du,0x00000006u,0x000001c1u,0x000001b7u,0x00050085u,0x00000006u,0x000001c2u,0x000001c1u,0x000001c0u,0x0003003eu,0x000001b7u,0x000001c2u,0x0004003du,0x0000008au,0x000001c4u,0x000000f1u,0x0004003du,0x0000003cu,0x000001c5u,0x00000044u,0x00070058u,0x0000004cu,0x000001c6u,0x000001c4u,0x000001c5u,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001c7u,0x000001c6u,0x000001c6u,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000001c3u,0x000001c7u,0x0004003du,0x0000008au,0x000001c9u,0x0000008cu,0x0004003du,0x0000003cu,0x000001cau,0x00000044u,0x00070058u,0x0000004cu,0x000001cbu,0x000001c9u,0x000001cau,0x00000002u,0x0000008fu,0x0008004fu,0x00000007u,0x000001ccu,0x000001cbu,0x000001cbu,0x00000000u,0x00000001u,0x00000002u,0x0003003eu,0x000001c8u,0x000001ccu,0x0004003du,0x00000007u,0x000001ceu,0x000001c8u,0x0004003du,0x00000007u,0x000001cfu,0x000001c3u,0x00050083u,0x00000007u,0x000001d0u,0x000001ceu,0x000001cfu,0x0006000cu,0x00000006u,0x000001d1u,0x00000001u,0x00000042u,0x000001d0u,0x0003003eu,0x000001cdu,0x000001d1u,0x0004003du,0x00000006u,0x000001d4u,0x000001b7u,0x0008000cu,0x00000006u,0x000001d5u,0x00000001u,0x00000031u,0x000000cdu,0x000001d3u,0x000001d4u,0x00050083u,0x00000006u,0x000001d6u,0x0000003fu,0x000001d5u,0x0003003eu,0x000001d2u,0x000001d6u,0x0004003du,0x00000006u,0x000001dau,0x000001cdu,0x0008000cu,0x00000006u,0x000001dbu,0x00000001u,0x00000031u,0x000001d8u,0x000001d9u,0x000001dau,0x0003003eu,0x000001d7u,0x000001dbu,0x0004003du,0x00000006u,0x000001ddu,0x000001d2u,0x0004003du,0x00000006u,0x000001deu,0x000001d7u,0x00050085u,0x00000006u,0x000001dfu,0x000001ddu,0x000001deu,0x0003003eu,0x000001dcu,0x000001dfu,0x0004003du,0x00000007u,0x000001e0u,0x000001a0u,0x0004003du,0x00000007u,0x000001e1u,0x000001c8u,0x0004003du,0x00000006u,0x000001e2u,0x000001dcu,0x00060050u,0x00000007u,0x000001e3u,0x000001e2u,0x000001e2u,0x000001e2u,0x0008000cu,0x00000007u,0x000001e4u,0x00000001u,0x0000002eu,0x000001e0u,0x000001e1u,0x000001e3u,0x0003003eu,0x000001a0u,0x000001e4u,0x0004003du,0x00000007u,0x000001e6u,0x000001a0u,0x0004003du,0x00000007u,0x000001e7u,0x00000187u,0x0004003du,0x00000006u,0x000001e8u,0x000001b7u,0x00060050u,0x00000007u,0x000001e9u,0x000001e8u,0x000001e8u,0x000001e8u,0x0008000cu,0x00000007u,0x000001eau,0x00000001u,0x0000002eu,0x000001e6u,0x000001e7u,0x000001e9u,0x0003003eu,0x000001e5u,0x000001eau,0x0004003du,0x00000027u,0x000001ebu,0x00000098u,0x000300f7u,0x000001edu,0x00000000u,0x000400fau,0x000001ebu,0x000001ecu,0x000001edu,0x000200f8u,0x000001ecu,0x0004003du,0x00000006u,0x000001efu,0x000000c9u,0x0004003du,0x00000006u,0x000001f0u,0x000000d5u,0x0007000cu,0x00000006u,0x000001f1u,0x00000001u,0x00000028u,0x000001efu,0x000001f0u,0x0003003eu,0x000001eeu,0x000001f1u,0x0004003du,0x00000006u,0x000001f3u,0x000001eeu,0x00050088u,0x00000006u,0x000001f4u,0x000001f3u,0x000000cdu,0x0008000cu,0x00000006u,0x000001f5u,0x00000001u,0x0000002bu,0x000001f4u,0x0000008fu,0x0000003fu,0x0003003eu,0x000001f2u,0x000001f5u,0x0004003du,0x00000006u,0x000001f7u,0x000001eeu,0x0007000cu,0x00000006u,0x000001f8u,0x00000001u,0x00000030u,0x000000cdu,0x000001f7u,0x0003003eu,0x000001f6u,0x000001f8u,0x0004003du,0x00000022u,0x000001f9u,0x00000024u,0x0004003du,0x00000016u,0x000001fau,0x00000018u,0x0004003du,0x00000006u,0x000001fbu,0x000001f6u,0x0004003du,0x00000006u,0x000001fcu,0x000001f2u,0x00070050u,0x0000004cu,0x000001fdu,0x000001fbu,0x000001fcu,0x0000008fu,0x0000003fu,0x00040063u,0x000001f9u,0x000001fau,0x000001fdu,0x000100fdu,0x000200f8u,0x000001edu,0x0004003du,0x00000022u,0x000001ffu,0x00000024u,0x0004003du,0x00000016u,0x00000200u,0x00000018u,0x0004003du,0x00000007u,0x00000201u,0x000001e5u,0x00050051u,0x00000006u,0x00000202u,0x00000201u,0x00000000u,0x00050051u,0x00000006u,0x00000203u,0x00000201u,0x00000001u,0x00050051u,0x00000006u,0x00000204u,0x00000201u,0x00000002u,0x00070050u,0x0000004cu,0x00000205u,0x00000202u,0x00000203u,0x00000204u,0x0000003fu,0x00040063u,0x000001ffu,0x00000200u,0x00000205u,0x000100fdu,0x00010038u,0x00050036u,0x00000006u,0x0000000bu,0x00000000u,0x00000009u,0x00030037u,0x00000008u,0x0000000au,0x000200f8u,0x0000000cu,0x0004003du,0x00000007u,0x0000000du,0x0000000au,0x00050094u,0x00000006u,0x00000012u,0x0000000du,0x00000011u,0x000200feu,0x00000012u,0x00010038u}; static const size_t DDFG_SYNTH_LEN = 3082; struct Blob { const uint32_t* code; size_t words; }; diff --git a/app/src/main/cpp/framegen/ddfg/framegen.cpp b/app/src/main/cpp/framegen/ddfg/framegen.cpp index 5200f6b094..20cc5e2d4a 100644 --- a/app/src/main/cpp/framegen/ddfg/framegen.cpp +++ b/app/src/main/cpp/framegen/ddfg/framegen.cpp @@ -3,9 +3,35 @@ #include "log.hpp" #include #include +#include namespace ddfg { +struct ScratchState { + VkDevice ownerDevice = VK_NULL_HANDLE; + VkBuffer synthUbo[ddfg::FrameGen::kSynthSlots]{}; + VkDeviceMemory synthUboMem[ddfg::FrameGen::kSynthSlots]{}; + void* synthUboPtr[ddfg::FrameGen::kSynthSlots]{}; + std::vector flowUbo; std::vector flowUboMem; std::vector flowUboPtr; + VkBuffer expandUbo = VK_NULL_HANDLE; VkDeviceMemory expandUboMem = VK_NULL_HANDLE; void* expandUboPtr = nullptr; + VkBuffer flowRegUbo = VK_NULL_HANDLE; VkDeviceMemory flowRegUboMem = VK_NULL_HANDLE; void* flowRegUboPtr = nullptr; + VkBuffer gmUbo[ddfg::FrameGen::kGmSlots]{}; + VkDeviceMemory gmUboMem[ddfg::FrameGen::kGmSlots]{}; + void* gmUboPtr[ddfg::FrameGen::kGmSlots]{}; + VkDescriptorSet sLumaCurr = VK_NULL_HANDLE, sLumaPrev = VK_NULL_HANDLE; + std::vector sDownA, sDownB, sFlow; + VkDescriptorSet sExpand[ddfg::FrameGen::kGmSlots]{}; + VkDescriptorSet sFlowReg0 = VK_NULL_HANDLE, sFlowRegAB = VK_NULL_HANDLE, sFlowRegBA = VK_NULL_HANDLE; + VkDescriptorSet sSynth[ddfg::FrameGen::kSynthSlots]{}; + VkDescriptorSet sGmReduce[ddfg::FrameGen::kGmSlots]{}; + std::vector sGmPrewarp[ddfg::FrameGen::kGmSlots]; + VkExtent2D builtFor{0,0}; + uint64_t builtGeneration = 0; + bool built = false; + bool flowInited = false; + bool flowReady = false; +}; + #define VKOK(x) do { if ((x) != VK_SUCCESS) { DDFG_LOGE("vk fail: %s", #x); return false; } } while (0) uint32_t FrameGen::findMemType(uint32_t bits, VkMemoryPropertyFlags props) const { @@ -107,6 +133,10 @@ static bool buildSetLayout(const DeviceDispatch* dd, VkDevice dev, bool FrameGen::init(const DeviceDispatch* dd, const InstanceDispatch* id, VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue) { + if (device_ || completionUnknown_ || deviceLost_) { + DDFG_LOGE("framegen: refusing to initialize an instance that still owns device resources"); + return false; + } dd_ = dd; id_ = id; phys_ = phys; device_ = dev; queueFamily_ = queueFamily; queue_ = queue; id_->GetPhysicalDeviceMemoryProperties(phys_, &memProps_); @@ -165,16 +195,37 @@ static VkExtent2D levelExtent(VkExtent2D e, int l) { } bool FrameGen::onResize(VkExtent2D extent, VkFormat , bool force) { - - + if (completionUnknown_ || deviceLost_) return false; + if (!device_) { + DDFG_LOGE("framegen: cannot resize before device initialization"); + return false; + } if (!force && ready_ && extent.width == extent_.width && extent.height == extent_.height) return true; + if (ready_ && !waitIdle("resize")) return false; + if (scratch_ && scratch_->ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) { + DDFG_LOGE("framegen resize: scratch cleanup failed; retaining the previous image set"); + return false; + } + + ready_ = false; + ++imageGeneration_; for (auto& i : pyrA_) destroyImage(i); pyrA_.clear(); for (auto& i : pyrB_) destroyImage(i); pyrB_.clear(); for (auto& i : pyrAs_) destroyImage(i); pyrAs_.clear(); for (auto& i : flowLvl_) destroyImage(i); flowLvl_.clear(); destroyImage(flowExpA_); destroyImage(flowExpB_); destroyImage(flowRegA_); destroyImage(flowRegB_); - extent_ = extent; ready_ = false; + extent_ = extent; + + for (int i = 0; i < 6; ++i) gmRun_[i] = 0.0; + for (int s = 0; s < kGmSlots; ++s) { + gmSlotValid_[s] = false; + for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0; + } + gmHaveEst_ = false; + gmEngaged_ = false; + gmStableCount_ = 0; + gmLastTransPx_ = 0.0f; const VkImageUsageFlags lumaUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; const VkImageUsageFlags flowUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; @@ -211,10 +262,51 @@ void FrameGen::barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkI VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); } +void FrameGen::initializeImage(VkCommandBuffer cmd, VkImage img, VkImageLayout to) { + VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + b.newLayout = to; + b.srcAccessMask = 0; + b.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + b.image = img; + b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); +} -void FrameGen::destroy() { - if (!device_) return; - dd_->DeviceWaitIdle(device_); + +bool FrameGen::destroy() { + if (!device_) return true; + if (!deviceLost_) { + // A previous wait failure leaves completion unknown, but a later + // teardown attempt may safely retry the wait before releasing resources. + if (!dd_ || !dd_->DeviceWaitIdle) { + ready_ = false; + completionUnknown_ = true; + DDFG_LOGE("framegen destroy: vkDeviceWaitIdle is unavailable; preserving GPU resources"); + return false; + } + const VkResult idleResult = dd_->DeviceWaitIdle(device_); + if (idleResult == VK_SUCCESS) completionUnknown_ = false; + if (idleResult != VK_SUCCESS) { + ready_ = false; + if (idleResult == VK_ERROR_DEVICE_LOST) { + deviceLost_ = true; + DDFG_LOGE("framegen destroy: device lost; releasing owned resources without waiting"); + } else { + completionUnknown_ = true; + DDFG_LOGE("framegen destroy: DeviceWaitIdle failed (%d); preserving resources because GPU completion is unknown", + (int)idleResult); + return false; + } + } + } + + ready_ = false; + if (descPool_) dd_->DestroyDescriptorPool(device_, descPool_, nullptr); + descPool_ = VK_NULL_HANDLE; + releaseScratch(); for (auto& i : pyrA_) destroyImage(i); pyrA_.clear(); for (auto& i : pyrB_) destroyImage(i); pyrB_.clear(); for (auto& i : pyrAs_) destroyImage(i); pyrAs_.clear(); @@ -226,15 +318,45 @@ void FrameGen::destroy() { destroyPipe(pGmReduce_); destroyPipe(pGmPrewarp_); destroyPipe(pFlowReg_); for (int s = 0; s < kGmSlots; ++s) { - if (gmSsboMem_[s]) dd_->UnmapMemory(device_, gmSsboMem_[s]); + if (gmSsboPtr_[s] && gmSsboMem_[s]) dd_->UnmapMemory(device_, gmSsboMem_[s]); if (gmSsbo_[s]) dd_->DestroyBuffer(device_, gmSsbo_[s], nullptr); if (gmSsboMem_[s]) dd_->FreeMemory(device_, gmSsboMem_[s], nullptr); gmSsbo_[s] = VK_NULL_HANDLE; gmSsboMem_[s] = VK_NULL_HANDLE; gmSsboPtr_[s] = nullptr; } gmBuffersReady_ = false; - if (descPool_) dd_->DestroyDescriptorPool(device_, descPool_, nullptr); if (linear_) dd_->DestroySampler(device_, linear_, nullptr); - descPool_ = VK_NULL_HANDLE; linear_ = VK_NULL_HANDLE; device_ = VK_NULL_HANDLE; ready_ = false; + linear_ = VK_NULL_HANDLE; + device_ = VK_NULL_HANDLE; + ready_ = false; + deviceLost_ = false; + return true; +} + +void FrameGen::abandon() { + device_ = VK_NULL_HANDLE; + dd_ = nullptr; + id_ = nullptr; + phys_ = VK_NULL_HANDLE; + queue_ = VK_NULL_HANDLE; + linear_ = VK_NULL_HANDLE; + descPool_ = VK_NULL_HANDLE; + scratch_.reset(); + pyrA_.clear(); pyrB_.clear(); pyrAs_.clear(); flowLvl_.clear(); + flowExpA_ = Img{}; flowExpB_ = Img{}; + flowRegA_ = Img{}; flowRegB_ = Img{}; + pLuma_ = Pipe{}; pDown_ = Pipe{}; pFlow_ = Pipe{}; pFlowM4_ = Pipe{}; + pExpand_ = Pipe{}; pExpandM4_ = Pipe{}; pSynth_ = Pipe{}; + pGmReduce_ = Pipe{}; pGmPrewarp_ = Pipe{}; pFlowReg_ = Pipe{}; + for (int s = 0; s < kGmSlots; ++s) { + gmSsbo_[s] = VK_NULL_HANDLE; + gmSsboMem_[s] = VK_NULL_HANDLE; + gmSsboPtr_[s] = nullptr; + gmSlotValid_[s] = false; + } + gmBuffersReady_ = false; + ready_ = false; + completionUnknown_ = false; + deviceLost_ = false; } } diff --git a/app/src/main/cpp/framegen/ddfg/framegen.hpp b/app/src/main/cpp/framegen/ddfg/framegen.hpp index 70719e7963..bba77480c7 100644 --- a/app/src/main/cpp/framegen/ddfg/framegen.hpp +++ b/app/src/main/cpp/framegen/ddfg/framegen.hpp @@ -1,12 +1,20 @@ #pragma once #include "vk_dispatch.hpp" #include "config.hpp" +#include #include namespace ddfg { +struct ScratchState; + class FrameGen { public: + FrameGen(); + ~FrameGen(); + FrameGen(const FrameGen&) = delete; + FrameGen& operator=(const FrameGen&) = delete; + bool init(const DeviceDispatch* dd, const InstanceDispatch* id, VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue); void configure(const Config& c); @@ -14,7 +22,8 @@ public: void record(VkCommandBuffer cmd, VkImageView prevView, VkImageView currView, VkImageView outView, float alpha, uint32_t gmSlot = 0, uint32_t synthSlot = 0, bool reuseFlow = false); - void destroy(); + bool destroy(); + void abandon(); bool valid() const { return device_ != VK_NULL_HANDLE && ready_; } const Config& config() const { return cfg_; } @@ -63,6 +72,10 @@ private: const std::vector& bindings); void destroyPipe(Pipe& p); void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to); + void initializeImage(VkCommandBuffer cmd, VkImage img, VkImageLayout to); + bool waitIdle(const char* operation); + bool destroyScratchResources(bool resetPool = true); + void releaseScratch(); const DeviceDispatch* dd_ = nullptr; const InstanceDispatch* id_ = nullptr; @@ -76,8 +89,12 @@ private: Config cfg_; VkExtent2D extent_{}; + uint64_t imageGeneration_ = 0; bool ready_ = false; + bool completionUnknown_ = false; + bool deviceLost_ = false; int flowFinest_ = kFlowFinestDefault; + std::unique_ptr scratch_; Pipe pLuma_, pDown_, pFlow_, pFlowM4_, pExpand_, pExpandM4_, pSynth_; Pipe pGmReduce_, pGmPrewarp_; diff --git a/app/src/main/cpp/framegen/ddfg/record_impl.inc b/app/src/main/cpp/framegen/ddfg/record_impl.inc index f366d9a9c4..3922db391b 100644 --- a/app/src/main/cpp/framegen/ddfg/record_impl.inc +++ b/app/src/main/cpp/framegen/ddfg/record_impl.inc @@ -1,31 +1,7 @@ -namespace { -struct ScratchState { - VkBuffer synthUbo[ddfg::FrameGen::kSynthSlots]{}; - VkDeviceMemory synthUboMem[ddfg::FrameGen::kSynthSlots]{}; - void* synthUboPtr[ddfg::FrameGen::kSynthSlots]{}; - std::vector flowUbo; std::vector flowUboMem; std::vector flowUboPtr; - VkBuffer expandUbo = VK_NULL_HANDLE; VkDeviceMemory expandUboMem = VK_NULL_HANDLE; void* expandUboPtr = nullptr; - VkBuffer flowRegUbo = VK_NULL_HANDLE; VkDeviceMemory flowRegUboMem = VK_NULL_HANDLE; void* flowRegUboPtr = nullptr; - VkBuffer gmUbo[ddfg::FrameGen::kGmSlots]{}; - VkDeviceMemory gmUboMem[ddfg::FrameGen::kGmSlots]{}; - void* gmUboPtr[ddfg::FrameGen::kGmSlots]{}; - VkDescriptorSet sLumaCurr = VK_NULL_HANDLE, sLumaPrev = VK_NULL_HANDLE; - std::vector sDownA, sDownB, sFlow; - VkDescriptorSet sExpand[ddfg::FrameGen::kGmSlots]{}; - - - - VkDescriptorSet sFlowReg0 = VK_NULL_HANDLE, sFlowRegAB = VK_NULL_HANDLE, sFlowRegBA = VK_NULL_HANDLE; - VkDescriptorSet sSynth[ddfg::FrameGen::kSynthSlots]{}; - VkDescriptorSet sGmReduce[ddfg::FrameGen::kGmSlots]{}; - std::vector sGmPrewarp[ddfg::FrameGen::kGmSlots]; - VkExtent2D builtFor{0,0}; - bool built = false; - bool flowInited = false; - bool flowReady = false; -}; -ScratchState g_scratch; +namespace ddfg { +FrameGen::FrameGen() : scratch_(std::make_unique()) {} +FrameGen::~FrameGen() { (void)destroy(); } } static bool makeUbo(const ddfg::DeviceDispatch* dd, VkDevice dev, @@ -58,6 +34,26 @@ static void wImg(const ddfg::DeviceDispatch* dd, VkDevice dev, VkDescriptorSet s w.dstSet = set; w.dstBinding = binding; w.descriptorCount = 1; w.descriptorType = type; w.pImageInfo = ⅈ dd->UpdateDescriptorSets(dev, 1, &w, 0, nullptr); } +static void wImgBatch(const ddfg::DeviceDispatch* dd, VkDevice dev, + const VkDescriptorSet* sets, const uint32_t* bindings, + const VkDescriptorType* types, const VkImageView* views, + const VkSampler* samplers, const VkImageLayout* layouts, + uint32_t count) { + VkDescriptorImageInfo infos[3]{}; + VkWriteDescriptorSet writes[3]{}; + for (uint32_t i = 0; i < count; ++i) { + infos[i].imageView = views[i]; + infos[i].sampler = samplers[i]; + infos[i].imageLayout = layouts[i]; + writes[i] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; + writes[i].dstSet = sets[i]; + writes[i].dstBinding = bindings[i]; + writes[i].descriptorCount = 1; + writes[i].descriptorType = types[i]; + writes[i].pImageInfo = &infos[i]; + } + dd->UpdateDescriptorSets(dev, count, writes, 0, nullptr); +} static void wUbo(const ddfg::DeviceDispatch* dd, VkDevice dev, VkDescriptorSet set, uint32_t binding, VkBuffer buf, VkDeviceSize range) { VkDescriptorBufferInfo bi{}; bi.buffer = buf; bi.range = range; @@ -122,7 +118,7 @@ static void mulAff(const double A[3][3], const double B[3][3], double out[3][3]) namespace ddfg { -static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, +static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const VkPhysicalDeviceMemoryProperties& mp, VkDescriptorPool pool, VkSampler samp, VkExtent2D ext, std::vector& pyrA, std::vector& pyrB, @@ -133,58 +129,123 @@ static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const FrameGen::Pipe& pSynth, const FrameGen::Pipe& pGmReduce, const FrameGen::Pipe& pGmPrewarp, const FrameGen::Pipe& pFlowReg, FrameGen::Img& flowRegA, FrameGen::Img& flowRegB, VkBuffer* gmSsbo, - int kLevels, const Config& cfg); + int kLevels, const Config& cfg, uint64_t imageGeneration); -static void destroyScratch(const DeviceDispatch* dd, VkDevice dev, VkDescriptorPool pool) { +bool FrameGen::waitIdle(const char* operation) { + if (completionUnknown_ || deviceLost_ || !device_) return false; + if (!dd_ || !dd_->DeviceWaitIdle) { + completionUnknown_ = true; + ready_ = false; + DDFG_LOGE("framegen: %s cannot confirm GPU completion; this instance is stopped and its resources are retained", + operation); + return false; + } + const VkResult result = dd_->DeviceWaitIdle(device_); + if (result == VK_SUCCESS) return true; + ready_ = false; + if (result == VK_ERROR_DEVICE_LOST) { + deviceLost_ = true; + DDFG_LOGE("framegen: %s reported device loss; cleanup will skip further waits", operation); + } else { + completionUnknown_ = true; + DDFG_LOGE("framegen: %s vkDeviceWaitIdle failed (%d); this instance is stopped and its GPU resources retained", + operation, (int)result); + } + return false; +} + +bool FrameGen::destroyScratchResources(bool resetPool) { + if (!scratch_) return true; + if (resetPool && descPool_ && !deviceLost_) { + if (!dd_ || !dd_->ResetDescriptorPool) { + ready_ = false; + DDFG_LOGE("framegen: descriptor-pool reset is unavailable; retaining scratch resources"); + return false; + } + const VkResult result = dd_->ResetDescriptorPool(device_, descPool_, 0); + if (result != VK_SUCCESS) { + ready_ = false; + if (result == VK_ERROR_DEVICE_LOST) deviceLost_ = true; + DDFG_LOGE("framegen: descriptor-pool reset failed (%d); retaining scratch resources", + (int)result); + return false; + } + } + releaseScratch(); + return true; +} + +void FrameGen::releaseScratch() { + if (!scratch_) return; + auto& S = *scratch_; auto freeUbo = [&](VkBuffer& b, VkDeviceMemory& m, void*& p) { - if (m) dd->UnmapMemory(dev, m); - if (b) dd->DestroyBuffer(dev, b, nullptr); - if (m) dd->FreeMemory(dev, m, nullptr); - b = VK_NULL_HANDLE; m = VK_NULL_HANDLE; p = nullptr; + if (p && m) dd_->UnmapMemory(device_, m); + if (b) dd_->DestroyBuffer(device_, b, nullptr); + if (m) dd_->FreeMemory(device_, m, nullptr); + b = VK_NULL_HANDLE; + m = VK_NULL_HANDLE; + p = nullptr; }; - auto& S = g_scratch; for (int s = 0; s < FrameGen::kSynthSlots; ++s) freeUbo(S.synthUbo[s], S.synthUboMem[s], S.synthUboPtr[s]); - freeUbo(S.expandUbo, S.expandUboMem, S.expandUboPtr); + freeUbo(S.expandUbo, S.expandUboMem, S.expandUboPtr); freeUbo(S.flowRegUbo, S.flowRegUboMem, S.flowRegUboPtr); for (size_t i = 0; i < S.flowUbo.size(); ++i) freeUbo(S.flowUbo[i], S.flowUboMem[i], S.flowUboPtr[i]); for (int s = 0; s < FrameGen::kGmSlots; ++s) freeUbo(S.gmUbo[s], S.gmUboMem[s], S.gmUboPtr[s]); - if (pool && dd->ResetDescriptorPool) dd->ResetDescriptorPool(dev, pool, 0); S = ScratchState{}; } + void FrameGen::configure(const Config& c) { - cfg_ = c; cfg_.sanitize(); - int want = flowFinestForPreset(cfg_.perfPreset); + if (completionUnknown_ || deviceLost_) return; + Config nextCfg = c; + nextCfg.sanitize(); + int want = flowFinestForPreset(nextCfg.perfPreset); const int maxFinest = kLevels - 2; if (want > maxFinest) { DDFG_LOGE("perf-preset=%d wants kFlowFinest=%d but only %d pyramid levels exist " - "(need >=2 solved) - clamping to %d", cfg_.perfPreset, want, kLevels, maxFinest); + "(need >=2 solved) - clamping to %d", nextCfg.perfPreset, want, kLevels, maxFinest); want = maxFinest; } if (want < 1) want = 1; const int prevFinest = flowFinest_; - flowFinest_ = want; - const bool live = (flowFinest_ != prevFinest) && ready_; + const bool live = (want != prevFinest) && ready_; DDFG_LOGI("perf-preset=%d -> kFlowFinest=%d (was %d) live-rebuild=%d ready=%d", - cfg_.perfPreset, flowFinest_, prevFinest, live ? 1 : 0, ready_ ? 1 : 0); + nextCfg.perfPreset, want, prevFinest, live ? 1 : 0, ready_ ? 1 : 0); - if (!live) return; + if (!live) { + cfg_ = nextCfg; + flowFinest_ = want; + return; + } + if (!waitIdle("live preset rebuild")) return; + if (scratch_ && scratch_->ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) { + DDFG_LOGE("perf-preset live rebuild: scratch cleanup failed; keeping the previous configuration"); + return; + } - - - dd_->DeviceWaitIdle(device_); - destroyScratch(dd_, device_, descPool_); - if (!onResize(extent_, VK_FORMAT_UNDEFINED, true)) - DDFG_LOGE("perf-preset live rebuild: onResize FAILED at %ux%u - FG disabled until next resize", - extent_.width, extent_.height); for (int i = 0; i < 6; ++i) gmRun_[i] = 0.0; - for (int s = 0; s < kGmSlots; ++s) { gmSlotValid_[s] = false; for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0; } - gmHaveEst_ = false; gmEngaged_ = false; gmStableCount_ = 0; gmLastTransPx_ = 0.0f; + for (int s = 0; s < kGmSlots; ++s) { + gmSlotValid_[s] = false; + for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0; + } + gmHaveEst_ = false; + gmEngaged_ = false; + gmStableCount_ = 0; + gmLastTransPx_ = 0.0f; + + cfg_ = nextCfg; + flowFinest_ = want; + ready_ = false; + if (!onResize(extent_, VK_FORMAT_UNDEFINED, true)) { + ready_ = false; + DDFG_LOGE("perf-preset live rebuild: onResize FAILED at %ux%u - frame generation unavailable", + extent_.width, extent_.height); + return; + } DDFG_LOGI("perf-preset live rebuild DONE (kFlowFinest=%d, flow predictor reset)", flowFinest_); } - bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) { ++gmFrames_; if (!gmBuffersReady_ || cfg_.gmMode == 2 ) { @@ -199,10 +260,10 @@ bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) { bool good = false; if (gmSlotValid_[gmSlot]) { const float* pt = (const float*)gmSsboPtr_[gmSlot]; - double sums[32]; for (int k = 0; k < 32; ++k) sums[k] = 0.0; + double sums[28]{}; for (int t = 0; t < kGmThreads; ++t) { const float* row = pt + (size_t)t * kGmStride; - for (int k = 0; k < kGmStride; ++k) sums[k] += (double)row[k]; + for (int k = 0; k < 28; ++k) sums[k] += (double)row[k]; } double coverage = sums[27]; double lvlpx = double((fullExtent.width >> kGmLevel) * (fullExtent.height >> kGmLevel)); @@ -254,23 +315,33 @@ bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) { void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView currView, VkImageView outView, float alpha, uint32_t gmSlot, uint32_t synthSlot, bool reuseFlow) { if (!valid()) return; + auto& S = *scratch_; if (gmSlot >= (uint32_t)kGmSlots) gmSlot = 0; if (synthSlot >= (uint32_t)kSynthSlots) synthSlot = 0; const bool m4 = (cfg_.model == 4); const Pipe& flowP = m4 ? pFlowM4_ : pFlow_; const Pipe& expandP = m4 ? pExpandM4_ : pExpand_; - if (!g_scratch.built || g_scratch.builtFor.width != extent_.width || g_scratch.builtFor.height != extent_.height) { - ensureScratch(this, dd_, device_, memProps_, descPool_, linear_, extent_, - pyrA_, pyrB_, pyrAs_, flowLvl_, flowExpA_, flowExpB_, - pLuma_, pDown_, flowP, expandP, pSynth_, pGmReduce_, pGmPrewarp_, - pFlowReg_, flowRegA_, flowRegB_, gmSsbo_, kLevels, cfg_); + if (!S.built || S.builtFor.width != extent_.width || + S.builtFor.height != extent_.height || + S.builtGeneration != imageGeneration_) { + if (S.built && !waitIdle("scratch rebuild")) return; + if (S.ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) { + DDFG_LOGE("framegen record: scratch cleanup failed; skipping this frame"); + return; + } + if (!ensureScratch(S, this, dd_, device_, memProps_, descPool_, linear_, extent_, + pyrA_, pyrB_, pyrAs_, flowLvl_, flowExpA_, flowExpB_, + pLuma_, pDown_, flowP, expandP, pSynth_, pGmReduce_, pGmPrewarp_, + pFlowReg_, flowRegA_, flowRegB_, gmSsbo_, kLevels, cfg_, imageGeneration_)) + return; } - if (reuseFlow && !g_scratch.flowReady) return; + if (S.ownerDevice != device_) return; + if (reuseFlow && !S.flowReady) return; if (!reuseFlow) { bool gmEngaged = updateGlobalMotion(gmSlot, extent_); - if (g_scratch.gmUboPtr[gmSlot]) { + if (S.gmUboPtr[gmSlot]) { GMUBO g{}; g.lin[0]=(float)gmRun_[0]; g.lin[1]=(float)gmRun_[1]; g.lin[2]=(float)gmRun_[2]; g.lin[3]=(float)gmRun_[3]; g.linT[0]=(float)gmRun_[4]; g.linT[1]=(float)gmRun_[5]; g.linT[2]=gmEngaged?1.0f:0.0f; g.linT[3]=0.0f; @@ -278,7 +349,7 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur g.app[0]=(float)gmRun_[0]; g.app[1]=(float)gmRun_[1]; g.app[2]=(float)gmRun_[2]; g.app[3]=(float)gmRun_[3]; g.appT[0]=(float)gmRun_[4]; g.appT[1]=(float)gmRun_[5]; } - std::memcpy(g_scratch.gmUboPtr[gmSlot], &g, sizeof(g)); + std::memcpy(S.gmUboPtr[gmSlot], &g, sizeof(g)); } { static int lastEng = -1; @@ -289,18 +360,37 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur } } - wImg(dd_, device_, g_scratch.sLumaCurr, 32, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, currView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - wImg(dd_, device_, g_scratch.sLumaPrev, 32, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, prevView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + const VkDescriptorSet lumaSets[] = {S.sLumaCurr, S.sLumaPrev}; + const uint32_t lumaBindings[] = {32, 32}; + const VkDescriptorType lumaTypes[] = { + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER}; + const VkImageView lumaViews[] = {currView, prevView}; + const VkSampler lumaSamplers[] = {linear_, linear_}; + const VkImageLayout lumaLayouts[] = { + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL}; + wImgBatch(dd_, device_, lumaSets, lumaBindings, lumaTypes, lumaViews, + lumaSamplers, lumaLayouts, 2); } SynthUBO su{cfg_.flowScale, alpha, cfg_.beta, cfg_.lambda, cfg_.epsilon, cfg_.photoScale, 0, 0, cfg_.hudX0, cfg_.hudY0, cfg_.hudX1, cfg_.hudY1}; - if (g_scratch.synthUboPtr[synthSlot]) std::memcpy(g_scratch.synthUboPtr[synthSlot], &su, sizeof(su)); + if (S.synthUboPtr[synthSlot]) std::memcpy(S.synthUboPtr[synthSlot], &su, sizeof(su)); - const VkDescriptorSet synthSet = g_scratch.sSynth[synthSlot]; - wImg(dd_, device_, synthSet, 32, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, prevView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - wImg(dd_, device_, synthSet, 33, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, currView, linear_, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - wImg(dd_, device_, synthSet, 48, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, outView, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL); + const VkDescriptorSet synthSet = S.sSynth[synthSlot]; + const VkDescriptorSet synthSets[] = {synthSet, synthSet, synthSet}; + const uint32_t synthBindings[] = {32, 33, 48}; + const VkDescriptorType synthTypes[] = { + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + VK_DESCRIPTOR_TYPE_STORAGE_IMAGE}; + const VkImageView synthViews[] = {prevView, currView, outView}; + const VkSampler synthSamplers[] = {linear_, linear_, VK_NULL_HANDLE}; + const VkImageLayout synthLayouts[] = { + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_GENERAL}; + wImgBatch(dd_, device_, synthSets, synthBindings, synthTypes, synthViews, + synthSamplers, synthLayouts, 3); auto disp = [&](const Pipe& p, VkDescriptorSet set, VkExtent2D e) { dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline); @@ -308,43 +398,94 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur dd_->CmdDispatch(cmd, (e.width + 15) / 16, (e.height + 15) / 16, 1); }; auto bar = [&](FrameGen::Img& i){ barrier(cmd, i.image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL); }; + auto barPair = [&](FrameGen::Img& a, FrameGen::Img& b) { + VkImageMemoryBarrier barriers[2]{}; + FrameGen::Img* images[] = {&a, &b}; + for (uint32_t i = 0; i < 2; ++i) { + barriers[i].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + barriers[i].srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + barriers[i].dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + barriers[i].oldLayout = VK_IMAGE_LAYOUT_GENERAL; + barriers[i].newLayout = VK_IMAGE_LAYOUT_GENERAL; + barriers[i].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barriers[i].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barriers[i].image = images[i]->image; + barriers[i].subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + } + dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, + 0, nullptr, 2, barriers); + }; + const bool frEngaged = (cfg_.frMode != 2) && (cfg_.frIters > 0); if (!reuseFlow) { - for (auto& i : pyrA_) barrier(cmd, i.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - for (auto& i : pyrB_) barrier(cmd, i.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - for (int l = flowFinest_; l < kLevels; ++l) barrier(cmd, pyrAs_[l].image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowExpA_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowExpB_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowRegA_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); - barrier(cmd, flowRegB_.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); + // Batch fresh-image transitions that share the same stage and access masks. + std::array initBarriers{}; + size_t initBarrierCount = 0; + auto addInitBarrier = [&](VkImage image) { + VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + b.newLayout = VK_IMAGE_LAYOUT_GENERAL; + b.srcAccessMask = 0; + b.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + b.image = image; + b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + initBarriers[initBarrierCount++] = b; + }; + for (auto& i : pyrA_) addInitBarrier(i.image); + for (auto& i : pyrB_) addInitBarrier(i.image); + for (int l = flowFinest_; l < kLevels; ++l) addInitBarrier(pyrAs_[l].image); + addInitBarrier(flowExpA_.image); + addInitBarrier(flowExpB_.image); + if (frEngaged) { + addInitBarrier(flowRegA_.image); + addInitBarrier(flowRegB_.image); + } + // The final flow level is cleared through TRANSFER_DST_OPTIMAL below; + // the other levels can use the common initialization barrier. + for (int l = flowFinest_; l < kLevels - 1; ++l) addInitBarrier(flowLvl_[l].image); + if (initBarrierCount != 0) { + dd_->CmdPipelineBarrier(cmd, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, + 0, nullptr, static_cast(initBarrierCount), initBarriers.data()); + } { VkClearColorValue zero{}; VkImageSubresourceRange rng{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; - for (int l = flowFinest_; l < kLevels; ++l) { - VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; - b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - b.srcAccessMask = 0; b.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - b.image = flowLvl_[l].image; b.subresourceRange = rng; - b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); - dd_->CmdClearColorImage(cmd, flowLvl_[l].image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &zero, 1, &rng); - b.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; b.newLayout = VK_IMAGE_LAYOUT_GENERAL; - b.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; b.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; - dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); - } + VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + b.srcAccessMask = 0; + b.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + b.image = flowLvl_[kLevels - 1].image; + b.subresourceRange = rng; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + dd_->CmdPipelineBarrier(cmd, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); + dd_->CmdClearColorImage(cmd, flowLvl_[kLevels - 1].image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &zero, 1, &rng); + b.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + b.newLayout = VK_IMAGE_LAYOUT_GENERAL; + b.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + b.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + dd_->CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b); } - disp(pLuma_, g_scratch.sLumaCurr, levelExtent(extent_, 0)); - disp(pLuma_, g_scratch.sLumaPrev, levelExtent(extent_, 0)); - bar(pyrA_[0]); bar(pyrB_[0]); + disp(pLuma_, S.sLumaCurr, levelExtent(extent_, 0)); + disp(pLuma_, S.sLumaPrev, levelExtent(extent_, 0)); + barPair(pyrA_[0], pyrB_[0]); for (int l = 1; l < kLevels; ++l) { - disp(pDown_, g_scratch.sDownA[l - 1], levelExtent(extent_, l)); - disp(pDown_, g_scratch.sDownB[l - 1], levelExtent(extent_, l)); - bar(pyrA_[l]); bar(pyrB_[l]); + disp(pDown_, S.sDownA[l - 1], levelExtent(extent_, l)); + disp(pDown_, S.sDownB[l - 1], levelExtent(extent_, l)); + barPair(pyrA_[l], pyrB_[l]); } - if (gmBuffersReady_ && g_scratch.sGmReduce[gmSlot]) { + if (gmBuffersReady_ && S.sGmReduce[gmSlot]) { dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.pipeline); - dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.layout, 0, 1, &g_scratch.sGmReduce[gmSlot], 0, nullptr); + dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.layout, 0, 1, &S.sGmReduce[gmSlot], 0, nullptr); dd_->CmdDispatch(cmd, (uint32_t)(kGmThreads / 64), 1, 1); VkMemoryBarrier mb{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; mb.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; mb.dstAccessMask = VK_ACCESS_HOST_READ_BIT; @@ -352,32 +493,31 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur 0, 1, &mb, 0, nullptr, 0, nullptr); } for (int l = flowFinest_; l < kLevels; ++l) { - disp(pGmPrewarp_, g_scratch.sGmPrewarp[gmSlot][l], levelExtent(extent_, l)); + disp(pGmPrewarp_, S.sGmPrewarp[gmSlot][l], levelExtent(extent_, l)); bar(pyrAs_[l]); } for (int l = kLevels - 1; l >= flowFinest_; --l) { - disp(flowP, g_scratch.sFlow[l], levelExtent(extent_, l)); + disp(flowP, S.sFlow[l], levelExtent(extent_, l)); bar(flowLvl_[l]); } - const bool frEngaged = (cfg_.frMode != 2) && (cfg_.frIters > 0); if (frEngaged) { const int F = flowFinest_; const VkExtent2D fe = levelExtent(extent_, F); - if (g_scratch.flowRegUboPtr) { + if (S.flowRegUboPtr) { FlowRegUBO fu{cfg_.frDt, cfg_.frLambda, cfg_.frEdge, cfg_.frEps}; - std::memcpy(g_scratch.flowRegUboPtr, &fu, sizeof(fu)); + std::memcpy(S.flowRegUboPtr, &fu, sizeof(fu)); } FrameGen::Img* last = nullptr; for (int it = 0; it < cfg_.frIters; ++it) { VkDescriptorSet set; FrameGen::Img* outImg; - if (it == 0) { set = g_scratch.sFlowReg0; outImg = &flowRegA_; } - else if (it % 2 == 1) { set = g_scratch.sFlowRegAB; outImg = &flowRegB_; } - else { set = g_scratch.sFlowRegBA; outImg = &flowRegA_; } + if (it == 0) { set = S.sFlowReg0; outImg = &flowRegA_; } + else if (it % 2 == 1) { set = S.sFlowRegAB; outImg = &flowRegB_; } + else { set = S.sFlowRegBA; outImg = &flowRegA_; } dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pFlowReg_.pipeline); dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pFlowReg_.layout, 0, 1, &set, 0, nullptr); dd_->CmdDispatch(cmd, (fe.width + 15) / 16, (fe.height + 15) / 16, 1); - bar(*outImg); + if (it + 1 < cfg_.frIters) bar(*outImg); last = outImg; } VkMemoryBarrier mb{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; @@ -407,14 +547,14 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur } } - disp(expandP, g_scratch.sExpand[gmSlot], levelExtent(extent_, 0)); - bar(flowExpA_); bar(flowExpB_); - g_scratch.flowReady = true; + disp(expandP, S.sExpand[gmSlot], levelExtent(extent_, 0)); + barPair(flowExpA_, flowExpB_); + S.flowReady = true; } disp(pSynth_, synthSet, levelExtent(extent_, 0)); } -static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, +static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const VkPhysicalDeviceMemoryProperties& mp, VkDescriptorPool pool, VkSampler samp, VkExtent2D ext, std::vector& pyrA, std::vector& pyrB, @@ -425,9 +565,10 @@ static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, const FrameGen::Pipe& pSynth, const FrameGen::Pipe& pGmReduce, const FrameGen::Pipe& pGmPrewarp, const FrameGen::Pipe& pFlowReg, FrameGen::Img& flowRegA, FrameGen::Img& flowRegB, VkBuffer* gmSsbo, - int kLevels, const Config& cfg) { - auto& S = g_scratch; + int kLevels, const Config& cfg, uint64_t imageGeneration) { + if (S.ownerDevice != VK_NULL_HANDLE && S.ownerDevice != dev) return false; S = ScratchState{}; + S.ownerDevice = dev; const auto GEN = VK_IMAGE_LAYOUT_GENERAL; for (int s = 0; s < FrameGen::kSynthSlots; ++s) @@ -528,7 +669,7 @@ static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev, wImg(dd, dev, S.sSynth[s], 35, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, expB.view, samp, GEN); } - S.builtFor = ext; S.built = true; + S.builtFor = ext; S.builtGeneration = imageGeneration; S.ownerDevice = dev; S.built = true; return true; } diff --git a/app/src/main/cpp/questxr/CMakeLists.txt b/app/src/main/cpp/questxr/CMakeLists.txt index c23558bb0b..dd7ccc3599 100644 --- a/app/src/main/cpp/questxr/CMakeLists.txt +++ b/app/src/main/cpp/questxr/CMakeLists.txt @@ -8,6 +8,6 @@ target_compile_features(droiddeckxr PRIVATE cxx_std_17) target_compile_definitions(droiddeckxr PRIVATE XR_USE_PLATFORM_ANDROID XR_USE_GRAPHICS_API_OPENGL_ES XR_USE_TIMESPEC) target_compile_options(droiddeckxr PRIVATE -Wall -Wextra -Wno-missing-field-initializers -Werror=return-type) target_link_options(droiddeckxr PRIVATE -Wl,-z,max-page-size=16384 -uANativeActivity_onCreate) -target_link_libraries(droiddeckxr PRIVATE droiddeckxr_glue OpenXR::openxr_loader EGL GLESv3 android log) +target_link_libraries(droiddeckxr PRIVATE droiddeckxr_glue OpenXR::openxr_loader EGL GLESv3 android jnigraphics log) target_include_directories(droiddeckxr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../tools/vr/src) diff --git a/app/src/main/cpp/questxr/quest_xr.cpp b/app/src/main/cpp/questxr/quest_xr.cpp index 09423c7d1a..7f0237b097 100644 --- a/app/src/main/cpp/questxr/quest_xr.cpp +++ b/app/src/main/cpp/questxr/quest_xr.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -22,10 +23,14 @@ #include #include #include +#include +#include #include "xr_tracking.h" #include "xr_frame_channel.h" #include "xr_frame_math.h" #include "gpu_frames.h" +#include "xr_host.h" +#include "xr_overlay.h" static void check(XrResult result, const char *operation) { if (XR_FAILED(result)) throw std::runtime_error(std::string(operation) + ": " + std::to_string(result)); @@ -37,6 +42,15 @@ struct Eye { std::vector images; }; +struct SurfaceLayer { + XrSwapchain swapchain = XR_NULL_HANDLE; + jobject surface = nullptr; + int width = 0, height = 0; +}; + +class QuestXR; +static QuestXR *g_runtime = nullptr; + class QuestXR { public: explicit QuestXR(android_app *app) : app_(app) {} @@ -76,21 +90,74 @@ public: "\"headPosition\":[%.6f,%.6f,%.6f],\"controllersActive\":[%s,%s]," "\"periodNs\":%lld,\"surfaceSwapchain\":%s,\"source\":\"%s\",\"guestFrames\":%lld,\"steamvrState\":%d," "\"receivedFrames\":%llu,\"rejectedFrames\":%llu,\"uploadedFrames\":%llu,\"sourceFrameId\":%llu," - "\"gpuReceivedFrames\":%llu,\"gpuDroppedFrames\":%llu,\"gpuVerifiedFrameId\":%llu,\"gpuChecksum\":%u,\"error\":\"%s\"}\n", + "\"gpuReceivedFrames\":%llu,\"gpuDroppedFrames\":%llu,\"gpuVerifiedFrameId\":%llu,\"gpuChecksum\":%u," + "\"hostVersion\":%u,\"visibleLayers\":%d,\"overlay\":%s,\"error\":\"%s\"}\n", (unsigned long long)frames_, (unsigned long long)rendered_, state_, (unsigned long long)head_.locationFlags, head_.pose.position.x, head_.pose.position.y, head_.pose.position.z, handActive_[0] ? "true" : "false", handActive_[1] ? "true" : "false", - (long long)period_, "false", "frames", + (long long)period_, surfaceSupported_ ? "true" : "false", "frames", 0LL, steamvrState, (unsigned long long)(receiver_.Received() + gpuFrames_.Received()), (unsigned long long)(receiver_.Rejected() + gpuFrames_.Rejected()), (unsigned long long)uploadedFrames_, (unsigned long long)sourceHeader_.frame_id, (unsigned long long)gpuFrames_.Received(), (unsigned long long)gpuFrames_.Dropped(), - (unsigned long long)verifiedFrame_, gpuChecksum_, error); + (unsigned long long)verifiedFrame_, gpuChecksum_, + hostBuffers_ ? DROIDDECK_XR_HOST_VERSION : 0u, visibleLayers_, + XrOverlay::active(hostControl_) ? "true" : "false", error); std::fclose(file); std::rename(temp.c_str(), path.c_str()); } + bool onXrThread() const { return pthread_equal(pthread_self(), xrThread_); } + + int createLayer(JNIEnv *env, int width, int height) { + if (!onXrThread() || !createSurfaceSwapchain_ || session_ == XR_NULL_HANDLE || width <= 0 || height <= 0) return -1; + for (int index = 0; index < DROIDDECK_XR_HOST_LAYERS; index++) { + SurfaceLayer &layer = layers_[index]; + if (layer.swapchain) continue; + XrSwapchainCreateInfo create{XR_TYPE_SWAPCHAIN_CREATE_INFO}; + create.usageFlags = XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT; + create.width = width; create.height = height; + jobject surface = nullptr; + XrResult result = createSurfaceSwapchain_(session_, &create, &layer.swapchain, &surface); + if (XR_FAILED(result) || !surface) { + __android_log_print(ANDROID_LOG_ERROR, "DroidDeckXR", "surface layer %dx%d failed: %d", width, height, result); + if (layer.swapchain) xrDestroySwapchain(layer.swapchain); + layer = {}; + return -1; + } + layer.surface = env->NewGlobalRef(surface); + layer.width = width; layer.height = height; + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "surface layer %d created %dx%d", index, width, height); + return index; + } + return -1; + } + + jobject layerSurface(JNIEnv *env, int index) { + if (!onXrThread() || index < 0 || index >= DROIDDECK_XR_HOST_LAYERS || !layers_[index].surface) return nullptr; + return env->NewLocalRef(layers_[index].surface); + } + + void setOrbImage(JNIEnv *env, jobject bitmap) { + if (!onXrThread() || !bitmap) return; + AndroidBitmapInfo info{}; + void *pixels = nullptr; + if (AndroidBitmap_getInfo(env, bitmap, &info) != ANDROID_BITMAP_RESULT_SUCCESS + || info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) return; + if (AndroidBitmap_lockPixels(env, bitmap, &pixels) != ANDROID_BITMAP_RESULT_SUCCESS) return; + overlay_.setLogo(pixels, (int)info.width, (int)info.height, (int)info.stride); + AndroidBitmap_unlockPixels(env, bitmap); + } + + void destroyLayer(JNIEnv *env, int index) { + if (!onXrThread() || index < 0 || index >= DROIDDECK_XR_HOST_LAYERS) return; + SurfaceLayer &layer = layers_[index]; + if (layer.swapchain) xrDestroySwapchain(layer.swapchain); + if (layer.surface) env->DeleteGlobalRef(layer.surface); + layer = {}; + } + private: android_app *app_; JNIEnv *env_ = nullptr; @@ -104,6 +171,20 @@ private: XrAction primary_ = XR_NULL_HANDLE, secondary_ = XR_NULL_HANDLE, menu_ = XR_NULL_HANDLE; XrAction triggerTouch_ = XR_NULL_HANDLE, stickTouch_ = XR_NULL_HANDLE, primaryTouch_ = XR_NULL_HANDLE; XrAction secondaryTouch_ = XR_NULL_HANDLE, thumbrestTouch_ = XR_NULL_HANDLE; + PFN_xrCreateSwapchainAndroidSurfaceKHR createSurfaceSwapchain_ = nullptr; + bool surfaceSupported_ = false; + bool imageLayoutSupported_ = false; + pthread_t xrThread_{}; + SurfaceLayer layers_[DROIDDECK_XR_HOST_LAYERS]; + DroidDeckXrHostState hostState_{}; + DroidDeckXrHostControl hostControl_{}; + bool hostBuffers_ = false; + jmethodID hostFrameCallback_ = nullptr; + uint64_t hostPulse_[2]{}; + int visibleLayers_ = 0; + XrOverlay overlay_; + Eye overlayEyes_[2]; + GLuint overlayDepth_[2]{}; DroidDeckXrHand inputs_[2]{}; PFN_xrConvertTimeToTimespecTimeKHR convertTime_ = nullptr; bool timespecSupported_ = false; @@ -220,6 +301,8 @@ private: void initialize() { app_->userData = this; + xrThread_ = pthread_self(); + g_runtime = this; app_->onInputEvent = [](android_app *app, AInputEvent *event) -> int32_t { if (AInputEvent_getType(event) != AINPUT_EVENT_TYPE_KEY || AKeyEvent_getKeyCode(event) != AKEYCODE_BACK || AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP) return 0; @@ -244,6 +327,10 @@ private: frameCallback_ = env_->GetMethodID(activityClass, "onXrFrame", "(J)V"); statusCallback_ = env_->GetMethodID(activityClass, "onXrStatus", "()I"); if (env_->ExceptionCheck()) { env_->ExceptionClear(); throw std::runtime_error("XR activity bridge methods unavailable"); } + hostFrameCallback_ = env_->GetMethodID(activityClass, "onXrHostFrame", "()V"); + jmethodID hostBuffersCallback = hostFrameCallback_ ? + env_->GetMethodID(activityClass, "onXrHostBuffers", "(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V") : nullptr; + if (env_->ExceptionCheck()) { env_->ExceptionClear(); hostFrameCallback_ = nullptr; hostBuffersCallback = nullptr; } env_->DeleteLocalRef(intentClass); env_->DeleteLocalRef(intent); env_->DeleteLocalRef(activityClass); PFN_xrInitializeLoaderKHR initializeLoader = nullptr; check(xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", @@ -261,10 +348,21 @@ private: timespecSupported_ = true; if (!std::strcmp(extension.extensionName, XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME)) performanceSupported_ = true; + if (!std::strcmp(extension.extensionName, XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME)) + surfaceSupported_ = true; + if (!std::strcmp(extension.extensionName, XR_FB_COMPOSITION_LAYER_IMAGE_LAYOUT_EXTENSION_NAME)) + imageLayoutSupported_ = true; } + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "surface swapchain available=%d image layout=%d", + surfaceSupported_, imageLayoutSupported_); + // A surface swapchain's image arrives upside down, and a quad's back face is not drawn, so + // panels need the layout flag to flip it. + surfaceSupported_ = surfaceSupported_ && imageLayoutSupported_; std::vector enabled{XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME, XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME}; if (timespecSupported_) enabled.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME); if (performanceSupported_) enabled.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); + if (surfaceSupported_) enabled.push_back(XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME); + if (surfaceSupported_) enabled.push_back(XR_FB_COMPOSITION_LAYER_IMAGE_LAYOUT_EXTENSION_NAME); XrInstanceCreateInfoAndroidKHR androidInfo{XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; androidInfo.applicationVM = app_->activity->vm; androidInfo.applicationActivity = app_->activity->clazz; @@ -281,6 +379,11 @@ private: reinterpret_cast(&setPerformance_)); if (XR_FAILED(result)) setPerformance_ = nullptr; } + if (surfaceSupported_ && XR_FAILED(xrGetInstanceProcAddr(instance_, "xrCreateSwapchainAndroidSurfaceKHR", + reinterpret_cast(&createSurfaceSwapchain_)))) { + createSurfaceSwapchain_ = nullptr; + surfaceSupported_ = false; + } if (timespecSupported_) check(xrGetInstanceProcAddr(instance_, "xrConvertTimeToTimespecTimeKHR", reinterpret_cast(&convertTime_)), "time conversion entrypoint"); XrSystemGetInfo systemInfo{XR_TYPE_SYSTEM_GET_INFO}; @@ -334,6 +437,16 @@ private: bool gpu = !verifyPixels_ && gpuFrames_.Start(std::string(app_->activity->internalDataPath) + "/.wayland-rt/" DROIDDECK_XR_GPU_SOCKET, display_); __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "GPU frame channel available=%d", gpu); } + overlay_.initialize(); + hostState_.version = DROIDDECK_XR_HOST_VERSION; + if (hostBuffersCallback) { + jobject state = env_->NewDirectByteBuffer(&hostState_, sizeof(hostState_)); + jobject control = env_->NewDirectByteBuffer(&hostControl_, sizeof(hostControl_)); + env_->CallVoidMethod(app_->activity->clazz, hostBuffersCallback, state, control); + if (env_->ExceptionCheck()) { env_->ExceptionDescribe(); env_->ExceptionClear(); hostFrameCallback_ = nullptr; } + else hostBuffers_ = true; + env_->DeleteLocalRef(state); env_->DeleteLocalRef(control); + } health(); } @@ -422,6 +535,13 @@ private: target.images.resize(count, {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR}); check(xrEnumerateSwapchainImages(target.swapchain, count, &count, reinterpret_cast(target.images.data())), "images"); + Eye &overlay = overlayEyes_[eye]; + overlay.width = target.width; overlay.height = target.height; + check(xrCreateSwapchain(session_, &create, &overlay.swapchain), "overlay swapchain"); + check(xrEnumerateSwapchainImages(overlay.swapchain, 0, &count, nullptr), "overlay image count"); + overlay.images.resize(count, {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR}); + check(xrEnumerateSwapchainImages(overlay.swapchain, count, &count, + reinterpret_cast(overlay.images.data())), "overlay images"); } } @@ -530,6 +650,12 @@ private: void initializeGraphics() { glGenFramebuffers(1, &framebuffer_); + glGenRenderbuffers(2, overlayDepth_); + for (int eye = 0; eye < 2; eye++) { + glBindRenderbuffer(GL_RENDERBUFFER, overlayDepth_[eye]); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, overlayEyes_[eye].width, overlayEyes_[eye].height); + } + glBindRenderbuffer(GL_RENDERBUFFER, 0); glGenVertexArrays(1, &vertexArray_); GLuint vertex = shader(GL_VERTEX_SHADER, "#version 300 es\nout vec2 uv; uniform float eye; void main(){vec2 coordinate=vec2(float((gl_VertexID<<1)&2),float(gl_VertexID&2));uv=vec2(coordinate.x*0.5+eye*0.5,1.0-coordinate.y);gl_Position=vec4(coordinate*2.0-1.0,0.0,1.0);}"); @@ -584,24 +710,46 @@ private: if (verifyPixels_ || uploadedFrames_ % 72 == 1) health(); } - void render(Eye &eye, uint32_t image) { + void render(Eye &eye, uint32_t image, bool source, const XrPosef &pose, const XrFovf &fov, float seconds) { glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eye.images[image].image, 0); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) throw std::runtime_error("Incomplete eye framebuffer"); - { - glViewport(0, 0, eye.width, eye.height); glDisable(GL_DEPTH_TEST); + glViewport(0, 0, eye.width, eye.height); glDisable(GL_DEPTH_TEST); + if (source) { glUseProgram(sourceProgram_); glBindVertexArray(vertexArray_); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sourceTexture_); glUniform1i(glGetUniformLocation(sourceProgram_, "source"), 0); glUniform1f(glGetUniformLocation(sourceProgram_, "eye"), &eye == &eyes_[1] ? 1.f : 0.f); glDrawArrays(GL_TRIANGLES, 0, 3); + } else { + glClearColor(0.f, 0.f, 0.f, 1.f); + glClear(GL_COLOR_BUFFER_BIT); } glBindFramebuffer(GL_FRAMEBUFFER, 0); if (glGetError() != GL_NO_ERROR) throw std::runtime_error("OpenGL render error"); glFlush(); } + // Lasers and the orb go in their own layer above the panels, which only the panels' depth hides. + void renderOverlay(int index, uint32_t image, const XrPosef &pose, const XrFovf &fov, float seconds) { + Eye &eye = overlayEyes_[index]; + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eye.images[image].image, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, overlayDepth_[index]); + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + throw std::runtime_error("Incomplete overlay framebuffer"); + glViewport(0, 0, eye.width, eye.height); + glClearColor(0.f, 0.f, 0.f, 0.f); glClearDepthf(1.f); + glDepthMask(GL_TRUE); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + overlay_.draw(pose, fov, hostControl_, hostState_, seconds); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + if (glGetError() != GL_NO_ERROR) throw std::runtime_error("OpenGL overlay error"); + glFlush(); + } + void pollEvents() { XrEventDataBuffer event{XR_TYPE_EVENT_DATA_BUFFER}; XrResult result; @@ -614,10 +762,13 @@ private: XrSessionBeginInfo begin{XR_TYPE_SESSION_BEGIN_INFO}; begin.primaryViewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; check(xrBeginSession(session_, &begin), "xrBeginSession"); running_ = true; + // Meta's clock governor scales clocks by the DroidDeck process's overall load and cannot see + // SteamVR missing refreshes inside the guest; holding the top level kept it at 72 Hz. if (setPerformance_) { for (auto domain : {XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_DOMAIN_GPU_EXT}) { - XrResult request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT); - __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "sustained performance domain=%d result=%d", domain, request); + XrResult request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_BOOST_EXT); + if (XR_FAILED(request)) request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT); + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "performance domain=%d result=%d", domain, request); } } } else if (state_ == XR_SESSION_STATE_STOPPING) { @@ -682,6 +833,7 @@ private: XrViewState viewState{XR_TYPE_VIEW_STATE}; uint32_t count = 0; XrView views[2]{{XR_TYPE_VIEW}, {XR_TYPE_VIEW}}; check(xrLocateViews(session_, &locate, &viewState, 2, &count, views), "xrLocateViews"); + hostFrame(frameState.predictedDisplayTime); publishTracking(views, frameState.predictedDisplayTime); if (guestAttached_) { timespec now{}; clock_gettime(CLOCK_MONOTONIC, &now); @@ -689,29 +841,34 @@ private: if (env_->ExceptionCheck()) { env_->ExceptionClear(); throw std::runtime_error("Guest frame callback failed"); } } XrCompositionLayerProjectionView projection[2]{{XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}, {XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}}; - bool valid = frameState.shouldRender && count == 2 && + const bool viewsValid = frameState.shouldRender && count == 2 && (viewState.viewStateFlags & (XR_VIEW_STATE_ORIENTATION_VALID_BIT | XR_VIEW_STATE_POSITION_VALID_BIT)) == (XR_VIEW_STATE_ORIENTATION_VALID_BIT | XR_VIEW_STATE_POSITION_VALID_BIT); - { - valid = valid && sourceHeader_.frame_id && xr_frame_now() - sourceHeader_.captured_ns < 500000000LL; - if (valid) for (int eye = 0; eye < 2; eye++) { - auto source = xr_frame_view(sourceHeader_, eye); - views[eye].pose.orientation = {source.orientation[0], source.orientation[1], source.orientation[2], source.orientation[3]}; - views[eye].pose.position = {source.position[0], source.position[1], source.position[2]}; - views[eye].fov = {source.fov[0], source.fov[1], source.fov[2], source.fov[3]}; - } + bool valid = viewsValid && sourceHeader_.frame_id && xr_frame_now() - sourceHeader_.captured_ns < 500000000LL; + if (valid) for (int eye = 0; eye < 2; eye++) { + auto source = xr_frame_view(sourceHeader_, eye); + views[eye].pose.orientation = {source.orientation[0], source.orientation[1], source.orientation[2], source.orientation[3]}; + views[eye].pose.position = {source.position[0], source.position[1], source.position[2]}; + views[eye].fov = {source.fov[0], source.fov[1], source.fov[2], source.fov[3]}; } + std::vector quads; + std::vector layouts; + if (viewsValid) collectQuads(quads, layouts); + const bool uiOnly = !valid && viewsValid && !quads.empty(); + const bool draw = valid || uiOnly; const std::string capture = captureRequest(); bool captured = valid; if (!capture.empty() && valid) captured = captureTexture(sourceTexture_, sourceHeader_.width, sourceHeader_.height, "source"); - if (valid) for (int eye = 0; eye < 2; eye++) { + timespec clock{}; clock_gettime(CLOCK_MONOTONIC, &clock); + const float seconds = (float)(clock.tv_sec % 3600) + clock.tv_nsec * 1e-9f; + if (draw) for (int eye = 0; eye < 2; eye++) { uint32_t image = 0; XrSwapchainImageAcquireInfo acquire{XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO}; check(xrAcquireSwapchainImage(eyes_[eye].swapchain, &acquire, &image), "acquire image"); XrSwapchainImageWaitInfo imageWait{XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO}; imageWait.timeout = XR_INFINITE_DURATION; check(xrWaitSwapchainImage(eyes_[eye].swapchain, &imageWait), "wait image"); - render(eyes_[eye], image); + render(eyes_[eye], image, valid, views[eye].pose, views[eye].fov, seconds); if (!capture.empty()) captured = captureTexture(eyes_[eye].images[image].image, eyes_[eye].width, eyes_[eye].height, eye ? "right" : "left") && captured; XrSwapchainImageReleaseInfo release{XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO}; check(xrReleaseSwapchainImage(eyes_[eye].swapchain, &release), "release image"); @@ -719,19 +876,143 @@ private: projection[eye].subImage.swapchain = eyes_[eye].swapchain; projection[eye].subImage.imageRect.extent = {eyes_[eye].width, eyes_[eye].height}; } + const bool overlay = viewsValid && hostBuffers_ && XrOverlay::active(hostControl_); + XrCompositionLayerProjectionView overlayViews[2]{{XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}, {XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}}; + if (overlay) for (int eye = 0; eye < 2; eye++) { + uint32_t image = 0; + XrSwapchainImageAcquireInfo acquire{XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO}; + check(xrAcquireSwapchainImage(overlayEyes_[eye].swapchain, &acquire, &image), "acquire overlay image"); + XrSwapchainImageWaitInfo imageWait{XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO}; imageWait.timeout = XR_INFINITE_DURATION; + check(xrWaitSwapchainImage(overlayEyes_[eye].swapchain, &imageWait), "wait overlay image"); + renderOverlay(eye, image, views[eye].pose, views[eye].fov, seconds); + XrSwapchainImageReleaseInfo release{XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO}; + check(xrReleaseSwapchainImage(overlayEyes_[eye].swapchain, &release), "release overlay image"); + overlayViews[eye].pose = views[eye].pose; overlayViews[eye].fov = views[eye].fov; + overlayViews[eye].subImage.swapchain = overlayEyes_[eye].swapchain; + overlayViews[eye].subImage.imageRect.extent = {overlayEyes_[eye].width, overlayEyes_[eye].height}; + } XrCompositionLayerProjection layer{XR_TYPE_COMPOSITION_LAYER_PROJECTION}; layer.space = world_; layer.viewCount = 2; layer.views = projection; - const XrCompositionLayerBaseHeader *layers[] = {reinterpret_cast(&layer)}; + XrCompositionLayerProjection overlayLayer{XR_TYPE_COMPOSITION_LAYER_PROJECTION}; + overlayLayer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; + overlayLayer.space = world_; overlayLayer.viewCount = 2; overlayLayer.views = overlayViews; + std::vector layers; + if (draw) layers.push_back(reinterpret_cast(&layer)); + for (auto &quad : quads) layers.push_back(reinterpret_cast(&quad)); + if (overlay) layers.push_back(reinterpret_cast(&overlayLayer)); + visibleLayers_ = (int)quads.size(); XrFrameEndInfo end{XR_TYPE_FRAME_END_INFO}; end.displayTime = frameState.predictedDisplayTime; - end.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; end.layerCount = valid ? 1 : 0; end.layers = layers; + end.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; + end.layerCount = (uint32_t)layers.size(); end.layers = layers.data(); check(xrEndFrame(session_, &end), "xrEndFrame"); if (!capture.empty()) captureResult(capture, captured, valid, projection, frameState.predictedDisplayTime); frames_++; if (valid) rendered_++; if (frames_ % 72 == 0) { health(); - __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "frames=%llu rendered=%llu head=%llu hands=%d,%d period=%lld", + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "frames=%llu rendered=%llu head=%llu hands=%d,%d period=%lld layers=%d", (unsigned long long)frames_, (unsigned long long)rendered_, (unsigned long long)head_.locationFlags, - handActive_[0], handActive_[1], (long long)period_); + handActive_[0], handActive_[1], (long long)period_, visibleLayers_); + } + } + + // Android surfaces are stored top row first, while OpenXR samples images bottom row first. + void collectQuads(std::vector &quads, std::vector &layouts) { + if (!hostBuffers_) return; + quads.reserve(DROIDDECK_XR_HOST_LAYERS); + layouts.reserve(DROIDDECK_XR_HOST_LAYERS); + const DroidDeckXrHostLayer *ordered[DROIDDECK_XR_HOST_LAYERS]; + int visible = 0; + for (const auto &layer : hostControl_.layers) { + if (!layer.visible || layer.id < 0 || layer.id >= DROIDDECK_XR_HOST_LAYERS || !layers_[layer.id].swapchain) continue; + if (!(layer.width > 0.f) || !(layer.height > 0.f)) continue; + ordered[visible++] = &layer; + } + std::sort(ordered, ordered + visible, [](const DroidDeckXrHostLayer *a, const DroidDeckXrHostLayer *b) { return a->order < b->order; }); + for (int index = 0; index < visible; index++) { + const auto &layer = *ordered[index]; + const SurfaceLayer &surface = layers_[layer.id]; + XrCompositionLayerQuad quad{XR_TYPE_COMPOSITION_LAYER_QUAD}; + quad.layerFlags = (layer.flags & DROIDDECK_XR_HOST_LAYER_ALPHA) ? XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT : 0; + quad.space = (layer.flags & DROIDDECK_XR_HOST_LAYER_HEAD_LOCKED) ? view_ : world_; + quad.eyeVisibility = XR_EYE_VISIBILITY_BOTH; + quad.subImage.swapchain = surface.swapchain; + quad.subImage.imageRect.extent = {surface.width, surface.height}; + quad.pose.orientation = {layer.pose.orientation[0], layer.pose.orientation[1], layer.pose.orientation[2], layer.pose.orientation[3]}; + quad.pose.position = {layer.pose.position[0], layer.pose.position[1], layer.pose.position[2]}; + quad.size = {layer.width, layer.height}; + layouts.push_back({XR_TYPE_COMPOSITION_LAYER_IMAGE_LAYOUT_FB, nullptr, XR_COMPOSITION_LAYER_IMAGE_LAYOUT_VERTICAL_FLIP_BIT_FB}); + quad.next = &layouts.back(); + quads.push_back(quad); + } + } + + // SteamVR draws its laser from the "tip" of the Quest Touch render model the driver names + // (resources/rendermodels/oculus_quest_plus_controller_*), placed on the raw grip pose; panels + // use the same ray so there is one laser per controller. + static DroidDeckXrPose steamVrPointer(const XrSpaceLocation &grip, int hand) { + const float q[4] = {grip.pose.orientation.x, grip.pose.orientation.y, grip.pose.orientation.z, grip.pose.orientation.w}; + const XrVec3 tip{hand == 0 ? 0.016694f : -0.016694f, -0.02522f, 0.024687f}; + const XrVec3 at = XrVec3{grip.pose.position.x, grip.pose.position.y, grip.pose.position.z} + rotate(q, tip); + const float tx = -0.320613f, tw = 0.947210f; + DroidDeckXrPose pose{}; + pose.orientation[0] = q[3] * tx + q[0] * tw; + pose.orientation[1] = q[1] * tw + q[2] * tx; + pose.orientation[2] = q[2] * tw - q[1] * tx; + pose.orientation[3] = q[3] * tw - q[0] * tx; + pose.position[0] = at.x; pose.position[1] = at.y; pose.position[2] = at.z; + pose.flags = (uint32_t)grip.locationFlags; + return pose; + } + + void hostFrame(XrTime predicted) { + if (!hostBuffers_ || !hostFrameCallback_) return; + hostState_.version = DROIDDECK_XR_HOST_VERSION; + hostState_.session_state = state_; + hostState_.flags = (surfaceSupported_ ? DROIDDECK_XR_HOST_SURFACE_SWAPCHAIN : 0u) | + (state_ == XR_SESSION_STATE_FOCUSED ? DROIDDECK_XR_HOST_FOCUSED : 0u); + hostState_.frame = (int64_t)frames_; + hostState_.display_time_ns = 0; + if (convertTime_) { + timespec displayTime{}; + if (XR_SUCCEEDED(convertTime_(instance_, predicted, &displayTime))) + hostState_.display_time_ns = (int64_t)displayTime.tv_sec * 1000000000LL + displayTime.tv_nsec; + } + hostState_.head = posePacket(head_.pose, head_.locationFlags); + const XrSpaceLocationFlags tracked = XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT; + for (int hand = 0; hand < 2; hand++) { + auto &out = hostState_.hands[hand]; + out.grip = posePacket(handLocations_[hand].pose, handLocations_[hand].locationFlags); + out.aim = steamVrPointer(handLocations_[hand], hand); + out.trigger = inputs_[hand].trigger; out.squeeze = inputs_[hand].squeeze; + out.stick[0] = inputs_[hand].stick[0]; out.stick[1] = inputs_[hand].stick[1]; + out.buttons = inputs_[hand].buttons; + out.active = handActive_[hand] && (handLocations_[hand].locationFlags & tracked) == tracked; + } + env_->CallVoidMethod(app_->activity->clazz, hostFrameCallback_); + if (env_->ExceptionCheck()) { + env_->ExceptionDescribe(); env_->ExceptionClear(); + hostControl_ = {}; + return; + } + if (hostControl_.version != DROIDDECK_XR_HOST_VERSION) { hostControl_ = {}; return; } + for (int hand = 0; hand < 2; hand++) { + const auto &control = hostControl_.hands[hand]; + if (control.mask & DROIDDECK_XR_HOST_MASK_INPUT) { + inputs_[hand].trigger = 0; inputs_[hand].squeeze = 0; + inputs_[hand].stick[0] = inputs_[hand].stick[1] = 0; + inputs_[hand].buttons = 0; + } + const auto &pulse = control.haptic; + if (pulse.id == hostPulse_[hand]) continue; + hostPulse_[hand] = pulse.id; + if (state_ != XR_SESSION_STATE_FOCUSED || !handActive_[hand] + || pulse.duration_ns < 1000000 || pulse.duration_ns > 1000000000 + || !std::isfinite(pulse.amplitude) || pulse.amplitude < 0 || pulse.amplitude > 1 + || !std::isfinite(pulse.frequency) || pulse.frequency < 0) continue; + XrHapticActionInfo info{XR_TYPE_HAPTIC_ACTION_INFO}; info.action = vibration_; info.subactionPath = hands_[hand]; + XrHapticVibration vibration{XR_TYPE_HAPTIC_VIBRATION}; + vibration.duration = pulse.duration_ns; vibration.amplitude = pulse.amplitude; vibration.frequency = pulse.frequency; + check(xrApplyHapticFeedback(session_, &info, reinterpret_cast(&vibration)), "host haptics"); } } @@ -746,11 +1027,17 @@ private: munmap(tracking_, sizeof(DroidDeckXrTracking)); } if (haptics_) munmap(haptics_, sizeof(DroidDeckXrHaptics)); + g_runtime = nullptr; + hostBuffers_ = false; if (display_ != EGL_NO_DISPLAY && context_ != EGL_NO_CONTEXT) { glDeleteFramebuffers(1, &framebuffer_); glDeleteVertexArrays(1, &vertexArray_); glDeleteTextures(1, &cpuTexture_); glDeleteProgram(sourceProgram_); + glDeleteRenderbuffers(2, overlayDepth_); + overlay_.destroy(); } + if (env_) for (int index = 0; index < DROIDDECK_XR_HOST_LAYERS; index++) destroyLayer(env_, index); for (auto &eye : eyes_) if (eye.swapchain) xrDestroySwapchain(eye.swapchain); + for (auto &eye : overlayEyes_) if (eye.swapchain) xrDestroySwapchain(eye.swapchain); for (auto space : handSpaces_) if (space) xrDestroySpace(space); if (view_) xrDestroySpace(view_); if (world_) xrDestroySpace(world_); if (session_) xrDestroySession(session_); @@ -766,6 +1053,26 @@ private: } }; +extern "C" JNIEXPORT jint JNICALL +Java_com_droiddeck_launcher_QuestXrActivity_nativeCreateLayer(JNIEnv *env, jobject, jint width, jint height) { + return g_runtime ? g_runtime->createLayer(env, width, height) : -1; +} + +extern "C" JNIEXPORT jobject JNICALL +Java_com_droiddeck_launcher_QuestXrActivity_nativeLayerSurface(JNIEnv *env, jobject, jint index) { + return g_runtime ? g_runtime->layerSurface(env, index) : nullptr; +} + +extern "C" JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_QuestXrActivity_nativeDestroyLayer(JNIEnv *env, jobject, jint index) { + if (g_runtime) g_runtime->destroyLayer(env, index); +} + +extern "C" JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_QuestXrActivity_nativeSetOrbImage(JNIEnv *env, jobject, jobject bitmap) { + if (g_runtime) g_runtime->setOrbImage(env, bitmap); +} + void android_main(android_app *app) { QuestXR runtime(app); try { runtime.run(); } diff --git a/app/src/main/cpp/questxr/xr_host.h b/app/src/main/cpp/questxr/xr_host.h new file mode 100644 index 0000000000..9f08c32537 --- /dev/null +++ b/app/src/main/cpp/questxr/xr_host.h @@ -0,0 +1,91 @@ +#pragma once +#include +#include +#include "xr_tracking.h" + +// Shared with com.droiddeck.launcher.session.xr.XrHost, which reads and writes these through direct +// ByteBuffers by fixed offset: any layout change must bump the version and update both sides. +#define DROIDDECK_XR_HOST_VERSION 1u +#define DROIDDECK_XR_HOST_LAYERS 6 + +#define DROIDDECK_XR_HOST_SURFACE_SWAPCHAIN (1u << 0) +#define DROIDDECK_XR_HOST_FOCUSED (1u << 1) + +#define DROIDDECK_XR_HOST_MASK_INPUT (1u << 0) + +#define DROIDDECK_XR_HOST_LAYER_ALPHA (1u << 0) +#define DROIDDECK_XR_HOST_LAYER_HEAD_LOCKED (1u << 1) + +struct DroidDeckXrHostHand { + DroidDeckXrPose grip; + DroidDeckXrPose aim; + float trigger, squeeze, stick[2]; + uint32_t buttons, active; + uint32_t reserved[2]; +}; + +struct DroidDeckXrHostState { + uint32_t version, session_state, flags, reserved0; + int64_t frame, display_time_ns; + DroidDeckXrPose head; + DroidDeckXrHostHand hands[2]; + uint32_t reserved[8]; +}; + +struct DroidDeckXrHostHaptic { + uint64_t id; + int64_t duration_ns; + float amplitude, frequency; +}; + +struct DroidDeckXrHostHandControl { + uint32_t mask; + float laser; + DroidDeckXrHostHaptic haptic; + uint32_t reserved[2]; +}; + +struct DroidDeckXrHostOrb { + uint32_t visible; + float progress, burst, radius; + DroidDeckXrPose pose; +}; + +struct DroidDeckXrHostLayer { + int32_t id; + uint32_t visible, flags; + int32_t order; + DroidDeckXrPose pose; + float width, height; + uint32_t reserved[2]; +}; + +struct DroidDeckXrHostControl { + uint32_t version, reserved0; + DroidDeckXrHostHandControl hands[2]; + DroidDeckXrHostOrb orb; + DroidDeckXrHostLayer layers[DROIDDECK_XR_HOST_LAYERS]; + uint32_t reserved[8]; +}; + +static_assert(sizeof(DroidDeckXrHostHand) == 96, "XR host hand layout"); +static_assert(offsetof(DroidDeckXrHostHand, aim) == 32 && offsetof(DroidDeckXrHostHand, trigger) == 64 && + offsetof(DroidDeckXrHostHand, stick) == 72 && offsetof(DroidDeckXrHostHand, buttons) == 80 && + offsetof(DroidDeckXrHostHand, active) == 84, "XR host hand layout"); +static_assert(offsetof(DroidDeckXrHostState, flags) == 8 && offsetof(DroidDeckXrHostState, frame) == 16 && + offsetof(DroidDeckXrHostState, head) == 32, "XR host state layout"); +static_assert(offsetof(DroidDeckXrHostHandControl, laser) == 4 && offsetof(DroidDeckXrHostHandControl, haptic) == 8, + "XR host hand control layout"); +static_assert(offsetof(DroidDeckXrHostHaptic, duration_ns) == 8 && offsetof(DroidDeckXrHostHaptic, amplitude) == 16, + "XR host haptic layout"); +static_assert(offsetof(DroidDeckXrHostOrb, progress) == 4 && offsetof(DroidDeckXrHostOrb, pose) == 16, "XR host orb layout"); +static_assert(offsetof(DroidDeckXrHostLayer, order) == 12 && offsetof(DroidDeckXrHostLayer, pose) == 16 && + offsetof(DroidDeckXrHostLayer, width) == 48, "XR host layer layout"); +static_assert(sizeof(DroidDeckXrHostState) == 288, "XR host state layout"); +static_assert(offsetof(DroidDeckXrHostState, hands) == 64, "XR host state layout"); +static_assert(sizeof(DroidDeckXrHostHandControl) == 40, "XR host hand control layout"); +static_assert(sizeof(DroidDeckXrHostOrb) == 48, "XR host orb layout"); +static_assert(sizeof(DroidDeckXrHostLayer) == 64, "XR host layer layout"); +static_assert(offsetof(DroidDeckXrHostControl, orb) == 88, "XR host control layout"); +static_assert(offsetof(DroidDeckXrHostControl, layers) == 136, "XR host control layout"); +static_assert(sizeof(DroidDeckXrHostControl) == 552, "XR host control layout"); diff --git a/app/src/main/cpp/questxr/xr_overlay.h b/app/src/main/cpp/questxr/xr_overlay.h new file mode 100644 index 0000000000..5078e27b16 --- /dev/null +++ b/app/src/main/cpp/questxr/xr_overlay.h @@ -0,0 +1,229 @@ +#pragma once +#include +#include +#include +#include +#include +#include "xr_host.h" + +struct XrVec3 { float x, y, z; }; + +static inline XrVec3 xrv(float x, float y, float z) { return {x, y, z}; } +static inline XrVec3 operator+(XrVec3 a, XrVec3 b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; } +static inline XrVec3 operator-(XrVec3 a, XrVec3 b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; } +static inline XrVec3 operator*(XrVec3 a, float s) { return {a.x * s, a.y * s, a.z * s}; } +static inline float dot(XrVec3 a, XrVec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; } +static inline XrVec3 cross(XrVec3 a, XrVec3 b) { return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; } +static inline XrVec3 normalized(XrVec3 a) { + float length = std::sqrt(dot(a, a)); + return length > 1e-6f ? a * (1.f / length) : xrv(0, 0, 0); +} + +static inline XrVec3 rotate(const float q[4], XrVec3 v) { + XrVec3 u{q[0], q[1], q[2]}; + float s = q[3]; + return u * (2.f * dot(u, v)) + v * (s * s - dot(u, u)) + cross(u, v) * (2.f * s); +} + +class XrOverlay { +public: + void initialize() { + GLuint vertex = compile(GL_VERTEX_SHADER, + "#version 300 es\nlayout(location=0) in vec3 position; layout(location=1) in vec2 coordinate;" + "uniform mat4 viewProjection; out vec2 uv;" + "void main(){uv=coordinate;gl_Position=viewProjection*vec4(position,1.0);}"); + GLuint fragment = compile(GL_FRAGMENT_SHADER, + "#version 300 es\nprecision highp float; in vec2 uv; uniform int mode; uniform float progress, burst, time;" + "uniform vec3 color; uniform sampler2D logo; uniform int hasLogo; out vec4 outputColor;" + "void main(){" + " if(mode==0){float across=1.0-abs(uv.y); float a=smoothstep(0.0,0.7,across)*mix(0.95,0.35,uv.x);" + " outputColor=vec4(color*a,a);return;}" + " if(mode==1){float r=length(uv); float a=1.0-smoothstep(0.55,1.0,r); outputColor=vec4(vec3(1.0)*a,a);return;}" + " float r=length(uv); vec3 c=vec3(0.0); float a=0.0;" + " float pulse=0.5+0.5*sin(time*6.0);" + " float glow=exp(-pow(max(r-0.45,0.0)*6.0,2.0))*(0.25+0.2*pulse)*step(0.5,r); c+=color*glow; a=max(a,glow*0.7);" + " if(hasLogo==1&&r<0.52){vec4 l=texture(logo,vec2(0.5+uv.x/1.04,0.5-uv.y/1.04)); c=c*(1.0-l.a)+l.rgb; a=a*(1.0-l.a)+l.a;}" + " else if(r<0.5){float core=1.0-smoothstep(0.46,0.5,r); c+=color*core; a=max(a,core);}" + " float angle=atan(uv.x,uv.y); float sweep=(angle<0.0?angle+6.2831853:angle)/6.2831853;" + " float band=1.0-smoothstep(0.0,0.03,abs(r-0.64));" + " float track=band*0.25; float fill=band*step(sweep,progress);" + " c+=vec3(1.0)*track+color*fill*1.4; a=max(a,max(track,fill));" + " if(burst>0.0){float ring=(1.0-smoothstep(0.0,0.06,abs(r-(0.64+burst*0.3))))*(1.0-burst); c+=color*ring*2.0; a=max(a,ring);}" + " a=clamp(a,0.0,1.0); outputColor=vec4(c*a,a);" + "}"); + program_ = glCreateProgram(); + glAttachShader(program_, vertex); glAttachShader(program_, fragment); + glLinkProgram(program_); glDeleteShader(vertex); glDeleteShader(fragment); + GLint linked = 0; glGetProgramiv(program_, GL_LINK_STATUS, &linked); + if (!linked) throw std::runtime_error("Overlay shader link failed"); + viewProjection_ = glGetUniformLocation(program_, "viewProjection"); + mode_ = glGetUniformLocation(program_, "mode"); + progress_ = glGetUniformLocation(program_, "progress"); + burst_ = glGetUniformLocation(program_, "burst"); + time_ = glGetUniformLocation(program_, "time"); + color_ = glGetUniformLocation(program_, "color"); + logoSampler_ = glGetUniformLocation(program_, "logo"); + hasLogo_ = glGetUniformLocation(program_, "hasLogo"); + glGenVertexArrays(1, &vertexArray_); + glGenBuffers(1, &buffer_); + glBindVertexArray(vertexArray_); + glBindBuffer(GL_ARRAY_BUFFER, buffer_); + glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 5 * 6, nullptr, GL_DYNAMIC_DRAW); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 5, nullptr); + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 5, reinterpret_cast(sizeof(float) * 3)); + glBindVertexArray(0); + } + + /** [pixels] are premultiplied RGBA rows, top row first, as an Android ARGB_8888 bitmap holds them. */ + void setLogo(const void *pixels, int width, int height, int stride) { + if (!logo_) glGenTextures(1, &logo_); + glBindTexture(GL_TEXTURE_2D, logo_); + glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / 4); + glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glGenerateMipmap(GL_TEXTURE_2D); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + + void destroy() { + if (logo_) glDeleteTextures(1, &logo_); + logo_ = 0; + if (program_) glDeleteProgram(program_); + if (buffer_) glDeleteBuffers(1, &buffer_); + if (vertexArray_) glDeleteVertexArrays(1, &vertexArray_); + program_ = buffer_ = vertexArray_ = 0; + } + + static bool active(const DroidDeckXrHostControl &control) { + return control.orb.visible || control.hands[0].laser > 0.f || control.hands[1].laser > 0.f; + } + + void draw(const XrPosef &eye, const XrFovf &fov, const DroidDeckXrHostControl &control, + const DroidDeckXrHostState &state, float seconds) { + if (!active(control)) return; + float matrix[16]; + viewProjectionOf(eye, fov, matrix); + const float eyeOrientation[4] = {eye.orientation.x, eye.orientation.y, eye.orientation.z, eye.orientation.w}; + const XrVec3 eyePosition{eye.position.x, eye.position.y, eye.position.z}; + glUseProgram(program_); + glUniformMatrix4fv(viewProjection_, 1, GL_FALSE, matrix); + glUniform3f(color_, 0.12f, 0.62f, 1.0f); + glUniform1f(time_, seconds); + glBindVertexArray(vertexArray_); + glBindBuffer(GL_ARRAY_BUFFER, buffer_); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glDepthMask(GL_TRUE); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + glDisable(GL_BLEND); + glUniform1i(mode_, 0); + for (const auto &layer : control.layers) { + if (!layer.visible || !(layer.width > 0.f) || !(layer.height > 0.f)) continue; + if (layer.flags & DROIDDECK_XR_HOST_LAYER_HEAD_LOCKED) continue; + XrVec3 center{layer.pose.position[0], layer.pose.position[1], layer.pose.position[2]}; + XrVec3 right = rotate(layer.pose.orientation, xrv(layer.width / 2.f, 0, 0)); + XrVec3 up = rotate(layer.pose.orientation, xrv(0, layer.height / 2.f, 0)); + quad(center - right - up, center + right - up, center - right + up, center + right + up, 0.f, 1.f); + } + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + for (int hand = 0; hand < 2; hand++) { + float length = control.hands[hand].laser; + if (!(length > 0.f) || !state.hands[hand].active) continue; + const auto &aim = state.hands[hand].aim; + XrVec3 start{aim.position[0], aim.position[1], aim.position[2]}; + XrVec3 direction = normalized(rotate(aim.orientation, xrv(0, 0, -1))); + XrVec3 end = start + direction * std::max(length - 0.004f, 0.f); + XrVec3 side = normalized(cross(direction, eyePosition - start)) * 0.0022f; + glUniform1i(mode_, 0); + quad(start - side, start + side, end - side, end + side, 0.f, 1.f); + XrVec3 right = rotate(eyeOrientation, xrv(1, 0, 0)) * 0.007f; + XrVec3 up = rotate(eyeOrientation, xrv(0, 1, 0)) * 0.007f; + glUniform1i(mode_, 1); + billboard(end + normalized(eyePosition - end) * 0.008f, right, up); + } + if (control.orb.visible) { + const auto &pose = control.orb.pose; + XrVec3 center{pose.position[0], pose.position[1], pose.position[2]}; + float size = control.orb.radius * 1.25f; + XrVec3 right = rotate(eyeOrientation, xrv(1, 0, 0)) * size; + XrVec3 up = rotate(eyeOrientation, xrv(0, 1, 0)) * size; + glUniform1i(mode_, 2); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, logo_); + glUniform1i(logoSampler_, 0); + glUniform1i(hasLogo_, logo_ ? 1 : 0); + glUniform1f(progress_, control.orb.progress); + glUniform1f(burst_, control.orb.burst); + billboard(center, right, up); + } + glBindVertexArray(0); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_TRUE); + } + +private: + GLuint program_ = 0, buffer_ = 0, vertexArray_ = 0, logo_ = 0; + GLint viewProjection_ = -1, mode_ = -1, progress_ = -1, burst_ = -1, time_ = -1, color_ = -1; + GLint logoSampler_ = -1, hasLogo_ = -1; + + static GLuint compile(GLenum type, const char *text) { + GLuint handle = glCreateShader(type); + glShaderSource(handle, 1, &text, nullptr); glCompileShader(handle); + GLint success = 0; glGetShaderiv(handle, GL_COMPILE_STATUS, &success); + if (!success) { glDeleteShader(handle); throw std::runtime_error("Overlay shader compile failed"); } + return handle; + } + + void billboard(XrVec3 center, XrVec3 right, XrVec3 up) { + quadUv(center - right - up, center + right - up, center - right + up, center + right + up); + } + + void quad(XrVec3 a0, XrVec3 a1, XrVec3 b0, XrVec3 b1, float from, float to) { + const float vertices[] = { + a0.x, a0.y, a0.z, from, -1, a1.x, a1.y, a1.z, from, 1, b0.x, b0.y, b0.z, to, -1, + b0.x, b0.y, b0.z, to, -1, a1.x, a1.y, a1.z, from, 1, b1.x, b1.y, b1.z, to, 1}; + glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); + glDrawArrays(GL_TRIANGLES, 0, 6); + } + + void quadUv(XrVec3 bottomLeft, XrVec3 bottomRight, XrVec3 topLeft, XrVec3 topRight) { + const float vertices[] = { + bottomLeft.x, bottomLeft.y, bottomLeft.z, -1, -1, bottomRight.x, bottomRight.y, bottomRight.z, 1, -1, + topLeft.x, topLeft.y, topLeft.z, -1, 1, topLeft.x, topLeft.y, topLeft.z, -1, 1, + bottomRight.x, bottomRight.y, bottomRight.z, 1, -1, topRight.x, topRight.y, topRight.z, 1, 1}; + glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); + glDrawArrays(GL_TRIANGLES, 0, 6); + } + + static void viewProjectionOf(const XrPosef &pose, const XrFovf &fov, float out[16]) { + const float q[4] = {pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w}; + XrVec3 xAxis = rotate(q, xrv(1, 0, 0)), yAxis = rotate(q, xrv(0, 1, 0)), zAxis = rotate(q, xrv(0, 0, 1)); + XrVec3 position{pose.position.x, pose.position.y, pose.position.z}; + float view[16] = { + xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, + -dot(xAxis, position), -dot(yAxis, position), -dot(zAxis, position), 1}; + const float nearZ = 0.05f, farZ = 100.f; + float left = std::tan(fov.angleLeft), right = std::tan(fov.angleRight); + float up = std::tan(fov.angleUp), down = std::tan(fov.angleDown); + float width = right - left, height = up - down; + float projection[16] = { + 2.f / width, 0, 0, 0, 0, 2.f / height, 0, 0, + (right + left) / width, (up + down) / height, -(farZ + nearZ) / (farZ - nearZ), -1, + 0, 0, -2.f * farZ * nearZ / (farZ - nearZ), 0}; + for (int column = 0; column < 4; column++) + for (int row = 0; row < 4; row++) { + float sum = 0; + for (int k = 0; k < 4; k++) sum += projection[k * 4 + row] * view[column * 4 + k]; + out[column * 4 + row] = sum; + } + } +}; diff --git a/app/src/main/cpp/sdnative/sdnative.c b/app/src/main/cpp/sdnative/sdnative.c index 85e0793b10..8482f38d33 100644 --- a/app/src/main/cpp/sdnative/sdnative.c +++ b/app/src/main/cpp/sdnative/sdnative.c @@ -1,6 +1,10 @@ #include +#include #include +#include +#include #include +#include #include #include @@ -11,9 +15,29 @@ Java_com_droiddeck_launcher_input_FakeInputWriter_nativeStoreFence(JNIEnv *env, atomic_thread_fence(memory_order_release); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_input_FakeInputWriter_nativeWake(JNIEnv *env, jclass clazz, jobject buffer, jint offset) { + (void)clazz; + uint8_t *base = (*env)->GetDirectBufferAddress(env, buffer); + if (base) syscall(SYS_futex, base + offset, FUTEX_WAKE, INT_MAX, NULL, NULL, 0); +} + JNIEXPORT jint JNICALL Java_com_droiddeck_launcher_session_ThreadSignals_tgkill(JNIEnv *env, jclass clazz, jint tgid, jint tid, jint signal) { (void)env; (void)clazz; return syscall(SYS_tgkill, tgid, tid, signal) == 0 ? 0 : errno; } + +JNIEXPORT jint JNICALL +Java_com_droiddeck_launcher_session_PageCacheNative_fadviseDontNeed(JNIEnv *env, jclass clazz, jstring path) { + (void)clazz; + const char *chars = (*env)->GetStringUTFChars(env, path, NULL); + if (!chars) return ENOMEM; + int fd = open(chars, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); + (*env)->ReleaseStringUTFChars(env, path, chars); + if (fd < 0) return errno; + int rc = posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); + close(fd); + return rc; +} diff --git a/app/src/main/cpp/shaders/SMAA.hlsl b/app/src/main/cpp/shaders/SMAA.hlsl new file mode 100644 index 0000000000..d955d52401 --- /dev/null +++ b/app/src/main/cpp/shaders/SMAA.hlsl @@ -0,0 +1,1361 @@ +/** + * Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) + * Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com) + * Copyright (C) 2013 Belen Masia (bmasia@unizar.es) + * Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com) + * Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to + * do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. As clarification, there + * is no requirement that the copyright notice and permission be included in + * binary distributions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +/** + * _______ ___ ___ ___ ___ + * / || \/ | / \ / \ + * | (---- | \ / | / ^ \ / ^ \ + * \ \ | |\/| | / /_\ \ / /_\ \ + * ----) | | | | | / _____ \ / _____ \ + * |_______/ |__| |__| /__/ \__\ /__/ \__\ + * + * E N H A N C E D + * S U B P I X E L M O R P H O L O G I C A L A N T I A L I A S I N G + * + * http://www.iryoku.com/smaa/ + * + * Hi, welcome aboard! + * + * Here you'll find instructions to get the shader up and running as fast as + * possible. + * + * IMPORTANTE NOTICE: when updating, remember to update both this file and the + * precomputed textures! They may change from version to version. + * + * The shader has three passes, chained together as follows: + * + * |input|------------------· + * v | + * [ SMAA*EdgeDetection ] | + * v | + * |edgesTex| | + * v | + * [ SMAABlendingWeightCalculation ] | + * v | + * |blendTex| | + * v | + * [ SMAANeighborhoodBlending ] <------· + * v + * |output| + * + * Note that each [pass] has its own vertex and pixel shader. Remember to use + * oversized triangles instead of quads to avoid overshading along the + * diagonal. + * + * You've three edge detection methods to choose from: luma, color or depth. + * They represent different quality/performance and anti-aliasing/sharpness + * tradeoffs, so our recommendation is for you to choose the one that best + * suits your particular scenario: + * + * - Depth edge detection is usually the fastest but it may miss some edges. + * + * - Luma edge detection is usually more expensive than depth edge detection, + * but catches visible edges that depth edge detection can miss. + * + * - Color edge detection is usually the most expensive one but catches + * chroma-only edges. + * + * For quickstarters: just use luma edge detection. + * + * The general advice is to not rush the integration process and ensure each + * step is done correctly (don't try to integrate SMAA T2x with predicated edge + * detection from the start!). Ok then, let's go! + * + * 1. The first step is to create two RGBA temporal render targets for holding + * |edgesTex| and |blendTex|. + * + * In DX10 or DX11, you can use a RG render target for the edges texture. + * In the case of NVIDIA GPUs, using RG render targets seems to actually be + * slower. + * + * On the Xbox 360, you can use the same render target for resolving both + * |edgesTex| and |blendTex|, as they aren't needed simultaneously. + * + * 2. Both temporal render targets |edgesTex| and |blendTex| must be cleared + * each frame. Do not forget to clear the alpha channel! + * + * 3. The next step is loading the two supporting precalculated textures, + * 'areaTex' and 'searchTex'. You'll find them in the 'Textures' folder as + * C++ headers, and also as regular DDS files. They'll be needed for the + * 'SMAABlendingWeightCalculation' pass. + * + * If you use the C++ headers, be sure to load them in the format specified + * inside of them. + * + * You can also compress 'areaTex' and 'searchTex' using BC5 and BC4 + * respectively, if you have that option in your content processor pipeline. + * When compressing then, you get a non-perceptible quality decrease, and a + * marginal performance increase. + * + * 4. All samplers must be set to linear filtering and clamp. + * + * After you get the technique working, remember that 64-bit inputs have + * half-rate linear filtering on GCN. + * + * If SMAA is applied to 64-bit color buffers, switching to point filtering + * when accesing them will increase the performance. Search for + * 'SMAASamplePoint' to see which textures may benefit from point + * filtering, and where (which is basically the color input in the edge + * detection and resolve passes). + * + * 5. All texture reads and buffer writes must be non-sRGB, with the exception + * of the input read and the output write in + * 'SMAANeighborhoodBlending' (and only in this pass!). If sRGB reads in + * this last pass are not possible, the technique will work anyway, but + * will perform antialiasing in gamma space. + * + * IMPORTANT: for best results the input read for the color/luma edge + * detection should *NOT* be sRGB. + * + * 6. Before including SMAA.h you'll have to setup the render target metrics, + * the target and any optional configuration defines. Optionally you can + * use a preset. + * + * You have the following targets available: + * SMAA_HLSL_3 + * SMAA_HLSL_4 + * SMAA_HLSL_4_1 + * SMAA_GLSL_3 * + * SMAA_GLSL_4 * + * + * * (See SMAA_INCLUDE_VS and SMAA_INCLUDE_PS below). + * + * And four presets: + * SMAA_PRESET_LOW (%60 of the quality) + * SMAA_PRESET_MEDIUM (%80 of the quality) + * SMAA_PRESET_HIGH (%95 of the quality) + * SMAA_PRESET_ULTRA (%99 of the quality) + * + * For example: + * #define SMAA_RT_METRICS float4(1.0 / 1280.0, 1.0 / 720.0, 1280.0, 720.0) + * #define SMAA_HLSL_4 + * #define SMAA_PRESET_HIGH + * #include "SMAA.h" + * + * Note that SMAA_RT_METRICS doesn't need to be a macro, it can be a + * uniform variable. The code is designed to minimize the impact of not + * using a constant value, but it is still better to hardcode it. + * + * Depending on how you encoded 'areaTex' and 'searchTex', you may have to + * add (and customize) the following defines before including SMAA.h: + * #define SMAA_AREATEX_SELECT(sample) sample.rg + * #define SMAA_SEARCHTEX_SELECT(sample) sample.r + * + * If your engine is already using porting macros, you can define + * SMAA_CUSTOM_SL, and define the porting functions by yourself. + * + * 7. Then, you'll have to setup the passes as indicated in the scheme above. + * You can take a look into SMAA.fx, to see how we did it for our demo. + * Checkout the function wrappers, you may want to copy-paste them! + * + * 8. It's recommended to validate the produced |edgesTex| and |blendTex|. + * You can use a screenshot from your engine to compare the |edgesTex| + * and |blendTex| produced inside of the engine with the results obtained + * with the reference demo. + * + * 9. After you get the last pass to work, it's time to optimize. You'll have + * to initialize a stencil buffer in the first pass (discard is already in + * the code), then mask execution by using it the second pass. The last + * pass should be executed in all pixels. + * + * + * After this point you can choose to enable predicated thresholding, + * temporal supersampling and motion blur integration: + * + * a) If you want to use predicated thresholding, take a look into + * SMAA_PREDICATION; you'll need to pass an extra texture in the edge + * detection pass. + * + * b) If you want to enable temporal supersampling (SMAA T2x): + * + * 1. The first step is to render using subpixel jitters. I won't go into + * detail, but it's as simple as moving each vertex position in the + * vertex shader, you can check how we do it in our DX10 demo. + * + * 2. Then, you must setup the temporal resolve. You may want to take a look + * into SMAAResolve for resolving 2x modes. After you get it working, you'll + * probably see ghosting everywhere. But fear not, you can enable the + * CryENGINE temporal reprojection by setting the SMAA_REPROJECTION macro. + * Check out SMAA_DECODE_VELOCITY if your velocity buffer is encoded. + * + * 3. The next step is to apply SMAA to each subpixel jittered frame, just as + * done for 1x. + * + * 4. At this point you should already have something usable, but for best + * results the proper area textures must be set depending on current jitter. + * For this, the parameter 'subsampleIndices' of + * 'SMAABlendingWeightCalculationPS' must be set as follows, for our T2x + * mode: + * + * @SUBSAMPLE_INDICES + * + * | S# | Camera Jitter | subsampleIndices | + * +----+------------------+---------------------+ + * | 0 | ( 0.25, -0.25) | float4(1, 1, 1, 0) | + * | 1 | (-0.25, 0.25) | float4(2, 2, 2, 0) | + * + * These jitter positions assume a bottom-to-top y axis. S# stands for the + * sample number. + * + * More information about temporal supersampling here: + * http://iryoku.com/aacourse/downloads/13-Anti-Aliasing-Methods-in-CryENGINE-3.pdf + * + * c) If you want to enable spatial multisampling (SMAA S2x): + * + * 1. The scene must be rendered using MSAA 2x. The MSAA 2x buffer must be + * created with: + * - DX10: see below (*) + * - DX10.1: D3D10_STANDARD_MULTISAMPLE_PATTERN or + * - DX11: D3D11_STANDARD_MULTISAMPLE_PATTERN + * + * This allows to ensure that the subsample order matches the table in + * @SUBSAMPLE_INDICES. + * + * (*) In the case of DX10, we refer the reader to: + * - SMAA::detectMSAAOrder and + * - SMAA::msaaReorder + * + * These functions allow to match the standard multisample patterns by + * detecting the subsample order for a specific GPU, and reordering + * them appropriately. + * + * 2. A shader must be run to output each subsample into a separate buffer + * (DX10 is required). You can use SMAASeparate for this purpose, or just do + * it in an existing pass (for example, in the tone mapping pass, which has + * the advantage of feeding tone mapped subsamples to SMAA, which will yield + * better results). + * + * 3. The full SMAA 1x pipeline must be run for each separated buffer, storing + * the results in the final buffer. The second run should alpha blend with + * the existing final buffer using a blending factor of 0.5. + * 'subsampleIndices' must be adjusted as in the SMAA T2x case (see point + * b). + * + * d) If you want to enable temporal supersampling on top of SMAA S2x + * (which actually is SMAA 4x): + * + * 1. SMAA 4x consists on temporally jittering SMAA S2x, so the first step is + * to calculate SMAA S2x for current frame. In this case, 'subsampleIndices' + * must be set as follows: + * + * | F# | S# | Camera Jitter | Net Jitter | subsampleIndices | + * +----+----+--------------------+-------------------+----------------------+ + * | 0 | 0 | ( 0.125, 0.125) | ( 0.375, -0.125) | float4(5, 3, 1, 3) | + * | 0 | 1 | ( 0.125, 0.125) | (-0.125, 0.375) | float4(4, 6, 2, 3) | + * +----+----+--------------------+-------------------+----------------------+ + * | 1 | 2 | (-0.125, -0.125) | ( 0.125, -0.375) | float4(3, 5, 1, 4) | + * | 1 | 3 | (-0.125, -0.125) | (-0.375, 0.125) | float4(6, 4, 2, 4) | + * + * These jitter positions assume a bottom-to-top y axis. F# stands for the + * frame number. S# stands for the sample number. + * + * 2. After calculating SMAA S2x for current frame (with the new subsample + * indices), previous frame must be reprojected as in SMAA T2x mode (see + * point b). + * + * e) If motion blur is used, you may want to do the edge detection pass + * together with motion blur. This has two advantages: + * + * 1. Pixels under heavy motion can be omitted from the edge detection process. + * For these pixels we can just store "no edge", as motion blur will take + * care of them. + * 2. The center pixel tap is reused. + * + * Note that in this case depth testing should be used instead of stenciling, + * as we have to write all the pixels in the motion blur pass. + * + * That's it! + */ + +//----------------------------------------------------------------------------- +// SMAA Presets + +/** + * Note that if you use one of these presets, the following configuration + * macros will be ignored if set in the "Configurable Defines" section. + */ + +#if defined(SMAA_PRESET_LOW) +#define SMAA_THRESHOLD 0.15 +#define SMAA_MAX_SEARCH_STEPS 4 +#define SMAA_DISABLE_DIAG_DETECTION +#define SMAA_DISABLE_CORNER_DETECTION +#elif defined(SMAA_PRESET_MEDIUM) +#define SMAA_THRESHOLD 0.1 +#define SMAA_MAX_SEARCH_STEPS 8 +#define SMAA_DISABLE_DIAG_DETECTION +#define SMAA_DISABLE_CORNER_DETECTION +#elif defined(SMAA_PRESET_HIGH) +#define SMAA_THRESHOLD 0.1 +#define SMAA_MAX_SEARCH_STEPS 16 +#define SMAA_MAX_SEARCH_STEPS_DIAG 8 +#define SMAA_CORNER_ROUNDING 25 +#elif defined(SMAA_PRESET_ULTRA) +#define SMAA_THRESHOLD 0.05 +#define SMAA_MAX_SEARCH_STEPS 32 +#define SMAA_MAX_SEARCH_STEPS_DIAG 16 +#define SMAA_CORNER_ROUNDING 25 +#endif + +//----------------------------------------------------------------------------- +// Configurable Defines + +/** + * SMAA_THRESHOLD specifies the threshold or sensitivity to edges. + * Lowering this value you will be able to detect more edges at the expense of + * performance. + * + * Range: [0, 0.5] + * 0.1 is a reasonable value, and allows to catch most visible edges. + * 0.05 is a rather overkill value, that allows to catch 'em all. + * + * If temporal supersampling is used, 0.2 could be a reasonable value, as low + * contrast edges are properly filtered by just 2x. + */ +#ifndef SMAA_THRESHOLD +#define SMAA_THRESHOLD 0.1 +#endif + +/** + * SMAA_DEPTH_THRESHOLD specifies the threshold for depth edge detection. + * + * Range: depends on the depth range of the scene. + */ +#ifndef SMAA_DEPTH_THRESHOLD +#define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD) +#endif + +/** + * SMAA_MAX_SEARCH_STEPS specifies the maximum steps performed in the + * horizontal/vertical pattern searches, at each side of the pixel. + * + * In number of pixels, it's actually the double. So the maximum line length + * perfectly handled by, for example 16, is 64 (by perfectly, we meant that + * longer lines won't look as good, but still antialiased). + * + * Range: [0, 112] + */ +#ifndef SMAA_MAX_SEARCH_STEPS +#define SMAA_MAX_SEARCH_STEPS 16 +#endif + +/** + * SMAA_MAX_SEARCH_STEPS_DIAG specifies the maximum steps performed in the + * diagonal pattern searches, at each side of the pixel. In this case we jump + * one pixel at time, instead of two. + * + * Range: [0, 20] + * + * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16 + * steps), but it can have a significant impact on older machines. + * + * Define SMAA_DISABLE_DIAG_DETECTION to disable diagonal processing. + */ +#ifndef SMAA_MAX_SEARCH_STEPS_DIAG +#define SMAA_MAX_SEARCH_STEPS_DIAG 8 +#endif + +/** + * SMAA_CORNER_ROUNDING specifies how much sharp corners will be rounded. + * + * Range: [0, 100] + * + * Define SMAA_DISABLE_CORNER_DETECTION to disable corner processing. + */ +#ifndef SMAA_CORNER_ROUNDING +#define SMAA_CORNER_ROUNDING 25 +#endif + +/** + * If there is an neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times + * bigger contrast than current edge, current edge will be discarded. + * + * This allows to eliminate spurious crossing edges, and is based on the fact + * that, if there is too much contrast in a direction, that will hide + * perceptually contrast in the other neighbors. + */ +#ifndef SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR +#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0 +#endif + +/** + * Predicated thresholding allows to better preserve texture details and to + * improve performance, by decreasing the number of detected edges using an + * additional buffer like the light accumulation buffer, object ids or even the + * depth buffer (the depth buffer usage may be limited to indoor or short range + * scenes). + * + * It locally decreases the luma or color threshold if an edge is found in an + * additional buffer (so the global threshold can be higher). + * + * This method was developed by Playstation EDGE MLAA team, and used in + * Killzone 3, by using the light accumulation buffer. More information here: + * http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx + */ +#ifndef SMAA_PREDICATION +#define SMAA_PREDICATION 0 +#endif + +/** + * Threshold to be used in the additional predication buffer. + * + * Range: depends on the input, so you'll have to find the magic number that + * works for you. + */ +#ifndef SMAA_PREDICATION_THRESHOLD +#define SMAA_PREDICATION_THRESHOLD 0.01 +#endif + +/** + * How much to scale the global threshold used for luma or color edge + * detection when using predication. + * + * Range: [1, 5] + */ +#ifndef SMAA_PREDICATION_SCALE +#define SMAA_PREDICATION_SCALE 2.0 +#endif + +/** + * How much to locally decrease the threshold. + * + * Range: [0, 1] + */ +#ifndef SMAA_PREDICATION_STRENGTH +#define SMAA_PREDICATION_STRENGTH 0.4 +#endif + +/** + * Temporal reprojection allows to remove ghosting artifacts when using + * temporal supersampling. We use the CryEngine 3 method which also introduces + * velocity weighting. This feature is of extreme importance for totally + * removing ghosting. More information here: + * http://iryoku.com/aacourse/downloads/13-Anti-Aliasing-Methods-in-CryENGINE-3.pdf + * + * Note that you'll need to setup a velocity buffer for enabling reprojection. + * For static geometry, saving the previous depth buffer is a viable + * alternative. + */ +#ifndef SMAA_REPROJECTION +#define SMAA_REPROJECTION 0 +#endif + +/** + * SMAA_REPROJECTION_WEIGHT_SCALE controls the velocity weighting. It allows to + * remove ghosting trails behind the moving object, which are not removed by + * just using reprojection. Using low values will exhibit ghosting, while using + * high values will disable temporal supersampling under motion. + * + * Behind the scenes, velocity weighting removes temporal supersampling when + * the velocity of the subsamples differs (meaning they are different objects). + * + * Range: [0, 80] + */ +#ifndef SMAA_REPROJECTION_WEIGHT_SCALE +#define SMAA_REPROJECTION_WEIGHT_SCALE 30.0 +#endif + +/** + * On some compilers, discard cannot be used in vertex shaders. Thus, they need + * to be compiled separately. + */ +#ifndef SMAA_INCLUDE_VS +#define SMAA_INCLUDE_VS 1 +#endif +#ifndef SMAA_INCLUDE_PS +#define SMAA_INCLUDE_PS 1 +#endif + +//----------------------------------------------------------------------------- +// Texture Access Defines + +#ifndef SMAA_AREATEX_SELECT +#if defined(SMAA_HLSL_3) +#define SMAA_AREATEX_SELECT(sample) sample.ra +#else +#define SMAA_AREATEX_SELECT(sample) sample.rg +#endif +#endif + +#ifndef SMAA_SEARCHTEX_SELECT +#define SMAA_SEARCHTEX_SELECT(sample) sample.r +#endif + +#ifndef SMAA_DECODE_VELOCITY +#define SMAA_DECODE_VELOCITY(sample) sample.rg +#endif + +//----------------------------------------------------------------------------- +// Non-Configurable Defines + +#define SMAA_AREATEX_MAX_DISTANCE 16 +#define SMAA_AREATEX_MAX_DISTANCE_DIAG 20 +#define SMAA_AREATEX_PIXEL_SIZE (1.0 / float2(160.0, 560.0)) +#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0) +#define SMAA_SEARCHTEX_SIZE float2(66.0, 33.0) +#define SMAA_SEARCHTEX_PACKED_SIZE float2(64.0, 16.0) +#define SMAA_CORNER_ROUNDING_NORM (float(SMAA_CORNER_ROUNDING) / 100.0) + +//----------------------------------------------------------------------------- +// Porting Functions + +#if defined(SMAA_HLSL_3) +#define SMAATexture2D(tex) sampler2D tex +#define SMAATexturePass2D(tex) tex +#define SMAASampleLevelZero(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) +#define SMAASampleLevelZeroPoint(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) +#define SMAASampleLevelZeroOffset(tex, coord, offset) tex2Dlod(tex, float4(coord + offset * SMAA_RT_METRICS.xy, 0.0, 0.0)) +#define SMAASample(tex, coord) tex2D(tex, coord) +#define SMAASamplePoint(tex, coord) tex2D(tex, coord) +#define SMAASampleOffset(tex, coord, offset) tex2D(tex, coord + offset * SMAA_RT_METRICS.xy) +#define SMAA_FLATTEN [flatten] +#define SMAA_BRANCH [branch] +#endif +#if defined(SMAA_HLSL_4) || defined(SMAA_HLSL_4_1) +SamplerState LinearSampler { Filter = MIN_MAG_LINEAR_MIP_POINT; AddressU = Clamp; AddressV = Clamp; }; +SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; }; +#define SMAATexture2D(tex) Texture2D tex +#define SMAATexturePass2D(tex) tex +#define SMAASampleLevelZero(tex, coord) tex.SampleLevel(LinearSampler, coord, 0) +#define SMAASampleLevelZeroPoint(tex, coord) tex.SampleLevel(PointSampler, coord, 0) +#define SMAASampleLevelZeroOffset(tex, coord, offset) tex.SampleLevel(LinearSampler, coord, 0, offset) +#define SMAASample(tex, coord) tex.Sample(LinearSampler, coord) +#define SMAASamplePoint(tex, coord) tex.Sample(PointSampler, coord) +#define SMAASampleOffset(tex, coord, offset) tex.Sample(LinearSampler, coord, offset) +#define SMAA_FLATTEN [flatten] +#define SMAA_BRANCH [branch] +#define SMAATexture2DMS2(tex) Texture2DMS tex +#define SMAALoad(tex, pos, sample) tex.Load(pos, sample) +#if defined(SMAA_HLSL_4_1) +#define SMAAGather(tex, coord) tex.Gather(LinearSampler, coord, 0) +#endif +#endif +#if defined(SMAA_GLSL_3) || defined(SMAA_GLSL_4) +#define SMAATexture2D(tex) sampler2D tex +#define SMAATexturePass2D(tex) tex +#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0) +#define SMAASampleLevelZeroPoint(tex, coord) textureLod(tex, coord, 0.0) +#define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodOffset(tex, coord, 0.0, offset) +#define SMAASample(tex, coord) texture(tex, coord) +#define SMAASamplePoint(tex, coord) texture(tex, coord) +#define SMAASampleOffset(tex, coord, offset) texture(tex, coord, offset) +#define SMAA_FLATTEN +#define SMAA_BRANCH +#define lerp(a, b, t) mix(a, b, t) +#define saturate(a) clamp(a, 0.0, 1.0) +#if defined(SMAA_GLSL_4) +#define mad(a, b, c) fma(a, b, c) +#define SMAAGather(tex, coord) textureGather(tex, coord) +#else +#define mad(a, b, c) (a * b + c) +#endif +#define float2 vec2 +#define float3 vec3 +#define float4 vec4 +#define int2 ivec2 +#define int3 ivec3 +#define int4 ivec4 +#define bool2 bvec2 +#define bool3 bvec3 +#define bool4 bvec4 +#endif + +#if !defined(SMAA_HLSL_3) && !defined(SMAA_HLSL_4) && !defined(SMAA_HLSL_4_1) && !defined(SMAA_GLSL_3) && !defined(SMAA_GLSL_4) && !defined(SMAA_CUSTOM_SL) +#error you must define the shading language: SMAA_HLSL_*, SMAA_GLSL_* or SMAA_CUSTOM_SL +#endif + +//----------------------------------------------------------------------------- +// Misc functions + +/** + * Gathers current pixel, and the top-left neighbors. + */ +float3 SMAAGatherNeighbours(float2 texcoord, + float4 offset[3], + SMAATexture2D(tex)) { + #ifdef SMAAGather + return SMAAGather(tex, texcoord + SMAA_RT_METRICS.xy * float2(-0.5, -0.5)).grb; + #else + float P = SMAASamplePoint(tex, texcoord).r; + float Pleft = SMAASamplePoint(tex, offset[0].xy).r; + float Ptop = SMAASamplePoint(tex, offset[0].zw).r; + return float3(P, Pleft, Ptop); + #endif +} + +/** + * Adjusts the threshold by means of predication. + */ +float2 SMAACalculatePredicatedThreshold(float2 texcoord, + float4 offset[3], + SMAATexture2D(predicationTex)) { + float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(predicationTex)); + float2 delta = abs(neighbours.xx - neighbours.yz); + float2 edges = step(SMAA_PREDICATION_THRESHOLD, delta); + return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * (1.0 - SMAA_PREDICATION_STRENGTH * edges); +} + +/** + * Conditional move: + */ +void SMAAMovc(bool2 cond, inout float2 variable, float2 value) { + SMAA_FLATTEN if (cond.x) variable.x = value.x; + SMAA_FLATTEN if (cond.y) variable.y = value.y; +} + +void SMAAMovc(bool4 cond, inout float4 variable, float4 value) { + SMAAMovc(cond.xy, variable.xy, value.xy); + SMAAMovc(cond.zw, variable.zw, value.zw); +} + + +#if SMAA_INCLUDE_VS +//----------------------------------------------------------------------------- +// Vertex Shaders + +/** + * Edge Detection Vertex Shader + */ +void SMAAEdgeDetectionVS(float2 texcoord, + out float4 offset[3]) { + offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, -1.0), texcoord.xyxy); + offset[1] = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, 1.0), texcoord.xyxy); + offset[2] = mad(SMAA_RT_METRICS.xyxy, float4(-2.0, 0.0, 0.0, -2.0), texcoord.xyxy); +} + +/** + * Blend Weight Calculation Vertex Shader + */ +void SMAABlendingWeightCalculationVS(float2 texcoord, + out float2 pixcoord, + out float4 offset[3]) { + pixcoord = texcoord * SMAA_RT_METRICS.zw; + + // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): + offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-0.25, -0.125, 1.25, -0.125), texcoord.xyxy); + offset[1] = mad(SMAA_RT_METRICS.xyxy, float4(-0.125, -0.25, -0.125, 1.25), texcoord.xyxy); + + // And these for the searches, they indicate the ends of the loops: + offset[2] = mad(SMAA_RT_METRICS.xxyy, + float4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS), + float4(offset[0].xz, offset[1].yw)); +} + +/** + * Neighborhood Blending Vertex Shader + */ +void SMAANeighborhoodBlendingVS(float2 texcoord, + out float4 offset) { + offset = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, 1.0), texcoord.xyxy); +} +#endif // SMAA_INCLUDE_VS + +#if SMAA_INCLUDE_PS +//----------------------------------------------------------------------------- +// Edge Detection Pixel Shaders (First Pass) + +/** + * Luma Edge Detection + * + * IMPORTANT NOTICE: luma edge detection requires gamma-corrected colors, and + * thus 'colorTex' should be a non-sRGB texture. + */ +float2 SMAALumaEdgeDetectionPS(float2 texcoord, + float4 offset[3], + SMAATexture2D(colorTex) + #if SMAA_PREDICATION + , SMAATexture2D(predicationTex) + #endif + ) { + // Calculate the threshold: + #if SMAA_PREDICATION + float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, SMAATexturePass2D(predicationTex)); + #else + float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD); + #endif + + // Calculate lumas: + float3 weights = float3(0.2126, 0.7152, 0.0722); + float L = dot(SMAASamplePoint(colorTex, texcoord).rgb, weights); + + float Lleft = dot(SMAASamplePoint(colorTex, offset[0].xy).rgb, weights); + float Ltop = dot(SMAASamplePoint(colorTex, offset[0].zw).rgb, weights); + + // We do the usual threshold: + float4 delta; + delta.xy = abs(L - float2(Lleft, Ltop)); + float2 edges = step(threshold, delta.xy); + + // Then discard if there is no edge: + if (dot(edges, float2(1.0, 1.0)) == 0.0) + discard; + + // Calculate right and bottom deltas: + float Lright = dot(SMAASamplePoint(colorTex, offset[1].xy).rgb, weights); + float Lbottom = dot(SMAASamplePoint(colorTex, offset[1].zw).rgb, weights); + delta.zw = abs(L - float2(Lright, Lbottom)); + + // Calculate the maximum delta in the direct neighborhood: + float2 maxDelta = max(delta.xy, delta.zw); + + // Calculate left-left and top-top deltas: + float Lleftleft = dot(SMAASamplePoint(colorTex, offset[2].xy).rgb, weights); + float Ltoptop = dot(SMAASamplePoint(colorTex, offset[2].zw).rgb, weights); + delta.zw = abs(float2(Lleft, Ltop) - float2(Lleftleft, Ltoptop)); + + // Calculate the final maximum delta: + maxDelta = max(maxDelta.xy, delta.zw); + float finalDelta = max(maxDelta.x, maxDelta.y); + + // Local contrast adaptation: + edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy); + + return edges; +} + +/** + * Color Edge Detection + * + * IMPORTANT NOTICE: color edge detection requires gamma-corrected colors, and + * thus 'colorTex' should be a non-sRGB texture. + */ +float2 SMAAColorEdgeDetectionPS(float2 texcoord, + float4 offset[3], + SMAATexture2D(colorTex) + #if SMAA_PREDICATION + , SMAATexture2D(predicationTex) + #endif + ) { + // Calculate the threshold: + #if SMAA_PREDICATION + float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, predicationTex); + #else + float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD); + #endif + + // Calculate color deltas: + float4 delta; + float3 C = SMAASamplePoint(colorTex, texcoord).rgb; + + float3 Cleft = SMAASamplePoint(colorTex, offset[0].xy).rgb; + float3 t = abs(C - Cleft); + delta.x = max(max(t.r, t.g), t.b); + + float3 Ctop = SMAASamplePoint(colorTex, offset[0].zw).rgb; + t = abs(C - Ctop); + delta.y = max(max(t.r, t.g), t.b); + + // We do the usual threshold: + float2 edges = step(threshold, delta.xy); + + // Then discard if there is no edge: + if (dot(edges, float2(1.0, 1.0)) == 0.0) + discard; + + // Calculate right and bottom deltas: + float3 Cright = SMAASamplePoint(colorTex, offset[1].xy).rgb; + t = abs(C - Cright); + delta.z = max(max(t.r, t.g), t.b); + + float3 Cbottom = SMAASamplePoint(colorTex, offset[1].zw).rgb; + t = abs(C - Cbottom); + delta.w = max(max(t.r, t.g), t.b); + + // Calculate the maximum delta in the direct neighborhood: + float2 maxDelta = max(delta.xy, delta.zw); + + // Calculate left-left and top-top deltas: + float3 Cleftleft = SMAASamplePoint(colorTex, offset[2].xy).rgb; + t = abs(C - Cleftleft); + delta.z = max(max(t.r, t.g), t.b); + + float3 Ctoptop = SMAASamplePoint(colorTex, offset[2].zw).rgb; + t = abs(C - Ctoptop); + delta.w = max(max(t.r, t.g), t.b); + + // Calculate the final maximum delta: + maxDelta = max(maxDelta.xy, delta.zw); + float finalDelta = max(maxDelta.x, maxDelta.y); + + // Local contrast adaptation: + edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy); + + return edges; +} + +/** + * Depth Edge Detection + */ +float2 SMAADepthEdgeDetectionPS(float2 texcoord, + float4 offset[3], + SMAATexture2D(depthTex)) { + float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(depthTex)); + float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z)); + float2 edges = step(SMAA_DEPTH_THRESHOLD, delta); + + if (dot(edges, float2(1.0, 1.0)) == 0.0) + discard; + + return edges; +} + +//----------------------------------------------------------------------------- +// Diagonal Search Functions + +#if !defined(SMAA_DISABLE_DIAG_DETECTION) + +/** + * Allows to decode two binary values from a bilinear-filtered access. + */ +float2 SMAADecodeDiagBilinearAccess(float2 e) { + // Bilinear access for fetching 'e' have a 0.25 offset, and we are + // interested in the R and G edges: + // + // +---G---+-------+ + // | x o R x | + // +-------+-------+ + // + // Then, if one of these edge is enabled: + // Red: (0.75 * X + 0.25 * 1) => 0.25 or 1.0 + // Green: (0.75 * 1 + 0.25 * X) => 0.75 or 1.0 + // + // This function will unpack the values (mad + mul + round): + // wolframalpha.com: round(x * abs(5 * x - 5 * 0.75)) plot 0 to 1 + e.r = e.r * abs(5.0 * e.r - 5.0 * 0.75); + return round(e); +} + +float4 SMAADecodeDiagBilinearAccess(float4 e) { + e.rb = e.rb * abs(5.0 * e.rb - 5.0 * 0.75); + return round(e); +} + +/** + * These functions allows to perform diagonal pattern searches. + */ +float2 SMAASearchDiag1(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) { + float4 coord = float4(texcoord, -1.0, 1.0); + float3 t = float3(SMAA_RT_METRICS.xy, 1.0); + while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && + coord.w > 0.9) { + coord.xyz = mad(t, float3(dir, 1.0), coord.xyz); + e = SMAASampleLevelZero(edgesTex, coord.xy).rg; + coord.w = dot(e, float2(0.5, 0.5)); + } + return coord.zw; +} + +float2 SMAASearchDiag2(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) { + float4 coord = float4(texcoord, -1.0, 1.0); + coord.x += 0.25 * SMAA_RT_METRICS.x; // See @SearchDiag2Optimization + float3 t = float3(SMAA_RT_METRICS.xy, 1.0); + while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && + coord.w > 0.9) { + coord.xyz = mad(t, float3(dir, 1.0), coord.xyz); + + // @SearchDiag2Optimization + // Fetch both edges at once using bilinear filtering: + e = SMAASampleLevelZero(edgesTex, coord.xy).rg; + e = SMAADecodeDiagBilinearAccess(e); + + // Non-optimized version: + // e.g = SMAASampleLevelZero(edgesTex, coord.xy).g; + // e.r = SMAASampleLevelZeroOffset(edgesTex, coord.xy, int2(1, 0)).r; + + coord.w = dot(e, float2(0.5, 0.5)); + } + return coord.zw; +} + +/** + * Similar to SMAAArea, this calculates the area corresponding to a certain + * diagonal distance and crossing edges 'e'. + */ +float2 SMAAAreaDiag(SMAATexture2D(areaTex), float2 dist, float2 e, float offset) { + float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE_DIAG, SMAA_AREATEX_MAX_DISTANCE_DIAG), e, dist); + + // We do a scale and bias for mapping to texel space: + texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE); + + // Diagonal areas are on the second half of the texture: + texcoord.x += 0.5; + + // Move to proper place, according to the subpixel offset: + texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset; + + // Do it! + return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord)); +} + +/** + * This searches for diagonal patterns and returns the corresponding weights. + */ +float2 SMAACalculateDiagWeights(SMAATexture2D(edgesTex), SMAATexture2D(areaTex), float2 texcoord, float2 e, float4 subsampleIndices) { + float2 weights = float2(0.0, 0.0); + + // Search for the line ends: + float4 d; + float2 end; + if (e.r > 0.0) { + d.xz = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, 1.0), end); + d.x += float(end.y > 0.9); + } else + d.xz = float2(0.0, 0.0); + d.yw = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, -1.0), end); + + SMAA_BRANCH + if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 + // Fetch the crossing edges: + float4 coords = mad(float4(-d.x + 0.25, d.x, d.y, -d.y - 0.25), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + float4 c; + c.xy = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).rg; + c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).rg; + c.yxwz = SMAADecodeDiagBilinearAccess(c.xyzw); + + // Non-optimized version: + // float4 coords = mad(float4(-d.x, d.x, d.y, -d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + // float4 c; + // c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; + // c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, 0)).r; + // c.z = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).g; + // c.w = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, -1)).r; + + // Merge crossing edges at each side into a single value: + float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw); + + // Remove the crossing edge if we didn't found the end of the line: + SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0)); + + // Fetch the areas for this line: + weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.z); + } + + // Search for the line ends: + d.xz = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, -1.0), end); + if (SMAASampleLevelZeroOffset(edgesTex, texcoord, int2(1, 0)).r > 0.0) { + d.yw = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, 1.0), end); + d.y += float(end.y > 0.9); + } else + d.yw = float2(0.0, 0.0); + + SMAA_BRANCH + if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 + // Fetch the crossing edges: + float4 coords = mad(float4(-d.x, -d.x, d.y, d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + float4 c; + c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; + c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, -1)).r; + c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).gr; + float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw); + + // Remove the crossing edge if we didn't found the end of the line: + SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0)); + + // Fetch the areas for this line: + weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.w).gr; + } + + return weights; +} +#endif + +//----------------------------------------------------------------------------- +// Horizontal/Vertical Search Functions + +/** + * This allows to determine how much length should we add in the last step + * of the searches. It takes the bilinearly interpolated edge (see + * @PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and + * crossing edges are active. + */ +float SMAASearchLength(SMAATexture2D(searchTex), float2 e, float offset) { + // The texture is flipped vertically, with left and right cases taking half + // of the space horizontally: + float2 scale = SMAA_SEARCHTEX_SIZE * float2(0.5, -1.0); + float2 bias = SMAA_SEARCHTEX_SIZE * float2(offset, 1.0); + + // Scale and bias to access texel centers: + scale += float2(-1.0, 1.0); + bias += float2( 0.5, -0.5); + + // Convert from pixel coordinates to texcoords: + // (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped) + scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; + bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; + + // Lookup the search texture: + return SMAA_SEARCHTEX_SELECT(SMAASampleLevelZero(searchTex, mad(scale, e, bias))); +} + +/** + * Horizontal/vertical search functions for the 2nd pass. + */ +float SMAASearchXLeft(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + /** + * @PSEUDO_GATHER4 + * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to + * sample between edge, thus fetching four edges in a row. + * Sampling with different offsets in each direction allows to disambiguate + * which edges are active from the four fetched ones. + */ + float2 e = float2(0.0, 1.0); + while (texcoord.x > end && + e.g > 0.8281 && // Is there some edge not activated? + e.r == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(-float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); + } + + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0), 3.25); + return mad(SMAA_RT_METRICS.x, offset, texcoord.x); + + // Non-optimized version: + // We correct the previous (-0.25, -0.125) offset we applied: + // texcoord.x += 0.25 * SMAA_RT_METRICS.x; + + // The searches are bias by 1, so adjust the coords accordingly: + // texcoord.x += SMAA_RT_METRICS.x; + + // Disambiguate the length added by the last step: + // texcoord.x += 2.0 * SMAA_RT_METRICS.x; // Undo last step + // texcoord.x -= SMAA_RT_METRICS.x * (255.0 / 127.0) * SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0); + // return mad(SMAA_RT_METRICS.x, offset, texcoord.x); +} + +float SMAASearchXRight(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + float2 e = float2(0.0, 1.0); + while (texcoord.x < end && + e.g > 0.8281 && // Is there some edge not activated? + e.r == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); + } + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.5), 3.25); + return mad(-SMAA_RT_METRICS.x, offset, texcoord.x); +} + +float SMAASearchYUp(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + float2 e = float2(1.0, 0.0); + while (texcoord.y > end && + e.r > 0.8281 && // Is there some edge not activated? + e.g == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(-float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); + } + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.0), 3.25); + return mad(SMAA_RT_METRICS.y, offset, texcoord.y); +} + +float SMAASearchYDown(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + float2 e = float2(1.0, 0.0); + while (texcoord.y < end && + e.r > 0.8281 && // Is there some edge not activated? + e.g == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); + } + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.5), 3.25); + return mad(-SMAA_RT_METRICS.y, offset, texcoord.y); +} + +/** + * Ok, we have the distance and both crossing edges. So, what are the areas + * at each side of current edge? + */ +float2 SMAAArea(SMAATexture2D(areaTex), float2 dist, float e1, float e2, float offset) { + // Rounding prevents precision errors of bilinear filtering: + float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE), round(4.0 * float2(e1, e2)), dist); + + // We do a scale and bias for mapping to texel space: + texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE); + + // Move to proper place, according to the subpixel offset: + texcoord.y = mad(SMAA_AREATEX_SUBTEX_SIZE, offset, texcoord.y); + + // Do it! + return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord)); +} + +//----------------------------------------------------------------------------- +// Corner Detection Functions + +void SMAADetectHorizontalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) { + #if !defined(SMAA_DISABLE_CORNER_DETECTION) + float2 leftRight = step(d.xy, d.yx); + float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight; + + rounding /= leftRight.x + leftRight.y; // Reduce blending for pixels in the center of a line. + + float2 factor = float2(1.0, 1.0); + factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, 1)).r; + factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, 1)).r; + factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, -2)).r; + factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, -2)).r; + + weights *= saturate(factor); + #endif +} + +void SMAADetectVerticalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) { + #if !defined(SMAA_DISABLE_CORNER_DETECTION) + float2 leftRight = step(d.xy, d.yx); + float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight; + + rounding /= leftRight.x + leftRight.y; + + float2 factor = float2(1.0, 1.0); + factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2( 1, 0)).g; + factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2( 1, 1)).g; + factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(-2, 0)).g; + factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(-2, 1)).g; + + weights *= saturate(factor); + #endif +} + +//----------------------------------------------------------------------------- +// Blending Weight Calculation Pixel Shader (Second Pass) + +float4 SMAABlendingWeightCalculationPS(float2 texcoord, + float2 pixcoord, + float4 offset[3], + SMAATexture2D(edgesTex), + SMAATexture2D(areaTex), + SMAATexture2D(searchTex), + float4 subsampleIndices) { // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES. + float4 weights = float4(0.0, 0.0, 0.0, 0.0); + + float2 e = SMAASample(edgesTex, texcoord).rg; + + SMAA_BRANCH + if (e.g > 0.0) { // Edge at north + #if !defined(SMAA_DISABLE_DIAG_DETECTION) + // Diagonals have both north and west edges, so searching for them in + // one of the boundaries is enough. + weights.rg = SMAACalculateDiagWeights(SMAATexturePass2D(edgesTex), SMAATexturePass2D(areaTex), texcoord, e, subsampleIndices); + + // We give priority to diagonals, so if we find a diagonal we skip + // horizontal/vertical processing. + SMAA_BRANCH + if (weights.r == -weights.g) { // weights.r + weights.g == 0.0 + #endif + + float2 d; + + // Find the distance to the left: + float3 coords; + coords.x = SMAASearchXLeft(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].xy, offset[2].x); + coords.y = offset[1].y; // offset[1].y = texcoord.y - 0.25 * SMAA_RT_METRICS.y (@CROSSING_OFFSET) + d.x = coords.x; + + // Now fetch the left crossing edges, two at a time using bilinear + // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to + // discern what value each edge has: + float e1 = SMAASampleLevelZero(edgesTex, coords.xy).r; + + // Find the distance to the right: + coords.z = SMAASearchXRight(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].zw, offset[2].y); + d.y = coords.z; + + // We want the distances to be in pixel units (doing this here allow to + // better interleave arithmetic and memory accesses): + d = abs(round(mad(SMAA_RT_METRICS.zz, d, -pixcoord.xx))); + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + float2 sqrt_d = sqrt(d); + + // Fetch the right crossing edges: + float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.zy, int2(1, 0)).r; + + // Ok, we know how this pattern looks like, now it is time for getting + // the actual area: + weights.rg = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.y); + + // Fix corners: + coords.y = texcoord.y; + SMAADetectHorizontalCornerPattern(SMAATexturePass2D(edgesTex), weights.rg, coords.xyzy, d); + + #if !defined(SMAA_DISABLE_DIAG_DETECTION) + } else + e.r = 0.0; // Skip vertical processing. + #endif + } + + SMAA_BRANCH + if (e.r > 0.0) { // Edge at west + float2 d; + + // Find the distance to the top: + float3 coords; + coords.y = SMAASearchYUp(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].xy, offset[2].z); + coords.x = offset[0].x; // offset[1].x = texcoord.x - 0.25 * SMAA_RT_METRICS.x; + d.x = coords.y; + + // Fetch the top crossing edges: + float e1 = SMAASampleLevelZero(edgesTex, coords.xy).g; + + // Find the distance to the bottom: + coords.z = SMAASearchYDown(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].zw, offset[2].w); + d.y = coords.z; + + // We want the distances to be in pixel units: + d = abs(round(mad(SMAA_RT_METRICS.ww, d, -pixcoord.yy))); + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + float2 sqrt_d = sqrt(d); + + // Fetch the bottom crossing edges: + float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.xz, int2(0, 1)).g; + + // Get the area for this direction: + weights.ba = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.x); + + // Fix corners: + coords.x = texcoord.x; + SMAADetectVerticalCornerPattern(SMAATexturePass2D(edgesTex), weights.ba, coords.xyxz, d); + } + + return weights; +} + +//----------------------------------------------------------------------------- +// Neighborhood Blending Pixel Shader (Third Pass) + +float4 SMAANeighborhoodBlendingPS(float2 texcoord, + float4 offset, + SMAATexture2D(colorTex), + SMAATexture2D(blendTex) + #if SMAA_REPROJECTION + , SMAATexture2D(velocityTex) + #endif + ) { + // Fetch the blending weights for current pixel: + float4 a; + a.x = SMAASample(blendTex, offset.xy).a; // Right + a.y = SMAASample(blendTex, offset.zw).g; // Top + a.wz = SMAASample(blendTex, texcoord).xz; // Bottom / Left + + // Is there any blending weight with a value greater than 0.0? + SMAA_BRANCH + if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) { + float4 color = SMAASampleLevelZero(colorTex, texcoord); + + #if SMAA_REPROJECTION + float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord)); + + // Pack velocity into the alpha channel: + color.a = sqrt(5.0 * length(velocity)); + #endif + + return color; + } else { + bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical) + + // Calculate the blending offsets: + float4 blendingOffset = float4(0.0, a.y, 0.0, a.w); + float2 blendingWeight = a.yw; + SMAAMovc(bool4(h, h, h, h), blendingOffset, float4(a.x, 0.0, a.z, 0.0)); + SMAAMovc(bool2(h, h), blendingWeight, a.xz); + blendingWeight /= dot(blendingWeight, float2(1.0, 1.0)); + + // Calculate the texture coordinates: + float4 blendingCoord = mad(blendingOffset, float4(SMAA_RT_METRICS.xy, -SMAA_RT_METRICS.xy), texcoord.xyxy); + + // We exploit bilinear filtering to mix current pixel with the chosen + // neighbor: + float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); + color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); + + #if SMAA_REPROJECTION + // Antialias velocity for proper reprojection in a later stage: + float2 velocity = blendingWeight.x * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.xy)); + velocity += blendingWeight.y * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.zw)); + + // Pack velocity into the alpha channel: + color.a = sqrt(5.0 * length(velocity)); + #endif + + return color; + } +} + +//----------------------------------------------------------------------------- +// Temporal Resolve Pixel Shader (Optional Pass) + +float4 SMAAResolvePS(float2 texcoord, + SMAATexture2D(currentColorTex), + SMAATexture2D(previousColorTex) + #if SMAA_REPROJECTION + , SMAATexture2D(velocityTex) + #endif + ) { + #if SMAA_REPROJECTION + // Velocity is assumed to be calculated for motion blur, so we need to + // inverse it for reprojection: + float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord).rg); + + // Fetch current pixel: + float4 current = SMAASamplePoint(currentColorTex, texcoord); + + // Reproject current coordinates and fetch previous pixel: + float4 previous = SMAASamplePoint(previousColorTex, texcoord + velocity); + + // Attenuate the previous pixel if the velocity is different: + float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0; + float weight = 0.5 * saturate(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE); + + // Blend the pixels according to the calculated weight: + return lerp(current, previous, weight); + #else + // Just blend the pixels: + float4 current = SMAASamplePoint(currentColorTex, texcoord); + float4 previous = SMAASamplePoint(previousColorTex, texcoord); + return lerp(current, previous, 0.5); + #endif +} + +//----------------------------------------------------------------------------- +// Separate Multisamples Pixel Shader (Optional Pass) + +#ifdef SMAALoad +void SMAASeparatePS(float4 position, + float2 texcoord, + out float4 target0, + out float4 target1, + SMAATexture2DMS2(colorTexMS)) { + int2 pos = int2(position.xy); + target0 = SMAALoad(colorTexMS, pos, 0); + target1 = SMAALoad(colorTexMS, pos, 1); +} +#endif + +//----------------------------------------------------------------------------- +#endif // SMAA_INCLUDE_PS diff --git a/app/src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt b/app/src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt new file mode 100644 index 0000000000..ffbc6b370b --- /dev/null +++ b/app/src/main/cpp/shaders/THIRD_PARTY_NOTICES.txt @@ -0,0 +1,156 @@ +Third-Party Notices — Graphics Shaders +====================================== + +AMD FidelityFX Super Resolution 1.0 (FSR 1.0) +---------------------------------------------- +The EASU (Edge-Adaptive Spatial Upsampling) and RCAS +(Robust Contrast-Adaptive Sharpening) shader implementations +are adapted from AMD's FidelityFX FSR 1.0 reference code. + +Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. + +SPDX-License-Identifier: MIT + +MIT License +----------- + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +NVIDIA Image Scaling (NIS) +-------------------------- +The NIS fragment shader is adapted from NVIDIA's NVIDIA Image Scaling +reference implementation, including NVScaler and NIS configuration code. + +Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +SPDX-License-Identifier: MIT + +The NIS luma prepass (nis_luma.frag), the gather-based NIS pass (nis3.frag) and its +coefficient banks (nis_coef.h) are from the same NVIDIA reference. + +AMD FidelityFX CAS (Contrast Adaptive Sharpening) +------------------------------------------------- +The CAS fragment shader (cas_ffx.frag) is ported from AMD's reference header +GPUOpen-Effects/FidelityFX-CAS ffx-cas/ffx_cas.h (v1.0.2). + +Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. + +SPDX-License-Identifier: MIT + +The MIT License text above applies to AMD FidelityFX FSR 1.0, AMD FidelityFX CAS and +NVIDIA Image Scaling (NIS). + +Snapdragon Game Super Resolution 1 (SGSR1) +------------------------------------------ +The SGSR fragment shaders are adapted from Qualcomm's reference GLSL +shaders, including the mobile and edge-direction variants. + +Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. + +SPDX-License-Identifier: BSD-3-Clause + +BSD 3-Clause License (SGSR1) +---------------------------- +Copyright (c) 2025, Qualcomm Innovation Center, 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: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. 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. + +3. Neither the name of the copyright holder 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 HOLDER 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. + +Upstream SGSR1 BSD 3-Clause License (2023) +---------------------------- +Copyright (c) 2023, Qualcomm Innovation Center, 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: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. 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. + +3. Neither the name of the copyright holder 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 HOLDER 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. + +SMAA (Enhanced Subpixel Morphological Antialiasing) +--------------------------------------------------- +SMAA.hlsl and the lookup tables in smaa_tables.h are from the authors' reference +implementation (github.com/iryoku/smaa). + +Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) +Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com) +Copyright (C) 2013 Belen Masia (bmasia@unizar.es) +Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com) +Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es) + +Permission is hereby granted, free of charge, to any person obtaining a copy +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. As clarification, there is no +requirement that the copyright notice and permission be included in binary +distributions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/app/src/main/cpp/shaders/cas.frag b/app/src/main/cpp/shaders/cas.frag new file mode 100644 index 0000000000..26c3adee9c --- /dev/null +++ b/app/src/main/cpp/shaders/cas.frag @@ -0,0 +1,68 @@ +#version 450 + +// ============================================================================= +// AMD FidelityFX CAS (Contrast-Adaptive Sharpening) - pure-CAS path. +// +// Ported from the OpenGL FSREffect.java MODE_SUPER_RESOLUTION shader so the +// Vulkan compositor's post-process pipeline applies the SAME sharpen the GL +// renderer's "Sharpen (CAS)" toggle does. Composable: layers on top of any +// scaling mode and runs even at native resolution (no upscale). +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// +// Slider -> SHARPNESS mapping is done CPU-side (planUpscaleFrame): +// SHARPNESS = slider / 100 (clamped 0..1, default slider 60 -> 0.60) +// Higher slider = stronger sharpen. This is the genuine AMD CAS sharpness term +// (peak = lerp(8,5,SHARPNESS)); note the GL source's level->value comments were +// inverted, so we map directly to the AMD term instead of copying that table. +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in pixels + float sharpness; // CAS SHARPNESS term [0..1] +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec2 uv = fragTexCoord; + vec2 px = 1.0 / pc.resolution; + float SHARPNESS = pc.sharpness; + + // 3x3 neighbourhood + vec3 a = texture(InputTexture, uv + vec2(-px.x, -px.y)).rgb; + vec3 b = texture(InputTexture, uv + vec2( 0.0, -px.y)).rgb; + vec3 c = texture(InputTexture, uv + vec2( px.x, -px.y)).rgb; + vec3 d = texture(InputTexture, uv + vec2(-px.x, 0.0)).rgb; + vec3 e = texture(InputTexture, uv).rgb; + vec3 f = texture(InputTexture, uv + vec2( px.x, 0.0)).rgb; + vec3 g = texture(InputTexture, uv + vec2(-px.x, px.y)).rgb; + vec3 h = texture(InputTexture, uv + vec2( 0.0, px.y)).rgb; + vec3 i = texture(InputTexture, uv + vec2( px.x, px.y)).rgb; + + // CAS + vec3 mnRGB = min(min(min(d, e), min(f, b)), h); + vec3 mnRGB2 = min(min(min(mnRGB, a), min(g, c)), i); + mnRGB += mnRGB2; + + vec3 mxRGB = max(max(max(d, e), max(f, b)), h); + vec3 mxRGB2 = max(max(max(mxRGB, a), max(g, c)), i); + mxRGB += mxRGB2; + + vec3 rcpMxRGB = vec3(1.0) / max(mxRGB, vec3(1e-6)); + vec3 ampRGB = clamp(min(mnRGB, 2.0 - mxRGB) * rcpMxRGB, 0.0, 1.0); + + float peak = 8.0 - 3.0 * SHARPNESS; + vec3 wRGB = -sqrt(ampRGB) / peak; + vec3 rcpWeightRGB = vec3(1.0) / (1.0 + 4.0 * wRGB); + + vec3 window = (b + d) + (f + h); + vec3 col = clamp((window * wRGB + e) * rcpWeightRGB, 0.0, 1.0); + + outColor = vec4(col, 1.0); +} diff --git a/app/src/main/cpp/shaders/cas_ffx.frag b/app/src/main/cpp/shaders/cas_ffx.frag new file mode 100644 index 0000000000..fff26a9fcf --- /dev/null +++ b/app/src/main/cpp/shaders/cas_ffx.frag @@ -0,0 +1,108 @@ +#version 450 + +// ============================================================================= +// AMD FidelityFX CAS (Contrast Adaptive Sharpening) - sharpen-only path. +// +// Ported from AMD's reference header: +// GPUOpen-Effects/FidelityFX-CAS ffx-cas/ffx_cas.h (v1.0.2, CAS 1.20190610) +// CasSetup() sharpness term + CasFilter() with noScaling == true. +// +// Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// Adapted in Bannerlator (The412Banner/Bannerlator) for its compositors; here +// in the Wayland effects chain, built half only (cas_ffx_half_frag.h): +// - AMD's default build: CAS_BETTER_DIAGONALS, CAS_SLOW and CAS_GO_SLOWER not +// defined -> the 5-tap "circle" (b d e f h) and the green channel's weight +// for all channels. cas.frag (the previous shader) is the BETTER_DIAGONALS +// + CAS_SLOW maths with 9 taps. +// - APrxLoRcp / APrxLoSqrt / APrxMedRcp (bit-trick approximations for AMD +// ALUs) are plain 1/x and sqrt here. +// - Same push constants as cas.frag: ndc, input size, sharpness [0..1]. +// CasSetup's const1.x = -1 / lerp(8, 5, sharpness) is computed here. +// - The input is the effect chain's previous target at the same size, so the +// output pixel reads the input pixel 1:1 (texel centres, edges clamped). +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in AMD's +// CasFilterH; positions stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + highp vec2 resolution; // input (= output) size in pixels + float sharpness; // CAS sharpness [0..1] +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +vec3 CasLoad(ivec2 p) { + highp vec2 uv = (vec2(p) + 0.5) / pc.resolution; + return textureLod(InputTexture, uv, 0.0).rgb; +} + +float AMin3F1(float x, float y, float z) { return min(x, min(y, z)); } +float AMax3F1(float x, float y, float z) { return max(x, max(y, z)); } + +void main() { + ivec2 sp = ivec2(fragTexCoord * pc.resolution); + + // CasSetup: sharp = -1 / lerp(8.0, 5.0, saturate(sharpness)). + float peak = -1.0 / mix(8.0, 5.0, clamp(pc.sharpness, 0.0, 1.0)); + + // b + // d e f + // h + vec3 b = CasLoad(sp + ivec2( 0, -1)); + vec3 d = CasLoad(sp + ivec2(-1, 0)); + vec3 e = CasLoad(sp); + vec3 f = CasLoad(sp + ivec2( 1, 0)); + vec3 h = CasLoad(sp + ivec2( 0, 1)); + + // Soft min and max of the circle (green only: the weight below uses green). + float mnG = AMin3F1(AMin3F1(d.g, e.g, f.g), b.g, h.g); + float mxG = AMax3F1(AMax3F1(d.g, e.g, f.g), b.g, h.g); + + // Smooth minimum distance to signal limit divided by smooth max. + // AMD's bit-trick reciprocal stays finite at 0; 1/0 here would give 0 * inf + // on black, so the max is floored (below one 8-bit step; mn = 0 there anyway). + float rcpMG = 1.0 / max(mxG, 1.0 / 1024.0); + float ampG = clamp(min(mnG, 1.0 - mxG) * rcpMG, 0.0, 1.0); + + // Shaping amount of sharpening. + ampG = sqrt(ampG); + + // Filter shape: 0 w 0 / w 1 w / 0 w 0 + float wG = ampG * peak; + float rcpWeight = 1.0 / (1.0 + 4.0 * wG); + vec3 pix = clamp((b * wG + d * wG + f * wG + h * wG + e) * rcpWeight, 0.0, 1.0); + + outColor = vec4(pix, 1.0); +} diff --git a/app/src/main/cpp/shaders/cas_ffx_half_frag.h b/app/src/main/cpp/shaders/cas_ffx_half_frag.h new file mode 100644 index 0000000000..2ba56158cc --- /dev/null +++ b/app/src/main/cpp/shaders/cas_ffx_half_frag.h @@ -0,0 +1,213 @@ + // 1115.1.0 + #pragma once +const uint32_t cas_ffx_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000000d7,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000047,0x000000d1,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00060005,0x0000000d,0x4c736143,0x2864616f,0x3b326976,0x00000000,0x00030005, + 0x0000000c,0x00000070,0x00070005,0x00000014,0x6e694d41,0x28314633,0x663b3166,0x31663b31, + 0x0000003b,0x00030005,0x00000011,0x00000078,0x00030005,0x00000012,0x00000079,0x00030005, + 0x00000013,0x0000007a,0x00070005,0x00000019,0x78614d41,0x28314633,0x663b3166,0x31663b31, + 0x0000003b,0x00030005,0x00000016,0x00000078,0x00030005,0x00000017,0x00000079,0x00030005, + 0x00000018,0x0000007a,0x00030005,0x0000001d,0x00007675,0x00030005,0x00000024,0x00004350, + 0x00040006,0x00000024,0x00000000,0x0063646e,0x00060006,0x00000024,0x00000001,0x6f736572, + 0x6974756c,0x00006e6f,0x00060006,0x00000024,0x00000002,0x72616873,0x73656e70,0x00000073, + 0x00030005,0x00000026,0x00006370,0x00060005,0x0000002f,0x75706e49,0x78655474,0x65727574, + 0x00000000,0x00030005,0x00000045,0x00007073,0x00060005,0x00000047,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x0000004d,0x6b616570,0x00000000,0x00030005,0x0000005a, + 0x00000062,0x00040005,0x00000060,0x61726170,0x0000006d,0x00030005,0x00000062,0x00000064, + 0x00040005,0x00000066,0x61726170,0x0000006d,0x00030005,0x00000068,0x00000065,0x00040005, + 0x00000069,0x61726170,0x0000006d,0x00030005,0x0000006c,0x00000066,0x00040005,0x00000070, + 0x61726170,0x0000006d,0x00030005,0x00000072,0x00000068,0x00040005,0x00000076,0x61726170, + 0x0000006d,0x00030005,0x00000078,0x00476e6d,0x00040005,0x00000079,0x61726170,0x0000006d, + 0x00040005,0x0000007e,0x61726170,0x0000006d,0x00040005,0x00000081,0x61726170,0x0000006d, + 0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000086,0x61726170,0x0000006d, + 0x00040005,0x00000089,0x61726170,0x0000006d,0x00030005,0x0000008d,0x0047786d,0x00040005, + 0x0000008e,0x61726170,0x0000006d,0x00040005,0x00000091,0x61726170,0x0000006d,0x00040005, + 0x00000094,0x61726170,0x0000006d,0x00040005,0x00000098,0x61726170,0x0000006d,0x00040005, + 0x00000099,0x61726170,0x0000006d,0x00040005,0x0000009c,0x61726170,0x0000006d,0x00040005, + 0x000000a0,0x4d706372,0x00000047,0x00040005,0x000000a5,0x47706d61,0x00000000,0x00030005, + 0x000000af,0x00004777,0x00050005,0x000000b3,0x57706372,0x68676965,0x00000074,0x00030005, + 0x000000b9,0x00786970,0x00050005,0x000000d1,0x4374756f,0x726f6c6f,0x00000000,0x00030047, + 0x0000000d,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000, + 0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,0x00030047,0x00000016, + 0x00000000,0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,0x00000000,0x00030047, + 0x00000019,0x00000000,0x00030047,0x00000024,0x00000002,0x00050048,0x00000024,0x00000000, + 0x00000023,0x00000000,0x00050048,0x00000024,0x00000001,0x00000023,0x00000010,0x00040048, + 0x00000024,0x00000002,0x00000000,0x00050048,0x00000024,0x00000002,0x00000023,0x00000018, + 0x00030047,0x0000002f,0x00000000,0x00040047,0x0000002f,0x00000021,0x00000000,0x00040047, + 0x0000002f,0x00000022,0x00000000,0x00030047,0x00000030,0x00000000,0x00030047,0x00000033, + 0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000037,0x00000000,0x00030047, + 0x00000038,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047,0x0000003a,0x00000000, + 0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003e,0x00000000,0x00030047,0x0000003f, + 0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000041,0x00000000,0x00030047, + 0x00000042,0x00000000,0x00040047,0x00000047,0x0000001e,0x00000000,0x00030047,0x0000004d, + 0x00000000,0x00030047,0x00000054,0x00000000,0x00030047,0x00000056,0x00000000,0x00030047, + 0x00000057,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,0x0000005a,0x00000000, + 0x00030047,0x00000061,0x00000000,0x00030047,0x00000062,0x00000000,0x00030047,0x00000067, + 0x00000000,0x00030047,0x00000068,0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047, + 0x0000006c,0x00000000,0x00030047,0x00000071,0x00000000,0x00030047,0x00000072,0x00000000, + 0x00030047,0x00000077,0x00000000,0x00030047,0x00000078,0x00000000,0x00030047,0x00000079, + 0x00000000,0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047, + 0x00000080,0x00000000,0x00030047,0x00000081,0x00000000,0x00030047,0x00000083,0x00000000, + 0x00030047,0x00000084,0x00000000,0x00030047,0x00000085,0x00000000,0x00030047,0x00000086, + 0x00000000,0x00030047,0x00000088,0x00000000,0x00030047,0x00000089,0x00000000,0x00030047, + 0x0000008b,0x00000000,0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000, + 0x00030047,0x0000008e,0x00000000,0x00030047,0x00000090,0x00000000,0x00030047,0x00000091, + 0x00000000,0x00030047,0x00000093,0x00000000,0x00030047,0x00000094,0x00000000,0x00030047, + 0x00000096,0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x00000098,0x00000000, + 0x00030047,0x00000099,0x00000000,0x00030047,0x0000009b,0x00000000,0x00030047,0x0000009c, + 0x00000000,0x00030047,0x0000009e,0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047, + 0x000000a0,0x00000000,0x00030047,0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000, + 0x00030047,0x000000a4,0x00000000,0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a6, + 0x00000000,0x00030047,0x000000a7,0x00000000,0x00030047,0x000000a8,0x00000000,0x00030047, + 0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000,0x00030047,0x000000ab,0x00000000, + 0x00030047,0x000000ac,0x00000000,0x00030047,0x000000ad,0x00000000,0x00030047,0x000000ae, + 0x00000000,0x00030047,0x000000af,0x00000000,0x00030047,0x000000b0,0x00000000,0x00030047, + 0x000000b1,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3,0x00000000, + 0x00030047,0x000000b5,0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b7, + 0x00000000,0x00030047,0x000000b8,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047, + 0x000000ba,0x00000000,0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000, + 0x00030047,0x000000bd,0x00000000,0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf, + 0x00000000,0x00030047,0x000000c0,0x00000000,0x00030047,0x000000c1,0x00000000,0x00030047, + 0x000000c2,0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047,0x000000c4,0x00000000, + 0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c7, + 0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047, + 0x000000ca,0x00000000,0x00030047,0x000000cb,0x00000000,0x00030047,0x000000cc,0x00000000, + 0x00030047,0x000000cd,0x00000000,0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf, + 0x00000000,0x00030047,0x000000d1,0x00000000,0x00040047,0x000000d1,0x0000001e,0x00000000, + 0x00030047,0x000000d2,0x00000000,0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4, + 0x00000000,0x00030047,0x000000d5,0x00000000,0x00030047,0x000000d6,0x00000000,0x00020013, + 0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001, + 0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007, + 0x00030016,0x00000009,0x00000020,0x00040017,0x0000000a,0x00000009,0x00000003,0x00040021, + 0x0000000b,0x0000000a,0x00000008,0x00040020,0x0000000f,0x00000007,0x00000009,0x00060021, + 0x00000010,0x00000009,0x0000000f,0x0000000f,0x0000000f,0x00040017,0x0000001b,0x00000009, + 0x00000002,0x00040020,0x0000001c,0x00000007,0x0000001b,0x0004002b,0x00000009,0x00000020, + 0x3f000000,0x00040017,0x00000023,0x00000009,0x00000004,0x0005001e,0x00000024,0x00000023, + 0x0000001b,0x00000009,0x00040020,0x00000025,0x00000009,0x00000024,0x0004003b,0x00000025, + 0x00000026,0x00000009,0x0004002b,0x00000006,0x00000027,0x00000001,0x00040020,0x00000028, + 0x00000009,0x0000001b,0x00090019,0x0000002c,0x00000009,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000001,0x00000000,0x0003001b,0x0000002d,0x0000002c,0x00040020,0x0000002e, + 0x00000000,0x0000002d,0x0004003b,0x0000002e,0x0000002f,0x00000000,0x0004002b,0x00000009, + 0x00000032,0x00000000,0x00040020,0x00000046,0x00000001,0x0000001b,0x0004003b,0x00000046, + 0x00000047,0x00000001,0x0004002b,0x00000009,0x0000004e,0xbf800000,0x0004002b,0x00000009, + 0x0000004f,0x41000000,0x0004002b,0x00000009,0x00000050,0x40a00000,0x0004002b,0x00000006, + 0x00000051,0x00000002,0x00040020,0x00000052,0x00000009,0x00000009,0x0004002b,0x00000009, + 0x00000055,0x3f800000,0x00040020,0x00000059,0x00000007,0x0000000a,0x0004002b,0x00000006, + 0x0000005c,0x00000000,0x0004002b,0x00000006,0x0000005d,0xffffffff,0x0005002c,0x00000007, + 0x0000005e,0x0000005c,0x0000005d,0x0005002c,0x00000007,0x00000064,0x0000005d,0x0000005c, + 0x0005002c,0x00000007,0x0000006e,0x00000027,0x0000005c,0x0005002c,0x00000007,0x00000074, + 0x0000005c,0x00000027,0x00040015,0x0000007a,0x00000020,0x00000000,0x0004002b,0x0000007a, + 0x0000007b,0x00000001,0x0004002b,0x00000009,0x000000a2,0x3a800000,0x0004002b,0x00000009, + 0x000000b4,0x40800000,0x00040020,0x000000d0,0x00000003,0x00000023,0x0004003b,0x000000d0, + 0x000000d1,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000008,0x00000045,0x00000007,0x0004003b,0x0000000f,0x0000004d, + 0x00000007,0x0004003b,0x00000059,0x0000005a,0x00000007,0x0004003b,0x00000008,0x00000060, + 0x00000007,0x0004003b,0x00000059,0x00000062,0x00000007,0x0004003b,0x00000008,0x00000066, + 0x00000007,0x0004003b,0x00000059,0x00000068,0x00000007,0x0004003b,0x00000008,0x00000069, + 0x00000007,0x0004003b,0x00000059,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000070, + 0x00000007,0x0004003b,0x00000059,0x00000072,0x00000007,0x0004003b,0x00000008,0x00000076, + 0x00000007,0x0004003b,0x0000000f,0x00000078,0x00000007,0x0004003b,0x0000000f,0x00000079, + 0x00000007,0x0004003b,0x0000000f,0x0000007e,0x00000007,0x0004003b,0x0000000f,0x00000081, + 0x00000007,0x0004003b,0x0000000f,0x00000085,0x00000007,0x0004003b,0x0000000f,0x00000086, + 0x00000007,0x0004003b,0x0000000f,0x00000089,0x00000007,0x0004003b,0x0000000f,0x0000008d, + 0x00000007,0x0004003b,0x0000000f,0x0000008e,0x00000007,0x0004003b,0x0000000f,0x00000091, + 0x00000007,0x0004003b,0x0000000f,0x00000094,0x00000007,0x0004003b,0x0000000f,0x00000098, + 0x00000007,0x0004003b,0x0000000f,0x00000099,0x00000007,0x0004003b,0x0000000f,0x0000009c, + 0x00000007,0x0004003b,0x0000000f,0x000000a0,0x00000007,0x0004003b,0x0000000f,0x000000a5, + 0x00000007,0x0004003b,0x0000000f,0x000000af,0x00000007,0x0004003b,0x0000000f,0x000000b3, + 0x00000007,0x0004003b,0x00000059,0x000000b9,0x00000007,0x0004003d,0x0000001b,0x00000048, + 0x00000047,0x00050041,0x00000028,0x00000049,0x00000026,0x00000027,0x0004003d,0x0000001b, + 0x0000004a,0x00000049,0x00050085,0x0000001b,0x0000004b,0x00000048,0x0000004a,0x0004006e, + 0x00000007,0x0000004c,0x0000004b,0x0003003e,0x00000045,0x0000004c,0x00050041,0x00000052, + 0x00000053,0x00000026,0x00000051,0x0004003d,0x00000009,0x00000054,0x00000053,0x0008000c, + 0x00000009,0x00000056,0x00000001,0x0000002b,0x00000054,0x00000032,0x00000055,0x0008000c, + 0x00000009,0x00000057,0x00000001,0x0000002e,0x0000004f,0x00000050,0x00000056,0x00050088, + 0x00000009,0x00000058,0x0000004e,0x00000057,0x0003003e,0x0000004d,0x00000058,0x0004003d, + 0x00000007,0x0000005b,0x00000045,0x00050080,0x00000007,0x0000005f,0x0000005b,0x0000005e, + 0x0003003e,0x00000060,0x0000005f,0x00050039,0x0000000a,0x00000061,0x0000000d,0x00000060, + 0x0003003e,0x0000005a,0x00000061,0x0004003d,0x00000007,0x00000063,0x00000045,0x00050080, + 0x00000007,0x00000065,0x00000063,0x00000064,0x0003003e,0x00000066,0x00000065,0x00050039, + 0x0000000a,0x00000067,0x0000000d,0x00000066,0x0003003e,0x00000062,0x00000067,0x0004003d, + 0x00000007,0x0000006a,0x00000045,0x0003003e,0x00000069,0x0000006a,0x00050039,0x0000000a, + 0x0000006b,0x0000000d,0x00000069,0x0003003e,0x00000068,0x0000006b,0x0004003d,0x00000007, + 0x0000006d,0x00000045,0x00050080,0x00000007,0x0000006f,0x0000006d,0x0000006e,0x0003003e, + 0x00000070,0x0000006f,0x00050039,0x0000000a,0x00000071,0x0000000d,0x00000070,0x0003003e, + 0x0000006c,0x00000071,0x0004003d,0x00000007,0x00000073,0x00000045,0x00050080,0x00000007, + 0x00000075,0x00000073,0x00000074,0x0003003e,0x00000076,0x00000075,0x00050039,0x0000000a, + 0x00000077,0x0000000d,0x00000076,0x0003003e,0x00000072,0x00000077,0x00050041,0x0000000f, + 0x0000007c,0x00000062,0x0000007b,0x0004003d,0x00000009,0x0000007d,0x0000007c,0x0003003e, + 0x00000079,0x0000007d,0x00050041,0x0000000f,0x0000007f,0x00000068,0x0000007b,0x0004003d, + 0x00000009,0x00000080,0x0000007f,0x0003003e,0x0000007e,0x00000080,0x00050041,0x0000000f, + 0x00000082,0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000083,0x00000082,0x0003003e, + 0x00000081,0x00000083,0x00070039,0x00000009,0x00000084,0x00000014,0x00000079,0x0000007e, + 0x00000081,0x0003003e,0x00000085,0x00000084,0x00050041,0x0000000f,0x00000087,0x0000005a, + 0x0000007b,0x0004003d,0x00000009,0x00000088,0x00000087,0x0003003e,0x00000086,0x00000088, + 0x00050041,0x0000000f,0x0000008a,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000008b, + 0x0000008a,0x0003003e,0x00000089,0x0000008b,0x00070039,0x00000009,0x0000008c,0x00000014, + 0x00000085,0x00000086,0x00000089,0x0003003e,0x00000078,0x0000008c,0x00050041,0x0000000f, + 0x0000008f,0x00000062,0x0000007b,0x0004003d,0x00000009,0x00000090,0x0000008f,0x0003003e, + 0x0000008e,0x00000090,0x00050041,0x0000000f,0x00000092,0x00000068,0x0000007b,0x0004003d, + 0x00000009,0x00000093,0x00000092,0x0003003e,0x00000091,0x00000093,0x00050041,0x0000000f, + 0x00000095,0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000096,0x00000095,0x0003003e, + 0x00000094,0x00000096,0x00070039,0x00000009,0x00000097,0x00000019,0x0000008e,0x00000091, + 0x00000094,0x0003003e,0x00000098,0x00000097,0x00050041,0x0000000f,0x0000009a,0x0000005a, + 0x0000007b,0x0004003d,0x00000009,0x0000009b,0x0000009a,0x0003003e,0x00000099,0x0000009b, + 0x00050041,0x0000000f,0x0000009d,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000009e, + 0x0000009d,0x0003003e,0x0000009c,0x0000009e,0x00070039,0x00000009,0x0000009f,0x00000019, + 0x00000098,0x00000099,0x0000009c,0x0003003e,0x0000008d,0x0000009f,0x0004003d,0x00000009, + 0x000000a1,0x0000008d,0x0007000c,0x00000009,0x000000a3,0x00000001,0x00000028,0x000000a1, + 0x000000a2,0x00050088,0x00000009,0x000000a4,0x00000055,0x000000a3,0x0003003e,0x000000a0, + 0x000000a4,0x0004003d,0x00000009,0x000000a6,0x00000078,0x0004003d,0x00000009,0x000000a7, + 0x0000008d,0x00050083,0x00000009,0x000000a8,0x00000055,0x000000a7,0x0007000c,0x00000009, + 0x000000a9,0x00000001,0x00000025,0x000000a6,0x000000a8,0x0004003d,0x00000009,0x000000aa, + 0x000000a0,0x00050085,0x00000009,0x000000ab,0x000000a9,0x000000aa,0x0008000c,0x00000009, + 0x000000ac,0x00000001,0x0000002b,0x000000ab,0x00000032,0x00000055,0x0003003e,0x000000a5, + 0x000000ac,0x0004003d,0x00000009,0x000000ad,0x000000a5,0x0006000c,0x00000009,0x000000ae, + 0x00000001,0x0000001f,0x000000ad,0x0003003e,0x000000a5,0x000000ae,0x0004003d,0x00000009, + 0x000000b0,0x000000a5,0x0004003d,0x00000009,0x000000b1,0x0000004d,0x00050085,0x00000009, + 0x000000b2,0x000000b0,0x000000b1,0x0003003e,0x000000af,0x000000b2,0x0004003d,0x00000009, + 0x000000b5,0x000000af,0x00050085,0x00000009,0x000000b6,0x000000b4,0x000000b5,0x00050081, + 0x00000009,0x000000b7,0x00000055,0x000000b6,0x00050088,0x00000009,0x000000b8,0x00000055, + 0x000000b7,0x0003003e,0x000000b3,0x000000b8,0x0004003d,0x0000000a,0x000000ba,0x0000005a, + 0x0004003d,0x00000009,0x000000bb,0x000000af,0x0005008e,0x0000000a,0x000000bc,0x000000ba, + 0x000000bb,0x0004003d,0x0000000a,0x000000bd,0x00000062,0x0004003d,0x00000009,0x000000be, + 0x000000af,0x0005008e,0x0000000a,0x000000bf,0x000000bd,0x000000be,0x00050081,0x0000000a, + 0x000000c0,0x000000bc,0x000000bf,0x0004003d,0x0000000a,0x000000c1,0x0000006c,0x0004003d, + 0x00000009,0x000000c2,0x000000af,0x0005008e,0x0000000a,0x000000c3,0x000000c1,0x000000c2, + 0x00050081,0x0000000a,0x000000c4,0x000000c0,0x000000c3,0x0004003d,0x0000000a,0x000000c5, + 0x00000072,0x0004003d,0x00000009,0x000000c6,0x000000af,0x0005008e,0x0000000a,0x000000c7, + 0x000000c5,0x000000c6,0x00050081,0x0000000a,0x000000c8,0x000000c4,0x000000c7,0x0004003d, + 0x0000000a,0x000000c9,0x00000068,0x00050081,0x0000000a,0x000000ca,0x000000c8,0x000000c9, + 0x0004003d,0x00000009,0x000000cb,0x000000b3,0x0005008e,0x0000000a,0x000000cc,0x000000ca, + 0x000000cb,0x00060050,0x0000000a,0x000000cd,0x00000032,0x00000032,0x00000032,0x00060050, + 0x0000000a,0x000000ce,0x00000055,0x00000055,0x00000055,0x0008000c,0x0000000a,0x000000cf, + 0x00000001,0x0000002b,0x000000cc,0x000000cd,0x000000ce,0x0003003e,0x000000b9,0x000000cf, + 0x0004003d,0x0000000a,0x000000d2,0x000000b9,0x00050051,0x00000009,0x000000d3,0x000000d2, + 0x00000000,0x00050051,0x00000009,0x000000d4,0x000000d2,0x00000001,0x00050051,0x00000009, + 0x000000d5,0x000000d2,0x00000002,0x00070050,0x00000023,0x000000d6,0x000000d3,0x000000d4, + 0x000000d5,0x00000055,0x0003003e,0x000000d1,0x000000d6,0x000100fd,0x00010038,0x00050036, + 0x0000000a,0x0000000d,0x00000000,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8, + 0x0000000e,0x0004003b,0x0000001c,0x0000001d,0x00000007,0x0004003d,0x00000007,0x0000001e, + 0x0000000c,0x0004006f,0x0000001b,0x0000001f,0x0000001e,0x00050050,0x0000001b,0x00000021, + 0x00000020,0x00000020,0x00050081,0x0000001b,0x00000022,0x0000001f,0x00000021,0x00050041, + 0x00000028,0x00000029,0x00000026,0x00000027,0x0004003d,0x0000001b,0x0000002a,0x00000029, + 0x00050088,0x0000001b,0x0000002b,0x00000022,0x0000002a,0x0003003e,0x0000001d,0x0000002b, + 0x0004003d,0x0000002d,0x00000030,0x0000002f,0x0004003d,0x0000001b,0x00000031,0x0000001d, + 0x00070058,0x00000023,0x00000033,0x00000030,0x00000031,0x00000002,0x00000032,0x0008004f, + 0x0000000a,0x00000034,0x00000033,0x00000033,0x00000000,0x00000001,0x00000002,0x000200fe, + 0x00000034,0x00010038,0x00050036,0x00000009,0x00000014,0x00000000,0x00000010,0x00030037, + 0x0000000f,0x00000011,0x00030037,0x0000000f,0x00000012,0x00030037,0x0000000f,0x00000013, + 0x000200f8,0x00000015,0x0004003d,0x00000009,0x00000037,0x00000011,0x0004003d,0x00000009, + 0x00000038,0x00000012,0x0004003d,0x00000009,0x00000039,0x00000013,0x0007000c,0x00000009, + 0x0000003a,0x00000001,0x00000025,0x00000038,0x00000039,0x0007000c,0x00000009,0x0000003b, + 0x00000001,0x00000025,0x00000037,0x0000003a,0x000200fe,0x0000003b,0x00010038,0x00050036, + 0x00000009,0x00000019,0x00000000,0x00000010,0x00030037,0x0000000f,0x00000016,0x00030037, + 0x0000000f,0x00000017,0x00030037,0x0000000f,0x00000018,0x000200f8,0x0000001a,0x0004003d, + 0x00000009,0x0000003e,0x00000016,0x0004003d,0x00000009,0x0000003f,0x00000017,0x0004003d, + 0x00000009,0x00000040,0x00000018,0x0007000c,0x00000009,0x00000041,0x00000001,0x00000028, + 0x0000003f,0x00000040,0x0007000c,0x00000009,0x00000042,0x00000001,0x00000028,0x0000003e, + 0x00000041,0x000200fe,0x00000042,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/cas_frag.h b/app/src/main/cpp/shaders/cas_frag.h index 103c2cce42..e21737d61a 100644 --- a/app/src/main/cpp/shaders/cas_frag.h +++ b/app/src/main/cpp/shaders/cas_frag.h @@ -1,8 +1,9 @@ + // 1116.3.0 #pragma once const uint32_t cas_code[] = { - 0x07230203,0x00010000,0x0008000b,0x000000f3,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x000000f4,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x000000ed,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x000000ee,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00030005,0x00000009,0x00007675,0x00060005,0x0000000b,0x67617266,0x43786554, 0x64726f6f,0x00000000,0x00030005,0x0000000d,0x00007870,0x00030005,0x00000010,0x00004350, @@ -15,15 +16,15 @@ const uint32_t cas_code[] = { 0x00030005,0x00000065,0x00000067,0x00030005,0x00000071,0x00000068,0x00030005,0x0000007a, 0x00000069,0x00040005,0x00000085,0x47526e6d,0x00000042,0x00040005,0x0000008f,0x47526e6d, 0x00003242,0x00040005,0x0000009c,0x4752786d,0x00000042,0x00040005,0x000000a6,0x4752786d, - 0x00003242,0x00050005,0x000000b3,0x4d706372,0x42475278,0x00000000,0x00040005,0x000000b7, - 0x52706d61,0x00004247,0x00040005,0x000000c5,0x6b616570,0x00000000,0x00040005,0x000000cb, - 0x42475277,0x00000000,0x00060005,0x000000d2,0x57706372,0x68676965,0x42475274,0x00000000, - 0x00040005,0x000000d9,0x646e6977,0x0000776f,0x00030005,0x000000e1,0x006c6f63,0x00050005, - 0x000000ed,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000, + 0x00003242,0x00050005,0x000000b3,0x4d706372,0x42475278,0x00000000,0x00040005,0x000000ba, + 0x52706d61,0x00004247,0x00040005,0x000000c6,0x6b616570,0x00000000,0x00040005,0x000000cc, + 0x42475277,0x00000000,0x00060005,0x000000d3,0x57706372,0x68676965,0x42475274,0x00000000, + 0x00040005,0x000000da,0x646e6977,0x0000776f,0x00030005,0x000000e2,0x006c6f63,0x00050005, + 0x000000ee,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000, 0x00030047,0x00000010,0x00000002,0x00050048,0x00000010,0x00000000,0x00000023,0x00000000, 0x00050048,0x00000010,0x00000001,0x00000023,0x00000010,0x00050048,0x00000010,0x00000002, 0x00000023,0x00000018,0x00040047,0x00000026,0x00000021,0x00000000,0x00040047,0x00000026, - 0x00000022,0x00000000,0x00040047,0x000000ed,0x0000001e,0x00000000,0x00020013,0x00000002, + 0x00000022,0x00000000,0x00040047,0x000000ee,0x0000001e,0x00000000,0x00020013,0x00000002, 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007, 0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040020,0x0000000a, 0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x0004002b,0x00000006, @@ -38,11 +39,11 @@ const uint32_t cas_code[] = { 0x00000025,0x00000000,0x00000024,0x0004003b,0x00000025,0x00000026,0x00000000,0x00040015, 0x00000029,0x00000020,0x00000000,0x0004002b,0x00000029,0x0000002a,0x00000000,0x0004002b, 0x00000029,0x0000002e,0x00000001,0x0004002b,0x00000006,0x00000039,0x00000000,0x0006002c, - 0x00000020,0x000000b4,0x0000000e,0x0000000e,0x0000000e,0x0004002b,0x00000006,0x000000b9, - 0x40000000,0x0004002b,0x00000006,0x000000c6,0x41000000,0x0004002b,0x00000006,0x000000c7, - 0x40400000,0x0004002b,0x00000006,0x000000cc,0xbf800000,0x0006002c,0x00000020,0x000000cd, - 0x000000cc,0x000000cc,0x000000cc,0x0004002b,0x00000006,0x000000d3,0x40800000,0x00040020, - 0x000000ec,0x00000003,0x0000000f,0x0004003b,0x000000ec,0x000000ed,0x00000003,0x00050036, + 0x00000020,0x000000b4,0x0000000e,0x0000000e,0x0000000e,0x0004002b,0x00000006,0x000000b6, + 0x358637bd,0x0006002c,0x00000020,0x000000b7,0x000000b6,0x000000b6,0x000000b6,0x0004002b, + 0x00000006,0x000000bc,0x40000000,0x0004002b,0x00000006,0x000000c7,0x41000000,0x0004002b, + 0x00000006,0x000000c8,0x40400000,0x0004002b,0x00000006,0x000000d4,0x40800000,0x00040020, + 0x000000ed,0x00000003,0x0000000f,0x0004003b,0x000000ed,0x000000ee,0x00000003,0x00050036, 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008, 0x00000009,0x00000007,0x0004003b,0x00000008,0x0000000d,0x00000007,0x0004003b,0x0000001a, 0x0000001b,0x00000007,0x0004003b,0x00000021,0x00000022,0x00000007,0x0004003b,0x00000021, @@ -52,10 +53,10 @@ const uint32_t cas_code[] = { 0x00000071,0x00000007,0x0004003b,0x00000021,0x0000007a,0x00000007,0x0004003b,0x00000021, 0x00000085,0x00000007,0x0004003b,0x00000021,0x0000008f,0x00000007,0x0004003b,0x00000021, 0x0000009c,0x00000007,0x0004003b,0x00000021,0x000000a6,0x00000007,0x0004003b,0x00000021, - 0x000000b3,0x00000007,0x0004003b,0x00000021,0x000000b7,0x00000007,0x0004003b,0x0000001a, - 0x000000c5,0x00000007,0x0004003b,0x00000021,0x000000cb,0x00000007,0x0004003b,0x00000021, - 0x000000d2,0x00000007,0x0004003b,0x00000021,0x000000d9,0x00000007,0x0004003b,0x00000021, - 0x000000e1,0x00000007,0x0004003d,0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009, + 0x000000b3,0x00000007,0x0004003b,0x00000021,0x000000ba,0x00000007,0x0004003b,0x0000001a, + 0x000000c6,0x00000007,0x0004003b,0x00000021,0x000000cc,0x00000007,0x0004003b,0x00000021, + 0x000000d3,0x00000007,0x0004003b,0x00000021,0x000000da,0x00000007,0x0004003b,0x00000021, + 0x000000e2,0x00000007,0x0004003d,0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009, 0x0000000c,0x00050041,0x00000015,0x00000016,0x00000012,0x00000014,0x0004003d,0x00000007, 0x00000017,0x00000016,0x00050050,0x00000007,0x00000018,0x0000000e,0x0000000e,0x00050088, 0x00000007,0x00000019,0x00000018,0x00000017,0x0003003e,0x0000000d,0x00000019,0x00050041, @@ -143,38 +144,39 @@ const uint32_t cas_code[] = { 0x0000007a,0x0007000c,0x00000020,0x000000af,0x00000001,0x00000028,0x000000ad,0x000000ae, 0x0003003e,0x000000a6,0x000000af,0x0004003d,0x00000020,0x000000b0,0x000000a6,0x0004003d, 0x00000020,0x000000b1,0x0000009c,0x00050081,0x00000020,0x000000b2,0x000000b1,0x000000b0, - 0x0003003e,0x0000009c,0x000000b2,0x0004003d,0x00000020,0x000000b5,0x0000009c,0x00050088, - 0x00000020,0x000000b6,0x000000b4,0x000000b5,0x0003003e,0x000000b3,0x000000b6,0x0004003d, - 0x00000020,0x000000b8,0x00000085,0x0004003d,0x00000020,0x000000ba,0x0000009c,0x00060050, - 0x00000020,0x000000bb,0x000000b9,0x000000b9,0x000000b9,0x00050083,0x00000020,0x000000bc, - 0x000000bb,0x000000ba,0x0007000c,0x00000020,0x000000bd,0x00000001,0x00000025,0x000000b8, - 0x000000bc,0x0004003d,0x00000020,0x000000be,0x000000b3,0x00050085,0x00000020,0x000000bf, - 0x000000bd,0x000000be,0x00060050,0x00000020,0x000000c0,0x00000039,0x00000039,0x00000039, - 0x00060050,0x00000020,0x000000c1,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x00000020, - 0x000000c2,0x00000001,0x0000002b,0x000000bf,0x000000c0,0x000000c1,0x0003003e,0x000000b7, - 0x000000c2,0x0004003d,0x00000020,0x000000c3,0x000000b7,0x0006000c,0x00000020,0x000000c4, - 0x00000001,0x00000020,0x000000c3,0x0003003e,0x000000b7,0x000000c4,0x0004003d,0x00000006, - 0x000000c8,0x0000001b,0x00050085,0x00000006,0x000000c9,0x000000c7,0x000000c8,0x00050083, - 0x00000006,0x000000ca,0x000000c6,0x000000c9,0x0003003e,0x000000c5,0x000000ca,0x0004003d, - 0x00000020,0x000000ce,0x000000b7,0x0004003d,0x00000006,0x000000cf,0x000000c5,0x0005008e, - 0x00000020,0x000000d0,0x000000ce,0x000000cf,0x00050088,0x00000020,0x000000d1,0x000000cd, - 0x000000d0,0x0003003e,0x000000cb,0x000000d1,0x0004003d,0x00000020,0x000000d4,0x000000cb, - 0x0005008e,0x00000020,0x000000d5,0x000000d4,0x000000d3,0x00060050,0x00000020,0x000000d6, - 0x0000000e,0x0000000e,0x0000000e,0x00050081,0x00000020,0x000000d7,0x000000d6,0x000000d5, - 0x00050088,0x00000020,0x000000d8,0x000000b4,0x000000d7,0x0003003e,0x000000d2,0x000000d8, - 0x0004003d,0x00000020,0x000000da,0x00000036,0x0004003d,0x00000020,0x000000db,0x0000004d, - 0x00050081,0x00000020,0x000000dc,0x000000da,0x000000db,0x0004003d,0x00000020,0x000000dd, - 0x0000005c,0x0004003d,0x00000020,0x000000de,0x00000071,0x00050081,0x00000020,0x000000df, - 0x000000dd,0x000000de,0x00050081,0x00000020,0x000000e0,0x000000dc,0x000000df,0x0003003e, - 0x000000d9,0x000000e0,0x0004003d,0x00000020,0x000000e2,0x000000d9,0x0004003d,0x00000020, - 0x000000e3,0x000000cb,0x00050085,0x00000020,0x000000e4,0x000000e2,0x000000e3,0x0004003d, - 0x00000020,0x000000e5,0x00000057,0x00050081,0x00000020,0x000000e6,0x000000e4,0x000000e5, - 0x0004003d,0x00000020,0x000000e7,0x000000d2,0x00050085,0x00000020,0x000000e8,0x000000e6, - 0x000000e7,0x00060050,0x00000020,0x000000e9,0x00000039,0x00000039,0x00000039,0x00060050, - 0x00000020,0x000000ea,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x00000020,0x000000eb, - 0x00000001,0x0000002b,0x000000e8,0x000000e9,0x000000ea,0x0003003e,0x000000e1,0x000000eb, - 0x0004003d,0x00000020,0x000000ee,0x000000e1,0x00050051,0x00000006,0x000000ef,0x000000ee, - 0x00000000,0x00050051,0x00000006,0x000000f0,0x000000ee,0x00000001,0x00050051,0x00000006, - 0x000000f1,0x000000ee,0x00000002,0x00070050,0x0000000f,0x000000f2,0x000000ef,0x000000f0, - 0x000000f1,0x0000000e,0x0003003e,0x000000ed,0x000000f2,0x000100fd,0x00010038 + 0x0003003e,0x0000009c,0x000000b2,0x0004003d,0x00000020,0x000000b5,0x0000009c,0x0007000c, + 0x00000020,0x000000b8,0x00000001,0x00000028,0x000000b5,0x000000b7,0x00050088,0x00000020, + 0x000000b9,0x000000b4,0x000000b8,0x0003003e,0x000000b3,0x000000b9,0x0004003d,0x00000020, + 0x000000bb,0x00000085,0x0004003d,0x00000020,0x000000bd,0x0000009c,0x00060050,0x00000020, + 0x000000be,0x000000bc,0x000000bc,0x000000bc,0x00050083,0x00000020,0x000000bf,0x000000be, + 0x000000bd,0x0007000c,0x00000020,0x000000c0,0x00000001,0x00000025,0x000000bb,0x000000bf, + 0x0004003d,0x00000020,0x000000c1,0x000000b3,0x00050085,0x00000020,0x000000c2,0x000000c0, + 0x000000c1,0x00060050,0x00000020,0x000000c3,0x00000039,0x00000039,0x00000039,0x00060050, + 0x00000020,0x000000c4,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x00000020,0x000000c5, + 0x00000001,0x0000002b,0x000000c2,0x000000c3,0x000000c4,0x0003003e,0x000000ba,0x000000c5, + 0x0004003d,0x00000006,0x000000c9,0x0000001b,0x00050085,0x00000006,0x000000ca,0x000000c8, + 0x000000c9,0x00050083,0x00000006,0x000000cb,0x000000c7,0x000000ca,0x0003003e,0x000000c6, + 0x000000cb,0x0004003d,0x00000020,0x000000cd,0x000000ba,0x0006000c,0x00000020,0x000000ce, + 0x00000001,0x0000001f,0x000000cd,0x0004007f,0x00000020,0x000000cf,0x000000ce,0x0004003d, + 0x00000006,0x000000d0,0x000000c6,0x00060050,0x00000020,0x000000d1,0x000000d0,0x000000d0, + 0x000000d0,0x00050088,0x00000020,0x000000d2,0x000000cf,0x000000d1,0x0003003e,0x000000cc, + 0x000000d2,0x0004003d,0x00000020,0x000000d5,0x000000cc,0x0005008e,0x00000020,0x000000d6, + 0x000000d5,0x000000d4,0x00060050,0x00000020,0x000000d7,0x0000000e,0x0000000e,0x0000000e, + 0x00050081,0x00000020,0x000000d8,0x000000d7,0x000000d6,0x00050088,0x00000020,0x000000d9, + 0x000000b4,0x000000d8,0x0003003e,0x000000d3,0x000000d9,0x0004003d,0x00000020,0x000000db, + 0x00000036,0x0004003d,0x00000020,0x000000dc,0x0000004d,0x00050081,0x00000020,0x000000dd, + 0x000000db,0x000000dc,0x0004003d,0x00000020,0x000000de,0x0000005c,0x0004003d,0x00000020, + 0x000000df,0x00000071,0x00050081,0x00000020,0x000000e0,0x000000de,0x000000df,0x00050081, + 0x00000020,0x000000e1,0x000000dd,0x000000e0,0x0003003e,0x000000da,0x000000e1,0x0004003d, + 0x00000020,0x000000e3,0x000000da,0x0004003d,0x00000020,0x000000e4,0x000000cc,0x00050085, + 0x00000020,0x000000e5,0x000000e3,0x000000e4,0x0004003d,0x00000020,0x000000e6,0x00000057, + 0x00050081,0x00000020,0x000000e7,0x000000e5,0x000000e6,0x0004003d,0x00000020,0x000000e8, + 0x000000d3,0x00050085,0x00000020,0x000000e9,0x000000e7,0x000000e8,0x00060050,0x00000020, + 0x000000ea,0x00000039,0x00000039,0x00000039,0x00060050,0x00000020,0x000000eb,0x0000000e, + 0x0000000e,0x0000000e,0x0008000c,0x00000020,0x000000ec,0x00000001,0x0000002b,0x000000e9, + 0x000000ea,0x000000eb,0x0003003e,0x000000e2,0x000000ec,0x0004003d,0x00000020,0x000000ef, + 0x000000e2,0x00050051,0x00000006,0x000000f0,0x000000ef,0x00000000,0x00050051,0x00000006, + 0x000000f1,0x000000ef,0x00000001,0x00050051,0x00000006,0x000000f2,0x000000ef,0x00000002, + 0x00070050,0x0000000f,0x000000f3,0x000000f0,0x000000f1,0x000000f2,0x0000000e,0x0003003e, + 0x000000ee,0x000000f3,0x000100fd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/color.frag b/app/src/main/cpp/shaders/color.frag new file mode 100644 index 0000000000..8629453f71 --- /dev/null +++ b/app/src/main/cpp/shaders/color.frag @@ -0,0 +1,52 @@ +#version 450 + +// ============================================================================= +// Color grade (brightness / contrast / saturation / gamma) post effect. +// +// Ported verbatim from the OpenGL ColorEffect.java shader. The four terms are +// prepared CPU-side (planUpscaleFrame) exactly as the GL path does: +// brightness = brightnessSlider / 100 clamped to [-1, 1] +// contrast = contrastSlider / 100 clamped to [ 0, 2] +// saturation = saturationSlider / 100 clamped to [ 0, 2] +// gamma = gammaSlider clamped to [0.1, 5] +// (the clamps replicate ColorEffectMaterial.use()). Neutral = (0,0,1,1) -> no-op, +// matching the GL "remove the effect" check; the chain skips Color when neutral. +// +// Term ORDER inside this shader is brightness -> contrast -> saturation -> gamma. +// Saturation sits after contrast and before gamma deliberately: it mixes towards +// Rec.709 luma of the already-graded linear-ish signal, so the greyscale it blends +// against is the one the viewer sees, and the gamma curve is still applied last to +// the finished colour. ColorEffect.java applies its terms in the same order, so a +// Screen Effect "Look" grades identically on the OpenGL and Vulkan renderers. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// `saturation` is APPENDED at the end of the block so the offsets of the three +// original terms are unchanged. +// Runs after Toon, before CAS in the canonical chain (grade the clean image). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + float brightness; // additive, [-1, 1] + float contrast; // [0, 2]; effective multiplier = clamp(contrast+1, 0.5, 2) + float gamma; // [0.1, 5] + float saturation; // [0, 2]; 1 = unchanged, 0 = greyscale +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec4 texelColor = texture(InputTexture, fragTexCoord); + vec3 color = texelColor.rgb; + color = clamp(color + pc.brightness, 0.0, 1.0); + color = (color - 0.5) * clamp(pc.contrast + 1.0, 0.5, 2.0) + 0.5; + vec3 grey = vec3(dot(color, vec3(0.2126, 0.7152, 0.0722))); + color = mix(grey, color, clamp(pc.saturation, 0.0, 2.0)); + color = max(color, vec3(0.0)); + color = pow(color, vec3(1.0 / pc.gamma)); + outColor = vec4(color, texelColor.a); +} diff --git a/app/src/main/cpp/shaders/color_frag.h b/app/src/main/cpp/shaders/color_frag.h index 7026c7c880..f8237dc27d 100644 --- a/app/src/main/cpp/shaders/color_frag.h +++ b/app/src/main/cpp/shaders/color_frag.h @@ -1,8 +1,9 @@ + // 1116.3.0 #pragma once const uint32_t color_code[] = { - 0x07230203,0x00010000,0x0008000b,0x00000059,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x0000005c,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000011,0x0000004e,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000011,0x00000051,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00050005,0x00000009,0x65786574,0x6c6f436c,0x0000726f,0x00060005,0x0000000d, 0x75706e49,0x78655474,0x65727574,0x00000000,0x00060005,0x00000011,0x67617266,0x43786554, @@ -11,13 +12,13 @@ const uint32_t color_code[] = { 0x67697262,0x656e7468,0x00007373,0x00060006,0x0000001a,0x00000002,0x746e6f63,0x74736172, 0x00000000,0x00050006,0x0000001a,0x00000003,0x6d6d6167,0x00000061,0x00060006,0x0000001a, 0x00000004,0x75746173,0x69746172,0x00006e6f,0x00030005,0x0000001c,0x00006370,0x00040005, - 0x00000036,0x79657267,0x00000000,0x00050005,0x0000004e,0x4374756f,0x726f6c6f,0x00000000, + 0x00000036,0x79657267,0x00000000,0x00050005,0x00000051,0x4374756f,0x726f6c6f,0x00000000, 0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x0000000d,0x00000022,0x00000000, 0x00040047,0x00000011,0x0000001e,0x00000000,0x00030047,0x0000001a,0x00000002,0x00050048, 0x0000001a,0x00000000,0x00000023,0x00000000,0x00050048,0x0000001a,0x00000001,0x00000023, 0x00000010,0x00050048,0x0000001a,0x00000002,0x00000023,0x00000014,0x00050048,0x0000001a, 0x00000003,0x00000023,0x00000018,0x00050048,0x0000001a,0x00000004,0x00000023,0x0000001c, - 0x00040047,0x0000004e,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, + 0x00040047,0x00000051,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, 0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004, 0x00040020,0x00000008,0x00000007,0x00000007,0x00090019,0x0000000a,0x00000006,0x00000001, 0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a, @@ -33,43 +34,46 @@ const uint32_t color_code[] = { 0x00000006,0x00000031,0x40000000,0x0004002b,0x00000006,0x00000038,0x3e59b3d0,0x0004002b, 0x00000006,0x00000039,0x3f371759,0x0004002b,0x00000006,0x0000003a,0x3d93dd98,0x0006002c, 0x00000014,0x0000003b,0x00000038,0x00000039,0x0000003a,0x0004002b,0x0000001d,0x00000040, - 0x00000004,0x0004002b,0x0000001d,0x00000047,0x00000003,0x00040020,0x0000004d,0x00000003, - 0x00000007,0x0004003b,0x0000004d,0x0000004e,0x00000003,0x00040015,0x00000050,0x00000020, - 0x00000000,0x0004002b,0x00000050,0x00000051,0x00000003,0x00040020,0x00000052,0x00000007, - 0x00000006,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, - 0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000015,0x00000016,0x00000007, - 0x0004003b,0x00000015,0x00000036,0x00000007,0x0004003d,0x0000000b,0x0000000e,0x0000000d, - 0x0004003d,0x0000000f,0x00000012,0x00000011,0x00050057,0x00000007,0x00000013,0x0000000e, - 0x00000012,0x0003003e,0x00000009,0x00000013,0x0004003d,0x00000007,0x00000017,0x00000009, - 0x0008004f,0x00000014,0x00000018,0x00000017,0x00000017,0x00000000,0x00000001,0x00000002, - 0x0003003e,0x00000016,0x00000018,0x0004003d,0x00000014,0x00000019,0x00000016,0x00050041, - 0x0000001f,0x00000020,0x0000001c,0x0000001e,0x0004003d,0x00000006,0x00000021,0x00000020, - 0x00060050,0x00000014,0x00000022,0x00000021,0x00000021,0x00000021,0x00050081,0x00000014, - 0x00000023,0x00000019,0x00000022,0x00060050,0x00000014,0x00000026,0x00000024,0x00000024, - 0x00000024,0x00060050,0x00000014,0x00000027,0x00000025,0x00000025,0x00000025,0x0008000c, - 0x00000014,0x00000028,0x00000001,0x0000002b,0x00000023,0x00000026,0x00000027,0x0003003e, - 0x00000016,0x00000028,0x0004003d,0x00000014,0x00000029,0x00000016,0x00060050,0x00000014, - 0x0000002b,0x0000002a,0x0000002a,0x0000002a,0x00050083,0x00000014,0x0000002c,0x00000029, - 0x0000002b,0x00050041,0x0000001f,0x0000002e,0x0000001c,0x0000002d,0x0004003d,0x00000006, - 0x0000002f,0x0000002e,0x00050081,0x00000006,0x00000030,0x0000002f,0x00000025,0x0008000c, - 0x00000006,0x00000032,0x00000001,0x0000002b,0x00000030,0x0000002a,0x00000031,0x0005008e, - 0x00000014,0x00000033,0x0000002c,0x00000032,0x00060050,0x00000014,0x00000034,0x0000002a, - 0x0000002a,0x0000002a,0x00050081,0x00000014,0x00000035,0x00000033,0x00000034,0x0003003e, - 0x00000016,0x00000035,0x0004003d,0x00000014,0x00000037,0x00000016,0x00050094,0x00000006, - 0x0000003c,0x00000037,0x0000003b,0x00060050,0x00000014,0x0000003d,0x0000003c,0x0000003c, - 0x0000003c,0x0003003e,0x00000036,0x0000003d,0x0004003d,0x00000014,0x0000003e,0x00000036, - 0x0004003d,0x00000014,0x0000003f,0x00000016,0x00050041,0x0000001f,0x00000041,0x0000001c, - 0x00000040,0x0004003d,0x00000006,0x00000042,0x00000041,0x0008000c,0x00000006,0x00000043, - 0x00000001,0x0000002b,0x00000042,0x00000024,0x00000031,0x00060050,0x00000014,0x00000044, - 0x00000043,0x00000043,0x00000043,0x0008000c,0x00000014,0x00000045,0x00000001,0x0000002e, - 0x0000003e,0x0000003f,0x00000044,0x0003003e,0x00000016,0x00000045,0x0004003d,0x00000014, - 0x00000046,0x00000016,0x00050041,0x0000001f,0x00000048,0x0000001c,0x00000047,0x0004003d, - 0x00000006,0x00000049,0x00000048,0x00050088,0x00000006,0x0000004a,0x00000025,0x00000049, - 0x00060050,0x00000014,0x0000004b,0x0000004a,0x0000004a,0x0000004a,0x0007000c,0x00000014, - 0x0000004c,0x00000001,0x0000001a,0x00000046,0x0000004b,0x0003003e,0x00000016,0x0000004c, - 0x0004003d,0x00000014,0x0000004f,0x00000016,0x00050041,0x00000052,0x00000053,0x00000009, - 0x00000051,0x0004003d,0x00000006,0x00000054,0x00000053,0x00050051,0x00000006,0x00000055, - 0x0000004f,0x00000000,0x00050051,0x00000006,0x00000056,0x0000004f,0x00000001,0x00050051, - 0x00000006,0x00000057,0x0000004f,0x00000002,0x00070050,0x00000007,0x00000058,0x00000055, - 0x00000056,0x00000057,0x00000054,0x0003003e,0x0000004e,0x00000058,0x000100fd,0x00010038 + 0x00000004,0x0006002c,0x00000014,0x00000047,0x00000024,0x00000024,0x00000024,0x0004002b, + 0x0000001d,0x0000004a,0x00000003,0x00040020,0x00000050,0x00000003,0x00000007,0x0004003b, + 0x00000050,0x00000051,0x00000003,0x00040015,0x00000053,0x00000020,0x00000000,0x0004002b, + 0x00000053,0x00000054,0x00000003,0x00040020,0x00000055,0x00000007,0x00000006,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008, + 0x00000009,0x00000007,0x0004003b,0x00000015,0x00000016,0x00000007,0x0004003b,0x00000015, + 0x00000036,0x00000007,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d,0x0000000f, + 0x00000012,0x00000011,0x00050057,0x00000007,0x00000013,0x0000000e,0x00000012,0x0003003e, + 0x00000009,0x00000013,0x0004003d,0x00000007,0x00000017,0x00000009,0x0008004f,0x00000014, + 0x00000018,0x00000017,0x00000017,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000016, + 0x00000018,0x0004003d,0x00000014,0x00000019,0x00000016,0x00050041,0x0000001f,0x00000020, + 0x0000001c,0x0000001e,0x0004003d,0x00000006,0x00000021,0x00000020,0x00060050,0x00000014, + 0x00000022,0x00000021,0x00000021,0x00000021,0x00050081,0x00000014,0x00000023,0x00000019, + 0x00000022,0x00060050,0x00000014,0x00000026,0x00000024,0x00000024,0x00000024,0x00060050, + 0x00000014,0x00000027,0x00000025,0x00000025,0x00000025,0x0008000c,0x00000014,0x00000028, + 0x00000001,0x0000002b,0x00000023,0x00000026,0x00000027,0x0003003e,0x00000016,0x00000028, + 0x0004003d,0x00000014,0x00000029,0x00000016,0x00060050,0x00000014,0x0000002b,0x0000002a, + 0x0000002a,0x0000002a,0x00050083,0x00000014,0x0000002c,0x00000029,0x0000002b,0x00050041, + 0x0000001f,0x0000002e,0x0000001c,0x0000002d,0x0004003d,0x00000006,0x0000002f,0x0000002e, + 0x00050081,0x00000006,0x00000030,0x0000002f,0x00000025,0x0008000c,0x00000006,0x00000032, + 0x00000001,0x0000002b,0x00000030,0x0000002a,0x00000031,0x0005008e,0x00000014,0x00000033, + 0x0000002c,0x00000032,0x00060050,0x00000014,0x00000034,0x0000002a,0x0000002a,0x0000002a, + 0x00050081,0x00000014,0x00000035,0x00000033,0x00000034,0x0003003e,0x00000016,0x00000035, + 0x0004003d,0x00000014,0x00000037,0x00000016,0x00050094,0x00000006,0x0000003c,0x00000037, + 0x0000003b,0x00060050,0x00000014,0x0000003d,0x0000003c,0x0000003c,0x0000003c,0x0003003e, + 0x00000036,0x0000003d,0x0004003d,0x00000014,0x0000003e,0x00000036,0x0004003d,0x00000014, + 0x0000003f,0x00000016,0x00050041,0x0000001f,0x00000041,0x0000001c,0x00000040,0x0004003d, + 0x00000006,0x00000042,0x00000041,0x0008000c,0x00000006,0x00000043,0x00000001,0x0000002b, + 0x00000042,0x00000024,0x00000031,0x00060050,0x00000014,0x00000044,0x00000043,0x00000043, + 0x00000043,0x0008000c,0x00000014,0x00000045,0x00000001,0x0000002e,0x0000003e,0x0000003f, + 0x00000044,0x0003003e,0x00000016,0x00000045,0x0004003d,0x00000014,0x00000046,0x00000016, + 0x0007000c,0x00000014,0x00000048,0x00000001,0x00000028,0x00000046,0x00000047,0x0003003e, + 0x00000016,0x00000048,0x0004003d,0x00000014,0x00000049,0x00000016,0x00050041,0x0000001f, + 0x0000004b,0x0000001c,0x0000004a,0x0004003d,0x00000006,0x0000004c,0x0000004b,0x00050088, + 0x00000006,0x0000004d,0x00000025,0x0000004c,0x00060050,0x00000014,0x0000004e,0x0000004d, + 0x0000004d,0x0000004d,0x0007000c,0x00000014,0x0000004f,0x00000001,0x0000001a,0x00000049, + 0x0000004e,0x0003003e,0x00000016,0x0000004f,0x0004003d,0x00000014,0x00000052,0x00000016, + 0x00050041,0x00000055,0x00000056,0x00000009,0x00000054,0x0004003d,0x00000006,0x00000057, + 0x00000056,0x00050051,0x00000006,0x00000058,0x00000052,0x00000000,0x00050051,0x00000006, + 0x00000059,0x00000052,0x00000001,0x00050051,0x00000006,0x0000005a,0x00000052,0x00000002, + 0x00070050,0x00000007,0x0000005b,0x00000058,0x00000059,0x0000005a,0x00000057,0x0003003e, + 0x00000051,0x0000005b,0x000100fd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/crt.frag b/app/src/main/cpp/shaders/crt.frag new file mode 100644 index 0000000000..1903549e95 --- /dev/null +++ b/app/src/main/cpp/shaders/crt.frag @@ -0,0 +1,42 @@ +#version 450 + +// ============================================================================= +// CRT (chromatic aberration + scanlines) post effect. +// +// Ported verbatim from the OpenGL CRTEffect.java shader. GL sampled with the +// varying vUV; here fragTexCoord IS that uv. All constants unchanged. Runs LAST +// in the canonical chain (the physical tube emulation, after NTSC's analog +// signal). Does not need the resolution, but the PC carries it for a uniform +// effect-PC layout. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in px (unused; layout uniformity) +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define CA_AMOUNT 1.0025 +#define SCANLINE_INTENSITY_X 0.125 +#define SCANLINE_INTENSITY_Y 0.375 +#define SCANLINE_SIZE 1024.0 + +void main() { + vec2 vUV = fragTexCoord; + vec4 finalColor = texture(InputTexture, vUV); + finalColor.rgb = vec3( + texture(InputTexture, (vUV - 0.5) * CA_AMOUNT + 0.5).r, + finalColor.g, + texture(InputTexture, (vUV - 0.5) / CA_AMOUNT + 0.5).b + ); + float scanlineX = abs(sin(vUV.x * SCANLINE_SIZE) * 0.5 * SCANLINE_INTENSITY_X); + float scanlineY = abs(sin(vUV.y * SCANLINE_SIZE) * 0.5 * SCANLINE_INTENSITY_Y); + outColor = vec4(mix(finalColor.rgb, vec3(0.0), scanlineX + scanlineY), finalColor.a); +} diff --git a/app/src/main/cpp/shaders/deband.frag b/app/src/main/cpp/shaders/deband.frag new file mode 100644 index 0000000000..025012608e --- /dev/null +++ b/app/src/main/cpp/shaders/deband.frag @@ -0,0 +1,56 @@ +#version 450 + +// ============================================================================= +// Debanding / dither - terminal post pass. +// +// Adds sub-LSB triangular-PDF (TPDF) noise just before the final 8-bit +// swapchain quantization, so smooth gradients (dark skies, fog, bloom +// falloff, vignettes) stop showing 8-bit "stair-step" banding. Especially +// visible on AMOLED panels in dark scenes. +// +// This is the LAST pass in the effect chain and always writes the swapchain, +// so the dither matches the display quantizer. The whole compositor chain is +// R8G8B8A8_UNORM and the swapchain has no _SRGB view, i.e. values are already +// display(gamma)-encoded here - so we dither in display space, ~1 LSB = 1/255, +// which is where AMOLED banding is worst (the darks). +// +// Noise = interleaved gradient noise (Jimenez 2014, public technique), two +// screen-locked samples summed for a triangular PDF (flat noise spectrum, no +// DC bias). Screen-locked (gl_FragCoord) so the pattern is static = no shimmer. +// Float-only hash (no floatBitsToInt / bvec / bitwise) = Adreno-compile-safe. +// +// Conventions match upscale.vert / cas.frag: combined-image-sampler at binding +// 0, push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// +// CPU side (planUpscaleFrame) maps the UI strength slider to LSB units: +// strength = slider / 100 (slider 100 -> 1.0 LSB, the default) +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in pixels (unused here, kept for layout parity) + float strength; // dither amplitude in LSBs (1.0 = +/-1/255 triangular) +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +// Interleaved gradient noise - returns [0,1), float-only, Adreno-safe. +float ign(vec2 p) { + return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); +} + +void main() { + vec3 col = texture(InputTexture, fragTexCoord).rgb; + + // Two decorrelated samples -> triangular PDF in (-1, 1). + float n1 = ign(gl_FragCoord.xy); + float n2 = ign(gl_FragCoord.xy + vec2(11.0, 17.0)); + float tri = (n1 + n2) - 1.0; + + col += vec3(tri * (pc.strength / 255.0)); + + outColor = vec4(col, 1.0); +} diff --git a/app/src/main/cpp/shaders/fsr_easu.frag b/app/src/main/cpp/shaders/fsr_easu.frag new file mode 100644 index 0000000000..dbc66824eb --- /dev/null +++ b/app/src/main/cpp/shaders/fsr_easu.frag @@ -0,0 +1,221 @@ +#version 450 + +// ============================================================================= +// AMD FidelityFX Super Resolution 1.0 - EASU (Edge-Adaptive Spatial Upsampling). +// +// Algorithm (FsrEasuF / FsrEasuTapF / FsrEasuSetF) ported verbatim from AMD's +// reference header: GPUOpen-Effects/FidelityFX-FSR ffx-fsr/ffx_fsr1.h +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Full license text is included in THIRD_PARTY_NOTICES.txt and packaged +// in the APK at assets/licenses/graphics/THIRD_PARTY_NOTICES.txt. +// +// Adapted for the Winlator native Vulkan compositor: +// - fp32-only path (the AF1/AU1 portability macros below replace ffx_a.h) +// - con0..con3 are computed CPU-side (FsrEasuCon) and delivered via push const +// - output pixel position comes from window.vert's fragTexCoord * outputSize +// - input sampled via textureGather on a CLAMP_TO_EDGE / linear sampler +// ============================================================================= + +// ---- minimal ffx_a.h fp32 portability layer ------------------------------- +#define AF1 float +#define AF2 vec2 +#define AF3 vec3 +#define AF4 vec4 +#define AU1 uint +#define AU2 uvec2 +#define AU4 uvec4 +#define ASU2 ivec2 +#define AP1 bool +#define AF1_(a) float(a) +#define AF2_(a) vec2(AF1_(a)) +#define AF3_(a) vec3(AF1_(a)) +#define AF4_(a) vec4(AF1_(a)) +#define AF2_AU2(x) uintBitsToFloat(uvec2(x)) +#define AF1_AU1(x) uintBitsToFloat(uint(x)) +float ARcpF1(float x) { return 1.0 / x; } +float APrxLoRcpF1(float x) { return 1.0 / x; } +float APrxMedRcpF1(float x){ return 1.0 / x; } +float APrxLoRsqF1(float x) { return inversesqrt(x); } +float ASatF1(float x) { return clamp(x, 0.0, 1.0); } +vec3 AMin3F3(vec3 a, vec3 b, vec3 c) { return min(a, min(b, c)); } +vec3 AMax3F3(vec3 a, vec3 b, vec3 c) { return max(a, max(b, c)); } +// --------------------------------------------------------------------------- + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in AMD's +// FSR_EASU_H / FSR_RCAS_H paths; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif +#ifdef DD_HALF +// 1/32768 is a 16-bit subnormal (flushed to 0 where denormals are not kept); +// 1/16384 is the smallest normal one. +#define BL_EASU_DIR_ZERO (1.0/16384.0) +#else +#define BL_EASU_DIR_ZERO (1.0/32768.0) +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + uvec4 con0; + uvec4 con1; + uvec4 con2; + uvec4 con3; + highp vec2 outputSize; // EASU output (this pass's render-target) size in pixels +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +AF4 FsrEasuRF(highp AF2 p) { return textureGather(InputTexture, p, 0); } +AF4 FsrEasuGF(highp AF2 p) { return textureGather(InputTexture, p, 1); } +AF4 FsrEasuBF(highp AF2 p) { return textureGather(InputTexture, p, 2); } + +void FsrEasuTapF( + inout AF3 aC, + inout AF1 aW, + AF2 off, + AF2 dir, + AF2 len, + AF1 lob, + AF1 clp, + AF3 c){ + AF2 v; + v.x=(off.x*( dir.x))+(off.y*dir.y); + v.y=(off.x*(-dir.y))+(off.y*dir.x); + v*=len; + AF1 d2=v.x*v.x+v.y*v.y; + d2=min(d2,clp); + AF1 wB=AF1_(2.0/5.0)*d2+AF1_(-1.0); + AF1 wA=lob*d2+AF1_(-1.0); + wB*=wB; + wA*=wA; + wB=AF1_(25.0/16.0)*wB+AF1_(-(25.0/16.0-1.0)); + AF1 w=wB*wA; + aC+=c*w;aW+=w;} + +void FsrEasuSetF( + inout AF2 dir, + inout AF1 len, + AF2 pp, + AP1 biS,AP1 biT,AP1 biU,AP1 biV, + AF1 lA,AF1 lB,AF1 lC,AF1 lD,AF1 lE){ + AF1 w = AF1_(0.0); + if(biS)w=(AF1_(1.0)-pp.x)*(AF1_(1.0)-pp.y); + if(biT)w= pp.x *(AF1_(1.0)-pp.y); + if(biU)w=(AF1_(1.0)-pp.x)* pp.y ; + if(biV)w= pp.x * pp.y ; + AF1 dc=lD-lC; + AF1 cb=lC-lB; + AF1 lenX=max(abs(dc),abs(cb)); + lenX=lenX>0.0?APrxLoRcpF1(lenX):AF1_(0.0); + AF1 dirX=lD-lB; + dir.x+=dirX*w; + lenX=ASatF1(abs(dirX)*lenX); + lenX*=lenX; + len+=lenX*w; + AF1 ec=lE-lC; + AF1 ca=lC-lA; + AF1 lenY=max(abs(ec),abs(ca)); + lenY=lenY>0.0?APrxLoRcpF1(lenY):AF1_(0.0); + AF1 dirY=lE-lA; + dir.y+=dirY*w; + lenY=ASatF1(abs(dirY)*lenY); + lenY*=lenY; + len+=lenY*w;} + +void FsrEasuF( + out AF3 pix, + AU2 ip, + AU4 con0, + AU4 con1, + AU4 con2, + AU4 con3){ + highp AF2 pp=AF2(ip)*AF2_AU2(con0.xy)+AF2_AU2(con0.zw); + highp AF2 fp=floor(pp); + pp-=fp; + highp AF2 p0=fp*AF2_AU2(con1.xy)+AF2_AU2(con1.zw); + highp AF2 p1=p0+AF2_AU2(con2.xy); + highp AF2 p2=p0+AF2_AU2(con2.zw); + highp AF2 p3=p0+AF2_AU2(con3.xy); + AF4 bczzR=FsrEasuRF(p0); + AF4 bczzG=FsrEasuGF(p0); + AF4 bczzB=FsrEasuBF(p0); + AF4 ijfeR=FsrEasuRF(p1); + AF4 ijfeG=FsrEasuGF(p1); + AF4 ijfeB=FsrEasuBF(p1); + AF4 klhgR=FsrEasuRF(p2); + AF4 klhgG=FsrEasuGF(p2); + AF4 klhgB=FsrEasuBF(p2); + AF4 zzonR=FsrEasuRF(p3); + AF4 zzonG=FsrEasuGF(p3); + AF4 zzonB=FsrEasuBF(p3); + AF4 bczzL=bczzB*AF4_(0.5)+(bczzR*AF4_(0.5)+bczzG); + AF4 ijfeL=ijfeB*AF4_(0.5)+(ijfeR*AF4_(0.5)+ijfeG); + AF4 klhgL=klhgB*AF4_(0.5)+(klhgR*AF4_(0.5)+klhgG); + AF4 zzonL=zzonB*AF4_(0.5)+(zzonR*AF4_(0.5)+zzonG); + AF1 bL=bczzL.x; + AF1 cL=bczzL.y; + AF1 iL=ijfeL.x; + AF1 jL=ijfeL.y; + AF1 fL=ijfeL.z; + AF1 eL=ijfeL.w; + AF1 kL=klhgL.x; + AF1 lL=klhgL.y; + AF1 hL=klhgL.z; + AF1 gL=klhgL.w; + AF1 oL=zzonL.z; + AF1 nL=zzonL.w; + AF2 dir=AF2_(0.0); + AF1 len=AF1_(0.0); + FsrEasuSetF(dir,len,pp,true, false,false,false,bL,eL,fL,gL,jL); + FsrEasuSetF(dir,len,pp,false,true ,false,false,cL,fL,gL,hL,kL); + FsrEasuSetF(dir,len,pp,false,false,true ,false,fL,iL,jL,kL,nL); + FsrEasuSetF(dir,len,pp,false,false,false,true ,gL,jL,kL,lL,oL); + AF2 dir2=dir*dir; + AF1 dirR=dir2.x+dir2.y; + AP1 zro=dirR push const con +// - input is the EASU output (already at output resolution), read 1:1 via +// texelFetch with edge clamping for robustness +// ============================================================================= + +// ---- minimal ffx_a.h fp32 portability layer ------------------------------- +#define AF1 float +#define AF2 vec2 +#define AF3 vec3 +#define AF4 vec4 +#define AU2 uvec2 +#define AU4 uvec4 +#define ASU2 ivec2 +#define AF1_(a) float(a) +#define AF1_AU1(x) uintBitsToFloat(uint(x)) +float ARcpF1(float x) { return 1.0 / x; } +float APrxMedRcpF1(float x){ return 1.0 / x; } +float ASatF1(float x) { return clamp(x, 0.0, 1.0); } +float AMin3F1(float a, float b, float c) { return min(a, min(b, c)); } +float AMax3F1(float a, float b, float c) { return max(a, max(b, c)); } +#define FSR_RCAS_LIMIT (0.25 - (1.0 / 16.0)) +// --------------------------------------------------------------------------- + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in AMD's +// FSR_EASU_H / FSR_RCAS_H paths; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; // EASU output, output res + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + uvec4 con; // con.x = bit-packed sharpness (FsrRcasCon) + highp vec2 outputSize; // pass output size in pixels +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +AF4 FsrRcasLoadF(ASU2 p) { + ivec2 sz = textureSize(InputTexture, 0); + return texelFetch(InputTexture, clamp(p, ivec2(0), sz - ivec2(1)), 0); +} +void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {} + +void FsrRcasF( + out AF1 pixR, + out AF1 pixG, + out AF1 pixB, + AU2 ip, + AU4 con){ + ASU2 sp=ASU2(ip); + AF3 b=FsrRcasLoadF(sp+ASU2( 0,-1)).rgb; + AF3 d=FsrRcasLoadF(sp+ASU2(-1, 0)).rgb; + AF3 e=FsrRcasLoadF(sp).rgb; + AF3 f=FsrRcasLoadF(sp+ASU2( 1, 0)).rgb; + AF3 h=FsrRcasLoadF(sp+ASU2( 0, 1)).rgb; + AF1 bR=b.r; + AF1 bG=b.g; + AF1 bB=b.b; + AF1 dR=d.r; + AF1 dG=d.g; + AF1 dB=d.b; + AF1 eR=e.r; + AF1 eG=e.g; + AF1 eB=e.b; + AF1 fR=f.r; + AF1 fG=f.g; + AF1 fB=f.b; + AF1 hR=h.r; + AF1 hG=h.g; + AF1 hB=h.b; + FsrRcasInputF(bR,bG,bB); + FsrRcasInputF(dR,dG,dB); + FsrRcasInputF(eR,eG,eB); + FsrRcasInputF(fR,fG,fB); + FsrRcasInputF(hR,hG,hB); + AF1 bL=bB*AF1_(0.5)+(bR*AF1_(0.5)+bG); + AF1 dL=dB*AF1_(0.5)+(dR*AF1_(0.5)+dG); + AF1 eL=eB*AF1_(0.5)+(eR*AF1_(0.5)+eG); + AF1 fL=fB*AF1_(0.5)+(fR*AF1_(0.5)+fG); + AF1 hL=hB*AF1_(0.5)+(hR*AF1_(0.5)+hG); + AF1 nz=AF1_(0.25)*bL+AF1_(0.25)*dL+AF1_(0.25)*fL+AF1_(0.25)*hL-eL; + nz=ASatF1(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL))); + nz=AF1_(-0.5)*nz+AF1_(1.0); + AF1 mn4R=min(AMin3F1(bR,dR,fR),hR); + AF1 mn4G=min(AMin3F1(bG,dG,fG),hG); + AF1 mn4B=min(AMin3F1(bB,dB,fB),hB); + AF1 mx4R=max(AMax3F1(bR,dR,fR),hR); + AF1 mx4G=max(AMax3F1(bG,dG,fG),hG); + AF1 mx4B=max(AMax3F1(bB,dB,fB),hB); + AF2 peakC=AF2(1.0,-1.0*4.0); + AF1 denMinR=AF1_(4.0)*mx4R; + AF1 denMinG=AF1_(4.0)*mx4G; + AF1 denMinB=AF1_(4.0)*mx4B; + AF1 denMaxR=AF1_(4.0)*mn4R+peakC.y; + AF1 denMaxG=AF1_(4.0)*mn4G+peakC.y; + AF1 denMaxB=AF1_(4.0)*mn4B+peakC.y; + AF1 hitMinR=denMinR>0.0?min(mn4R,eR)/denMinR:AF1_(0.0); + AF1 hitMinG=denMinG>0.0?min(mn4G,eG)/denMinG:AF1_(0.0); + AF1 hitMinB=denMinB>0.0?min(mn4B,eB)/denMinB:AF1_(0.0); + AF1 numMaxR=peakC.x-max(mx4R,eR); + AF1 numMaxG=peakC.x-max(mx4G,eG); + AF1 numMaxB=peakC.x-max(mx4B,eB); + AF1 hitMaxR=abs(denMaxR)>1e-6?numMaxR/denMaxR:AF1_(0.0); + AF1 hitMaxG=abs(denMaxG)>1e-6?numMaxG/denMaxG:AF1_(0.0); + AF1 hitMaxB=abs(denMaxB)>1e-6?numMaxB/denMaxB:AF1_(0.0); + AF1 lobeR=max(-hitMinR,hitMaxR); + AF1 lobeG=max(-hitMinG,hitMaxG); + AF1 lobeB=max(-hitMinB,hitMaxB); + AF1 lobe=max(AF1_(-FSR_RCAS_LIMIT),min(AMax3F1(lobeR,lobeG,lobeB),AF1_(0.0)))*AF1_AU1(con.x); + AF1 rcpL=APrxMedRcpF1(AF1_(4.0)*lobe+AF1_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL; + return;} + +void main() { + uvec2 ip = uvec2(fragTexCoord * pc.outputSize); + vec3 c; + FsrRcasF(c.r, c.g, c.b, ip, pc.con); + outColor = vec4(c, 1.0); +} diff --git a/app/src/main/cpp/shaders/fsr_rcas_frag.h b/app/src/main/cpp/shaders/fsr_rcas_frag.h index f241d7590c..e011659ba6 100644 --- a/app/src/main/cpp/shaders/fsr_rcas_frag.h +++ b/app/src/main/cpp/shaders/fsr_rcas_frag.h @@ -1,468 +1,503 @@ + // 1116.3.0 #pragma once const uint32_t fsr_rcas_code[] = { - 0x07230203,0x00010000,0x0008000b,0x0000025e,0x00000000,0x00020011,0x00000001,0x00020011, + 0x07230203,0x00010000,0x0008000b,0x0000028c,0x00000000,0x00020011,0x00000001,0x00020011, 0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, - 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000023b, - 0x00000258,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, - 0x00000004,0x6e69616d,0x00000000,0x00050005,0x0000000a,0x70635241,0x66283146,0x00003b31, - 0x00030005,0x00000009,0x00000078,0x00070005,0x0000000d,0x78725041,0x5264654d,0x31467063, - 0x3b316628,0x00000000,0x00030005,0x0000000c,0x00000078,0x00050005,0x00000010,0x74615341, - 0x66283146,0x00003b31,0x00030005,0x0000000f,0x00000078,0x00070005,0x00000016,0x6e694d41, - 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000013,0x00000061,0x00030005, - 0x00000014,0x00000062,0x00030005,0x00000015,0x00000063,0x00070005,0x0000001b,0x78614d41, - 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000018,0x00000061,0x00030005, - 0x00000019,0x00000062,0x00030005,0x0000001a,0x00000063,0x00070005,0x00000023,0x52727346, - 0x4c736163,0x4664616f,0x32697628,0x0000003b,0x00030005,0x00000022,0x00000070,0x00080005, - 0x00000029,0x52727346,0x49736163,0x7475706e,0x31662846,0x3b31663b,0x003b3166,0x00030005, - 0x00000026,0x00000072,0x00030005,0x00000027,0x00000067,0x00030005,0x00000028,0x00000062, - 0x00090005,0x00000036,0x52727346,0x46736163,0x3b316628,0x663b3166,0x75763b31,0x75763b32, - 0x00003b34,0x00040005,0x00000031,0x52786970,0x00000000,0x00040005,0x00000032,0x47786970, - 0x00000000,0x00040005,0x00000033,0x42786970,0x00000000,0x00030005,0x00000034,0x00007069, - 0x00030005,0x00000035,0x006e6f63,0x00030005,0x00000054,0x00007a73,0x00060005,0x00000058, - 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000069,0x00007073,0x00030005, - 0x0000006e,0x00000062,0x00040005,0x00000073,0x61726170,0x0000006d,0x00030005,0x00000076, - 0x00000064,0x00040005,0x0000007a,0x61726170,0x0000006d,0x00030005,0x0000007d,0x00000065, - 0x00040005,0x0000007e,0x61726170,0x0000006d,0x00030005,0x00000082,0x00000066,0x00040005, - 0x00000086,0x61726170,0x0000006d,0x00030005,0x00000089,0x00000068,0x00040005,0x0000008d, - 0x61726170,0x0000006d,0x00030005,0x00000090,0x00005262,0x00030005,0x00000094,0x00004762, - 0x00030005,0x00000098,0x00004262,0x00030005,0x0000009c,0x00005264,0x00030005,0x0000009f, - 0x00004764,0x00030005,0x000000a2,0x00004264,0x00030005,0x000000a5,0x00005265,0x00030005, - 0x000000a8,0x00004765,0x00030005,0x000000ab,0x00004265,0x00030005,0x000000ae,0x00005266, - 0x00030005,0x000000b1,0x00004766,0x00030005,0x000000b4,0x00004266,0x00030005,0x000000b7, - 0x00005268,0x00030005,0x000000ba,0x00004768,0x00030005,0x000000bd,0x00004268,0x00040005, - 0x000000c0,0x61726170,0x0000006d,0x00040005,0x000000c2,0x61726170,0x0000006d,0x00040005, - 0x000000c4,0x61726170,0x0000006d,0x00040005,0x000000ca,0x61726170,0x0000006d,0x00040005, - 0x000000cc,0x61726170,0x0000006d,0x00040005,0x000000ce,0x61726170,0x0000006d,0x00040005, - 0x000000d4,0x61726170,0x0000006d,0x00040005,0x000000d6,0x61726170,0x0000006d,0x00040005, - 0x000000d8,0x61726170,0x0000006d,0x00040005,0x000000de,0x61726170,0x0000006d,0x00040005, - 0x000000e0,0x61726170,0x0000006d,0x00040005,0x000000e2,0x61726170,0x0000006d,0x00040005, - 0x000000e8,0x61726170,0x0000006d,0x00040005,0x000000ea,0x61726170,0x0000006d,0x00040005, - 0x000000ec,0x61726170,0x0000006d,0x00030005,0x000000f2,0x00004c62,0x00030005,0x000000fb, - 0x00004c64,0x00030005,0x00000103,0x00004c65,0x00030005,0x0000010b,0x00004c66,0x00030005, - 0x00000113,0x00004c68,0x00030005,0x0000011b,0x00007a6e,0x00040005,0x0000012c,0x61726170, - 0x0000006d,0x00040005,0x0000012e,0x61726170,0x0000006d,0x00040005,0x00000130,0x61726170, - 0x0000006d,0x00040005,0x00000133,0x61726170,0x0000006d,0x00040005,0x00000134,0x61726170, - 0x0000006d,0x00040005,0x00000136,0x61726170,0x0000006d,0x00040005,0x00000139,0x61726170, - 0x0000006d,0x00040005,0x0000013b,0x61726170,0x0000006d,0x00040005,0x0000013d,0x61726170, - 0x0000006d,0x00040005,0x00000140,0x61726170,0x0000006d,0x00040005,0x00000141,0x61726170, - 0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d,0x00040005,0x00000147,0x61726170, - 0x0000006d,0x00040005,0x0000014a,0x61726170,0x0000006d,0x00040005,0x00000150,0x52346e6d, - 0x00000000,0x00040005,0x00000151,0x61726170,0x0000006d,0x00040005,0x00000153,0x61726170, - 0x0000006d,0x00040005,0x00000155,0x61726170,0x0000006d,0x00040005,0x0000015a,0x47346e6d, - 0x00000000,0x00040005,0x0000015b,0x61726170,0x0000006d,0x00040005,0x0000015d,0x61726170, - 0x0000006d,0x00040005,0x0000015f,0x61726170,0x0000006d,0x00040005,0x00000164,0x42346e6d, - 0x00000000,0x00040005,0x00000165,0x61726170,0x0000006d,0x00040005,0x00000167,0x61726170, - 0x0000006d,0x00040005,0x00000169,0x61726170,0x0000006d,0x00040005,0x0000016e,0x5234786d, - 0x00000000,0x00040005,0x0000016f,0x61726170,0x0000006d,0x00040005,0x00000171,0x61726170, - 0x0000006d,0x00040005,0x00000173,0x61726170,0x0000006d,0x00040005,0x00000178,0x4734786d, - 0x00000000,0x00040005,0x00000179,0x61726170,0x0000006d,0x00040005,0x0000017b,0x61726170, - 0x0000006d,0x00040005,0x0000017d,0x61726170,0x0000006d,0x00040005,0x00000182,0x4234786d, - 0x00000000,0x00040005,0x00000183,0x61726170,0x0000006d,0x00040005,0x00000185,0x61726170, - 0x0000006d,0x00040005,0x00000187,0x61726170,0x0000006d,0x00040005,0x0000018e,0x6b616570, - 0x00000043,0x00040005,0x00000191,0x4d746968,0x00526e69,0x00040005,0x00000198,0x61726170, - 0x0000006d,0x00040005,0x0000019b,0x4d746968,0x00476e69,0x00040005,0x000001a1,0x61726170, - 0x0000006d,0x00040005,0x000001a4,0x4d746968,0x00426e69,0x00040005,0x000001aa,0x61726170, - 0x0000006d,0x00040005,0x000001ad,0x4d746968,0x00527861,0x00040005,0x000001b9,0x61726170, - 0x0000006d,0x00040005,0x000001bc,0x4d746968,0x00477861,0x00040005,0x000001c8,0x61726170, - 0x0000006d,0x00040005,0x000001cb,0x4d746968,0x00427861,0x00040005,0x000001d7,0x61726170, - 0x0000006d,0x00040005,0x000001da,0x65626f6c,0x00000052,0x00040005,0x000001df,0x65626f6c, - 0x00000047,0x00040005,0x000001e4,0x65626f6c,0x00000042,0x00040005,0x000001e9,0x65626f6c, - 0x00000000,0x00040005,0x000001eb,0x61726170,0x0000006d,0x00040005,0x000001ed,0x61726170, - 0x0000006d,0x00040005,0x000001ef,0x61726170,0x0000006d,0x00040005,0x000001f9,0x4c706372, - 0x00000000,0x00040005,0x000001fd,0x61726170,0x0000006d,0x00030005,0x00000239,0x00007069, - 0x00060005,0x0000023b,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00030005,0x0000023d, - 0x00004350,0x00040006,0x0000023d,0x00000000,0x0063646e,0x00040006,0x0000023d,0x00000001, - 0x006e6f63,0x00060006,0x0000023d,0x00000002,0x7074756f,0x69537475,0x0000657a,0x00030005, - 0x0000023f,0x00006370,0x00030005,0x00000246,0x00000063,0x00040005,0x00000247,0x61726170, - 0x0000006d,0x00040005,0x00000248,0x61726170,0x0000006d,0x00040005,0x00000249,0x61726170, - 0x0000006d,0x00040005,0x0000024a,0x61726170,0x0000006d,0x00040005,0x0000024c,0x61726170, - 0x0000006d,0x00050005,0x00000258,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x00000058, - 0x00000021,0x00000000,0x00040047,0x00000058,0x00000022,0x00000000,0x00040047,0x0000023b, - 0x0000001e,0x00000000,0x00030047,0x0000023d,0x00000002,0x00050048,0x0000023d,0x00000000, - 0x00000023,0x00000000,0x00050048,0x0000023d,0x00000001,0x00000023,0x00000010,0x00050048, - 0x0000023d,0x00000002,0x00000023,0x00000020,0x00040047,0x00000258,0x0000001e,0x00000000, - 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, - 0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007, - 0x00060021,0x00000012,0x00000006,0x00000007,0x00000007,0x00000007,0x00040015,0x0000001d, - 0x00000020,0x00000001,0x00040017,0x0000001e,0x0000001d,0x00000002,0x00040020,0x0000001f, - 0x00000007,0x0000001e,0x00040017,0x00000020,0x00000006,0x00000004,0x00040021,0x00000021, - 0x00000020,0x0000001f,0x00060021,0x00000025,0x00000002,0x00000007,0x00000007,0x00000007, - 0x00040015,0x0000002b,0x00000020,0x00000000,0x00040017,0x0000002c,0x0000002b,0x00000002, - 0x00040020,0x0000002d,0x00000007,0x0000002c,0x00040017,0x0000002e,0x0000002b,0x00000004, - 0x00040020,0x0000002f,0x00000007,0x0000002e,0x00080021,0x00000030,0x00000002,0x00000007, - 0x00000007,0x00000007,0x0000002d,0x0000002f,0x0004002b,0x00000006,0x00000038,0x3f800000, - 0x0004002b,0x00000006,0x00000042,0x00000000,0x00090019,0x00000055,0x00000006,0x00000001, - 0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000056,0x00000055, - 0x00040020,0x00000057,0x00000000,0x00000056,0x0004003b,0x00000057,0x00000058,0x00000000, - 0x0004002b,0x0000001d,0x0000005a,0x00000000,0x0005002c,0x0000001e,0x0000005f,0x0000005a, - 0x0000005a,0x0004002b,0x0000001d,0x00000061,0x00000001,0x0005002c,0x0000001e,0x00000062, - 0x00000061,0x00000061,0x00040017,0x0000006c,0x00000006,0x00000003,0x00040020,0x0000006d, - 0x00000007,0x0000006c,0x0004002b,0x0000001d,0x00000070,0xffffffff,0x0005002c,0x0000001e, - 0x00000071,0x0000005a,0x00000070,0x0005002c,0x0000001e,0x00000078,0x00000070,0x0000005a, - 0x0005002c,0x0000001e,0x00000084,0x00000061,0x0000005a,0x0005002c,0x0000001e,0x0000008b, - 0x0000005a,0x00000061,0x0004002b,0x0000002b,0x00000091,0x00000000,0x0004002b,0x0000002b, - 0x00000095,0x00000001,0x0004002b,0x0000002b,0x00000099,0x00000002,0x0004002b,0x00000006, - 0x000000f4,0x3f000000,0x0004002b,0x00000006,0x0000011c,0x3e800000,0x0004002b,0x00000006, - 0x0000014c,0xbf000000,0x00040017,0x0000018c,0x00000006,0x00000002,0x00040020,0x0000018d, - 0x00000007,0x0000018c,0x0004002b,0x00000006,0x0000018f,0xc0800000,0x0005002c,0x0000018c, - 0x00000190,0x00000038,0x0000018f,0x0004002b,0x00000006,0x00000195,0x40800000,0x0004002b, - 0x00000006,0x000001ea,0xbe400000,0x00040020,0x000001f4,0x00000007,0x0000002b,0x00040020, - 0x0000023a,0x00000001,0x0000018c,0x0004003b,0x0000023a,0x0000023b,0x00000001,0x0005001e, - 0x0000023d,0x00000020,0x0000002e,0x0000018c,0x00040020,0x0000023e,0x00000009,0x0000023d, - 0x0004003b,0x0000023e,0x0000023f,0x00000009,0x0004002b,0x0000001d,0x00000240,0x00000002, - 0x00040020,0x00000241,0x00000009,0x0000018c,0x00040020,0x0000024d,0x00000009,0x0000002e, - 0x00040020,0x00000257,0x00000003,0x00000020,0x0004003b,0x00000257,0x00000258,0x00000003, - 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b, - 0x0000002d,0x00000239,0x00000007,0x0004003b,0x0000006d,0x00000246,0x00000007,0x0004003b, - 0x00000007,0x00000247,0x00000007,0x0004003b,0x00000007,0x00000248,0x00000007,0x0004003b, - 0x00000007,0x00000249,0x00000007,0x0004003b,0x0000002d,0x0000024a,0x00000007,0x0004003b, - 0x0000002f,0x0000024c,0x00000007,0x0004003d,0x0000018c,0x0000023c,0x0000023b,0x00050041, - 0x00000241,0x00000242,0x0000023f,0x00000240,0x0004003d,0x0000018c,0x00000243,0x00000242, - 0x00050085,0x0000018c,0x00000244,0x0000023c,0x00000243,0x0004006d,0x0000002c,0x00000245, - 0x00000244,0x0003003e,0x00000239,0x00000245,0x0004003d,0x0000002c,0x0000024b,0x00000239, - 0x0003003e,0x0000024a,0x0000024b,0x00050041,0x0000024d,0x0000024e,0x0000023f,0x00000061, - 0x0004003d,0x0000002e,0x0000024f,0x0000024e,0x0003003e,0x0000024c,0x0000024f,0x00090039, - 0x00000002,0x00000250,0x00000036,0x00000247,0x00000248,0x00000249,0x0000024a,0x0000024c, - 0x0004003d,0x00000006,0x00000251,0x00000247,0x00050041,0x00000007,0x00000252,0x00000246, - 0x00000091,0x0003003e,0x00000252,0x00000251,0x0004003d,0x00000006,0x00000253,0x00000248, - 0x00050041,0x00000007,0x00000254,0x00000246,0x00000095,0x0003003e,0x00000254,0x00000253, - 0x0004003d,0x00000006,0x00000255,0x00000249,0x00050041,0x00000007,0x00000256,0x00000246, - 0x00000099,0x0003003e,0x00000256,0x00000255,0x0004003d,0x0000006c,0x00000259,0x00000246, - 0x00050051,0x00000006,0x0000025a,0x00000259,0x00000000,0x00050051,0x00000006,0x0000025b, - 0x00000259,0x00000001,0x00050051,0x00000006,0x0000025c,0x00000259,0x00000002,0x00070050, - 0x00000020,0x0000025d,0x0000025a,0x0000025b,0x0000025c,0x00000038,0x0003003e,0x00000258, - 0x0000025d,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008, - 0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003d,0x00000006,0x00000039, - 0x00000009,0x00050088,0x00000006,0x0000003a,0x00000038,0x00000039,0x000200fe,0x0000003a, - 0x00010038,0x00050036,0x00000006,0x0000000d,0x00000000,0x00000008,0x00030037,0x00000007, - 0x0000000c,0x000200f8,0x0000000e,0x0004003d,0x00000006,0x0000003d,0x0000000c,0x00050088, - 0x00000006,0x0000003e,0x00000038,0x0000003d,0x000200fe,0x0000003e,0x00010038,0x00050036, - 0x00000006,0x00000010,0x00000000,0x00000008,0x00030037,0x00000007,0x0000000f,0x000200f8, - 0x00000011,0x0004003d,0x00000006,0x00000041,0x0000000f,0x0008000c,0x00000006,0x00000043, - 0x00000001,0x0000002b,0x00000041,0x00000042,0x00000038,0x000200fe,0x00000043,0x00010038, - 0x00050036,0x00000006,0x00000016,0x00000000,0x00000012,0x00030037,0x00000007,0x00000013, - 0x00030037,0x00000007,0x00000014,0x00030037,0x00000007,0x00000015,0x000200f8,0x00000017, - 0x0004003d,0x00000006,0x00000046,0x00000013,0x0004003d,0x00000006,0x00000047,0x00000014, - 0x0004003d,0x00000006,0x00000048,0x00000015,0x0007000c,0x00000006,0x00000049,0x00000001, - 0x00000025,0x00000047,0x00000048,0x0007000c,0x00000006,0x0000004a,0x00000001,0x00000025, - 0x00000046,0x00000049,0x000200fe,0x0000004a,0x00010038,0x00050036,0x00000006,0x0000001b, - 0x00000000,0x00000012,0x00030037,0x00000007,0x00000018,0x00030037,0x00000007,0x00000019, - 0x00030037,0x00000007,0x0000001a,0x000200f8,0x0000001c,0x0004003d,0x00000006,0x0000004d, - 0x00000018,0x0004003d,0x00000006,0x0000004e,0x00000019,0x0004003d,0x00000006,0x0000004f, - 0x0000001a,0x0007000c,0x00000006,0x00000050,0x00000001,0x00000028,0x0000004e,0x0000004f, - 0x0007000c,0x00000006,0x00000051,0x00000001,0x00000028,0x0000004d,0x00000050,0x000200fe, - 0x00000051,0x00010038,0x00050036,0x00000020,0x00000023,0x00000000,0x00000021,0x00030037, - 0x0000001f,0x00000022,0x000200f8,0x00000024,0x0004003b,0x0000001f,0x00000054,0x00000007, - 0x0004003d,0x00000056,0x00000059,0x00000058,0x00040064,0x00000055,0x0000005b,0x00000059, - 0x00050067,0x0000001e,0x0000005c,0x0000005b,0x0000005a,0x0003003e,0x00000054,0x0000005c, - 0x0004003d,0x00000056,0x0000005d,0x00000058,0x0004003d,0x0000001e,0x0000005e,0x00000022, - 0x0004003d,0x0000001e,0x00000060,0x00000054,0x00050082,0x0000001e,0x00000063,0x00000060, - 0x00000062,0x0008000c,0x0000001e,0x00000064,0x00000001,0x0000002d,0x0000005e,0x0000005f, - 0x00000063,0x00040064,0x00000055,0x00000065,0x0000005d,0x0007005f,0x00000020,0x00000066, - 0x00000065,0x00000064,0x00000002,0x0000005a,0x000200fe,0x00000066,0x00010038,0x00050036, - 0x00000002,0x00000029,0x00000000,0x00000025,0x00030037,0x00000007,0x00000026,0x00030037, - 0x00000007,0x00000027,0x00030037,0x00000007,0x00000028,0x000200f8,0x0000002a,0x000100fd, - 0x00010038,0x00050036,0x00000002,0x00000036,0x00000000,0x00000030,0x00030037,0x00000007, - 0x00000031,0x00030037,0x00000007,0x00000032,0x00030037,0x00000007,0x00000033,0x00030037, - 0x0000002d,0x00000034,0x00030037,0x0000002f,0x00000035,0x000200f8,0x00000037,0x0004003b, - 0x0000001f,0x00000069,0x00000007,0x0004003b,0x0000006d,0x0000006e,0x00000007,0x0004003b, - 0x0000001f,0x00000073,0x00000007,0x0004003b,0x0000006d,0x00000076,0x00000007,0x0004003b, - 0x0000001f,0x0000007a,0x00000007,0x0004003b,0x0000006d,0x0000007d,0x00000007,0x0004003b, - 0x0000001f,0x0000007e,0x00000007,0x0004003b,0x0000006d,0x00000082,0x00000007,0x0004003b, - 0x0000001f,0x00000086,0x00000007,0x0004003b,0x0000006d,0x00000089,0x00000007,0x0004003b, - 0x0000001f,0x0000008d,0x00000007,0x0004003b,0x00000007,0x00000090,0x00000007,0x0004003b, - 0x00000007,0x00000094,0x00000007,0x0004003b,0x00000007,0x00000098,0x00000007,0x0004003b, - 0x00000007,0x0000009c,0x00000007,0x0004003b,0x00000007,0x0000009f,0x00000007,0x0004003b, - 0x00000007,0x000000a2,0x00000007,0x0004003b,0x00000007,0x000000a5,0x00000007,0x0004003b, - 0x00000007,0x000000a8,0x00000007,0x0004003b,0x00000007,0x000000ab,0x00000007,0x0004003b, - 0x00000007,0x000000ae,0x00000007,0x0004003b,0x00000007,0x000000b1,0x00000007,0x0004003b, - 0x00000007,0x000000b4,0x00000007,0x0004003b,0x00000007,0x000000b7,0x00000007,0x0004003b, - 0x00000007,0x000000ba,0x00000007,0x0004003b,0x00000007,0x000000bd,0x00000007,0x0004003b, - 0x00000007,0x000000c0,0x00000007,0x0004003b,0x00000007,0x000000c2,0x00000007,0x0004003b, - 0x00000007,0x000000c4,0x00000007,0x0004003b,0x00000007,0x000000ca,0x00000007,0x0004003b, - 0x00000007,0x000000cc,0x00000007,0x0004003b,0x00000007,0x000000ce,0x00000007,0x0004003b, - 0x00000007,0x000000d4,0x00000007,0x0004003b,0x00000007,0x000000d6,0x00000007,0x0004003b, - 0x00000007,0x000000d8,0x00000007,0x0004003b,0x00000007,0x000000de,0x00000007,0x0004003b, - 0x00000007,0x000000e0,0x00000007,0x0004003b,0x00000007,0x000000e2,0x00000007,0x0004003b, - 0x00000007,0x000000e8,0x00000007,0x0004003b,0x00000007,0x000000ea,0x00000007,0x0004003b, - 0x00000007,0x000000ec,0x00000007,0x0004003b,0x00000007,0x000000f2,0x00000007,0x0004003b, - 0x00000007,0x000000fb,0x00000007,0x0004003b,0x00000007,0x00000103,0x00000007,0x0004003b, - 0x00000007,0x0000010b,0x00000007,0x0004003b,0x00000007,0x00000113,0x00000007,0x0004003b, - 0x00000007,0x0000011b,0x00000007,0x0004003b,0x00000007,0x0000012c,0x00000007,0x0004003b, - 0x00000007,0x0000012e,0x00000007,0x0004003b,0x00000007,0x00000130,0x00000007,0x0004003b, - 0x00000007,0x00000133,0x00000007,0x0004003b,0x00000007,0x00000134,0x00000007,0x0004003b, + 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000269, + 0x00000286,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00070005,0x0000000a,0x78725041,0x5264654d,0x31467063, + 0x3b316628,0x00000000,0x00030005,0x00000009,0x00000078,0x00050005,0x0000000d,0x74615341, + 0x66283146,0x00003b31,0x00030005,0x0000000c,0x00000078,0x00070005,0x00000013,0x6e694d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000010,0x00000061,0x00030005, + 0x00000011,0x00000062,0x00030005,0x00000012,0x00000063,0x00070005,0x00000018,0x78614d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000015,0x00000061,0x00030005, + 0x00000016,0x00000062,0x00030005,0x00000017,0x00000063,0x00070005,0x00000020,0x52727346, + 0x4c736163,0x4664616f,0x32697628,0x0000003b,0x00030005,0x0000001f,0x00000070,0x00080005, + 0x00000026,0x52727346,0x49736163,0x7475706e,0x31662846,0x3b31663b,0x003b3166,0x00030005, + 0x00000023,0x00000072,0x00030005,0x00000024,0x00000067,0x00030005,0x00000025,0x00000062, + 0x00090005,0x00000033,0x52727346,0x46736163,0x3b316628,0x663b3166,0x75763b31,0x75763b32, + 0x00003b34,0x00040005,0x0000002e,0x52786970,0x00000000,0x00040005,0x0000002f,0x47786970, + 0x00000000,0x00040005,0x00000030,0x42786970,0x00000000,0x00030005,0x00000031,0x00007069, + 0x00030005,0x00000032,0x006e6f63,0x00030005,0x0000004d,0x00007a73,0x00060005,0x00000051, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000062,0x00007073,0x00030005, + 0x00000067,0x00000062,0x00040005,0x0000006c,0x61726170,0x0000006d,0x00030005,0x0000006f, + 0x00000064,0x00040005,0x00000073,0x61726170,0x0000006d,0x00030005,0x00000076,0x00000065, + 0x00040005,0x00000077,0x61726170,0x0000006d,0x00030005,0x0000007b,0x00000066,0x00040005, + 0x0000007f,0x61726170,0x0000006d,0x00030005,0x00000082,0x00000068,0x00040005,0x00000086, + 0x61726170,0x0000006d,0x00030005,0x00000089,0x00005262,0x00030005,0x0000008d,0x00004762, + 0x00030005,0x00000091,0x00004262,0x00030005,0x00000095,0x00005264,0x00030005,0x00000098, + 0x00004764,0x00030005,0x0000009b,0x00004264,0x00030005,0x0000009e,0x00005265,0x00030005, + 0x000000a1,0x00004765,0x00030005,0x000000a4,0x00004265,0x00030005,0x000000a7,0x00005266, + 0x00030005,0x000000aa,0x00004766,0x00030005,0x000000ad,0x00004266,0x00030005,0x000000b0, + 0x00005268,0x00030005,0x000000b3,0x00004768,0x00030005,0x000000b6,0x00004268,0x00040005, + 0x000000b9,0x61726170,0x0000006d,0x00040005,0x000000bb,0x61726170,0x0000006d,0x00040005, + 0x000000bd,0x61726170,0x0000006d,0x00040005,0x000000c3,0x61726170,0x0000006d,0x00040005, + 0x000000c5,0x61726170,0x0000006d,0x00040005,0x000000c7,0x61726170,0x0000006d,0x00040005, + 0x000000cd,0x61726170,0x0000006d,0x00040005,0x000000cf,0x61726170,0x0000006d,0x00040005, + 0x000000d1,0x61726170,0x0000006d,0x00040005,0x000000d7,0x61726170,0x0000006d,0x00040005, + 0x000000d9,0x61726170,0x0000006d,0x00040005,0x000000db,0x61726170,0x0000006d,0x00040005, + 0x000000e1,0x61726170,0x0000006d,0x00040005,0x000000e3,0x61726170,0x0000006d,0x00040005, + 0x000000e5,0x61726170,0x0000006d,0x00030005,0x000000eb,0x00004c62,0x00030005,0x000000f4, + 0x00004c64,0x00030005,0x000000fc,0x00004c65,0x00030005,0x00000104,0x00004c66,0x00030005, + 0x0000010c,0x00004c68,0x00030005,0x00000114,0x00007a6e,0x00040005,0x00000125,0x61726170, + 0x0000006d,0x00040005,0x00000127,0x61726170,0x0000006d,0x00040005,0x00000129,0x61726170, + 0x0000006d,0x00040005,0x0000012c,0x61726170,0x0000006d,0x00040005,0x0000012d,0x61726170, + 0x0000006d,0x00040005,0x0000012f,0x61726170,0x0000006d,0x00040005,0x00000132,0x61726170, + 0x0000006d,0x00040005,0x00000134,0x61726170,0x0000006d,0x00040005,0x00000136,0x61726170, + 0x0000006d,0x00040005,0x00000139,0x61726170,0x0000006d,0x00040005,0x0000013a,0x61726170, + 0x0000006d,0x00040005,0x0000013c,0x61726170,0x0000006d,0x00040005,0x00000140,0x61726170, + 0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d,0x00040005,0x00000149,0x52346e6d, + 0x00000000,0x00040005,0x0000014a,0x61726170,0x0000006d,0x00040005,0x0000014c,0x61726170, + 0x0000006d,0x00040005,0x0000014e,0x61726170,0x0000006d,0x00040005,0x00000153,0x47346e6d, + 0x00000000,0x00040005,0x00000154,0x61726170,0x0000006d,0x00040005,0x00000156,0x61726170, + 0x0000006d,0x00040005,0x00000158,0x61726170,0x0000006d,0x00040005,0x0000015d,0x42346e6d, + 0x00000000,0x00040005,0x0000015e,0x61726170,0x0000006d,0x00040005,0x00000160,0x61726170, + 0x0000006d,0x00040005,0x00000162,0x61726170,0x0000006d,0x00040005,0x00000167,0x5234786d, + 0x00000000,0x00040005,0x00000168,0x61726170,0x0000006d,0x00040005,0x0000016a,0x61726170, + 0x0000006d,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x00000171,0x4734786d, + 0x00000000,0x00040005,0x00000172,0x61726170,0x0000006d,0x00040005,0x00000174,0x61726170, + 0x0000006d,0x00040005,0x00000176,0x61726170,0x0000006d,0x00040005,0x0000017b,0x4234786d, + 0x00000000,0x00040005,0x0000017c,0x61726170,0x0000006d,0x00040005,0x0000017e,0x61726170, + 0x0000006d,0x00040005,0x00000180,0x61726170,0x0000006d,0x00040005,0x00000187,0x6b616570, + 0x00000043,0x00040005,0x0000018a,0x4d6e6564,0x00526e69,0x00040005,0x0000018e,0x4d6e6564, + 0x00476e69,0x00040005,0x00000191,0x4d6e6564,0x00426e69,0x00040005,0x00000194,0x4d6e6564, + 0x00527861,0x00040005,0x0000019a,0x4d6e6564,0x00477861,0x00040005,0x000001a0,0x4d6e6564, + 0x00427861,0x00040005,0x000001a6,0x4d746968,0x00526e69,0x00040005,0x000001b4,0x4d746968, + 0x00476e69,0x00040005,0x000001c1,0x4d746968,0x00426e69,0x00040005,0x000001ce,0x4d6d756e, + 0x00527861,0x00040005,0x000001d5,0x4d6d756e,0x00477861,0x00040005,0x000001dc,0x4d6d756e, + 0x00427861,0x00040005,0x000001e3,0x4d746968,0x00527861,0x00040005,0x000001f0,0x4d746968, + 0x00477861,0x00040005,0x000001fc,0x4d746968,0x00427861,0x00040005,0x00000208,0x65626f6c, + 0x00000052,0x00040005,0x0000020d,0x65626f6c,0x00000047,0x00040005,0x00000212,0x65626f6c, + 0x00000042,0x00040005,0x00000217,0x65626f6c,0x00000000,0x00040005,0x00000219,0x61726170, + 0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d,0x00040005,0x0000021d,0x61726170, + 0x0000006d,0x00040005,0x00000227,0x4c706372,0x00000000,0x00040005,0x0000022b,0x61726170, + 0x0000006d,0x00030005,0x00000267,0x00007069,0x00060005,0x00000269,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00030005,0x0000026b,0x00004350,0x00040006,0x0000026b,0x00000000, + 0x0063646e,0x00040006,0x0000026b,0x00000001,0x006e6f63,0x00060006,0x0000026b,0x00000002, + 0x7074756f,0x69537475,0x0000657a,0x00030005,0x0000026d,0x00006370,0x00030005,0x00000274, + 0x00000063,0x00040005,0x00000275,0x61726170,0x0000006d,0x00040005,0x00000276,0x61726170, + 0x0000006d,0x00040005,0x00000277,0x61726170,0x0000006d,0x00040005,0x00000278,0x61726170, + 0x0000006d,0x00040005,0x0000027a,0x61726170,0x0000006d,0x00050005,0x00000286,0x4374756f, + 0x726f6c6f,0x00000000,0x00040047,0x00000051,0x00000021,0x00000000,0x00040047,0x00000051, + 0x00000022,0x00000000,0x00040047,0x00000269,0x0000001e,0x00000000,0x00030047,0x0000026b, + 0x00000002,0x00050048,0x0000026b,0x00000000,0x00000023,0x00000000,0x00050048,0x0000026b, + 0x00000001,0x00000023,0x00000010,0x00050048,0x0000026b,0x00000002,0x00000023,0x00000020, + 0x00040047,0x00000286,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, + 0x00000002,0x00030016,0x00000006,0x00000020,0x00040020,0x00000007,0x00000007,0x00000006, + 0x00040021,0x00000008,0x00000006,0x00000007,0x00060021,0x0000000f,0x00000006,0x00000007, + 0x00000007,0x00000007,0x00040015,0x0000001a,0x00000020,0x00000001,0x00040017,0x0000001b, + 0x0000001a,0x00000002,0x00040020,0x0000001c,0x00000007,0x0000001b,0x00040017,0x0000001d, + 0x00000006,0x00000004,0x00040021,0x0000001e,0x0000001d,0x0000001c,0x00060021,0x00000022, + 0x00000002,0x00000007,0x00000007,0x00000007,0x00040015,0x00000028,0x00000020,0x00000000, + 0x00040017,0x00000029,0x00000028,0x00000002,0x00040020,0x0000002a,0x00000007,0x00000029, + 0x00040017,0x0000002b,0x00000028,0x00000004,0x00040020,0x0000002c,0x00000007,0x0000002b, + 0x00080021,0x0000002d,0x00000002,0x00000007,0x00000007,0x00000007,0x0000002a,0x0000002c, + 0x0004002b,0x00000006,0x00000035,0x3f800000,0x0004002b,0x00000006,0x0000003b,0x00000000, + 0x00090019,0x0000004e,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001, + 0x00000000,0x0003001b,0x0000004f,0x0000004e,0x00040020,0x00000050,0x00000000,0x0000004f, + 0x0004003b,0x00000050,0x00000051,0x00000000,0x0004002b,0x0000001a,0x00000053,0x00000000, + 0x0005002c,0x0000001b,0x00000058,0x00000053,0x00000053,0x0004002b,0x0000001a,0x0000005a, + 0x00000001,0x0005002c,0x0000001b,0x0000005b,0x0000005a,0x0000005a,0x00040017,0x00000065, + 0x00000006,0x00000003,0x00040020,0x00000066,0x00000007,0x00000065,0x0004002b,0x0000001a, + 0x00000069,0xffffffff,0x0005002c,0x0000001b,0x0000006a,0x00000053,0x00000069,0x0005002c, + 0x0000001b,0x00000071,0x00000069,0x00000053,0x0005002c,0x0000001b,0x0000007d,0x0000005a, + 0x00000053,0x0005002c,0x0000001b,0x00000084,0x00000053,0x0000005a,0x0004002b,0x00000028, + 0x0000008a,0x00000000,0x0004002b,0x00000028,0x0000008e,0x00000001,0x0004002b,0x00000028, + 0x00000092,0x00000002,0x0004002b,0x00000006,0x000000ed,0x3f000000,0x0004002b,0x00000006, + 0x00000115,0x3e800000,0x0004002b,0x00000006,0x00000145,0xbf000000,0x00040017,0x00000185, + 0x00000006,0x00000002,0x00040020,0x00000186,0x00000007,0x00000185,0x0004002b,0x00000006, + 0x00000188,0xc0800000,0x0005002c,0x00000185,0x00000189,0x00000035,0x00000188,0x0004002b, + 0x00000006,0x0000018b,0x40800000,0x00020014,0x000001a8,0x0004002b,0x00000006,0x000001e6, + 0x358637bd,0x0004002b,0x00000006,0x00000218,0xbe400000,0x00040020,0x00000222,0x00000007, + 0x00000028,0x00040020,0x00000268,0x00000001,0x00000185,0x0004003b,0x00000268,0x00000269, + 0x00000001,0x0005001e,0x0000026b,0x0000001d,0x0000002b,0x00000185,0x00040020,0x0000026c, + 0x00000009,0x0000026b,0x0004003b,0x0000026c,0x0000026d,0x00000009,0x0004002b,0x0000001a, + 0x0000026e,0x00000002,0x00040020,0x0000026f,0x00000009,0x00000185,0x00040020,0x0000027b, + 0x00000009,0x0000002b,0x00040020,0x00000285,0x00000003,0x0000001d,0x0004003b,0x00000285, + 0x00000286,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x0000002a,0x00000267,0x00000007,0x0004003b,0x00000066,0x00000274, + 0x00000007,0x0004003b,0x00000007,0x00000275,0x00000007,0x0004003b,0x00000007,0x00000276, + 0x00000007,0x0004003b,0x00000007,0x00000277,0x00000007,0x0004003b,0x0000002a,0x00000278, + 0x00000007,0x0004003b,0x0000002c,0x0000027a,0x00000007,0x0004003d,0x00000185,0x0000026a, + 0x00000269,0x00050041,0x0000026f,0x00000270,0x0000026d,0x0000026e,0x0004003d,0x00000185, + 0x00000271,0x00000270,0x00050085,0x00000185,0x00000272,0x0000026a,0x00000271,0x0004006d, + 0x00000029,0x00000273,0x00000272,0x0003003e,0x00000267,0x00000273,0x0004003d,0x00000029, + 0x00000279,0x00000267,0x0003003e,0x00000278,0x00000279,0x00050041,0x0000027b,0x0000027c, + 0x0000026d,0x0000005a,0x0004003d,0x0000002b,0x0000027d,0x0000027c,0x0003003e,0x0000027a, + 0x0000027d,0x00090039,0x00000002,0x0000027e,0x00000033,0x00000275,0x00000276,0x00000277, + 0x00000278,0x0000027a,0x0004003d,0x00000006,0x0000027f,0x00000275,0x00050041,0x00000007, + 0x00000280,0x00000274,0x0000008a,0x0003003e,0x00000280,0x0000027f,0x0004003d,0x00000006, + 0x00000281,0x00000276,0x00050041,0x00000007,0x00000282,0x00000274,0x0000008e,0x0003003e, + 0x00000282,0x00000281,0x0004003d,0x00000006,0x00000283,0x00000277,0x00050041,0x00000007, + 0x00000284,0x00000274,0x00000092,0x0003003e,0x00000284,0x00000283,0x0004003d,0x00000065, + 0x00000287,0x00000274,0x00050051,0x00000006,0x00000288,0x00000287,0x00000000,0x00050051, + 0x00000006,0x00000289,0x00000287,0x00000001,0x00050051,0x00000006,0x0000028a,0x00000287, + 0x00000002,0x00070050,0x0000001d,0x0000028b,0x00000288,0x00000289,0x0000028a,0x00000035, + 0x0003003e,0x00000286,0x0000028b,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a, + 0x00000000,0x00000008,0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003d, + 0x00000006,0x00000036,0x00000009,0x00050088,0x00000006,0x00000037,0x00000035,0x00000036, + 0x000200fe,0x00000037,0x00010038,0x00050036,0x00000006,0x0000000d,0x00000000,0x00000008, + 0x00030037,0x00000007,0x0000000c,0x000200f8,0x0000000e,0x0004003d,0x00000006,0x0000003a, + 0x0000000c,0x0008000c,0x00000006,0x0000003c,0x00000001,0x0000002b,0x0000003a,0x0000003b, + 0x00000035,0x000200fe,0x0000003c,0x00010038,0x00050036,0x00000006,0x00000013,0x00000000, + 0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037,0x00000007,0x00000011,0x00030037, + 0x00000007,0x00000012,0x000200f8,0x00000014,0x0004003d,0x00000006,0x0000003f,0x00000010, + 0x0004003d,0x00000006,0x00000040,0x00000011,0x0004003d,0x00000006,0x00000041,0x00000012, + 0x0007000c,0x00000006,0x00000042,0x00000001,0x00000025,0x00000040,0x00000041,0x0007000c, + 0x00000006,0x00000043,0x00000001,0x00000025,0x0000003f,0x00000042,0x000200fe,0x00000043, + 0x00010038,0x00050036,0x00000006,0x00000018,0x00000000,0x0000000f,0x00030037,0x00000007, + 0x00000015,0x00030037,0x00000007,0x00000016,0x00030037,0x00000007,0x00000017,0x000200f8, + 0x00000019,0x0004003d,0x00000006,0x00000046,0x00000015,0x0004003d,0x00000006,0x00000047, + 0x00000016,0x0004003d,0x00000006,0x00000048,0x00000017,0x0007000c,0x00000006,0x00000049, + 0x00000001,0x00000028,0x00000047,0x00000048,0x0007000c,0x00000006,0x0000004a,0x00000001, + 0x00000028,0x00000046,0x00000049,0x000200fe,0x0000004a,0x00010038,0x00050036,0x0000001d, + 0x00000020,0x00000000,0x0000001e,0x00030037,0x0000001c,0x0000001f,0x000200f8,0x00000021, + 0x0004003b,0x0000001c,0x0000004d,0x00000007,0x0004003d,0x0000004f,0x00000052,0x00000051, + 0x00040064,0x0000004e,0x00000054,0x00000052,0x00050067,0x0000001b,0x00000055,0x00000054, + 0x00000053,0x0003003e,0x0000004d,0x00000055,0x0004003d,0x0000004f,0x00000056,0x00000051, + 0x0004003d,0x0000001b,0x00000057,0x0000001f,0x0004003d,0x0000001b,0x00000059,0x0000004d, + 0x00050082,0x0000001b,0x0000005c,0x00000059,0x0000005b,0x0008000c,0x0000001b,0x0000005d, + 0x00000001,0x0000002d,0x00000057,0x00000058,0x0000005c,0x00040064,0x0000004e,0x0000005e, + 0x00000056,0x0007005f,0x0000001d,0x0000005f,0x0000005e,0x0000005d,0x00000002,0x00000053, + 0x000200fe,0x0000005f,0x00010038,0x00050036,0x00000002,0x00000026,0x00000000,0x00000022, + 0x00030037,0x00000007,0x00000023,0x00030037,0x00000007,0x00000024,0x00030037,0x00000007, + 0x00000025,0x000200f8,0x00000027,0x000100fd,0x00010038,0x00050036,0x00000002,0x00000033, + 0x00000000,0x0000002d,0x00030037,0x00000007,0x0000002e,0x00030037,0x00000007,0x0000002f, + 0x00030037,0x00000007,0x00000030,0x00030037,0x0000002a,0x00000031,0x00030037,0x0000002c, + 0x00000032,0x000200f8,0x00000034,0x0004003b,0x0000001c,0x00000062,0x00000007,0x0004003b, + 0x00000066,0x00000067,0x00000007,0x0004003b,0x0000001c,0x0000006c,0x00000007,0x0004003b, + 0x00000066,0x0000006f,0x00000007,0x0004003b,0x0000001c,0x00000073,0x00000007,0x0004003b, + 0x00000066,0x00000076,0x00000007,0x0004003b,0x0000001c,0x00000077,0x00000007,0x0004003b, + 0x00000066,0x0000007b,0x00000007,0x0004003b,0x0000001c,0x0000007f,0x00000007,0x0004003b, + 0x00000066,0x00000082,0x00000007,0x0004003b,0x0000001c,0x00000086,0x00000007,0x0004003b, + 0x00000007,0x00000089,0x00000007,0x0004003b,0x00000007,0x0000008d,0x00000007,0x0004003b, + 0x00000007,0x00000091,0x00000007,0x0004003b,0x00000007,0x00000095,0x00000007,0x0004003b, + 0x00000007,0x00000098,0x00000007,0x0004003b,0x00000007,0x0000009b,0x00000007,0x0004003b, + 0x00000007,0x0000009e,0x00000007,0x0004003b,0x00000007,0x000000a1,0x00000007,0x0004003b, + 0x00000007,0x000000a4,0x00000007,0x0004003b,0x00000007,0x000000a7,0x00000007,0x0004003b, + 0x00000007,0x000000aa,0x00000007,0x0004003b,0x00000007,0x000000ad,0x00000007,0x0004003b, + 0x00000007,0x000000b0,0x00000007,0x0004003b,0x00000007,0x000000b3,0x00000007,0x0004003b, + 0x00000007,0x000000b6,0x00000007,0x0004003b,0x00000007,0x000000b9,0x00000007,0x0004003b, + 0x00000007,0x000000bb,0x00000007,0x0004003b,0x00000007,0x000000bd,0x00000007,0x0004003b, + 0x00000007,0x000000c3,0x00000007,0x0004003b,0x00000007,0x000000c5,0x00000007,0x0004003b, + 0x00000007,0x000000c7,0x00000007,0x0004003b,0x00000007,0x000000cd,0x00000007,0x0004003b, + 0x00000007,0x000000cf,0x00000007,0x0004003b,0x00000007,0x000000d1,0x00000007,0x0004003b, + 0x00000007,0x000000d7,0x00000007,0x0004003b,0x00000007,0x000000d9,0x00000007,0x0004003b, + 0x00000007,0x000000db,0x00000007,0x0004003b,0x00000007,0x000000e1,0x00000007,0x0004003b, + 0x00000007,0x000000e3,0x00000007,0x0004003b,0x00000007,0x000000e5,0x00000007,0x0004003b, + 0x00000007,0x000000eb,0x00000007,0x0004003b,0x00000007,0x000000f4,0x00000007,0x0004003b, + 0x00000007,0x000000fc,0x00000007,0x0004003b,0x00000007,0x00000104,0x00000007,0x0004003b, + 0x00000007,0x0000010c,0x00000007,0x0004003b,0x00000007,0x00000114,0x00000007,0x0004003b, + 0x00000007,0x00000125,0x00000007,0x0004003b,0x00000007,0x00000127,0x00000007,0x0004003b, + 0x00000007,0x00000129,0x00000007,0x0004003b,0x00000007,0x0000012c,0x00000007,0x0004003b, + 0x00000007,0x0000012d,0x00000007,0x0004003b,0x00000007,0x0000012f,0x00000007,0x0004003b, + 0x00000007,0x00000132,0x00000007,0x0004003b,0x00000007,0x00000134,0x00000007,0x0004003b, 0x00000007,0x00000136,0x00000007,0x0004003b,0x00000007,0x00000139,0x00000007,0x0004003b, - 0x00000007,0x0000013b,0x00000007,0x0004003b,0x00000007,0x0000013d,0x00000007,0x0004003b, - 0x00000007,0x00000140,0x00000007,0x0004003b,0x00000007,0x00000141,0x00000007,0x0004003b, - 0x00000007,0x00000143,0x00000007,0x0004003b,0x00000007,0x00000147,0x00000007,0x0004003b, - 0x00000007,0x0000014a,0x00000007,0x0004003b,0x00000007,0x00000150,0x00000007,0x0004003b, - 0x00000007,0x00000151,0x00000007,0x0004003b,0x00000007,0x00000153,0x00000007,0x0004003b, - 0x00000007,0x00000155,0x00000007,0x0004003b,0x00000007,0x0000015a,0x00000007,0x0004003b, - 0x00000007,0x0000015b,0x00000007,0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b, - 0x00000007,0x0000015f,0x00000007,0x0004003b,0x00000007,0x00000164,0x00000007,0x0004003b, - 0x00000007,0x00000165,0x00000007,0x0004003b,0x00000007,0x00000167,0x00000007,0x0004003b, - 0x00000007,0x00000169,0x00000007,0x0004003b,0x00000007,0x0000016e,0x00000007,0x0004003b, - 0x00000007,0x0000016f,0x00000007,0x0004003b,0x00000007,0x00000171,0x00000007,0x0004003b, - 0x00000007,0x00000173,0x00000007,0x0004003b,0x00000007,0x00000178,0x00000007,0x0004003b, - 0x00000007,0x00000179,0x00000007,0x0004003b,0x00000007,0x0000017b,0x00000007,0x0004003b, - 0x00000007,0x0000017d,0x00000007,0x0004003b,0x00000007,0x00000182,0x00000007,0x0004003b, - 0x00000007,0x00000183,0x00000007,0x0004003b,0x00000007,0x00000185,0x00000007,0x0004003b, - 0x00000007,0x00000187,0x00000007,0x0004003b,0x0000018d,0x0000018e,0x00000007,0x0004003b, - 0x00000007,0x00000191,0x00000007,0x0004003b,0x00000007,0x00000198,0x00000007,0x0004003b, - 0x00000007,0x0000019b,0x00000007,0x0004003b,0x00000007,0x000001a1,0x00000007,0x0004003b, - 0x00000007,0x000001a4,0x00000007,0x0004003b,0x00000007,0x000001aa,0x00000007,0x0004003b, - 0x00000007,0x000001ad,0x00000007,0x0004003b,0x00000007,0x000001b9,0x00000007,0x0004003b, - 0x00000007,0x000001bc,0x00000007,0x0004003b,0x00000007,0x000001c8,0x00000007,0x0004003b, - 0x00000007,0x000001cb,0x00000007,0x0004003b,0x00000007,0x000001d7,0x00000007,0x0004003b, - 0x00000007,0x000001da,0x00000007,0x0004003b,0x00000007,0x000001df,0x00000007,0x0004003b, - 0x00000007,0x000001e4,0x00000007,0x0004003b,0x00000007,0x000001e9,0x00000007,0x0004003b, - 0x00000007,0x000001eb,0x00000007,0x0004003b,0x00000007,0x000001ed,0x00000007,0x0004003b, - 0x00000007,0x000001ef,0x00000007,0x0004003b,0x00000007,0x000001f9,0x00000007,0x0004003b, - 0x00000007,0x000001fd,0x00000007,0x0004003d,0x0000002c,0x0000006a,0x00000034,0x0004007c, - 0x0000001e,0x0000006b,0x0000006a,0x0003003e,0x00000069,0x0000006b,0x0004003d,0x0000001e, - 0x0000006f,0x00000069,0x00050080,0x0000001e,0x00000072,0x0000006f,0x00000071,0x0003003e, - 0x00000073,0x00000072,0x00050039,0x00000020,0x00000074,0x00000023,0x00000073,0x0008004f, - 0x0000006c,0x00000075,0x00000074,0x00000074,0x00000000,0x00000001,0x00000002,0x0003003e, - 0x0000006e,0x00000075,0x0004003d,0x0000001e,0x00000077,0x00000069,0x00050080,0x0000001e, - 0x00000079,0x00000077,0x00000078,0x0003003e,0x0000007a,0x00000079,0x00050039,0x00000020, - 0x0000007b,0x00000023,0x0000007a,0x0008004f,0x0000006c,0x0000007c,0x0000007b,0x0000007b, - 0x00000000,0x00000001,0x00000002,0x0003003e,0x00000076,0x0000007c,0x0004003d,0x0000001e, - 0x0000007f,0x00000069,0x0003003e,0x0000007e,0x0000007f,0x00050039,0x00000020,0x00000080, - 0x00000023,0x0000007e,0x0008004f,0x0000006c,0x00000081,0x00000080,0x00000080,0x00000000, - 0x00000001,0x00000002,0x0003003e,0x0000007d,0x00000081,0x0004003d,0x0000001e,0x00000083, - 0x00000069,0x00050080,0x0000001e,0x00000085,0x00000083,0x00000084,0x0003003e,0x00000086, - 0x00000085,0x00050039,0x00000020,0x00000087,0x00000023,0x00000086,0x0008004f,0x0000006c, - 0x00000088,0x00000087,0x00000087,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000082, - 0x00000088,0x0004003d,0x0000001e,0x0000008a,0x00000069,0x00050080,0x0000001e,0x0000008c, - 0x0000008a,0x0000008b,0x0003003e,0x0000008d,0x0000008c,0x00050039,0x00000020,0x0000008e, - 0x00000023,0x0000008d,0x0008004f,0x0000006c,0x0000008f,0x0000008e,0x0000008e,0x00000000, - 0x00000001,0x00000002,0x0003003e,0x00000089,0x0000008f,0x00050041,0x00000007,0x00000092, - 0x0000006e,0x00000091,0x0004003d,0x00000006,0x00000093,0x00000092,0x0003003e,0x00000090, - 0x00000093,0x00050041,0x00000007,0x00000096,0x0000006e,0x00000095,0x0004003d,0x00000006, - 0x00000097,0x00000096,0x0003003e,0x00000094,0x00000097,0x00050041,0x00000007,0x0000009a, - 0x0000006e,0x00000099,0x0004003d,0x00000006,0x0000009b,0x0000009a,0x0003003e,0x00000098, - 0x0000009b,0x00050041,0x00000007,0x0000009d,0x00000076,0x00000091,0x0004003d,0x00000006, - 0x0000009e,0x0000009d,0x0003003e,0x0000009c,0x0000009e,0x00050041,0x00000007,0x000000a0, - 0x00000076,0x00000095,0x0004003d,0x00000006,0x000000a1,0x000000a0,0x0003003e,0x0000009f, - 0x000000a1,0x00050041,0x00000007,0x000000a3,0x00000076,0x00000099,0x0004003d,0x00000006, - 0x000000a4,0x000000a3,0x0003003e,0x000000a2,0x000000a4,0x00050041,0x00000007,0x000000a6, - 0x0000007d,0x00000091,0x0004003d,0x00000006,0x000000a7,0x000000a6,0x0003003e,0x000000a5, - 0x000000a7,0x00050041,0x00000007,0x000000a9,0x0000007d,0x00000095,0x0004003d,0x00000006, - 0x000000aa,0x000000a9,0x0003003e,0x000000a8,0x000000aa,0x00050041,0x00000007,0x000000ac, - 0x0000007d,0x00000099,0x0004003d,0x00000006,0x000000ad,0x000000ac,0x0003003e,0x000000ab, - 0x000000ad,0x00050041,0x00000007,0x000000af,0x00000082,0x00000091,0x0004003d,0x00000006, - 0x000000b0,0x000000af,0x0003003e,0x000000ae,0x000000b0,0x00050041,0x00000007,0x000000b2, - 0x00000082,0x00000095,0x0004003d,0x00000006,0x000000b3,0x000000b2,0x0003003e,0x000000b1, - 0x000000b3,0x00050041,0x00000007,0x000000b5,0x00000082,0x00000099,0x0004003d,0x00000006, - 0x000000b6,0x000000b5,0x0003003e,0x000000b4,0x000000b6,0x00050041,0x00000007,0x000000b8, - 0x00000089,0x00000091,0x0004003d,0x00000006,0x000000b9,0x000000b8,0x0003003e,0x000000b7, - 0x000000b9,0x00050041,0x00000007,0x000000bb,0x00000089,0x00000095,0x0004003d,0x00000006, - 0x000000bc,0x000000bb,0x0003003e,0x000000ba,0x000000bc,0x00050041,0x00000007,0x000000be, - 0x00000089,0x00000099,0x0004003d,0x00000006,0x000000bf,0x000000be,0x0003003e,0x000000bd, - 0x000000bf,0x0004003d,0x00000006,0x000000c1,0x00000090,0x0003003e,0x000000c0,0x000000c1, - 0x0004003d,0x00000006,0x000000c3,0x00000094,0x0003003e,0x000000c2,0x000000c3,0x0004003d, - 0x00000006,0x000000c5,0x00000098,0x0003003e,0x000000c4,0x000000c5,0x00070039,0x00000002, - 0x000000c6,0x00000029,0x000000c0,0x000000c2,0x000000c4,0x0004003d,0x00000006,0x000000c7, - 0x000000c0,0x0003003e,0x00000090,0x000000c7,0x0004003d,0x00000006,0x000000c8,0x000000c2, - 0x0003003e,0x00000094,0x000000c8,0x0004003d,0x00000006,0x000000c9,0x000000c4,0x0003003e, - 0x00000098,0x000000c9,0x0004003d,0x00000006,0x000000cb,0x0000009c,0x0003003e,0x000000ca, - 0x000000cb,0x0004003d,0x00000006,0x000000cd,0x0000009f,0x0003003e,0x000000cc,0x000000cd, - 0x0004003d,0x00000006,0x000000cf,0x000000a2,0x0003003e,0x000000ce,0x000000cf,0x00070039, - 0x00000002,0x000000d0,0x00000029,0x000000ca,0x000000cc,0x000000ce,0x0004003d,0x00000006, - 0x000000d1,0x000000ca,0x0003003e,0x0000009c,0x000000d1,0x0004003d,0x00000006,0x000000d2, - 0x000000cc,0x0003003e,0x0000009f,0x000000d2,0x0004003d,0x00000006,0x000000d3,0x000000ce, - 0x0003003e,0x000000a2,0x000000d3,0x0004003d,0x00000006,0x000000d5,0x000000a5,0x0003003e, - 0x000000d4,0x000000d5,0x0004003d,0x00000006,0x000000d7,0x000000a8,0x0003003e,0x000000d6, - 0x000000d7,0x0004003d,0x00000006,0x000000d9,0x000000ab,0x0003003e,0x000000d8,0x000000d9, - 0x00070039,0x00000002,0x000000da,0x00000029,0x000000d4,0x000000d6,0x000000d8,0x0004003d, - 0x00000006,0x000000db,0x000000d4,0x0003003e,0x000000a5,0x000000db,0x0004003d,0x00000006, - 0x000000dc,0x000000d6,0x0003003e,0x000000a8,0x000000dc,0x0004003d,0x00000006,0x000000dd, - 0x000000d8,0x0003003e,0x000000ab,0x000000dd,0x0004003d,0x00000006,0x000000df,0x000000ae, - 0x0003003e,0x000000de,0x000000df,0x0004003d,0x00000006,0x000000e1,0x000000b1,0x0003003e, - 0x000000e0,0x000000e1,0x0004003d,0x00000006,0x000000e3,0x000000b4,0x0003003e,0x000000e2, - 0x000000e3,0x00070039,0x00000002,0x000000e4,0x00000029,0x000000de,0x000000e0,0x000000e2, - 0x0004003d,0x00000006,0x000000e5,0x000000de,0x0003003e,0x000000ae,0x000000e5,0x0004003d, - 0x00000006,0x000000e6,0x000000e0,0x0003003e,0x000000b1,0x000000e6,0x0004003d,0x00000006, - 0x000000e7,0x000000e2,0x0003003e,0x000000b4,0x000000e7,0x0004003d,0x00000006,0x000000e9, - 0x000000b7,0x0003003e,0x000000e8,0x000000e9,0x0004003d,0x00000006,0x000000eb,0x000000ba, - 0x0003003e,0x000000ea,0x000000eb,0x0004003d,0x00000006,0x000000ed,0x000000bd,0x0003003e, - 0x000000ec,0x000000ed,0x00070039,0x00000002,0x000000ee,0x00000029,0x000000e8,0x000000ea, - 0x000000ec,0x0004003d,0x00000006,0x000000ef,0x000000e8,0x0003003e,0x000000b7,0x000000ef, - 0x0004003d,0x00000006,0x000000f0,0x000000ea,0x0003003e,0x000000ba,0x000000f0,0x0004003d, - 0x00000006,0x000000f1,0x000000ec,0x0003003e,0x000000bd,0x000000f1,0x0004003d,0x00000006, - 0x000000f3,0x00000098,0x00050085,0x00000006,0x000000f5,0x000000f3,0x000000f4,0x0004003d, - 0x00000006,0x000000f6,0x00000090,0x00050085,0x00000006,0x000000f7,0x000000f6,0x000000f4, - 0x0004003d,0x00000006,0x000000f8,0x00000094,0x00050081,0x00000006,0x000000f9,0x000000f7, - 0x000000f8,0x00050081,0x00000006,0x000000fa,0x000000f5,0x000000f9,0x0003003e,0x000000f2, - 0x000000fa,0x0004003d,0x00000006,0x000000fc,0x000000a2,0x00050085,0x00000006,0x000000fd, - 0x000000fc,0x000000f4,0x0004003d,0x00000006,0x000000fe,0x0000009c,0x00050085,0x00000006, - 0x000000ff,0x000000fe,0x000000f4,0x0004003d,0x00000006,0x00000100,0x0000009f,0x00050081, - 0x00000006,0x00000101,0x000000ff,0x00000100,0x00050081,0x00000006,0x00000102,0x000000fd, - 0x00000101,0x0003003e,0x000000fb,0x00000102,0x0004003d,0x00000006,0x00000104,0x000000ab, - 0x00050085,0x00000006,0x00000105,0x00000104,0x000000f4,0x0004003d,0x00000006,0x00000106, - 0x000000a5,0x00050085,0x00000006,0x00000107,0x00000106,0x000000f4,0x0004003d,0x00000006, - 0x00000108,0x000000a8,0x00050081,0x00000006,0x00000109,0x00000107,0x00000108,0x00050081, - 0x00000006,0x0000010a,0x00000105,0x00000109,0x0003003e,0x00000103,0x0000010a,0x0004003d, - 0x00000006,0x0000010c,0x000000b4,0x00050085,0x00000006,0x0000010d,0x0000010c,0x000000f4, - 0x0004003d,0x00000006,0x0000010e,0x000000ae,0x00050085,0x00000006,0x0000010f,0x0000010e, - 0x000000f4,0x0004003d,0x00000006,0x00000110,0x000000b1,0x00050081,0x00000006,0x00000111, - 0x0000010f,0x00000110,0x00050081,0x00000006,0x00000112,0x0000010d,0x00000111,0x0003003e, - 0x0000010b,0x00000112,0x0004003d,0x00000006,0x00000114,0x000000bd,0x00050085,0x00000006, - 0x00000115,0x00000114,0x000000f4,0x0004003d,0x00000006,0x00000116,0x000000b7,0x00050085, - 0x00000006,0x00000117,0x00000116,0x000000f4,0x0004003d,0x00000006,0x00000118,0x000000ba, - 0x00050081,0x00000006,0x00000119,0x00000117,0x00000118,0x00050081,0x00000006,0x0000011a, - 0x00000115,0x00000119,0x0003003e,0x00000113,0x0000011a,0x0004003d,0x00000006,0x0000011d, - 0x000000f2,0x00050085,0x00000006,0x0000011e,0x0000011c,0x0000011d,0x0004003d,0x00000006, - 0x0000011f,0x000000fb,0x00050085,0x00000006,0x00000120,0x0000011c,0x0000011f,0x00050081, - 0x00000006,0x00000121,0x0000011e,0x00000120,0x0004003d,0x00000006,0x00000122,0x0000010b, - 0x00050085,0x00000006,0x00000123,0x0000011c,0x00000122,0x00050081,0x00000006,0x00000124, - 0x00000121,0x00000123,0x0004003d,0x00000006,0x00000125,0x00000113,0x00050085,0x00000006, - 0x00000126,0x0000011c,0x00000125,0x00050081,0x00000006,0x00000127,0x00000124,0x00000126, - 0x0004003d,0x00000006,0x00000128,0x00000103,0x00050083,0x00000006,0x00000129,0x00000127, - 0x00000128,0x0003003e,0x0000011b,0x00000129,0x0004003d,0x00000006,0x0000012a,0x0000011b, - 0x0006000c,0x00000006,0x0000012b,0x00000001,0x00000004,0x0000012a,0x0004003d,0x00000006, - 0x0000012d,0x000000f2,0x0003003e,0x0000012c,0x0000012d,0x0004003d,0x00000006,0x0000012f, - 0x000000fb,0x0003003e,0x0000012e,0x0000012f,0x0004003d,0x00000006,0x00000131,0x00000103, - 0x0003003e,0x00000130,0x00000131,0x00070039,0x00000006,0x00000132,0x0000001b,0x0000012c, - 0x0000012e,0x00000130,0x0003003e,0x00000133,0x00000132,0x0004003d,0x00000006,0x00000135, - 0x0000010b,0x0003003e,0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x00000113, - 0x0003003e,0x00000136,0x00000137,0x00070039,0x00000006,0x00000138,0x0000001b,0x00000133, - 0x00000134,0x00000136,0x0004003d,0x00000006,0x0000013a,0x000000f2,0x0003003e,0x00000139, - 0x0000013a,0x0004003d,0x00000006,0x0000013c,0x000000fb,0x0003003e,0x0000013b,0x0000013c, - 0x0004003d,0x00000006,0x0000013e,0x00000103,0x0003003e,0x0000013d,0x0000013e,0x00070039, - 0x00000006,0x0000013f,0x00000016,0x00000139,0x0000013b,0x0000013d,0x0003003e,0x00000140, - 0x0000013f,0x0004003d,0x00000006,0x00000142,0x0000010b,0x0003003e,0x00000141,0x00000142, - 0x0004003d,0x00000006,0x00000144,0x00000113,0x0003003e,0x00000143,0x00000144,0x00070039, - 0x00000006,0x00000145,0x00000016,0x00000140,0x00000141,0x00000143,0x00050083,0x00000006, - 0x00000146,0x00000138,0x00000145,0x0003003e,0x00000147,0x00000146,0x00050039,0x00000006, - 0x00000148,0x0000000d,0x00000147,0x00050085,0x00000006,0x00000149,0x0000012b,0x00000148, - 0x0003003e,0x0000014a,0x00000149,0x00050039,0x00000006,0x0000014b,0x00000010,0x0000014a, - 0x0003003e,0x0000011b,0x0000014b,0x0004003d,0x00000006,0x0000014d,0x0000011b,0x00050085, - 0x00000006,0x0000014e,0x0000014c,0x0000014d,0x00050081,0x00000006,0x0000014f,0x0000014e, - 0x00000038,0x0003003e,0x0000011b,0x0000014f,0x0004003d,0x00000006,0x00000152,0x00000090, - 0x0003003e,0x00000151,0x00000152,0x0004003d,0x00000006,0x00000154,0x0000009c,0x0003003e, - 0x00000153,0x00000154,0x0004003d,0x00000006,0x00000156,0x000000ae,0x0003003e,0x00000155, - 0x00000156,0x00070039,0x00000006,0x00000157,0x00000016,0x00000151,0x00000153,0x00000155, - 0x0004003d,0x00000006,0x00000158,0x000000b7,0x0007000c,0x00000006,0x00000159,0x00000001, - 0x00000025,0x00000157,0x00000158,0x0003003e,0x00000150,0x00000159,0x0004003d,0x00000006, - 0x0000015c,0x00000094,0x0003003e,0x0000015b,0x0000015c,0x0004003d,0x00000006,0x0000015e, - 0x0000009f,0x0003003e,0x0000015d,0x0000015e,0x0004003d,0x00000006,0x00000160,0x000000b1, - 0x0003003e,0x0000015f,0x00000160,0x00070039,0x00000006,0x00000161,0x00000016,0x0000015b, - 0x0000015d,0x0000015f,0x0004003d,0x00000006,0x00000162,0x000000ba,0x0007000c,0x00000006, - 0x00000163,0x00000001,0x00000025,0x00000161,0x00000162,0x0003003e,0x0000015a,0x00000163, - 0x0004003d,0x00000006,0x00000166,0x00000098,0x0003003e,0x00000165,0x00000166,0x0004003d, - 0x00000006,0x00000168,0x000000a2,0x0003003e,0x00000167,0x00000168,0x0004003d,0x00000006, - 0x0000016a,0x000000b4,0x0003003e,0x00000169,0x0000016a,0x00070039,0x00000006,0x0000016b, - 0x00000016,0x00000165,0x00000167,0x00000169,0x0004003d,0x00000006,0x0000016c,0x000000bd, - 0x0007000c,0x00000006,0x0000016d,0x00000001,0x00000025,0x0000016b,0x0000016c,0x0003003e, - 0x00000164,0x0000016d,0x0004003d,0x00000006,0x00000170,0x00000090,0x0003003e,0x0000016f, - 0x00000170,0x0004003d,0x00000006,0x00000172,0x0000009c,0x0003003e,0x00000171,0x00000172, - 0x0004003d,0x00000006,0x00000174,0x000000ae,0x0003003e,0x00000173,0x00000174,0x00070039, - 0x00000006,0x00000175,0x0000001b,0x0000016f,0x00000171,0x00000173,0x0004003d,0x00000006, - 0x00000176,0x000000b7,0x0007000c,0x00000006,0x00000177,0x00000001,0x00000028,0x00000175, - 0x00000176,0x0003003e,0x0000016e,0x00000177,0x0004003d,0x00000006,0x0000017a,0x00000094, - 0x0003003e,0x00000179,0x0000017a,0x0004003d,0x00000006,0x0000017c,0x0000009f,0x0003003e, - 0x0000017b,0x0000017c,0x0004003d,0x00000006,0x0000017e,0x000000b1,0x0003003e,0x0000017d, - 0x0000017e,0x00070039,0x00000006,0x0000017f,0x0000001b,0x00000179,0x0000017b,0x0000017d, - 0x0004003d,0x00000006,0x00000180,0x000000ba,0x0007000c,0x00000006,0x00000181,0x00000001, - 0x00000028,0x0000017f,0x00000180,0x0003003e,0x00000178,0x00000181,0x0004003d,0x00000006, - 0x00000184,0x00000098,0x0003003e,0x00000183,0x00000184,0x0004003d,0x00000006,0x00000186, - 0x000000a2,0x0003003e,0x00000185,0x00000186,0x0004003d,0x00000006,0x00000188,0x000000b4, - 0x0003003e,0x00000187,0x00000188,0x00070039,0x00000006,0x00000189,0x0000001b,0x00000183, - 0x00000185,0x00000187,0x0004003d,0x00000006,0x0000018a,0x000000bd,0x0007000c,0x00000006, - 0x0000018b,0x00000001,0x00000028,0x00000189,0x0000018a,0x0003003e,0x00000182,0x0000018b, - 0x0003003e,0x0000018e,0x00000190,0x0004003d,0x00000006,0x00000192,0x00000150,0x0004003d, - 0x00000006,0x00000193,0x000000a5,0x0007000c,0x00000006,0x00000194,0x00000001,0x00000025, - 0x00000192,0x00000193,0x0004003d,0x00000006,0x00000196,0x0000016e,0x00050085,0x00000006, - 0x00000197,0x00000195,0x00000196,0x0003003e,0x00000198,0x00000197,0x00050039,0x00000006, - 0x00000199,0x0000000a,0x00000198,0x00050085,0x00000006,0x0000019a,0x00000194,0x00000199, - 0x0003003e,0x00000191,0x0000019a,0x0004003d,0x00000006,0x0000019c,0x0000015a,0x0004003d, - 0x00000006,0x0000019d,0x000000a8,0x0007000c,0x00000006,0x0000019e,0x00000001,0x00000025, - 0x0000019c,0x0000019d,0x0004003d,0x00000006,0x0000019f,0x00000178,0x00050085,0x00000006, - 0x000001a0,0x00000195,0x0000019f,0x0003003e,0x000001a1,0x000001a0,0x00050039,0x00000006, - 0x000001a2,0x0000000a,0x000001a1,0x00050085,0x00000006,0x000001a3,0x0000019e,0x000001a2, - 0x0003003e,0x0000019b,0x000001a3,0x0004003d,0x00000006,0x000001a5,0x00000164,0x0004003d, - 0x00000006,0x000001a6,0x000000ab,0x0007000c,0x00000006,0x000001a7,0x00000001,0x00000025, - 0x000001a5,0x000001a6,0x0004003d,0x00000006,0x000001a8,0x00000182,0x00050085,0x00000006, - 0x000001a9,0x00000195,0x000001a8,0x0003003e,0x000001aa,0x000001a9,0x00050039,0x00000006, - 0x000001ab,0x0000000a,0x000001aa,0x00050085,0x00000006,0x000001ac,0x000001a7,0x000001ab, - 0x0003003e,0x000001a4,0x000001ac,0x00050041,0x00000007,0x000001ae,0x0000018e,0x00000091, - 0x0004003d,0x00000006,0x000001af,0x000001ae,0x0004003d,0x00000006,0x000001b0,0x0000016e, - 0x0004003d,0x00000006,0x000001b1,0x000000a5,0x0007000c,0x00000006,0x000001b2,0x00000001, - 0x00000028,0x000001b0,0x000001b1,0x00050083,0x00000006,0x000001b3,0x000001af,0x000001b2, - 0x0004003d,0x00000006,0x000001b4,0x00000150,0x00050085,0x00000006,0x000001b5,0x00000195, - 0x000001b4,0x00050041,0x00000007,0x000001b6,0x0000018e,0x00000095,0x0004003d,0x00000006, - 0x000001b7,0x000001b6,0x00050081,0x00000006,0x000001b8,0x000001b5,0x000001b7,0x0003003e, - 0x000001b9,0x000001b8,0x00050039,0x00000006,0x000001ba,0x0000000a,0x000001b9,0x00050085, - 0x00000006,0x000001bb,0x000001b3,0x000001ba,0x0003003e,0x000001ad,0x000001bb,0x00050041, - 0x00000007,0x000001bd,0x0000018e,0x00000091,0x0004003d,0x00000006,0x000001be,0x000001bd, - 0x0004003d,0x00000006,0x000001bf,0x00000178,0x0004003d,0x00000006,0x000001c0,0x000000a8, - 0x0007000c,0x00000006,0x000001c1,0x00000001,0x00000028,0x000001bf,0x000001c0,0x00050083, - 0x00000006,0x000001c2,0x000001be,0x000001c1,0x0004003d,0x00000006,0x000001c3,0x0000015a, - 0x00050085,0x00000006,0x000001c4,0x00000195,0x000001c3,0x00050041,0x00000007,0x000001c5, - 0x0000018e,0x00000095,0x0004003d,0x00000006,0x000001c6,0x000001c5,0x00050081,0x00000006, - 0x000001c7,0x000001c4,0x000001c6,0x0003003e,0x000001c8,0x000001c7,0x00050039,0x00000006, - 0x000001c9,0x0000000a,0x000001c8,0x00050085,0x00000006,0x000001ca,0x000001c2,0x000001c9, - 0x0003003e,0x000001bc,0x000001ca,0x00050041,0x00000007,0x000001cc,0x0000018e,0x00000091, - 0x0004003d,0x00000006,0x000001cd,0x000001cc,0x0004003d,0x00000006,0x000001ce,0x00000182, - 0x0004003d,0x00000006,0x000001cf,0x000000ab,0x0007000c,0x00000006,0x000001d0,0x00000001, - 0x00000028,0x000001ce,0x000001cf,0x00050083,0x00000006,0x000001d1,0x000001cd,0x000001d0, - 0x0004003d,0x00000006,0x000001d2,0x00000164,0x00050085,0x00000006,0x000001d3,0x00000195, - 0x000001d2,0x00050041,0x00000007,0x000001d4,0x0000018e,0x00000095,0x0004003d,0x00000006, - 0x000001d5,0x000001d4,0x00050081,0x00000006,0x000001d6,0x000001d3,0x000001d5,0x0003003e, - 0x000001d7,0x000001d6,0x00050039,0x00000006,0x000001d8,0x0000000a,0x000001d7,0x00050085, - 0x00000006,0x000001d9,0x000001d1,0x000001d8,0x0003003e,0x000001cb,0x000001d9,0x0004003d, - 0x00000006,0x000001db,0x00000191,0x0004007f,0x00000006,0x000001dc,0x000001db,0x0004003d, - 0x00000006,0x000001dd,0x000001ad,0x0007000c,0x00000006,0x000001de,0x00000001,0x00000028, - 0x000001dc,0x000001dd,0x0003003e,0x000001da,0x000001de,0x0004003d,0x00000006,0x000001e0, - 0x0000019b,0x0004007f,0x00000006,0x000001e1,0x000001e0,0x0004003d,0x00000006,0x000001e2, - 0x000001bc,0x0007000c,0x00000006,0x000001e3,0x00000001,0x00000028,0x000001e1,0x000001e2, - 0x0003003e,0x000001df,0x000001e3,0x0004003d,0x00000006,0x000001e5,0x000001a4,0x0004007f, - 0x00000006,0x000001e6,0x000001e5,0x0004003d,0x00000006,0x000001e7,0x000001cb,0x0007000c, - 0x00000006,0x000001e8,0x00000001,0x00000028,0x000001e6,0x000001e7,0x0003003e,0x000001e4, - 0x000001e8,0x0004003d,0x00000006,0x000001ec,0x000001da,0x0003003e,0x000001eb,0x000001ec, - 0x0004003d,0x00000006,0x000001ee,0x000001df,0x0003003e,0x000001ed,0x000001ee,0x0004003d, - 0x00000006,0x000001f0,0x000001e4,0x0003003e,0x000001ef,0x000001f0,0x00070039,0x00000006, - 0x000001f1,0x0000001b,0x000001eb,0x000001ed,0x000001ef,0x0007000c,0x00000006,0x000001f2, - 0x00000001,0x00000025,0x000001f1,0x00000042,0x0007000c,0x00000006,0x000001f3,0x00000001, - 0x00000028,0x000001ea,0x000001f2,0x00050041,0x000001f4,0x000001f5,0x00000035,0x00000091, - 0x0004003d,0x0000002b,0x000001f6,0x000001f5,0x0004007c,0x00000006,0x000001f7,0x000001f6, - 0x00050085,0x00000006,0x000001f8,0x000001f3,0x000001f7,0x0003003e,0x000001e9,0x000001f8, - 0x0004003d,0x00000006,0x000001fa,0x000001e9,0x00050085,0x00000006,0x000001fb,0x00000195, - 0x000001fa,0x00050081,0x00000006,0x000001fc,0x000001fb,0x00000038,0x0003003e,0x000001fd, - 0x000001fc,0x00050039,0x00000006,0x000001fe,0x0000000d,0x000001fd,0x0003003e,0x000001f9, - 0x000001fe,0x0004003d,0x00000006,0x000001ff,0x000001e9,0x0004003d,0x00000006,0x00000200, - 0x00000090,0x00050085,0x00000006,0x00000201,0x000001ff,0x00000200,0x0004003d,0x00000006, - 0x00000202,0x000001e9,0x0004003d,0x00000006,0x00000203,0x0000009c,0x00050085,0x00000006, - 0x00000204,0x00000202,0x00000203,0x00050081,0x00000006,0x00000205,0x00000201,0x00000204, - 0x0004003d,0x00000006,0x00000206,0x000001e9,0x0004003d,0x00000006,0x00000207,0x000000b7, - 0x00050085,0x00000006,0x00000208,0x00000206,0x00000207,0x00050081,0x00000006,0x00000209, - 0x00000205,0x00000208,0x0004003d,0x00000006,0x0000020a,0x000001e9,0x0004003d,0x00000006, - 0x0000020b,0x000000ae,0x00050085,0x00000006,0x0000020c,0x0000020a,0x0000020b,0x00050081, - 0x00000006,0x0000020d,0x00000209,0x0000020c,0x0004003d,0x00000006,0x0000020e,0x000000a5, - 0x00050081,0x00000006,0x0000020f,0x0000020d,0x0000020e,0x0004003d,0x00000006,0x00000210, - 0x000001f9,0x00050085,0x00000006,0x00000211,0x0000020f,0x00000210,0x0003003e,0x00000031, - 0x00000211,0x0004003d,0x00000006,0x00000212,0x000001e9,0x0004003d,0x00000006,0x00000213, - 0x00000094,0x00050085,0x00000006,0x00000214,0x00000212,0x00000213,0x0004003d,0x00000006, - 0x00000215,0x000001e9,0x0004003d,0x00000006,0x00000216,0x0000009f,0x00050085,0x00000006, - 0x00000217,0x00000215,0x00000216,0x00050081,0x00000006,0x00000218,0x00000214,0x00000217, - 0x0004003d,0x00000006,0x00000219,0x000001e9,0x0004003d,0x00000006,0x0000021a,0x000000ba, - 0x00050085,0x00000006,0x0000021b,0x00000219,0x0000021a,0x00050081,0x00000006,0x0000021c, - 0x00000218,0x0000021b,0x0004003d,0x00000006,0x0000021d,0x000001e9,0x0004003d,0x00000006, - 0x0000021e,0x000000b1,0x00050085,0x00000006,0x0000021f,0x0000021d,0x0000021e,0x00050081, - 0x00000006,0x00000220,0x0000021c,0x0000021f,0x0004003d,0x00000006,0x00000221,0x000000a8, - 0x00050081,0x00000006,0x00000222,0x00000220,0x00000221,0x0004003d,0x00000006,0x00000223, - 0x000001f9,0x00050085,0x00000006,0x00000224,0x00000222,0x00000223,0x0003003e,0x00000032, - 0x00000224,0x0004003d,0x00000006,0x00000225,0x000001e9,0x0004003d,0x00000006,0x00000226, - 0x00000098,0x00050085,0x00000006,0x00000227,0x00000225,0x00000226,0x0004003d,0x00000006, - 0x00000228,0x000001e9,0x0004003d,0x00000006,0x00000229,0x000000a2,0x00050085,0x00000006, - 0x0000022a,0x00000228,0x00000229,0x00050081,0x00000006,0x0000022b,0x00000227,0x0000022a, - 0x0004003d,0x00000006,0x0000022c,0x000001e9,0x0004003d,0x00000006,0x0000022d,0x000000bd, - 0x00050085,0x00000006,0x0000022e,0x0000022c,0x0000022d,0x00050081,0x00000006,0x0000022f, - 0x0000022b,0x0000022e,0x0004003d,0x00000006,0x00000230,0x000001e9,0x0004003d,0x00000006, - 0x00000231,0x000000b4,0x00050085,0x00000006,0x00000232,0x00000230,0x00000231,0x00050081, - 0x00000006,0x00000233,0x0000022f,0x00000232,0x0004003d,0x00000006,0x00000234,0x000000ab, - 0x00050081,0x00000006,0x00000235,0x00000233,0x00000234,0x0004003d,0x00000006,0x00000236, - 0x000001f9,0x00050085,0x00000006,0x00000237,0x00000235,0x00000236,0x0003003e,0x00000033, - 0x00000237,0x000100fd,0x00010038 + 0x00000007,0x0000013a,0x00000007,0x0004003b,0x00000007,0x0000013c,0x00000007,0x0004003b, + 0x00000007,0x00000140,0x00000007,0x0004003b,0x00000007,0x00000143,0x00000007,0x0004003b, + 0x00000007,0x00000149,0x00000007,0x0004003b,0x00000007,0x0000014a,0x00000007,0x0004003b, + 0x00000007,0x0000014c,0x00000007,0x0004003b,0x00000007,0x0000014e,0x00000007,0x0004003b, + 0x00000007,0x00000153,0x00000007,0x0004003b,0x00000007,0x00000154,0x00000007,0x0004003b, + 0x00000007,0x00000156,0x00000007,0x0004003b,0x00000007,0x00000158,0x00000007,0x0004003b, + 0x00000007,0x0000015d,0x00000007,0x0004003b,0x00000007,0x0000015e,0x00000007,0x0004003b, + 0x00000007,0x00000160,0x00000007,0x0004003b,0x00000007,0x00000162,0x00000007,0x0004003b, + 0x00000007,0x00000167,0x00000007,0x0004003b,0x00000007,0x00000168,0x00000007,0x0004003b, + 0x00000007,0x0000016a,0x00000007,0x0004003b,0x00000007,0x0000016c,0x00000007,0x0004003b, + 0x00000007,0x00000171,0x00000007,0x0004003b,0x00000007,0x00000172,0x00000007,0x0004003b, + 0x00000007,0x00000174,0x00000007,0x0004003b,0x00000007,0x00000176,0x00000007,0x0004003b, + 0x00000007,0x0000017b,0x00000007,0x0004003b,0x00000007,0x0000017c,0x00000007,0x0004003b, + 0x00000007,0x0000017e,0x00000007,0x0004003b,0x00000007,0x00000180,0x00000007,0x0004003b, + 0x00000186,0x00000187,0x00000007,0x0004003b,0x00000007,0x0000018a,0x00000007,0x0004003b, + 0x00000007,0x0000018e,0x00000007,0x0004003b,0x00000007,0x00000191,0x00000007,0x0004003b, + 0x00000007,0x00000194,0x00000007,0x0004003b,0x00000007,0x0000019a,0x00000007,0x0004003b, + 0x00000007,0x000001a0,0x00000007,0x0004003b,0x00000007,0x000001a6,0x00000007,0x0004003b, + 0x00000007,0x000001aa,0x00000007,0x0004003b,0x00000007,0x000001b4,0x00000007,0x0004003b, + 0x00000007,0x000001b7,0x00000007,0x0004003b,0x00000007,0x000001c1,0x00000007,0x0004003b, + 0x00000007,0x000001c4,0x00000007,0x0004003b,0x00000007,0x000001ce,0x00000007,0x0004003b, + 0x00000007,0x000001d5,0x00000007,0x0004003b,0x00000007,0x000001dc,0x00000007,0x0004003b, + 0x00000007,0x000001e3,0x00000007,0x0004003b,0x00000007,0x000001e8,0x00000007,0x0004003b, + 0x00000007,0x000001f0,0x00000007,0x0004003b,0x00000007,0x000001f4,0x00000007,0x0004003b, + 0x00000007,0x000001fc,0x00000007,0x0004003b,0x00000007,0x00000200,0x00000007,0x0004003b, + 0x00000007,0x00000208,0x00000007,0x0004003b,0x00000007,0x0000020d,0x00000007,0x0004003b, + 0x00000007,0x00000212,0x00000007,0x0004003b,0x00000007,0x00000217,0x00000007,0x0004003b, + 0x00000007,0x00000219,0x00000007,0x0004003b,0x00000007,0x0000021b,0x00000007,0x0004003b, + 0x00000007,0x0000021d,0x00000007,0x0004003b,0x00000007,0x00000227,0x00000007,0x0004003b, + 0x00000007,0x0000022b,0x00000007,0x0004003d,0x00000029,0x00000063,0x00000031,0x0004007c, + 0x0000001b,0x00000064,0x00000063,0x0003003e,0x00000062,0x00000064,0x0004003d,0x0000001b, + 0x00000068,0x00000062,0x00050080,0x0000001b,0x0000006b,0x00000068,0x0000006a,0x0003003e, + 0x0000006c,0x0000006b,0x00050039,0x0000001d,0x0000006d,0x00000020,0x0000006c,0x0008004f, + 0x00000065,0x0000006e,0x0000006d,0x0000006d,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000067,0x0000006e,0x0004003d,0x0000001b,0x00000070,0x00000062,0x00050080,0x0000001b, + 0x00000072,0x00000070,0x00000071,0x0003003e,0x00000073,0x00000072,0x00050039,0x0000001d, + 0x00000074,0x00000020,0x00000073,0x0008004f,0x00000065,0x00000075,0x00000074,0x00000074, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000006f,0x00000075,0x0004003d,0x0000001b, + 0x00000078,0x00000062,0x0003003e,0x00000077,0x00000078,0x00050039,0x0000001d,0x00000079, + 0x00000020,0x00000077,0x0008004f,0x00000065,0x0000007a,0x00000079,0x00000079,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000076,0x0000007a,0x0004003d,0x0000001b,0x0000007c, + 0x00000062,0x00050080,0x0000001b,0x0000007e,0x0000007c,0x0000007d,0x0003003e,0x0000007f, + 0x0000007e,0x00050039,0x0000001d,0x00000080,0x00000020,0x0000007f,0x0008004f,0x00000065, + 0x00000081,0x00000080,0x00000080,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000007b, + 0x00000081,0x0004003d,0x0000001b,0x00000083,0x00000062,0x00050080,0x0000001b,0x00000085, + 0x00000083,0x00000084,0x0003003e,0x00000086,0x00000085,0x00050039,0x0000001d,0x00000087, + 0x00000020,0x00000086,0x0008004f,0x00000065,0x00000088,0x00000087,0x00000087,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000082,0x00000088,0x00050041,0x00000007,0x0000008b, + 0x00000067,0x0000008a,0x0004003d,0x00000006,0x0000008c,0x0000008b,0x0003003e,0x00000089, + 0x0000008c,0x00050041,0x00000007,0x0000008f,0x00000067,0x0000008e,0x0004003d,0x00000006, + 0x00000090,0x0000008f,0x0003003e,0x0000008d,0x00000090,0x00050041,0x00000007,0x00000093, + 0x00000067,0x00000092,0x0004003d,0x00000006,0x00000094,0x00000093,0x0003003e,0x00000091, + 0x00000094,0x00050041,0x00000007,0x00000096,0x0000006f,0x0000008a,0x0004003d,0x00000006, + 0x00000097,0x00000096,0x0003003e,0x00000095,0x00000097,0x00050041,0x00000007,0x00000099, + 0x0000006f,0x0000008e,0x0004003d,0x00000006,0x0000009a,0x00000099,0x0003003e,0x00000098, + 0x0000009a,0x00050041,0x00000007,0x0000009c,0x0000006f,0x00000092,0x0004003d,0x00000006, + 0x0000009d,0x0000009c,0x0003003e,0x0000009b,0x0000009d,0x00050041,0x00000007,0x0000009f, + 0x00000076,0x0000008a,0x0004003d,0x00000006,0x000000a0,0x0000009f,0x0003003e,0x0000009e, + 0x000000a0,0x00050041,0x00000007,0x000000a2,0x00000076,0x0000008e,0x0004003d,0x00000006, + 0x000000a3,0x000000a2,0x0003003e,0x000000a1,0x000000a3,0x00050041,0x00000007,0x000000a5, + 0x00000076,0x00000092,0x0004003d,0x00000006,0x000000a6,0x000000a5,0x0003003e,0x000000a4, + 0x000000a6,0x00050041,0x00000007,0x000000a8,0x0000007b,0x0000008a,0x0004003d,0x00000006, + 0x000000a9,0x000000a8,0x0003003e,0x000000a7,0x000000a9,0x00050041,0x00000007,0x000000ab, + 0x0000007b,0x0000008e,0x0004003d,0x00000006,0x000000ac,0x000000ab,0x0003003e,0x000000aa, + 0x000000ac,0x00050041,0x00000007,0x000000ae,0x0000007b,0x00000092,0x0004003d,0x00000006, + 0x000000af,0x000000ae,0x0003003e,0x000000ad,0x000000af,0x00050041,0x00000007,0x000000b1, + 0x00000082,0x0000008a,0x0004003d,0x00000006,0x000000b2,0x000000b1,0x0003003e,0x000000b0, + 0x000000b2,0x00050041,0x00000007,0x000000b4,0x00000082,0x0000008e,0x0004003d,0x00000006, + 0x000000b5,0x000000b4,0x0003003e,0x000000b3,0x000000b5,0x00050041,0x00000007,0x000000b7, + 0x00000082,0x00000092,0x0004003d,0x00000006,0x000000b8,0x000000b7,0x0003003e,0x000000b6, + 0x000000b8,0x0004003d,0x00000006,0x000000ba,0x00000089,0x0003003e,0x000000b9,0x000000ba, + 0x0004003d,0x00000006,0x000000bc,0x0000008d,0x0003003e,0x000000bb,0x000000bc,0x0004003d, + 0x00000006,0x000000be,0x00000091,0x0003003e,0x000000bd,0x000000be,0x00070039,0x00000002, + 0x000000bf,0x00000026,0x000000b9,0x000000bb,0x000000bd,0x0004003d,0x00000006,0x000000c0, + 0x000000b9,0x0003003e,0x00000089,0x000000c0,0x0004003d,0x00000006,0x000000c1,0x000000bb, + 0x0003003e,0x0000008d,0x000000c1,0x0004003d,0x00000006,0x000000c2,0x000000bd,0x0003003e, + 0x00000091,0x000000c2,0x0004003d,0x00000006,0x000000c4,0x00000095,0x0003003e,0x000000c3, + 0x000000c4,0x0004003d,0x00000006,0x000000c6,0x00000098,0x0003003e,0x000000c5,0x000000c6, + 0x0004003d,0x00000006,0x000000c8,0x0000009b,0x0003003e,0x000000c7,0x000000c8,0x00070039, + 0x00000002,0x000000c9,0x00000026,0x000000c3,0x000000c5,0x000000c7,0x0004003d,0x00000006, + 0x000000ca,0x000000c3,0x0003003e,0x00000095,0x000000ca,0x0004003d,0x00000006,0x000000cb, + 0x000000c5,0x0003003e,0x00000098,0x000000cb,0x0004003d,0x00000006,0x000000cc,0x000000c7, + 0x0003003e,0x0000009b,0x000000cc,0x0004003d,0x00000006,0x000000ce,0x0000009e,0x0003003e, + 0x000000cd,0x000000ce,0x0004003d,0x00000006,0x000000d0,0x000000a1,0x0003003e,0x000000cf, + 0x000000d0,0x0004003d,0x00000006,0x000000d2,0x000000a4,0x0003003e,0x000000d1,0x000000d2, + 0x00070039,0x00000002,0x000000d3,0x00000026,0x000000cd,0x000000cf,0x000000d1,0x0004003d, + 0x00000006,0x000000d4,0x000000cd,0x0003003e,0x0000009e,0x000000d4,0x0004003d,0x00000006, + 0x000000d5,0x000000cf,0x0003003e,0x000000a1,0x000000d5,0x0004003d,0x00000006,0x000000d6, + 0x000000d1,0x0003003e,0x000000a4,0x000000d6,0x0004003d,0x00000006,0x000000d8,0x000000a7, + 0x0003003e,0x000000d7,0x000000d8,0x0004003d,0x00000006,0x000000da,0x000000aa,0x0003003e, + 0x000000d9,0x000000da,0x0004003d,0x00000006,0x000000dc,0x000000ad,0x0003003e,0x000000db, + 0x000000dc,0x00070039,0x00000002,0x000000dd,0x00000026,0x000000d7,0x000000d9,0x000000db, + 0x0004003d,0x00000006,0x000000de,0x000000d7,0x0003003e,0x000000a7,0x000000de,0x0004003d, + 0x00000006,0x000000df,0x000000d9,0x0003003e,0x000000aa,0x000000df,0x0004003d,0x00000006, + 0x000000e0,0x000000db,0x0003003e,0x000000ad,0x000000e0,0x0004003d,0x00000006,0x000000e2, + 0x000000b0,0x0003003e,0x000000e1,0x000000e2,0x0004003d,0x00000006,0x000000e4,0x000000b3, + 0x0003003e,0x000000e3,0x000000e4,0x0004003d,0x00000006,0x000000e6,0x000000b6,0x0003003e, + 0x000000e5,0x000000e6,0x00070039,0x00000002,0x000000e7,0x00000026,0x000000e1,0x000000e3, + 0x000000e5,0x0004003d,0x00000006,0x000000e8,0x000000e1,0x0003003e,0x000000b0,0x000000e8, + 0x0004003d,0x00000006,0x000000e9,0x000000e3,0x0003003e,0x000000b3,0x000000e9,0x0004003d, + 0x00000006,0x000000ea,0x000000e5,0x0003003e,0x000000b6,0x000000ea,0x0004003d,0x00000006, + 0x000000ec,0x00000091,0x00050085,0x00000006,0x000000ee,0x000000ec,0x000000ed,0x0004003d, + 0x00000006,0x000000ef,0x00000089,0x00050085,0x00000006,0x000000f0,0x000000ef,0x000000ed, + 0x0004003d,0x00000006,0x000000f1,0x0000008d,0x00050081,0x00000006,0x000000f2,0x000000f0, + 0x000000f1,0x00050081,0x00000006,0x000000f3,0x000000ee,0x000000f2,0x0003003e,0x000000eb, + 0x000000f3,0x0004003d,0x00000006,0x000000f5,0x0000009b,0x00050085,0x00000006,0x000000f6, + 0x000000f5,0x000000ed,0x0004003d,0x00000006,0x000000f7,0x00000095,0x00050085,0x00000006, + 0x000000f8,0x000000f7,0x000000ed,0x0004003d,0x00000006,0x000000f9,0x00000098,0x00050081, + 0x00000006,0x000000fa,0x000000f8,0x000000f9,0x00050081,0x00000006,0x000000fb,0x000000f6, + 0x000000fa,0x0003003e,0x000000f4,0x000000fb,0x0004003d,0x00000006,0x000000fd,0x000000a4, + 0x00050085,0x00000006,0x000000fe,0x000000fd,0x000000ed,0x0004003d,0x00000006,0x000000ff, + 0x0000009e,0x00050085,0x00000006,0x00000100,0x000000ff,0x000000ed,0x0004003d,0x00000006, + 0x00000101,0x000000a1,0x00050081,0x00000006,0x00000102,0x00000100,0x00000101,0x00050081, + 0x00000006,0x00000103,0x000000fe,0x00000102,0x0003003e,0x000000fc,0x00000103,0x0004003d, + 0x00000006,0x00000105,0x000000ad,0x00050085,0x00000006,0x00000106,0x00000105,0x000000ed, + 0x0004003d,0x00000006,0x00000107,0x000000a7,0x00050085,0x00000006,0x00000108,0x00000107, + 0x000000ed,0x0004003d,0x00000006,0x00000109,0x000000aa,0x00050081,0x00000006,0x0000010a, + 0x00000108,0x00000109,0x00050081,0x00000006,0x0000010b,0x00000106,0x0000010a,0x0003003e, + 0x00000104,0x0000010b,0x0004003d,0x00000006,0x0000010d,0x000000b6,0x00050085,0x00000006, + 0x0000010e,0x0000010d,0x000000ed,0x0004003d,0x00000006,0x0000010f,0x000000b0,0x00050085, + 0x00000006,0x00000110,0x0000010f,0x000000ed,0x0004003d,0x00000006,0x00000111,0x000000b3, + 0x00050081,0x00000006,0x00000112,0x00000110,0x00000111,0x00050081,0x00000006,0x00000113, + 0x0000010e,0x00000112,0x0003003e,0x0000010c,0x00000113,0x0004003d,0x00000006,0x00000116, + 0x000000eb,0x00050085,0x00000006,0x00000117,0x00000115,0x00000116,0x0004003d,0x00000006, + 0x00000118,0x000000f4,0x00050085,0x00000006,0x00000119,0x00000115,0x00000118,0x00050081, + 0x00000006,0x0000011a,0x00000117,0x00000119,0x0004003d,0x00000006,0x0000011b,0x00000104, + 0x00050085,0x00000006,0x0000011c,0x00000115,0x0000011b,0x00050081,0x00000006,0x0000011d, + 0x0000011a,0x0000011c,0x0004003d,0x00000006,0x0000011e,0x0000010c,0x00050085,0x00000006, + 0x0000011f,0x00000115,0x0000011e,0x00050081,0x00000006,0x00000120,0x0000011d,0x0000011f, + 0x0004003d,0x00000006,0x00000121,0x000000fc,0x00050083,0x00000006,0x00000122,0x00000120, + 0x00000121,0x0003003e,0x00000114,0x00000122,0x0004003d,0x00000006,0x00000123,0x00000114, + 0x0006000c,0x00000006,0x00000124,0x00000001,0x00000004,0x00000123,0x0004003d,0x00000006, + 0x00000126,0x000000eb,0x0003003e,0x00000125,0x00000126,0x0004003d,0x00000006,0x00000128, + 0x000000f4,0x0003003e,0x00000127,0x00000128,0x0004003d,0x00000006,0x0000012a,0x000000fc, + 0x0003003e,0x00000129,0x0000012a,0x00070039,0x00000006,0x0000012b,0x00000018,0x00000125, + 0x00000127,0x00000129,0x0003003e,0x0000012c,0x0000012b,0x0004003d,0x00000006,0x0000012e, + 0x00000104,0x0003003e,0x0000012d,0x0000012e,0x0004003d,0x00000006,0x00000130,0x0000010c, + 0x0003003e,0x0000012f,0x00000130,0x00070039,0x00000006,0x00000131,0x00000018,0x0000012c, + 0x0000012d,0x0000012f,0x0004003d,0x00000006,0x00000133,0x000000eb,0x0003003e,0x00000132, + 0x00000133,0x0004003d,0x00000006,0x00000135,0x000000f4,0x0003003e,0x00000134,0x00000135, + 0x0004003d,0x00000006,0x00000137,0x000000fc,0x0003003e,0x00000136,0x00000137,0x00070039, + 0x00000006,0x00000138,0x00000013,0x00000132,0x00000134,0x00000136,0x0003003e,0x00000139, + 0x00000138,0x0004003d,0x00000006,0x0000013b,0x00000104,0x0003003e,0x0000013a,0x0000013b, + 0x0004003d,0x00000006,0x0000013d,0x0000010c,0x0003003e,0x0000013c,0x0000013d,0x00070039, + 0x00000006,0x0000013e,0x00000013,0x00000139,0x0000013a,0x0000013c,0x00050083,0x00000006, + 0x0000013f,0x00000131,0x0000013e,0x0003003e,0x00000140,0x0000013f,0x00050039,0x00000006, + 0x00000141,0x0000000a,0x00000140,0x00050085,0x00000006,0x00000142,0x00000124,0x00000141, + 0x0003003e,0x00000143,0x00000142,0x00050039,0x00000006,0x00000144,0x0000000d,0x00000143, + 0x0003003e,0x00000114,0x00000144,0x0004003d,0x00000006,0x00000146,0x00000114,0x00050085, + 0x00000006,0x00000147,0x00000145,0x00000146,0x00050081,0x00000006,0x00000148,0x00000147, + 0x00000035,0x0003003e,0x00000114,0x00000148,0x0004003d,0x00000006,0x0000014b,0x00000089, + 0x0003003e,0x0000014a,0x0000014b,0x0004003d,0x00000006,0x0000014d,0x00000095,0x0003003e, + 0x0000014c,0x0000014d,0x0004003d,0x00000006,0x0000014f,0x000000a7,0x0003003e,0x0000014e, + 0x0000014f,0x00070039,0x00000006,0x00000150,0x00000013,0x0000014a,0x0000014c,0x0000014e, + 0x0004003d,0x00000006,0x00000151,0x000000b0,0x0007000c,0x00000006,0x00000152,0x00000001, + 0x00000025,0x00000150,0x00000151,0x0003003e,0x00000149,0x00000152,0x0004003d,0x00000006, + 0x00000155,0x0000008d,0x0003003e,0x00000154,0x00000155,0x0004003d,0x00000006,0x00000157, + 0x00000098,0x0003003e,0x00000156,0x00000157,0x0004003d,0x00000006,0x00000159,0x000000aa, + 0x0003003e,0x00000158,0x00000159,0x00070039,0x00000006,0x0000015a,0x00000013,0x00000154, + 0x00000156,0x00000158,0x0004003d,0x00000006,0x0000015b,0x000000b3,0x0007000c,0x00000006, + 0x0000015c,0x00000001,0x00000025,0x0000015a,0x0000015b,0x0003003e,0x00000153,0x0000015c, + 0x0004003d,0x00000006,0x0000015f,0x00000091,0x0003003e,0x0000015e,0x0000015f,0x0004003d, + 0x00000006,0x00000161,0x0000009b,0x0003003e,0x00000160,0x00000161,0x0004003d,0x00000006, + 0x00000163,0x000000ad,0x0003003e,0x00000162,0x00000163,0x00070039,0x00000006,0x00000164, + 0x00000013,0x0000015e,0x00000160,0x00000162,0x0004003d,0x00000006,0x00000165,0x000000b6, + 0x0007000c,0x00000006,0x00000166,0x00000001,0x00000025,0x00000164,0x00000165,0x0003003e, + 0x0000015d,0x00000166,0x0004003d,0x00000006,0x00000169,0x00000089,0x0003003e,0x00000168, + 0x00000169,0x0004003d,0x00000006,0x0000016b,0x00000095,0x0003003e,0x0000016a,0x0000016b, + 0x0004003d,0x00000006,0x0000016d,0x000000a7,0x0003003e,0x0000016c,0x0000016d,0x00070039, + 0x00000006,0x0000016e,0x00000018,0x00000168,0x0000016a,0x0000016c,0x0004003d,0x00000006, + 0x0000016f,0x000000b0,0x0007000c,0x00000006,0x00000170,0x00000001,0x00000028,0x0000016e, + 0x0000016f,0x0003003e,0x00000167,0x00000170,0x0004003d,0x00000006,0x00000173,0x0000008d, + 0x0003003e,0x00000172,0x00000173,0x0004003d,0x00000006,0x00000175,0x00000098,0x0003003e, + 0x00000174,0x00000175,0x0004003d,0x00000006,0x00000177,0x000000aa,0x0003003e,0x00000176, + 0x00000177,0x00070039,0x00000006,0x00000178,0x00000018,0x00000172,0x00000174,0x00000176, + 0x0004003d,0x00000006,0x00000179,0x000000b3,0x0007000c,0x00000006,0x0000017a,0x00000001, + 0x00000028,0x00000178,0x00000179,0x0003003e,0x00000171,0x0000017a,0x0004003d,0x00000006, + 0x0000017d,0x00000091,0x0003003e,0x0000017c,0x0000017d,0x0004003d,0x00000006,0x0000017f, + 0x0000009b,0x0003003e,0x0000017e,0x0000017f,0x0004003d,0x00000006,0x00000181,0x000000ad, + 0x0003003e,0x00000180,0x00000181,0x00070039,0x00000006,0x00000182,0x00000018,0x0000017c, + 0x0000017e,0x00000180,0x0004003d,0x00000006,0x00000183,0x000000b6,0x0007000c,0x00000006, + 0x00000184,0x00000001,0x00000028,0x00000182,0x00000183,0x0003003e,0x0000017b,0x00000184, + 0x0003003e,0x00000187,0x00000189,0x0004003d,0x00000006,0x0000018c,0x00000167,0x00050085, + 0x00000006,0x0000018d,0x0000018b,0x0000018c,0x0003003e,0x0000018a,0x0000018d,0x0004003d, + 0x00000006,0x0000018f,0x00000171,0x00050085,0x00000006,0x00000190,0x0000018b,0x0000018f, + 0x0003003e,0x0000018e,0x00000190,0x0004003d,0x00000006,0x00000192,0x0000017b,0x00050085, + 0x00000006,0x00000193,0x0000018b,0x00000192,0x0003003e,0x00000191,0x00000193,0x0004003d, + 0x00000006,0x00000195,0x00000149,0x00050085,0x00000006,0x00000196,0x0000018b,0x00000195, + 0x00050041,0x00000007,0x00000197,0x00000187,0x0000008e,0x0004003d,0x00000006,0x00000198, + 0x00000197,0x00050081,0x00000006,0x00000199,0x00000196,0x00000198,0x0003003e,0x00000194, + 0x00000199,0x0004003d,0x00000006,0x0000019b,0x00000153,0x00050085,0x00000006,0x0000019c, + 0x0000018b,0x0000019b,0x00050041,0x00000007,0x0000019d,0x00000187,0x0000008e,0x0004003d, + 0x00000006,0x0000019e,0x0000019d,0x00050081,0x00000006,0x0000019f,0x0000019c,0x0000019e, + 0x0003003e,0x0000019a,0x0000019f,0x0004003d,0x00000006,0x000001a1,0x0000015d,0x00050085, + 0x00000006,0x000001a2,0x0000018b,0x000001a1,0x00050041,0x00000007,0x000001a3,0x00000187, + 0x0000008e,0x0004003d,0x00000006,0x000001a4,0x000001a3,0x00050081,0x00000006,0x000001a5, + 0x000001a2,0x000001a4,0x0003003e,0x000001a0,0x000001a5,0x0004003d,0x00000006,0x000001a7, + 0x0000018a,0x000500ba,0x000001a8,0x000001a9,0x000001a7,0x0000003b,0x000300f7,0x000001ac, + 0x00000000,0x000400fa,0x000001a9,0x000001ab,0x000001b2,0x000200f8,0x000001ab,0x0004003d, + 0x00000006,0x000001ad,0x00000149,0x0004003d,0x00000006,0x000001ae,0x0000009e,0x0007000c, + 0x00000006,0x000001af,0x00000001,0x00000025,0x000001ad,0x000001ae,0x0004003d,0x00000006, + 0x000001b0,0x0000018a,0x00050088,0x00000006,0x000001b1,0x000001af,0x000001b0,0x0003003e, + 0x000001aa,0x000001b1,0x000200f9,0x000001ac,0x000200f8,0x000001b2,0x0003003e,0x000001aa, + 0x0000003b,0x000200f9,0x000001ac,0x000200f8,0x000001ac,0x0004003d,0x00000006,0x000001b3, + 0x000001aa,0x0003003e,0x000001a6,0x000001b3,0x0004003d,0x00000006,0x000001b5,0x0000018e, + 0x000500ba,0x000001a8,0x000001b6,0x000001b5,0x0000003b,0x000300f7,0x000001b9,0x00000000, + 0x000400fa,0x000001b6,0x000001b8,0x000001bf,0x000200f8,0x000001b8,0x0004003d,0x00000006, + 0x000001ba,0x00000153,0x0004003d,0x00000006,0x000001bb,0x000000a1,0x0007000c,0x00000006, + 0x000001bc,0x00000001,0x00000025,0x000001ba,0x000001bb,0x0004003d,0x00000006,0x000001bd, + 0x0000018e,0x00050088,0x00000006,0x000001be,0x000001bc,0x000001bd,0x0003003e,0x000001b7, + 0x000001be,0x000200f9,0x000001b9,0x000200f8,0x000001bf,0x0003003e,0x000001b7,0x0000003b, + 0x000200f9,0x000001b9,0x000200f8,0x000001b9,0x0004003d,0x00000006,0x000001c0,0x000001b7, + 0x0003003e,0x000001b4,0x000001c0,0x0004003d,0x00000006,0x000001c2,0x00000191,0x000500ba, + 0x000001a8,0x000001c3,0x000001c2,0x0000003b,0x000300f7,0x000001c6,0x00000000,0x000400fa, + 0x000001c3,0x000001c5,0x000001cc,0x000200f8,0x000001c5,0x0004003d,0x00000006,0x000001c7, + 0x0000015d,0x0004003d,0x00000006,0x000001c8,0x000000a4,0x0007000c,0x00000006,0x000001c9, + 0x00000001,0x00000025,0x000001c7,0x000001c8,0x0004003d,0x00000006,0x000001ca,0x00000191, + 0x00050088,0x00000006,0x000001cb,0x000001c9,0x000001ca,0x0003003e,0x000001c4,0x000001cb, + 0x000200f9,0x000001c6,0x000200f8,0x000001cc,0x0003003e,0x000001c4,0x0000003b,0x000200f9, + 0x000001c6,0x000200f8,0x000001c6,0x0004003d,0x00000006,0x000001cd,0x000001c4,0x0003003e, + 0x000001c1,0x000001cd,0x00050041,0x00000007,0x000001cf,0x00000187,0x0000008a,0x0004003d, + 0x00000006,0x000001d0,0x000001cf,0x0004003d,0x00000006,0x000001d1,0x00000167,0x0004003d, + 0x00000006,0x000001d2,0x0000009e,0x0007000c,0x00000006,0x000001d3,0x00000001,0x00000028, + 0x000001d1,0x000001d2,0x00050083,0x00000006,0x000001d4,0x000001d0,0x000001d3,0x0003003e, + 0x000001ce,0x000001d4,0x00050041,0x00000007,0x000001d6,0x00000187,0x0000008a,0x0004003d, + 0x00000006,0x000001d7,0x000001d6,0x0004003d,0x00000006,0x000001d8,0x00000171,0x0004003d, + 0x00000006,0x000001d9,0x000000a1,0x0007000c,0x00000006,0x000001da,0x00000001,0x00000028, + 0x000001d8,0x000001d9,0x00050083,0x00000006,0x000001db,0x000001d7,0x000001da,0x0003003e, + 0x000001d5,0x000001db,0x00050041,0x00000007,0x000001dd,0x00000187,0x0000008a,0x0004003d, + 0x00000006,0x000001de,0x000001dd,0x0004003d,0x00000006,0x000001df,0x0000017b,0x0004003d, + 0x00000006,0x000001e0,0x000000a4,0x0007000c,0x00000006,0x000001e1,0x00000001,0x00000028, + 0x000001df,0x000001e0,0x00050083,0x00000006,0x000001e2,0x000001de,0x000001e1,0x0003003e, + 0x000001dc,0x000001e2,0x0004003d,0x00000006,0x000001e4,0x00000194,0x0006000c,0x00000006, + 0x000001e5,0x00000001,0x00000004,0x000001e4,0x000500ba,0x000001a8,0x000001e7,0x000001e5, + 0x000001e6,0x000300f7,0x000001ea,0x00000000,0x000400fa,0x000001e7,0x000001e9,0x000001ee, + 0x000200f8,0x000001e9,0x0004003d,0x00000006,0x000001eb,0x000001ce,0x0004003d,0x00000006, + 0x000001ec,0x00000194,0x00050088,0x00000006,0x000001ed,0x000001eb,0x000001ec,0x0003003e, + 0x000001e8,0x000001ed,0x000200f9,0x000001ea,0x000200f8,0x000001ee,0x0003003e,0x000001e8, + 0x0000003b,0x000200f9,0x000001ea,0x000200f8,0x000001ea,0x0004003d,0x00000006,0x000001ef, + 0x000001e8,0x0003003e,0x000001e3,0x000001ef,0x0004003d,0x00000006,0x000001f1,0x0000019a, + 0x0006000c,0x00000006,0x000001f2,0x00000001,0x00000004,0x000001f1,0x000500ba,0x000001a8, + 0x000001f3,0x000001f2,0x000001e6,0x000300f7,0x000001f6,0x00000000,0x000400fa,0x000001f3, + 0x000001f5,0x000001fa,0x000200f8,0x000001f5,0x0004003d,0x00000006,0x000001f7,0x000001d5, + 0x0004003d,0x00000006,0x000001f8,0x0000019a,0x00050088,0x00000006,0x000001f9,0x000001f7, + 0x000001f8,0x0003003e,0x000001f4,0x000001f9,0x000200f9,0x000001f6,0x000200f8,0x000001fa, + 0x0003003e,0x000001f4,0x0000003b,0x000200f9,0x000001f6,0x000200f8,0x000001f6,0x0004003d, + 0x00000006,0x000001fb,0x000001f4,0x0003003e,0x000001f0,0x000001fb,0x0004003d,0x00000006, + 0x000001fd,0x000001a0,0x0006000c,0x00000006,0x000001fe,0x00000001,0x00000004,0x000001fd, + 0x000500ba,0x000001a8,0x000001ff,0x000001fe,0x000001e6,0x000300f7,0x00000202,0x00000000, + 0x000400fa,0x000001ff,0x00000201,0x00000206,0x000200f8,0x00000201,0x0004003d,0x00000006, + 0x00000203,0x000001dc,0x0004003d,0x00000006,0x00000204,0x000001a0,0x00050088,0x00000006, + 0x00000205,0x00000203,0x00000204,0x0003003e,0x00000200,0x00000205,0x000200f9,0x00000202, + 0x000200f8,0x00000206,0x0003003e,0x00000200,0x0000003b,0x000200f9,0x00000202,0x000200f8, + 0x00000202,0x0004003d,0x00000006,0x00000207,0x00000200,0x0003003e,0x000001fc,0x00000207, + 0x0004003d,0x00000006,0x00000209,0x000001a6,0x0004007f,0x00000006,0x0000020a,0x00000209, + 0x0004003d,0x00000006,0x0000020b,0x000001e3,0x0007000c,0x00000006,0x0000020c,0x00000001, + 0x00000028,0x0000020a,0x0000020b,0x0003003e,0x00000208,0x0000020c,0x0004003d,0x00000006, + 0x0000020e,0x000001b4,0x0004007f,0x00000006,0x0000020f,0x0000020e,0x0004003d,0x00000006, + 0x00000210,0x000001f0,0x0007000c,0x00000006,0x00000211,0x00000001,0x00000028,0x0000020f, + 0x00000210,0x0003003e,0x0000020d,0x00000211,0x0004003d,0x00000006,0x00000213,0x000001c1, + 0x0004007f,0x00000006,0x00000214,0x00000213,0x0004003d,0x00000006,0x00000215,0x000001fc, + 0x0007000c,0x00000006,0x00000216,0x00000001,0x00000028,0x00000214,0x00000215,0x0003003e, + 0x00000212,0x00000216,0x0004003d,0x00000006,0x0000021a,0x00000208,0x0003003e,0x00000219, + 0x0000021a,0x0004003d,0x00000006,0x0000021c,0x0000020d,0x0003003e,0x0000021b,0x0000021c, + 0x0004003d,0x00000006,0x0000021e,0x00000212,0x0003003e,0x0000021d,0x0000021e,0x00070039, + 0x00000006,0x0000021f,0x00000018,0x00000219,0x0000021b,0x0000021d,0x0007000c,0x00000006, + 0x00000220,0x00000001,0x00000025,0x0000021f,0x0000003b,0x0007000c,0x00000006,0x00000221, + 0x00000001,0x00000028,0x00000218,0x00000220,0x00050041,0x00000222,0x00000223,0x00000032, + 0x0000008a,0x0004003d,0x00000028,0x00000224,0x00000223,0x0004007c,0x00000006,0x00000225, + 0x00000224,0x00050085,0x00000006,0x00000226,0x00000221,0x00000225,0x0003003e,0x00000217, + 0x00000226,0x0004003d,0x00000006,0x00000228,0x00000217,0x00050085,0x00000006,0x00000229, + 0x0000018b,0x00000228,0x00050081,0x00000006,0x0000022a,0x00000229,0x00000035,0x0003003e, + 0x0000022b,0x0000022a,0x00050039,0x00000006,0x0000022c,0x0000000a,0x0000022b,0x0003003e, + 0x00000227,0x0000022c,0x0004003d,0x00000006,0x0000022d,0x00000217,0x0004003d,0x00000006, + 0x0000022e,0x00000089,0x00050085,0x00000006,0x0000022f,0x0000022d,0x0000022e,0x0004003d, + 0x00000006,0x00000230,0x00000217,0x0004003d,0x00000006,0x00000231,0x00000095,0x00050085, + 0x00000006,0x00000232,0x00000230,0x00000231,0x00050081,0x00000006,0x00000233,0x0000022f, + 0x00000232,0x0004003d,0x00000006,0x00000234,0x00000217,0x0004003d,0x00000006,0x00000235, + 0x000000b0,0x00050085,0x00000006,0x00000236,0x00000234,0x00000235,0x00050081,0x00000006, + 0x00000237,0x00000233,0x00000236,0x0004003d,0x00000006,0x00000238,0x00000217,0x0004003d, + 0x00000006,0x00000239,0x000000a7,0x00050085,0x00000006,0x0000023a,0x00000238,0x00000239, + 0x00050081,0x00000006,0x0000023b,0x00000237,0x0000023a,0x0004003d,0x00000006,0x0000023c, + 0x0000009e,0x00050081,0x00000006,0x0000023d,0x0000023b,0x0000023c,0x0004003d,0x00000006, + 0x0000023e,0x00000227,0x00050085,0x00000006,0x0000023f,0x0000023d,0x0000023e,0x0003003e, + 0x0000002e,0x0000023f,0x0004003d,0x00000006,0x00000240,0x00000217,0x0004003d,0x00000006, + 0x00000241,0x0000008d,0x00050085,0x00000006,0x00000242,0x00000240,0x00000241,0x0004003d, + 0x00000006,0x00000243,0x00000217,0x0004003d,0x00000006,0x00000244,0x00000098,0x00050085, + 0x00000006,0x00000245,0x00000243,0x00000244,0x00050081,0x00000006,0x00000246,0x00000242, + 0x00000245,0x0004003d,0x00000006,0x00000247,0x00000217,0x0004003d,0x00000006,0x00000248, + 0x000000b3,0x00050085,0x00000006,0x00000249,0x00000247,0x00000248,0x00050081,0x00000006, + 0x0000024a,0x00000246,0x00000249,0x0004003d,0x00000006,0x0000024b,0x00000217,0x0004003d, + 0x00000006,0x0000024c,0x000000aa,0x00050085,0x00000006,0x0000024d,0x0000024b,0x0000024c, + 0x00050081,0x00000006,0x0000024e,0x0000024a,0x0000024d,0x0004003d,0x00000006,0x0000024f, + 0x000000a1,0x00050081,0x00000006,0x00000250,0x0000024e,0x0000024f,0x0004003d,0x00000006, + 0x00000251,0x00000227,0x00050085,0x00000006,0x00000252,0x00000250,0x00000251,0x0003003e, + 0x0000002f,0x00000252,0x0004003d,0x00000006,0x00000253,0x00000217,0x0004003d,0x00000006, + 0x00000254,0x00000091,0x00050085,0x00000006,0x00000255,0x00000253,0x00000254,0x0004003d, + 0x00000006,0x00000256,0x00000217,0x0004003d,0x00000006,0x00000257,0x0000009b,0x00050085, + 0x00000006,0x00000258,0x00000256,0x00000257,0x00050081,0x00000006,0x00000259,0x00000255, + 0x00000258,0x0004003d,0x00000006,0x0000025a,0x00000217,0x0004003d,0x00000006,0x0000025b, + 0x000000b6,0x00050085,0x00000006,0x0000025c,0x0000025a,0x0000025b,0x00050081,0x00000006, + 0x0000025d,0x00000259,0x0000025c,0x0004003d,0x00000006,0x0000025e,0x00000217,0x0004003d, + 0x00000006,0x0000025f,0x000000ad,0x00050085,0x00000006,0x00000260,0x0000025e,0x0000025f, + 0x00050081,0x00000006,0x00000261,0x0000025d,0x00000260,0x0004003d,0x00000006,0x00000262, + 0x000000a4,0x00050081,0x00000006,0x00000263,0x00000261,0x00000262,0x0004003d,0x00000006, + 0x00000264,0x00000227,0x00050085,0x00000006,0x00000265,0x00000263,0x00000264,0x0003003e, + 0x00000030,0x00000265,0x000100fd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/fsr_rcas_half_frag.h b/app/src/main/cpp/shaders/fsr_rcas_half_frag.h new file mode 100644 index 0000000000..c3d43fde32 --- /dev/null +++ b/app/src/main/cpp/shaders/fsr_rcas_half_frag.h @@ -0,0 +1,641 @@ + // 1116.2.0 + #pragma once +const uint32_t fsr_rcas_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000028c,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000269, + 0x00000286,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00070005,0x0000000a,0x78725041,0x5264654d,0x31467063, + 0x3b316628,0x00000000,0x00030005,0x00000009,0x00000078,0x00050005,0x0000000d,0x74615341, + 0x66283146,0x00003b31,0x00030005,0x0000000c,0x00000078,0x00070005,0x00000013,0x6e694d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000010,0x00000061,0x00030005, + 0x00000011,0x00000062,0x00030005,0x00000012,0x00000063,0x00070005,0x00000018,0x78614d41, + 0x28314633,0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000015,0x00000061,0x00030005, + 0x00000016,0x00000062,0x00030005,0x00000017,0x00000063,0x00070005,0x00000020,0x52727346, + 0x4c736163,0x4664616f,0x32697628,0x0000003b,0x00030005,0x0000001f,0x00000070,0x00080005, + 0x00000026,0x52727346,0x49736163,0x7475706e,0x31662846,0x3b31663b,0x003b3166,0x00030005, + 0x00000023,0x00000072,0x00030005,0x00000024,0x00000067,0x00030005,0x00000025,0x00000062, + 0x00090005,0x00000033,0x52727346,0x46736163,0x3b316628,0x663b3166,0x75763b31,0x75763b32, + 0x00003b34,0x00040005,0x0000002e,0x52786970,0x00000000,0x00040005,0x0000002f,0x47786970, + 0x00000000,0x00040005,0x00000030,0x42786970,0x00000000,0x00030005,0x00000031,0x00007069, + 0x00030005,0x00000032,0x006e6f63,0x00030005,0x0000004d,0x00007a73,0x00060005,0x00000051, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000062,0x00007073,0x00030005, + 0x00000067,0x00000062,0x00040005,0x0000006c,0x61726170,0x0000006d,0x00030005,0x0000006f, + 0x00000064,0x00040005,0x00000073,0x61726170,0x0000006d,0x00030005,0x00000076,0x00000065, + 0x00040005,0x00000077,0x61726170,0x0000006d,0x00030005,0x0000007b,0x00000066,0x00040005, + 0x0000007f,0x61726170,0x0000006d,0x00030005,0x00000082,0x00000068,0x00040005,0x00000086, + 0x61726170,0x0000006d,0x00030005,0x00000089,0x00005262,0x00030005,0x0000008d,0x00004762, + 0x00030005,0x00000091,0x00004262,0x00030005,0x00000095,0x00005264,0x00030005,0x00000098, + 0x00004764,0x00030005,0x0000009b,0x00004264,0x00030005,0x0000009e,0x00005265,0x00030005, + 0x000000a1,0x00004765,0x00030005,0x000000a4,0x00004265,0x00030005,0x000000a7,0x00005266, + 0x00030005,0x000000aa,0x00004766,0x00030005,0x000000ad,0x00004266,0x00030005,0x000000b0, + 0x00005268,0x00030005,0x000000b3,0x00004768,0x00030005,0x000000b6,0x00004268,0x00040005, + 0x000000b9,0x61726170,0x0000006d,0x00040005,0x000000bb,0x61726170,0x0000006d,0x00040005, + 0x000000bd,0x61726170,0x0000006d,0x00040005,0x000000c3,0x61726170,0x0000006d,0x00040005, + 0x000000c5,0x61726170,0x0000006d,0x00040005,0x000000c7,0x61726170,0x0000006d,0x00040005, + 0x000000cd,0x61726170,0x0000006d,0x00040005,0x000000cf,0x61726170,0x0000006d,0x00040005, + 0x000000d1,0x61726170,0x0000006d,0x00040005,0x000000d7,0x61726170,0x0000006d,0x00040005, + 0x000000d9,0x61726170,0x0000006d,0x00040005,0x000000db,0x61726170,0x0000006d,0x00040005, + 0x000000e1,0x61726170,0x0000006d,0x00040005,0x000000e3,0x61726170,0x0000006d,0x00040005, + 0x000000e5,0x61726170,0x0000006d,0x00030005,0x000000eb,0x00004c62,0x00030005,0x000000f4, + 0x00004c64,0x00030005,0x000000fc,0x00004c65,0x00030005,0x00000104,0x00004c66,0x00030005, + 0x0000010c,0x00004c68,0x00030005,0x00000114,0x00007a6e,0x00040005,0x00000125,0x61726170, + 0x0000006d,0x00040005,0x00000127,0x61726170,0x0000006d,0x00040005,0x00000129,0x61726170, + 0x0000006d,0x00040005,0x0000012c,0x61726170,0x0000006d,0x00040005,0x0000012d,0x61726170, + 0x0000006d,0x00040005,0x0000012f,0x61726170,0x0000006d,0x00040005,0x00000132,0x61726170, + 0x0000006d,0x00040005,0x00000134,0x61726170,0x0000006d,0x00040005,0x00000136,0x61726170, + 0x0000006d,0x00040005,0x00000139,0x61726170,0x0000006d,0x00040005,0x0000013a,0x61726170, + 0x0000006d,0x00040005,0x0000013c,0x61726170,0x0000006d,0x00040005,0x00000140,0x61726170, + 0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d,0x00040005,0x00000149,0x52346e6d, + 0x00000000,0x00040005,0x0000014a,0x61726170,0x0000006d,0x00040005,0x0000014c,0x61726170, + 0x0000006d,0x00040005,0x0000014e,0x61726170,0x0000006d,0x00040005,0x00000153,0x47346e6d, + 0x00000000,0x00040005,0x00000154,0x61726170,0x0000006d,0x00040005,0x00000156,0x61726170, + 0x0000006d,0x00040005,0x00000158,0x61726170,0x0000006d,0x00040005,0x0000015d,0x42346e6d, + 0x00000000,0x00040005,0x0000015e,0x61726170,0x0000006d,0x00040005,0x00000160,0x61726170, + 0x0000006d,0x00040005,0x00000162,0x61726170,0x0000006d,0x00040005,0x00000167,0x5234786d, + 0x00000000,0x00040005,0x00000168,0x61726170,0x0000006d,0x00040005,0x0000016a,0x61726170, + 0x0000006d,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x00000171,0x4734786d, + 0x00000000,0x00040005,0x00000172,0x61726170,0x0000006d,0x00040005,0x00000174,0x61726170, + 0x0000006d,0x00040005,0x00000176,0x61726170,0x0000006d,0x00040005,0x0000017b,0x4234786d, + 0x00000000,0x00040005,0x0000017c,0x61726170,0x0000006d,0x00040005,0x0000017e,0x61726170, + 0x0000006d,0x00040005,0x00000180,0x61726170,0x0000006d,0x00040005,0x00000187,0x6b616570, + 0x00000043,0x00040005,0x0000018a,0x4d6e6564,0x00526e69,0x00040005,0x0000018e,0x4d6e6564, + 0x00476e69,0x00040005,0x00000191,0x4d6e6564,0x00426e69,0x00040005,0x00000194,0x4d6e6564, + 0x00527861,0x00040005,0x0000019a,0x4d6e6564,0x00477861,0x00040005,0x000001a0,0x4d6e6564, + 0x00427861,0x00040005,0x000001a6,0x4d746968,0x00526e69,0x00040005,0x000001b4,0x4d746968, + 0x00476e69,0x00040005,0x000001c1,0x4d746968,0x00426e69,0x00040005,0x000001ce,0x4d6d756e, + 0x00527861,0x00040005,0x000001d5,0x4d6d756e,0x00477861,0x00040005,0x000001dc,0x4d6d756e, + 0x00427861,0x00040005,0x000001e3,0x4d746968,0x00527861,0x00040005,0x000001f0,0x4d746968, + 0x00477861,0x00040005,0x000001fc,0x4d746968,0x00427861,0x00040005,0x00000208,0x65626f6c, + 0x00000052,0x00040005,0x0000020d,0x65626f6c,0x00000047,0x00040005,0x00000212,0x65626f6c, + 0x00000042,0x00040005,0x00000217,0x65626f6c,0x00000000,0x00040005,0x00000219,0x61726170, + 0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d,0x00040005,0x0000021d,0x61726170, + 0x0000006d,0x00040005,0x00000227,0x4c706372,0x00000000,0x00040005,0x0000022b,0x61726170, + 0x0000006d,0x00030005,0x00000267,0x00007069,0x00060005,0x00000269,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00030005,0x0000026b,0x00004350,0x00040006,0x0000026b,0x00000000, + 0x0063646e,0x00040006,0x0000026b,0x00000001,0x006e6f63,0x00060006,0x0000026b,0x00000002, + 0x7074756f,0x69537475,0x0000657a,0x00030005,0x0000026d,0x00006370,0x00030005,0x00000274, + 0x00000063,0x00040005,0x00000275,0x61726170,0x0000006d,0x00040005,0x00000276,0x61726170, + 0x0000006d,0x00040005,0x00000277,0x61726170,0x0000006d,0x00040005,0x00000278,0x61726170, + 0x0000006d,0x00040005,0x0000027a,0x61726170,0x0000006d,0x00050005,0x00000286,0x4374756f, + 0x726f6c6f,0x00000000,0x00030047,0x00000020,0x00000000,0x00030047,0x00000023,0x00000000, + 0x00030047,0x00000024,0x00000000,0x00030047,0x00000025,0x00000000,0x00030047,0x0000002e, + 0x00000000,0x00030047,0x0000002f,0x00000000,0x00030047,0x00000030,0x00000000,0x00030047, + 0x00000051,0x00000000,0x00040047,0x00000051,0x00000021,0x00000000,0x00040047,0x00000051, + 0x00000022,0x00000000,0x00030047,0x00000052,0x00000000,0x00030047,0x00000056,0x00000000, + 0x00030047,0x0000005f,0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x0000006d, + 0x00000000,0x00030047,0x0000006e,0x00000000,0x00030047,0x0000006f,0x00000000,0x00030047, + 0x00000074,0x00000000,0x00030047,0x00000075,0x00000000,0x00030047,0x00000076,0x00000000, + 0x00030047,0x00000079,0x00000000,0x00030047,0x0000007a,0x00000000,0x00030047,0x0000007b, + 0x00000000,0x00030047,0x00000080,0x00000000,0x00030047,0x00000081,0x00000000,0x00030047, + 0x00000082,0x00000000,0x00030047,0x00000087,0x00000000,0x00030047,0x00000088,0x00000000, + 0x00030047,0x00000089,0x00000000,0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d, + 0x00000000,0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,0x00000000,0x00030047, + 0x00000094,0x00000000,0x00030047,0x00000095,0x00000000,0x00030047,0x00000097,0x00000000, + 0x00030047,0x00000098,0x00000000,0x00030047,0x0000009a,0x00000000,0x00030047,0x0000009b, + 0x00000000,0x00030047,0x0000009d,0x00000000,0x00030047,0x0000009e,0x00000000,0x00030047, + 0x000000a0,0x00000000,0x00030047,0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000, + 0x00030047,0x000000a4,0x00000000,0x00030047,0x000000a6,0x00000000,0x00030047,0x000000a7, + 0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000,0x00030047, + 0x000000ac,0x00000000,0x00030047,0x000000ad,0x00000000,0x00030047,0x000000af,0x00000000, + 0x00030047,0x000000b0,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3, + 0x00000000,0x00030047,0x000000b5,0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047, + 0x000000b8,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,0x000000ba,0x00000000, + 0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,0x00030047,0x000000bd, + 0x00000000,0x00030047,0x000000be,0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047, + 0x000000c4,0x00000000,0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c6,0x00000000, + 0x00030047,0x000000c7,0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000cd, + 0x00000000,0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047, + 0x000000d0,0x00000000,0x00030047,0x000000d1,0x00000000,0x00030047,0x000000d2,0x00000000, + 0x00030047,0x000000d7,0x00000000,0x00030047,0x000000d8,0x00000000,0x00030047,0x000000d9, + 0x00000000,0x00030047,0x000000da,0x00000000,0x00030047,0x000000db,0x00000000,0x00030047, + 0x000000dc,0x00000000,0x00030047,0x000000e1,0x00000000,0x00030047,0x000000e2,0x00000000, + 0x00030047,0x000000e3,0x00000000,0x00030047,0x000000e4,0x00000000,0x00030047,0x000000e5, + 0x00000000,0x00030047,0x000000e6,0x00000000,0x00030047,0x000000eb,0x00000000,0x00030047, + 0x000000ec,0x00000000,0x00030047,0x000000ee,0x00000000,0x00030047,0x000000ef,0x00000000, + 0x00030047,0x000000f0,0x00000000,0x00030047,0x000000f1,0x00000000,0x00030047,0x000000f2, + 0x00000000,0x00030047,0x000000f3,0x00000000,0x00030047,0x000000f4,0x00000000,0x00030047, + 0x000000f5,0x00000000,0x00030047,0x000000f6,0x00000000,0x00030047,0x000000f7,0x00000000, + 0x00030047,0x000000f8,0x00000000,0x00030047,0x000000f9,0x00000000,0x00030047,0x000000fa, + 0x00000000,0x00030047,0x000000fb,0x00000000,0x00030047,0x000000fc,0x00000000,0x00030047, + 0x000000fd,0x00000000,0x00030047,0x000000fe,0x00000000,0x00030047,0x000000ff,0x00000000, + 0x00030047,0x00000100,0x00000000,0x00030047,0x00000101,0x00000000,0x00030047,0x00000102, + 0x00000000,0x00030047,0x00000103,0x00000000,0x00030047,0x00000104,0x00000000,0x00030047, + 0x00000105,0x00000000,0x00030047,0x00000106,0x00000000,0x00030047,0x00000107,0x00000000, + 0x00030047,0x00000108,0x00000000,0x00030047,0x00000109,0x00000000,0x00030047,0x0000010a, + 0x00000000,0x00030047,0x0000010b,0x00000000,0x00030047,0x0000010c,0x00000000,0x00030047, + 0x0000010d,0x00000000,0x00030047,0x0000010e,0x00000000,0x00030047,0x0000010f,0x00000000, + 0x00030047,0x00000110,0x00000000,0x00030047,0x00000111,0x00000000,0x00030047,0x00000112, + 0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114,0x00000000,0x00030047, + 0x00000116,0x00000000,0x00030047,0x00000117,0x00000000,0x00030047,0x00000118,0x00000000, + 0x00030047,0x00000119,0x00000000,0x00030047,0x0000011a,0x00000000,0x00030047,0x0000011b, + 0x00000000,0x00030047,0x0000011c,0x00000000,0x00030047,0x0000011d,0x00000000,0x00030047, + 0x0000011e,0x00000000,0x00030047,0x0000011f,0x00000000,0x00030047,0x00000120,0x00000000, + 0x00030047,0x00000121,0x00000000,0x00030047,0x00000122,0x00000000,0x00030047,0x00000123, + 0x00000000,0x00030047,0x00000124,0x00000000,0x00030047,0x00000126,0x00000000,0x00030047, + 0x00000128,0x00000000,0x00030047,0x0000012a,0x00000000,0x00030047,0x0000012e,0x00000000, + 0x00030047,0x00000130,0x00000000,0x00030047,0x00000133,0x00000000,0x00030047,0x00000135, + 0x00000000,0x00030047,0x00000137,0x00000000,0x00030047,0x0000013b,0x00000000,0x00030047, + 0x0000013d,0x00000000,0x00030047,0x00000146,0x00000000,0x00030047,0x00000147,0x00000000, + 0x00030047,0x00000148,0x00000000,0x00030047,0x00000149,0x00000000,0x00030047,0x0000014b, + 0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014f,0x00000000,0x00030047, + 0x00000151,0x00000000,0x00030047,0x00000153,0x00000000,0x00030047,0x00000155,0x00000000, + 0x00030047,0x00000157,0x00000000,0x00030047,0x00000159,0x00000000,0x00030047,0x0000015b, + 0x00000000,0x00030047,0x0000015d,0x00000000,0x00030047,0x0000015f,0x00000000,0x00030047, + 0x00000161,0x00000000,0x00030047,0x00000163,0x00000000,0x00030047,0x00000165,0x00000000, + 0x00030047,0x00000167,0x00000000,0x00030047,0x00000169,0x00000000,0x00030047,0x0000016b, + 0x00000000,0x00030047,0x0000016d,0x00000000,0x00030047,0x0000016f,0x00000000,0x00030047, + 0x00000171,0x00000000,0x00030047,0x00000173,0x00000000,0x00030047,0x00000175,0x00000000, + 0x00030047,0x00000177,0x00000000,0x00030047,0x00000179,0x00000000,0x00030047,0x0000017b, + 0x00000000,0x00030047,0x0000017d,0x00000000,0x00030047,0x0000017f,0x00000000,0x00030047, + 0x00000181,0x00000000,0x00030047,0x00000183,0x00000000,0x00030047,0x00000187,0x00000000, + 0x00030047,0x0000018a,0x00000000,0x00030047,0x0000018c,0x00000000,0x00030047,0x0000018d, + 0x00000000,0x00030047,0x0000018e,0x00000000,0x00030047,0x0000018f,0x00000000,0x00030047, + 0x00000190,0x00000000,0x00030047,0x00000191,0x00000000,0x00030047,0x00000192,0x00000000, + 0x00030047,0x00000193,0x00000000,0x00030047,0x00000194,0x00000000,0x00030047,0x00000195, + 0x00000000,0x00030047,0x00000196,0x00000000,0x00030047,0x00000198,0x00000000,0x00030047, + 0x00000199,0x00000000,0x00030047,0x0000019a,0x00000000,0x00030047,0x0000019b,0x00000000, + 0x00030047,0x0000019c,0x00000000,0x00030047,0x0000019e,0x00000000,0x00030047,0x0000019f, + 0x00000000,0x00030047,0x000001a0,0x00000000,0x00030047,0x000001a1,0x00000000,0x00030047, + 0x000001a2,0x00000000,0x00030047,0x000001a4,0x00000000,0x00030047,0x000001a5,0x00000000, + 0x00030047,0x000001a6,0x00000000,0x00030047,0x000001a7,0x00000000,0x00030047,0x000001aa, + 0x00000000,0x00030047,0x000001ad,0x00000000,0x00030047,0x000001ae,0x00000000,0x00030047, + 0x000001af,0x00000000,0x00030047,0x000001b0,0x00000000,0x00030047,0x000001b1,0x00000000, + 0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4,0x00000000,0x00030047,0x000001b5, + 0x00000000,0x00030047,0x000001b7,0x00000000,0x00030047,0x000001ba,0x00000000,0x00030047, + 0x000001bb,0x00000000,0x00030047,0x000001bc,0x00000000,0x00030047,0x000001bd,0x00000000, + 0x00030047,0x000001be,0x00000000,0x00030047,0x000001c0,0x00000000,0x00030047,0x000001c1, + 0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047,0x000001c4,0x00000000,0x00030047, + 0x000001c7,0x00000000,0x00030047,0x000001c8,0x00000000,0x00030047,0x000001c9,0x00000000, + 0x00030047,0x000001ca,0x00000000,0x00030047,0x000001cb,0x00000000,0x00030047,0x000001cd, + 0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047,0x000001d0,0x00000000,0x00030047, + 0x000001d1,0x00000000,0x00030047,0x000001d2,0x00000000,0x00030047,0x000001d3,0x00000000, + 0x00030047,0x000001d4,0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d7, + 0x00000000,0x00030047,0x000001d8,0x00000000,0x00030047,0x000001d9,0x00000000,0x00030047, + 0x000001da,0x00000000,0x00030047,0x000001db,0x00000000,0x00030047,0x000001dc,0x00000000, + 0x00030047,0x000001de,0x00000000,0x00030047,0x000001df,0x00000000,0x00030047,0x000001e0, + 0x00000000,0x00030047,0x000001e1,0x00000000,0x00030047,0x000001e2,0x00000000,0x00030047, + 0x000001e3,0x00000000,0x00030047,0x000001e4,0x00000000,0x00030047,0x000001e5,0x00000000, + 0x00030047,0x000001e8,0x00000000,0x00030047,0x000001eb,0x00000000,0x00030047,0x000001ec, + 0x00000000,0x00030047,0x000001ed,0x00000000,0x00030047,0x000001ef,0x00000000,0x00030047, + 0x000001f0,0x00000000,0x00030047,0x000001f1,0x00000000,0x00030047,0x000001f2,0x00000000, + 0x00030047,0x000001f4,0x00000000,0x00030047,0x000001f7,0x00000000,0x00030047,0x000001f8, + 0x00000000,0x00030047,0x000001f9,0x00000000,0x00030047,0x000001fb,0x00000000,0x00030047, + 0x000001fc,0x00000000,0x00030047,0x000001fd,0x00000000,0x00030047,0x000001fe,0x00000000, + 0x00030047,0x00000200,0x00000000,0x00030047,0x00000203,0x00000000,0x00030047,0x00000204, + 0x00000000,0x00030047,0x00000205,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047, + 0x00000208,0x00000000,0x00030047,0x00000209,0x00000000,0x00030047,0x0000020a,0x00000000, + 0x00030047,0x0000020b,0x00000000,0x00030047,0x0000020c,0x00000000,0x00030047,0x0000020d, + 0x00000000,0x00030047,0x0000020e,0x00000000,0x00030047,0x0000020f,0x00000000,0x00030047, + 0x00000210,0x00000000,0x00030047,0x00000211,0x00000000,0x00030047,0x00000212,0x00000000, + 0x00030047,0x00000213,0x00000000,0x00030047,0x00000214,0x00000000,0x00030047,0x00000215, + 0x00000000,0x00030047,0x00000216,0x00000000,0x00030047,0x00000217,0x00000000,0x00030047, + 0x0000021a,0x00000000,0x00030047,0x0000021c,0x00000000,0x00030047,0x0000021e,0x00000000, + 0x00030047,0x00000227,0x00000000,0x00030047,0x00000228,0x00000000,0x00030047,0x00000229, + 0x00000000,0x00030047,0x0000022a,0x00000000,0x00030047,0x0000022d,0x00000000,0x00030047, + 0x0000022e,0x00000000,0x00030047,0x0000022f,0x00000000,0x00030047,0x00000230,0x00000000, + 0x00030047,0x00000231,0x00000000,0x00030047,0x00000232,0x00000000,0x00030047,0x00000233, + 0x00000000,0x00030047,0x00000234,0x00000000,0x00030047,0x00000235,0x00000000,0x00030047, + 0x00000236,0x00000000,0x00030047,0x00000237,0x00000000,0x00030047,0x00000238,0x00000000, + 0x00030047,0x00000239,0x00000000,0x00030047,0x0000023a,0x00000000,0x00030047,0x0000023b, + 0x00000000,0x00030047,0x0000023c,0x00000000,0x00030047,0x0000023d,0x00000000,0x00030047, + 0x0000023e,0x00000000,0x00030047,0x0000023f,0x00000000,0x00030047,0x00000240,0x00000000, + 0x00030047,0x00000241,0x00000000,0x00030047,0x00000242,0x00000000,0x00030047,0x00000243, + 0x00000000,0x00030047,0x00000244,0x00000000,0x00030047,0x00000245,0x00000000,0x00030047, + 0x00000246,0x00000000,0x00030047,0x00000247,0x00000000,0x00030047,0x00000248,0x00000000, + 0x00030047,0x00000249,0x00000000,0x00030047,0x0000024a,0x00000000,0x00030047,0x0000024b, + 0x00000000,0x00030047,0x0000024c,0x00000000,0x00030047,0x0000024d,0x00000000,0x00030047, + 0x0000024e,0x00000000,0x00030047,0x0000024f,0x00000000,0x00030047,0x00000250,0x00000000, + 0x00030047,0x00000251,0x00000000,0x00030047,0x00000252,0x00000000,0x00030047,0x00000253, + 0x00000000,0x00030047,0x00000254,0x00000000,0x00030047,0x00000255,0x00000000,0x00030047, + 0x00000256,0x00000000,0x00030047,0x00000257,0x00000000,0x00030047,0x00000258,0x00000000, + 0x00030047,0x00000259,0x00000000,0x00030047,0x0000025a,0x00000000,0x00030047,0x0000025b, + 0x00000000,0x00030047,0x0000025c,0x00000000,0x00030047,0x0000025d,0x00000000,0x00030047, + 0x0000025e,0x00000000,0x00030047,0x0000025f,0x00000000,0x00030047,0x00000260,0x00000000, + 0x00030047,0x00000261,0x00000000,0x00030047,0x00000262,0x00000000,0x00030047,0x00000263, + 0x00000000,0x00030047,0x00000264,0x00000000,0x00030047,0x00000265,0x00000000,0x00040047, + 0x00000269,0x0000001e,0x00000000,0x00030047,0x0000026b,0x00000002,0x00050048,0x0000026b, + 0x00000000,0x00000023,0x00000000,0x00050048,0x0000026b,0x00000001,0x00000023,0x00000010, + 0x00050048,0x0000026b,0x00000002,0x00000023,0x00000020,0x00030047,0x00000274,0x00000000, + 0x00030047,0x00000275,0x00000000,0x00030047,0x00000276,0x00000000,0x00030047,0x00000277, + 0x00000000,0x00030047,0x00000286,0x00000000,0x00040047,0x00000286,0x0000001e,0x00000000, + 0x00030047,0x00000287,0x00000000,0x00030047,0x00000288,0x00000000,0x00030047,0x00000289, + 0x00000000,0x00030047,0x0000028a,0x00000000,0x00030047,0x0000028b,0x00000000,0x00020013, + 0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040020, + 0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007,0x00060021, + 0x0000000f,0x00000006,0x00000007,0x00000007,0x00000007,0x00040015,0x0000001a,0x00000020, + 0x00000001,0x00040017,0x0000001b,0x0000001a,0x00000002,0x00040020,0x0000001c,0x00000007, + 0x0000001b,0x00040017,0x0000001d,0x00000006,0x00000004,0x00040021,0x0000001e,0x0000001d, + 0x0000001c,0x00060021,0x00000022,0x00000002,0x00000007,0x00000007,0x00000007,0x00040015, + 0x00000028,0x00000020,0x00000000,0x00040017,0x00000029,0x00000028,0x00000002,0x00040020, + 0x0000002a,0x00000007,0x00000029,0x00040017,0x0000002b,0x00000028,0x00000004,0x00040020, + 0x0000002c,0x00000007,0x0000002b,0x00080021,0x0000002d,0x00000002,0x00000007,0x00000007, + 0x00000007,0x0000002a,0x0000002c,0x0004002b,0x00000006,0x00000035,0x3f800000,0x0004002b, + 0x00000006,0x0000003b,0x00000000,0x00090019,0x0000004e,0x00000006,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000004f,0x0000004e,0x00040020, + 0x00000050,0x00000000,0x0000004f,0x0004003b,0x00000050,0x00000051,0x00000000,0x0004002b, + 0x0000001a,0x00000053,0x00000000,0x0005002c,0x0000001b,0x00000058,0x00000053,0x00000053, + 0x0004002b,0x0000001a,0x0000005a,0x00000001,0x0005002c,0x0000001b,0x0000005b,0x0000005a, + 0x0000005a,0x00040017,0x00000065,0x00000006,0x00000003,0x00040020,0x00000066,0x00000007, + 0x00000065,0x0004002b,0x0000001a,0x00000069,0xffffffff,0x0005002c,0x0000001b,0x0000006a, + 0x00000053,0x00000069,0x0005002c,0x0000001b,0x00000071,0x00000069,0x00000053,0x0005002c, + 0x0000001b,0x0000007d,0x0000005a,0x00000053,0x0005002c,0x0000001b,0x00000084,0x00000053, + 0x0000005a,0x0004002b,0x00000028,0x0000008a,0x00000000,0x0004002b,0x00000028,0x0000008e, + 0x00000001,0x0004002b,0x00000028,0x00000092,0x00000002,0x0004002b,0x00000006,0x000000ed, + 0x3f000000,0x0004002b,0x00000006,0x00000115,0x3e800000,0x0004002b,0x00000006,0x00000145, + 0xbf000000,0x00040017,0x00000185,0x00000006,0x00000002,0x00040020,0x00000186,0x00000007, + 0x00000185,0x0004002b,0x00000006,0x00000188,0xc0800000,0x0005002c,0x00000185,0x00000189, + 0x00000035,0x00000188,0x0004002b,0x00000006,0x0000018b,0x40800000,0x00020014,0x000001a8, + 0x0004002b,0x00000006,0x000001e6,0x358637bd,0x0004002b,0x00000006,0x00000218,0xbe400000, + 0x00040020,0x00000222,0x00000007,0x00000028,0x00040020,0x00000268,0x00000001,0x00000185, + 0x0004003b,0x00000268,0x00000269,0x00000001,0x0005001e,0x0000026b,0x0000001d,0x0000002b, + 0x00000185,0x00040020,0x0000026c,0x00000009,0x0000026b,0x0004003b,0x0000026c,0x0000026d, + 0x00000009,0x0004002b,0x0000001a,0x0000026e,0x00000002,0x00040020,0x0000026f,0x00000009, + 0x00000185,0x00040020,0x0000027b,0x00000009,0x0000002b,0x00040020,0x00000285,0x00000003, + 0x0000001d,0x0004003b,0x00000285,0x00000286,0x00000003,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000002a,0x00000267,0x00000007, + 0x0004003b,0x00000066,0x00000274,0x00000007,0x0004003b,0x00000007,0x00000275,0x00000007, + 0x0004003b,0x00000007,0x00000276,0x00000007,0x0004003b,0x00000007,0x00000277,0x00000007, + 0x0004003b,0x0000002a,0x00000278,0x00000007,0x0004003b,0x0000002c,0x0000027a,0x00000007, + 0x0004003d,0x00000185,0x0000026a,0x00000269,0x00050041,0x0000026f,0x00000270,0x0000026d, + 0x0000026e,0x0004003d,0x00000185,0x00000271,0x00000270,0x00050085,0x00000185,0x00000272, + 0x0000026a,0x00000271,0x0004006d,0x00000029,0x00000273,0x00000272,0x0003003e,0x00000267, + 0x00000273,0x0004003d,0x00000029,0x00000279,0x00000267,0x0003003e,0x00000278,0x00000279, + 0x00050041,0x0000027b,0x0000027c,0x0000026d,0x0000005a,0x0004003d,0x0000002b,0x0000027d, + 0x0000027c,0x0003003e,0x0000027a,0x0000027d,0x00090039,0x00000002,0x0000027e,0x00000033, + 0x00000275,0x00000276,0x00000277,0x00000278,0x0000027a,0x0004003d,0x00000006,0x0000027f, + 0x00000275,0x00050041,0x00000007,0x00000280,0x00000274,0x0000008a,0x0003003e,0x00000280, + 0x0000027f,0x0004003d,0x00000006,0x00000281,0x00000276,0x00050041,0x00000007,0x00000282, + 0x00000274,0x0000008e,0x0003003e,0x00000282,0x00000281,0x0004003d,0x00000006,0x00000283, + 0x00000277,0x00050041,0x00000007,0x00000284,0x00000274,0x00000092,0x0003003e,0x00000284, + 0x00000283,0x0004003d,0x00000065,0x00000287,0x00000274,0x00050051,0x00000006,0x00000288, + 0x00000287,0x00000000,0x00050051,0x00000006,0x00000289,0x00000287,0x00000001,0x00050051, + 0x00000006,0x0000028a,0x00000287,0x00000002,0x00070050,0x0000001d,0x0000028b,0x00000288, + 0x00000289,0x0000028a,0x00000035,0x0003003e,0x00000286,0x0000028b,0x000100fd,0x00010038, + 0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,0x00030037,0x00000007,0x00000009, + 0x000200f8,0x0000000b,0x0004003d,0x00000006,0x00000036,0x00000009,0x00050088,0x00000006, + 0x00000037,0x00000035,0x00000036,0x000200fe,0x00000037,0x00010038,0x00050036,0x00000006, + 0x0000000d,0x00000000,0x00000008,0x00030037,0x00000007,0x0000000c,0x000200f8,0x0000000e, + 0x0004003d,0x00000006,0x0000003a,0x0000000c,0x0008000c,0x00000006,0x0000003c,0x00000001, + 0x0000002b,0x0000003a,0x0000003b,0x00000035,0x000200fe,0x0000003c,0x00010038,0x00050036, + 0x00000006,0x00000013,0x00000000,0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037, + 0x00000007,0x00000011,0x00030037,0x00000007,0x00000012,0x000200f8,0x00000014,0x0004003d, + 0x00000006,0x0000003f,0x00000010,0x0004003d,0x00000006,0x00000040,0x00000011,0x0004003d, + 0x00000006,0x00000041,0x00000012,0x0007000c,0x00000006,0x00000042,0x00000001,0x00000025, + 0x00000040,0x00000041,0x0007000c,0x00000006,0x00000043,0x00000001,0x00000025,0x0000003f, + 0x00000042,0x000200fe,0x00000043,0x00010038,0x00050036,0x00000006,0x00000018,0x00000000, + 0x0000000f,0x00030037,0x00000007,0x00000015,0x00030037,0x00000007,0x00000016,0x00030037, + 0x00000007,0x00000017,0x000200f8,0x00000019,0x0004003d,0x00000006,0x00000046,0x00000015, + 0x0004003d,0x00000006,0x00000047,0x00000016,0x0004003d,0x00000006,0x00000048,0x00000017, + 0x0007000c,0x00000006,0x00000049,0x00000001,0x00000028,0x00000047,0x00000048,0x0007000c, + 0x00000006,0x0000004a,0x00000001,0x00000028,0x00000046,0x00000049,0x000200fe,0x0000004a, + 0x00010038,0x00050036,0x0000001d,0x00000020,0x00000000,0x0000001e,0x00030037,0x0000001c, + 0x0000001f,0x000200f8,0x00000021,0x0004003b,0x0000001c,0x0000004d,0x00000007,0x0004003d, + 0x0000004f,0x00000052,0x00000051,0x00040064,0x0000004e,0x00000054,0x00000052,0x00050067, + 0x0000001b,0x00000055,0x00000054,0x00000053,0x0003003e,0x0000004d,0x00000055,0x0004003d, + 0x0000004f,0x00000056,0x00000051,0x0004003d,0x0000001b,0x00000057,0x0000001f,0x0004003d, + 0x0000001b,0x00000059,0x0000004d,0x00050082,0x0000001b,0x0000005c,0x00000059,0x0000005b, + 0x0008000c,0x0000001b,0x0000005d,0x00000001,0x0000002d,0x00000057,0x00000058,0x0000005c, + 0x00040064,0x0000004e,0x0000005e,0x00000056,0x0007005f,0x0000001d,0x0000005f,0x0000005e, + 0x0000005d,0x00000002,0x00000053,0x000200fe,0x0000005f,0x00010038,0x00050036,0x00000002, + 0x00000026,0x00000000,0x00000022,0x00030037,0x00000007,0x00000023,0x00030037,0x00000007, + 0x00000024,0x00030037,0x00000007,0x00000025,0x000200f8,0x00000027,0x000100fd,0x00010038, + 0x00050036,0x00000002,0x00000033,0x00000000,0x0000002d,0x00030037,0x00000007,0x0000002e, + 0x00030037,0x00000007,0x0000002f,0x00030037,0x00000007,0x00000030,0x00030037,0x0000002a, + 0x00000031,0x00030037,0x0000002c,0x00000032,0x000200f8,0x00000034,0x0004003b,0x0000001c, + 0x00000062,0x00000007,0x0004003b,0x00000066,0x00000067,0x00000007,0x0004003b,0x0000001c, + 0x0000006c,0x00000007,0x0004003b,0x00000066,0x0000006f,0x00000007,0x0004003b,0x0000001c, + 0x00000073,0x00000007,0x0004003b,0x00000066,0x00000076,0x00000007,0x0004003b,0x0000001c, + 0x00000077,0x00000007,0x0004003b,0x00000066,0x0000007b,0x00000007,0x0004003b,0x0000001c, + 0x0000007f,0x00000007,0x0004003b,0x00000066,0x00000082,0x00000007,0x0004003b,0x0000001c, + 0x00000086,0x00000007,0x0004003b,0x00000007,0x00000089,0x00000007,0x0004003b,0x00000007, + 0x0000008d,0x00000007,0x0004003b,0x00000007,0x00000091,0x00000007,0x0004003b,0x00000007, + 0x00000095,0x00000007,0x0004003b,0x00000007,0x00000098,0x00000007,0x0004003b,0x00000007, + 0x0000009b,0x00000007,0x0004003b,0x00000007,0x0000009e,0x00000007,0x0004003b,0x00000007, + 0x000000a1,0x00000007,0x0004003b,0x00000007,0x000000a4,0x00000007,0x0004003b,0x00000007, + 0x000000a7,0x00000007,0x0004003b,0x00000007,0x000000aa,0x00000007,0x0004003b,0x00000007, + 0x000000ad,0x00000007,0x0004003b,0x00000007,0x000000b0,0x00000007,0x0004003b,0x00000007, + 0x000000b3,0x00000007,0x0004003b,0x00000007,0x000000b6,0x00000007,0x0004003b,0x00000007, + 0x000000b9,0x00000007,0x0004003b,0x00000007,0x000000bb,0x00000007,0x0004003b,0x00000007, + 0x000000bd,0x00000007,0x0004003b,0x00000007,0x000000c3,0x00000007,0x0004003b,0x00000007, + 0x000000c5,0x00000007,0x0004003b,0x00000007,0x000000c7,0x00000007,0x0004003b,0x00000007, + 0x000000cd,0x00000007,0x0004003b,0x00000007,0x000000cf,0x00000007,0x0004003b,0x00000007, + 0x000000d1,0x00000007,0x0004003b,0x00000007,0x000000d7,0x00000007,0x0004003b,0x00000007, + 0x000000d9,0x00000007,0x0004003b,0x00000007,0x000000db,0x00000007,0x0004003b,0x00000007, + 0x000000e1,0x00000007,0x0004003b,0x00000007,0x000000e3,0x00000007,0x0004003b,0x00000007, + 0x000000e5,0x00000007,0x0004003b,0x00000007,0x000000eb,0x00000007,0x0004003b,0x00000007, + 0x000000f4,0x00000007,0x0004003b,0x00000007,0x000000fc,0x00000007,0x0004003b,0x00000007, + 0x00000104,0x00000007,0x0004003b,0x00000007,0x0000010c,0x00000007,0x0004003b,0x00000007, + 0x00000114,0x00000007,0x0004003b,0x00000007,0x00000125,0x00000007,0x0004003b,0x00000007, + 0x00000127,0x00000007,0x0004003b,0x00000007,0x00000129,0x00000007,0x0004003b,0x00000007, + 0x0000012c,0x00000007,0x0004003b,0x00000007,0x0000012d,0x00000007,0x0004003b,0x00000007, + 0x0000012f,0x00000007,0x0004003b,0x00000007,0x00000132,0x00000007,0x0004003b,0x00000007, + 0x00000134,0x00000007,0x0004003b,0x00000007,0x00000136,0x00000007,0x0004003b,0x00000007, + 0x00000139,0x00000007,0x0004003b,0x00000007,0x0000013a,0x00000007,0x0004003b,0x00000007, + 0x0000013c,0x00000007,0x0004003b,0x00000007,0x00000140,0x00000007,0x0004003b,0x00000007, + 0x00000143,0x00000007,0x0004003b,0x00000007,0x00000149,0x00000007,0x0004003b,0x00000007, + 0x0000014a,0x00000007,0x0004003b,0x00000007,0x0000014c,0x00000007,0x0004003b,0x00000007, + 0x0000014e,0x00000007,0x0004003b,0x00000007,0x00000153,0x00000007,0x0004003b,0x00000007, + 0x00000154,0x00000007,0x0004003b,0x00000007,0x00000156,0x00000007,0x0004003b,0x00000007, + 0x00000158,0x00000007,0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b,0x00000007, + 0x0000015e,0x00000007,0x0004003b,0x00000007,0x00000160,0x00000007,0x0004003b,0x00000007, + 0x00000162,0x00000007,0x0004003b,0x00000007,0x00000167,0x00000007,0x0004003b,0x00000007, + 0x00000168,0x00000007,0x0004003b,0x00000007,0x0000016a,0x00000007,0x0004003b,0x00000007, + 0x0000016c,0x00000007,0x0004003b,0x00000007,0x00000171,0x00000007,0x0004003b,0x00000007, + 0x00000172,0x00000007,0x0004003b,0x00000007,0x00000174,0x00000007,0x0004003b,0x00000007, + 0x00000176,0x00000007,0x0004003b,0x00000007,0x0000017b,0x00000007,0x0004003b,0x00000007, + 0x0000017c,0x00000007,0x0004003b,0x00000007,0x0000017e,0x00000007,0x0004003b,0x00000007, + 0x00000180,0x00000007,0x0004003b,0x00000186,0x00000187,0x00000007,0x0004003b,0x00000007, + 0x0000018a,0x00000007,0x0004003b,0x00000007,0x0000018e,0x00000007,0x0004003b,0x00000007, + 0x00000191,0x00000007,0x0004003b,0x00000007,0x00000194,0x00000007,0x0004003b,0x00000007, + 0x0000019a,0x00000007,0x0004003b,0x00000007,0x000001a0,0x00000007,0x0004003b,0x00000007, + 0x000001a6,0x00000007,0x0004003b,0x00000007,0x000001aa,0x00000007,0x0004003b,0x00000007, + 0x000001b4,0x00000007,0x0004003b,0x00000007,0x000001b7,0x00000007,0x0004003b,0x00000007, + 0x000001c1,0x00000007,0x0004003b,0x00000007,0x000001c4,0x00000007,0x0004003b,0x00000007, + 0x000001ce,0x00000007,0x0004003b,0x00000007,0x000001d5,0x00000007,0x0004003b,0x00000007, + 0x000001dc,0x00000007,0x0004003b,0x00000007,0x000001e3,0x00000007,0x0004003b,0x00000007, + 0x000001e8,0x00000007,0x0004003b,0x00000007,0x000001f0,0x00000007,0x0004003b,0x00000007, + 0x000001f4,0x00000007,0x0004003b,0x00000007,0x000001fc,0x00000007,0x0004003b,0x00000007, + 0x00000200,0x00000007,0x0004003b,0x00000007,0x00000208,0x00000007,0x0004003b,0x00000007, + 0x0000020d,0x00000007,0x0004003b,0x00000007,0x00000212,0x00000007,0x0004003b,0x00000007, + 0x00000217,0x00000007,0x0004003b,0x00000007,0x00000219,0x00000007,0x0004003b,0x00000007, + 0x0000021b,0x00000007,0x0004003b,0x00000007,0x0000021d,0x00000007,0x0004003b,0x00000007, + 0x00000227,0x00000007,0x0004003b,0x00000007,0x0000022b,0x00000007,0x0004003d,0x00000029, + 0x00000063,0x00000031,0x0004007c,0x0000001b,0x00000064,0x00000063,0x0003003e,0x00000062, + 0x00000064,0x0004003d,0x0000001b,0x00000068,0x00000062,0x00050080,0x0000001b,0x0000006b, + 0x00000068,0x0000006a,0x0003003e,0x0000006c,0x0000006b,0x00050039,0x0000001d,0x0000006d, + 0x00000020,0x0000006c,0x0008004f,0x00000065,0x0000006e,0x0000006d,0x0000006d,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000067,0x0000006e,0x0004003d,0x0000001b,0x00000070, + 0x00000062,0x00050080,0x0000001b,0x00000072,0x00000070,0x00000071,0x0003003e,0x00000073, + 0x00000072,0x00050039,0x0000001d,0x00000074,0x00000020,0x00000073,0x0008004f,0x00000065, + 0x00000075,0x00000074,0x00000074,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000006f, + 0x00000075,0x0004003d,0x0000001b,0x00000078,0x00000062,0x0003003e,0x00000077,0x00000078, + 0x00050039,0x0000001d,0x00000079,0x00000020,0x00000077,0x0008004f,0x00000065,0x0000007a, + 0x00000079,0x00000079,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000076,0x0000007a, + 0x0004003d,0x0000001b,0x0000007c,0x00000062,0x00050080,0x0000001b,0x0000007e,0x0000007c, + 0x0000007d,0x0003003e,0x0000007f,0x0000007e,0x00050039,0x0000001d,0x00000080,0x00000020, + 0x0000007f,0x0008004f,0x00000065,0x00000081,0x00000080,0x00000080,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x0000007b,0x00000081,0x0004003d,0x0000001b,0x00000083,0x00000062, + 0x00050080,0x0000001b,0x00000085,0x00000083,0x00000084,0x0003003e,0x00000086,0x00000085, + 0x00050039,0x0000001d,0x00000087,0x00000020,0x00000086,0x0008004f,0x00000065,0x00000088, + 0x00000087,0x00000087,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000082,0x00000088, + 0x00050041,0x00000007,0x0000008b,0x00000067,0x0000008a,0x0004003d,0x00000006,0x0000008c, + 0x0000008b,0x0003003e,0x00000089,0x0000008c,0x00050041,0x00000007,0x0000008f,0x00000067, + 0x0000008e,0x0004003d,0x00000006,0x00000090,0x0000008f,0x0003003e,0x0000008d,0x00000090, + 0x00050041,0x00000007,0x00000093,0x00000067,0x00000092,0x0004003d,0x00000006,0x00000094, + 0x00000093,0x0003003e,0x00000091,0x00000094,0x00050041,0x00000007,0x00000096,0x0000006f, + 0x0000008a,0x0004003d,0x00000006,0x00000097,0x00000096,0x0003003e,0x00000095,0x00000097, + 0x00050041,0x00000007,0x00000099,0x0000006f,0x0000008e,0x0004003d,0x00000006,0x0000009a, + 0x00000099,0x0003003e,0x00000098,0x0000009a,0x00050041,0x00000007,0x0000009c,0x0000006f, + 0x00000092,0x0004003d,0x00000006,0x0000009d,0x0000009c,0x0003003e,0x0000009b,0x0000009d, + 0x00050041,0x00000007,0x0000009f,0x00000076,0x0000008a,0x0004003d,0x00000006,0x000000a0, + 0x0000009f,0x0003003e,0x0000009e,0x000000a0,0x00050041,0x00000007,0x000000a2,0x00000076, + 0x0000008e,0x0004003d,0x00000006,0x000000a3,0x000000a2,0x0003003e,0x000000a1,0x000000a3, + 0x00050041,0x00000007,0x000000a5,0x00000076,0x00000092,0x0004003d,0x00000006,0x000000a6, + 0x000000a5,0x0003003e,0x000000a4,0x000000a6,0x00050041,0x00000007,0x000000a8,0x0000007b, + 0x0000008a,0x0004003d,0x00000006,0x000000a9,0x000000a8,0x0003003e,0x000000a7,0x000000a9, + 0x00050041,0x00000007,0x000000ab,0x0000007b,0x0000008e,0x0004003d,0x00000006,0x000000ac, + 0x000000ab,0x0003003e,0x000000aa,0x000000ac,0x00050041,0x00000007,0x000000ae,0x0000007b, + 0x00000092,0x0004003d,0x00000006,0x000000af,0x000000ae,0x0003003e,0x000000ad,0x000000af, + 0x00050041,0x00000007,0x000000b1,0x00000082,0x0000008a,0x0004003d,0x00000006,0x000000b2, + 0x000000b1,0x0003003e,0x000000b0,0x000000b2,0x00050041,0x00000007,0x000000b4,0x00000082, + 0x0000008e,0x0004003d,0x00000006,0x000000b5,0x000000b4,0x0003003e,0x000000b3,0x000000b5, + 0x00050041,0x00000007,0x000000b7,0x00000082,0x00000092,0x0004003d,0x00000006,0x000000b8, + 0x000000b7,0x0003003e,0x000000b6,0x000000b8,0x0004003d,0x00000006,0x000000ba,0x00000089, + 0x0003003e,0x000000b9,0x000000ba,0x0004003d,0x00000006,0x000000bc,0x0000008d,0x0003003e, + 0x000000bb,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000091,0x0003003e,0x000000bd, + 0x000000be,0x00070039,0x00000002,0x000000bf,0x00000026,0x000000b9,0x000000bb,0x000000bd, + 0x0004003d,0x00000006,0x000000c0,0x000000b9,0x0003003e,0x00000089,0x000000c0,0x0004003d, + 0x00000006,0x000000c1,0x000000bb,0x0003003e,0x0000008d,0x000000c1,0x0004003d,0x00000006, + 0x000000c2,0x000000bd,0x0003003e,0x00000091,0x000000c2,0x0004003d,0x00000006,0x000000c4, + 0x00000095,0x0003003e,0x000000c3,0x000000c4,0x0004003d,0x00000006,0x000000c6,0x00000098, + 0x0003003e,0x000000c5,0x000000c6,0x0004003d,0x00000006,0x000000c8,0x0000009b,0x0003003e, + 0x000000c7,0x000000c8,0x00070039,0x00000002,0x000000c9,0x00000026,0x000000c3,0x000000c5, + 0x000000c7,0x0004003d,0x00000006,0x000000ca,0x000000c3,0x0003003e,0x00000095,0x000000ca, + 0x0004003d,0x00000006,0x000000cb,0x000000c5,0x0003003e,0x00000098,0x000000cb,0x0004003d, + 0x00000006,0x000000cc,0x000000c7,0x0003003e,0x0000009b,0x000000cc,0x0004003d,0x00000006, + 0x000000ce,0x0000009e,0x0003003e,0x000000cd,0x000000ce,0x0004003d,0x00000006,0x000000d0, + 0x000000a1,0x0003003e,0x000000cf,0x000000d0,0x0004003d,0x00000006,0x000000d2,0x000000a4, + 0x0003003e,0x000000d1,0x000000d2,0x00070039,0x00000002,0x000000d3,0x00000026,0x000000cd, + 0x000000cf,0x000000d1,0x0004003d,0x00000006,0x000000d4,0x000000cd,0x0003003e,0x0000009e, + 0x000000d4,0x0004003d,0x00000006,0x000000d5,0x000000cf,0x0003003e,0x000000a1,0x000000d5, + 0x0004003d,0x00000006,0x000000d6,0x000000d1,0x0003003e,0x000000a4,0x000000d6,0x0004003d, + 0x00000006,0x000000d8,0x000000a7,0x0003003e,0x000000d7,0x000000d8,0x0004003d,0x00000006, + 0x000000da,0x000000aa,0x0003003e,0x000000d9,0x000000da,0x0004003d,0x00000006,0x000000dc, + 0x000000ad,0x0003003e,0x000000db,0x000000dc,0x00070039,0x00000002,0x000000dd,0x00000026, + 0x000000d7,0x000000d9,0x000000db,0x0004003d,0x00000006,0x000000de,0x000000d7,0x0003003e, + 0x000000a7,0x000000de,0x0004003d,0x00000006,0x000000df,0x000000d9,0x0003003e,0x000000aa, + 0x000000df,0x0004003d,0x00000006,0x000000e0,0x000000db,0x0003003e,0x000000ad,0x000000e0, + 0x0004003d,0x00000006,0x000000e2,0x000000b0,0x0003003e,0x000000e1,0x000000e2,0x0004003d, + 0x00000006,0x000000e4,0x000000b3,0x0003003e,0x000000e3,0x000000e4,0x0004003d,0x00000006, + 0x000000e6,0x000000b6,0x0003003e,0x000000e5,0x000000e6,0x00070039,0x00000002,0x000000e7, + 0x00000026,0x000000e1,0x000000e3,0x000000e5,0x0004003d,0x00000006,0x000000e8,0x000000e1, + 0x0003003e,0x000000b0,0x000000e8,0x0004003d,0x00000006,0x000000e9,0x000000e3,0x0003003e, + 0x000000b3,0x000000e9,0x0004003d,0x00000006,0x000000ea,0x000000e5,0x0003003e,0x000000b6, + 0x000000ea,0x0004003d,0x00000006,0x000000ec,0x00000091,0x00050085,0x00000006,0x000000ee, + 0x000000ec,0x000000ed,0x0004003d,0x00000006,0x000000ef,0x00000089,0x00050085,0x00000006, + 0x000000f0,0x000000ef,0x000000ed,0x0004003d,0x00000006,0x000000f1,0x0000008d,0x00050081, + 0x00000006,0x000000f2,0x000000f0,0x000000f1,0x00050081,0x00000006,0x000000f3,0x000000ee, + 0x000000f2,0x0003003e,0x000000eb,0x000000f3,0x0004003d,0x00000006,0x000000f5,0x0000009b, + 0x00050085,0x00000006,0x000000f6,0x000000f5,0x000000ed,0x0004003d,0x00000006,0x000000f7, + 0x00000095,0x00050085,0x00000006,0x000000f8,0x000000f7,0x000000ed,0x0004003d,0x00000006, + 0x000000f9,0x00000098,0x00050081,0x00000006,0x000000fa,0x000000f8,0x000000f9,0x00050081, + 0x00000006,0x000000fb,0x000000f6,0x000000fa,0x0003003e,0x000000f4,0x000000fb,0x0004003d, + 0x00000006,0x000000fd,0x000000a4,0x00050085,0x00000006,0x000000fe,0x000000fd,0x000000ed, + 0x0004003d,0x00000006,0x000000ff,0x0000009e,0x00050085,0x00000006,0x00000100,0x000000ff, + 0x000000ed,0x0004003d,0x00000006,0x00000101,0x000000a1,0x00050081,0x00000006,0x00000102, + 0x00000100,0x00000101,0x00050081,0x00000006,0x00000103,0x000000fe,0x00000102,0x0003003e, + 0x000000fc,0x00000103,0x0004003d,0x00000006,0x00000105,0x000000ad,0x00050085,0x00000006, + 0x00000106,0x00000105,0x000000ed,0x0004003d,0x00000006,0x00000107,0x000000a7,0x00050085, + 0x00000006,0x00000108,0x00000107,0x000000ed,0x0004003d,0x00000006,0x00000109,0x000000aa, + 0x00050081,0x00000006,0x0000010a,0x00000108,0x00000109,0x00050081,0x00000006,0x0000010b, + 0x00000106,0x0000010a,0x0003003e,0x00000104,0x0000010b,0x0004003d,0x00000006,0x0000010d, + 0x000000b6,0x00050085,0x00000006,0x0000010e,0x0000010d,0x000000ed,0x0004003d,0x00000006, + 0x0000010f,0x000000b0,0x00050085,0x00000006,0x00000110,0x0000010f,0x000000ed,0x0004003d, + 0x00000006,0x00000111,0x000000b3,0x00050081,0x00000006,0x00000112,0x00000110,0x00000111, + 0x00050081,0x00000006,0x00000113,0x0000010e,0x00000112,0x0003003e,0x0000010c,0x00000113, + 0x0004003d,0x00000006,0x00000116,0x000000eb,0x00050085,0x00000006,0x00000117,0x00000115, + 0x00000116,0x0004003d,0x00000006,0x00000118,0x000000f4,0x00050085,0x00000006,0x00000119, + 0x00000115,0x00000118,0x00050081,0x00000006,0x0000011a,0x00000117,0x00000119,0x0004003d, + 0x00000006,0x0000011b,0x00000104,0x00050085,0x00000006,0x0000011c,0x00000115,0x0000011b, + 0x00050081,0x00000006,0x0000011d,0x0000011a,0x0000011c,0x0004003d,0x00000006,0x0000011e, + 0x0000010c,0x00050085,0x00000006,0x0000011f,0x00000115,0x0000011e,0x00050081,0x00000006, + 0x00000120,0x0000011d,0x0000011f,0x0004003d,0x00000006,0x00000121,0x000000fc,0x00050083, + 0x00000006,0x00000122,0x00000120,0x00000121,0x0003003e,0x00000114,0x00000122,0x0004003d, + 0x00000006,0x00000123,0x00000114,0x0006000c,0x00000006,0x00000124,0x00000001,0x00000004, + 0x00000123,0x0004003d,0x00000006,0x00000126,0x000000eb,0x0003003e,0x00000125,0x00000126, + 0x0004003d,0x00000006,0x00000128,0x000000f4,0x0003003e,0x00000127,0x00000128,0x0004003d, + 0x00000006,0x0000012a,0x000000fc,0x0003003e,0x00000129,0x0000012a,0x00070039,0x00000006, + 0x0000012b,0x00000018,0x00000125,0x00000127,0x00000129,0x0003003e,0x0000012c,0x0000012b, + 0x0004003d,0x00000006,0x0000012e,0x00000104,0x0003003e,0x0000012d,0x0000012e,0x0004003d, + 0x00000006,0x00000130,0x0000010c,0x0003003e,0x0000012f,0x00000130,0x00070039,0x00000006, + 0x00000131,0x00000018,0x0000012c,0x0000012d,0x0000012f,0x0004003d,0x00000006,0x00000133, + 0x000000eb,0x0003003e,0x00000132,0x00000133,0x0004003d,0x00000006,0x00000135,0x000000f4, + 0x0003003e,0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x000000fc,0x0003003e, + 0x00000136,0x00000137,0x00070039,0x00000006,0x00000138,0x00000013,0x00000132,0x00000134, + 0x00000136,0x0003003e,0x00000139,0x00000138,0x0004003d,0x00000006,0x0000013b,0x00000104, + 0x0003003e,0x0000013a,0x0000013b,0x0004003d,0x00000006,0x0000013d,0x0000010c,0x0003003e, + 0x0000013c,0x0000013d,0x00070039,0x00000006,0x0000013e,0x00000013,0x00000139,0x0000013a, + 0x0000013c,0x00050083,0x00000006,0x0000013f,0x00000131,0x0000013e,0x0003003e,0x00000140, + 0x0000013f,0x00050039,0x00000006,0x00000141,0x0000000a,0x00000140,0x00050085,0x00000006, + 0x00000142,0x00000124,0x00000141,0x0003003e,0x00000143,0x00000142,0x00050039,0x00000006, + 0x00000144,0x0000000d,0x00000143,0x0003003e,0x00000114,0x00000144,0x0004003d,0x00000006, + 0x00000146,0x00000114,0x00050085,0x00000006,0x00000147,0x00000145,0x00000146,0x00050081, + 0x00000006,0x00000148,0x00000147,0x00000035,0x0003003e,0x00000114,0x00000148,0x0004003d, + 0x00000006,0x0000014b,0x00000089,0x0003003e,0x0000014a,0x0000014b,0x0004003d,0x00000006, + 0x0000014d,0x00000095,0x0003003e,0x0000014c,0x0000014d,0x0004003d,0x00000006,0x0000014f, + 0x000000a7,0x0003003e,0x0000014e,0x0000014f,0x00070039,0x00000006,0x00000150,0x00000013, + 0x0000014a,0x0000014c,0x0000014e,0x0004003d,0x00000006,0x00000151,0x000000b0,0x0007000c, + 0x00000006,0x00000152,0x00000001,0x00000025,0x00000150,0x00000151,0x0003003e,0x00000149, + 0x00000152,0x0004003d,0x00000006,0x00000155,0x0000008d,0x0003003e,0x00000154,0x00000155, + 0x0004003d,0x00000006,0x00000157,0x00000098,0x0003003e,0x00000156,0x00000157,0x0004003d, + 0x00000006,0x00000159,0x000000aa,0x0003003e,0x00000158,0x00000159,0x00070039,0x00000006, + 0x0000015a,0x00000013,0x00000154,0x00000156,0x00000158,0x0004003d,0x00000006,0x0000015b, + 0x000000b3,0x0007000c,0x00000006,0x0000015c,0x00000001,0x00000025,0x0000015a,0x0000015b, + 0x0003003e,0x00000153,0x0000015c,0x0004003d,0x00000006,0x0000015f,0x00000091,0x0003003e, + 0x0000015e,0x0000015f,0x0004003d,0x00000006,0x00000161,0x0000009b,0x0003003e,0x00000160, + 0x00000161,0x0004003d,0x00000006,0x00000163,0x000000ad,0x0003003e,0x00000162,0x00000163, + 0x00070039,0x00000006,0x00000164,0x00000013,0x0000015e,0x00000160,0x00000162,0x0004003d, + 0x00000006,0x00000165,0x000000b6,0x0007000c,0x00000006,0x00000166,0x00000001,0x00000025, + 0x00000164,0x00000165,0x0003003e,0x0000015d,0x00000166,0x0004003d,0x00000006,0x00000169, + 0x00000089,0x0003003e,0x00000168,0x00000169,0x0004003d,0x00000006,0x0000016b,0x00000095, + 0x0003003e,0x0000016a,0x0000016b,0x0004003d,0x00000006,0x0000016d,0x000000a7,0x0003003e, + 0x0000016c,0x0000016d,0x00070039,0x00000006,0x0000016e,0x00000018,0x00000168,0x0000016a, + 0x0000016c,0x0004003d,0x00000006,0x0000016f,0x000000b0,0x0007000c,0x00000006,0x00000170, + 0x00000001,0x00000028,0x0000016e,0x0000016f,0x0003003e,0x00000167,0x00000170,0x0004003d, + 0x00000006,0x00000173,0x0000008d,0x0003003e,0x00000172,0x00000173,0x0004003d,0x00000006, + 0x00000175,0x00000098,0x0003003e,0x00000174,0x00000175,0x0004003d,0x00000006,0x00000177, + 0x000000aa,0x0003003e,0x00000176,0x00000177,0x00070039,0x00000006,0x00000178,0x00000018, + 0x00000172,0x00000174,0x00000176,0x0004003d,0x00000006,0x00000179,0x000000b3,0x0007000c, + 0x00000006,0x0000017a,0x00000001,0x00000028,0x00000178,0x00000179,0x0003003e,0x00000171, + 0x0000017a,0x0004003d,0x00000006,0x0000017d,0x00000091,0x0003003e,0x0000017c,0x0000017d, + 0x0004003d,0x00000006,0x0000017f,0x0000009b,0x0003003e,0x0000017e,0x0000017f,0x0004003d, + 0x00000006,0x00000181,0x000000ad,0x0003003e,0x00000180,0x00000181,0x00070039,0x00000006, + 0x00000182,0x00000018,0x0000017c,0x0000017e,0x00000180,0x0004003d,0x00000006,0x00000183, + 0x000000b6,0x0007000c,0x00000006,0x00000184,0x00000001,0x00000028,0x00000182,0x00000183, + 0x0003003e,0x0000017b,0x00000184,0x0003003e,0x00000187,0x00000189,0x0004003d,0x00000006, + 0x0000018c,0x00000167,0x00050085,0x00000006,0x0000018d,0x0000018b,0x0000018c,0x0003003e, + 0x0000018a,0x0000018d,0x0004003d,0x00000006,0x0000018f,0x00000171,0x00050085,0x00000006, + 0x00000190,0x0000018b,0x0000018f,0x0003003e,0x0000018e,0x00000190,0x0004003d,0x00000006, + 0x00000192,0x0000017b,0x00050085,0x00000006,0x00000193,0x0000018b,0x00000192,0x0003003e, + 0x00000191,0x00000193,0x0004003d,0x00000006,0x00000195,0x00000149,0x00050085,0x00000006, + 0x00000196,0x0000018b,0x00000195,0x00050041,0x00000007,0x00000197,0x00000187,0x0000008e, + 0x0004003d,0x00000006,0x00000198,0x00000197,0x00050081,0x00000006,0x00000199,0x00000196, + 0x00000198,0x0003003e,0x00000194,0x00000199,0x0004003d,0x00000006,0x0000019b,0x00000153, + 0x00050085,0x00000006,0x0000019c,0x0000018b,0x0000019b,0x00050041,0x00000007,0x0000019d, + 0x00000187,0x0000008e,0x0004003d,0x00000006,0x0000019e,0x0000019d,0x00050081,0x00000006, + 0x0000019f,0x0000019c,0x0000019e,0x0003003e,0x0000019a,0x0000019f,0x0004003d,0x00000006, + 0x000001a1,0x0000015d,0x00050085,0x00000006,0x000001a2,0x0000018b,0x000001a1,0x00050041, + 0x00000007,0x000001a3,0x00000187,0x0000008e,0x0004003d,0x00000006,0x000001a4,0x000001a3, + 0x00050081,0x00000006,0x000001a5,0x000001a2,0x000001a4,0x0003003e,0x000001a0,0x000001a5, + 0x0004003d,0x00000006,0x000001a7,0x0000018a,0x000500ba,0x000001a8,0x000001a9,0x000001a7, + 0x0000003b,0x000300f7,0x000001ac,0x00000000,0x000400fa,0x000001a9,0x000001ab,0x000001b2, + 0x000200f8,0x000001ab,0x0004003d,0x00000006,0x000001ad,0x00000149,0x0004003d,0x00000006, + 0x000001ae,0x0000009e,0x0007000c,0x00000006,0x000001af,0x00000001,0x00000025,0x000001ad, + 0x000001ae,0x0004003d,0x00000006,0x000001b0,0x0000018a,0x00050088,0x00000006,0x000001b1, + 0x000001af,0x000001b0,0x0003003e,0x000001aa,0x000001b1,0x000200f9,0x000001ac,0x000200f8, + 0x000001b2,0x0003003e,0x000001aa,0x0000003b,0x000200f9,0x000001ac,0x000200f8,0x000001ac, + 0x0004003d,0x00000006,0x000001b3,0x000001aa,0x0003003e,0x000001a6,0x000001b3,0x0004003d, + 0x00000006,0x000001b5,0x0000018e,0x000500ba,0x000001a8,0x000001b6,0x000001b5,0x0000003b, + 0x000300f7,0x000001b9,0x00000000,0x000400fa,0x000001b6,0x000001b8,0x000001bf,0x000200f8, + 0x000001b8,0x0004003d,0x00000006,0x000001ba,0x00000153,0x0004003d,0x00000006,0x000001bb, + 0x000000a1,0x0007000c,0x00000006,0x000001bc,0x00000001,0x00000025,0x000001ba,0x000001bb, + 0x0004003d,0x00000006,0x000001bd,0x0000018e,0x00050088,0x00000006,0x000001be,0x000001bc, + 0x000001bd,0x0003003e,0x000001b7,0x000001be,0x000200f9,0x000001b9,0x000200f8,0x000001bf, + 0x0003003e,0x000001b7,0x0000003b,0x000200f9,0x000001b9,0x000200f8,0x000001b9,0x0004003d, + 0x00000006,0x000001c0,0x000001b7,0x0003003e,0x000001b4,0x000001c0,0x0004003d,0x00000006, + 0x000001c2,0x00000191,0x000500ba,0x000001a8,0x000001c3,0x000001c2,0x0000003b,0x000300f7, + 0x000001c6,0x00000000,0x000400fa,0x000001c3,0x000001c5,0x000001cc,0x000200f8,0x000001c5, + 0x0004003d,0x00000006,0x000001c7,0x0000015d,0x0004003d,0x00000006,0x000001c8,0x000000a4, + 0x0007000c,0x00000006,0x000001c9,0x00000001,0x00000025,0x000001c7,0x000001c8,0x0004003d, + 0x00000006,0x000001ca,0x00000191,0x00050088,0x00000006,0x000001cb,0x000001c9,0x000001ca, + 0x0003003e,0x000001c4,0x000001cb,0x000200f9,0x000001c6,0x000200f8,0x000001cc,0x0003003e, + 0x000001c4,0x0000003b,0x000200f9,0x000001c6,0x000200f8,0x000001c6,0x0004003d,0x00000006, + 0x000001cd,0x000001c4,0x0003003e,0x000001c1,0x000001cd,0x00050041,0x00000007,0x000001cf, + 0x00000187,0x0000008a,0x0004003d,0x00000006,0x000001d0,0x000001cf,0x0004003d,0x00000006, + 0x000001d1,0x00000167,0x0004003d,0x00000006,0x000001d2,0x0000009e,0x0007000c,0x00000006, + 0x000001d3,0x00000001,0x00000028,0x000001d1,0x000001d2,0x00050083,0x00000006,0x000001d4, + 0x000001d0,0x000001d3,0x0003003e,0x000001ce,0x000001d4,0x00050041,0x00000007,0x000001d6, + 0x00000187,0x0000008a,0x0004003d,0x00000006,0x000001d7,0x000001d6,0x0004003d,0x00000006, + 0x000001d8,0x00000171,0x0004003d,0x00000006,0x000001d9,0x000000a1,0x0007000c,0x00000006, + 0x000001da,0x00000001,0x00000028,0x000001d8,0x000001d9,0x00050083,0x00000006,0x000001db, + 0x000001d7,0x000001da,0x0003003e,0x000001d5,0x000001db,0x00050041,0x00000007,0x000001dd, + 0x00000187,0x0000008a,0x0004003d,0x00000006,0x000001de,0x000001dd,0x0004003d,0x00000006, + 0x000001df,0x0000017b,0x0004003d,0x00000006,0x000001e0,0x000000a4,0x0007000c,0x00000006, + 0x000001e1,0x00000001,0x00000028,0x000001df,0x000001e0,0x00050083,0x00000006,0x000001e2, + 0x000001de,0x000001e1,0x0003003e,0x000001dc,0x000001e2,0x0004003d,0x00000006,0x000001e4, + 0x00000194,0x0006000c,0x00000006,0x000001e5,0x00000001,0x00000004,0x000001e4,0x000500ba, + 0x000001a8,0x000001e7,0x000001e5,0x000001e6,0x000300f7,0x000001ea,0x00000000,0x000400fa, + 0x000001e7,0x000001e9,0x000001ee,0x000200f8,0x000001e9,0x0004003d,0x00000006,0x000001eb, + 0x000001ce,0x0004003d,0x00000006,0x000001ec,0x00000194,0x00050088,0x00000006,0x000001ed, + 0x000001eb,0x000001ec,0x0003003e,0x000001e8,0x000001ed,0x000200f9,0x000001ea,0x000200f8, + 0x000001ee,0x0003003e,0x000001e8,0x0000003b,0x000200f9,0x000001ea,0x000200f8,0x000001ea, + 0x0004003d,0x00000006,0x000001ef,0x000001e8,0x0003003e,0x000001e3,0x000001ef,0x0004003d, + 0x00000006,0x000001f1,0x0000019a,0x0006000c,0x00000006,0x000001f2,0x00000001,0x00000004, + 0x000001f1,0x000500ba,0x000001a8,0x000001f3,0x000001f2,0x000001e6,0x000300f7,0x000001f6, + 0x00000000,0x000400fa,0x000001f3,0x000001f5,0x000001fa,0x000200f8,0x000001f5,0x0004003d, + 0x00000006,0x000001f7,0x000001d5,0x0004003d,0x00000006,0x000001f8,0x0000019a,0x00050088, + 0x00000006,0x000001f9,0x000001f7,0x000001f8,0x0003003e,0x000001f4,0x000001f9,0x000200f9, + 0x000001f6,0x000200f8,0x000001fa,0x0003003e,0x000001f4,0x0000003b,0x000200f9,0x000001f6, + 0x000200f8,0x000001f6,0x0004003d,0x00000006,0x000001fb,0x000001f4,0x0003003e,0x000001f0, + 0x000001fb,0x0004003d,0x00000006,0x000001fd,0x000001a0,0x0006000c,0x00000006,0x000001fe, + 0x00000001,0x00000004,0x000001fd,0x000500ba,0x000001a8,0x000001ff,0x000001fe,0x000001e6, + 0x000300f7,0x00000202,0x00000000,0x000400fa,0x000001ff,0x00000201,0x00000206,0x000200f8, + 0x00000201,0x0004003d,0x00000006,0x00000203,0x000001dc,0x0004003d,0x00000006,0x00000204, + 0x000001a0,0x00050088,0x00000006,0x00000205,0x00000203,0x00000204,0x0003003e,0x00000200, + 0x00000205,0x000200f9,0x00000202,0x000200f8,0x00000206,0x0003003e,0x00000200,0x0000003b, + 0x000200f9,0x00000202,0x000200f8,0x00000202,0x0004003d,0x00000006,0x00000207,0x00000200, + 0x0003003e,0x000001fc,0x00000207,0x0004003d,0x00000006,0x00000209,0x000001a6,0x0004007f, + 0x00000006,0x0000020a,0x00000209,0x0004003d,0x00000006,0x0000020b,0x000001e3,0x0007000c, + 0x00000006,0x0000020c,0x00000001,0x00000028,0x0000020a,0x0000020b,0x0003003e,0x00000208, + 0x0000020c,0x0004003d,0x00000006,0x0000020e,0x000001b4,0x0004007f,0x00000006,0x0000020f, + 0x0000020e,0x0004003d,0x00000006,0x00000210,0x000001f0,0x0007000c,0x00000006,0x00000211, + 0x00000001,0x00000028,0x0000020f,0x00000210,0x0003003e,0x0000020d,0x00000211,0x0004003d, + 0x00000006,0x00000213,0x000001c1,0x0004007f,0x00000006,0x00000214,0x00000213,0x0004003d, + 0x00000006,0x00000215,0x000001fc,0x0007000c,0x00000006,0x00000216,0x00000001,0x00000028, + 0x00000214,0x00000215,0x0003003e,0x00000212,0x00000216,0x0004003d,0x00000006,0x0000021a, + 0x00000208,0x0003003e,0x00000219,0x0000021a,0x0004003d,0x00000006,0x0000021c,0x0000020d, + 0x0003003e,0x0000021b,0x0000021c,0x0004003d,0x00000006,0x0000021e,0x00000212,0x0003003e, + 0x0000021d,0x0000021e,0x00070039,0x00000006,0x0000021f,0x00000018,0x00000219,0x0000021b, + 0x0000021d,0x0007000c,0x00000006,0x00000220,0x00000001,0x00000025,0x0000021f,0x0000003b, + 0x0007000c,0x00000006,0x00000221,0x00000001,0x00000028,0x00000218,0x00000220,0x00050041, + 0x00000222,0x00000223,0x00000032,0x0000008a,0x0004003d,0x00000028,0x00000224,0x00000223, + 0x0004007c,0x00000006,0x00000225,0x00000224,0x00050085,0x00000006,0x00000226,0x00000221, + 0x00000225,0x0003003e,0x00000217,0x00000226,0x0004003d,0x00000006,0x00000228,0x00000217, + 0x00050085,0x00000006,0x00000229,0x0000018b,0x00000228,0x00050081,0x00000006,0x0000022a, + 0x00000229,0x00000035,0x0003003e,0x0000022b,0x0000022a,0x00050039,0x00000006,0x0000022c, + 0x0000000a,0x0000022b,0x0003003e,0x00000227,0x0000022c,0x0004003d,0x00000006,0x0000022d, + 0x00000217,0x0004003d,0x00000006,0x0000022e,0x00000089,0x00050085,0x00000006,0x0000022f, + 0x0000022d,0x0000022e,0x0004003d,0x00000006,0x00000230,0x00000217,0x0004003d,0x00000006, + 0x00000231,0x00000095,0x00050085,0x00000006,0x00000232,0x00000230,0x00000231,0x00050081, + 0x00000006,0x00000233,0x0000022f,0x00000232,0x0004003d,0x00000006,0x00000234,0x00000217, + 0x0004003d,0x00000006,0x00000235,0x000000b0,0x00050085,0x00000006,0x00000236,0x00000234, + 0x00000235,0x00050081,0x00000006,0x00000237,0x00000233,0x00000236,0x0004003d,0x00000006, + 0x00000238,0x00000217,0x0004003d,0x00000006,0x00000239,0x000000a7,0x00050085,0x00000006, + 0x0000023a,0x00000238,0x00000239,0x00050081,0x00000006,0x0000023b,0x00000237,0x0000023a, + 0x0004003d,0x00000006,0x0000023c,0x0000009e,0x00050081,0x00000006,0x0000023d,0x0000023b, + 0x0000023c,0x0004003d,0x00000006,0x0000023e,0x00000227,0x00050085,0x00000006,0x0000023f, + 0x0000023d,0x0000023e,0x0003003e,0x0000002e,0x0000023f,0x0004003d,0x00000006,0x00000240, + 0x00000217,0x0004003d,0x00000006,0x00000241,0x0000008d,0x00050085,0x00000006,0x00000242, + 0x00000240,0x00000241,0x0004003d,0x00000006,0x00000243,0x00000217,0x0004003d,0x00000006, + 0x00000244,0x00000098,0x00050085,0x00000006,0x00000245,0x00000243,0x00000244,0x00050081, + 0x00000006,0x00000246,0x00000242,0x00000245,0x0004003d,0x00000006,0x00000247,0x00000217, + 0x0004003d,0x00000006,0x00000248,0x000000b3,0x00050085,0x00000006,0x00000249,0x00000247, + 0x00000248,0x00050081,0x00000006,0x0000024a,0x00000246,0x00000249,0x0004003d,0x00000006, + 0x0000024b,0x00000217,0x0004003d,0x00000006,0x0000024c,0x000000aa,0x00050085,0x00000006, + 0x0000024d,0x0000024b,0x0000024c,0x00050081,0x00000006,0x0000024e,0x0000024a,0x0000024d, + 0x0004003d,0x00000006,0x0000024f,0x000000a1,0x00050081,0x00000006,0x00000250,0x0000024e, + 0x0000024f,0x0004003d,0x00000006,0x00000251,0x00000227,0x00050085,0x00000006,0x00000252, + 0x00000250,0x00000251,0x0003003e,0x0000002f,0x00000252,0x0004003d,0x00000006,0x00000253, + 0x00000217,0x0004003d,0x00000006,0x00000254,0x00000091,0x00050085,0x00000006,0x00000255, + 0x00000253,0x00000254,0x0004003d,0x00000006,0x00000256,0x00000217,0x0004003d,0x00000006, + 0x00000257,0x0000009b,0x00050085,0x00000006,0x00000258,0x00000256,0x00000257,0x00050081, + 0x00000006,0x00000259,0x00000255,0x00000258,0x0004003d,0x00000006,0x0000025a,0x00000217, + 0x0004003d,0x00000006,0x0000025b,0x000000b6,0x00050085,0x00000006,0x0000025c,0x0000025a, + 0x0000025b,0x00050081,0x00000006,0x0000025d,0x00000259,0x0000025c,0x0004003d,0x00000006, + 0x0000025e,0x00000217,0x0004003d,0x00000006,0x0000025f,0x000000ad,0x00050085,0x00000006, + 0x00000260,0x0000025e,0x0000025f,0x00050081,0x00000006,0x00000261,0x0000025d,0x00000260, + 0x0004003d,0x00000006,0x00000262,0x000000a4,0x00050081,0x00000006,0x00000263,0x00000261, + 0x00000262,0x0004003d,0x00000006,0x00000264,0x00000227,0x00050085,0x00000006,0x00000265, + 0x00000263,0x00000264,0x0003003e,0x00000030,0x00000265,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/fxaa.frag b/app/src/main/cpp/shaders/fxaa.frag new file mode 100644 index 0000000000..9476117722 --- /dev/null +++ b/app/src/main/cpp/shaders/fxaa.frag @@ -0,0 +1,67 @@ +#version 450 + +// ============================================================================= +// FXAA (Fast Approximate Anti-Aliasing) post effect. +// +// Ported verbatim from the OpenGL FXAAEffect.java shader so the Vulkan +// compositor's post-process pipeline applies the SAME anti-aliasing the GL +// renderer's "FXAA" toggle does. GL sampled with gl_FragCoord.xy*invResolution; +// here fragTexCoord already spans [0,1] across the output, so it IS that uv. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// Runs FIRST in the canonical post chain (AA on the clean composited image). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in px +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define FXAA_MIN_REDUCE (1.0 / 128.0) +#define FXAA_MUL_REDUCE (1.0 / 8.0) +#define MAX_SPAN 8.0 +const vec3 luma = vec3(0.299, 0.587, 0.114); + +void main() { + vec2 invResolution = 1.0 / pc.resolution; + vec2 uv = fragTexCoord; + + vec3 rgbNW = texture(InputTexture, uv + vec2(-1.0, -1.0) * invResolution).rgb; + vec3 rgbNE = texture(InputTexture, uv + vec2( 1.0, -1.0) * invResolution).rgb; + vec3 rgbSW = texture(InputTexture, uv + vec2(-1.0, 1.0) * invResolution).rgb; + vec3 rgbSE = texture(InputTexture, uv + vec2( 1.0, 1.0) * invResolution).rgb; + vec3 rgbM = texture(InputTexture, uv).rgb; + + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * FXAA_MUL_REDUCE, FXAA_MIN_REDUCE); + float minDirFactor = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = clamp(dir * minDirFactor, vec2(-MAX_SPAN), vec2(MAX_SPAN)) * invResolution; + + vec4 rgbA = 0.5 * ( + texture(InputTexture, uv + dir * (1.0 / 3.0 - 0.5)) + + texture(InputTexture, uv + dir * (2.0 / 3.0 - 0.5))); + vec4 rgbB = rgbA * 0.5 + 0.25 * ( + texture(InputTexture, uv + dir * -0.5) + + texture(InputTexture, uv + dir * 0.5)); + + float lumaB = dot(rgbB, vec4(luma, 0.0)); + outColor = (lumaB < lumaMin || lumaB > lumaMax) ? rgbA : rgbB; +} diff --git a/app/src/main/cpp/shaders/fxaa_toon.frag b/app/src/main/cpp/shaders/fxaa_toon.frag new file mode 100644 index 0000000000..ee75bba04f --- /dev/null +++ b/app/src/main/cpp/shaders/fxaa_toon.frag @@ -0,0 +1,69 @@ +#version 450 + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; + vec2 resolution; +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define FXAA_MIN_REDUCE (1.0 / 128.0) +#define FXAA_MUL_REDUCE (1.0 / 8.0) +#define MAX_SPAN 8.0 + +const vec3 luma = vec3(0.299, 0.587, 0.114); + +void main() { + vec2 invResolution = 1.0 / pc.resolution; + vec2 uv = fragTexCoord; + + vec3 rgbNW = texture(InputTexture, uv + vec2(-1.0, -1.0) * invResolution).rgb; + vec3 rgbNE = texture(InputTexture, uv + vec2( 1.0, -1.0) * invResolution).rgb; + vec3 rgbSW = texture(InputTexture, uv + vec2(-1.0, 1.0) * invResolution).rgb; + vec3 rgbSE = texture(InputTexture, uv + vec2( 1.0, 1.0) * invResolution).rgb; + vec3 rgbM = texture(InputTexture, uv).rgb; + + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max( + (lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * FXAA_MUL_REDUCE, + FXAA_MIN_REDUCE); + float minDirFactor = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = clamp(dir * minDirFactor, vec2(-MAX_SPAN), vec2(MAX_SPAN)) * invResolution; + + vec4 rgbA = 0.5 * ( + texture(InputTexture, uv + dir * (1.0 / 3.0 - 0.5)) + + texture(InputTexture, uv + dir * (2.0 / 3.0 - 0.5))); + vec4 rgbB = rgbA * 0.5 + 0.25 * ( + texture(InputTexture, uv + dir * -0.5) + + texture(InputTexture, uv + dir * 0.5)); + + vec4 fxaaColor = dot(rgbB, vec4(luma, 0.0)) < lumaMin || + dot(rgbB, vec4(luma, 0.0)) > lumaMax ? rgbA : rgbB; + + // Approximate Toon edges using only FXAA's existing five samples. + vec3 colorLeft = 0.5 * (rgbNW + rgbSW); + vec3 colorRight = 0.5 * (rgbNE + rgbSE); + vec3 colorUp = 0.5 * (rgbNW + rgbNE); + vec3 colorDown = 0.5 * (rgbSW + rgbSE); + + float diffHorizontal = length(colorRight - colorLeft); + float diffVertical = length(colorUp - colorDown); + float edgeFactor = step(0.2, diffHorizontal + diffVertical); + + outColor = vec4(mix(fxaaColor.rgb, vec3(0.0), edgeFactor), 1.0); +} diff --git a/app/src/main/cpp/shaders/fxaa_toon_frag.h b/app/src/main/cpp/shaders/fxaa_toon_frag.h new file mode 100644 index 0000000000..3c8e221743 --- /dev/null +++ b/app/src/main/cpp/shaders/fxaa_toon_frag.h @@ -0,0 +1,202 @@ + // 1116.3.0 + #pragma once +const uint32_t fxaa_toon_code[] = { + 0x07230203,0x00010000,0x0008000b,0x00000115,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000018,0x0000010a,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00060005,0x00000009,0x52766e69,0x6c6f7365,0x6f697475,0x0000006e,0x00030005, + 0x0000000c,0x00004350,0x00040006,0x0000000c,0x00000000,0x0063646e,0x00060006,0x0000000c, + 0x00000001,0x6f736572,0x6974756c,0x00006e6f,0x00030005,0x0000000e,0x00006370,0x00030005, + 0x00000016,0x00007675,0x00060005,0x00000018,0x67617266,0x43786554,0x64726f6f,0x00000000, + 0x00040005,0x0000001c,0x4e626772,0x00000057,0x00060005,0x00000020,0x75706e49,0x78655474, + 0x65727574,0x00000000,0x00040005,0x0000002a,0x4e626772,0x00000045,0x00040005,0x00000033, + 0x53626772,0x00000057,0x00040005,0x0000003c,0x53626772,0x00000045,0x00040005,0x00000045, + 0x4d626772,0x00000000,0x00040005,0x0000004b,0x616d756c,0x0000574e,0x00040005,0x00000052, + 0x616d756c,0x0000454e,0x00040005,0x00000055,0x616d756c,0x00005753,0x00040005,0x00000058, + 0x616d756c,0x00004553,0x00040005,0x0000005b,0x616d756c,0x0000004d,0x00040005,0x0000005e, + 0x616d756c,0x006e694d,0x00040005,0x00000068,0x616d756c,0x0078614d,0x00030005,0x00000072, + 0x00726964,0x00050005,0x00000087,0x52726964,0x63756465,0x00000065,0x00060005,0x00000095, + 0x446e696d,0x61467269,0x726f7463,0x00000000,0x00040005,0x000000ab,0x41626772,0x00000000, + 0x00040005,0x000000bd,0x42626772,0x00000000,0x00050005,0x000000d0,0x61617866,0x6f6c6f43, + 0x00000072,0x00050005,0x000000e5,0x6f6c6f63,0x66654c72,0x00000074,0x00050005,0x000000ea, + 0x6f6c6f63,0x67695272,0x00007468,0x00040005,0x000000ef,0x6f6c6f63,0x00705572,0x00050005, + 0x000000f4,0x6f6c6f63,0x776f4472,0x0000006e,0x00060005,0x000000f9,0x66666964,0x69726f48, + 0x746e6f7a,0x00006c61,0x00060005,0x000000fe,0x66666964,0x74726556,0x6c616369,0x00000000, + 0x00050005,0x00000103,0x65676465,0x74636146,0x0000726f,0x00050005,0x0000010a,0x4374756f, + 0x726f6c6f,0x00000000,0x00030047,0x0000000c,0x00000002,0x00050048,0x0000000c,0x00000000, + 0x00000023,0x00000000,0x00050048,0x0000000c,0x00000001,0x00000023,0x00000010,0x00040047, + 0x00000018,0x0000001e,0x00000000,0x00040047,0x00000020,0x00000021,0x00000000,0x00040047, + 0x00000020,0x00000022,0x00000000,0x00040047,0x0000010a,0x0000001e,0x00000000,0x00020013, + 0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017, + 0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x0004002b, + 0x00000006,0x0000000a,0x3f800000,0x00040017,0x0000000b,0x00000006,0x00000004,0x0004001e, + 0x0000000c,0x0000000b,0x00000007,0x00040020,0x0000000d,0x00000009,0x0000000c,0x0004003b, + 0x0000000d,0x0000000e,0x00000009,0x00040015,0x0000000f,0x00000020,0x00000001,0x0004002b, + 0x0000000f,0x00000010,0x00000001,0x00040020,0x00000011,0x00000009,0x00000007,0x00040020, + 0x00000017,0x00000001,0x00000007,0x0004003b,0x00000017,0x00000018,0x00000001,0x00040017, + 0x0000001a,0x00000006,0x00000003,0x00040020,0x0000001b,0x00000007,0x0000001a,0x00090019, + 0x0000001d,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x0000001e,0x0000001d,0x00040020,0x0000001f,0x00000000,0x0000001e,0x0004003b, + 0x0000001f,0x00000020,0x00000000,0x0004002b,0x00000006,0x00000023,0xbf800000,0x0005002c, + 0x00000007,0x00000024,0x00000023,0x00000023,0x0005002c,0x00000007,0x0000002d,0x0000000a, + 0x00000023,0x0005002c,0x00000007,0x00000036,0x00000023,0x0000000a,0x0005002c,0x00000007, + 0x0000003f,0x0000000a,0x0000000a,0x00040020,0x0000004a,0x00000007,0x00000006,0x0004002b, + 0x00000006,0x0000004d,0x3e991687,0x0004002b,0x00000006,0x0000004e,0x3f1645a2,0x0004002b, + 0x00000006,0x0000004f,0x3de978d5,0x0006002c,0x0000001a,0x00000050,0x0000004d,0x0000004e, + 0x0000004f,0x00040015,0x0000007b,0x00000020,0x00000000,0x0004002b,0x0000007b,0x0000007c, + 0x00000000,0x0004002b,0x0000007b,0x00000085,0x00000001,0x0004002b,0x00000006,0x0000008f, + 0x3e800000,0x0004002b,0x00000006,0x00000091,0x3e000000,0x0004002b,0x00000006,0x00000093, + 0x3c000000,0x0004002b,0x00000006,0x000000a3,0xc1000000,0x0005002c,0x00000007,0x000000a4, + 0x000000a3,0x000000a3,0x0004002b,0x00000006,0x000000a5,0x41000000,0x0005002c,0x00000007, + 0x000000a6,0x000000a5,0x000000a5,0x00040020,0x000000aa,0x00000007,0x0000000b,0x0004002b, + 0x00000006,0x000000ac,0x3f000000,0x0004002b,0x00000006,0x000000b0,0xbe2aaaab,0x0004002b, + 0x00000006,0x000000b7,0x3e2aaaab,0x0004002b,0x00000006,0x000000c3,0xbf000000,0x00020014, + 0x000000d1,0x0004002b,0x00000006,0x000000d3,0x00000000,0x0007002c,0x0000000b,0x000000d4, + 0x0000004d,0x0000004e,0x0000004f,0x000000d3,0x00040017,0x000000e2,0x000000d1,0x00000004, + 0x0004002b,0x00000006,0x00000104,0x3e4ccccd,0x00040020,0x00000109,0x00000003,0x0000000b, + 0x0004003b,0x00000109,0x0000010a,0x00000003,0x0006002c,0x0000001a,0x0000010d,0x000000d3, + 0x000000d3,0x000000d3,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000008,0x00000016, + 0x00000007,0x0004003b,0x0000001b,0x0000001c,0x00000007,0x0004003b,0x0000001b,0x0000002a, + 0x00000007,0x0004003b,0x0000001b,0x00000033,0x00000007,0x0004003b,0x0000001b,0x0000003c, + 0x00000007,0x0004003b,0x0000001b,0x00000045,0x00000007,0x0004003b,0x0000004a,0x0000004b, + 0x00000007,0x0004003b,0x0000004a,0x00000052,0x00000007,0x0004003b,0x0000004a,0x00000055, + 0x00000007,0x0004003b,0x0000004a,0x00000058,0x00000007,0x0004003b,0x0000004a,0x0000005b, + 0x00000007,0x0004003b,0x0000004a,0x0000005e,0x00000007,0x0004003b,0x0000004a,0x00000068, + 0x00000007,0x0004003b,0x00000008,0x00000072,0x00000007,0x0004003b,0x0000004a,0x00000087, + 0x00000007,0x0004003b,0x0000004a,0x00000095,0x00000007,0x0004003b,0x000000aa,0x000000ab, + 0x00000007,0x0004003b,0x000000aa,0x000000bd,0x00000007,0x0004003b,0x000000aa,0x000000d0, + 0x00000007,0x0004003b,0x0000001b,0x000000e5,0x00000007,0x0004003b,0x0000001b,0x000000ea, + 0x00000007,0x0004003b,0x0000001b,0x000000ef,0x00000007,0x0004003b,0x0000001b,0x000000f4, + 0x00000007,0x0004003b,0x0000004a,0x000000f9,0x00000007,0x0004003b,0x0000004a,0x000000fe, + 0x00000007,0x0004003b,0x0000004a,0x00000103,0x00000007,0x00050041,0x00000011,0x00000012, + 0x0000000e,0x00000010,0x0004003d,0x00000007,0x00000013,0x00000012,0x00050050,0x00000007, + 0x00000014,0x0000000a,0x0000000a,0x00050088,0x00000007,0x00000015,0x00000014,0x00000013, + 0x0003003e,0x00000009,0x00000015,0x0004003d,0x00000007,0x00000019,0x00000018,0x0003003e, + 0x00000016,0x00000019,0x0004003d,0x0000001e,0x00000021,0x00000020,0x0004003d,0x00000007, + 0x00000022,0x00000016,0x0004003d,0x00000007,0x00000025,0x00000009,0x00050085,0x00000007, + 0x00000026,0x00000024,0x00000025,0x00050081,0x00000007,0x00000027,0x00000022,0x00000026, + 0x00050057,0x0000000b,0x00000028,0x00000021,0x00000027,0x0008004f,0x0000001a,0x00000029, + 0x00000028,0x00000028,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000001c,0x00000029, + 0x0004003d,0x0000001e,0x0000002b,0x00000020,0x0004003d,0x00000007,0x0000002c,0x00000016, + 0x0004003d,0x00000007,0x0000002e,0x00000009,0x00050085,0x00000007,0x0000002f,0x0000002d, + 0x0000002e,0x00050081,0x00000007,0x00000030,0x0000002c,0x0000002f,0x00050057,0x0000000b, + 0x00000031,0x0000002b,0x00000030,0x0008004f,0x0000001a,0x00000032,0x00000031,0x00000031, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000002a,0x00000032,0x0004003d,0x0000001e, + 0x00000034,0x00000020,0x0004003d,0x00000007,0x00000035,0x00000016,0x0004003d,0x00000007, + 0x00000037,0x00000009,0x00050085,0x00000007,0x00000038,0x00000036,0x00000037,0x00050081, + 0x00000007,0x00000039,0x00000035,0x00000038,0x00050057,0x0000000b,0x0000003a,0x00000034, + 0x00000039,0x0008004f,0x0000001a,0x0000003b,0x0000003a,0x0000003a,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000033,0x0000003b,0x0004003d,0x0000001e,0x0000003d,0x00000020, + 0x0004003d,0x00000007,0x0000003e,0x00000016,0x0004003d,0x00000007,0x00000040,0x00000009, + 0x00050085,0x00000007,0x00000041,0x0000003f,0x00000040,0x00050081,0x00000007,0x00000042, + 0x0000003e,0x00000041,0x00050057,0x0000000b,0x00000043,0x0000003d,0x00000042,0x0008004f, + 0x0000001a,0x00000044,0x00000043,0x00000043,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x0000003c,0x00000044,0x0004003d,0x0000001e,0x00000046,0x00000020,0x0004003d,0x00000007, + 0x00000047,0x00000016,0x00050057,0x0000000b,0x00000048,0x00000046,0x00000047,0x0008004f, + 0x0000001a,0x00000049,0x00000048,0x00000048,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000045,0x00000049,0x0004003d,0x0000001a,0x0000004c,0x0000001c,0x00050094,0x00000006, + 0x00000051,0x0000004c,0x00000050,0x0003003e,0x0000004b,0x00000051,0x0004003d,0x0000001a, + 0x00000053,0x0000002a,0x00050094,0x00000006,0x00000054,0x00000053,0x00000050,0x0003003e, + 0x00000052,0x00000054,0x0004003d,0x0000001a,0x00000056,0x00000033,0x00050094,0x00000006, + 0x00000057,0x00000056,0x00000050,0x0003003e,0x00000055,0x00000057,0x0004003d,0x0000001a, + 0x00000059,0x0000003c,0x00050094,0x00000006,0x0000005a,0x00000059,0x00000050,0x0003003e, + 0x00000058,0x0000005a,0x0004003d,0x0000001a,0x0000005c,0x00000045,0x00050094,0x00000006, + 0x0000005d,0x0000005c,0x00000050,0x0003003e,0x0000005b,0x0000005d,0x0004003d,0x00000006, + 0x0000005f,0x0000005b,0x0004003d,0x00000006,0x00000060,0x0000004b,0x0004003d,0x00000006, + 0x00000061,0x00000052,0x0007000c,0x00000006,0x00000062,0x00000001,0x00000025,0x00000060, + 0x00000061,0x0004003d,0x00000006,0x00000063,0x00000055,0x0004003d,0x00000006,0x00000064, + 0x00000058,0x0007000c,0x00000006,0x00000065,0x00000001,0x00000025,0x00000063,0x00000064, + 0x0007000c,0x00000006,0x00000066,0x00000001,0x00000025,0x00000062,0x00000065,0x0007000c, + 0x00000006,0x00000067,0x00000001,0x00000025,0x0000005f,0x00000066,0x0003003e,0x0000005e, + 0x00000067,0x0004003d,0x00000006,0x00000069,0x0000005b,0x0004003d,0x00000006,0x0000006a, + 0x0000004b,0x0004003d,0x00000006,0x0000006b,0x00000052,0x0007000c,0x00000006,0x0000006c, + 0x00000001,0x00000028,0x0000006a,0x0000006b,0x0004003d,0x00000006,0x0000006d,0x00000055, + 0x0004003d,0x00000006,0x0000006e,0x00000058,0x0007000c,0x00000006,0x0000006f,0x00000001, + 0x00000028,0x0000006d,0x0000006e,0x0007000c,0x00000006,0x00000070,0x00000001,0x00000028, + 0x0000006c,0x0000006f,0x0007000c,0x00000006,0x00000071,0x00000001,0x00000028,0x00000069, + 0x00000070,0x0003003e,0x00000068,0x00000071,0x0004003d,0x00000006,0x00000073,0x0000004b, + 0x0004003d,0x00000006,0x00000074,0x00000052,0x00050081,0x00000006,0x00000075,0x00000073, + 0x00000074,0x0004003d,0x00000006,0x00000076,0x00000055,0x0004003d,0x00000006,0x00000077, + 0x00000058,0x00050081,0x00000006,0x00000078,0x00000076,0x00000077,0x00050083,0x00000006, + 0x00000079,0x00000075,0x00000078,0x0004007f,0x00000006,0x0000007a,0x00000079,0x00050041, + 0x0000004a,0x0000007d,0x00000072,0x0000007c,0x0003003e,0x0000007d,0x0000007a,0x0004003d, + 0x00000006,0x0000007e,0x0000004b,0x0004003d,0x00000006,0x0000007f,0x00000055,0x00050081, + 0x00000006,0x00000080,0x0000007e,0x0000007f,0x0004003d,0x00000006,0x00000081,0x00000052, + 0x0004003d,0x00000006,0x00000082,0x00000058,0x00050081,0x00000006,0x00000083,0x00000081, + 0x00000082,0x00050083,0x00000006,0x00000084,0x00000080,0x00000083,0x00050041,0x0000004a, + 0x00000086,0x00000072,0x00000085,0x0003003e,0x00000086,0x00000084,0x0004003d,0x00000006, + 0x00000088,0x0000004b,0x0004003d,0x00000006,0x00000089,0x00000052,0x00050081,0x00000006, + 0x0000008a,0x00000088,0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000055,0x00050081, + 0x00000006,0x0000008c,0x0000008a,0x0000008b,0x0004003d,0x00000006,0x0000008d,0x00000058, + 0x00050081,0x00000006,0x0000008e,0x0000008c,0x0000008d,0x00050085,0x00000006,0x00000090, + 0x0000008e,0x0000008f,0x00050085,0x00000006,0x00000092,0x00000090,0x00000091,0x0007000c, + 0x00000006,0x00000094,0x00000001,0x00000028,0x00000092,0x00000093,0x0003003e,0x00000087, + 0x00000094,0x00050041,0x0000004a,0x00000096,0x00000072,0x0000007c,0x0004003d,0x00000006, + 0x00000097,0x00000096,0x0006000c,0x00000006,0x00000098,0x00000001,0x00000004,0x00000097, + 0x00050041,0x0000004a,0x00000099,0x00000072,0x00000085,0x0004003d,0x00000006,0x0000009a, + 0x00000099,0x0006000c,0x00000006,0x0000009b,0x00000001,0x00000004,0x0000009a,0x0007000c, + 0x00000006,0x0000009c,0x00000001,0x00000025,0x00000098,0x0000009b,0x0004003d,0x00000006, + 0x0000009d,0x00000087,0x00050081,0x00000006,0x0000009e,0x0000009c,0x0000009d,0x00050088, + 0x00000006,0x0000009f,0x0000000a,0x0000009e,0x0003003e,0x00000095,0x0000009f,0x0004003d, + 0x00000007,0x000000a0,0x00000072,0x0004003d,0x00000006,0x000000a1,0x00000095,0x0005008e, + 0x00000007,0x000000a2,0x000000a0,0x000000a1,0x0008000c,0x00000007,0x000000a7,0x00000001, + 0x0000002b,0x000000a2,0x000000a4,0x000000a6,0x0004003d,0x00000007,0x000000a8,0x00000009, + 0x00050085,0x00000007,0x000000a9,0x000000a7,0x000000a8,0x0003003e,0x00000072,0x000000a9, + 0x0004003d,0x0000001e,0x000000ad,0x00000020,0x0004003d,0x00000007,0x000000ae,0x00000016, + 0x0004003d,0x00000007,0x000000af,0x00000072,0x0005008e,0x00000007,0x000000b1,0x000000af, + 0x000000b0,0x00050081,0x00000007,0x000000b2,0x000000ae,0x000000b1,0x00050057,0x0000000b, + 0x000000b3,0x000000ad,0x000000b2,0x0004003d,0x0000001e,0x000000b4,0x00000020,0x0004003d, + 0x00000007,0x000000b5,0x00000016,0x0004003d,0x00000007,0x000000b6,0x00000072,0x0005008e, + 0x00000007,0x000000b8,0x000000b6,0x000000b7,0x00050081,0x00000007,0x000000b9,0x000000b5, + 0x000000b8,0x00050057,0x0000000b,0x000000ba,0x000000b4,0x000000b9,0x00050081,0x0000000b, + 0x000000bb,0x000000b3,0x000000ba,0x0005008e,0x0000000b,0x000000bc,0x000000bb,0x000000ac, + 0x0003003e,0x000000ab,0x000000bc,0x0004003d,0x0000000b,0x000000be,0x000000ab,0x0005008e, + 0x0000000b,0x000000bf,0x000000be,0x000000ac,0x0004003d,0x0000001e,0x000000c0,0x00000020, + 0x0004003d,0x00000007,0x000000c1,0x00000016,0x0004003d,0x00000007,0x000000c2,0x00000072, + 0x0005008e,0x00000007,0x000000c4,0x000000c2,0x000000c3,0x00050081,0x00000007,0x000000c5, + 0x000000c1,0x000000c4,0x00050057,0x0000000b,0x000000c6,0x000000c0,0x000000c5,0x0004003d, + 0x0000001e,0x000000c7,0x00000020,0x0004003d,0x00000007,0x000000c8,0x00000016,0x0004003d, + 0x00000007,0x000000c9,0x00000072,0x0005008e,0x00000007,0x000000ca,0x000000c9,0x000000ac, + 0x00050081,0x00000007,0x000000cb,0x000000c8,0x000000ca,0x00050057,0x0000000b,0x000000cc, + 0x000000c7,0x000000cb,0x00050081,0x0000000b,0x000000cd,0x000000c6,0x000000cc,0x0005008e, + 0x0000000b,0x000000ce,0x000000cd,0x0000008f,0x00050081,0x0000000b,0x000000cf,0x000000bf, + 0x000000ce,0x0003003e,0x000000bd,0x000000cf,0x0004003d,0x0000000b,0x000000d2,0x000000bd, + 0x00050094,0x00000006,0x000000d5,0x000000d2,0x000000d4,0x0004003d,0x00000006,0x000000d6, + 0x0000005e,0x000500b8,0x000000d1,0x000000d7,0x000000d5,0x000000d6,0x000400a8,0x000000d1, + 0x000000d8,0x000000d7,0x000300f7,0x000000da,0x00000000,0x000400fa,0x000000d8,0x000000d9, + 0x000000da,0x000200f8,0x000000d9,0x0004003d,0x0000000b,0x000000db,0x000000bd,0x00050094, + 0x00000006,0x000000dc,0x000000db,0x000000d4,0x0004003d,0x00000006,0x000000dd,0x00000068, + 0x000500ba,0x000000d1,0x000000de,0x000000dc,0x000000dd,0x000200f9,0x000000da,0x000200f8, + 0x000000da,0x000700f5,0x000000d1,0x000000df,0x000000d7,0x00000005,0x000000de,0x000000d9, + 0x0004003d,0x0000000b,0x000000e0,0x000000ab,0x0004003d,0x0000000b,0x000000e1,0x000000bd, + 0x00070050,0x000000e2,0x000000e3,0x000000df,0x000000df,0x000000df,0x000000df,0x000600a9, + 0x0000000b,0x000000e4,0x000000e3,0x000000e0,0x000000e1,0x0003003e,0x000000d0,0x000000e4, + 0x0004003d,0x0000001a,0x000000e6,0x0000001c,0x0004003d,0x0000001a,0x000000e7,0x00000033, + 0x00050081,0x0000001a,0x000000e8,0x000000e6,0x000000e7,0x0005008e,0x0000001a,0x000000e9, + 0x000000e8,0x000000ac,0x0003003e,0x000000e5,0x000000e9,0x0004003d,0x0000001a,0x000000eb, + 0x0000002a,0x0004003d,0x0000001a,0x000000ec,0x0000003c,0x00050081,0x0000001a,0x000000ed, + 0x000000eb,0x000000ec,0x0005008e,0x0000001a,0x000000ee,0x000000ed,0x000000ac,0x0003003e, + 0x000000ea,0x000000ee,0x0004003d,0x0000001a,0x000000f0,0x0000001c,0x0004003d,0x0000001a, + 0x000000f1,0x0000002a,0x00050081,0x0000001a,0x000000f2,0x000000f0,0x000000f1,0x0005008e, + 0x0000001a,0x000000f3,0x000000f2,0x000000ac,0x0003003e,0x000000ef,0x000000f3,0x0004003d, + 0x0000001a,0x000000f5,0x00000033,0x0004003d,0x0000001a,0x000000f6,0x0000003c,0x00050081, + 0x0000001a,0x000000f7,0x000000f5,0x000000f6,0x0005008e,0x0000001a,0x000000f8,0x000000f7, + 0x000000ac,0x0003003e,0x000000f4,0x000000f8,0x0004003d,0x0000001a,0x000000fa,0x000000ea, + 0x0004003d,0x0000001a,0x000000fb,0x000000e5,0x00050083,0x0000001a,0x000000fc,0x000000fa, + 0x000000fb,0x0006000c,0x00000006,0x000000fd,0x00000001,0x00000042,0x000000fc,0x0003003e, + 0x000000f9,0x000000fd,0x0004003d,0x0000001a,0x000000ff,0x000000ef,0x0004003d,0x0000001a, + 0x00000100,0x000000f4,0x00050083,0x0000001a,0x00000101,0x000000ff,0x00000100,0x0006000c, + 0x00000006,0x00000102,0x00000001,0x00000042,0x00000101,0x0003003e,0x000000fe,0x00000102, + 0x0004003d,0x00000006,0x00000105,0x000000f9,0x0004003d,0x00000006,0x00000106,0x000000fe, + 0x00050081,0x00000006,0x00000107,0x00000105,0x00000106,0x0007000c,0x00000006,0x00000108, + 0x00000001,0x00000030,0x00000104,0x00000107,0x0003003e,0x00000103,0x00000108,0x0004003d, + 0x0000000b,0x0000010b,0x000000d0,0x0008004f,0x0000001a,0x0000010c,0x0000010b,0x0000010b, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000006,0x0000010e,0x00000103,0x00060050, + 0x0000001a,0x0000010f,0x0000010e,0x0000010e,0x0000010e,0x0008000c,0x0000001a,0x00000110, + 0x00000001,0x0000002e,0x0000010c,0x0000010d,0x0000010f,0x00050051,0x00000006,0x00000111, + 0x00000110,0x00000000,0x00050051,0x00000006,0x00000112,0x00000110,0x00000001,0x00050051, + 0x00000006,0x00000113,0x00000110,0x00000002,0x00070050,0x0000000b,0x00000114,0x00000111, + 0x00000112,0x00000113,0x0000000a,0x0003003e,0x0000010a,0x00000114,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/gen_shaders.sh b/app/src/main/cpp/shaders/gen_shaders.sh new file mode 100755 index 0000000000..8c583544e3 --- /dev/null +++ b/app/src/main/cpp/shaders/gen_shaders.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# ============================================================================= +# Regenerate the committed SPIR-V headers (*_frag.h / *_vert.h) for the native +# Vulkan compositor's post-process shaders. +# +# The Android NDK build does NOT compile GLSL; instead every *.frag / *.vert in +# this directory is pre-compiled to a SPIR-V uint32 array header that is #included +# by VulkanRendererContext.cpp. Run this whenever you edit a shader, then commit +# the regenerated *.h alongside the *.frag/*.vert source. +# +# Requires glslangValidator on PATH (e.g. the Vulkan SDK or the termux package). +# +# Usage: ./gen_shaders.sh # regenerate all shaders +# ./gen_shaders.sh nis crt # regenerate only the named shaders +# +# The upscalers and CAS also get a half-precision build: the same source with +# -DDD_HALF=1 -> _half_frag.h (array _half_code). The compositors +# pick the plain or the half set at start-up (debug.droiddeck.upscale.shaders). +# Names in HALF_ONLY are built half only. +# ============================================================================= +set -euo pipefail + +cd "$(dirname "$0")" + +if ! command -v glslangValidator >/dev/null 2>&1; then + echo "error: glslangValidator not found on PATH" >&2 + exit 1 +fi + +HALF=(sgsr sgsr_quality fsr_easu fsr_rcas cas_ffx nis_luma nis3) +HALF_ONLY=(cas_ffx nis_luma nis3) + +in_list() { + local x="$1"; shift + for y in "$@"; do [ "$x" = "$y" ] && return 0; done + return 1 +} + +gen() { + local src="$1" # e.g. nis.frag + local base="${src%.*}" # nis + local ext="${src##*.}" # frag | vert + if ! in_list "${base}" "${HALF_ONLY[@]}"; then + local vn="${base}_code" + if [ "$ext" = "vert" ]; then + vn="${base}_vert_code" + fi + local out="${base}_${ext}.h" + echo " ${src} -> ${out} (--vn ${vn})" + glslangValidator -V "${src}" --vn "${vn}" -o "${out}" + fi + if in_list "${base}" "${HALF[@]}"; then + local hvn="${base}_half_code" + local hout="${base}_half_${ext}.h" + echo " ${src} -> ${hout} (--vn ${hvn}, -DDD_HALF=1)" + glslangValidator -V -DDD_HALF=1 "${src}" --vn "${hvn}" -o "${hout}" + fi +} + +shaders=() +if [ "$#" -gt 0 ]; then + for name in "$@"; do + for f in "${name}.frag" "${name}.vert"; do + [ -f "$f" ] && shaders+=("$f") + done + done +else + for f in *.frag *.vert; do + [ -f "$f" ] && shaders+=("$f") + done +fi + +for s in "${shaders[@]}"; do + gen "$s" +done + +echo "done." diff --git a/app/src/main/cpp/shaders/hdr.frag b/app/src/main/cpp/shaders/hdr.frag new file mode 100644 index 0000000000..3a24ce392d --- /dev/null +++ b/app/src/main/cpp/shaders/hdr.frag @@ -0,0 +1,64 @@ +#version 450 + +// ============================================================================= +// Fake-HDR (dual-radius bloom + contrast lift) post effect. +// +// Ported from the OpenGL HDREffect.java shader so the Vulkan compositor's +// post-process pipeline applies the SAME fake-HDR the GL renderer's "HDR" +// toggle does. Binary on/off; HDRPower fixed at 1.30. Composable: runs at any +// resolution, after the optional scaling and CAS passes. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in pixels +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +const float HDRPower = 1.30; +const float radius1 = 0.793; +const float radius2 = 0.870; + +void main() { + vec2 texcoord = fragTexCoord; + vec2 px = 1.0 / pc.resolution; + + vec3 color = texture(InputTexture, texcoord).rgb; + + // --- BLOOM PASS 1 (radius1) --- + vec3 bloom_sum1 = texture(InputTexture, texcoord + vec2( 1.5, -1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2(-1.5, -1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 1.5, 1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2(-1.5, 1.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 0.0, -2.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 0.0, 2.5) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2(-2.5, 0.0) * radius1 * px).rgb; + bloom_sum1 += texture(InputTexture, texcoord + vec2( 2.5, 0.0) * radius1 * px).rgb; + bloom_sum1 *= 0.005; + + // --- BLOOM PASS 2 (radius2) --- + vec3 bloom_sum2 = texture(InputTexture, texcoord + vec2( 1.5, -1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2(-1.5, -1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 1.5, 1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2(-1.5, 1.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 0.0, -2.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 0.0, 2.5) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2(-2.5, 0.0) * radius2 * px).rgb; + bloom_sum2 += texture(InputTexture, texcoord + vec2( 2.5, 0.0) * radius2 * px).rgb; + bloom_sum2 *= 0.010; + + // --- FAKE HDR --- + float dist = radius2 - radius1; + vec3 HDR = (color + (bloom_sum2 - bloom_sum1)) * dist; + vec3 blend = HDR + color; + color = pow(abs(blend), vec3(abs(HDRPower))) + HDR; + + outColor = vec4(clamp(color, 0.0, 1.0), 1.0); +} diff --git a/app/src/main/cpp/shaders/nis.frag b/app/src/main/cpp/shaders/nis.frag new file mode 100644 index 0000000000..025fa4f251 --- /dev/null +++ b/app/src/main/cpp/shaders/nis.frag @@ -0,0 +1,458 @@ +#version 450 + +// ============================================================================= +// NVIDIA Image Scaling (NIS) - NVScaler spatial upscaler + adaptive sharpen. +// +// Ported from NVIDIA's reference NVScaler: +// NVIDIAGameWorks/NVIDIAImageScaling NIS/NIS_Scaler.h (+ NIS_Config.h) +// +// The MIT License (MIT) +// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Adapted for the Winlator native Vulkan compositor: +// - #version 450 (Vulkan GLSL), single-pass FRAGMENT shader (the reference is +// an LDS-tiled compute shader). The block/LDS cooperative tile loads are +// replaced with direct per-fragment texture() fetches of the 6x6 luma +// support, and the edge map is computed inline from that support. The math +// (edge detection + 6-tap directional scale/USM blend) is the reference's. +// - The kPhaseCount x 6 scaler/USM coefficient banks (coef_scale, coef_usm, +// fp32 path) are BAKED below as const arrays - no second descriptor binding +// (the post dsLayout has ONE sampler at binding 0 shared by all pipelines). +// - Config-UBO reads are replaced by push constants + baked SDR constants; the +// sharpness-derived params are recomputed in-shader exactly as +// NVScalerUpdateConfig does, driven by the existing "Sharpness" slider. +// - fp32 only (NOT the fp16/bit-packed NIS_USE_HALF_PRECISION path) so there +// are no bitwise/bvec ops - Adreno-compile-safe. +// - HDR mode = None (SDR). The whole compositor chain is R8G8B8A8_UNORM and +// values are display(gamma)-encoded here, matching NIS LDR expectations. +// - Reuses upscale.vert: fragTexCoord spans [0,1] across the destination rect +// (= normalised output position). With kScaleX = inputW/outputW, the source +// sample position reduces to srcX = fragTexCoord.x*inputW - 0.5 (so the +// output viewport origin/size cancel out and are never needed here). +// +// Conventions match sgsr.frag / cas.frag: combined-image-sampler at binding 0, +// push-constant block leads with vec4 ndc (offset 0, consumed by upscale.vert), +// then ViewportInfo (xy = 1/inputSize texel size, zw = inputSize px) + sharpness. +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as NVIDIA's +// NIS_USE_HALF_PRECISION path (pixels, weights, coefficient tables); positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float sharpness; // "Sharpness" slider mapped to [0..1] (NIS sharpness) +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +// ---- SDR (HDR mode None) constants, from NVScalerUpdateConfig ----------------- +const float kDetectRatio = 2.0 * 1127.0 / 1024.0; // 2.201171875 +const float kDetectThres = 64.0 / 1024.0; // 0.0625 +const float kMinContrastRatio = 2.0; +const float kMaxContrastRatio = 10.0; +const float kRatioNorm = 1.0 / (kMaxContrastRatio - kMinContrastRatio); // 0.125 +const float kContrastBoost = 1.0; +const float kEps = 1.0 / 255.0; +const float kSharpStartY = 0.45; +const float kSharpEndY = 0.9; +const float kSharpScaleY = 1.0 / (kSharpEndY - kSharpStartY); // 2.222... +const int kPhaseCount = 64; + +// Sharpness-derived params (recomputed in main from pc.sharpness, read here). +float gSharpStrengthMin; +float gSharpStrengthScale; +float gSharpLimitMin; +float gSharpLimitScale; + +const float coefScale[384] = float[384]( + 0.0, 0.0, 1.0000, 0.0, 0.0, 0.0, // phase 0 + 0.0029, -0.0127, 1.0000, 0.0132, -0.0034, 0.0, // phase 1 + 0.0063, -0.0249, 0.9985, 0.0269, -0.0068, 0.0, // phase 2 + 0.0088, -0.0361, 0.9956, 0.0415, -0.0103, 0.0005, // phase 3 + 0.0117, -0.0474, 0.9932, 0.0562, -0.0142, 0.0005, // phase 4 + 0.0142, -0.0576, 0.9897, 0.0713, -0.0181, 0.0005, // phase 5 + 0.0166, -0.0674, 0.9844, 0.0874, -0.0220, 0.0010, // phase 6 + 0.0186, -0.0762, 0.9785, 0.1040, -0.0264, 0.0015, // phase 7 + 0.0205, -0.0850, 0.9727, 0.1206, -0.0308, 0.0020, // phase 8 + 0.0225, -0.0928, 0.9648, 0.1382, -0.0352, 0.0024, // phase 9 + 0.0239, -0.1006, 0.9575, 0.1558, -0.0396, 0.0029, // phase 10 + 0.0254, -0.1074, 0.9487, 0.1738, -0.0439, 0.0034, // phase 11 + 0.0264, -0.1138, 0.9390, 0.1929, -0.0488, 0.0044, // phase 12 + 0.0278, -0.1191, 0.9282, 0.2119, -0.0537, 0.0049, // phase 13 + 0.0288, -0.1245, 0.9170, 0.2310, -0.0581, 0.0059, // phase 14 + 0.0293, -0.1294, 0.9058, 0.2510, -0.0630, 0.0063, // phase 15 + 0.0303, -0.1333, 0.8926, 0.2710, -0.0679, 0.0073, // phase 16 + 0.0308, -0.1367, 0.8789, 0.2915, -0.0728, 0.0083, // phase 17 + 0.0308, -0.1401, 0.8657, 0.3120, -0.0776, 0.0093, // phase 18 + 0.0313, -0.1426, 0.8506, 0.3330, -0.0825, 0.0103, // phase 19 + 0.0313, -0.1445, 0.8354, 0.3540, -0.0874, 0.0112, // phase 20 + 0.0313, -0.1460, 0.8193, 0.3755, -0.0923, 0.0122, // phase 21 + 0.0313, -0.1470, 0.8022, 0.3965, -0.0967, 0.0137, // phase 22 + 0.0308, -0.1479, 0.7856, 0.4185, -0.1016, 0.0146, // phase 23 + 0.0303, -0.1479, 0.7681, 0.4399, -0.1060, 0.0156, // phase 24 + 0.0298, -0.1479, 0.7505, 0.4614, -0.1104, 0.0166, // phase 25 + 0.0293, -0.1470, 0.7314, 0.4829, -0.1147, 0.0181, // phase 26 + 0.0288, -0.1460, 0.7119, 0.5049, -0.1187, 0.0190, // phase 27 + 0.0278, -0.1445, 0.6929, 0.5264, -0.1226, 0.0200, // phase 28 + 0.0273, -0.1431, 0.6724, 0.5479, -0.1260, 0.0215, // phase 29 + 0.0264, -0.1411, 0.6528, 0.5693, -0.1299, 0.0225, // phase 30 + 0.0254, -0.1387, 0.6323, 0.5903, -0.1328, 0.0234, // phase 31 + 0.0244, -0.1357, 0.6113, 0.6113, -0.1357, 0.0244, // phase 32 + 0.0234, -0.1328, 0.5903, 0.6323, -0.1387, 0.0254, // phase 33 + 0.0225, -0.1299, 0.5693, 0.6528, -0.1411, 0.0264, // phase 34 + 0.0215, -0.1260, 0.5479, 0.6724, -0.1431, 0.0273, // phase 35 + 0.0200, -0.1226, 0.5264, 0.6929, -0.1445, 0.0278, // phase 36 + 0.0190, -0.1187, 0.5049, 0.7119, -0.1460, 0.0288, // phase 37 + 0.0181, -0.1147, 0.4829, 0.7314, -0.1470, 0.0293, // phase 38 + 0.0166, -0.1104, 0.4614, 0.7505, -0.1479, 0.0298, // phase 39 + 0.0156, -0.1060, 0.4399, 0.7681, -0.1479, 0.0303, // phase 40 + 0.0146, -0.1016, 0.4185, 0.7856, -0.1479, 0.0308, // phase 41 + 0.0137, -0.0967, 0.3965, 0.8022, -0.1470, 0.0313, // phase 42 + 0.0122, -0.0923, 0.3755, 0.8193, -0.1460, 0.0313, // phase 43 + 0.0112, -0.0874, 0.3540, 0.8354, -0.1445, 0.0313, // phase 44 + 0.0103, -0.0825, 0.3330, 0.8506, -0.1426, 0.0313, // phase 45 + 0.0093, -0.0776, 0.3120, 0.8657, -0.1401, 0.0308, // phase 46 + 0.0083, -0.0728, 0.2915, 0.8789, -0.1367, 0.0308, // phase 47 + 0.0073, -0.0679, 0.2710, 0.8926, -0.1333, 0.0303, // phase 48 + 0.0063, -0.0630, 0.2510, 0.9058, -0.1294, 0.0293, // phase 49 + 0.0059, -0.0581, 0.2310, 0.9170, -0.1245, 0.0288, // phase 50 + 0.0049, -0.0537, 0.2119, 0.9282, -0.1191, 0.0278, // phase 51 + 0.0044, -0.0488, 0.1929, 0.9390, -0.1138, 0.0264, // phase 52 + 0.0034, -0.0439, 0.1738, 0.9487, -0.1074, 0.0254, // phase 53 + 0.0029, -0.0396, 0.1558, 0.9575, -0.1006, 0.0239, // phase 54 + 0.0024, -0.0352, 0.1382, 0.9648, -0.0928, 0.0225, // phase 55 + 0.0020, -0.0308, 0.1206, 0.9727, -0.0850, 0.0205, // phase 56 + 0.0015, -0.0264, 0.1040, 0.9785, -0.0762, 0.0186, // phase 57 + 0.0010, -0.0220, 0.0874, 0.9844, -0.0674, 0.0166, // phase 58 + 0.0005, -0.0181, 0.0713, 0.9897, -0.0576, 0.0142, // phase 59 + 0.0005, -0.0142, 0.0562, 0.9932, -0.0474, 0.0117, // phase 60 + 0.0005, -0.0103, 0.0415, 0.9956, -0.0361, 0.0088, // phase 61 + 0.0, -0.0068, 0.0269, 0.9985, -0.0249, 0.0063, // phase 62 + 0.0, -0.0034, 0.0132, 1.0000, -0.0127, 0.0029 // phase 63 +); + +const float coefUsm[384] = float[384]( + 0.0, -0.6001, 1.2002, -0.6001, 0.0, 0.0, // phase 0 + 0.0029, -0.6084, 1.1987, -0.5903, -0.0029, 0.0, // phase 1 + 0.0049, -0.6147, 1.1958, -0.5791, -0.0068, 0.0005, // phase 2 + 0.0073, -0.6196, 1.1890, -0.5659, -0.0103, 0.0, // phase 3 + 0.0093, -0.6235, 1.1802, -0.5513, -0.0151, 0.0, // phase 4 + 0.0112, -0.6265, 1.1699, -0.5352, -0.0195, 0.0005, // phase 5 + 0.0122, -0.6270, 1.1582, -0.5181, -0.0259, 0.0005, // phase 6 + 0.0142, -0.6284, 1.1455, -0.5005, -0.0317, 0.0005, // phase 7 + 0.0156, -0.6265, 1.1274, -0.4790, -0.0386, 0.0005, // phase 8 + 0.0166, -0.6235, 1.1089, -0.4570, -0.0454, 0.0010, // phase 9 + 0.0176, -0.6187, 1.0879, -0.4346, -0.0532, 0.0010, // phase 10 + 0.0181, -0.6138, 1.0659, -0.4102, -0.0615, 0.0015, // phase 11 + 0.0190, -0.6069, 1.0405, -0.3843, -0.0698, 0.0015, // phase 12 + 0.0195, -0.6006, 1.0161, -0.3574, -0.0796, 0.0020, // phase 13 + 0.0200, -0.5928, 0.9893, -0.3286, -0.0898, 0.0024, // phase 14 + 0.0200, -0.5820, 0.9580, -0.2988, -0.1001, 0.0029, // phase 15 + 0.0200, -0.5728, 0.9292, -0.2690, -0.1104, 0.0034, // phase 16 + 0.0200, -0.5620, 0.8975, -0.2368, -0.1226, 0.0039, // phase 17 + 0.0205, -0.5498, 0.8643, -0.2046, -0.1343, 0.0044, // phase 18 + 0.0200, -0.5371, 0.8301, -0.1709, -0.1465, 0.0049, // phase 19 + 0.0195, -0.5239, 0.7944, -0.1367, -0.1587, 0.0054, // phase 20 + 0.0195, -0.5107, 0.7598, -0.1021, -0.1724, 0.0059, // phase 21 + 0.0190, -0.4966, 0.7231, -0.0649, -0.1865, 0.0063, // phase 22 + 0.0186, -0.4819, 0.6846, -0.0288, -0.1997, 0.0068, // phase 23 + 0.0186, -0.4668, 0.6460, 0.0093, -0.2144, 0.0073, // phase 24 + 0.0176, -0.4507, 0.6055, 0.0479, -0.2290, 0.0083, // phase 25 + 0.0171, -0.4370, 0.5693, 0.0859, -0.2446, 0.0088, // phase 26 + 0.0161, -0.4199, 0.5283, 0.1255, -0.2598, 0.0098, // phase 27 + 0.0161, -0.4048, 0.4883, 0.1655, -0.2754, 0.0103, // phase 28 + 0.0151, -0.3887, 0.4497, 0.2041, -0.2910, 0.0107, // phase 29 + 0.0142, -0.3711, 0.4072, 0.2446, -0.3066, 0.0117, // phase 30 + 0.0137, -0.3555, 0.3672, 0.2852, -0.3228, 0.0122, // phase 31 + 0.0132, -0.3394, 0.3262, 0.3262, -0.3394, 0.0132, // phase 32 + 0.0122, -0.3228, 0.2852, 0.3672, -0.3555, 0.0137, // phase 33 + 0.0117, -0.3066, 0.2446, 0.4072, -0.3711, 0.0142, // phase 34 + 0.0107, -0.2910, 0.2041, 0.4497, -0.3887, 0.0151, // phase 35 + 0.0103, -0.2754, 0.1655, 0.4883, -0.4048, 0.0161, // phase 36 + 0.0098, -0.2598, 0.1255, 0.5283, -0.4199, 0.0161, // phase 37 + 0.0088, -0.2446, 0.0859, 0.5693, -0.4370, 0.0171, // phase 38 + 0.0083, -0.2290, 0.0479, 0.6055, -0.4507, 0.0176, // phase 39 + 0.0073, -0.2144, 0.0093, 0.6460, -0.4668, 0.0186, // phase 40 + 0.0068, -0.1997, -0.0288, 0.6846, -0.4819, 0.0186, // phase 41 + 0.0063, -0.1865, -0.0649, 0.7231, -0.4966, 0.0190, // phase 42 + 0.0059, -0.1724, -0.1021, 0.7598, -0.5107, 0.0195, // phase 43 + 0.0054, -0.1587, -0.1367, 0.7944, -0.5239, 0.0195, // phase 44 + 0.0049, -0.1465, -0.1709, 0.8301, -0.5371, 0.0200, // phase 45 + 0.0044, -0.1343, -0.2046, 0.8643, -0.5498, 0.0205, // phase 46 + 0.0039, -0.1226, -0.2368, 0.8975, -0.5620, 0.0200, // phase 47 + 0.0034, -0.1104, -0.2690, 0.9292, -0.5728, 0.0200, // phase 48 + 0.0029, -0.1001, -0.2988, 0.9580, -0.5820, 0.0200, // phase 49 + 0.0024, -0.0898, -0.3286, 0.9893, -0.5928, 0.0200, // phase 50 + 0.0020, -0.0796, -0.3574, 1.0161, -0.6006, 0.0195, // phase 51 + 0.0015, -0.0698, -0.3843, 1.0405, -0.6069, 0.0190, // phase 52 + 0.0015, -0.0615, -0.4102, 1.0659, -0.6138, 0.0181, // phase 53 + 0.0010, -0.0532, -0.4346, 1.0879, -0.6187, 0.0176, // phase 54 + 0.0010, -0.0454, -0.4570, 1.1089, -0.6235, 0.0166, // phase 55 + 0.0005, -0.0386, -0.4790, 1.1274, -0.6265, 0.0156, // phase 56 + 0.0005, -0.0317, -0.5005, 1.1455, -0.6284, 0.0142, // phase 57 + 0.0005, -0.0259, -0.5181, 1.1582, -0.6270, 0.0122, // phase 58 + 0.0005, -0.0195, -0.5352, 1.1699, -0.6265, 0.0112, // phase 59 + 0.0, -0.0151, -0.5513, 1.1802, -0.6235, 0.0093, // phase 60 + 0.0, -0.0103, -0.5659, 1.1890, -0.6196, 0.0073, // phase 61 + 0.0005, -0.0068, -0.5791, 1.1958, -0.6147, 0.0049, // phase 62 + 0.0, -0.0029, -0.5903, 1.1987, -0.6084, 0.0029 // phase 63 +); + +float getY(vec3 rgb) { + return dot(rgb, vec3(0.2126, 0.7152, 0.0722)); +} + +// GetEdgeMap on a 3x3 luma window (pRC: R=row 0=top, C=col 0=left). +vec4 edgeAt(float p00, float p01, float p02, + float p10, float p11, float p12, + float p20, float p21, float p22) { + float g_0 = abs(p00 + p01 + p02 - p20 - p21 - p22); + float g_45 = abs(p10 + p00 + p01 - p21 - p22 - p12); + float g_90 = abs(p00 + p10 + p20 - p02 - p12 - p22); + float g_135 = abs(p10 + p20 + p21 - p01 - p02 - p12); + + float g_0_90_max = max(g_0, g_90); + float g_0_90_min = min(g_0, g_90); + float g_45_135_max = max(g_45, g_135); + float g_45_135_min = min(g_45, g_135); + + if (g_0_90_max + g_45_135_max == 0.0) { + return vec4(0.0); + } + + float e_0_90 = g_0_90_max / (g_0_90_max + g_45_135_max); + float e_45_135 = 1.0 - e_0_90; + + bool c_0_90 = (g_0_90_max > (g_0_90_min * kDetectRatio)) && (g_0_90_max > kDetectThres) && (g_0_90_max > g_45_135_min); + bool c_45_135 = (g_45_135_max > (g_45_135_min * kDetectRatio)) && (g_45_135_max > kDetectThres) && (g_45_135_max > g_0_90_min); + bool c_g_0_90 = (g_0_90_max == g_0); + bool c_g_45_135= (g_45_135_max == g_45); + + float f_e_0_90 = (c_0_90 && c_45_135) ? e_0_90 : 1.0; + float f_e_45_135 = (c_0_90 && c_45_135) ? e_45_135 : 1.0; + + float w0 = (c_0_90 && c_g_0_90) ? f_e_0_90 : 0.0; + float w90 = (c_0_90 && !c_g_0_90) ? f_e_0_90 : 0.0; + float w45 = (c_45_135 && c_g_45_135) ? f_e_45_135 : 0.0; + float w135 = (c_45_135 && !c_g_45_135)? f_e_45_135 : 0.0; + + return vec4(w0, w90, w45, w135); +} + +vec4 getInterpEdgeMap(vec4 e00, vec4 e01, vec4 e10, vec4 e11, float fx, float fy) { + vec4 h0 = mix(e00, e01, fx); + vec4 h1 = mix(e10, e11, fx); + return mix(h0, h1, fy); +} + +float calcLTI(float p0, float p1, float p2, float p3, float p4, float p5, int phase_index) { + bool selector = (phase_index <= kPhaseCount / 2); + float sel = selector ? p0 : p3; + float a_min = min(min(p1, p2), sel); + float a_max = max(max(p1, p2), sel); + sel = selector ? p2 : p5; + float b_min = min(min(p3, p4), sel); + float b_max = max(max(p3, p4), sel); + + float a_cont = a_max - a_min; + float b_cont = b_max - b_min; + + float cont_ratio = max(a_cont, b_cont) / (min(a_cont, b_cont) + kEps); + return (1.0 - clamp((cont_ratio - kMinContrastRatio) * kRatioNorm, 0.0, 1.0)) * kContrastBoost; +} + +float evalPoly6(float pxl[6], int phase_int) { + phase_int = clamp(phase_int, 0, 63); + float y = 0.0; + float y_usm = 0.0; + for (int i = 0; i < 6; ++i) { + y += coefScale[phase_int * 6 + i] * pxl[i]; + y_usm += coefUsm[phase_int * 6 + i] * pxl[i]; + } + + // piece-wise ramp based on luma (NIS_SCALE_FLOAT == 1) + float y_scale = 1.0 - clamp((y - kSharpStartY) * kSharpScaleY, 0.0, 1.0); + float y_sharpness = y_scale * gSharpStrengthScale + gSharpStrengthMin; + y_usm *= y_sharpness; + + float y_sharpness_limit = (y_scale * gSharpLimitScale + gSharpLimitMin) * y; + y_usm = min(y_sharpness_limit, max(-y_sharpness_limit, y_usm)); + y_usm *= calcLTI(pxl[0], pxl[1], pxl[2], pxl[3], pxl[4], pxl[5], phase_int); + + return y + y_usm; +} + +float filterNormal(float p[6][6], int phase_x_int, int phase_y_int) { + phase_x_int = clamp(phase_x_int, 0, 63); + phase_y_int = clamp(phase_y_int, 0, 63); + float h_acc = 0.0; + for (int j = 0; j < 6; ++j) { + float v_acc = 0.0; + for (int i = 0; i < 6; ++i) { + v_acc += p[i][j] * coefScale[phase_y_int * 6 + i]; + } + h_acc += v_acc * coefScale[phase_x_int * 6 + j]; + } + return h_acc; +} + +float addDirFilters(float p[6][6], float phase_x_frac, float phase_y_frac, + int phase_x_frac_int, int phase_y_frac_int, vec4 w) { + float f = 0.0; + if (w.x > 0.0) { + // 0 deg filter + float interp0Deg[6]; + for (int i = 0; i < 6; ++i) { + interp0Deg[i] = mix(p[i][2], p[i][3], phase_x_frac); + } + f += evalPoly6(interp0Deg, phase_y_frac_int) * w.x; + } + if (w.y > 0.0) { + // 90 deg filter + float interp90Deg[6]; + for (int i = 0; i < 6; ++i) { + interp90Deg[i] = mix(p[2][i], p[3][i], phase_y_frac); + } + f += evalPoly6(interp90Deg, phase_x_frac_int) * w.y; + } + if (w.z > 0.0) { + // 45 deg filter + float pphase_b45 = 0.5 + 0.5 * (phase_x_frac - phase_y_frac); + + float temp_interp45Deg[7]; + temp_interp45Deg[1] = mix(p[2][1], p[1][2], pphase_b45); + temp_interp45Deg[3] = mix(p[3][2], p[2][3], pphase_b45); + temp_interp45Deg[5] = mix(p[4][3], p[3][4], pphase_b45); + { + pphase_b45 = pphase_b45 - 0.5; + float a = (pphase_b45 >= 0.0) ? p[0][2] : p[2][0]; + float b = (pphase_b45 >= 0.0) ? p[1][3] : p[3][1]; + float c = (pphase_b45 >= 0.0) ? p[2][4] : p[4][2]; + float d = (pphase_b45 >= 0.0) ? p[3][5] : p[5][3]; + temp_interp45Deg[0] = mix(p[1][1], a, abs(pphase_b45)); + temp_interp45Deg[2] = mix(p[2][2], b, abs(pphase_b45)); + temp_interp45Deg[4] = mix(p[3][3], c, abs(pphase_b45)); + temp_interp45Deg[6] = mix(p[4][4], d, abs(pphase_b45)); + } + + float interp45Deg[6]; + float pphase_p45 = phase_x_frac + phase_y_frac; + if (pphase_p45 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i + 1]; + } + pphase_p45 = pphase_p45 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i]; + } + } + + f += evalPoly6(interp45Deg, int(pphase_p45 * 64.0)) * w.z; + } + if (w.w > 0.0) { + // 135 deg filter + float pphase_b135 = 0.5 * (phase_x_frac + phase_y_frac); + + float temp_interp135Deg[7]; + temp_interp135Deg[1] = mix(p[3][1], p[4][2], pphase_b135); + temp_interp135Deg[3] = mix(p[2][2], p[3][3], pphase_b135); + temp_interp135Deg[5] = mix(p[1][3], p[2][4], pphase_b135); + { + pphase_b135 = pphase_b135 - 0.5; + float a = (pphase_b135 >= 0.0) ? p[5][2] : p[3][0]; + float b = (pphase_b135 >= 0.0) ? p[4][3] : p[2][1]; + float c = (pphase_b135 >= 0.0) ? p[3][4] : p[1][2]; + float d = (pphase_b135 >= 0.0) ? p[2][5] : p[0][3]; + temp_interp135Deg[0] = mix(p[4][1], a, abs(pphase_b135)); + temp_interp135Deg[2] = mix(p[3][2], b, abs(pphase_b135)); + temp_interp135Deg[4] = mix(p[2][3], c, abs(pphase_b135)); + temp_interp135Deg[6] = mix(p[1][4], d, abs(pphase_b135)); + } + + float interp135Deg[6]; + float pphase_p135 = 1.0 + (phase_x_frac - phase_y_frac); + if (pphase_p135 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i + 1]; + } + pphase_p135 = pphase_p135 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i]; + } + } + + f += evalPoly6(interp135Deg, int(pphase_p135 * 64.0)) * w.w; + } + return f; +} + +void main() { + // Sharpness-derived params - mirror NVScalerUpdateConfig (SDR path). + float sharpness = clamp(pc.sharpness, 0.0, 1.0); + float sharpen_slider = sharpness - 0.5; + float MaxScale = (sharpen_slider >= 0.0) ? 1.25 : 1.75; + float MinScale = (sharpen_slider >= 0.0) ? 1.25 : 1.0; + float LimitScale = MinScale; + + gSharpStrengthMin = max(0.0, 0.4 + sharpen_slider * MinScale * 1.2); + float sharpStrengthMax = 1.6 + sharpen_slider * MaxScale * 1.8; + gSharpStrengthScale = sharpStrengthMax - gSharpStrengthMin; + gSharpLimitMin = max(0.1, 0.14 + sharpen_slider * LimitScale * 0.32); + float sharpLimitMax = 0.5 + sharpen_slider * LimitScale * 0.6; + gSharpLimitScale = sharpLimitMax - gSharpLimitMin; + + highp vec2 inSize = pc.ViewportInfo.zw; + highp vec2 invIn = pc.ViewportInfo.xy; + + // Source sample position in input-pixel space (output viewport cancels out). + highp float srcX = fragTexCoord.x * inSize.x - 0.5; + highp float srcY = fragTexCoord.y * inSize.y - 0.5; + highp float fsx = floor(srcX); + highp float fsy = floor(srcY); + highp float fx = srcX - fsx; + highp float fy = srcY - fsy; + int fx_int = int(fx * float(kPhaseCount)); + int fy_int = int(fy * float(kPhaseCount)); + + // 6x6 luma support: p[i][j] = luma at source texel (fsx + j - 2, fsy + i - 2). + float p[6][6]; + for (int i = 0; i < 6; ++i) { + for (int j = 0; j < 6; ++j) { + highp vec2 tc = (vec2(fsx + float(j) - 2.0, fsy + float(i) - 2.0) + 0.5) * invIn; + p[i][j] = getY(textureLod(InputTexture, tc, 0.0).rgb); + } + } + + // 2x2 edge map around the source pixel (3x3 luma window per corner). + vec4 e00 = edgeAt(p[1][1], p[1][2], p[1][3], p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3]); + vec4 e01 = edgeAt(p[1][2], p[1][3], p[1][4], p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4]); + vec4 e10 = edgeAt(p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3], p[4][1], p[4][2], p[4][3]); + vec4 e11 = edgeAt(p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4], p[4][2], p[4][3], p[4][4]); + vec4 w = getInterpEdgeMap(e00, e01, e10, e11, fx, fy); // * NIS_SCALE_INT (==1) + + float baseWeight = 1.0 - w.x - w.y - w.z - w.w; // NIS_SCALE_FLOAT - sum + float opY = filterNormal(p, fx_int, fy_int) * baseWeight; + opY += addDirFilters(p, fx, fy, fx_int, fy_int, w); + + // Bilinear color tap (coord reduces to fragTexCoord) + luma correction. + vec4 op = texture(InputTexture, fragTexCoord); + float y = getY(op.rgb); + float corr = opY - y; // * (1/NIS_SCALE_FLOAT) == 1 + op.rgb += vec3(corr); + + outColor = vec4(clamp(op.rgb, 0.0, 1.0), 1.0); +} diff --git a/app/src/main/cpp/shaders/nis3.frag b/app/src/main/cpp/shaders/nis3.frag new file mode 100644 index 0000000000..4439f7a413 --- /dev/null +++ b/app/src/main/cpp/shaders/nis3.frag @@ -0,0 +1,357 @@ +#version 450 + +// ============================================================================= +// nis3.frag (feat/nis-rewrite): nis.frag's NVScaler maths with +// - the 6x6 luma support read from the nis_luma.frag prepass (luma in alpha) +// by 9 textureGather calls instead of 36 textureLod + getY per pixel; +// - the two coefficient banks in a uniform buffer (set 1, nis_coef.h) instead +// of const arrays: indexed by the per-pixel phase, the 384-entry const arrays +// were copied into a per-pixel variable before every lookup (glslang +// OpStore %indexable), several times per pixel. +// Edge maps and filter maths are nis.frag's. Built half only (nis3_half_frag.h); +// the old set keeps nis.frag. +// ============================================================================= + +// ============================================================================= +// NVIDIA Image Scaling (NIS) - NVScaler spatial upscaler + adaptive sharpen. +// +// Ported from NVIDIA's reference NVScaler: +// NVIDIAGameWorks/NVIDIAImageScaling NIS/NIS_Scaler.h (+ NIS_Config.h) +// +// The MIT License (MIT) +// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: MIT +// +// Adapted for the Winlator native Vulkan compositor: +// - #version 450 (Vulkan GLSL), single-pass FRAGMENT shader (the reference is +// an LDS-tiled compute shader). The block/LDS cooperative tile loads are +// replaced with direct per-fragment texture() fetches of the 6x6 luma +// support, and the edge map is computed inline from that support. The math +// (edge detection + 6-tap directional scale/USM blend) is the reference's. +// - The kPhaseCount x 6 scaler/USM coefficient banks (coef_scale, coef_usm, +// fp32 path) are BAKED below as const arrays - no second descriptor binding +// (the post dsLayout has ONE sampler at binding 0 shared by all pipelines). +// - Config-UBO reads are replaced by push constants + baked SDR constants; the +// sharpness-derived params are recomputed in-shader exactly as +// NVScalerUpdateConfig does, driven by the existing "Sharpness" slider. +// - fp32 only (NOT the fp16/bit-packed NIS_USE_HALF_PRECISION path) so there +// are no bitwise/bvec ops - Adreno-compile-safe. +// - HDR mode = None (SDR). The whole compositor chain is R8G8B8A8_UNORM and +// values are display(gamma)-encoded here, matching NIS LDR expectations. +// - Reuses upscale.vert: fragTexCoord spans [0,1] across the destination rect +// (= normalised output position). With kScaleX = inputW/outputW, the source +// sample position reduces to srcX = fragTexCoord.x*inputW - 0.5 (so the +// output viewport origin/size cancel out and are never needed here). +// +// Conventions match sgsr.frag / cas.frag: combined-image-sampler at binding 0, +// push-constant block leads with vec4 ndc (offset 0, consumed by upscale.vert), +// then ViewportInfo (xy = 1/inputSize texel size, zw = inputSize px) + sharpness. +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as NVIDIA's +// NIS_USE_HALF_PRECISION path (pixels, weights, coefficient tables); positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float sharpness; // "Sharpness" slider mapped to [0..1] (NIS sharpness) +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +// ---- SDR (HDR mode None) constants, from NVScalerUpdateConfig ----------------- +const float kDetectRatio = 2.0 * 1127.0 / 1024.0; // 2.201171875 +const float kDetectThres = 64.0 / 1024.0; // 0.0625 +const float kMinContrastRatio = 2.0; +const float kMaxContrastRatio = 10.0; +const float kRatioNorm = 1.0 / (kMaxContrastRatio - kMinContrastRatio); // 0.125 +const float kContrastBoost = 1.0; +const float kEps = 1.0 / 255.0; +const float kSharpStartY = 0.45; +const float kSharpEndY = 0.9; +const float kSharpScaleY = 1.0 / (kSharpEndY - kSharpStartY); // 2.222... +const int kPhaseCount = 64; + +// Sharpness-derived params (recomputed in main from pc.sharpness, read here). +float gSharpStrengthMin; +float gSharpStrengthScale; +float gSharpLimitMin; +float gSharpLimitScale; + +// NVIDIA NIS coef_scale / coef_usm (64 phases x 6 taps, the values nis.frag bakes), filled by the +// compositor from nis_coef.h: two vec4 per phase (taps 0-3, taps 4-5 + 2 zeros), std140. +layout(std140, set = 1, binding = 0) uniform NisCoef { + vec4 scale[128]; + vec4 usm[128]; +} nisCoef; + +float getY(vec3 rgb) { + return 0.2126 * rgb.x + 0.7152 * rgb.y + 0.0722 * rgb.z; +} + +// GetEdgeMap on a 3x3 luma window (pRC: R=row 0=top, C=col 0=left). +vec4 edgeAt(float p00, float p01, float p02, + float p10, float p11, float p12, + float p20, float p21, float p22) { + float g_0 = abs(p00 + p01 + p02 - p20 - p21 - p22); + float g_45 = abs(p10 + p00 + p01 - p21 - p22 - p12); + float g_90 = abs(p00 + p10 + p20 - p02 - p12 - p22); + float g_135 = abs(p10 + p20 + p21 - p01 - p02 - p12); + + float g_0_90_max = max(g_0, g_90); + float g_0_90_min = min(g_0, g_90); + float g_45_135_max = max(g_45, g_135); + float g_45_135_min = min(g_45, g_135); + + if (g_0_90_max + g_45_135_max == 0.0) { + return vec4(0.0); + } + + float e_0_90 = min(g_0_90_max / (g_0_90_max + g_45_135_max), 1.0); + float e_45_135 = 1.0 - e_0_90; + + bool c_0_90 = (g_0_90_max > (g_0_90_min * kDetectRatio)) && (g_0_90_max > kDetectThres) && (g_0_90_max > g_45_135_min); + bool c_45_135 = (g_45_135_max > (g_45_135_min * kDetectRatio)) && (g_45_135_max > kDetectThres) && (g_45_135_max > g_0_90_min); + bool c_g_0_90 = (g_0_90_max == g_0); + bool c_g_45_135= (g_45_135_max == g_45); + + float f_e_0_90 = (c_0_90 && c_45_135) ? e_0_90 : 1.0; + float f_e_45_135 = (c_0_90 && c_45_135) ? e_45_135 : 1.0; + + float w0 = (c_0_90 && c_g_0_90) ? f_e_0_90 : 0.0; + float w90 = (c_0_90 && !c_g_0_90) ? f_e_0_90 : 0.0; + float w45 = (c_45_135 && c_g_45_135) ? f_e_45_135 : 0.0; + float w135 = (c_45_135 && !c_g_45_135)? f_e_45_135 : 0.0; + + return vec4(w0, w90, w45, w135); +} + +vec4 getInterpEdgeMap(vec4 e00, vec4 e01, vec4 e10, vec4 e11, float fx, float fy) { + vec4 h0 = mix(e00, e01, fx); + vec4 h1 = mix(e10, e11, fx); + return mix(h0, h1, fy); +} + +float calcLTI(float p0, float p1, float p2, float p3, float p4, float p5, int phase_index) { + bool selector = (phase_index <= kPhaseCount / 2); + float sel = selector ? p0 : p3; + float a_min = min(min(p1, p2), sel); + float a_max = max(max(p1, p2), sel); + sel = selector ? p2 : p5; + float b_min = min(min(p3, p4), sel); + float b_max = max(max(p3, p4), sel); + + float a_cont = a_max - a_min; + float b_cont = b_max - b_min; + + float cont_ratio = max(a_cont, b_cont) / (min(a_cont, b_cont) + kEps); + return (1.0 - clamp((cont_ratio - kMinContrastRatio) * kRatioNorm, 0.0, 1.0)) * kContrastBoost; +} + +float evalPoly6(float pxl[6], int phase_int) { + phase_int = clamp(phase_int, 0, 63); + vec4 s0 = nisCoef.scale[phase_int * 2], s1 = nisCoef.scale[phase_int * 2 + 1]; + vec4 u0 = nisCoef.usm[phase_int * 2], u1 = nisCoef.usm[phase_int * 2 + 1]; + float y = 0.0; + y += s0.x * pxl[0]; y += s0.y * pxl[1]; y += s0.z * pxl[2]; + y += s0.w * pxl[3]; y += s1.x * pxl[4]; y += s1.y * pxl[5]; + float y_usm = 0.0; + y_usm += u0.x * pxl[0]; y_usm += u0.y * pxl[1]; y_usm += u0.z * pxl[2]; + y_usm += u0.w * pxl[3]; y_usm += u1.x * pxl[4]; y_usm += u1.y * pxl[5]; + + // piece-wise ramp based on luma (NIS_SCALE_FLOAT == 1) + float y_scale = 1.0 - clamp((y - kSharpStartY) * kSharpScaleY, 0.0, 1.0); + float y_sharpness = y_scale * gSharpStrengthScale + gSharpStrengthMin; + y_usm *= y_sharpness; + + float y_sharpness_limit = (y_scale * gSharpLimitScale + gSharpLimitMin) * y; + y_usm = min(y_sharpness_limit, max(-y_sharpness_limit, y_usm)); + y_usm *= calcLTI(pxl[0], pxl[1], pxl[2], pxl[3], pxl[4], pxl[5], phase_int); + + return y + y_usm; +} + +float filterNormal(float p[6][6], int phase_x_int, int phase_y_int) { + phase_x_int = clamp(phase_x_int, 0, 63); + phase_y_int = clamp(phase_y_int, 0, 63); + vec4 y0 = nisCoef.scale[phase_y_int * 2], y1 = nisCoef.scale[phase_y_int * 2 + 1]; + vec4 x0 = nisCoef.scale[phase_x_int * 2], x1 = nisCoef.scale[phase_x_int * 2 + 1]; + float cy[6] = float[6](y0.x, y0.y, y0.z, y0.w, y1.x, y1.y); + float cx[6] = float[6](x0.x, x0.y, x0.z, x0.w, x1.x, x1.y); + float h_acc = 0.0; + for (int j = 0; j < 6; ++j) { + float v_acc = 0.0; + for (int i = 0; i < 6; ++i) { + v_acc += p[i][j] * cy[i]; + } + h_acc += v_acc * cx[j]; + } + return h_acc; +} + +float addDirFilters(float p[6][6], float phase_x_frac, float phase_y_frac, + int phase_x_frac_int, int phase_y_frac_int, vec4 w) { + float f = 0.0; + if (w.x > 0.0) { + // 0 deg filter + float interp0Deg[6]; + for (int i = 0; i < 6; ++i) { + interp0Deg[i] = mix(p[i][2], p[i][3], phase_x_frac); + } + f += evalPoly6(interp0Deg, phase_y_frac_int) * w.x; + } + if (w.y > 0.0) { + // 90 deg filter + float interp90Deg[6]; + for (int i = 0; i < 6; ++i) { + interp90Deg[i] = mix(p[2][i], p[3][i], phase_y_frac); + } + f += evalPoly6(interp90Deg, phase_x_frac_int) * w.y; + } + if (w.z > 0.0) { + // 45 deg filter + float pphase_b45 = 0.5 + 0.5 * (phase_x_frac - phase_y_frac); + + float temp_interp45Deg[7]; + temp_interp45Deg[1] = mix(p[2][1], p[1][2], pphase_b45); + temp_interp45Deg[3] = mix(p[3][2], p[2][3], pphase_b45); + temp_interp45Deg[5] = mix(p[4][3], p[3][4], pphase_b45); + { + pphase_b45 = pphase_b45 - 0.5; + float a = (pphase_b45 >= 0.0) ? p[0][2] : p[2][0]; + float b = (pphase_b45 >= 0.0) ? p[1][3] : p[3][1]; + float c = (pphase_b45 >= 0.0) ? p[2][4] : p[4][2]; + float d = (pphase_b45 >= 0.0) ? p[3][5] : p[5][3]; + temp_interp45Deg[0] = mix(p[1][1], a, abs(pphase_b45)); + temp_interp45Deg[2] = mix(p[2][2], b, abs(pphase_b45)); + temp_interp45Deg[4] = mix(p[3][3], c, abs(pphase_b45)); + temp_interp45Deg[6] = mix(p[4][4], d, abs(pphase_b45)); + } + + float interp45Deg[6]; + float pphase_p45 = phase_x_frac + phase_y_frac; + if (pphase_p45 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i + 1]; + } + pphase_p45 = pphase_p45 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp45Deg[i] = temp_interp45Deg[i]; + } + } + + f += evalPoly6(interp45Deg, int(pphase_p45 * 64.0)) * w.z; + } + if (w.w > 0.0) { + // 135 deg filter + float pphase_b135 = 0.5 * (phase_x_frac + phase_y_frac); + + float temp_interp135Deg[7]; + temp_interp135Deg[1] = mix(p[3][1], p[4][2], pphase_b135); + temp_interp135Deg[3] = mix(p[2][2], p[3][3], pphase_b135); + temp_interp135Deg[5] = mix(p[1][3], p[2][4], pphase_b135); + { + pphase_b135 = pphase_b135 - 0.5; + float a = (pphase_b135 >= 0.0) ? p[5][2] : p[3][0]; + float b = (pphase_b135 >= 0.0) ? p[4][3] : p[2][1]; + float c = (pphase_b135 >= 0.0) ? p[3][4] : p[1][2]; + float d = (pphase_b135 >= 0.0) ? p[2][5] : p[0][3]; + temp_interp135Deg[0] = mix(p[4][1], a, abs(pphase_b135)); + temp_interp135Deg[2] = mix(p[3][2], b, abs(pphase_b135)); + temp_interp135Deg[4] = mix(p[2][3], c, abs(pphase_b135)); + temp_interp135Deg[6] = mix(p[1][4], d, abs(pphase_b135)); + } + + float interp135Deg[6]; + float pphase_p135 = 1.0 + (phase_x_frac - phase_y_frac); + if (pphase_p135 >= 1.0) { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i + 1]; + } + pphase_p135 = pphase_p135 - 1.0; + } else { + for (int i = 0; i < 6; ++i) { + interp135Deg[i] = temp_interp135Deg[i]; + } + } + + f += evalPoly6(interp135Deg, int(pphase_p135 * 64.0)) * w.w; + } + return f; +} + +void main() { + // Sharpness-derived params - mirror NVScalerUpdateConfig (SDR path). + float sharpness = clamp(pc.sharpness, 0.0, 1.0); + float sharpen_slider = sharpness - 0.5; + float MaxScale = (sharpen_slider >= 0.0) ? 1.25 : 1.75; + float MinScale = (sharpen_slider >= 0.0) ? 1.25 : 1.0; + float LimitScale = (sharpen_slider >= 0.0) ? 1.25 : 1.0; + + gSharpStrengthMin = max(0.0, 0.4 + sharpen_slider * MinScale * 1.2); + float sharpStrengthMax = 1.6 + sharpen_slider * MaxScale * 1.8; + gSharpStrengthScale = sharpStrengthMax - gSharpStrengthMin; + gSharpLimitMin = max(0.1, 0.14 + sharpen_slider * LimitScale * 0.32); + float sharpLimitMax = 0.5 + sharpen_slider * LimitScale * 0.6; + gSharpLimitScale = sharpLimitMax - gSharpLimitMin; + + highp vec2 inSize = pc.ViewportInfo.zw; + highp vec2 invIn = pc.ViewportInfo.xy; + + // Source sample position in input-pixel space (output viewport cancels out). + highp float srcX = fragTexCoord.x * inSize.x - 0.5; + highp float srcY = fragTexCoord.y * inSize.y - 0.5; + highp float fsx = floor(srcX); + highp float fsy = floor(srcY); + highp float fx = srcX - fsx; + highp float fy = srcY - fsy; + int fx_int = int(fx * float(kPhaseCount)); + int fy_int = int(fy * float(kPhaseCount)); + + // 6x6 luma support: p[i][j] = luma at source texel (fsx + j - 2, fsy + i - 2), from the + // prepass alpha. A gather at the shared corner of texels (x, y)..(x + 1, y + 1) returns + // .w = (x, y), .z = (x + 1, y), .x = (x, y + 1), .y = (x + 1, y + 1); block (bi, bj) starts + // at x = fsx - 2 + 2 bj, y = fsy - 2 + 2 bi, so its corner is (fsx + 2 bj - 1, fsy + 2 bi - 1). + // Clamp-to-edge clamps each gathered texel like the per-texel fetches did. + float p[6][6]; + for (int bi = 0; bi < 3; ++bi) { + for (int bj = 0; bj < 3; ++bj) { + highp vec2 tc = vec2(fsx + float(2 * bj - 1), fsy + float(2 * bi - 1)) * invIn; + vec4 g = textureGather(InputTexture, tc, 3); + p[2 * bi][2 * bj] = g.w; + p[2 * bi][2 * bj + 1] = g.z; + p[2 * bi + 1][2 * bj] = g.x; + p[2 * bi + 1][2 * bj + 1] = g.y; + } + } + + // 2x2 edge map around the source pixel (3x3 luma window per corner). + vec4 e00 = edgeAt(p[1][1], p[1][2], p[1][3], p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3]); + vec4 e01 = edgeAt(p[1][2], p[1][3], p[1][4], p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4]); + vec4 e10 = edgeAt(p[2][1], p[2][2], p[2][3], p[3][1], p[3][2], p[3][3], p[4][1], p[4][2], p[4][3]); + vec4 e11 = edgeAt(p[2][2], p[2][3], p[2][4], p[3][2], p[3][3], p[3][4], p[4][2], p[4][3], p[4][4]); + vec4 w = getInterpEdgeMap(e00, e01, e10, e11, fx, fy); // * NIS_SCALE_INT (==1) + + float baseWeight = 1.0 - w.x - w.y - w.z - w.w; // NIS_SCALE_FLOAT - sum + float opY = filterNormal(p, fx_int, fy_int) * baseWeight; + opY += addDirFilters(p, fx, fy, fx_int, fy_int, w); + + // Bilinear color tap from the prepass rgb (= the game image) + luma correction. + vec4 op = texture(InputTexture, fragTexCoord); + float y = getY(op.rgb); + float corr = opY - y; // * (1/NIS_SCALE_FLOAT) == 1 + op.rgb += vec3(corr); + + outColor = vec4(clamp(op.rgb, 0.0, 1.0), 1.0); +} diff --git a/app/src/main/cpp/shaders/nis3_half_frag.h b/app/src/main/cpp/shaders/nis3_half_frag.h new file mode 100644 index 0000000000..7603498099 --- /dev/null +++ b/app/src/main/cpp/shaders/nis3_half_frag.h @@ -0,0 +1,1364 @@ + // 1116.2.0 + #pragma once +const uint32_t nis3_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000005a2,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000462,0x00000595,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00050005,0x0000000b,0x59746567,0x33667628,0x0000003b,0x00030005,0x0000000a, + 0x00626772,0x000b0005,0x00000019,0x65676465,0x66287441,0x31663b31,0x3b31663b,0x663b3166, + 0x31663b31,0x3b31663b,0x663b3166,0x00003b31,0x00030005,0x00000010,0x00303070,0x00030005, + 0x00000011,0x00313070,0x00030005,0x00000012,0x00323070,0x00030005,0x00000013,0x00303170, + 0x00030005,0x00000014,0x00313170,0x00030005,0x00000015,0x00323170,0x00030005,0x00000016, + 0x00303270,0x00030005,0x00000017,0x00313270,0x00030005,0x00000018,0x00323270,0x000c0005, + 0x00000023,0x49746567,0x7265746e,0x67644570,0x70614d65,0x34667628,0x3466763b,0x3466763b, + 0x3466763b,0x3b31663b,0x003b3166,0x00030005,0x0000001d,0x00303065,0x00030005,0x0000001e, + 0x00313065,0x00030005,0x0000001f,0x00303165,0x00030005,0x00000020,0x00313165,0x00030005, + 0x00000021,0x00007866,0x00030005,0x00000022,0x00007966,0x000a0005,0x0000002f,0x636c6163, + 0x2849544c,0x663b3166,0x31663b31,0x3b31663b,0x663b3166,0x31693b31,0x0000003b,0x00030005, + 0x00000028,0x00003070,0x00030005,0x00000029,0x00003170,0x00030005,0x0000002a,0x00003270, + 0x00030005,0x0000002b,0x00003370,0x00030005,0x0000002c,0x00003470,0x00030005,0x0000002d, + 0x00003570,0x00050005,0x0000002e,0x73616870,0x6e695f65,0x00786564,0x00070005,0x00000038, + 0x6c617665,0x796c6f50,0x31662836,0x3b5d365b,0x003b3169,0x00030005,0x00000036,0x006c7870, + 0x00050005,0x00000037,0x73616870,0x6e695f65,0x00000074,0x000a0005,0x00000040,0x746c6966, + 0x6f4e7265,0x6c616d72,0x5b316628,0x365b5d36,0x31693b5d,0x3b31693b,0x00000000,0x00030005, + 0x0000003d,0x00000070,0x00050005,0x0000003e,0x73616870,0x5f785f65,0x00746e69,0x00050005, + 0x0000003f,0x73616870,0x5f795f65,0x00746e69,0x000c0005,0x00000049,0x44646461,0x69467269, + 0x7265746c,0x31662873,0x5b5d365b,0x663b5d36,0x31663b31,0x3b31693b,0x763b3169,0x003b3466, + 0x00030005,0x00000043,0x00000070,0x00060005,0x00000044,0x73616870,0x5f785f65,0x63617266, + 0x00000000,0x00060005,0x00000045,0x73616870,0x5f795f65,0x63617266,0x00000000,0x00070005, + 0x00000046,0x73616870,0x5f785f65,0x63617266,0x746e695f,0x00000000,0x00070005,0x00000047, + 0x73616870,0x5f795f65,0x63617266,0x746e695f,0x00000000,0x00030005,0x00000048,0x00000077, + 0x00030005,0x0000005e,0x00305f67,0x00040005,0x0000006b,0x35345f67,0x00000000,0x00040005, + 0x00000078,0x30395f67,0x00000000,0x00040005,0x00000085,0x33315f67,0x00000035,0x00050005, + 0x00000092,0x5f305f67,0x6d5f3039,0x00007861,0x00050005,0x00000096,0x5f305f67,0x6d5f3039, + 0x00006e69,0x00060005,0x0000009a,0x35345f67,0x3533315f,0x78616d5f,0x00000000,0x00060005, + 0x0000009e,0x35345f67,0x3533315f,0x6e696d5f,0x00000000,0x00040005,0x000000ac,0x5f305f65, + 0x00003039,0x00050005,0x000000b4,0x35345f65,0x3533315f,0x00000000,0x00040005,0x000000b8, + 0x5f305f63,0x00003039,0x00050005,0x000000c6,0x35345f63,0x3533315f,0x00000000,0x00050005, + 0x000000d2,0x5f675f63,0x30395f30,0x00000000,0x00050005,0x000000d6,0x5f675f63,0x315f3534, + 0x00003533,0x00050005,0x000000da,0x5f655f66,0x30395f30,0x00000000,0x00050005,0x000000e0, + 0x5f655f66,0x315f3534,0x00003533,0x00030005,0x000000e6,0x00003077,0x00030005,0x000000ec, + 0x00303977,0x00030005,0x000000f3,0x00353477,0x00040005,0x000000f9,0x35333177,0x00000000, + 0x00030005,0x00000107,0x00003068,0x00030005,0x0000010d,0x00003168,0x00050005,0x0000011a, + 0x656c6573,0x726f7463,0x00000000,0x00030005,0x0000011e,0x006c6573,0x00040005,0x00000123, + 0x696d5f61,0x0000006e,0x00040005,0x00000129,0x616d5f61,0x00000078,0x00040005,0x00000133, + 0x696d5f62,0x0000006e,0x00040005,0x00000139,0x616d5f62,0x00000078,0x00040005,0x0000013f, + 0x6f635f61,0x0000746e,0x00040005,0x00000143,0x6f635f62,0x0000746e,0x00050005,0x00000147, + 0x746e6f63,0x7461725f,0x00006f69,0x00030005,0x0000015f,0x00003073,0x00040005,0x00000163, + 0x4373694e,0x0066656f,0x00050006,0x00000163,0x00000000,0x6c616373,0x00000065,0x00040006, + 0x00000163,0x00000001,0x006d7375,0x00040005,0x00000165,0x4373696e,0x0066656f,0x00030005, + 0x0000016c,0x00003173,0x00030005,0x00000173,0x00003075,0x00030005,0x00000178,0x00003175, + 0x00030005,0x0000017e,0x00000079,0x00040005,0x000001ad,0x73755f79,0x0000006d,0x00040005, + 0x000001d8,0x63735f79,0x00656c61,0x00050005,0x000001e0,0x68735f79,0x6e707261,0x00737365, + 0x00070005,0x000001e3,0x61685367,0x74537072,0x676e6572,0x63536874,0x00656c61,0x00070005, + 0x000001e6,0x61685367,0x74537072,0x676e6572,0x694d6874,0x0000006e,0x00070005,0x000001ec, + 0x68735f79,0x6e707261,0x5f737365,0x696d696c,0x00000074,0x00070005,0x000001ee,0x61685367, + 0x694c7072,0x5374696d,0x656c6163,0x00000000,0x00060005,0x000001f1,0x61685367,0x694c7072, + 0x4d74696d,0x00006e69,0x00040005,0x000001fc,0x61726170,0x0000006d,0x00040005,0x000001ff, + 0x61726170,0x0000006d,0x00040005,0x00000202,0x61726170,0x0000006d,0x00040005,0x00000205, + 0x61726170,0x0000006d,0x00040005,0x00000208,0x61726170,0x0000006d,0x00040005,0x0000020b, + 0x61726170,0x0000006d,0x00040005,0x0000020e,0x61726170,0x0000006d,0x00030005,0x0000021c, + 0x00003079,0x00030005,0x00000221,0x00003179,0x00030005,0x00000227,0x00003078,0x00030005, + 0x0000022c,0x00003178,0x00030005,0x00000232,0x00007963,0x00030005,0x00000240,0x00007863, + 0x00040005,0x0000024e,0x63615f68,0x00000063,0x00030005,0x0000024f,0x0000006a,0x00040005, + 0x00000258,0x63615f76,0x00000063,0x00030005,0x00000259,0x00000069,0x00030005,0x00000279, + 0x00000066,0x00030005,0x0000027f,0x00000069,0x00050005,0x00000287,0x65746e69,0x44307072, + 0x00006765,0x00040005,0x00000294,0x61726170,0x0000006d,0x00040005,0x00000296,0x61726170, + 0x0000006d,0x00030005,0x000002a3,0x00000069,0x00050005,0x000002ab,0x65746e69,0x30397072, + 0x00676544,0x00040005,0x000002b8,0x61726170,0x0000006d,0x00040005,0x000002ba,0x61726170, + 0x0000006d,0x00050005,0x000002c7,0x61687070,0x625f6573,0x00003534,0x00070005,0x000002d1, + 0x706d6574,0x746e695f,0x34707265,0x67654435,0x00000000,0x00030005,0x000002e9,0x00000061, + 0x00030005,0x000002f5,0x00000062,0x00030005,0x00000301,0x00000063,0x00030005,0x0000030d, + 0x00000064,0x00050005,0x00000335,0x61687070,0x705f6573,0x00003534,0x00030005,0x0000033d, + 0x00000069,0x00050005,0x00000345,0x65746e69,0x35347072,0x00676544,0x00030005,0x00000351, + 0x00000069,0x00040005,0x00000364,0x61726170,0x0000006d,0x00040005,0x00000366,0x61726170, + 0x0000006d,0x00050005,0x00000372,0x61687070,0x625f6573,0x00353331,0x00070005,0x00000377, + 0x706d6574,0x746e695f,0x31707265,0x65443533,0x00000067,0x00030005,0x0000038f,0x00000061, + 0x00030005,0x0000039b,0x00000062,0x00030005,0x000003a7,0x00000063,0x00030005,0x000003b3, + 0x00000064,0x00050005,0x000003db,0x61687070,0x705f6573,0x00353331,0x00030005,0x000003e4, + 0x00000069,0x00060005,0x000003ec,0x65746e69,0x33317072,0x67654435,0x00000000,0x00030005, + 0x000003f8,0x00000069,0x00040005,0x0000040a,0x61726170,0x0000006d,0x00040005,0x0000040c, + 0x61726170,0x0000006d,0x00050005,0x00000416,0x72616873,0x73656e70,0x00000073,0x00030005, + 0x00000417,0x00004350,0x00040006,0x00000417,0x00000000,0x0063646e,0x00070006,0x00000417, + 0x00000001,0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00060006,0x00000417,0x00000002, + 0x72616873,0x73656e70,0x00000073,0x00030005,0x00000419,0x00006370,0x00060005,0x0000041e, + 0x72616873,0x5f6e6570,0x64696c73,0x00007265,0x00050005,0x00000421,0x5378614d,0x656c6163, + 0x00000000,0x00050005,0x00000427,0x536e694d,0x656c6163,0x00000000,0x00050005,0x0000042b, + 0x696d694c,0x61635374,0x0000656c,0x00070005,0x00000437,0x72616873,0x72745370,0x74676e65, + 0x78614d68,0x00000000,0x00060005,0x0000044b,0x72616873,0x6d694c70,0x614d7469,0x00000078, + 0x00040005,0x00000457,0x69536e69,0x0000657a,0x00040005,0x0000045c,0x49766e69,0x0000006e, + 0x00040005,0x00000460,0x58637273,0x00000000,0x00060005,0x00000462,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x0000046a,0x59637273,0x00000000,0x00030005,0x00000471, + 0x00787366,0x00030005,0x00000474,0x00797366,0x00030005,0x00000477,0x00007866,0x00030005, + 0x0000047b,0x00007966,0x00040005,0x0000047f,0x695f7866,0x0000746e,0x00040005,0x00000483, + 0x695f7966,0x0000746e,0x00030005,0x00000487,0x00006962,0x00030005,0x0000048f,0x00006a62, + 0x00030005,0x00000497,0x00006374,0x00030005,0x000004a7,0x00000067,0x00060005,0x000004ab, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x000004af,0x00000070,0x00030005, + 0x000004d4,0x00303065,0x00040005,0x000004d5,0x61726170,0x0000006d,0x00040005,0x000004d8, + 0x61726170,0x0000006d,0x00040005,0x000004db,0x61726170,0x0000006d,0x00040005,0x000004de, + 0x61726170,0x0000006d,0x00040005,0x000004e1,0x61726170,0x0000006d,0x00040005,0x000004e4, + 0x61726170,0x0000006d,0x00040005,0x000004e7,0x61726170,0x0000006d,0x00040005,0x000004ea, + 0x61726170,0x0000006d,0x00040005,0x000004ed,0x61726170,0x0000006d,0x00030005,0x000004f1, + 0x00313065,0x00040005,0x000004f2,0x61726170,0x0000006d,0x00040005,0x000004f5,0x61726170, + 0x0000006d,0x00040005,0x000004f8,0x61726170,0x0000006d,0x00040005,0x000004fb,0x61726170, + 0x0000006d,0x00040005,0x000004fe,0x61726170,0x0000006d,0x00040005,0x00000501,0x61726170, + 0x0000006d,0x00040005,0x00000504,0x61726170,0x0000006d,0x00040005,0x00000507,0x61726170, + 0x0000006d,0x00040005,0x0000050a,0x61726170,0x0000006d,0x00030005,0x0000050e,0x00303165, + 0x00040005,0x0000050f,0x61726170,0x0000006d,0x00040005,0x00000512,0x61726170,0x0000006d, + 0x00040005,0x00000515,0x61726170,0x0000006d,0x00040005,0x00000518,0x61726170,0x0000006d, + 0x00040005,0x0000051b,0x61726170,0x0000006d,0x00040005,0x0000051e,0x61726170,0x0000006d, + 0x00040005,0x00000521,0x61726170,0x0000006d,0x00040005,0x00000524,0x61726170,0x0000006d, + 0x00040005,0x00000527,0x61726170,0x0000006d,0x00030005,0x0000052b,0x00313165,0x00040005, + 0x0000052c,0x61726170,0x0000006d,0x00040005,0x0000052f,0x61726170,0x0000006d,0x00040005, + 0x00000532,0x61726170,0x0000006d,0x00040005,0x00000535,0x61726170,0x0000006d,0x00040005, + 0x00000538,0x61726170,0x0000006d,0x00040005,0x0000053b,0x61726170,0x0000006d,0x00040005, + 0x0000053e,0x61726170,0x0000006d,0x00040005,0x00000541,0x61726170,0x0000006d,0x00040005, + 0x00000544,0x61726170,0x0000006d,0x00030005,0x00000548,0x00000077,0x00040005,0x00000549, + 0x61726170,0x0000006d,0x00040005,0x0000054b,0x61726170,0x0000006d,0x00040005,0x0000054d, + 0x61726170,0x0000006d,0x00040005,0x0000054f,0x61726170,0x0000006d,0x00040005,0x00000551, + 0x61726170,0x0000006d,0x00040005,0x00000553,0x61726170,0x0000006d,0x00050005,0x00000556, + 0x65736162,0x67696557,0x00007468,0x00030005,0x00000563,0x0059706f,0x00040005,0x00000564, + 0x61726170,0x0000006d,0x00040005,0x00000566,0x61726170,0x0000006d,0x00040005,0x00000568, + 0x61726170,0x0000006d,0x00040005,0x0000056d,0x61726170,0x0000006d,0x00040005,0x0000056f, + 0x61726170,0x0000006d,0x00040005,0x00000571,0x61726170,0x0000006d,0x00040005,0x00000573, + 0x61726170,0x0000006d,0x00040005,0x00000575,0x61726170,0x0000006d,0x00040005,0x00000577, + 0x61726170,0x0000006d,0x00030005,0x0000057c,0x0000706f,0x00030005,0x00000580,0x00000079, + 0x00040005,0x00000581,0x61726170,0x0000006d,0x00040005,0x00000585,0x72726f63,0x00000000, + 0x00050005,0x00000595,0x4374756f,0x726f6c6f,0x00000000,0x00030047,0x0000000a,0x00000000, + 0x00030047,0x0000000b,0x00000000,0x00030047,0x00000010,0x00000000,0x00030047,0x00000011, + 0x00000000,0x00030047,0x00000012,0x00000000,0x00030047,0x00000013,0x00000000,0x00030047, + 0x00000014,0x00000000,0x00030047,0x00000015,0x00000000,0x00030047,0x00000016,0x00000000, + 0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,0x00000000,0x00030047,0x00000019, + 0x00000000,0x00030047,0x0000001d,0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047, + 0x0000001f,0x00000000,0x00030047,0x00000020,0x00000000,0x00030047,0x00000021,0x00000000, + 0x00030047,0x00000022,0x00000000,0x00030047,0x00000023,0x00000000,0x00030047,0x00000028, + 0x00000000,0x00030047,0x00000029,0x00000000,0x00030047,0x0000002a,0x00000000,0x00030047, + 0x0000002b,0x00000000,0x00030047,0x0000002c,0x00000000,0x00030047,0x0000002d,0x00000000, + 0x00030047,0x0000002f,0x00000000,0x00030047,0x00000036,0x00000000,0x00030047,0x00000038, + 0x00000000,0x00030047,0x0000003d,0x00000000,0x00030047,0x00000040,0x00000000,0x00030047, + 0x00000043,0x00000000,0x00030047,0x00000044,0x00000000,0x00030047,0x00000045,0x00000000, + 0x00030047,0x00000048,0x00000000,0x00030047,0x00000049,0x00000000,0x00030047,0x0000004e, + 0x00000000,0x00030047,0x0000004f,0x00000000,0x00030047,0x00000053,0x00000000,0x00030047, + 0x00000054,0x00000000,0x00030047,0x00000055,0x00000000,0x00030047,0x00000059,0x00000000, + 0x00030047,0x0000005a,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x0000005e, + 0x00000000,0x00030047,0x0000005f,0x00000000,0x00030047,0x00000060,0x00000000,0x00030047, + 0x00000061,0x00000000,0x00030047,0x00000062,0x00000000,0x00030047,0x00000063,0x00000000, + 0x00030047,0x00000064,0x00000000,0x00030047,0x00000065,0x00000000,0x00030047,0x00000066, + 0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x00000068,0x00000000,0x00030047, + 0x00000069,0x00000000,0x00030047,0x0000006a,0x00000000,0x00030047,0x0000006b,0x00000000, + 0x00030047,0x0000006c,0x00000000,0x00030047,0x0000006d,0x00000000,0x00030047,0x0000006e, + 0x00000000,0x00030047,0x0000006f,0x00000000,0x00030047,0x00000070,0x00000000,0x00030047, + 0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,0x00030047,0x00000073,0x00000000, + 0x00030047,0x00000074,0x00000000,0x00030047,0x00000075,0x00000000,0x00030047,0x00000076, + 0x00000000,0x00030047,0x00000077,0x00000000,0x00030047,0x00000078,0x00000000,0x00030047, + 0x00000079,0x00000000,0x00030047,0x0000007a,0x00000000,0x00030047,0x0000007b,0x00000000, + 0x00030047,0x0000007c,0x00000000,0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e, + 0x00000000,0x00030047,0x0000007f,0x00000000,0x00030047,0x00000080,0x00000000,0x00030047, + 0x00000081,0x00000000,0x00030047,0x00000082,0x00000000,0x00030047,0x00000083,0x00000000, + 0x00030047,0x00000084,0x00000000,0x00030047,0x00000085,0x00000000,0x00030047,0x00000086, + 0x00000000,0x00030047,0x00000087,0x00000000,0x00030047,0x00000088,0x00000000,0x00030047, + 0x00000089,0x00000000,0x00030047,0x0000008a,0x00000000,0x00030047,0x0000008b,0x00000000, + 0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e, + 0x00000000,0x00030047,0x0000008f,0x00000000,0x00030047,0x00000090,0x00000000,0x00030047, + 0x00000091,0x00000000,0x00030047,0x00000092,0x00000000,0x00030047,0x00000093,0x00000000, + 0x00030047,0x00000094,0x00000000,0x00030047,0x00000095,0x00000000,0x00030047,0x00000096, + 0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,0x00030047, + 0x00000099,0x00000000,0x00030047,0x0000009a,0x00000000,0x00030047,0x0000009b,0x00000000, + 0x00030047,0x0000009c,0x00000000,0x00030047,0x0000009d,0x00000000,0x00030047,0x0000009e, + 0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047, + 0x000000a1,0x00000000,0x00030047,0x000000a2,0x00000000,0x00030047,0x000000a3,0x00000000, + 0x00030047,0x000000a4,0x00000000,0x00030047,0x000000ac,0x00000000,0x00030047,0x000000ad, + 0x00000000,0x00030047,0x000000ae,0x00000000,0x00030047,0x000000af,0x00000000,0x00030047, + 0x000000b0,0x00000000,0x00030047,0x000000b1,0x00000000,0x00030047,0x000000b2,0x00000000, + 0x00030047,0x000000b3,0x00000000,0x00030047,0x000000b4,0x00000000,0x00030047,0x000000b5, + 0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047, + 0x000000ba,0x00000000,0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000, + 0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,0x00000000,0x00030047,0x000000c2, + 0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047,0x000000c7,0x00000000,0x00030047, + 0x000000c8,0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,0x000000cb,0x00000000, + 0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d3, + 0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d7,0x00000000,0x00030047, + 0x000000d8,0x00000000,0x00030047,0x000000da,0x00000000,0x00030047,0x000000de,0x00000000, + 0x00030047,0x000000e0,0x00000000,0x00030047,0x000000e4,0x00000000,0x00030047,0x000000e6, + 0x00000000,0x00030047,0x000000ea,0x00000000,0x00030047,0x000000ec,0x00000000,0x00030047, + 0x000000f1,0x00000000,0x00030047,0x000000f3,0x00000000,0x00030047,0x000000f7,0x00000000, + 0x00030047,0x000000f9,0x00000000,0x00030047,0x000000fe,0x00000000,0x00030047,0x00000100, + 0x00000000,0x00030047,0x00000101,0x00000000,0x00030047,0x00000102,0x00000000,0x00030047, + 0x00000103,0x00000000,0x00030047,0x00000104,0x00000000,0x00030047,0x00000107,0x00000000, + 0x00030047,0x00000108,0x00000000,0x00030047,0x00000109,0x00000000,0x00030047,0x0000010a, + 0x00000000,0x00030047,0x0000010b,0x00000000,0x00030047,0x0000010c,0x00000000,0x00030047, + 0x0000010d,0x00000000,0x00030047,0x0000010e,0x00000000,0x00030047,0x0000010f,0x00000000, + 0x00030047,0x00000110,0x00000000,0x00030047,0x00000111,0x00000000,0x00030047,0x00000112, + 0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114,0x00000000,0x00030047, + 0x00000115,0x00000000,0x00030047,0x00000116,0x00000000,0x00030047,0x00000117,0x00000000, + 0x00030047,0x0000011e,0x00000000,0x00030047,0x00000120,0x00000000,0x00030047,0x00000121, + 0x00000000,0x00030047,0x00000123,0x00000000,0x00030047,0x00000124,0x00000000,0x00030047, + 0x00000125,0x00000000,0x00030047,0x00000126,0x00000000,0x00030047,0x00000127,0x00000000, + 0x00030047,0x00000128,0x00000000,0x00030047,0x00000129,0x00000000,0x00030047,0x0000012a, + 0x00000000,0x00030047,0x0000012b,0x00000000,0x00030047,0x0000012c,0x00000000,0x00030047, + 0x0000012d,0x00000000,0x00030047,0x0000012e,0x00000000,0x00030047,0x00000130,0x00000000, + 0x00030047,0x00000131,0x00000000,0x00030047,0x00000133,0x00000000,0x00030047,0x00000134, + 0x00000000,0x00030047,0x00000135,0x00000000,0x00030047,0x00000136,0x00000000,0x00030047, + 0x00000137,0x00000000,0x00030047,0x00000138,0x00000000,0x00030047,0x00000139,0x00000000, + 0x00030047,0x0000013a,0x00000000,0x00030047,0x0000013b,0x00000000,0x00030047,0x0000013c, + 0x00000000,0x00030047,0x0000013d,0x00000000,0x00030047,0x0000013e,0x00000000,0x00030047, + 0x0000013f,0x00000000,0x00030047,0x00000140,0x00000000,0x00030047,0x00000141,0x00000000, + 0x00030047,0x00000142,0x00000000,0x00030047,0x00000143,0x00000000,0x00030047,0x00000144, + 0x00000000,0x00030047,0x00000145,0x00000000,0x00030047,0x00000146,0x00000000,0x00030047, + 0x00000147,0x00000000,0x00030047,0x00000148,0x00000000,0x00030047,0x00000149,0x00000000, + 0x00030047,0x0000014a,0x00000000,0x00030047,0x0000014b,0x00000000,0x00030047,0x0000014c, + 0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014e,0x00000000,0x00030047, + 0x0000014f,0x00000000,0x00030047,0x00000150,0x00000000,0x00030047,0x00000151,0x00000000, + 0x00030047,0x00000152,0x00000000,0x00030047,0x00000153,0x00000000,0x00030047,0x00000154, + 0x00000000,0x00030047,0x00000155,0x00000000,0x00030047,0x00000156,0x00000000,0x00030047, + 0x00000157,0x00000000,0x00030047,0x00000158,0x00000000,0x00030047,0x0000015f,0x00000000, + 0x00040047,0x00000161,0x00000006,0x00000010,0x00040047,0x00000162,0x00000006,0x00000010, + 0x00030047,0x00000163,0x00000002,0x00040048,0x00000163,0x00000000,0x00000000,0x00050048, + 0x00000163,0x00000000,0x00000023,0x00000000,0x00040048,0x00000163,0x00000001,0x00000000, + 0x00050048,0x00000163,0x00000001,0x00000023,0x00000800,0x00040047,0x00000165,0x00000021, + 0x00000000,0x00040047,0x00000165,0x00000022,0x00000001,0x00030047,0x0000016b,0x00000000, + 0x00030047,0x0000016c,0x00000000,0x00030047,0x00000172,0x00000000,0x00030047,0x00000173, + 0x00000000,0x00030047,0x00000177,0x00000000,0x00030047,0x00000178,0x00000000,0x00030047, + 0x0000017d,0x00000000,0x00030047,0x0000017e,0x00000000,0x00030047,0x00000180,0x00000000, + 0x00030047,0x00000182,0x00000000,0x00030047,0x00000183,0x00000000,0x00030047,0x00000184, + 0x00000000,0x00030047,0x00000185,0x00000000,0x00030047,0x00000187,0x00000000,0x00030047, + 0x00000189,0x00000000,0x00030047,0x0000018a,0x00000000,0x00030047,0x0000018b,0x00000000, + 0x00030047,0x0000018c,0x00000000,0x00030047,0x0000018e,0x00000000,0x00030047,0x00000190, + 0x00000000,0x00030047,0x00000191,0x00000000,0x00030047,0x00000192,0x00000000,0x00030047, + 0x00000193,0x00000000,0x00030047,0x00000196,0x00000000,0x00030047,0x00000199,0x00000000, + 0x00030047,0x0000019a,0x00000000,0x00030047,0x0000019b,0x00000000,0x00030047,0x0000019c, + 0x00000000,0x00030047,0x0000019e,0x00000000,0x00030047,0x000001a1,0x00000000,0x00030047, + 0x000001a2,0x00000000,0x00030047,0x000001a3,0x00000000,0x00030047,0x000001a4,0x00000000, + 0x00030047,0x000001a6,0x00000000,0x00030047,0x000001a9,0x00000000,0x00030047,0x000001aa, + 0x00000000,0x00030047,0x000001ab,0x00000000,0x00030047,0x000001ac,0x00000000,0x00030047, + 0x000001ad,0x00000000,0x00030047,0x000001af,0x00000000,0x00030047,0x000001b1,0x00000000, + 0x00030047,0x000001b2,0x00000000,0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4, + 0x00000000,0x00030047,0x000001b6,0x00000000,0x00030047,0x000001b8,0x00000000,0x00030047, + 0x000001b9,0x00000000,0x00030047,0x000001ba,0x00000000,0x00030047,0x000001bb,0x00000000, + 0x00030047,0x000001bd,0x00000000,0x00030047,0x000001bf,0x00000000,0x00030047,0x000001c0, + 0x00000000,0x00030047,0x000001c1,0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047, + 0x000001c4,0x00000000,0x00030047,0x000001c6,0x00000000,0x00030047,0x000001c7,0x00000000, + 0x00030047,0x000001c8,0x00000000,0x00030047,0x000001c9,0x00000000,0x00030047,0x000001cb, + 0x00000000,0x00030047,0x000001cd,0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047, + 0x000001cf,0x00000000,0x00030047,0x000001d0,0x00000000,0x00030047,0x000001d2,0x00000000, + 0x00030047,0x000001d4,0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d6, + 0x00000000,0x00030047,0x000001d7,0x00000000,0x00030047,0x000001d8,0x00000000,0x00030047, + 0x000001d9,0x00000000,0x00030047,0x000001da,0x00000000,0x00030047,0x000001db,0x00000000, + 0x00030047,0x000001dc,0x00000000,0x00030047,0x000001dd,0x00000000,0x00030047,0x000001de, + 0x00000000,0x00030047,0x000001df,0x00000000,0x00030047,0x000001e0,0x00000000,0x00030047, + 0x000001e1,0x00000000,0x00030047,0x000001e3,0x00000000,0x00030047,0x000001e4,0x00000000, + 0x00030047,0x000001e5,0x00000000,0x00030047,0x000001e6,0x00000000,0x00030047,0x000001e7, + 0x00000000,0x00030047,0x000001e8,0x00000000,0x00030047,0x000001e9,0x00000000,0x00030047, + 0x000001ea,0x00000000,0x00030047,0x000001eb,0x00000000,0x00030047,0x000001ec,0x00000000, + 0x00030047,0x000001ed,0x00000000,0x00030047,0x000001ee,0x00000000,0x00030047,0x000001ef, + 0x00000000,0x00030047,0x000001f0,0x00000000,0x00030047,0x000001f1,0x00000000,0x00030047, + 0x000001f2,0x00000000,0x00030047,0x000001f3,0x00000000,0x00030047,0x000001f4,0x00000000, + 0x00030047,0x000001f5,0x00000000,0x00030047,0x000001f6,0x00000000,0x00030047,0x000001f7, + 0x00000000,0x00030047,0x000001f8,0x00000000,0x00030047,0x000001f9,0x00000000,0x00030047, + 0x000001fa,0x00000000,0x00030047,0x000001fb,0x00000000,0x00030047,0x000001fc,0x00000000, + 0x00030047,0x000001fe,0x00000000,0x00030047,0x000001ff,0x00000000,0x00030047,0x00000201, + 0x00000000,0x00030047,0x00000202,0x00000000,0x00030047,0x00000204,0x00000000,0x00030047, + 0x00000205,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047,0x00000208,0x00000000, + 0x00030047,0x0000020a,0x00000000,0x00030047,0x0000020b,0x00000000,0x00030047,0x0000020d, + 0x00000000,0x00030047,0x00000210,0x00000000,0x00030047,0x00000211,0x00000000,0x00030047, + 0x00000212,0x00000000,0x00030047,0x00000213,0x00000000,0x00030047,0x00000214,0x00000000, + 0x00030047,0x00000215,0x00000000,0x00030047,0x0000021c,0x00000000,0x00030047,0x00000220, + 0x00000000,0x00030047,0x00000221,0x00000000,0x00030047,0x00000226,0x00000000,0x00030047, + 0x00000227,0x00000000,0x00030047,0x0000022b,0x00000000,0x00030047,0x0000022c,0x00000000, + 0x00030047,0x00000231,0x00000000,0x00030047,0x00000232,0x00000000,0x00030047,0x00000234, + 0x00000000,0x00030047,0x00000236,0x00000000,0x00030047,0x00000238,0x00000000,0x00030047, + 0x0000023a,0x00000000,0x00030047,0x0000023c,0x00000000,0x00030047,0x0000023e,0x00000000, + 0x00030047,0x00000240,0x00000000,0x00030047,0x00000242,0x00000000,0x00030047,0x00000244, + 0x00000000,0x00030047,0x00000246,0x00000000,0x00030047,0x00000248,0x00000000,0x00030047, + 0x0000024a,0x00000000,0x00030047,0x0000024c,0x00000000,0x00030047,0x0000024e,0x00000000, + 0x00030047,0x00000258,0x00000000,0x00030047,0x00000264,0x00000000,0x00030047,0x00000267, + 0x00000000,0x00030047,0x00000268,0x00000000,0x00030047,0x00000269,0x00000000,0x00030047, + 0x0000026a,0x00000000,0x00030047,0x0000026d,0x00000000,0x00030047,0x00000270,0x00000000, + 0x00030047,0x00000271,0x00000000,0x00030047,0x00000272,0x00000000,0x00030047,0x00000273, + 0x00000000,0x00030047,0x00000276,0x00000000,0x00030047,0x00000279,0x00000000,0x00030047, + 0x0000027b,0x00000000,0x00030047,0x00000287,0x00000000,0x00030047,0x0000028b,0x00000000, + 0x00030047,0x0000028e,0x00000000,0x00030047,0x0000028f,0x00000000,0x00030047,0x00000290, + 0x00000000,0x00030047,0x00000294,0x00000000,0x00030047,0x00000295,0x00000000,0x00030047, + 0x00000298,0x00000000,0x00030047,0x0000029a,0x00000000,0x00030047,0x0000029b,0x00000000, + 0x00030047,0x0000029c,0x00000000,0x00030047,0x0000029d,0x00000000,0x00030047,0x0000029f, + 0x00000000,0x00030047,0x000002ab,0x00000000,0x00030047,0x000002af,0x00000000,0x00030047, + 0x000002b2,0x00000000,0x00030047,0x000002b3,0x00000000,0x00030047,0x000002b4,0x00000000, + 0x00030047,0x000002b8,0x00000000,0x00030047,0x000002b9,0x00000000,0x00030047,0x000002bc, + 0x00000000,0x00030047,0x000002be,0x00000000,0x00030047,0x000002bf,0x00000000,0x00030047, + 0x000002c0,0x00000000,0x00030047,0x000002c1,0x00000000,0x00030047,0x000002c3,0x00000000, + 0x00030047,0x000002c7,0x00000000,0x00030047,0x000002c9,0x00000000,0x00030047,0x000002ca, + 0x00000000,0x00030047,0x000002cb,0x00000000,0x00030047,0x000002cc,0x00000000,0x00030047, + 0x000002cd,0x00000000,0x00030047,0x000002d1,0x00000000,0x00030047,0x000002d3,0x00000000, + 0x00030047,0x000002d5,0x00000000,0x00030047,0x000002d6,0x00000000,0x00030047,0x000002d7, + 0x00000000,0x00030047,0x000002da,0x00000000,0x00030047,0x000002dc,0x00000000,0x00030047, + 0x000002dd,0x00000000,0x00030047,0x000002de,0x00000000,0x00030047,0x000002e1,0x00000000, + 0x00030047,0x000002e3,0x00000000,0x00030047,0x000002e4,0x00000000,0x00030047,0x000002e5, + 0x00000000,0x00030047,0x000002e7,0x00000000,0x00030047,0x000002e8,0x00000000,0x00030047, + 0x000002e9,0x00000000,0x00030047,0x000002ea,0x00000000,0x00030047,0x000002ec,0x00000000, + 0x00030047,0x000002f0,0x00000000,0x00030047,0x000002f3,0x00000000,0x00030047,0x000002f4, + 0x00000000,0x00030047,0x000002f5,0x00000000,0x00030047,0x000002f6,0x00000000,0x00030047, + 0x000002f8,0x00000000,0x00030047,0x000002fc,0x00000000,0x00030047,0x000002ff,0x00000000, + 0x00030047,0x00000300,0x00000000,0x00030047,0x00000301,0x00000000,0x00030047,0x00000302, + 0x00000000,0x00030047,0x00000304,0x00000000,0x00030047,0x00000308,0x00000000,0x00030047, + 0x0000030b,0x00000000,0x00030047,0x0000030c,0x00000000,0x00030047,0x0000030d,0x00000000, + 0x00030047,0x0000030e,0x00000000,0x00030047,0x00000310,0x00000000,0x00030047,0x00000314, + 0x00000000,0x00030047,0x00000317,0x00000000,0x00030047,0x00000318,0x00000000,0x00030047, + 0x0000031a,0x00000000,0x00030047,0x0000031b,0x00000000,0x00030047,0x0000031c,0x00000000, + 0x00030047,0x0000031d,0x00000000,0x00030047,0x0000031e,0x00000000,0x00030047,0x00000321, + 0x00000000,0x00030047,0x00000322,0x00000000,0x00030047,0x00000323,0x00000000,0x00030047, + 0x00000324,0x00000000,0x00030047,0x00000325,0x00000000,0x00030047,0x00000328,0x00000000, + 0x00030047,0x00000329,0x00000000,0x00030047,0x0000032a,0x00000000,0x00030047,0x0000032b, + 0x00000000,0x00030047,0x0000032c,0x00000000,0x00030047,0x0000032f,0x00000000,0x00030047, + 0x00000330,0x00000000,0x00030047,0x00000331,0x00000000,0x00030047,0x00000332,0x00000000, + 0x00030047,0x00000333,0x00000000,0x00030047,0x00000335,0x00000000,0x00030047,0x00000336, + 0x00000000,0x00030047,0x00000337,0x00000000,0x00030047,0x00000338,0x00000000,0x00030047, + 0x00000339,0x00000000,0x00030047,0x00000345,0x00000000,0x00030047,0x0000034a,0x00000000, + 0x00030047,0x0000034e,0x00000000,0x00030047,0x0000034f,0x00000000,0x00030047,0x0000035c, + 0x00000000,0x00030047,0x00000360,0x00000000,0x00030047,0x00000362,0x00000000,0x00030047, + 0x00000363,0x00000000,0x00030047,0x00000364,0x00000000,0x00030047,0x00000365,0x00000000, + 0x00030047,0x00000367,0x00000000,0x00030047,0x00000369,0x00000000,0x00030047,0x0000036a, + 0x00000000,0x00030047,0x0000036b,0x00000000,0x00030047,0x0000036c,0x00000000,0x00030047, + 0x0000036e,0x00000000,0x00030047,0x00000372,0x00000000,0x00030047,0x00000373,0x00000000, + 0x00030047,0x00000374,0x00000000,0x00030047,0x00000375,0x00000000,0x00030047,0x00000376, + 0x00000000,0x00030047,0x00000377,0x00000000,0x00030047,0x00000379,0x00000000,0x00030047, + 0x0000037b,0x00000000,0x00030047,0x0000037c,0x00000000,0x00030047,0x0000037d,0x00000000, + 0x00030047,0x00000380,0x00000000,0x00030047,0x00000382,0x00000000,0x00030047,0x00000383, + 0x00000000,0x00030047,0x00000384,0x00000000,0x00030047,0x00000387,0x00000000,0x00030047, + 0x00000389,0x00000000,0x00030047,0x0000038a,0x00000000,0x00030047,0x0000038b,0x00000000, + 0x00030047,0x0000038d,0x00000000,0x00030047,0x0000038e,0x00000000,0x00030047,0x0000038f, + 0x00000000,0x00030047,0x00000390,0x00000000,0x00030047,0x00000392,0x00000000,0x00030047, + 0x00000396,0x00000000,0x00030047,0x00000399,0x00000000,0x00030047,0x0000039a,0x00000000, + 0x00030047,0x0000039b,0x00000000,0x00030047,0x0000039c,0x00000000,0x00030047,0x0000039e, + 0x00000000,0x00030047,0x000003a2,0x00000000,0x00030047,0x000003a5,0x00000000,0x00030047, + 0x000003a6,0x00000000,0x00030047,0x000003a7,0x00000000,0x00030047,0x000003a8,0x00000000, + 0x00030047,0x000003aa,0x00000000,0x00030047,0x000003ae,0x00000000,0x00030047,0x000003b1, + 0x00000000,0x00030047,0x000003b2,0x00000000,0x00030047,0x000003b3,0x00000000,0x00030047, + 0x000003b4,0x00000000,0x00030047,0x000003b6,0x00000000,0x00030047,0x000003ba,0x00000000, + 0x00030047,0x000003bd,0x00000000,0x00030047,0x000003be,0x00000000,0x00030047,0x000003c0, + 0x00000000,0x00030047,0x000003c1,0x00000000,0x00030047,0x000003c2,0x00000000,0x00030047, + 0x000003c3,0x00000000,0x00030047,0x000003c4,0x00000000,0x00030047,0x000003c7,0x00000000, + 0x00030047,0x000003c8,0x00000000,0x00030047,0x000003c9,0x00000000,0x00030047,0x000003ca, + 0x00000000,0x00030047,0x000003cb,0x00000000,0x00030047,0x000003ce,0x00000000,0x00030047, + 0x000003cf,0x00000000,0x00030047,0x000003d0,0x00000000,0x00030047,0x000003d1,0x00000000, + 0x00030047,0x000003d2,0x00000000,0x00030047,0x000003d5,0x00000000,0x00030047,0x000003d6, + 0x00000000,0x00030047,0x000003d7,0x00000000,0x00030047,0x000003d8,0x00000000,0x00030047, + 0x000003d9,0x00000000,0x00030047,0x000003db,0x00000000,0x00030047,0x000003dc,0x00000000, + 0x00030047,0x000003dd,0x00000000,0x00030047,0x000003de,0x00000000,0x00030047,0x000003df, + 0x00000000,0x00030047,0x000003e0,0x00000000,0x00030047,0x000003ec,0x00000000,0x00030047, + 0x000003f1,0x00000000,0x00030047,0x000003f5,0x00000000,0x00030047,0x000003f6,0x00000000, + 0x00030047,0x00000403,0x00000000,0x00030047,0x00000407,0x00000000,0x00030047,0x00000408, + 0x00000000,0x00030047,0x00000409,0x00000000,0x00030047,0x0000040a,0x00000000,0x00030047, + 0x0000040b,0x00000000,0x00030047,0x0000040d,0x00000000,0x00030047,0x0000040f,0x00000000, + 0x00030047,0x00000410,0x00000000,0x00030047,0x00000411,0x00000000,0x00030047,0x00000412, + 0x00000000,0x00030047,0x00000413,0x00000000,0x00030047,0x00000416,0x00000000,0x00030047, + 0x00000417,0x00000002,0x00050048,0x00000417,0x00000000,0x00000023,0x00000000,0x00050048, + 0x00000417,0x00000001,0x00000023,0x00000010,0x00040048,0x00000417,0x00000002,0x00000000, + 0x00050048,0x00000417,0x00000002,0x00000023,0x00000020,0x00030047,0x0000041c,0x00000000, + 0x00030047,0x0000041d,0x00000000,0x00030047,0x0000041e,0x00000000,0x00030047,0x0000041f, + 0x00000000,0x00030047,0x00000420,0x00000000,0x00030047,0x00000421,0x00000000,0x00030047, + 0x00000422,0x00000000,0x00030047,0x00000427,0x00000000,0x00030047,0x00000428,0x00000000, + 0x00030047,0x0000042b,0x00000000,0x00030047,0x0000042c,0x00000000,0x00030047,0x00000430, + 0x00000000,0x00030047,0x00000431,0x00000000,0x00030047,0x00000432,0x00000000,0x00030047, + 0x00000434,0x00000000,0x00030047,0x00000435,0x00000000,0x00030047,0x00000436,0x00000000, + 0x00030047,0x00000437,0x00000000,0x00030047,0x00000439,0x00000000,0x00030047,0x0000043a, + 0x00000000,0x00030047,0x0000043b,0x00000000,0x00030047,0x0000043d,0x00000000,0x00030047, + 0x0000043e,0x00000000,0x00030047,0x0000043f,0x00000000,0x00030047,0x00000440,0x00000000, + 0x00030047,0x00000441,0x00000000,0x00030047,0x00000444,0x00000000,0x00030047,0x00000445, + 0x00000000,0x00030047,0x00000446,0x00000000,0x00030047,0x00000448,0x00000000,0x00030047, + 0x00000449,0x00000000,0x00030047,0x0000044a,0x00000000,0x00030047,0x0000044b,0x00000000, + 0x00030047,0x0000044c,0x00000000,0x00030047,0x0000044d,0x00000000,0x00030047,0x0000044e, + 0x00000000,0x00030047,0x00000450,0x00000000,0x00030047,0x00000451,0x00000000,0x00030047, + 0x00000452,0x00000000,0x00030047,0x00000453,0x00000000,0x00030047,0x00000454,0x00000000, + 0x00040047,0x00000462,0x0000001e,0x00000000,0x00030047,0x000004a7,0x00000000,0x00030047, + 0x000004ab,0x00000000,0x00040047,0x000004ab,0x00000021,0x00000000,0x00040047,0x000004ab, + 0x00000022,0x00000000,0x00030047,0x000004ac,0x00000000,0x00030047,0x000004ae,0x00000000, + 0x00030047,0x000004af,0x00000000,0x00030047,0x000004b5,0x00000000,0x00030047,0x000004bd, + 0x00000000,0x00030047,0x000004c5,0x00000000,0x00030047,0x000004ce,0x00000000,0x00030047, + 0x000004d4,0x00000000,0x00030047,0x000004d5,0x00000000,0x00030047,0x000004d7,0x00000000, + 0x00030047,0x000004d8,0x00000000,0x00030047,0x000004da,0x00000000,0x00030047,0x000004db, + 0x00000000,0x00030047,0x000004dd,0x00000000,0x00030047,0x000004de,0x00000000,0x00030047, + 0x000004e0,0x00000000,0x00030047,0x000004e1,0x00000000,0x00030047,0x000004e3,0x00000000, + 0x00030047,0x000004e4,0x00000000,0x00030047,0x000004e6,0x00000000,0x00030047,0x000004e7, + 0x00000000,0x00030047,0x000004e9,0x00000000,0x00030047,0x000004ea,0x00000000,0x00030047, + 0x000004ec,0x00000000,0x00030047,0x000004ed,0x00000000,0x00030047,0x000004ef,0x00000000, + 0x00030047,0x000004f0,0x00000000,0x00030047,0x000004f1,0x00000000,0x00030047,0x000004f2, + 0x00000000,0x00030047,0x000004f4,0x00000000,0x00030047,0x000004f5,0x00000000,0x00030047, + 0x000004f7,0x00000000,0x00030047,0x000004f8,0x00000000,0x00030047,0x000004fa,0x00000000, + 0x00030047,0x000004fb,0x00000000,0x00030047,0x000004fd,0x00000000,0x00030047,0x000004fe, + 0x00000000,0x00030047,0x00000500,0x00000000,0x00030047,0x00000501,0x00000000,0x00030047, + 0x00000503,0x00000000,0x00030047,0x00000504,0x00000000,0x00030047,0x00000506,0x00000000, + 0x00030047,0x00000507,0x00000000,0x00030047,0x00000509,0x00000000,0x00030047,0x0000050a, + 0x00000000,0x00030047,0x0000050c,0x00000000,0x00030047,0x0000050d,0x00000000,0x00030047, + 0x0000050e,0x00000000,0x00030047,0x0000050f,0x00000000,0x00030047,0x00000511,0x00000000, + 0x00030047,0x00000512,0x00000000,0x00030047,0x00000514,0x00000000,0x00030047,0x00000515, + 0x00000000,0x00030047,0x00000517,0x00000000,0x00030047,0x00000518,0x00000000,0x00030047, + 0x0000051a,0x00000000,0x00030047,0x0000051b,0x00000000,0x00030047,0x0000051d,0x00000000, + 0x00030047,0x0000051e,0x00000000,0x00030047,0x00000520,0x00000000,0x00030047,0x00000521, + 0x00000000,0x00030047,0x00000523,0x00000000,0x00030047,0x00000524,0x00000000,0x00030047, + 0x00000526,0x00000000,0x00030047,0x00000527,0x00000000,0x00030047,0x00000529,0x00000000, + 0x00030047,0x0000052a,0x00000000,0x00030047,0x0000052b,0x00000000,0x00030047,0x0000052c, + 0x00000000,0x00030047,0x0000052e,0x00000000,0x00030047,0x0000052f,0x00000000,0x00030047, + 0x00000531,0x00000000,0x00030047,0x00000532,0x00000000,0x00030047,0x00000534,0x00000000, + 0x00030047,0x00000535,0x00000000,0x00030047,0x00000537,0x00000000,0x00030047,0x00000538, + 0x00000000,0x00030047,0x0000053a,0x00000000,0x00030047,0x0000053b,0x00000000,0x00030047, + 0x0000053d,0x00000000,0x00030047,0x0000053e,0x00000000,0x00030047,0x00000540,0x00000000, + 0x00030047,0x00000541,0x00000000,0x00030047,0x00000543,0x00000000,0x00030047,0x00000544, + 0x00000000,0x00030047,0x00000546,0x00000000,0x00030047,0x00000547,0x00000000,0x00030047, + 0x00000548,0x00000000,0x00030047,0x00000549,0x00000000,0x00030047,0x0000054a,0x00000000, + 0x00030047,0x0000054b,0x00000000,0x00030047,0x0000054c,0x00000000,0x00030047,0x0000054d, + 0x00000000,0x00030047,0x0000054e,0x00000000,0x00030047,0x0000054f,0x00000000,0x00030047, + 0x00000550,0x00000000,0x00030047,0x00000551,0x00000000,0x00030047,0x00000553,0x00000000, + 0x00030047,0x00000555,0x00000000,0x00030047,0x00000556,0x00000000,0x00030047,0x00000558, + 0x00000000,0x00030047,0x00000559,0x00000000,0x00030047,0x0000055b,0x00000000,0x00030047, + 0x0000055c,0x00000000,0x00030047,0x0000055e,0x00000000,0x00030047,0x0000055f,0x00000000, + 0x00030047,0x00000561,0x00000000,0x00030047,0x00000562,0x00000000,0x00030047,0x00000563, + 0x00000000,0x00030047,0x00000564,0x00000000,0x00030047,0x00000565,0x00000000,0x00030047, + 0x0000056a,0x00000000,0x00030047,0x0000056b,0x00000000,0x00030047,0x0000056c,0x00000000, + 0x00030047,0x0000056d,0x00000000,0x00030047,0x0000056e,0x00000000,0x00030047,0x0000056f, + 0x00000000,0x00030047,0x00000571,0x00000000,0x00030047,0x00000577,0x00000000,0x00030047, + 0x00000578,0x00000000,0x00030047,0x00000579,0x00000000,0x00030047,0x0000057a,0x00000000, + 0x00030047,0x0000057b,0x00000000,0x00030047,0x0000057c,0x00000000,0x00030047,0x0000057d, + 0x00000000,0x00030047,0x0000057f,0x00000000,0x00030047,0x00000580,0x00000000,0x00030047, + 0x00000581,0x00000000,0x00030047,0x00000582,0x00000000,0x00030047,0x00000583,0x00000000, + 0x00030047,0x00000584,0x00000000,0x00030047,0x00000585,0x00000000,0x00030047,0x00000586, + 0x00000000,0x00030047,0x00000587,0x00000000,0x00030047,0x00000588,0x00000000,0x00030047, + 0x00000589,0x00000000,0x00030047,0x0000058a,0x00000000,0x00030047,0x0000058b,0x00000000, + 0x00030047,0x0000058c,0x00000000,0x00030047,0x0000058d,0x00000000,0x00030047,0x00000595, + 0x00000000,0x00040047,0x00000595,0x0000001e,0x00000000,0x00030047,0x00000596,0x00000000, + 0x00030047,0x00000597,0x00000000,0x00030047,0x00000598,0x00000000,0x00030047,0x00000599, + 0x00000000,0x00030047,0x0000059a,0x00000000,0x00030047,0x0000059b,0x00000000,0x00030047, + 0x0000059c,0x00000000,0x00030047,0x0000059d,0x00000000,0x00030047,0x0000059e,0x00000000, + 0x00030047,0x0000059f,0x00000000,0x00030047,0x000005a0,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007, + 0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007,0x00040021,0x00000009, + 0x00000006,0x00000008,0x00040020,0x0000000d,0x00000007,0x00000006,0x00040017,0x0000000e, + 0x00000006,0x00000004,0x000c0021,0x0000000f,0x0000000e,0x0000000d,0x0000000d,0x0000000d, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x00040020,0x0000001b, + 0x00000007,0x0000000e,0x00090021,0x0000001c,0x0000000e,0x0000001b,0x0000001b,0x0000001b, + 0x0000001b,0x0000000d,0x0000000d,0x00040015,0x00000025,0x00000020,0x00000001,0x00040020, + 0x00000026,0x00000007,0x00000025,0x000a0021,0x00000027,0x00000006,0x0000000d,0x0000000d, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x00000026,0x00040015,0x00000031,0x00000020, + 0x00000000,0x0004002b,0x00000031,0x00000032,0x00000006,0x0004001c,0x00000033,0x00000006, + 0x00000032,0x00040020,0x00000034,0x00000007,0x00000033,0x00050021,0x00000035,0x00000006, + 0x00000034,0x00000026,0x0004001c,0x0000003a,0x00000033,0x00000032,0x00040020,0x0000003b, + 0x00000007,0x0000003a,0x00060021,0x0000003c,0x00000006,0x0000003b,0x00000026,0x00000026, + 0x00090021,0x00000042,0x00000006,0x0000003b,0x0000000d,0x0000000d,0x00000026,0x00000026, + 0x0000001b,0x0004002b,0x00000006,0x0000004b,0x3e59b3d0,0x0004002b,0x00000031,0x0000004c, + 0x00000000,0x0004002b,0x00000006,0x00000050,0x3f371759,0x0004002b,0x00000031,0x00000051, + 0x00000001,0x0004002b,0x00000006,0x00000056,0x3d93dd98,0x0004002b,0x00000031,0x00000057, + 0x00000002,0x0004002b,0x00000006,0x000000a5,0x00000000,0x00020014,0x000000a6,0x0007002c, + 0x0000000e,0x000000aa,0x000000a5,0x000000a5,0x000000a5,0x000000a5,0x0004002b,0x00000006, + 0x000000b2,0x3f800000,0x00040020,0x000000b7,0x00000007,0x000000a6,0x0004002b,0x00000006, + 0x000000bb,0x400ce000,0x0004002b,0x00000006,0x000000bf,0x3d800000,0x0004002b,0x00000025, + 0x0000011c,0x00000020,0x0004002b,0x00000006,0x0000014e,0x3b808081,0x0004002b,0x00000006, + 0x00000152,0x40000000,0x0004002b,0x00000006,0x00000154,0x3e000000,0x0004002b,0x00000025, + 0x0000015c,0x00000000,0x0004002b,0x00000025,0x0000015d,0x0000003f,0x0004002b,0x00000031, + 0x00000160,0x00000080,0x0004001c,0x00000161,0x0000000e,0x00000160,0x0004001c,0x00000162, + 0x0000000e,0x00000160,0x0004001e,0x00000163,0x00000161,0x00000162,0x00040020,0x00000164, + 0x00000002,0x00000163,0x0004003b,0x00000164,0x00000165,0x00000002,0x0004002b,0x00000025, + 0x00000167,0x00000002,0x00040020,0x00000169,0x00000002,0x0000000e,0x0004002b,0x00000025, + 0x0000016f,0x00000001,0x0004002b,0x00000031,0x00000194,0x00000003,0x0004002b,0x00000025, + 0x00000197,0x00000003,0x0004002b,0x00000025,0x0000019f,0x00000004,0x0004002b,0x00000025, + 0x000001a7,0x00000005,0x0004002b,0x00000006,0x000001da,0x3ee66666,0x0004002b,0x00000006, + 0x000001dc,0x400e38e4,0x00040020,0x000001e2,0x00000006,0x00000006,0x0004003b,0x000001e2, + 0x000001e3,0x00000006,0x0004003b,0x000001e2,0x000001e6,0x00000006,0x0004003b,0x000001e2, + 0x000001ee,0x00000006,0x0004003b,0x000001e2,0x000001f1,0x00000006,0x0004002b,0x00000025, + 0x00000256,0x00000006,0x0004002b,0x00000006,0x000002c8,0x3f000000,0x0004002b,0x00000031, + 0x000002ce,0x00000007,0x0004001c,0x000002cf,0x00000006,0x000002ce,0x00040020,0x000002d0, + 0x00000007,0x000002cf,0x0004002b,0x00000006,0x00000361,0x42800000,0x0005001e,0x00000417, + 0x0000000e,0x0000000e,0x00000006,0x00040020,0x00000418,0x00000009,0x00000417,0x0004003b, + 0x00000418,0x00000419,0x00000009,0x00040020,0x0000041a,0x00000009,0x00000006,0x0004002b, + 0x00000006,0x00000424,0x3fa00000,0x0004002b,0x00000006,0x00000425,0x3fe00000,0x0004002b, + 0x00000006,0x0000042f,0x3ecccccd,0x0004002b,0x00000006,0x00000433,0x3f99999a,0x0004002b, + 0x00000006,0x00000438,0x3fcccccd,0x0004002b,0x00000006,0x0000043c,0x3fe66666,0x0004002b, + 0x00000006,0x00000442,0x3dcccccd,0x0004002b,0x00000006,0x00000443,0x3e0f5c29,0x0004002b, + 0x00000006,0x00000447,0x3ea3d70a,0x0004002b,0x00000006,0x0000044f,0x3f19999a,0x00040017, + 0x00000455,0x00000006,0x00000002,0x00040020,0x00000456,0x00000007,0x00000455,0x00040020, + 0x00000458,0x00000009,0x0000000e,0x00040020,0x00000461,0x00000001,0x00000455,0x0004003b, + 0x00000461,0x00000462,0x00000001,0x00040020,0x00000463,0x00000001,0x00000006,0x00090019, + 0x000004a8,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x000004a9,0x000004a8,0x00040020,0x000004aa,0x00000000,0x000004a9,0x0004003b, + 0x000004aa,0x000004ab,0x00000000,0x00040020,0x00000594,0x00000003,0x0000000e,0x0004003b, + 0x00000594,0x00000595,0x00000003,0x0004002b,0x00000006,0x0000059f,0x41200000,0x0004002b, + 0x00000006,0x000005a0,0x3f666666,0x0004002b,0x00000025,0x000005a1,0x00000040,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d, + 0x00000416,0x00000007,0x0004003b,0x0000000d,0x0000041e,0x00000007,0x0004003b,0x0000000d, + 0x00000421,0x00000007,0x0004003b,0x0000000d,0x00000427,0x00000007,0x0004003b,0x0000000d, + 0x0000042b,0x00000007,0x0004003b,0x0000000d,0x00000437,0x00000007,0x0004003b,0x0000000d, + 0x0000044b,0x00000007,0x0004003b,0x00000456,0x00000457,0x00000007,0x0004003b,0x00000456, + 0x0000045c,0x00000007,0x0004003b,0x0000000d,0x00000460,0x00000007,0x0004003b,0x0000000d, + 0x0000046a,0x00000007,0x0004003b,0x0000000d,0x00000471,0x00000007,0x0004003b,0x0000000d, + 0x00000474,0x00000007,0x0004003b,0x0000000d,0x00000477,0x00000007,0x0004003b,0x0000000d, + 0x0000047b,0x00000007,0x0004003b,0x00000026,0x0000047f,0x00000007,0x0004003b,0x00000026, + 0x00000483,0x00000007,0x0004003b,0x00000026,0x00000487,0x00000007,0x0004003b,0x00000026, + 0x0000048f,0x00000007,0x0004003b,0x00000456,0x00000497,0x00000007,0x0004003b,0x0000001b, + 0x000004a7,0x00000007,0x0004003b,0x0000003b,0x000004af,0x00000007,0x0004003b,0x0000001b, + 0x000004d4,0x00000007,0x0004003b,0x0000000d,0x000004d5,0x00000007,0x0004003b,0x0000000d, + 0x000004d8,0x00000007,0x0004003b,0x0000000d,0x000004db,0x00000007,0x0004003b,0x0000000d, + 0x000004de,0x00000007,0x0004003b,0x0000000d,0x000004e1,0x00000007,0x0004003b,0x0000000d, + 0x000004e4,0x00000007,0x0004003b,0x0000000d,0x000004e7,0x00000007,0x0004003b,0x0000000d, + 0x000004ea,0x00000007,0x0004003b,0x0000000d,0x000004ed,0x00000007,0x0004003b,0x0000001b, + 0x000004f1,0x00000007,0x0004003b,0x0000000d,0x000004f2,0x00000007,0x0004003b,0x0000000d, + 0x000004f5,0x00000007,0x0004003b,0x0000000d,0x000004f8,0x00000007,0x0004003b,0x0000000d, + 0x000004fb,0x00000007,0x0004003b,0x0000000d,0x000004fe,0x00000007,0x0004003b,0x0000000d, + 0x00000501,0x00000007,0x0004003b,0x0000000d,0x00000504,0x00000007,0x0004003b,0x0000000d, + 0x00000507,0x00000007,0x0004003b,0x0000000d,0x0000050a,0x00000007,0x0004003b,0x0000001b, + 0x0000050e,0x00000007,0x0004003b,0x0000000d,0x0000050f,0x00000007,0x0004003b,0x0000000d, + 0x00000512,0x00000007,0x0004003b,0x0000000d,0x00000515,0x00000007,0x0004003b,0x0000000d, + 0x00000518,0x00000007,0x0004003b,0x0000000d,0x0000051b,0x00000007,0x0004003b,0x0000000d, + 0x0000051e,0x00000007,0x0004003b,0x0000000d,0x00000521,0x00000007,0x0004003b,0x0000000d, + 0x00000524,0x00000007,0x0004003b,0x0000000d,0x00000527,0x00000007,0x0004003b,0x0000001b, + 0x0000052b,0x00000007,0x0004003b,0x0000000d,0x0000052c,0x00000007,0x0004003b,0x0000000d, + 0x0000052f,0x00000007,0x0004003b,0x0000000d,0x00000532,0x00000007,0x0004003b,0x0000000d, + 0x00000535,0x00000007,0x0004003b,0x0000000d,0x00000538,0x00000007,0x0004003b,0x0000000d, + 0x0000053b,0x00000007,0x0004003b,0x0000000d,0x0000053e,0x00000007,0x0004003b,0x0000000d, + 0x00000541,0x00000007,0x0004003b,0x0000000d,0x00000544,0x00000007,0x0004003b,0x0000001b, + 0x00000548,0x00000007,0x0004003b,0x0000001b,0x00000549,0x00000007,0x0004003b,0x0000001b, + 0x0000054b,0x00000007,0x0004003b,0x0000001b,0x0000054d,0x00000007,0x0004003b,0x0000001b, + 0x0000054f,0x00000007,0x0004003b,0x0000000d,0x00000551,0x00000007,0x0004003b,0x0000000d, + 0x00000553,0x00000007,0x0004003b,0x0000000d,0x00000556,0x00000007,0x0004003b,0x0000000d, + 0x00000563,0x00000007,0x0004003b,0x0000003b,0x00000564,0x00000007,0x0004003b,0x00000026, + 0x00000566,0x00000007,0x0004003b,0x00000026,0x00000568,0x00000007,0x0004003b,0x0000003b, + 0x0000056d,0x00000007,0x0004003b,0x0000000d,0x0000056f,0x00000007,0x0004003b,0x0000000d, + 0x00000571,0x00000007,0x0004003b,0x00000026,0x00000573,0x00000007,0x0004003b,0x00000026, + 0x00000575,0x00000007,0x0004003b,0x0000001b,0x00000577,0x00000007,0x0004003b,0x0000001b, + 0x0000057c,0x00000007,0x0004003b,0x0000000d,0x00000580,0x00000007,0x0004003b,0x00000008, + 0x00000581,0x00000007,0x0004003b,0x0000000d,0x00000585,0x00000007,0x00050041,0x0000041a, + 0x0000041b,0x00000419,0x00000167,0x0004003d,0x00000006,0x0000041c,0x0000041b,0x0008000c, + 0x00000006,0x0000041d,0x00000001,0x0000002b,0x0000041c,0x000000a5,0x000000b2,0x0003003e, + 0x00000416,0x0000041d,0x0004003d,0x00000006,0x0000041f,0x00000416,0x00050083,0x00000006, + 0x00000420,0x0000041f,0x000002c8,0x0003003e,0x0000041e,0x00000420,0x0004003d,0x00000006, + 0x00000422,0x0000041e,0x000500be,0x000000a6,0x00000423,0x00000422,0x000000a5,0x000600a9, + 0x00000006,0x00000426,0x00000423,0x00000424,0x00000425,0x0003003e,0x00000421,0x00000426, + 0x0004003d,0x00000006,0x00000428,0x0000041e,0x000500be,0x000000a6,0x00000429,0x00000428, + 0x000000a5,0x000600a9,0x00000006,0x0000042a,0x00000429,0x00000424,0x000000b2,0x0003003e, + 0x00000427,0x0000042a,0x0004003d,0x00000006,0x0000042c,0x0000041e,0x000500be,0x000000a6, + 0x0000042d,0x0000042c,0x000000a5,0x000600a9,0x00000006,0x0000042e,0x0000042d,0x00000424, + 0x000000b2,0x0003003e,0x0000042b,0x0000042e,0x0004003d,0x00000006,0x00000430,0x0000041e, + 0x0004003d,0x00000006,0x00000431,0x00000427,0x00050085,0x00000006,0x00000432,0x00000430, + 0x00000431,0x00050085,0x00000006,0x00000434,0x00000432,0x00000433,0x00050081,0x00000006, + 0x00000435,0x0000042f,0x00000434,0x0007000c,0x00000006,0x00000436,0x00000001,0x00000028, + 0x000000a5,0x00000435,0x0003003e,0x000001e6,0x00000436,0x0004003d,0x00000006,0x00000439, + 0x0000041e,0x0004003d,0x00000006,0x0000043a,0x00000421,0x00050085,0x00000006,0x0000043b, + 0x00000439,0x0000043a,0x00050085,0x00000006,0x0000043d,0x0000043b,0x0000043c,0x00050081, + 0x00000006,0x0000043e,0x00000438,0x0000043d,0x0003003e,0x00000437,0x0000043e,0x0004003d, + 0x00000006,0x0000043f,0x00000437,0x0004003d,0x00000006,0x00000440,0x000001e6,0x00050083, + 0x00000006,0x00000441,0x0000043f,0x00000440,0x0003003e,0x000001e3,0x00000441,0x0004003d, + 0x00000006,0x00000444,0x0000041e,0x0004003d,0x00000006,0x00000445,0x0000042b,0x00050085, + 0x00000006,0x00000446,0x00000444,0x00000445,0x00050085,0x00000006,0x00000448,0x00000446, + 0x00000447,0x00050081,0x00000006,0x00000449,0x00000443,0x00000448,0x0007000c,0x00000006, + 0x0000044a,0x00000001,0x00000028,0x00000442,0x00000449,0x0003003e,0x000001f1,0x0000044a, + 0x0004003d,0x00000006,0x0000044c,0x0000041e,0x0004003d,0x00000006,0x0000044d,0x0000042b, + 0x00050085,0x00000006,0x0000044e,0x0000044c,0x0000044d,0x00050085,0x00000006,0x00000450, + 0x0000044e,0x0000044f,0x00050081,0x00000006,0x00000451,0x000002c8,0x00000450,0x0003003e, + 0x0000044b,0x00000451,0x0004003d,0x00000006,0x00000452,0x0000044b,0x0004003d,0x00000006, + 0x00000453,0x000001f1,0x00050083,0x00000006,0x00000454,0x00000452,0x00000453,0x0003003e, + 0x000001ee,0x00000454,0x00050041,0x00000458,0x00000459,0x00000419,0x0000016f,0x0004003d, + 0x0000000e,0x0000045a,0x00000459,0x0007004f,0x00000455,0x0000045b,0x0000045a,0x0000045a, + 0x00000002,0x00000003,0x0003003e,0x00000457,0x0000045b,0x00050041,0x00000458,0x0000045d, + 0x00000419,0x0000016f,0x0004003d,0x0000000e,0x0000045e,0x0000045d,0x0007004f,0x00000455, + 0x0000045f,0x0000045e,0x0000045e,0x00000000,0x00000001,0x0003003e,0x0000045c,0x0000045f, + 0x00050041,0x00000463,0x00000464,0x00000462,0x0000004c,0x0004003d,0x00000006,0x00000465, + 0x00000464,0x00050041,0x0000000d,0x00000466,0x00000457,0x0000004c,0x0004003d,0x00000006, + 0x00000467,0x00000466,0x00050085,0x00000006,0x00000468,0x00000465,0x00000467,0x00050083, + 0x00000006,0x00000469,0x00000468,0x000002c8,0x0003003e,0x00000460,0x00000469,0x00050041, + 0x00000463,0x0000046b,0x00000462,0x00000051,0x0004003d,0x00000006,0x0000046c,0x0000046b, + 0x00050041,0x0000000d,0x0000046d,0x00000457,0x00000051,0x0004003d,0x00000006,0x0000046e, + 0x0000046d,0x00050085,0x00000006,0x0000046f,0x0000046c,0x0000046e,0x00050083,0x00000006, + 0x00000470,0x0000046f,0x000002c8,0x0003003e,0x0000046a,0x00000470,0x0004003d,0x00000006, + 0x00000472,0x00000460,0x0006000c,0x00000006,0x00000473,0x00000001,0x00000008,0x00000472, + 0x0003003e,0x00000471,0x00000473,0x0004003d,0x00000006,0x00000475,0x0000046a,0x0006000c, + 0x00000006,0x00000476,0x00000001,0x00000008,0x00000475,0x0003003e,0x00000474,0x00000476, + 0x0004003d,0x00000006,0x00000478,0x00000460,0x0004003d,0x00000006,0x00000479,0x00000471, + 0x00050083,0x00000006,0x0000047a,0x00000478,0x00000479,0x0003003e,0x00000477,0x0000047a, + 0x0004003d,0x00000006,0x0000047c,0x0000046a,0x0004003d,0x00000006,0x0000047d,0x00000474, + 0x00050083,0x00000006,0x0000047e,0x0000047c,0x0000047d,0x0003003e,0x0000047b,0x0000047e, + 0x0004003d,0x00000006,0x00000480,0x00000477,0x00050085,0x00000006,0x00000481,0x00000480, + 0x00000361,0x0004006e,0x00000025,0x00000482,0x00000481,0x0003003e,0x0000047f,0x00000482, + 0x0004003d,0x00000006,0x00000484,0x0000047b,0x00050085,0x00000006,0x00000485,0x00000484, + 0x00000361,0x0004006e,0x00000025,0x00000486,0x00000485,0x0003003e,0x00000483,0x00000486, + 0x0003003e,0x00000487,0x0000015c,0x000200f9,0x00000488,0x000200f8,0x00000488,0x000400f6, + 0x0000048a,0x0000048b,0x00000000,0x000200f9,0x0000048c,0x000200f8,0x0000048c,0x0004003d, + 0x00000025,0x0000048d,0x00000487,0x000500b1,0x000000a6,0x0000048e,0x0000048d,0x00000197, + 0x000400fa,0x0000048e,0x00000489,0x0000048a,0x000200f8,0x00000489,0x0003003e,0x0000048f, + 0x0000015c,0x000200f9,0x00000490,0x000200f8,0x00000490,0x000400f6,0x00000492,0x00000493, + 0x00000000,0x000200f9,0x00000494,0x000200f8,0x00000494,0x0004003d,0x00000025,0x00000495, + 0x0000048f,0x000500b1,0x000000a6,0x00000496,0x00000495,0x00000197,0x000400fa,0x00000496, + 0x00000491,0x00000492,0x000200f8,0x00000491,0x0004003d,0x00000006,0x00000498,0x00000471, + 0x0004003d,0x00000025,0x00000499,0x0000048f,0x00050084,0x00000025,0x0000049a,0x00000167, + 0x00000499,0x00050082,0x00000025,0x0000049b,0x0000049a,0x0000016f,0x0004006f,0x00000006, + 0x0000049c,0x0000049b,0x00050081,0x00000006,0x0000049d,0x00000498,0x0000049c,0x0004003d, + 0x00000006,0x0000049e,0x00000474,0x0004003d,0x00000025,0x0000049f,0x00000487,0x00050084, + 0x00000025,0x000004a0,0x00000167,0x0000049f,0x00050082,0x00000025,0x000004a1,0x000004a0, + 0x0000016f,0x0004006f,0x00000006,0x000004a2,0x000004a1,0x00050081,0x00000006,0x000004a3, + 0x0000049e,0x000004a2,0x00050050,0x00000455,0x000004a4,0x0000049d,0x000004a3,0x0004003d, + 0x00000455,0x000004a5,0x0000045c,0x00050085,0x00000455,0x000004a6,0x000004a4,0x000004a5, + 0x0003003e,0x00000497,0x000004a6,0x0004003d,0x000004a9,0x000004ac,0x000004ab,0x0004003d, + 0x00000455,0x000004ad,0x00000497,0x00060060,0x0000000e,0x000004ae,0x000004ac,0x000004ad, + 0x00000197,0x0003003e,0x000004a7,0x000004ae,0x0004003d,0x00000025,0x000004b0,0x00000487, + 0x00050084,0x00000025,0x000004b1,0x00000167,0x000004b0,0x0004003d,0x00000025,0x000004b2, + 0x0000048f,0x00050084,0x00000025,0x000004b3,0x00000167,0x000004b2,0x00050041,0x0000000d, + 0x000004b4,0x000004a7,0x00000194,0x0004003d,0x00000006,0x000004b5,0x000004b4,0x00060041, + 0x0000000d,0x000004b6,0x000004af,0x000004b1,0x000004b3,0x0003003e,0x000004b6,0x000004b5, + 0x0004003d,0x00000025,0x000004b7,0x00000487,0x00050084,0x00000025,0x000004b8,0x00000167, + 0x000004b7,0x0004003d,0x00000025,0x000004b9,0x0000048f,0x00050084,0x00000025,0x000004ba, + 0x00000167,0x000004b9,0x00050080,0x00000025,0x000004bb,0x000004ba,0x0000016f,0x00050041, + 0x0000000d,0x000004bc,0x000004a7,0x00000057,0x0004003d,0x00000006,0x000004bd,0x000004bc, + 0x00060041,0x0000000d,0x000004be,0x000004af,0x000004b8,0x000004bb,0x0003003e,0x000004be, + 0x000004bd,0x0004003d,0x00000025,0x000004bf,0x00000487,0x00050084,0x00000025,0x000004c0, + 0x00000167,0x000004bf,0x00050080,0x00000025,0x000004c1,0x000004c0,0x0000016f,0x0004003d, + 0x00000025,0x000004c2,0x0000048f,0x00050084,0x00000025,0x000004c3,0x00000167,0x000004c2, + 0x00050041,0x0000000d,0x000004c4,0x000004a7,0x0000004c,0x0004003d,0x00000006,0x000004c5, + 0x000004c4,0x00060041,0x0000000d,0x000004c6,0x000004af,0x000004c1,0x000004c3,0x0003003e, + 0x000004c6,0x000004c5,0x0004003d,0x00000025,0x000004c7,0x00000487,0x00050084,0x00000025, + 0x000004c8,0x00000167,0x000004c7,0x00050080,0x00000025,0x000004c9,0x000004c8,0x0000016f, + 0x0004003d,0x00000025,0x000004ca,0x0000048f,0x00050084,0x00000025,0x000004cb,0x00000167, + 0x000004ca,0x00050080,0x00000025,0x000004cc,0x000004cb,0x0000016f,0x00050041,0x0000000d, + 0x000004cd,0x000004a7,0x00000051,0x0004003d,0x00000006,0x000004ce,0x000004cd,0x00060041, + 0x0000000d,0x000004cf,0x000004af,0x000004c9,0x000004cc,0x0003003e,0x000004cf,0x000004ce, + 0x000200f9,0x00000493,0x000200f8,0x00000493,0x0004003d,0x00000025,0x000004d0,0x0000048f, + 0x00050080,0x00000025,0x000004d1,0x000004d0,0x0000016f,0x0003003e,0x0000048f,0x000004d1, + 0x000200f9,0x00000490,0x000200f8,0x00000492,0x000200f9,0x0000048b,0x000200f8,0x0000048b, + 0x0004003d,0x00000025,0x000004d2,0x00000487,0x00050080,0x00000025,0x000004d3,0x000004d2, + 0x0000016f,0x0003003e,0x00000487,0x000004d3,0x000200f9,0x00000488,0x000200f8,0x0000048a, + 0x00060041,0x0000000d,0x000004d6,0x000004af,0x0000016f,0x0000016f,0x0004003d,0x00000006, + 0x000004d7,0x000004d6,0x0003003e,0x000004d5,0x000004d7,0x00060041,0x0000000d,0x000004d9, + 0x000004af,0x0000016f,0x00000167,0x0004003d,0x00000006,0x000004da,0x000004d9,0x0003003e, + 0x000004d8,0x000004da,0x00060041,0x0000000d,0x000004dc,0x000004af,0x0000016f,0x00000197, + 0x0004003d,0x00000006,0x000004dd,0x000004dc,0x0003003e,0x000004db,0x000004dd,0x00060041, + 0x0000000d,0x000004df,0x000004af,0x00000167,0x0000016f,0x0004003d,0x00000006,0x000004e0, + 0x000004df,0x0003003e,0x000004de,0x000004e0,0x00060041,0x0000000d,0x000004e2,0x000004af, + 0x00000167,0x00000167,0x0004003d,0x00000006,0x000004e3,0x000004e2,0x0003003e,0x000004e1, + 0x000004e3,0x00060041,0x0000000d,0x000004e5,0x000004af,0x00000167,0x00000197,0x0004003d, + 0x00000006,0x000004e6,0x000004e5,0x0003003e,0x000004e4,0x000004e6,0x00060041,0x0000000d, + 0x000004e8,0x000004af,0x00000197,0x0000016f,0x0004003d,0x00000006,0x000004e9,0x000004e8, + 0x0003003e,0x000004e7,0x000004e9,0x00060041,0x0000000d,0x000004eb,0x000004af,0x00000197, + 0x00000167,0x0004003d,0x00000006,0x000004ec,0x000004eb,0x0003003e,0x000004ea,0x000004ec, + 0x00060041,0x0000000d,0x000004ee,0x000004af,0x00000197,0x00000197,0x0004003d,0x00000006, + 0x000004ef,0x000004ee,0x0003003e,0x000004ed,0x000004ef,0x000d0039,0x0000000e,0x000004f0, + 0x00000019,0x000004d5,0x000004d8,0x000004db,0x000004de,0x000004e1,0x000004e4,0x000004e7, + 0x000004ea,0x000004ed,0x0003003e,0x000004d4,0x000004f0,0x00060041,0x0000000d,0x000004f3, + 0x000004af,0x0000016f,0x00000167,0x0004003d,0x00000006,0x000004f4,0x000004f3,0x0003003e, + 0x000004f2,0x000004f4,0x00060041,0x0000000d,0x000004f6,0x000004af,0x0000016f,0x00000197, + 0x0004003d,0x00000006,0x000004f7,0x000004f6,0x0003003e,0x000004f5,0x000004f7,0x00060041, + 0x0000000d,0x000004f9,0x000004af,0x0000016f,0x0000019f,0x0004003d,0x00000006,0x000004fa, + 0x000004f9,0x0003003e,0x000004f8,0x000004fa,0x00060041,0x0000000d,0x000004fc,0x000004af, + 0x00000167,0x00000167,0x0004003d,0x00000006,0x000004fd,0x000004fc,0x0003003e,0x000004fb, + 0x000004fd,0x00060041,0x0000000d,0x000004ff,0x000004af,0x00000167,0x00000197,0x0004003d, + 0x00000006,0x00000500,0x000004ff,0x0003003e,0x000004fe,0x00000500,0x00060041,0x0000000d, + 0x00000502,0x000004af,0x00000167,0x0000019f,0x0004003d,0x00000006,0x00000503,0x00000502, + 0x0003003e,0x00000501,0x00000503,0x00060041,0x0000000d,0x00000505,0x000004af,0x00000197, + 0x00000167,0x0004003d,0x00000006,0x00000506,0x00000505,0x0003003e,0x00000504,0x00000506, + 0x00060041,0x0000000d,0x00000508,0x000004af,0x00000197,0x00000197,0x0004003d,0x00000006, + 0x00000509,0x00000508,0x0003003e,0x00000507,0x00000509,0x00060041,0x0000000d,0x0000050b, + 0x000004af,0x00000197,0x0000019f,0x0004003d,0x00000006,0x0000050c,0x0000050b,0x0003003e, + 0x0000050a,0x0000050c,0x000d0039,0x0000000e,0x0000050d,0x00000019,0x000004f2,0x000004f5, + 0x000004f8,0x000004fb,0x000004fe,0x00000501,0x00000504,0x00000507,0x0000050a,0x0003003e, + 0x000004f1,0x0000050d,0x00060041,0x0000000d,0x00000510,0x000004af,0x00000167,0x0000016f, + 0x0004003d,0x00000006,0x00000511,0x00000510,0x0003003e,0x0000050f,0x00000511,0x00060041, + 0x0000000d,0x00000513,0x000004af,0x00000167,0x00000167,0x0004003d,0x00000006,0x00000514, + 0x00000513,0x0003003e,0x00000512,0x00000514,0x00060041,0x0000000d,0x00000516,0x000004af, + 0x00000167,0x00000197,0x0004003d,0x00000006,0x00000517,0x00000516,0x0003003e,0x00000515, + 0x00000517,0x00060041,0x0000000d,0x00000519,0x000004af,0x00000197,0x0000016f,0x0004003d, + 0x00000006,0x0000051a,0x00000519,0x0003003e,0x00000518,0x0000051a,0x00060041,0x0000000d, + 0x0000051c,0x000004af,0x00000197,0x00000167,0x0004003d,0x00000006,0x0000051d,0x0000051c, + 0x0003003e,0x0000051b,0x0000051d,0x00060041,0x0000000d,0x0000051f,0x000004af,0x00000197, + 0x00000197,0x0004003d,0x00000006,0x00000520,0x0000051f,0x0003003e,0x0000051e,0x00000520, + 0x00060041,0x0000000d,0x00000522,0x000004af,0x0000019f,0x0000016f,0x0004003d,0x00000006, + 0x00000523,0x00000522,0x0003003e,0x00000521,0x00000523,0x00060041,0x0000000d,0x00000525, + 0x000004af,0x0000019f,0x00000167,0x0004003d,0x00000006,0x00000526,0x00000525,0x0003003e, + 0x00000524,0x00000526,0x00060041,0x0000000d,0x00000528,0x000004af,0x0000019f,0x00000197, + 0x0004003d,0x00000006,0x00000529,0x00000528,0x0003003e,0x00000527,0x00000529,0x000d0039, + 0x0000000e,0x0000052a,0x00000019,0x0000050f,0x00000512,0x00000515,0x00000518,0x0000051b, + 0x0000051e,0x00000521,0x00000524,0x00000527,0x0003003e,0x0000050e,0x0000052a,0x00060041, + 0x0000000d,0x0000052d,0x000004af,0x00000167,0x00000167,0x0004003d,0x00000006,0x0000052e, + 0x0000052d,0x0003003e,0x0000052c,0x0000052e,0x00060041,0x0000000d,0x00000530,0x000004af, + 0x00000167,0x00000197,0x0004003d,0x00000006,0x00000531,0x00000530,0x0003003e,0x0000052f, + 0x00000531,0x00060041,0x0000000d,0x00000533,0x000004af,0x00000167,0x0000019f,0x0004003d, + 0x00000006,0x00000534,0x00000533,0x0003003e,0x00000532,0x00000534,0x00060041,0x0000000d, + 0x00000536,0x000004af,0x00000197,0x00000167,0x0004003d,0x00000006,0x00000537,0x00000536, + 0x0003003e,0x00000535,0x00000537,0x00060041,0x0000000d,0x00000539,0x000004af,0x00000197, + 0x00000197,0x0004003d,0x00000006,0x0000053a,0x00000539,0x0003003e,0x00000538,0x0000053a, + 0x00060041,0x0000000d,0x0000053c,0x000004af,0x00000197,0x0000019f,0x0004003d,0x00000006, + 0x0000053d,0x0000053c,0x0003003e,0x0000053b,0x0000053d,0x00060041,0x0000000d,0x0000053f, + 0x000004af,0x0000019f,0x00000167,0x0004003d,0x00000006,0x00000540,0x0000053f,0x0003003e, + 0x0000053e,0x00000540,0x00060041,0x0000000d,0x00000542,0x000004af,0x0000019f,0x00000197, + 0x0004003d,0x00000006,0x00000543,0x00000542,0x0003003e,0x00000541,0x00000543,0x00060041, + 0x0000000d,0x00000545,0x000004af,0x0000019f,0x0000019f,0x0004003d,0x00000006,0x00000546, + 0x00000545,0x0003003e,0x00000544,0x00000546,0x000d0039,0x0000000e,0x00000547,0x00000019, + 0x0000052c,0x0000052f,0x00000532,0x00000535,0x00000538,0x0000053b,0x0000053e,0x00000541, + 0x00000544,0x0003003e,0x0000052b,0x00000547,0x0004003d,0x0000000e,0x0000054a,0x000004d4, + 0x0003003e,0x00000549,0x0000054a,0x0004003d,0x0000000e,0x0000054c,0x000004f1,0x0003003e, + 0x0000054b,0x0000054c,0x0004003d,0x0000000e,0x0000054e,0x0000050e,0x0003003e,0x0000054d, + 0x0000054e,0x0004003d,0x0000000e,0x00000550,0x0000052b,0x0003003e,0x0000054f,0x00000550, + 0x0004003d,0x00000006,0x00000552,0x00000477,0x0003003e,0x00000551,0x00000552,0x0004003d, + 0x00000006,0x00000554,0x0000047b,0x0003003e,0x00000553,0x00000554,0x000a0039,0x0000000e, + 0x00000555,0x00000023,0x00000549,0x0000054b,0x0000054d,0x0000054f,0x00000551,0x00000553, + 0x0003003e,0x00000548,0x00000555,0x00050041,0x0000000d,0x00000557,0x00000548,0x0000004c, + 0x0004003d,0x00000006,0x00000558,0x00000557,0x00050083,0x00000006,0x00000559,0x000000b2, + 0x00000558,0x00050041,0x0000000d,0x0000055a,0x00000548,0x00000051,0x0004003d,0x00000006, + 0x0000055b,0x0000055a,0x00050083,0x00000006,0x0000055c,0x00000559,0x0000055b,0x00050041, + 0x0000000d,0x0000055d,0x00000548,0x00000057,0x0004003d,0x00000006,0x0000055e,0x0000055d, + 0x00050083,0x00000006,0x0000055f,0x0000055c,0x0000055e,0x00050041,0x0000000d,0x00000560, + 0x00000548,0x00000194,0x0004003d,0x00000006,0x00000561,0x00000560,0x00050083,0x00000006, + 0x00000562,0x0000055f,0x00000561,0x0003003e,0x00000556,0x00000562,0x0004003d,0x0000003a, + 0x00000565,0x000004af,0x0003003e,0x00000564,0x00000565,0x0004003d,0x00000025,0x00000567, + 0x0000047f,0x0003003e,0x00000566,0x00000567,0x0004003d,0x00000025,0x00000569,0x00000483, + 0x0003003e,0x00000568,0x00000569,0x00070039,0x00000006,0x0000056a,0x00000040,0x00000564, + 0x00000566,0x00000568,0x0004003d,0x00000006,0x0000056b,0x00000556,0x00050085,0x00000006, + 0x0000056c,0x0000056a,0x0000056b,0x0003003e,0x00000563,0x0000056c,0x0004003d,0x0000003a, + 0x0000056e,0x000004af,0x0003003e,0x0000056d,0x0000056e,0x0004003d,0x00000006,0x00000570, + 0x00000477,0x0003003e,0x0000056f,0x00000570,0x0004003d,0x00000006,0x00000572,0x0000047b, + 0x0003003e,0x00000571,0x00000572,0x0004003d,0x00000025,0x00000574,0x0000047f,0x0003003e, + 0x00000573,0x00000574,0x0004003d,0x00000025,0x00000576,0x00000483,0x0003003e,0x00000575, + 0x00000576,0x0004003d,0x0000000e,0x00000578,0x00000548,0x0003003e,0x00000577,0x00000578, + 0x000a0039,0x00000006,0x00000579,0x00000049,0x0000056d,0x0000056f,0x00000571,0x00000573, + 0x00000575,0x00000577,0x0004003d,0x00000006,0x0000057a,0x00000563,0x00050081,0x00000006, + 0x0000057b,0x0000057a,0x00000579,0x0003003e,0x00000563,0x0000057b,0x0004003d,0x000004a9, + 0x0000057d,0x000004ab,0x0004003d,0x00000455,0x0000057e,0x00000462,0x00050057,0x0000000e, + 0x0000057f,0x0000057d,0x0000057e,0x0003003e,0x0000057c,0x0000057f,0x0004003d,0x0000000e, + 0x00000582,0x0000057c,0x0008004f,0x00000007,0x00000583,0x00000582,0x00000582,0x00000000, + 0x00000001,0x00000002,0x0003003e,0x00000581,0x00000583,0x00050039,0x00000006,0x00000584, + 0x0000000b,0x00000581,0x0003003e,0x00000580,0x00000584,0x0004003d,0x00000006,0x00000586, + 0x00000563,0x0004003d,0x00000006,0x00000587,0x00000580,0x00050083,0x00000006,0x00000588, + 0x00000586,0x00000587,0x0003003e,0x00000585,0x00000588,0x0004003d,0x00000006,0x00000589, + 0x00000585,0x00060050,0x00000007,0x0000058a,0x00000589,0x00000589,0x00000589,0x0004003d, + 0x0000000e,0x0000058b,0x0000057c,0x0008004f,0x00000007,0x0000058c,0x0000058b,0x0000058b, + 0x00000000,0x00000001,0x00000002,0x00050081,0x00000007,0x0000058d,0x0000058c,0x0000058a, + 0x00050041,0x0000000d,0x0000058e,0x0000057c,0x0000004c,0x00050051,0x00000006,0x0000058f, + 0x0000058d,0x00000000,0x0003003e,0x0000058e,0x0000058f,0x00050041,0x0000000d,0x00000590, + 0x0000057c,0x00000051,0x00050051,0x00000006,0x00000591,0x0000058d,0x00000001,0x0003003e, + 0x00000590,0x00000591,0x00050041,0x0000000d,0x00000592,0x0000057c,0x00000057,0x00050051, + 0x00000006,0x00000593,0x0000058d,0x00000002,0x0003003e,0x00000592,0x00000593,0x0004003d, + 0x0000000e,0x00000596,0x0000057c,0x0008004f,0x00000007,0x00000597,0x00000596,0x00000596, + 0x00000000,0x00000001,0x00000002,0x00060050,0x00000007,0x00000598,0x000000a5,0x000000a5, + 0x000000a5,0x00060050,0x00000007,0x00000599,0x000000b2,0x000000b2,0x000000b2,0x0008000c, + 0x00000007,0x0000059a,0x00000001,0x0000002b,0x00000597,0x00000598,0x00000599,0x00050051, + 0x00000006,0x0000059b,0x0000059a,0x00000000,0x00050051,0x00000006,0x0000059c,0x0000059a, + 0x00000001,0x00050051,0x00000006,0x0000059d,0x0000059a,0x00000002,0x00070050,0x0000000e, + 0x0000059e,0x0000059b,0x0000059c,0x0000059d,0x000000b2,0x0003003e,0x00000595,0x0000059e, + 0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000b,0x00000000,0x00000009,0x00030037, + 0x00000008,0x0000000a,0x000200f8,0x0000000c,0x00050041,0x0000000d,0x0000004d,0x0000000a, + 0x0000004c,0x0004003d,0x00000006,0x0000004e,0x0000004d,0x00050085,0x00000006,0x0000004f, + 0x0000004b,0x0000004e,0x00050041,0x0000000d,0x00000052,0x0000000a,0x00000051,0x0004003d, + 0x00000006,0x00000053,0x00000052,0x00050085,0x00000006,0x00000054,0x00000050,0x00000053, + 0x00050081,0x00000006,0x00000055,0x0000004f,0x00000054,0x00050041,0x0000000d,0x00000058, + 0x0000000a,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000058,0x00050085,0x00000006, + 0x0000005a,0x00000056,0x00000059,0x00050081,0x00000006,0x0000005b,0x00000055,0x0000005a, + 0x000200fe,0x0000005b,0x00010038,0x00050036,0x0000000e,0x00000019,0x00000000,0x0000000f, + 0x00030037,0x0000000d,0x00000010,0x00030037,0x0000000d,0x00000011,0x00030037,0x0000000d, + 0x00000012,0x00030037,0x0000000d,0x00000013,0x00030037,0x0000000d,0x00000014,0x00030037, + 0x0000000d,0x00000015,0x00030037,0x0000000d,0x00000016,0x00030037,0x0000000d,0x00000017, + 0x00030037,0x0000000d,0x00000018,0x000200f8,0x0000001a,0x0004003b,0x0000000d,0x0000005e, + 0x00000007,0x0004003b,0x0000000d,0x0000006b,0x00000007,0x0004003b,0x0000000d,0x00000078, + 0x00000007,0x0004003b,0x0000000d,0x00000085,0x00000007,0x0004003b,0x0000000d,0x00000092, + 0x00000007,0x0004003b,0x0000000d,0x00000096,0x00000007,0x0004003b,0x0000000d,0x0000009a, + 0x00000007,0x0004003b,0x0000000d,0x0000009e,0x00000007,0x0004003b,0x0000000d,0x000000ac, + 0x00000007,0x0004003b,0x0000000d,0x000000b4,0x00000007,0x0004003b,0x000000b7,0x000000b8, + 0x00000007,0x0004003b,0x000000b7,0x000000c6,0x00000007,0x0004003b,0x000000b7,0x000000d2, + 0x00000007,0x0004003b,0x000000b7,0x000000d6,0x00000007,0x0004003b,0x0000000d,0x000000da, + 0x00000007,0x0004003b,0x0000000d,0x000000e0,0x00000007,0x0004003b,0x0000000d,0x000000e6, + 0x00000007,0x0004003b,0x0000000d,0x000000ec,0x00000007,0x0004003b,0x0000000d,0x000000f3, + 0x00000007,0x0004003b,0x0000000d,0x000000f9,0x00000007,0x0004003d,0x00000006,0x0000005f, + 0x00000010,0x0004003d,0x00000006,0x00000060,0x00000011,0x00050081,0x00000006,0x00000061, + 0x0000005f,0x00000060,0x0004003d,0x00000006,0x00000062,0x00000012,0x00050081,0x00000006, + 0x00000063,0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064,0x00000016,0x00050083, + 0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006,0x00000066,0x00000017, + 0x00050083,0x00000006,0x00000067,0x00000065,0x00000066,0x0004003d,0x00000006,0x00000068, + 0x00000018,0x00050083,0x00000006,0x00000069,0x00000067,0x00000068,0x0006000c,0x00000006, + 0x0000006a,0x00000001,0x00000004,0x00000069,0x0003003e,0x0000005e,0x0000006a,0x0004003d, + 0x00000006,0x0000006c,0x00000013,0x0004003d,0x00000006,0x0000006d,0x00000010,0x00050081, + 0x00000006,0x0000006e,0x0000006c,0x0000006d,0x0004003d,0x00000006,0x0000006f,0x00000011, + 0x00050081,0x00000006,0x00000070,0x0000006e,0x0000006f,0x0004003d,0x00000006,0x00000071, + 0x00000017,0x00050083,0x00000006,0x00000072,0x00000070,0x00000071,0x0004003d,0x00000006, + 0x00000073,0x00000018,0x00050083,0x00000006,0x00000074,0x00000072,0x00000073,0x0004003d, + 0x00000006,0x00000075,0x00000015,0x00050083,0x00000006,0x00000076,0x00000074,0x00000075, + 0x0006000c,0x00000006,0x00000077,0x00000001,0x00000004,0x00000076,0x0003003e,0x0000006b, + 0x00000077,0x0004003d,0x00000006,0x00000079,0x00000010,0x0004003d,0x00000006,0x0000007a, + 0x00000013,0x00050081,0x00000006,0x0000007b,0x00000079,0x0000007a,0x0004003d,0x00000006, + 0x0000007c,0x00000016,0x00050081,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x0004003d, + 0x00000006,0x0000007e,0x00000012,0x00050083,0x00000006,0x0000007f,0x0000007d,0x0000007e, + 0x0004003d,0x00000006,0x00000080,0x00000015,0x00050083,0x00000006,0x00000081,0x0000007f, + 0x00000080,0x0004003d,0x00000006,0x00000082,0x00000018,0x00050083,0x00000006,0x00000083, + 0x00000081,0x00000082,0x0006000c,0x00000006,0x00000084,0x00000001,0x00000004,0x00000083, + 0x0003003e,0x00000078,0x00000084,0x0004003d,0x00000006,0x00000086,0x00000013,0x0004003d, + 0x00000006,0x00000087,0x00000016,0x00050081,0x00000006,0x00000088,0x00000086,0x00000087, + 0x0004003d,0x00000006,0x00000089,0x00000017,0x00050081,0x00000006,0x0000008a,0x00000088, + 0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000011,0x00050083,0x00000006,0x0000008c, + 0x0000008a,0x0000008b,0x0004003d,0x00000006,0x0000008d,0x00000012,0x00050083,0x00000006, + 0x0000008e,0x0000008c,0x0000008d,0x0004003d,0x00000006,0x0000008f,0x00000015,0x00050083, + 0x00000006,0x00000090,0x0000008e,0x0000008f,0x0006000c,0x00000006,0x00000091,0x00000001, + 0x00000004,0x00000090,0x0003003e,0x00000085,0x00000091,0x0004003d,0x00000006,0x00000093, + 0x0000005e,0x0004003d,0x00000006,0x00000094,0x00000078,0x0007000c,0x00000006,0x00000095, + 0x00000001,0x00000028,0x00000093,0x00000094,0x0003003e,0x00000092,0x00000095,0x0004003d, + 0x00000006,0x00000097,0x0000005e,0x0004003d,0x00000006,0x00000098,0x00000078,0x0007000c, + 0x00000006,0x00000099,0x00000001,0x00000025,0x00000097,0x00000098,0x0003003e,0x00000096, + 0x00000099,0x0004003d,0x00000006,0x0000009b,0x0000006b,0x0004003d,0x00000006,0x0000009c, + 0x00000085,0x0007000c,0x00000006,0x0000009d,0x00000001,0x00000028,0x0000009b,0x0000009c, + 0x0003003e,0x0000009a,0x0000009d,0x0004003d,0x00000006,0x0000009f,0x0000006b,0x0004003d, + 0x00000006,0x000000a0,0x00000085,0x0007000c,0x00000006,0x000000a1,0x00000001,0x00000025, + 0x0000009f,0x000000a0,0x0003003e,0x0000009e,0x000000a1,0x0004003d,0x00000006,0x000000a2, + 0x00000092,0x0004003d,0x00000006,0x000000a3,0x0000009a,0x00050081,0x00000006,0x000000a4, + 0x000000a2,0x000000a3,0x000500b4,0x000000a6,0x000000a7,0x000000a4,0x000000a5,0x000300f7, + 0x000000a9,0x00000000,0x000400fa,0x000000a7,0x000000a8,0x000000a9,0x000200f8,0x000000a8, + 0x000200fe,0x000000aa,0x000200f8,0x000000a9,0x0004003d,0x00000006,0x000000ad,0x00000092, + 0x0004003d,0x00000006,0x000000ae,0x00000092,0x0004003d,0x00000006,0x000000af,0x0000009a, + 0x00050081,0x00000006,0x000000b0,0x000000ae,0x000000af,0x00050088,0x00000006,0x000000b1, + 0x000000ad,0x000000b0,0x0007000c,0x00000006,0x000000b3,0x00000001,0x00000025,0x000000b1, + 0x000000b2,0x0003003e,0x000000ac,0x000000b3,0x0004003d,0x00000006,0x000000b5,0x000000ac, + 0x00050083,0x00000006,0x000000b6,0x000000b2,0x000000b5,0x0003003e,0x000000b4,0x000000b6, + 0x0004003d,0x00000006,0x000000b9,0x00000092,0x0004003d,0x00000006,0x000000ba,0x00000096, + 0x00050085,0x00000006,0x000000bc,0x000000ba,0x000000bb,0x000500ba,0x000000a6,0x000000bd, + 0x000000b9,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000092,0x000500ba,0x000000a6, + 0x000000c0,0x000000be,0x000000bf,0x000500a7,0x000000a6,0x000000c1,0x000000bd,0x000000c0, + 0x0004003d,0x00000006,0x000000c2,0x00000092,0x0004003d,0x00000006,0x000000c3,0x0000009e, + 0x000500ba,0x000000a6,0x000000c4,0x000000c2,0x000000c3,0x000500a7,0x000000a6,0x000000c5, + 0x000000c1,0x000000c4,0x0003003e,0x000000b8,0x000000c5,0x0004003d,0x00000006,0x000000c7, + 0x0000009a,0x0004003d,0x00000006,0x000000c8,0x0000009e,0x00050085,0x00000006,0x000000c9, + 0x000000c8,0x000000bb,0x000500ba,0x000000a6,0x000000ca,0x000000c7,0x000000c9,0x0004003d, + 0x00000006,0x000000cb,0x0000009a,0x000500ba,0x000000a6,0x000000cc,0x000000cb,0x000000bf, + 0x000500a7,0x000000a6,0x000000cd,0x000000ca,0x000000cc,0x0004003d,0x00000006,0x000000ce, + 0x0000009a,0x0004003d,0x00000006,0x000000cf,0x00000096,0x000500ba,0x000000a6,0x000000d0, + 0x000000ce,0x000000cf,0x000500a7,0x000000a6,0x000000d1,0x000000cd,0x000000d0,0x0003003e, + 0x000000c6,0x000000d1,0x0004003d,0x00000006,0x000000d3,0x00000092,0x0004003d,0x00000006, + 0x000000d4,0x0000005e,0x000500b4,0x000000a6,0x000000d5,0x000000d3,0x000000d4,0x0003003e, + 0x000000d2,0x000000d5,0x0004003d,0x00000006,0x000000d7,0x0000009a,0x0004003d,0x00000006, + 0x000000d8,0x0000006b,0x000500b4,0x000000a6,0x000000d9,0x000000d7,0x000000d8,0x0003003e, + 0x000000d6,0x000000d9,0x0004003d,0x000000a6,0x000000db,0x000000b8,0x0004003d,0x000000a6, + 0x000000dc,0x000000c6,0x000500a7,0x000000a6,0x000000dd,0x000000db,0x000000dc,0x0004003d, + 0x00000006,0x000000de,0x000000ac,0x000600a9,0x00000006,0x000000df,0x000000dd,0x000000de, + 0x000000b2,0x0003003e,0x000000da,0x000000df,0x0004003d,0x000000a6,0x000000e1,0x000000b8, + 0x0004003d,0x000000a6,0x000000e2,0x000000c6,0x000500a7,0x000000a6,0x000000e3,0x000000e1, + 0x000000e2,0x0004003d,0x00000006,0x000000e4,0x000000b4,0x000600a9,0x00000006,0x000000e5, + 0x000000e3,0x000000e4,0x000000b2,0x0003003e,0x000000e0,0x000000e5,0x0004003d,0x000000a6, + 0x000000e7,0x000000b8,0x0004003d,0x000000a6,0x000000e8,0x000000d2,0x000500a7,0x000000a6, + 0x000000e9,0x000000e7,0x000000e8,0x0004003d,0x00000006,0x000000ea,0x000000da,0x000600a9, + 0x00000006,0x000000eb,0x000000e9,0x000000ea,0x000000a5,0x0003003e,0x000000e6,0x000000eb, + 0x0004003d,0x000000a6,0x000000ed,0x000000b8,0x0004003d,0x000000a6,0x000000ee,0x000000d2, + 0x000400a8,0x000000a6,0x000000ef,0x000000ee,0x000500a7,0x000000a6,0x000000f0,0x000000ed, + 0x000000ef,0x0004003d,0x00000006,0x000000f1,0x000000da,0x000600a9,0x00000006,0x000000f2, + 0x000000f0,0x000000f1,0x000000a5,0x0003003e,0x000000ec,0x000000f2,0x0004003d,0x000000a6, + 0x000000f4,0x000000c6,0x0004003d,0x000000a6,0x000000f5,0x000000d6,0x000500a7,0x000000a6, + 0x000000f6,0x000000f4,0x000000f5,0x0004003d,0x00000006,0x000000f7,0x000000e0,0x000600a9, + 0x00000006,0x000000f8,0x000000f6,0x000000f7,0x000000a5,0x0003003e,0x000000f3,0x000000f8, + 0x0004003d,0x000000a6,0x000000fa,0x000000c6,0x0004003d,0x000000a6,0x000000fb,0x000000d6, + 0x000400a8,0x000000a6,0x000000fc,0x000000fb,0x000500a7,0x000000a6,0x000000fd,0x000000fa, + 0x000000fc,0x0004003d,0x00000006,0x000000fe,0x000000e0,0x000600a9,0x00000006,0x000000ff, + 0x000000fd,0x000000fe,0x000000a5,0x0003003e,0x000000f9,0x000000ff,0x0004003d,0x00000006, + 0x00000100,0x000000e6,0x0004003d,0x00000006,0x00000101,0x000000ec,0x0004003d,0x00000006, + 0x00000102,0x000000f3,0x0004003d,0x00000006,0x00000103,0x000000f9,0x00070050,0x0000000e, + 0x00000104,0x00000100,0x00000101,0x00000102,0x00000103,0x000200fe,0x00000104,0x00010038, + 0x00050036,0x0000000e,0x00000023,0x00000000,0x0000001c,0x00030037,0x0000001b,0x0000001d, + 0x00030037,0x0000001b,0x0000001e,0x00030037,0x0000001b,0x0000001f,0x00030037,0x0000001b, + 0x00000020,0x00030037,0x0000000d,0x00000021,0x00030037,0x0000000d,0x00000022,0x000200f8, + 0x00000024,0x0004003b,0x0000001b,0x00000107,0x00000007,0x0004003b,0x0000001b,0x0000010d, + 0x00000007,0x0004003d,0x0000000e,0x00000108,0x0000001d,0x0004003d,0x0000000e,0x00000109, + 0x0000001e,0x0004003d,0x00000006,0x0000010a,0x00000021,0x00070050,0x0000000e,0x0000010b, + 0x0000010a,0x0000010a,0x0000010a,0x0000010a,0x0008000c,0x0000000e,0x0000010c,0x00000001, + 0x0000002e,0x00000108,0x00000109,0x0000010b,0x0003003e,0x00000107,0x0000010c,0x0004003d, + 0x0000000e,0x0000010e,0x0000001f,0x0004003d,0x0000000e,0x0000010f,0x00000020,0x0004003d, + 0x00000006,0x00000110,0x00000021,0x00070050,0x0000000e,0x00000111,0x00000110,0x00000110, + 0x00000110,0x00000110,0x0008000c,0x0000000e,0x00000112,0x00000001,0x0000002e,0x0000010e, + 0x0000010f,0x00000111,0x0003003e,0x0000010d,0x00000112,0x0004003d,0x0000000e,0x00000113, + 0x00000107,0x0004003d,0x0000000e,0x00000114,0x0000010d,0x0004003d,0x00000006,0x00000115, + 0x00000022,0x00070050,0x0000000e,0x00000116,0x00000115,0x00000115,0x00000115,0x00000115, + 0x0008000c,0x0000000e,0x00000117,0x00000001,0x0000002e,0x00000113,0x00000114,0x00000116, + 0x000200fe,0x00000117,0x00010038,0x00050036,0x00000006,0x0000002f,0x00000000,0x00000027, + 0x00030037,0x0000000d,0x00000028,0x00030037,0x0000000d,0x00000029,0x00030037,0x0000000d, + 0x0000002a,0x00030037,0x0000000d,0x0000002b,0x00030037,0x0000000d,0x0000002c,0x00030037, + 0x0000000d,0x0000002d,0x00030037,0x00000026,0x0000002e,0x000200f8,0x00000030,0x0004003b, + 0x000000b7,0x0000011a,0x00000007,0x0004003b,0x0000000d,0x0000011e,0x00000007,0x0004003b, + 0x0000000d,0x00000123,0x00000007,0x0004003b,0x0000000d,0x00000129,0x00000007,0x0004003b, + 0x0000000d,0x00000133,0x00000007,0x0004003b,0x0000000d,0x00000139,0x00000007,0x0004003b, + 0x0000000d,0x0000013f,0x00000007,0x0004003b,0x0000000d,0x00000143,0x00000007,0x0004003b, + 0x0000000d,0x00000147,0x00000007,0x0004003d,0x00000025,0x0000011b,0x0000002e,0x000500b3, + 0x000000a6,0x0000011d,0x0000011b,0x0000011c,0x0003003e,0x0000011a,0x0000011d,0x0004003d, + 0x000000a6,0x0000011f,0x0000011a,0x0004003d,0x00000006,0x00000120,0x00000028,0x0004003d, + 0x00000006,0x00000121,0x0000002b,0x000600a9,0x00000006,0x00000122,0x0000011f,0x00000120, + 0x00000121,0x0003003e,0x0000011e,0x00000122,0x0004003d,0x00000006,0x00000124,0x00000029, + 0x0004003d,0x00000006,0x00000125,0x0000002a,0x0007000c,0x00000006,0x00000126,0x00000001, + 0x00000025,0x00000124,0x00000125,0x0004003d,0x00000006,0x00000127,0x0000011e,0x0007000c, + 0x00000006,0x00000128,0x00000001,0x00000025,0x00000126,0x00000127,0x0003003e,0x00000123, + 0x00000128,0x0004003d,0x00000006,0x0000012a,0x00000029,0x0004003d,0x00000006,0x0000012b, + 0x0000002a,0x0007000c,0x00000006,0x0000012c,0x00000001,0x00000028,0x0000012a,0x0000012b, + 0x0004003d,0x00000006,0x0000012d,0x0000011e,0x0007000c,0x00000006,0x0000012e,0x00000001, + 0x00000028,0x0000012c,0x0000012d,0x0003003e,0x00000129,0x0000012e,0x0004003d,0x000000a6, + 0x0000012f,0x0000011a,0x0004003d,0x00000006,0x00000130,0x0000002a,0x0004003d,0x00000006, + 0x00000131,0x0000002d,0x000600a9,0x00000006,0x00000132,0x0000012f,0x00000130,0x00000131, + 0x0003003e,0x0000011e,0x00000132,0x0004003d,0x00000006,0x00000134,0x0000002b,0x0004003d, + 0x00000006,0x00000135,0x0000002c,0x0007000c,0x00000006,0x00000136,0x00000001,0x00000025, + 0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x0000011e,0x0007000c,0x00000006, + 0x00000138,0x00000001,0x00000025,0x00000136,0x00000137,0x0003003e,0x00000133,0x00000138, + 0x0004003d,0x00000006,0x0000013a,0x0000002b,0x0004003d,0x00000006,0x0000013b,0x0000002c, + 0x0007000c,0x00000006,0x0000013c,0x00000001,0x00000028,0x0000013a,0x0000013b,0x0004003d, + 0x00000006,0x0000013d,0x0000011e,0x0007000c,0x00000006,0x0000013e,0x00000001,0x00000028, + 0x0000013c,0x0000013d,0x0003003e,0x00000139,0x0000013e,0x0004003d,0x00000006,0x00000140, + 0x00000129,0x0004003d,0x00000006,0x00000141,0x00000123,0x00050083,0x00000006,0x00000142, + 0x00000140,0x00000141,0x0003003e,0x0000013f,0x00000142,0x0004003d,0x00000006,0x00000144, + 0x00000139,0x0004003d,0x00000006,0x00000145,0x00000133,0x00050083,0x00000006,0x00000146, + 0x00000144,0x00000145,0x0003003e,0x00000143,0x00000146,0x0004003d,0x00000006,0x00000148, + 0x0000013f,0x0004003d,0x00000006,0x00000149,0x00000143,0x0007000c,0x00000006,0x0000014a, + 0x00000001,0x00000028,0x00000148,0x00000149,0x0004003d,0x00000006,0x0000014b,0x0000013f, + 0x0004003d,0x00000006,0x0000014c,0x00000143,0x0007000c,0x00000006,0x0000014d,0x00000001, + 0x00000025,0x0000014b,0x0000014c,0x00050081,0x00000006,0x0000014f,0x0000014d,0x0000014e, + 0x00050088,0x00000006,0x00000150,0x0000014a,0x0000014f,0x0003003e,0x00000147,0x00000150, + 0x0004003d,0x00000006,0x00000151,0x00000147,0x00050083,0x00000006,0x00000153,0x00000151, + 0x00000152,0x00050085,0x00000006,0x00000155,0x00000153,0x00000154,0x0008000c,0x00000006, + 0x00000156,0x00000001,0x0000002b,0x00000155,0x000000a5,0x000000b2,0x00050083,0x00000006, + 0x00000157,0x000000b2,0x00000156,0x00050085,0x00000006,0x00000158,0x00000157,0x000000b2, + 0x000200fe,0x00000158,0x00010038,0x00050036,0x00000006,0x00000038,0x00000000,0x00000035, + 0x00030037,0x00000034,0x00000036,0x00030037,0x00000026,0x00000037,0x000200f8,0x00000039, + 0x0004003b,0x0000001b,0x0000015f,0x00000007,0x0004003b,0x0000001b,0x0000016c,0x00000007, + 0x0004003b,0x0000001b,0x00000173,0x00000007,0x0004003b,0x0000001b,0x00000178,0x00000007, + 0x0004003b,0x0000000d,0x0000017e,0x00000007,0x0004003b,0x0000000d,0x000001ad,0x00000007, + 0x0004003b,0x0000000d,0x000001d8,0x00000007,0x0004003b,0x0000000d,0x000001e0,0x00000007, + 0x0004003b,0x0000000d,0x000001ec,0x00000007,0x0004003b,0x0000000d,0x000001fc,0x00000007, + 0x0004003b,0x0000000d,0x000001ff,0x00000007,0x0004003b,0x0000000d,0x00000202,0x00000007, + 0x0004003b,0x0000000d,0x00000205,0x00000007,0x0004003b,0x0000000d,0x00000208,0x00000007, + 0x0004003b,0x0000000d,0x0000020b,0x00000007,0x0004003b,0x00000026,0x0000020e,0x00000007, + 0x0004003d,0x00000025,0x0000015b,0x00000037,0x0008000c,0x00000025,0x0000015e,0x00000001, + 0x0000002d,0x0000015b,0x0000015c,0x0000015d,0x0003003e,0x00000037,0x0000015e,0x0004003d, + 0x00000025,0x00000166,0x00000037,0x00050084,0x00000025,0x00000168,0x00000166,0x00000167, + 0x00060041,0x00000169,0x0000016a,0x00000165,0x0000015c,0x00000168,0x0004003d,0x0000000e, + 0x0000016b,0x0000016a,0x0003003e,0x0000015f,0x0000016b,0x0004003d,0x00000025,0x0000016d, + 0x00000037,0x00050084,0x00000025,0x0000016e,0x0000016d,0x00000167,0x00050080,0x00000025, + 0x00000170,0x0000016e,0x0000016f,0x00060041,0x00000169,0x00000171,0x00000165,0x0000015c, + 0x00000170,0x0004003d,0x0000000e,0x00000172,0x00000171,0x0003003e,0x0000016c,0x00000172, + 0x0004003d,0x00000025,0x00000174,0x00000037,0x00050084,0x00000025,0x00000175,0x00000174, + 0x00000167,0x00060041,0x00000169,0x00000176,0x00000165,0x0000016f,0x00000175,0x0004003d, + 0x0000000e,0x00000177,0x00000176,0x0003003e,0x00000173,0x00000177,0x0004003d,0x00000025, + 0x00000179,0x00000037,0x00050084,0x00000025,0x0000017a,0x00000179,0x00000167,0x00050080, + 0x00000025,0x0000017b,0x0000017a,0x0000016f,0x00060041,0x00000169,0x0000017c,0x00000165, + 0x0000016f,0x0000017b,0x0004003d,0x0000000e,0x0000017d,0x0000017c,0x0003003e,0x00000178, + 0x0000017d,0x0003003e,0x0000017e,0x000000a5,0x00050041,0x0000000d,0x0000017f,0x0000015f, + 0x0000004c,0x0004003d,0x00000006,0x00000180,0x0000017f,0x00050041,0x0000000d,0x00000181, + 0x00000036,0x0000015c,0x0004003d,0x00000006,0x00000182,0x00000181,0x00050085,0x00000006, + 0x00000183,0x00000180,0x00000182,0x0004003d,0x00000006,0x00000184,0x0000017e,0x00050081, + 0x00000006,0x00000185,0x00000184,0x00000183,0x0003003e,0x0000017e,0x00000185,0x00050041, + 0x0000000d,0x00000186,0x0000015f,0x00000051,0x0004003d,0x00000006,0x00000187,0x00000186, + 0x00050041,0x0000000d,0x00000188,0x00000036,0x0000016f,0x0004003d,0x00000006,0x00000189, + 0x00000188,0x00050085,0x00000006,0x0000018a,0x00000187,0x00000189,0x0004003d,0x00000006, + 0x0000018b,0x0000017e,0x00050081,0x00000006,0x0000018c,0x0000018b,0x0000018a,0x0003003e, + 0x0000017e,0x0000018c,0x00050041,0x0000000d,0x0000018d,0x0000015f,0x00000057,0x0004003d, + 0x00000006,0x0000018e,0x0000018d,0x00050041,0x0000000d,0x0000018f,0x00000036,0x00000167, + 0x0004003d,0x00000006,0x00000190,0x0000018f,0x00050085,0x00000006,0x00000191,0x0000018e, + 0x00000190,0x0004003d,0x00000006,0x00000192,0x0000017e,0x00050081,0x00000006,0x00000193, + 0x00000192,0x00000191,0x0003003e,0x0000017e,0x00000193,0x00050041,0x0000000d,0x00000195, + 0x0000015f,0x00000194,0x0004003d,0x00000006,0x00000196,0x00000195,0x00050041,0x0000000d, + 0x00000198,0x00000036,0x00000197,0x0004003d,0x00000006,0x00000199,0x00000198,0x00050085, + 0x00000006,0x0000019a,0x00000196,0x00000199,0x0004003d,0x00000006,0x0000019b,0x0000017e, + 0x00050081,0x00000006,0x0000019c,0x0000019b,0x0000019a,0x0003003e,0x0000017e,0x0000019c, + 0x00050041,0x0000000d,0x0000019d,0x0000016c,0x0000004c,0x0004003d,0x00000006,0x0000019e, + 0x0000019d,0x00050041,0x0000000d,0x000001a0,0x00000036,0x0000019f,0x0004003d,0x00000006, + 0x000001a1,0x000001a0,0x00050085,0x00000006,0x000001a2,0x0000019e,0x000001a1,0x0004003d, + 0x00000006,0x000001a3,0x0000017e,0x00050081,0x00000006,0x000001a4,0x000001a3,0x000001a2, + 0x0003003e,0x0000017e,0x000001a4,0x00050041,0x0000000d,0x000001a5,0x0000016c,0x00000051, + 0x0004003d,0x00000006,0x000001a6,0x000001a5,0x00050041,0x0000000d,0x000001a8,0x00000036, + 0x000001a7,0x0004003d,0x00000006,0x000001a9,0x000001a8,0x00050085,0x00000006,0x000001aa, + 0x000001a6,0x000001a9,0x0004003d,0x00000006,0x000001ab,0x0000017e,0x00050081,0x00000006, + 0x000001ac,0x000001ab,0x000001aa,0x0003003e,0x0000017e,0x000001ac,0x0003003e,0x000001ad, + 0x000000a5,0x00050041,0x0000000d,0x000001ae,0x00000173,0x0000004c,0x0004003d,0x00000006, + 0x000001af,0x000001ae,0x00050041,0x0000000d,0x000001b0,0x00000036,0x0000015c,0x0004003d, + 0x00000006,0x000001b1,0x000001b0,0x00050085,0x00000006,0x000001b2,0x000001af,0x000001b1, + 0x0004003d,0x00000006,0x000001b3,0x000001ad,0x00050081,0x00000006,0x000001b4,0x000001b3, + 0x000001b2,0x0003003e,0x000001ad,0x000001b4,0x00050041,0x0000000d,0x000001b5,0x00000173, + 0x00000051,0x0004003d,0x00000006,0x000001b6,0x000001b5,0x00050041,0x0000000d,0x000001b7, + 0x00000036,0x0000016f,0x0004003d,0x00000006,0x000001b8,0x000001b7,0x00050085,0x00000006, + 0x000001b9,0x000001b6,0x000001b8,0x0004003d,0x00000006,0x000001ba,0x000001ad,0x00050081, + 0x00000006,0x000001bb,0x000001ba,0x000001b9,0x0003003e,0x000001ad,0x000001bb,0x00050041, + 0x0000000d,0x000001bc,0x00000173,0x00000057,0x0004003d,0x00000006,0x000001bd,0x000001bc, + 0x00050041,0x0000000d,0x000001be,0x00000036,0x00000167,0x0004003d,0x00000006,0x000001bf, + 0x000001be,0x00050085,0x00000006,0x000001c0,0x000001bd,0x000001bf,0x0004003d,0x00000006, + 0x000001c1,0x000001ad,0x00050081,0x00000006,0x000001c2,0x000001c1,0x000001c0,0x0003003e, + 0x000001ad,0x000001c2,0x00050041,0x0000000d,0x000001c3,0x00000173,0x00000194,0x0004003d, + 0x00000006,0x000001c4,0x000001c3,0x00050041,0x0000000d,0x000001c5,0x00000036,0x00000197, + 0x0004003d,0x00000006,0x000001c6,0x000001c5,0x00050085,0x00000006,0x000001c7,0x000001c4, + 0x000001c6,0x0004003d,0x00000006,0x000001c8,0x000001ad,0x00050081,0x00000006,0x000001c9, + 0x000001c8,0x000001c7,0x0003003e,0x000001ad,0x000001c9,0x00050041,0x0000000d,0x000001ca, + 0x00000178,0x0000004c,0x0004003d,0x00000006,0x000001cb,0x000001ca,0x00050041,0x0000000d, + 0x000001cc,0x00000036,0x0000019f,0x0004003d,0x00000006,0x000001cd,0x000001cc,0x00050085, + 0x00000006,0x000001ce,0x000001cb,0x000001cd,0x0004003d,0x00000006,0x000001cf,0x000001ad, + 0x00050081,0x00000006,0x000001d0,0x000001cf,0x000001ce,0x0003003e,0x000001ad,0x000001d0, + 0x00050041,0x0000000d,0x000001d1,0x00000178,0x00000051,0x0004003d,0x00000006,0x000001d2, + 0x000001d1,0x00050041,0x0000000d,0x000001d3,0x00000036,0x000001a7,0x0004003d,0x00000006, + 0x000001d4,0x000001d3,0x00050085,0x00000006,0x000001d5,0x000001d2,0x000001d4,0x0004003d, + 0x00000006,0x000001d6,0x000001ad,0x00050081,0x00000006,0x000001d7,0x000001d6,0x000001d5, + 0x0003003e,0x000001ad,0x000001d7,0x0004003d,0x00000006,0x000001d9,0x0000017e,0x00050083, + 0x00000006,0x000001db,0x000001d9,0x000001da,0x00050085,0x00000006,0x000001dd,0x000001db, + 0x000001dc,0x0008000c,0x00000006,0x000001de,0x00000001,0x0000002b,0x000001dd,0x000000a5, + 0x000000b2,0x00050083,0x00000006,0x000001df,0x000000b2,0x000001de,0x0003003e,0x000001d8, + 0x000001df,0x0004003d,0x00000006,0x000001e1,0x000001d8,0x0004003d,0x00000006,0x000001e4, + 0x000001e3,0x00050085,0x00000006,0x000001e5,0x000001e1,0x000001e4,0x0004003d,0x00000006, + 0x000001e7,0x000001e6,0x00050081,0x00000006,0x000001e8,0x000001e5,0x000001e7,0x0003003e, + 0x000001e0,0x000001e8,0x0004003d,0x00000006,0x000001e9,0x000001e0,0x0004003d,0x00000006, + 0x000001ea,0x000001ad,0x00050085,0x00000006,0x000001eb,0x000001ea,0x000001e9,0x0003003e, + 0x000001ad,0x000001eb,0x0004003d,0x00000006,0x000001ed,0x000001d8,0x0004003d,0x00000006, + 0x000001ef,0x000001ee,0x00050085,0x00000006,0x000001f0,0x000001ed,0x000001ef,0x0004003d, + 0x00000006,0x000001f2,0x000001f1,0x00050081,0x00000006,0x000001f3,0x000001f0,0x000001f2, + 0x0004003d,0x00000006,0x000001f4,0x0000017e,0x00050085,0x00000006,0x000001f5,0x000001f3, + 0x000001f4,0x0003003e,0x000001ec,0x000001f5,0x0004003d,0x00000006,0x000001f6,0x000001ec, + 0x0004003d,0x00000006,0x000001f7,0x000001ec,0x0004007f,0x00000006,0x000001f8,0x000001f7, + 0x0004003d,0x00000006,0x000001f9,0x000001ad,0x0007000c,0x00000006,0x000001fa,0x00000001, + 0x00000028,0x000001f8,0x000001f9,0x0007000c,0x00000006,0x000001fb,0x00000001,0x00000025, + 0x000001f6,0x000001fa,0x0003003e,0x000001ad,0x000001fb,0x00050041,0x0000000d,0x000001fd, + 0x00000036,0x0000015c,0x0004003d,0x00000006,0x000001fe,0x000001fd,0x0003003e,0x000001fc, + 0x000001fe,0x00050041,0x0000000d,0x00000200,0x00000036,0x0000016f,0x0004003d,0x00000006, + 0x00000201,0x00000200,0x0003003e,0x000001ff,0x00000201,0x00050041,0x0000000d,0x00000203, + 0x00000036,0x00000167,0x0004003d,0x00000006,0x00000204,0x00000203,0x0003003e,0x00000202, + 0x00000204,0x00050041,0x0000000d,0x00000206,0x00000036,0x00000197,0x0004003d,0x00000006, + 0x00000207,0x00000206,0x0003003e,0x00000205,0x00000207,0x00050041,0x0000000d,0x00000209, + 0x00000036,0x0000019f,0x0004003d,0x00000006,0x0000020a,0x00000209,0x0003003e,0x00000208, + 0x0000020a,0x00050041,0x0000000d,0x0000020c,0x00000036,0x000001a7,0x0004003d,0x00000006, + 0x0000020d,0x0000020c,0x0003003e,0x0000020b,0x0000020d,0x0004003d,0x00000025,0x0000020f, + 0x00000037,0x0003003e,0x0000020e,0x0000020f,0x000b0039,0x00000006,0x00000210,0x0000002f, + 0x000001fc,0x000001ff,0x00000202,0x00000205,0x00000208,0x0000020b,0x0000020e,0x0004003d, + 0x00000006,0x00000211,0x000001ad,0x00050085,0x00000006,0x00000212,0x00000211,0x00000210, + 0x0003003e,0x000001ad,0x00000212,0x0004003d,0x00000006,0x00000213,0x0000017e,0x0004003d, + 0x00000006,0x00000214,0x000001ad,0x00050081,0x00000006,0x00000215,0x00000213,0x00000214, + 0x000200fe,0x00000215,0x00010038,0x00050036,0x00000006,0x00000040,0x00000000,0x0000003c, + 0x00030037,0x0000003b,0x0000003d,0x00030037,0x00000026,0x0000003e,0x00030037,0x00000026, + 0x0000003f,0x000200f8,0x00000041,0x0004003b,0x0000001b,0x0000021c,0x00000007,0x0004003b, + 0x0000001b,0x00000221,0x00000007,0x0004003b,0x0000001b,0x00000227,0x00000007,0x0004003b, + 0x0000001b,0x0000022c,0x00000007,0x0004003b,0x00000034,0x00000232,0x00000007,0x0004003b, + 0x00000034,0x00000240,0x00000007,0x0004003b,0x0000000d,0x0000024e,0x00000007,0x0004003b, + 0x00000026,0x0000024f,0x00000007,0x0004003b,0x0000000d,0x00000258,0x00000007,0x0004003b, + 0x00000026,0x00000259,0x00000007,0x0004003d,0x00000025,0x00000218,0x0000003e,0x0008000c, + 0x00000025,0x00000219,0x00000001,0x0000002d,0x00000218,0x0000015c,0x0000015d,0x0003003e, + 0x0000003e,0x00000219,0x0004003d,0x00000025,0x0000021a,0x0000003f,0x0008000c,0x00000025, + 0x0000021b,0x00000001,0x0000002d,0x0000021a,0x0000015c,0x0000015d,0x0003003e,0x0000003f, + 0x0000021b,0x0004003d,0x00000025,0x0000021d,0x0000003f,0x00050084,0x00000025,0x0000021e, + 0x0000021d,0x00000167,0x00060041,0x00000169,0x0000021f,0x00000165,0x0000015c,0x0000021e, + 0x0004003d,0x0000000e,0x00000220,0x0000021f,0x0003003e,0x0000021c,0x00000220,0x0004003d, + 0x00000025,0x00000222,0x0000003f,0x00050084,0x00000025,0x00000223,0x00000222,0x00000167, + 0x00050080,0x00000025,0x00000224,0x00000223,0x0000016f,0x00060041,0x00000169,0x00000225, + 0x00000165,0x0000015c,0x00000224,0x0004003d,0x0000000e,0x00000226,0x00000225,0x0003003e, + 0x00000221,0x00000226,0x0004003d,0x00000025,0x00000228,0x0000003e,0x00050084,0x00000025, + 0x00000229,0x00000228,0x00000167,0x00060041,0x00000169,0x0000022a,0x00000165,0x0000015c, + 0x00000229,0x0004003d,0x0000000e,0x0000022b,0x0000022a,0x0003003e,0x00000227,0x0000022b, + 0x0004003d,0x00000025,0x0000022d,0x0000003e,0x00050084,0x00000025,0x0000022e,0x0000022d, + 0x00000167,0x00050080,0x00000025,0x0000022f,0x0000022e,0x0000016f,0x00060041,0x00000169, + 0x00000230,0x00000165,0x0000015c,0x0000022f,0x0004003d,0x0000000e,0x00000231,0x00000230, + 0x0003003e,0x0000022c,0x00000231,0x00050041,0x0000000d,0x00000233,0x0000021c,0x0000004c, + 0x0004003d,0x00000006,0x00000234,0x00000233,0x00050041,0x0000000d,0x00000235,0x0000021c, + 0x00000051,0x0004003d,0x00000006,0x00000236,0x00000235,0x00050041,0x0000000d,0x00000237, + 0x0000021c,0x00000057,0x0004003d,0x00000006,0x00000238,0x00000237,0x00050041,0x0000000d, + 0x00000239,0x0000021c,0x00000194,0x0004003d,0x00000006,0x0000023a,0x00000239,0x00050041, + 0x0000000d,0x0000023b,0x00000221,0x0000004c,0x0004003d,0x00000006,0x0000023c,0x0000023b, + 0x00050041,0x0000000d,0x0000023d,0x00000221,0x00000051,0x0004003d,0x00000006,0x0000023e, + 0x0000023d,0x00090050,0x00000033,0x0000023f,0x00000234,0x00000236,0x00000238,0x0000023a, + 0x0000023c,0x0000023e,0x0003003e,0x00000232,0x0000023f,0x00050041,0x0000000d,0x00000241, + 0x00000227,0x0000004c,0x0004003d,0x00000006,0x00000242,0x00000241,0x00050041,0x0000000d, + 0x00000243,0x00000227,0x00000051,0x0004003d,0x00000006,0x00000244,0x00000243,0x00050041, + 0x0000000d,0x00000245,0x00000227,0x00000057,0x0004003d,0x00000006,0x00000246,0x00000245, + 0x00050041,0x0000000d,0x00000247,0x00000227,0x00000194,0x0004003d,0x00000006,0x00000248, + 0x00000247,0x00050041,0x0000000d,0x00000249,0x0000022c,0x0000004c,0x0004003d,0x00000006, + 0x0000024a,0x00000249,0x00050041,0x0000000d,0x0000024b,0x0000022c,0x00000051,0x0004003d, + 0x00000006,0x0000024c,0x0000024b,0x00090050,0x00000033,0x0000024d,0x00000242,0x00000244, + 0x00000246,0x00000248,0x0000024a,0x0000024c,0x0003003e,0x00000240,0x0000024d,0x0003003e, + 0x0000024e,0x000000a5,0x0003003e,0x0000024f,0x0000015c,0x000200f9,0x00000250,0x000200f8, + 0x00000250,0x000400f6,0x00000252,0x00000253,0x00000000,0x000200f9,0x00000254,0x000200f8, + 0x00000254,0x0004003d,0x00000025,0x00000255,0x0000024f,0x000500b1,0x000000a6,0x00000257, + 0x00000255,0x00000256,0x000400fa,0x00000257,0x00000251,0x00000252,0x000200f8,0x00000251, + 0x0003003e,0x00000258,0x000000a5,0x0003003e,0x00000259,0x0000015c,0x000200f9,0x0000025a, + 0x000200f8,0x0000025a,0x000400f6,0x0000025c,0x0000025d,0x00000000,0x000200f9,0x0000025e, + 0x000200f8,0x0000025e,0x0004003d,0x00000025,0x0000025f,0x00000259,0x000500b1,0x000000a6, + 0x00000260,0x0000025f,0x00000256,0x000400fa,0x00000260,0x0000025b,0x0000025c,0x000200f8, + 0x0000025b,0x0004003d,0x00000025,0x00000261,0x00000259,0x0004003d,0x00000025,0x00000262, + 0x0000024f,0x00060041,0x0000000d,0x00000263,0x0000003d,0x00000261,0x00000262,0x0004003d, + 0x00000006,0x00000264,0x00000263,0x0004003d,0x00000025,0x00000265,0x00000259,0x00050041, + 0x0000000d,0x00000266,0x00000232,0x00000265,0x0004003d,0x00000006,0x00000267,0x00000266, + 0x00050085,0x00000006,0x00000268,0x00000264,0x00000267,0x0004003d,0x00000006,0x00000269, + 0x00000258,0x00050081,0x00000006,0x0000026a,0x00000269,0x00000268,0x0003003e,0x00000258, + 0x0000026a,0x000200f9,0x0000025d,0x000200f8,0x0000025d,0x0004003d,0x00000025,0x0000026b, + 0x00000259,0x00050080,0x00000025,0x0000026c,0x0000026b,0x0000016f,0x0003003e,0x00000259, + 0x0000026c,0x000200f9,0x0000025a,0x000200f8,0x0000025c,0x0004003d,0x00000006,0x0000026d, + 0x00000258,0x0004003d,0x00000025,0x0000026e,0x0000024f,0x00050041,0x0000000d,0x0000026f, + 0x00000240,0x0000026e,0x0004003d,0x00000006,0x00000270,0x0000026f,0x00050085,0x00000006, + 0x00000271,0x0000026d,0x00000270,0x0004003d,0x00000006,0x00000272,0x0000024e,0x00050081, + 0x00000006,0x00000273,0x00000272,0x00000271,0x0003003e,0x0000024e,0x00000273,0x000200f9, + 0x00000253,0x000200f8,0x00000253,0x0004003d,0x00000025,0x00000274,0x0000024f,0x00050080, + 0x00000025,0x00000275,0x00000274,0x0000016f,0x0003003e,0x0000024f,0x00000275,0x000200f9, + 0x00000250,0x000200f8,0x00000252,0x0004003d,0x00000006,0x00000276,0x0000024e,0x000200fe, + 0x00000276,0x00010038,0x00050036,0x00000006,0x00000049,0x00000000,0x00000042,0x00030037, + 0x0000003b,0x00000043,0x00030037,0x0000000d,0x00000044,0x00030037,0x0000000d,0x00000045, + 0x00030037,0x00000026,0x00000046,0x00030037,0x00000026,0x00000047,0x00030037,0x0000001b, + 0x00000048,0x000200f8,0x0000004a,0x0004003b,0x0000000d,0x00000279,0x00000007,0x0004003b, + 0x00000026,0x0000027f,0x00000007,0x0004003b,0x00000034,0x00000287,0x00000007,0x0004003b, + 0x00000034,0x00000294,0x00000007,0x0004003b,0x00000026,0x00000296,0x00000007,0x0004003b, + 0x00000026,0x000002a3,0x00000007,0x0004003b,0x00000034,0x000002ab,0x00000007,0x0004003b, + 0x00000034,0x000002b8,0x00000007,0x0004003b,0x00000026,0x000002ba,0x00000007,0x0004003b, + 0x0000000d,0x000002c7,0x00000007,0x0004003b,0x000002d0,0x000002d1,0x00000007,0x0004003b, + 0x0000000d,0x000002e9,0x00000007,0x0004003b,0x0000000d,0x000002ec,0x00000007,0x0004003b, + 0x0000000d,0x000002f5,0x00000007,0x0004003b,0x0000000d,0x000002f8,0x00000007,0x0004003b, + 0x0000000d,0x00000301,0x00000007,0x0004003b,0x0000000d,0x00000304,0x00000007,0x0004003b, + 0x0000000d,0x0000030d,0x00000007,0x0004003b,0x0000000d,0x00000310,0x00000007,0x0004003b, + 0x0000000d,0x00000335,0x00000007,0x0004003b,0x00000026,0x0000033d,0x00000007,0x0004003b, + 0x00000034,0x00000345,0x00000007,0x0004003b,0x00000026,0x00000351,0x00000007,0x0004003b, + 0x00000034,0x00000364,0x00000007,0x0004003b,0x00000026,0x00000366,0x00000007,0x0004003b, + 0x0000000d,0x00000372,0x00000007,0x0004003b,0x000002d0,0x00000377,0x00000007,0x0004003b, + 0x0000000d,0x0000038f,0x00000007,0x0004003b,0x0000000d,0x00000392,0x00000007,0x0004003b, + 0x0000000d,0x0000039b,0x00000007,0x0004003b,0x0000000d,0x0000039e,0x00000007,0x0004003b, + 0x0000000d,0x000003a7,0x00000007,0x0004003b,0x0000000d,0x000003aa,0x00000007,0x0004003b, + 0x0000000d,0x000003b3,0x00000007,0x0004003b,0x0000000d,0x000003b6,0x00000007,0x0004003b, + 0x0000000d,0x000003db,0x00000007,0x0004003b,0x00000026,0x000003e4,0x00000007,0x0004003b, + 0x00000034,0x000003ec,0x00000007,0x0004003b,0x00000026,0x000003f8,0x00000007,0x0004003b, + 0x00000034,0x0000040a,0x00000007,0x0004003b,0x00000026,0x0000040c,0x00000007,0x0003003e, + 0x00000279,0x000000a5,0x00050041,0x0000000d,0x0000027a,0x00000048,0x0000004c,0x0004003d, + 0x00000006,0x0000027b,0x0000027a,0x000500ba,0x000000a6,0x0000027c,0x0000027b,0x000000a5, + 0x000300f7,0x0000027e,0x00000000,0x000400fa,0x0000027c,0x0000027d,0x0000027e,0x000200f8, + 0x0000027d,0x0003003e,0x0000027f,0x0000015c,0x000200f9,0x00000280,0x000200f8,0x00000280, + 0x000400f6,0x00000282,0x00000283,0x00000000,0x000200f9,0x00000284,0x000200f8,0x00000284, + 0x0004003d,0x00000025,0x00000285,0x0000027f,0x000500b1,0x000000a6,0x00000286,0x00000285, + 0x00000256,0x000400fa,0x00000286,0x00000281,0x00000282,0x000200f8,0x00000281,0x0004003d, + 0x00000025,0x00000288,0x0000027f,0x0004003d,0x00000025,0x00000289,0x0000027f,0x00060041, + 0x0000000d,0x0000028a,0x00000043,0x00000289,0x00000167,0x0004003d,0x00000006,0x0000028b, + 0x0000028a,0x0004003d,0x00000025,0x0000028c,0x0000027f,0x00060041,0x0000000d,0x0000028d, + 0x00000043,0x0000028c,0x00000197,0x0004003d,0x00000006,0x0000028e,0x0000028d,0x0004003d, + 0x00000006,0x0000028f,0x00000044,0x0008000c,0x00000006,0x00000290,0x00000001,0x0000002e, + 0x0000028b,0x0000028e,0x0000028f,0x00050041,0x0000000d,0x00000291,0x00000287,0x00000288, + 0x0003003e,0x00000291,0x00000290,0x000200f9,0x00000283,0x000200f8,0x00000283,0x0004003d, + 0x00000025,0x00000292,0x0000027f,0x00050080,0x00000025,0x00000293,0x00000292,0x0000016f, + 0x0003003e,0x0000027f,0x00000293,0x000200f9,0x00000280,0x000200f8,0x00000282,0x0004003d, + 0x00000033,0x00000295,0x00000287,0x0003003e,0x00000294,0x00000295,0x0004003d,0x00000025, + 0x00000297,0x00000047,0x0003003e,0x00000296,0x00000297,0x00060039,0x00000006,0x00000298, + 0x00000038,0x00000294,0x00000296,0x00050041,0x0000000d,0x00000299,0x00000048,0x0000004c, + 0x0004003d,0x00000006,0x0000029a,0x00000299,0x00050085,0x00000006,0x0000029b,0x00000298, + 0x0000029a,0x0004003d,0x00000006,0x0000029c,0x00000279,0x00050081,0x00000006,0x0000029d, + 0x0000029c,0x0000029b,0x0003003e,0x00000279,0x0000029d,0x000200f9,0x0000027e,0x000200f8, + 0x0000027e,0x00050041,0x0000000d,0x0000029e,0x00000048,0x00000051,0x0004003d,0x00000006, + 0x0000029f,0x0000029e,0x000500ba,0x000000a6,0x000002a0,0x0000029f,0x000000a5,0x000300f7, + 0x000002a2,0x00000000,0x000400fa,0x000002a0,0x000002a1,0x000002a2,0x000200f8,0x000002a1, + 0x0003003e,0x000002a3,0x0000015c,0x000200f9,0x000002a4,0x000200f8,0x000002a4,0x000400f6, + 0x000002a6,0x000002a7,0x00000000,0x000200f9,0x000002a8,0x000200f8,0x000002a8,0x0004003d, + 0x00000025,0x000002a9,0x000002a3,0x000500b1,0x000000a6,0x000002aa,0x000002a9,0x00000256, + 0x000400fa,0x000002aa,0x000002a5,0x000002a6,0x000200f8,0x000002a5,0x0004003d,0x00000025, + 0x000002ac,0x000002a3,0x0004003d,0x00000025,0x000002ad,0x000002a3,0x00060041,0x0000000d, + 0x000002ae,0x00000043,0x00000167,0x000002ad,0x0004003d,0x00000006,0x000002af,0x000002ae, + 0x0004003d,0x00000025,0x000002b0,0x000002a3,0x00060041,0x0000000d,0x000002b1,0x00000043, + 0x00000197,0x000002b0,0x0004003d,0x00000006,0x000002b2,0x000002b1,0x0004003d,0x00000006, + 0x000002b3,0x00000045,0x0008000c,0x00000006,0x000002b4,0x00000001,0x0000002e,0x000002af, + 0x000002b2,0x000002b3,0x00050041,0x0000000d,0x000002b5,0x000002ab,0x000002ac,0x0003003e, + 0x000002b5,0x000002b4,0x000200f9,0x000002a7,0x000200f8,0x000002a7,0x0004003d,0x00000025, + 0x000002b6,0x000002a3,0x00050080,0x00000025,0x000002b7,0x000002b6,0x0000016f,0x0003003e, + 0x000002a3,0x000002b7,0x000200f9,0x000002a4,0x000200f8,0x000002a6,0x0004003d,0x00000033, + 0x000002b9,0x000002ab,0x0003003e,0x000002b8,0x000002b9,0x0004003d,0x00000025,0x000002bb, + 0x00000046,0x0003003e,0x000002ba,0x000002bb,0x00060039,0x00000006,0x000002bc,0x00000038, + 0x000002b8,0x000002ba,0x00050041,0x0000000d,0x000002bd,0x00000048,0x00000051,0x0004003d, + 0x00000006,0x000002be,0x000002bd,0x00050085,0x00000006,0x000002bf,0x000002bc,0x000002be, + 0x0004003d,0x00000006,0x000002c0,0x00000279,0x00050081,0x00000006,0x000002c1,0x000002c0, + 0x000002bf,0x0003003e,0x00000279,0x000002c1,0x000200f9,0x000002a2,0x000200f8,0x000002a2, + 0x00050041,0x0000000d,0x000002c2,0x00000048,0x00000057,0x0004003d,0x00000006,0x000002c3, + 0x000002c2,0x000500ba,0x000000a6,0x000002c4,0x000002c3,0x000000a5,0x000300f7,0x000002c6, + 0x00000000,0x000400fa,0x000002c4,0x000002c5,0x000002c6,0x000200f8,0x000002c5,0x0004003d, + 0x00000006,0x000002c9,0x00000044,0x0004003d,0x00000006,0x000002ca,0x00000045,0x00050083, + 0x00000006,0x000002cb,0x000002c9,0x000002ca,0x00050085,0x00000006,0x000002cc,0x000002c8, + 0x000002cb,0x00050081,0x00000006,0x000002cd,0x000002c8,0x000002cc,0x0003003e,0x000002c7, + 0x000002cd,0x00060041,0x0000000d,0x000002d2,0x00000043,0x00000167,0x0000016f,0x0004003d, + 0x00000006,0x000002d3,0x000002d2,0x00060041,0x0000000d,0x000002d4,0x00000043,0x0000016f, + 0x00000167,0x0004003d,0x00000006,0x000002d5,0x000002d4,0x0004003d,0x00000006,0x000002d6, + 0x000002c7,0x0008000c,0x00000006,0x000002d7,0x00000001,0x0000002e,0x000002d3,0x000002d5, + 0x000002d6,0x00050041,0x0000000d,0x000002d8,0x000002d1,0x0000016f,0x0003003e,0x000002d8, + 0x000002d7,0x00060041,0x0000000d,0x000002d9,0x00000043,0x00000197,0x00000167,0x0004003d, + 0x00000006,0x000002da,0x000002d9,0x00060041,0x0000000d,0x000002db,0x00000043,0x00000167, + 0x00000197,0x0004003d,0x00000006,0x000002dc,0x000002db,0x0004003d,0x00000006,0x000002dd, + 0x000002c7,0x0008000c,0x00000006,0x000002de,0x00000001,0x0000002e,0x000002da,0x000002dc, + 0x000002dd,0x00050041,0x0000000d,0x000002df,0x000002d1,0x00000197,0x0003003e,0x000002df, + 0x000002de,0x00060041,0x0000000d,0x000002e0,0x00000043,0x0000019f,0x00000197,0x0004003d, + 0x00000006,0x000002e1,0x000002e0,0x00060041,0x0000000d,0x000002e2,0x00000043,0x00000197, + 0x0000019f,0x0004003d,0x00000006,0x000002e3,0x000002e2,0x0004003d,0x00000006,0x000002e4, + 0x000002c7,0x0008000c,0x00000006,0x000002e5,0x00000001,0x0000002e,0x000002e1,0x000002e3, + 0x000002e4,0x00050041,0x0000000d,0x000002e6,0x000002d1,0x000001a7,0x0003003e,0x000002e6, + 0x000002e5,0x0004003d,0x00000006,0x000002e7,0x000002c7,0x00050083,0x00000006,0x000002e8, + 0x000002e7,0x000002c8,0x0003003e,0x000002c7,0x000002e8,0x0004003d,0x00000006,0x000002ea, + 0x000002c7,0x000500be,0x000000a6,0x000002eb,0x000002ea,0x000000a5,0x000300f7,0x000002ee, + 0x00000000,0x000400fa,0x000002eb,0x000002ed,0x000002f1,0x000200f8,0x000002ed,0x00060041, + 0x0000000d,0x000002ef,0x00000043,0x0000015c,0x00000167,0x0004003d,0x00000006,0x000002f0, + 0x000002ef,0x0003003e,0x000002ec,0x000002f0,0x000200f9,0x000002ee,0x000200f8,0x000002f1, + 0x00060041,0x0000000d,0x000002f2,0x00000043,0x00000167,0x0000015c,0x0004003d,0x00000006, + 0x000002f3,0x000002f2,0x0003003e,0x000002ec,0x000002f3,0x000200f9,0x000002ee,0x000200f8, + 0x000002ee,0x0004003d,0x00000006,0x000002f4,0x000002ec,0x0003003e,0x000002e9,0x000002f4, + 0x0004003d,0x00000006,0x000002f6,0x000002c7,0x000500be,0x000000a6,0x000002f7,0x000002f6, + 0x000000a5,0x000300f7,0x000002fa,0x00000000,0x000400fa,0x000002f7,0x000002f9,0x000002fd, + 0x000200f8,0x000002f9,0x00060041,0x0000000d,0x000002fb,0x00000043,0x0000016f,0x00000197, + 0x0004003d,0x00000006,0x000002fc,0x000002fb,0x0003003e,0x000002f8,0x000002fc,0x000200f9, + 0x000002fa,0x000200f8,0x000002fd,0x00060041,0x0000000d,0x000002fe,0x00000043,0x00000197, + 0x0000016f,0x0004003d,0x00000006,0x000002ff,0x000002fe,0x0003003e,0x000002f8,0x000002ff, + 0x000200f9,0x000002fa,0x000200f8,0x000002fa,0x0004003d,0x00000006,0x00000300,0x000002f8, + 0x0003003e,0x000002f5,0x00000300,0x0004003d,0x00000006,0x00000302,0x000002c7,0x000500be, + 0x000000a6,0x00000303,0x00000302,0x000000a5,0x000300f7,0x00000306,0x00000000,0x000400fa, + 0x00000303,0x00000305,0x00000309,0x000200f8,0x00000305,0x00060041,0x0000000d,0x00000307, + 0x00000043,0x00000167,0x0000019f,0x0004003d,0x00000006,0x00000308,0x00000307,0x0003003e, + 0x00000304,0x00000308,0x000200f9,0x00000306,0x000200f8,0x00000309,0x00060041,0x0000000d, + 0x0000030a,0x00000043,0x0000019f,0x00000167,0x0004003d,0x00000006,0x0000030b,0x0000030a, + 0x0003003e,0x00000304,0x0000030b,0x000200f9,0x00000306,0x000200f8,0x00000306,0x0004003d, + 0x00000006,0x0000030c,0x00000304,0x0003003e,0x00000301,0x0000030c,0x0004003d,0x00000006, + 0x0000030e,0x000002c7,0x000500be,0x000000a6,0x0000030f,0x0000030e,0x000000a5,0x000300f7, + 0x00000312,0x00000000,0x000400fa,0x0000030f,0x00000311,0x00000315,0x000200f8,0x00000311, + 0x00060041,0x0000000d,0x00000313,0x00000043,0x00000197,0x000001a7,0x0004003d,0x00000006, + 0x00000314,0x00000313,0x0003003e,0x00000310,0x00000314,0x000200f9,0x00000312,0x000200f8, + 0x00000315,0x00060041,0x0000000d,0x00000316,0x00000043,0x000001a7,0x00000197,0x0004003d, + 0x00000006,0x00000317,0x00000316,0x0003003e,0x00000310,0x00000317,0x000200f9,0x00000312, + 0x000200f8,0x00000312,0x0004003d,0x00000006,0x00000318,0x00000310,0x0003003e,0x0000030d, + 0x00000318,0x00060041,0x0000000d,0x00000319,0x00000043,0x0000016f,0x0000016f,0x0004003d, + 0x00000006,0x0000031a,0x00000319,0x0004003d,0x00000006,0x0000031b,0x000002e9,0x0004003d, + 0x00000006,0x0000031c,0x000002c7,0x0006000c,0x00000006,0x0000031d,0x00000001,0x00000004, + 0x0000031c,0x0008000c,0x00000006,0x0000031e,0x00000001,0x0000002e,0x0000031a,0x0000031b, + 0x0000031d,0x00050041,0x0000000d,0x0000031f,0x000002d1,0x0000015c,0x0003003e,0x0000031f, + 0x0000031e,0x00060041,0x0000000d,0x00000320,0x00000043,0x00000167,0x00000167,0x0004003d, + 0x00000006,0x00000321,0x00000320,0x0004003d,0x00000006,0x00000322,0x000002f5,0x0004003d, + 0x00000006,0x00000323,0x000002c7,0x0006000c,0x00000006,0x00000324,0x00000001,0x00000004, + 0x00000323,0x0008000c,0x00000006,0x00000325,0x00000001,0x0000002e,0x00000321,0x00000322, + 0x00000324,0x00050041,0x0000000d,0x00000326,0x000002d1,0x00000167,0x0003003e,0x00000326, + 0x00000325,0x00060041,0x0000000d,0x00000327,0x00000043,0x00000197,0x00000197,0x0004003d, + 0x00000006,0x00000328,0x00000327,0x0004003d,0x00000006,0x00000329,0x00000301,0x0004003d, + 0x00000006,0x0000032a,0x000002c7,0x0006000c,0x00000006,0x0000032b,0x00000001,0x00000004, + 0x0000032a,0x0008000c,0x00000006,0x0000032c,0x00000001,0x0000002e,0x00000328,0x00000329, + 0x0000032b,0x00050041,0x0000000d,0x0000032d,0x000002d1,0x0000019f,0x0003003e,0x0000032d, + 0x0000032c,0x00060041,0x0000000d,0x0000032e,0x00000043,0x0000019f,0x0000019f,0x0004003d, + 0x00000006,0x0000032f,0x0000032e,0x0004003d,0x00000006,0x00000330,0x0000030d,0x0004003d, + 0x00000006,0x00000331,0x000002c7,0x0006000c,0x00000006,0x00000332,0x00000001,0x00000004, + 0x00000331,0x0008000c,0x00000006,0x00000333,0x00000001,0x0000002e,0x0000032f,0x00000330, + 0x00000332,0x00050041,0x0000000d,0x00000334,0x000002d1,0x00000256,0x0003003e,0x00000334, + 0x00000333,0x0004003d,0x00000006,0x00000336,0x00000044,0x0004003d,0x00000006,0x00000337, + 0x00000045,0x00050081,0x00000006,0x00000338,0x00000336,0x00000337,0x0003003e,0x00000335, + 0x00000338,0x0004003d,0x00000006,0x00000339,0x00000335,0x000500be,0x000000a6,0x0000033a, + 0x00000339,0x000000b2,0x000300f7,0x0000033c,0x00000000,0x000400fa,0x0000033a,0x0000033b, + 0x00000350,0x000200f8,0x0000033b,0x0003003e,0x0000033d,0x0000015c,0x000200f9,0x0000033e, + 0x000200f8,0x0000033e,0x000400f6,0x00000340,0x00000341,0x00000000,0x000200f9,0x00000342, + 0x000200f8,0x00000342,0x0004003d,0x00000025,0x00000343,0x0000033d,0x000500b1,0x000000a6, + 0x00000344,0x00000343,0x00000256,0x000400fa,0x00000344,0x0000033f,0x00000340,0x000200f8, + 0x0000033f,0x0004003d,0x00000025,0x00000346,0x0000033d,0x0004003d,0x00000025,0x00000347, + 0x0000033d,0x00050080,0x00000025,0x00000348,0x00000347,0x0000016f,0x00050041,0x0000000d, + 0x00000349,0x000002d1,0x00000348,0x0004003d,0x00000006,0x0000034a,0x00000349,0x00050041, + 0x0000000d,0x0000034b,0x00000345,0x00000346,0x0003003e,0x0000034b,0x0000034a,0x000200f9, + 0x00000341,0x000200f8,0x00000341,0x0004003d,0x00000025,0x0000034c,0x0000033d,0x00050080, + 0x00000025,0x0000034d,0x0000034c,0x0000016f,0x0003003e,0x0000033d,0x0000034d,0x000200f9, + 0x0000033e,0x000200f8,0x00000340,0x0004003d,0x00000006,0x0000034e,0x00000335,0x00050083, + 0x00000006,0x0000034f,0x0000034e,0x000000b2,0x0003003e,0x00000335,0x0000034f,0x000200f9, + 0x0000033c,0x000200f8,0x00000350,0x0003003e,0x00000351,0x0000015c,0x000200f9,0x00000352, + 0x000200f8,0x00000352,0x000400f6,0x00000354,0x00000355,0x00000000,0x000200f9,0x00000356, + 0x000200f8,0x00000356,0x0004003d,0x00000025,0x00000357,0x00000351,0x000500b1,0x000000a6, + 0x00000358,0x00000357,0x00000256,0x000400fa,0x00000358,0x00000353,0x00000354,0x000200f8, + 0x00000353,0x0004003d,0x00000025,0x00000359,0x00000351,0x0004003d,0x00000025,0x0000035a, + 0x00000351,0x00050041,0x0000000d,0x0000035b,0x000002d1,0x0000035a,0x0004003d,0x00000006, + 0x0000035c,0x0000035b,0x00050041,0x0000000d,0x0000035d,0x00000345,0x00000359,0x0003003e, + 0x0000035d,0x0000035c,0x000200f9,0x00000355,0x000200f8,0x00000355,0x0004003d,0x00000025, + 0x0000035e,0x00000351,0x00050080,0x00000025,0x0000035f,0x0000035e,0x0000016f,0x0003003e, + 0x00000351,0x0000035f,0x000200f9,0x00000352,0x000200f8,0x00000354,0x000200f9,0x0000033c, + 0x000200f8,0x0000033c,0x0004003d,0x00000006,0x00000360,0x00000335,0x00050085,0x00000006, + 0x00000362,0x00000360,0x00000361,0x0004006e,0x00000025,0x00000363,0x00000362,0x0004003d, + 0x00000033,0x00000365,0x00000345,0x0003003e,0x00000364,0x00000365,0x0003003e,0x00000366, + 0x00000363,0x00060039,0x00000006,0x00000367,0x00000038,0x00000364,0x00000366,0x00050041, + 0x0000000d,0x00000368,0x00000048,0x00000057,0x0004003d,0x00000006,0x00000369,0x00000368, + 0x00050085,0x00000006,0x0000036a,0x00000367,0x00000369,0x0004003d,0x00000006,0x0000036b, + 0x00000279,0x00050081,0x00000006,0x0000036c,0x0000036b,0x0000036a,0x0003003e,0x00000279, + 0x0000036c,0x000200f9,0x000002c6,0x000200f8,0x000002c6,0x00050041,0x0000000d,0x0000036d, + 0x00000048,0x00000194,0x0004003d,0x00000006,0x0000036e,0x0000036d,0x000500ba,0x000000a6, + 0x0000036f,0x0000036e,0x000000a5,0x000300f7,0x00000371,0x00000000,0x000400fa,0x0000036f, + 0x00000370,0x00000371,0x000200f8,0x00000370,0x0004003d,0x00000006,0x00000373,0x00000044, + 0x0004003d,0x00000006,0x00000374,0x00000045,0x00050081,0x00000006,0x00000375,0x00000373, + 0x00000374,0x00050085,0x00000006,0x00000376,0x000002c8,0x00000375,0x0003003e,0x00000372, + 0x00000376,0x00060041,0x0000000d,0x00000378,0x00000043,0x00000197,0x0000016f,0x0004003d, + 0x00000006,0x00000379,0x00000378,0x00060041,0x0000000d,0x0000037a,0x00000043,0x0000019f, + 0x00000167,0x0004003d,0x00000006,0x0000037b,0x0000037a,0x0004003d,0x00000006,0x0000037c, + 0x00000372,0x0008000c,0x00000006,0x0000037d,0x00000001,0x0000002e,0x00000379,0x0000037b, + 0x0000037c,0x00050041,0x0000000d,0x0000037e,0x00000377,0x0000016f,0x0003003e,0x0000037e, + 0x0000037d,0x00060041,0x0000000d,0x0000037f,0x00000043,0x00000167,0x00000167,0x0004003d, + 0x00000006,0x00000380,0x0000037f,0x00060041,0x0000000d,0x00000381,0x00000043,0x00000197, + 0x00000197,0x0004003d,0x00000006,0x00000382,0x00000381,0x0004003d,0x00000006,0x00000383, + 0x00000372,0x0008000c,0x00000006,0x00000384,0x00000001,0x0000002e,0x00000380,0x00000382, + 0x00000383,0x00050041,0x0000000d,0x00000385,0x00000377,0x00000197,0x0003003e,0x00000385, + 0x00000384,0x00060041,0x0000000d,0x00000386,0x00000043,0x0000016f,0x00000197,0x0004003d, + 0x00000006,0x00000387,0x00000386,0x00060041,0x0000000d,0x00000388,0x00000043,0x00000167, + 0x0000019f,0x0004003d,0x00000006,0x00000389,0x00000388,0x0004003d,0x00000006,0x0000038a, + 0x00000372,0x0008000c,0x00000006,0x0000038b,0x00000001,0x0000002e,0x00000387,0x00000389, + 0x0000038a,0x00050041,0x0000000d,0x0000038c,0x00000377,0x000001a7,0x0003003e,0x0000038c, + 0x0000038b,0x0004003d,0x00000006,0x0000038d,0x00000372,0x00050083,0x00000006,0x0000038e, + 0x0000038d,0x000002c8,0x0003003e,0x00000372,0x0000038e,0x0004003d,0x00000006,0x00000390, + 0x00000372,0x000500be,0x000000a6,0x00000391,0x00000390,0x000000a5,0x000300f7,0x00000394, + 0x00000000,0x000400fa,0x00000391,0x00000393,0x00000397,0x000200f8,0x00000393,0x00060041, + 0x0000000d,0x00000395,0x00000043,0x000001a7,0x00000167,0x0004003d,0x00000006,0x00000396, + 0x00000395,0x0003003e,0x00000392,0x00000396,0x000200f9,0x00000394,0x000200f8,0x00000397, + 0x00060041,0x0000000d,0x00000398,0x00000043,0x00000197,0x0000015c,0x0004003d,0x00000006, + 0x00000399,0x00000398,0x0003003e,0x00000392,0x00000399,0x000200f9,0x00000394,0x000200f8, + 0x00000394,0x0004003d,0x00000006,0x0000039a,0x00000392,0x0003003e,0x0000038f,0x0000039a, + 0x0004003d,0x00000006,0x0000039c,0x00000372,0x000500be,0x000000a6,0x0000039d,0x0000039c, + 0x000000a5,0x000300f7,0x000003a0,0x00000000,0x000400fa,0x0000039d,0x0000039f,0x000003a3, + 0x000200f8,0x0000039f,0x00060041,0x0000000d,0x000003a1,0x00000043,0x0000019f,0x00000197, + 0x0004003d,0x00000006,0x000003a2,0x000003a1,0x0003003e,0x0000039e,0x000003a2,0x000200f9, + 0x000003a0,0x000200f8,0x000003a3,0x00060041,0x0000000d,0x000003a4,0x00000043,0x00000167, + 0x0000016f,0x0004003d,0x00000006,0x000003a5,0x000003a4,0x0003003e,0x0000039e,0x000003a5, + 0x000200f9,0x000003a0,0x000200f8,0x000003a0,0x0004003d,0x00000006,0x000003a6,0x0000039e, + 0x0003003e,0x0000039b,0x000003a6,0x0004003d,0x00000006,0x000003a8,0x00000372,0x000500be, + 0x000000a6,0x000003a9,0x000003a8,0x000000a5,0x000300f7,0x000003ac,0x00000000,0x000400fa, + 0x000003a9,0x000003ab,0x000003af,0x000200f8,0x000003ab,0x00060041,0x0000000d,0x000003ad, + 0x00000043,0x00000197,0x0000019f,0x0004003d,0x00000006,0x000003ae,0x000003ad,0x0003003e, + 0x000003aa,0x000003ae,0x000200f9,0x000003ac,0x000200f8,0x000003af,0x00060041,0x0000000d, + 0x000003b0,0x00000043,0x0000016f,0x00000167,0x0004003d,0x00000006,0x000003b1,0x000003b0, + 0x0003003e,0x000003aa,0x000003b1,0x000200f9,0x000003ac,0x000200f8,0x000003ac,0x0004003d, + 0x00000006,0x000003b2,0x000003aa,0x0003003e,0x000003a7,0x000003b2,0x0004003d,0x00000006, + 0x000003b4,0x00000372,0x000500be,0x000000a6,0x000003b5,0x000003b4,0x000000a5,0x000300f7, + 0x000003b8,0x00000000,0x000400fa,0x000003b5,0x000003b7,0x000003bb,0x000200f8,0x000003b7, + 0x00060041,0x0000000d,0x000003b9,0x00000043,0x00000167,0x000001a7,0x0004003d,0x00000006, + 0x000003ba,0x000003b9,0x0003003e,0x000003b6,0x000003ba,0x000200f9,0x000003b8,0x000200f8, + 0x000003bb,0x00060041,0x0000000d,0x000003bc,0x00000043,0x0000015c,0x00000197,0x0004003d, + 0x00000006,0x000003bd,0x000003bc,0x0003003e,0x000003b6,0x000003bd,0x000200f9,0x000003b8, + 0x000200f8,0x000003b8,0x0004003d,0x00000006,0x000003be,0x000003b6,0x0003003e,0x000003b3, + 0x000003be,0x00060041,0x0000000d,0x000003bf,0x00000043,0x0000019f,0x0000016f,0x0004003d, + 0x00000006,0x000003c0,0x000003bf,0x0004003d,0x00000006,0x000003c1,0x0000038f,0x0004003d, + 0x00000006,0x000003c2,0x00000372,0x0006000c,0x00000006,0x000003c3,0x00000001,0x00000004, + 0x000003c2,0x0008000c,0x00000006,0x000003c4,0x00000001,0x0000002e,0x000003c0,0x000003c1, + 0x000003c3,0x00050041,0x0000000d,0x000003c5,0x00000377,0x0000015c,0x0003003e,0x000003c5, + 0x000003c4,0x00060041,0x0000000d,0x000003c6,0x00000043,0x00000197,0x00000167,0x0004003d, + 0x00000006,0x000003c7,0x000003c6,0x0004003d,0x00000006,0x000003c8,0x0000039b,0x0004003d, + 0x00000006,0x000003c9,0x00000372,0x0006000c,0x00000006,0x000003ca,0x00000001,0x00000004, + 0x000003c9,0x0008000c,0x00000006,0x000003cb,0x00000001,0x0000002e,0x000003c7,0x000003c8, + 0x000003ca,0x00050041,0x0000000d,0x000003cc,0x00000377,0x00000167,0x0003003e,0x000003cc, + 0x000003cb,0x00060041,0x0000000d,0x000003cd,0x00000043,0x00000167,0x00000197,0x0004003d, + 0x00000006,0x000003ce,0x000003cd,0x0004003d,0x00000006,0x000003cf,0x000003a7,0x0004003d, + 0x00000006,0x000003d0,0x00000372,0x0006000c,0x00000006,0x000003d1,0x00000001,0x00000004, + 0x000003d0,0x0008000c,0x00000006,0x000003d2,0x00000001,0x0000002e,0x000003ce,0x000003cf, + 0x000003d1,0x00050041,0x0000000d,0x000003d3,0x00000377,0x0000019f,0x0003003e,0x000003d3, + 0x000003d2,0x00060041,0x0000000d,0x000003d4,0x00000043,0x0000016f,0x0000019f,0x0004003d, + 0x00000006,0x000003d5,0x000003d4,0x0004003d,0x00000006,0x000003d6,0x000003b3,0x0004003d, + 0x00000006,0x000003d7,0x00000372,0x0006000c,0x00000006,0x000003d8,0x00000001,0x00000004, + 0x000003d7,0x0008000c,0x00000006,0x000003d9,0x00000001,0x0000002e,0x000003d5,0x000003d6, + 0x000003d8,0x00050041,0x0000000d,0x000003da,0x00000377,0x00000256,0x0003003e,0x000003da, + 0x000003d9,0x0004003d,0x00000006,0x000003dc,0x00000044,0x0004003d,0x00000006,0x000003dd, + 0x00000045,0x00050083,0x00000006,0x000003de,0x000003dc,0x000003dd,0x00050081,0x00000006, + 0x000003df,0x000000b2,0x000003de,0x0003003e,0x000003db,0x000003df,0x0004003d,0x00000006, + 0x000003e0,0x000003db,0x000500be,0x000000a6,0x000003e1,0x000003e0,0x000000b2,0x000300f7, + 0x000003e3,0x00000000,0x000400fa,0x000003e1,0x000003e2,0x000003f7,0x000200f8,0x000003e2, + 0x0003003e,0x000003e4,0x0000015c,0x000200f9,0x000003e5,0x000200f8,0x000003e5,0x000400f6, + 0x000003e7,0x000003e8,0x00000000,0x000200f9,0x000003e9,0x000200f8,0x000003e9,0x0004003d, + 0x00000025,0x000003ea,0x000003e4,0x000500b1,0x000000a6,0x000003eb,0x000003ea,0x00000256, + 0x000400fa,0x000003eb,0x000003e6,0x000003e7,0x000200f8,0x000003e6,0x0004003d,0x00000025, + 0x000003ed,0x000003e4,0x0004003d,0x00000025,0x000003ee,0x000003e4,0x00050080,0x00000025, + 0x000003ef,0x000003ee,0x0000016f,0x00050041,0x0000000d,0x000003f0,0x00000377,0x000003ef, + 0x0004003d,0x00000006,0x000003f1,0x000003f0,0x00050041,0x0000000d,0x000003f2,0x000003ec, + 0x000003ed,0x0003003e,0x000003f2,0x000003f1,0x000200f9,0x000003e8,0x000200f8,0x000003e8, + 0x0004003d,0x00000025,0x000003f3,0x000003e4,0x00050080,0x00000025,0x000003f4,0x000003f3, + 0x0000016f,0x0003003e,0x000003e4,0x000003f4,0x000200f9,0x000003e5,0x000200f8,0x000003e7, + 0x0004003d,0x00000006,0x000003f5,0x000003db,0x00050083,0x00000006,0x000003f6,0x000003f5, + 0x000000b2,0x0003003e,0x000003db,0x000003f6,0x000200f9,0x000003e3,0x000200f8,0x000003f7, + 0x0003003e,0x000003f8,0x0000015c,0x000200f9,0x000003f9,0x000200f8,0x000003f9,0x000400f6, + 0x000003fb,0x000003fc,0x00000000,0x000200f9,0x000003fd,0x000200f8,0x000003fd,0x0004003d, + 0x00000025,0x000003fe,0x000003f8,0x000500b1,0x000000a6,0x000003ff,0x000003fe,0x00000256, + 0x000400fa,0x000003ff,0x000003fa,0x000003fb,0x000200f8,0x000003fa,0x0004003d,0x00000025, + 0x00000400,0x000003f8,0x0004003d,0x00000025,0x00000401,0x000003f8,0x00050041,0x0000000d, + 0x00000402,0x00000377,0x00000401,0x0004003d,0x00000006,0x00000403,0x00000402,0x00050041, + 0x0000000d,0x00000404,0x000003ec,0x00000400,0x0003003e,0x00000404,0x00000403,0x000200f9, + 0x000003fc,0x000200f8,0x000003fc,0x0004003d,0x00000025,0x00000405,0x000003f8,0x00050080, + 0x00000025,0x00000406,0x00000405,0x0000016f,0x0003003e,0x000003f8,0x00000406,0x000200f9, + 0x000003f9,0x000200f8,0x000003fb,0x000200f9,0x000003e3,0x000200f8,0x000003e3,0x0004003d, + 0x00000006,0x00000407,0x000003db,0x00050085,0x00000006,0x00000408,0x00000407,0x00000361, + 0x0004006e,0x00000025,0x00000409,0x00000408,0x0004003d,0x00000033,0x0000040b,0x000003ec, + 0x0003003e,0x0000040a,0x0000040b,0x0003003e,0x0000040c,0x00000409,0x00060039,0x00000006, + 0x0000040d,0x00000038,0x0000040a,0x0000040c,0x00050041,0x0000000d,0x0000040e,0x00000048, + 0x00000194,0x0004003d,0x00000006,0x0000040f,0x0000040e,0x00050085,0x00000006,0x00000410, + 0x0000040d,0x0000040f,0x0004003d,0x00000006,0x00000411,0x00000279,0x00050081,0x00000006, + 0x00000412,0x00000411,0x00000410,0x0003003e,0x00000279,0x00000412,0x000200f9,0x00000371, + 0x000200f8,0x00000371,0x0004003d,0x00000006,0x00000413,0x00000279,0x000200fe,0x00000413, + 0x00010038 +}; diff --git a/app/src/main/cpp/shaders/nis_coef.h b/app/src/main/cpp/shaders/nis_coef.h new file mode 100644 index 0000000000..77252c738e --- /dev/null +++ b/app/src/main/cpp/shaders/nis_coef.h @@ -0,0 +1,156 @@ +// NVIDIA Image Scaling coefficient banks for nis3.frag (uniform buffer, set 1, binding 0): +// coef_scale and coef_usm, 64 phases x 6 taps, laid out as two vec4 per phase (taps 0-3, taps 4-5 +// + two zeros) to match the shader's std140 vec4[128] arrays. Values = nis.frag's baked tables. +// +// The MIT License (MIT) +// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +// associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +// NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT +// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +#pragma once + +static const float kNisCoefScale[64 * 8] = { + 0.0000f, 0.0000f, 1.0000f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, // phase 0 + 0.0029f, -0.0127f, 1.0000f, 0.0132f, -0.0034f, 0.0000f, 0.0000f, 0.0000f, // phase 1 + 0.0063f, -0.0249f, 0.9985f, 0.0269f, -0.0068f, 0.0000f, 0.0000f, 0.0000f, // phase 2 + 0.0088f, -0.0361f, 0.9956f, 0.0415f, -0.0103f, 0.0005f, 0.0000f, 0.0000f, // phase 3 + 0.0117f, -0.0474f, 0.9932f, 0.0562f, -0.0142f, 0.0005f, 0.0000f, 0.0000f, // phase 4 + 0.0142f, -0.0576f, 0.9897f, 0.0713f, -0.0181f, 0.0005f, 0.0000f, 0.0000f, // phase 5 + 0.0166f, -0.0674f, 0.9844f, 0.0874f, -0.0220f, 0.0010f, 0.0000f, 0.0000f, // phase 6 + 0.0186f, -0.0762f, 0.9785f, 0.1040f, -0.0264f, 0.0015f, 0.0000f, 0.0000f, // phase 7 + 0.0205f, -0.0850f, 0.9727f, 0.1206f, -0.0308f, 0.0020f, 0.0000f, 0.0000f, // phase 8 + 0.0225f, -0.0928f, 0.9648f, 0.1382f, -0.0352f, 0.0024f, 0.0000f, 0.0000f, // phase 9 + 0.0239f, -0.1006f, 0.9575f, 0.1558f, -0.0396f, 0.0029f, 0.0000f, 0.0000f, // phase 10 + 0.0254f, -0.1074f, 0.9487f, 0.1738f, -0.0439f, 0.0034f, 0.0000f, 0.0000f, // phase 11 + 0.0264f, -0.1138f, 0.9390f, 0.1929f, -0.0488f, 0.0044f, 0.0000f, 0.0000f, // phase 12 + 0.0278f, -0.1191f, 0.9282f, 0.2119f, -0.0537f, 0.0049f, 0.0000f, 0.0000f, // phase 13 + 0.0288f, -0.1245f, 0.9170f, 0.2310f, -0.0581f, 0.0059f, 0.0000f, 0.0000f, // phase 14 + 0.0293f, -0.1294f, 0.9058f, 0.2510f, -0.0630f, 0.0063f, 0.0000f, 0.0000f, // phase 15 + 0.0303f, -0.1333f, 0.8926f, 0.2710f, -0.0679f, 0.0073f, 0.0000f, 0.0000f, // phase 16 + 0.0308f, -0.1367f, 0.8789f, 0.2915f, -0.0728f, 0.0083f, 0.0000f, 0.0000f, // phase 17 + 0.0308f, -0.1401f, 0.8657f, 0.3120f, -0.0776f, 0.0093f, 0.0000f, 0.0000f, // phase 18 + 0.0313f, -0.1426f, 0.8506f, 0.3330f, -0.0825f, 0.0103f, 0.0000f, 0.0000f, // phase 19 + 0.0313f, -0.1445f, 0.8354f, 0.3540f, -0.0874f, 0.0112f, 0.0000f, 0.0000f, // phase 20 + 0.0313f, -0.1460f, 0.8193f, 0.3755f, -0.0923f, 0.0122f, 0.0000f, 0.0000f, // phase 21 + 0.0313f, -0.1470f, 0.8022f, 0.3965f, -0.0967f, 0.0137f, 0.0000f, 0.0000f, // phase 22 + 0.0308f, -0.1479f, 0.7856f, 0.4185f, -0.1016f, 0.0146f, 0.0000f, 0.0000f, // phase 23 + 0.0303f, -0.1479f, 0.7681f, 0.4399f, -0.1060f, 0.0156f, 0.0000f, 0.0000f, // phase 24 + 0.0298f, -0.1479f, 0.7505f, 0.4614f, -0.1104f, 0.0166f, 0.0000f, 0.0000f, // phase 25 + 0.0293f, -0.1470f, 0.7314f, 0.4829f, -0.1147f, 0.0181f, 0.0000f, 0.0000f, // phase 26 + 0.0288f, -0.1460f, 0.7119f, 0.5049f, -0.1187f, 0.0190f, 0.0000f, 0.0000f, // phase 27 + 0.0278f, -0.1445f, 0.6929f, 0.5264f, -0.1226f, 0.0200f, 0.0000f, 0.0000f, // phase 28 + 0.0273f, -0.1431f, 0.6724f, 0.5479f, -0.1260f, 0.0215f, 0.0000f, 0.0000f, // phase 29 + 0.0264f, -0.1411f, 0.6528f, 0.5693f, -0.1299f, 0.0225f, 0.0000f, 0.0000f, // phase 30 + 0.0254f, -0.1387f, 0.6323f, 0.5903f, -0.1328f, 0.0234f, 0.0000f, 0.0000f, // phase 31 + 0.0244f, -0.1357f, 0.6113f, 0.6113f, -0.1357f, 0.0244f, 0.0000f, 0.0000f, // phase 32 + 0.0234f, -0.1328f, 0.5903f, 0.6323f, -0.1387f, 0.0254f, 0.0000f, 0.0000f, // phase 33 + 0.0225f, -0.1299f, 0.5693f, 0.6528f, -0.1411f, 0.0264f, 0.0000f, 0.0000f, // phase 34 + 0.0215f, -0.1260f, 0.5479f, 0.6724f, -0.1431f, 0.0273f, 0.0000f, 0.0000f, // phase 35 + 0.0200f, -0.1226f, 0.5264f, 0.6929f, -0.1445f, 0.0278f, 0.0000f, 0.0000f, // phase 36 + 0.0190f, -0.1187f, 0.5049f, 0.7119f, -0.1460f, 0.0288f, 0.0000f, 0.0000f, // phase 37 + 0.0181f, -0.1147f, 0.4829f, 0.7314f, -0.1470f, 0.0293f, 0.0000f, 0.0000f, // phase 38 + 0.0166f, -0.1104f, 0.4614f, 0.7505f, -0.1479f, 0.0298f, 0.0000f, 0.0000f, // phase 39 + 0.0156f, -0.1060f, 0.4399f, 0.7681f, -0.1479f, 0.0303f, 0.0000f, 0.0000f, // phase 40 + 0.0146f, -0.1016f, 0.4185f, 0.7856f, -0.1479f, 0.0308f, 0.0000f, 0.0000f, // phase 41 + 0.0137f, -0.0967f, 0.3965f, 0.8022f, -0.1470f, 0.0313f, 0.0000f, 0.0000f, // phase 42 + 0.0122f, -0.0923f, 0.3755f, 0.8193f, -0.1460f, 0.0313f, 0.0000f, 0.0000f, // phase 43 + 0.0112f, -0.0874f, 0.3540f, 0.8354f, -0.1445f, 0.0313f, 0.0000f, 0.0000f, // phase 44 + 0.0103f, -0.0825f, 0.3330f, 0.8506f, -0.1426f, 0.0313f, 0.0000f, 0.0000f, // phase 45 + 0.0093f, -0.0776f, 0.3120f, 0.8657f, -0.1401f, 0.0308f, 0.0000f, 0.0000f, // phase 46 + 0.0083f, -0.0728f, 0.2915f, 0.8789f, -0.1367f, 0.0308f, 0.0000f, 0.0000f, // phase 47 + 0.0073f, -0.0679f, 0.2710f, 0.8926f, -0.1333f, 0.0303f, 0.0000f, 0.0000f, // phase 48 + 0.0063f, -0.0630f, 0.2510f, 0.9058f, -0.1294f, 0.0293f, 0.0000f, 0.0000f, // phase 49 + 0.0059f, -0.0581f, 0.2310f, 0.9170f, -0.1245f, 0.0288f, 0.0000f, 0.0000f, // phase 50 + 0.0049f, -0.0537f, 0.2119f, 0.9282f, -0.1191f, 0.0278f, 0.0000f, 0.0000f, // phase 51 + 0.0044f, -0.0488f, 0.1929f, 0.9390f, -0.1138f, 0.0264f, 0.0000f, 0.0000f, // phase 52 + 0.0034f, -0.0439f, 0.1738f, 0.9487f, -0.1074f, 0.0254f, 0.0000f, 0.0000f, // phase 53 + 0.0029f, -0.0396f, 0.1558f, 0.9575f, -0.1006f, 0.0239f, 0.0000f, 0.0000f, // phase 54 + 0.0024f, -0.0352f, 0.1382f, 0.9648f, -0.0928f, 0.0225f, 0.0000f, 0.0000f, // phase 55 + 0.0020f, -0.0308f, 0.1206f, 0.9727f, -0.0850f, 0.0205f, 0.0000f, 0.0000f, // phase 56 + 0.0015f, -0.0264f, 0.1040f, 0.9785f, -0.0762f, 0.0186f, 0.0000f, 0.0000f, // phase 57 + 0.0010f, -0.0220f, 0.0874f, 0.9844f, -0.0674f, 0.0166f, 0.0000f, 0.0000f, // phase 58 + 0.0005f, -0.0181f, 0.0713f, 0.9897f, -0.0576f, 0.0142f, 0.0000f, 0.0000f, // phase 59 + 0.0005f, -0.0142f, 0.0562f, 0.9932f, -0.0474f, 0.0117f, 0.0000f, 0.0000f, // phase 60 + 0.0005f, -0.0103f, 0.0415f, 0.9956f, -0.0361f, 0.0088f, 0.0000f, 0.0000f, // phase 61 + 0.0000f, -0.0068f, 0.0269f, 0.9985f, -0.0249f, 0.0063f, 0.0000f, 0.0000f, // phase 62 + 0.0000f, -0.0034f, 0.0132f, 1.0000f, -0.0127f, 0.0029f, 0.0000f, 0.0000f, // phase 63 +}; + +static const float kNisCoefUsm[64 * 8] = { + 0.0000f, -0.6001f, 1.2002f, -0.6001f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, // phase 0 + 0.0029f, -0.6084f, 1.1987f, -0.5903f, -0.0029f, 0.0000f, 0.0000f, 0.0000f, // phase 1 + 0.0049f, -0.6147f, 1.1958f, -0.5791f, -0.0068f, 0.0005f, 0.0000f, 0.0000f, // phase 2 + 0.0073f, -0.6196f, 1.1890f, -0.5659f, -0.0103f, 0.0000f, 0.0000f, 0.0000f, // phase 3 + 0.0093f, -0.6235f, 1.1802f, -0.5513f, -0.0151f, 0.0000f, 0.0000f, 0.0000f, // phase 4 + 0.0112f, -0.6265f, 1.1699f, -0.5352f, -0.0195f, 0.0005f, 0.0000f, 0.0000f, // phase 5 + 0.0122f, -0.6270f, 1.1582f, -0.5181f, -0.0259f, 0.0005f, 0.0000f, 0.0000f, // phase 6 + 0.0142f, -0.6284f, 1.1455f, -0.5005f, -0.0317f, 0.0005f, 0.0000f, 0.0000f, // phase 7 + 0.0156f, -0.6265f, 1.1274f, -0.4790f, -0.0386f, 0.0005f, 0.0000f, 0.0000f, // phase 8 + 0.0166f, -0.6235f, 1.1089f, -0.4570f, -0.0454f, 0.0010f, 0.0000f, 0.0000f, // phase 9 + 0.0176f, -0.6187f, 1.0879f, -0.4346f, -0.0532f, 0.0010f, 0.0000f, 0.0000f, // phase 10 + 0.0181f, -0.6138f, 1.0659f, -0.4102f, -0.0615f, 0.0015f, 0.0000f, 0.0000f, // phase 11 + 0.0190f, -0.6069f, 1.0405f, -0.3843f, -0.0698f, 0.0015f, 0.0000f, 0.0000f, // phase 12 + 0.0195f, -0.6006f, 1.0161f, -0.3574f, -0.0796f, 0.0020f, 0.0000f, 0.0000f, // phase 13 + 0.0200f, -0.5928f, 0.9893f, -0.3286f, -0.0898f, 0.0024f, 0.0000f, 0.0000f, // phase 14 + 0.0200f, -0.5820f, 0.9580f, -0.2988f, -0.1001f, 0.0029f, 0.0000f, 0.0000f, // phase 15 + 0.0200f, -0.5728f, 0.9292f, -0.2690f, -0.1104f, 0.0034f, 0.0000f, 0.0000f, // phase 16 + 0.0200f, -0.5620f, 0.8975f, -0.2368f, -0.1226f, 0.0039f, 0.0000f, 0.0000f, // phase 17 + 0.0205f, -0.5498f, 0.8643f, -0.2046f, -0.1343f, 0.0044f, 0.0000f, 0.0000f, // phase 18 + 0.0200f, -0.5371f, 0.8301f, -0.1709f, -0.1465f, 0.0049f, 0.0000f, 0.0000f, // phase 19 + 0.0195f, -0.5239f, 0.7944f, -0.1367f, -0.1587f, 0.0054f, 0.0000f, 0.0000f, // phase 20 + 0.0195f, -0.5107f, 0.7598f, -0.1021f, -0.1724f, 0.0059f, 0.0000f, 0.0000f, // phase 21 + 0.0190f, -0.4966f, 0.7231f, -0.0649f, -0.1865f, 0.0063f, 0.0000f, 0.0000f, // phase 22 + 0.0186f, -0.4819f, 0.6846f, -0.0288f, -0.1997f, 0.0068f, 0.0000f, 0.0000f, // phase 23 + 0.0186f, -0.4668f, 0.6460f, 0.0093f, -0.2144f, 0.0073f, 0.0000f, 0.0000f, // phase 24 + 0.0176f, -0.4507f, 0.6055f, 0.0479f, -0.2290f, 0.0083f, 0.0000f, 0.0000f, // phase 25 + 0.0171f, -0.4370f, 0.5693f, 0.0859f, -0.2446f, 0.0088f, 0.0000f, 0.0000f, // phase 26 + 0.0161f, -0.4199f, 0.5283f, 0.1255f, -0.2598f, 0.0098f, 0.0000f, 0.0000f, // phase 27 + 0.0161f, -0.4048f, 0.4883f, 0.1655f, -0.2754f, 0.0103f, 0.0000f, 0.0000f, // phase 28 + 0.0151f, -0.3887f, 0.4497f, 0.2041f, -0.2910f, 0.0107f, 0.0000f, 0.0000f, // phase 29 + 0.0142f, -0.3711f, 0.4072f, 0.2446f, -0.3066f, 0.0117f, 0.0000f, 0.0000f, // phase 30 + 0.0137f, -0.3555f, 0.3672f, 0.2852f, -0.3228f, 0.0122f, 0.0000f, 0.0000f, // phase 31 + 0.0132f, -0.3394f, 0.3262f, 0.3262f, -0.3394f, 0.0132f, 0.0000f, 0.0000f, // phase 32 + 0.0122f, -0.3228f, 0.2852f, 0.3672f, -0.3555f, 0.0137f, 0.0000f, 0.0000f, // phase 33 + 0.0117f, -0.3066f, 0.2446f, 0.4072f, -0.3711f, 0.0142f, 0.0000f, 0.0000f, // phase 34 + 0.0107f, -0.2910f, 0.2041f, 0.4497f, -0.3887f, 0.0151f, 0.0000f, 0.0000f, // phase 35 + 0.0103f, -0.2754f, 0.1655f, 0.4883f, -0.4048f, 0.0161f, 0.0000f, 0.0000f, // phase 36 + 0.0098f, -0.2598f, 0.1255f, 0.5283f, -0.4199f, 0.0161f, 0.0000f, 0.0000f, // phase 37 + 0.0088f, -0.2446f, 0.0859f, 0.5693f, -0.4370f, 0.0171f, 0.0000f, 0.0000f, // phase 38 + 0.0083f, -0.2290f, 0.0479f, 0.6055f, -0.4507f, 0.0176f, 0.0000f, 0.0000f, // phase 39 + 0.0073f, -0.2144f, 0.0093f, 0.6460f, -0.4668f, 0.0186f, 0.0000f, 0.0000f, // phase 40 + 0.0068f, -0.1997f, -0.0288f, 0.6846f, -0.4819f, 0.0186f, 0.0000f, 0.0000f, // phase 41 + 0.0063f, -0.1865f, -0.0649f, 0.7231f, -0.4966f, 0.0190f, 0.0000f, 0.0000f, // phase 42 + 0.0059f, -0.1724f, -0.1021f, 0.7598f, -0.5107f, 0.0195f, 0.0000f, 0.0000f, // phase 43 + 0.0054f, -0.1587f, -0.1367f, 0.7944f, -0.5239f, 0.0195f, 0.0000f, 0.0000f, // phase 44 + 0.0049f, -0.1465f, -0.1709f, 0.8301f, -0.5371f, 0.0200f, 0.0000f, 0.0000f, // phase 45 + 0.0044f, -0.1343f, -0.2046f, 0.8643f, -0.5498f, 0.0205f, 0.0000f, 0.0000f, // phase 46 + 0.0039f, -0.1226f, -0.2368f, 0.8975f, -0.5620f, 0.0200f, 0.0000f, 0.0000f, // phase 47 + 0.0034f, -0.1104f, -0.2690f, 0.9292f, -0.5728f, 0.0200f, 0.0000f, 0.0000f, // phase 48 + 0.0029f, -0.1001f, -0.2988f, 0.9580f, -0.5820f, 0.0200f, 0.0000f, 0.0000f, // phase 49 + 0.0024f, -0.0898f, -0.3286f, 0.9893f, -0.5928f, 0.0200f, 0.0000f, 0.0000f, // phase 50 + 0.0020f, -0.0796f, -0.3574f, 1.0161f, -0.6006f, 0.0195f, 0.0000f, 0.0000f, // phase 51 + 0.0015f, -0.0698f, -0.3843f, 1.0405f, -0.6069f, 0.0190f, 0.0000f, 0.0000f, // phase 52 + 0.0015f, -0.0615f, -0.4102f, 1.0659f, -0.6138f, 0.0181f, 0.0000f, 0.0000f, // phase 53 + 0.0010f, -0.0532f, -0.4346f, 1.0879f, -0.6187f, 0.0176f, 0.0000f, 0.0000f, // phase 54 + 0.0010f, -0.0454f, -0.4570f, 1.1089f, -0.6235f, 0.0166f, 0.0000f, 0.0000f, // phase 55 + 0.0005f, -0.0386f, -0.4790f, 1.1274f, -0.6265f, 0.0156f, 0.0000f, 0.0000f, // phase 56 + 0.0005f, -0.0317f, -0.5005f, 1.1455f, -0.6284f, 0.0142f, 0.0000f, 0.0000f, // phase 57 + 0.0005f, -0.0259f, -0.5181f, 1.1582f, -0.6270f, 0.0122f, 0.0000f, 0.0000f, // phase 58 + 0.0005f, -0.0195f, -0.5352f, 1.1699f, -0.6265f, 0.0112f, 0.0000f, 0.0000f, // phase 59 + 0.0000f, -0.0151f, -0.5513f, 1.1802f, -0.6235f, 0.0093f, 0.0000f, 0.0000f, // phase 60 + 0.0000f, -0.0103f, -0.5659f, 1.1890f, -0.6196f, 0.0073f, 0.0000f, 0.0000f, // phase 61 + 0.0005f, -0.0068f, -0.5791f, 1.1958f, -0.6147f, 0.0049f, 0.0000f, 0.0000f, // phase 62 + 0.0000f, -0.0029f, -0.5903f, 1.1987f, -0.6084f, 0.0029f, 0.0000f, 0.0000f, // phase 63 +}; diff --git a/app/src/main/cpp/shaders/nis_frag.h b/app/src/main/cpp/shaders/nis_frag.h index b20294eae8..8946f147c9 100644 --- a/app/src/main/cpp/shaders/nis_frag.h +++ b/app/src/main/cpp/shaders/nis_frag.h @@ -1,8 +1,9 @@ + // 1116.3.0 #pragma once const uint32_t nis_code[] = { - 0x07230203,0x00010000,0x0008000b,0x00000644,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x0000062f,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000051f,0x00000637,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000050a,0x00000622,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00050005,0x0000000b,0x59746567,0x33667628,0x0000003b,0x00030005,0x0000000a, 0x00626772,0x000b0005,0x00000019,0x65676465,0x66287441,0x31663b31,0x3b31663b,0x663b3166, @@ -28,1194 +29,1180 @@ const uint32_t nis_code[] = { 0x00000000,0x00060005,0x00000045,0x73616870,0x5f795f65,0x63617266,0x00000000,0x00070005, 0x00000046,0x73616870,0x5f785f65,0x63617266,0x746e695f,0x00000000,0x00070005,0x00000047, 0x73616870,0x5f795f65,0x63617266,0x746e695f,0x00000000,0x00030005,0x00000048,0x00000077, - 0x00030005,0x0000005e,0x00305f67,0x00040005,0x0000006b,0x35345f67,0x00000000,0x00040005, - 0x00000078,0x30395f67,0x00000000,0x00040005,0x00000085,0x33315f67,0x00000035,0x00050005, - 0x00000092,0x5f305f67,0x6d5f3039,0x00007861,0x00050005,0x00000096,0x5f305f67,0x6d5f3039, - 0x00006e69,0x00060005,0x0000009a,0x35345f67,0x3533315f,0x78616d5f,0x00000000,0x00060005, - 0x0000009e,0x35345f67,0x3533315f,0x6e696d5f,0x00000000,0x00040005,0x000000ac,0x5f305f65, - 0x00003039,0x00050005,0x000000b4,0x35345f65,0x3533315f,0x00000000,0x00040005,0x000000b8, - 0x5f305f63,0x00003039,0x00050005,0x000000c6,0x35345f63,0x3533315f,0x00000000,0x00050005, - 0x000000d2,0x5f675f63,0x30395f30,0x00000000,0x00050005,0x000000d6,0x5f675f63,0x315f3534, - 0x00003533,0x00050005,0x000000da,0x5f655f66,0x30395f30,0x00000000,0x00050005,0x000000e0, - 0x5f655f66,0x315f3534,0x00003533,0x00030005,0x000000e6,0x00003077,0x00030005,0x000000ec, - 0x00303977,0x00030005,0x000000f3,0x00353477,0x00040005,0x000000f9,0x35333177,0x00000000, - 0x00030005,0x00000107,0x00003068,0x00030005,0x0000010d,0x00003168,0x00050005,0x0000011a, - 0x656c6573,0x726f7463,0x00000000,0x00030005,0x0000011e,0x006c6573,0x00040005,0x00000123, - 0x696d5f61,0x0000006e,0x00040005,0x00000129,0x616d5f61,0x00000078,0x00040005,0x00000133, - 0x696d5f62,0x0000006e,0x00040005,0x00000139,0x616d5f62,0x00000078,0x00040005,0x0000013f, - 0x6f635f61,0x0000746e,0x00040005,0x00000143,0x6f635f62,0x0000746e,0x00050005,0x00000147, - 0x746e6f63,0x7461725f,0x00006f69,0x00030005,0x0000015f,0x00000079,0x00030005,0x00000160, - 0x00000069,0x00050005,0x00000215,0x65646e69,0x6c626178,0x00000065,0x00040005,0x00000221, - 0x73755f79,0x0000006d,0x00030005,0x00000222,0x00000069,0x00050005,0x000002b0,0x65646e69, - 0x6c626178,0x00000065,0x00040005,0x000002bb,0x63735f79,0x00656c61,0x00050005,0x000002c3, - 0x68735f79,0x6e707261,0x00737365,0x00070005,0x000002c6,0x61685367,0x74537072,0x676e6572, - 0x63536874,0x00656c61,0x00070005,0x000002c9,0x61685367,0x74537072,0x676e6572,0x694d6874, - 0x0000006e,0x00070005,0x000002cf,0x68735f79,0x6e707261,0x5f737365,0x696d696c,0x00000074, - 0x00070005,0x000002d1,0x61685367,0x694c7072,0x5374696d,0x656c6163,0x00000000,0x00060005, - 0x000002d4,0x61685367,0x694c7072,0x4d74696d,0x00006e69,0x00040005,0x000002e3,0x61726170, - 0x0000006d,0x00040005,0x000002e6,0x61726170,0x0000006d,0x00040005,0x000002e9,0x61726170, - 0x0000006d,0x00040005,0x000002ec,0x61726170,0x0000006d,0x00040005,0x000002ef,0x61726170, - 0x0000006d,0x00040005,0x000002f2,0x61726170,0x0000006d,0x00040005,0x000002f5,0x61726170, - 0x0000006d,0x00040005,0x00000303,0x63615f68,0x00000063,0x00030005,0x00000304,0x0000006a, - 0x00040005,0x0000030c,0x63615f76,0x00000063,0x00030005,0x0000030d,0x00000069,0x00050005, - 0x0000031d,0x65646e69,0x6c626178,0x00000065,0x00050005,0x0000032a,0x65646e69,0x6c626178, - 0x00000065,0x00030005,0x00000335,0x00000066,0x00030005,0x0000033b,0x00000069,0x00050005, - 0x00000343,0x65746e69,0x44307072,0x00006765,0x00040005,0x00000350,0x61726170,0x0000006d, - 0x00040005,0x00000352,0x61726170,0x0000006d,0x00030005,0x0000035f,0x00000069,0x00050005, - 0x00000367,0x65746e69,0x30397072,0x00676544,0x00040005,0x00000374,0x61726170,0x0000006d, - 0x00040005,0x00000376,0x61726170,0x0000006d,0x00050005,0x00000383,0x61687070,0x625f6573, - 0x00003534,0x00070005,0x0000038d,0x706d6574,0x746e695f,0x34707265,0x67654435,0x00000000, - 0x00030005,0x000003a5,0x00000061,0x00030005,0x000003b1,0x00000062,0x00030005,0x000003bd, - 0x00000063,0x00030005,0x000003c9,0x00000064,0x00050005,0x000003f1,0x61687070,0x705f6573, - 0x00003534,0x00030005,0x000003f9,0x00000069,0x00050005,0x00000401,0x65746e69,0x35347072, - 0x00676544,0x00030005,0x0000040d,0x00000069,0x00040005,0x00000420,0x61726170,0x0000006d, - 0x00040005,0x00000422,0x61726170,0x0000006d,0x00050005,0x0000042f,0x61687070,0x625f6573, - 0x00353331,0x00070005,0x00000434,0x706d6574,0x746e695f,0x31707265,0x65443533,0x00000067, - 0x00030005,0x0000044c,0x00000061,0x00030005,0x00000458,0x00000062,0x00030005,0x00000464, - 0x00000063,0x00030005,0x00000470,0x00000064,0x00050005,0x00000498,0x61687070,0x705f6573, - 0x00353331,0x00030005,0x000004a1,0x00000069,0x00060005,0x000004a9,0x65746e69,0x33317072, - 0x67654435,0x00000000,0x00030005,0x000004b5,0x00000069,0x00040005,0x000004c7,0x61726170, - 0x0000006d,0x00040005,0x000004c9,0x61726170,0x0000006d,0x00050005,0x000004d3,0x72616873, - 0x73656e70,0x00000073,0x00030005,0x000004d4,0x00004350,0x00040006,0x000004d4,0x00000000, - 0x0063646e,0x00070006,0x000004d4,0x00000001,0x77656956,0x74726f70,0x6f666e49,0x00000000, - 0x00060006,0x000004d4,0x00000002,0x72616873,0x73656e70,0x00000073,0x00030005,0x000004d6, - 0x00006370,0x00060005,0x000004db,0x72616873,0x5f6e6570,0x64696c73,0x00007265,0x00050005, - 0x000004de,0x5378614d,0x656c6163,0x00000000,0x00050005,0x000004e4,0x536e694d,0x656c6163, - 0x00000000,0x00050005,0x000004e8,0x696d694c,0x61635374,0x0000656c,0x00070005,0x000004f4, - 0x72616873,0x72745370,0x74676e65,0x78614d68,0x00000000,0x00060005,0x00000508,0x72616873, - 0x6d694c70,0x614d7469,0x00000078,0x00040005,0x00000514,0x69536e69,0x0000657a,0x00040005, - 0x00000519,0x49766e69,0x0000006e,0x00040005,0x0000051d,0x58637273,0x00000000,0x00060005, - 0x0000051f,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x00000527,0x59637273, - 0x00000000,0x00030005,0x0000052e,0x00787366,0x00030005,0x00000531,0x00797366,0x00030005, - 0x00000534,0x00007866,0x00030005,0x00000538,0x00007966,0x00040005,0x0000053c,0x695f7866, - 0x0000746e,0x00040005,0x00000540,0x695f7966,0x0000746e,0x00030005,0x00000544,0x00000069, - 0x00030005,0x0000054c,0x0000006a,0x00030005,0x00000554,0x00006374,0x00030005,0x00000564, - 0x00000070,0x00060005,0x0000056a,0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005, - 0x0000056e,0x61726170,0x0000006d,0x00030005,0x00000576,0x00303065,0x00040005,0x00000577, - 0x61726170,0x0000006d,0x00040005,0x0000057a,0x61726170,0x0000006d,0x00040005,0x0000057d, - 0x61726170,0x0000006d,0x00040005,0x00000580,0x61726170,0x0000006d,0x00040005,0x00000583, - 0x61726170,0x0000006d,0x00040005,0x00000586,0x61726170,0x0000006d,0x00040005,0x00000589, - 0x61726170,0x0000006d,0x00040005,0x0000058c,0x61726170,0x0000006d,0x00040005,0x0000058f, - 0x61726170,0x0000006d,0x00030005,0x00000593,0x00313065,0x00040005,0x00000594,0x61726170, - 0x0000006d,0x00040005,0x00000597,0x61726170,0x0000006d,0x00040005,0x0000059a,0x61726170, - 0x0000006d,0x00040005,0x0000059d,0x61726170,0x0000006d,0x00040005,0x000005a0,0x61726170, - 0x0000006d,0x00040005,0x000005a3,0x61726170,0x0000006d,0x00040005,0x000005a6,0x61726170, - 0x0000006d,0x00040005,0x000005a9,0x61726170,0x0000006d,0x00040005,0x000005ac,0x61726170, - 0x0000006d,0x00030005,0x000005b0,0x00303165,0x00040005,0x000005b1,0x61726170,0x0000006d, - 0x00040005,0x000005b4,0x61726170,0x0000006d,0x00040005,0x000005b7,0x61726170,0x0000006d, - 0x00040005,0x000005ba,0x61726170,0x0000006d,0x00040005,0x000005bd,0x61726170,0x0000006d, - 0x00040005,0x000005c0,0x61726170,0x0000006d,0x00040005,0x000005c3,0x61726170,0x0000006d, - 0x00040005,0x000005c6,0x61726170,0x0000006d,0x00040005,0x000005c9,0x61726170,0x0000006d, - 0x00030005,0x000005cd,0x00313165,0x00040005,0x000005ce,0x61726170,0x0000006d,0x00040005, - 0x000005d1,0x61726170,0x0000006d,0x00040005,0x000005d4,0x61726170,0x0000006d,0x00040005, - 0x000005d7,0x61726170,0x0000006d,0x00040005,0x000005da,0x61726170,0x0000006d,0x00040005, - 0x000005dd,0x61726170,0x0000006d,0x00040005,0x000005e0,0x61726170,0x0000006d,0x00040005, - 0x000005e3,0x61726170,0x0000006d,0x00040005,0x000005e6,0x61726170,0x0000006d,0x00030005, - 0x000005ea,0x00000077,0x00040005,0x000005eb,0x61726170,0x0000006d,0x00040005,0x000005ed, - 0x61726170,0x0000006d,0x00040005,0x000005ef,0x61726170,0x0000006d,0x00040005,0x000005f1, - 0x61726170,0x0000006d,0x00040005,0x000005f3,0x61726170,0x0000006d,0x00040005,0x000005f5, - 0x61726170,0x0000006d,0x00050005,0x000005f8,0x65736162,0x67696557,0x00007468,0x00030005, - 0x00000605,0x0059706f,0x00040005,0x00000606,0x61726170,0x0000006d,0x00040005,0x00000608, - 0x61726170,0x0000006d,0x00040005,0x0000060a,0x61726170,0x0000006d,0x00040005,0x0000060f, - 0x61726170,0x0000006d,0x00040005,0x00000611,0x61726170,0x0000006d,0x00040005,0x00000613, - 0x61726170,0x0000006d,0x00040005,0x00000615,0x61726170,0x0000006d,0x00040005,0x00000617, - 0x61726170,0x0000006d,0x00040005,0x00000619,0x61726170,0x0000006d,0x00030005,0x0000061e, - 0x0000706f,0x00030005,0x00000622,0x00000079,0x00040005,0x00000623,0x61726170,0x0000006d, - 0x00040005,0x00000627,0x72726f63,0x00000000,0x00050005,0x00000637,0x4374756f,0x726f6c6f, - 0x00000000,0x00030047,0x000004d4,0x00000002,0x00050048,0x000004d4,0x00000000,0x00000023, - 0x00000000,0x00050048,0x000004d4,0x00000001,0x00000023,0x00000010,0x00050048,0x000004d4, - 0x00000002,0x00000023,0x00000020,0x00040047,0x0000051f,0x0000001e,0x00000000,0x00040047, - 0x0000056a,0x00000021,0x00000000,0x00040047,0x0000056a,0x00000022,0x00000000,0x00040047, - 0x00000637,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, - 0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000003,0x00040020, - 0x00000008,0x00000007,0x00000007,0x00040021,0x00000009,0x00000006,0x00000008,0x00040020, - 0x0000000d,0x00000007,0x00000006,0x00040017,0x0000000e,0x00000006,0x00000004,0x000c0021, - 0x0000000f,0x0000000e,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d, - 0x0000000d,0x0000000d,0x0000000d,0x00040020,0x0000001b,0x00000007,0x0000000e,0x00090021, - 0x0000001c,0x0000000e,0x0000001b,0x0000001b,0x0000001b,0x0000001b,0x0000000d,0x0000000d, - 0x00040015,0x00000025,0x00000020,0x00000001,0x00040020,0x00000026,0x00000007,0x00000025, - 0x000a0021,0x00000027,0x00000006,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d, - 0x0000000d,0x00000026,0x00040015,0x00000031,0x00000020,0x00000000,0x0004002b,0x00000031, - 0x00000032,0x00000006,0x0004001c,0x00000033,0x00000006,0x00000032,0x00040020,0x00000034, - 0x00000007,0x00000033,0x00050021,0x00000035,0x00000006,0x00000034,0x00000026,0x0004001c, - 0x0000003a,0x00000033,0x00000032,0x00040020,0x0000003b,0x00000007,0x0000003a,0x00060021, - 0x0000003c,0x00000006,0x0000003b,0x00000026,0x00000026,0x00090021,0x00000042,0x00000006, - 0x0000003b,0x0000000d,0x0000000d,0x00000026,0x00000026,0x0000001b,0x0004002b,0x00000006, - 0x0000004b,0x3e59b3d0,0x0004002b,0x00000031,0x0000004c,0x00000000,0x0004002b,0x00000006, - 0x00000050,0x3f371759,0x0004002b,0x00000031,0x00000051,0x00000001,0x0004002b,0x00000006, - 0x00000056,0x3d93dd98,0x0004002b,0x00000031,0x00000057,0x00000002,0x0004002b,0x00000006, - 0x000000a5,0x00000000,0x00020014,0x000000a6,0x0007002c,0x0000000e,0x000000aa,0x000000a5, - 0x000000a5,0x000000a5,0x000000a5,0x0004002b,0x00000006,0x000000b2,0x3f800000,0x00040020, - 0x000000b7,0x00000007,0x000000a6,0x0004002b,0x00000006,0x000000bb,0x400ce000,0x0004002b, - 0x00000006,0x000000bf,0x3d800000,0x0004002b,0x00000025,0x0000011c,0x00000020,0x0004002b, - 0x00000006,0x0000014e,0x3b808081,0x0004002b,0x00000006,0x00000152,0x40000000,0x0004002b, - 0x00000006,0x00000154,0x3e000000,0x0004002b,0x00000025,0x0000015c,0x00000000,0x0004002b, - 0x00000025,0x0000015d,0x0000003f,0x0004002b,0x00000025,0x00000167,0x00000006,0x0004002b, - 0x00000031,0x00000169,0x00000180,0x0004001c,0x0000016a,0x00000006,0x00000169,0x0004002b, - 0x00000006,0x0000016b,0x3b3e0ded,0x0004002b,0x00000006,0x0000016c,0xbc5013a9,0x0004002b, - 0x00000006,0x0000016d,0x3c5844d0,0x0004002b,0x00000006,0x0000016e,0xbb5ed289,0x0004002b, - 0x00000006,0x0000016f,0x3bce703b,0x0004002b,0x00000006,0x00000170,0xbccbfb16,0x0004002b, - 0x00000006,0x00000171,0x3f7f9db2,0x0004002b,0x00000006,0x00000172,0x3cdc5d64,0x0004002b, - 0x00000006,0x00000173,0xbbded289,0x0004002b,0x00000006,0x00000174,0x3c102de0,0x0004002b, - 0x00000006,0x00000175,0xbd13dd98,0x0004002b,0x00000006,0x00000176,0x3f7edfa4,0x0004002b, - 0x00000006,0x00000177,0x3d29fbe7,0x0004002b,0x00000006,0x00000178,0xbc28c155,0x0004002b, - 0x00000006,0x00000179,0x3a03126f,0x0004002b,0x00000006,0x0000017a,0x3c3fb15b,0x0004002b, - 0x00000006,0x0000017b,0xbd422681,0x0004002b,0x00000006,0x0000017c,0x3f7e425b,0x0004002b, - 0x00000006,0x0000017d,0x3d6631f9,0x0004002b,0x00000006,0x0000017e,0xbc68a71e,0x0004002b, - 0x00000006,0x0000017f,0x3c68a71e,0x0004002b,0x00000006,0x00000180,0xbd6bedfa,0x0004002b, - 0x00000006,0x00000181,0x3f7d5cfb,0x0004002b,0x00000006,0x00000182,0x3d9205bc,0x0004002b, - 0x00000006,0x00000183,0xbc944674,0x0004002b,0x00000006,0x00000184,0x3c87fcb9,0x0004002b, - 0x00000006,0x00000185,0xbd8a0903,0x0004002b,0x00000006,0x00000186,0x3f7c01a3,0x0004002b, - 0x00000006,0x00000187,0x3db2fec5,0x0004002b,0x00000006,0x00000188,0xbcb43958,0x0004002b, - 0x00000006,0x00000189,0x3a83126f,0x0004002b,0x00000006,0x0000018a,0x3c985f07,0x0004002b, - 0x00000006,0x0000018b,0xbd9c0ebf,0x0004002b,0x00000006,0x0000018c,0x3f7a7efa,0x0004002b, - 0x00000006,0x0000018d,0x3dd4fdf4,0x0004002b,0x00000006,0x0000018e,0xbcd844d0,0x0004002b, - 0x00000006,0x0000018f,0x3ac49ba6,0x0004002b,0x00000006,0x00000190,0x3ca7ef9e,0x0004002b, - 0x00000006,0x00000191,0xbdae147b,0x0004002b,0x00000006,0x00000192,0x3f7902de,0x0004002b, - 0x00000006,0x00000193,0x3df6fd22,0x0004002b,0x00000006,0x00000194,0xbcfc5048,0x0004002b, - 0x00000006,0x00000195,0x3b03126f,0x0004002b,0x00000006,0x00000196,0x3cb851ec,0x0004002b, - 0x00000006,0x00000197,0xbdbe0ded,0x0004002b,0x00000006,0x00000198,0x3f76fd22,0x0004002b, - 0x00000006,0x00000199,0x3e0d844d,0x0004002b,0x00000006,0x0000019a,0xbd102de0,0x0004002b, - 0x00000006,0x0000019b,0x3b1d4952,0x0004002b,0x00000006,0x0000019c,0x3cc3c9ef,0x0004002b, - 0x00000006,0x0000019d,0xbdce075f,0x0004002b,0x00000006,0x0000019e,0x3f751eb8,0x0004002b, - 0x00000006,0x0000019f,0x3e1f8a09,0x0004002b,0x00000006,0x000001a0,0xbd22339c,0x0004002b, - 0x00000006,0x000001a1,0x3cd013a9,0x0004002b,0x00000006,0x000001a2,0xbddbf488,0x0004002b, - 0x00000006,0x000001a3,0x3f72de01,0x0004002b,0x00000006,0x000001a4,0x3e31f8a1,0x0004002b, - 0x00000006,0x000001a5,0xbd33d07d,0x0004002b,0x00000006,0x000001a6,0x3b5ed289,0x0004002b, - 0x00000006,0x000001a7,0x3cd844d0,0x0004002b,0x00000006,0x000001a8,0xbde90ff9,0x0004002b, - 0x00000006,0x000001a9,0x3f70624e,0x0004002b,0x00000006,0x000001aa,0x3e458794,0x0004002b, - 0x00000006,0x000001ab,0xbd47e282,0x0004002b,0x00000006,0x000001ac,0x3b902de0,0x0004002b, - 0x00000006,0x000001ad,0x3ce3bcd3,0x0004002b,0x00000006,0x000001ae,0xbdf3eab3,0x0004002b, - 0x00000006,0x000001af,0x3f6d9e84,0x0004002b,0x00000006,0x000001b0,0x3e58fc50,0x0004002b, - 0x00000006,0x000001b1,0xbd5bf488,0x0004002b,0x00000006,0x000001b2,0x3ba0902e,0x0004002b, - 0x00000006,0x000001b3,0x3cebedfa,0x0004002b,0x00000006,0x000001b4,0xbdfef9db,0x0004002b, - 0x00000006,0x000001b5,0x3f6ac083,0x0004002b,0x00000006,0x000001b6,0x3e6c8b44,0x0004002b, - 0x00000006,0x000001b7,0xbd6dfa44,0x0004002b,0x00000006,0x000001b8,0x3bc154ca,0x0004002b, - 0x00000006,0x000001b9,0x3cf0068e,0x0004002b,0x00000006,0x000001ba,0xbe04816f,0x0004002b, - 0x00000006,0x000001bb,0x3f67e282,0x0004002b,0x00000006,0x000001bc,0x3e808312,0x0004002b, - 0x00000006,0x000001bd,0xbd810625,0x0004002b,0x00000006,0x000001be,0x3cf837b5,0x0004002b, - 0x00000006,0x000001bf,0xbe087fcc,0x0004002b,0x00000006,0x000001c0,0x3f64816f,0x0004002b, - 0x00000006,0x000001c1,0x3e8ac083,0x0004002b,0x00000006,0x000001c2,0xbd8b0f28,0x0004002b, - 0x00000006,0x000001c3,0x3bef34d7,0x0004002b,0x00000006,0x000001c4,0x3cfc5048,0x0004002b, - 0x00000006,0x000001c5,0xbe0bfb16,0x0004002b,0x00000006,0x000001c6,0x3f60ff97,0x0004002b, - 0x00000006,0x000001c7,0x3e953f7d,0x0004002b,0x00000006,0x000001c8,0xbd95182b,0x0004002b, - 0x00000006,0x000001c9,0x3c07fcb9,0x0004002b,0x00000006,0x000001ca,0xbe0f7660,0x0004002b, - 0x00000006,0x000001cb,0x3f5d9e84,0x0004002b,0x00000006,0x000001cc,0x3e9fbe77,0x0004002b, - 0x00000006,0x000001cd,0xbd9eecc0,0x0004002b,0x00000006,0x000001ce,0x3c185f07,0x0004002b, - 0x00000006,0x000001cf,0x3d00346e,0x0004002b,0x00000006,0x000001d0,0xbe1205bc,0x0004002b, - 0x00000006,0x000001d1,0x3f59c0ec,0x0004002b,0x00000006,0x000001d2,0x3eaa7efa,0x0004002b, - 0x00000006,0x000001d3,0xbda8f5c3,0x0004002b,0x00000006,0x000001d4,0x3c28c155,0x0004002b, - 0x00000006,0x000001d5,0xbe13f7cf,0x0004002b,0x00000006,0x000001d6,0x3f55dcc6,0x0004002b, - 0x00000006,0x000001d7,0x3eb53f7d,0x0004002b,0x00000006,0x000001d8,0xbdb2fec5,0x0004002b, - 0x00000006,0x000001d9,0x3c378034,0x0004002b,0x00000006,0x000001da,0xbe158106,0x0004002b, - 0x00000006,0x000001db,0x3f51bda5,0x0004002b,0x00000006,0x000001dc,0x3ec04189,0x0004002b, - 0x00000006,0x000001dd,0xbdbd07c8,0x0004002b,0x00000006,0x000001de,0x3c47e282,0x0004002b, - 0x00000006,0x000001df,0xbe16872b,0x0004002b,0x00000006,0x000001e0,0x3f4d5cfb,0x0004002b, - 0x00000006,0x000001e1,0x3ecb020c,0x0004002b,0x00000006,0x000001e2,0xbdc60aa6,0x0004002b, - 0x00000006,0x000001e3,0x3c6075f7,0x0004002b,0x00000006,0x000001e4,0xbe177319,0x0004002b, - 0x00000006,0x000001e5,0x3f491d15,0x0004002b,0x00000006,0x000001e6,0x3ed645a2,0x0004002b, - 0x00000006,0x000001e7,0xbdd013a9,0x0004002b,0x00000006,0x000001e8,0x3c6f34d7,0x0004002b, - 0x00000006,0x000001e9,0x3f44a234,0x0004002b,0x00000006,0x000001ea,0x3ee13a93,0x0004002b, - 0x00000006,0x000001eb,0xbdd91687,0x0004002b,0x00000006,0x000001ec,0x3c7f9724,0x0004002b, - 0x00000006,0x000001ed,0x3cf41f21,0x0004002b,0x00000006,0x000001ee,0x3f4020c5,0x0004002b, - 0x00000006,0x000001ef,0x3eec3c9f,0x0004002b,0x00000006,0x000001f0,0xbde21965,0x0004002b, - 0x00000006,0x000001f1,0x3f3b3d08,0x0004002b,0x00000006,0x000001f2,0x3ef73eab,0x0004002b, - 0x00000006,0x000001f3,0xbdeae7d5,0x0004002b,0x00000006,0x000001f4,0x3c944674,0x0004002b, - 0x00000006,0x000001f5,0x3f363f14,0x0004002b,0x00000006,0x000001f6,0x3f014120,0x0004002b, - 0x00000006,0x000001f7,0xbdf318fc,0x0004002b,0x00000006,0x000001f8,0x3c9ba5e3,0x0004002b, - 0x00000006,0x000001f9,0x3f3161e5,0x0004002b,0x00000006,0x000001fa,0x3f06c227,0x0004002b, - 0x00000006,0x000001fb,0xbdfb15b5,0x0004002b,0x00000006,0x000001fc,0x3ca3d70a,0x0004002b, - 0x00000006,0x000001fd,0x3cdfa440,0x0004002b,0x00000006,0x000001fe,0xbe1288ce,0x0004002b, - 0x00000006,0x000001ff,0x3f2c2268,0x0004002b,0x00000006,0x00000200,0x3f0c432d,0x0004002b, - 0x00000006,0x00000201,0xbe010625,0x0004002b,0x00000006,0x00000202,0x3cb020c5,0x0004002b, - 0x00000006,0x00000203,0xbe107c85,0x0004002b,0x00000006,0x00000204,0x3f271de7,0x0004002b, - 0x00000006,0x00000205,0x3f11bda5,0x0004002b,0x00000006,0x00000206,0xbe050481,0x0004002b, - 0x00000006,0x00000207,0xbe0e075f,0x0004002b,0x00000006,0x00000208,0x3f21de6a,0x0004002b, - 0x00000006,0x00000209,0x3f171de7,0x0004002b,0x00000006,0x0000020a,0xbe07fcb9,0x0004002b, - 0x00000006,0x0000020b,0x3cbfb15b,0x0004002b,0x00000006,0x0000020c,0x3cc7e282,0x0004002b, - 0x00000006,0x0000020d,0xbe0af4f1,0x0004002b,0x00000006,0x0000020e,0x3f1c7e28,0x0183002c, - 0x0000016a,0x0000020f,0x000000a5,0x000000a5,0x000000b2,0x000000a5,0x000000a5,0x000000a5, - 0x0000016b,0x0000016c,0x000000b2,0x0000016d,0x0000016e,0x000000a5,0x0000016f,0x00000170, - 0x00000171,0x00000172,0x00000173,0x000000a5,0x00000174,0x00000175,0x00000176,0x00000177, - 0x00000178,0x00000179,0x0000017a,0x0000017b,0x0000017c,0x0000017d,0x0000017e,0x00000179, - 0x0000017f,0x00000180,0x00000181,0x00000182,0x00000183,0x00000179,0x00000184,0x00000185, - 0x00000186,0x00000187,0x00000188,0x00000189,0x0000018a,0x0000018b,0x0000018c,0x0000018d, - 0x0000018e,0x0000018f,0x00000190,0x00000191,0x00000192,0x00000193,0x00000194,0x00000195, - 0x00000196,0x00000197,0x00000198,0x00000199,0x0000019a,0x0000019b,0x0000019c,0x0000019d, - 0x0000019e,0x0000019f,0x000001a0,0x0000016b,0x000001a1,0x000001a2,0x000001a3,0x000001a4, - 0x000001a5,0x000001a6,0x000001a7,0x000001a8,0x000001a9,0x000001aa,0x000001ab,0x000001ac, - 0x000001ad,0x000001ae,0x000001af,0x000001b0,0x000001b1,0x000001b2,0x000001b3,0x000001b4, - 0x000001b5,0x000001b6,0x000001b7,0x000001b8,0x000001b9,0x000001ba,0x000001bb,0x000001bc, - 0x000001bd,0x0000016f,0x000001be,0x000001bf,0x000001c0,0x000001c1,0x000001c2,0x000001c3, - 0x000001c4,0x000001c5,0x000001c6,0x000001c7,0x000001c8,0x000001c9,0x000001c4,0x000001ca, - 0x000001cb,0x000001cc,0x000001cd,0x000001ce,0x000001cf,0x000001d0,0x000001d1,0x000001d2, - 0x000001d3,0x000001d4,0x000001cf,0x000001d5,0x000001d6,0x000001d7,0x000001d8,0x000001d9, - 0x000001cf,0x000001da,0x000001db,0x000001dc,0x000001dd,0x000001de,0x000001cf,0x000001df, - 0x000001e0,0x000001e1,0x000001e2,0x000001e3,0x000001c4,0x000001e4,0x000001e5,0x000001e6, - 0x000001e7,0x000001e8,0x000001be,0x000001e4,0x000001e9,0x000001ea,0x000001eb,0x000001ec, - 0x000001ed,0x000001e4,0x000001ee,0x000001ef,0x000001f0,0x00000184,0x000001b9,0x000001df, - 0x000001f1,0x000001f2,0x000001f3,0x000001f4,0x000001b3,0x000001da,0x000001f5,0x000001f6, - 0x000001f7,0x000001f8,0x000001ad,0x000001d5,0x000001f9,0x000001fa,0x000001fb,0x000001fc, - 0x000001fd,0x000001fe,0x000001ff,0x00000200,0x00000201,0x00000202,0x000001a7,0x00000203, - 0x00000204,0x00000205,0x00000206,0x00000196,0x000001a1,0x00000207,0x00000208,0x00000209, - 0x0000020a,0x0000020b,0x0000020c,0x0000020d,0x0000020e,0x0000020e,0x0000020d,0x0000020c, - 0x0000020b,0x0000020a,0x00000209,0x00000208,0x00000207,0x000001a1,0x00000196,0x00000206, - 0x00000205,0x00000204,0x00000203,0x000001a7,0x00000202,0x00000201,0x00000200,0x000001ff, - 0x000001fe,0x000001fd,0x000001fc,0x000001fb,0x000001fa,0x000001f9,0x000001d5,0x000001ad, - 0x000001f8,0x000001f7,0x000001f6,0x000001f5,0x000001da,0x000001b3,0x000001f4,0x000001f3, - 0x000001f2,0x000001f1,0x000001df,0x000001b9,0x00000184,0x000001f0,0x000001ef,0x000001ee, - 0x000001e4,0x000001ed,0x000001ec,0x000001eb,0x000001ea,0x000001e9,0x000001e4,0x000001be, - 0x000001e8,0x000001e7,0x000001e6,0x000001e5,0x000001e4,0x000001c4,0x000001e3,0x000001e2, - 0x000001e1,0x000001e0,0x000001df,0x000001cf,0x000001de,0x000001dd,0x000001dc,0x000001db, - 0x000001da,0x000001cf,0x000001d9,0x000001d8,0x000001d7,0x000001d6,0x000001d5,0x000001cf, - 0x000001d4,0x000001d3,0x000001d2,0x000001d1,0x000001d0,0x000001cf,0x000001ce,0x000001cd, - 0x000001cc,0x000001cb,0x000001ca,0x000001c4,0x000001c9,0x000001c8,0x000001c7,0x000001c6, - 0x000001c5,0x000001c4,0x000001c3,0x000001c2,0x000001c1,0x000001c0,0x000001bf,0x000001be, - 0x0000016f,0x000001bd,0x000001bc,0x000001bb,0x000001ba,0x000001b9,0x000001b8,0x000001b7, - 0x000001b6,0x000001b5,0x000001b4,0x000001b3,0x000001b2,0x000001b1,0x000001b0,0x000001af, - 0x000001ae,0x000001ad,0x000001ac,0x000001ab,0x000001aa,0x000001a9,0x000001a8,0x000001a7, - 0x000001a6,0x000001a5,0x000001a4,0x000001a3,0x000001a2,0x000001a1,0x0000016b,0x000001a0, - 0x0000019f,0x0000019e,0x0000019d,0x0000019c,0x0000019b,0x0000019a,0x00000199,0x00000198, - 0x00000197,0x00000196,0x00000195,0x00000194,0x00000193,0x00000192,0x00000191,0x00000190, - 0x0000018f,0x0000018e,0x0000018d,0x0000018c,0x0000018b,0x0000018a,0x00000189,0x00000188, - 0x00000187,0x00000186,0x00000185,0x00000184,0x00000179,0x00000183,0x00000182,0x00000181, - 0x00000180,0x0000017f,0x00000179,0x0000017e,0x0000017d,0x0000017c,0x0000017b,0x0000017a, - 0x00000179,0x00000178,0x00000177,0x00000176,0x00000175,0x00000174,0x000000a5,0x00000173, - 0x00000172,0x00000171,0x00000170,0x0000016f,0x000000a5,0x0000016e,0x0000016d,0x000000b2, - 0x0000016c,0x0000016b,0x00040020,0x00000214,0x00000007,0x0000016a,0x0004002b,0x00000025, - 0x0000021f,0x00000001,0x0004002b,0x00000006,0x0000022a,0xbf19a027,0x0004002b,0x00000006, - 0x0000022b,0x3f99a027,0x0004002b,0x00000006,0x0000022c,0xbf1bc01a,0x0004002b,0x00000006, - 0x0000022d,0x3f996f00,0x0004002b,0x00000006,0x0000022e,0xbf171de7,0x0004002b,0x00000006, - 0x0000022f,0xbb3e0ded,0x0004002b,0x00000006,0x00000230,0xbf1d5cfb,0x0004002b,0x00000006, - 0x00000231,0x3f990ff9,0x0004002b,0x00000006,0x00000232,0xbf143fe6,0x0004002b,0x00000006, - 0x00000233,0xbf1e9e1b,0x0004002b,0x00000006,0x00000234,0x3f983127,0x0004002b,0x00000006, - 0x00000235,0xbf10ded3,0x0004002b,0x00000006,0x00000236,0xbf1f9db2,0x0004002b,0x00000006, - 0x00000237,0x3f9710cb,0x0004002b,0x00000006,0x00000238,0xbf0d21ff,0x0004002b,0x00000006, - 0x00000239,0xbc7765fe,0x0004002b,0x00000006,0x0000023a,0xbf20624e,0x0004002b,0x00000006, - 0x0000023b,0x3f95bf48,0x0004002b,0x00000006,0x0000023c,0xbf0902de,0x0004002b,0x00000006, - 0x0000023d,0xbc9fbe77,0x0004002b,0x00000006,0x0000023e,0xbf208312,0x0004002b,0x00000006, - 0x0000023f,0x3f943fe6,0x0004002b,0x00000006,0x00000240,0xbf04a234,0x0004002b,0x00000006, - 0x00000241,0xbcd42c3d,0x0004002b,0x00000006,0x00000242,0xbf20ded3,0x0004002b,0x00000006, - 0x00000243,0x3f929fbe,0x0004002b,0x00000006,0x00000244,0xbf0020c5,0x0004002b,0x00000006, - 0x00000245,0xbd01d7dc,0x0004002b,0x00000006,0x00000246,0x3f904ea5,0x0004002b,0x00000006, - 0x00000247,0xbef53f7d,0x0004002b,0x00000006,0x00000248,0xbd1e1b09,0x0004002b,0x00000006, - 0x00000249,0x3f8df06f,0x0004002b,0x00000006,0x0000024a,0xbee9fbe7,0x0004002b,0x00000006, - 0x0000024b,0xbd39f55a,0x0004002b,0x00000006,0x0000024c,0x3c902de0,0x0004002b,0x00000006, - 0x0000024d,0xbf1e6320,0x0004002b,0x00000006,0x0000024e,0x3f8b404f,0x0004002b,0x00000006, - 0x0000024f,0xbede83e4,0x0004002b,0x00000006,0x00000250,0xbd59e83e,0x0004002b,0x00000006, - 0x00000251,0xbf1d21ff,0x0004002b,0x00000006,0x00000252,0x3f886f69,0x0004002b,0x00000006, - 0x00000253,0xbed205bc,0x0004002b,0x00000006,0x00000254,0xbd7be76d,0x0004002b,0x00000006, - 0x00000255,0xbf1b5dcc,0x0004002b,0x00000006,0x00000256,0x3f852f1b,0x0004002b,0x00000006, - 0x00000257,0xbec4c2f8,0x0004002b,0x00000006,0x00000258,0xbd8ef34d,0x0004002b,0x00000006, - 0x00000259,0x3c9fbe77,0x0004002b,0x00000006,0x0000025a,0xbf19c0ec,0x0004002b,0x00000006, - 0x0000025b,0x3f820f91,0x0004002b,0x00000006,0x0000025c,0xbeb6fd22,0x0004002b,0x00000006, - 0x0000025d,0xbda30553,0x0004002b,0x00000006,0x0000025e,0xbf17c1be,0x0004002b,0x00000006, - 0x0000025f,0x3f7d42c4,0x0004002b,0x00000006,0x00000260,0xbea83e42,0x0004002b,0x00000006, - 0x00000261,0xbdb7e910,0x0004002b,0x00000006,0x00000262,0xbf14fdf4,0x0004002b,0x00000006, - 0x00000263,0x3f753f7d,0x0004002b,0x00000006,0x00000264,0xbe98fc50,0x0004002b,0x00000006, - 0x00000265,0xbdcd013b,0x0004002b,0x00000006,0x00000266,0xbf12a305,0x0004002b,0x00000006, - 0x00000267,0x3f6de00d,0x0004002b,0x00000006,0x00000268,0xbe89ba5e,0x0004002b,0x00000006, - 0x00000269,0xbf0fdf3b,0x0004002b,0x00000006,0x0000026a,0x3f65c28f,0x0004002b,0x00000006, - 0x0000026b,0xbe727bb3,0x0004002b,0x00000006,0x0000026c,0x3b7f9724,0x0004002b,0x00000006, - 0x0000026d,0xbf0cbfb1,0x0004002b,0x00000006,0x0000026e,0x3f5d42c4,0x0004002b,0x00000006, - 0x0000026f,0xbe5182aa,0x0004002b,0x00000006,0x00000270,0xbe0985f0,0x0004002b,0x00000006, - 0x00000271,0xbf097f63,0x0004002b,0x00000006,0x00000272,0x3f54816f,0x0004002b,0x00000006, - 0x00000273,0xbe2f0069,0x0004002b,0x00000006,0x00000274,0xbe160419,0x0004002b,0x00000006, - 0x00000275,0xbf061e4f,0x0004002b,0x00000006,0x00000276,0x3f4b5dcc,0x0004002b,0x00000006, - 0x00000277,0xbe228241,0x0004002b,0x00000006,0x00000278,0x3bb0f27c,0x0004002b,0x00000006, - 0x00000279,0xbf02bd3c,0x0004002b,0x00000006,0x0000027a,0x3f428241,0x0004002b,0x00000006, - 0x0000027b,0xbdd119ce,0x0004002b,0x00000006,0x0000027c,0xbe3089a0,0x0004002b,0x00000006, - 0x0000027d,0xbefe425b,0x0004002b,0x00000006,0x0000027e,0x3f391d15,0x0004002b,0x00000006, - 0x0000027f,0xbd84ea4b,0x0004002b,0x00000006,0x00000280,0xbe3ef9db,0x0004002b,0x00000006, - 0x00000281,0xbef6bb99,0x0004002b,0x00000006,0x00000282,0x3f2f41f2,0x0004002b,0x00000006, - 0x00000283,0xbcebedfa,0x0004002b,0x00000006,0x00000284,0xbe4c7e28,0x0004002b,0x00000006, - 0x00000285,0x3bded289,0x0004002b,0x00000006,0x00000286,0xbeef0069,0x0004002b,0x00000006, - 0x00000287,0x3f256042,0x0004002b,0x00000006,0x00000288,0xbe5b8bac,0x0004002b,0x00000006, - 0x00000289,0xbee6c227,0x0004002b,0x00000006,0x0000028a,0x3f1b020c,0x0004002b,0x00000006, - 0x0000028b,0x3d4432ca,0x0004002b,0x00000006,0x0000028c,0xbe6a7efa,0x0004002b,0x00000006, - 0x0000028d,0x3c8c154d,0x0004002b,0x00000006,0x0000028e,0xbedfbe77,0x0004002b,0x00000006, - 0x0000028f,0x3dafec57,0x0004002b,0x00000006,0x00000290,0xbe7a786c,0x0004002b,0x00000006, - 0x00000291,0x3c83e426,0x0004002b,0x00000006,0x00000292,0xbed6fd22,0x0004002b,0x00000006, - 0x00000293,0x3f073eab,0x0004002b,0x00000006,0x00000294,0x3e008312,0x0004002b,0x00000006, - 0x00000295,0xbe850481,0x0004002b,0x00000006,0x00000296,0x3c20902e,0x0004002b,0x00000006, - 0x00000297,0xbecf41f2,0x0004002b,0x00000006,0x00000298,0x3efa0275,0x0004002b,0x00000006, - 0x00000299,0x3e2978d5,0x0004002b,0x00000006,0x0000029a,0xbe8d013b,0x0004002b,0x00000006, - 0x0000029b,0x3c7765fe,0x0004002b,0x00000006,0x0000029c,0xbec703b0,0x0004002b,0x00000006, - 0x0000029d,0x3ee63f14,0x0004002b,0x00000006,0x0000029e,0x3e50ff97,0x0004002b,0x00000006, - 0x0000029f,0xbe94fdf4,0x0004002b,0x00000006,0x000002a0,0x3c2f4f0e,0x0004002b,0x00000006, - 0x000002a1,0xbebe00d2,0x0004002b,0x00000006,0x000002a2,0x3ed07c85,0x0004002b,0x00000006, - 0x000002a3,0x3e7a786c,0x0004002b,0x00000006,0x000002a4,0xbe9cfaad,0x0004002b,0x00000006, - 0x000002a5,0xbeb60419,0x0004002b,0x00000006,0x000002a6,0x3ebc01a3,0x0004002b,0x00000006, - 0x000002a7,0x3e9205bc,0x0004002b,0x00000006,0x000002a8,0xbea5460b,0x0004002b,0x00000006, - 0x000002a9,0xbeadc5d6,0x0004002b,0x00000006,0x000002aa,0x3ea703b0,0x0183002c,0x0000016a, - 0x000002ab,0x000000a5,0x0000022a,0x0000022b,0x0000022a,0x000000a5,0x000000a5,0x0000016b, - 0x0000022c,0x0000022d,0x0000022e,0x0000022f,0x000000a5,0x000001b2,0x00000230,0x00000231, - 0x00000232,0x00000173,0x00000179,0x000001c3,0x00000233,0x00000234,0x00000235,0x00000178, - 0x000000a5,0x000001ce,0x00000236,0x00000237,0x00000238,0x00000239,0x000000a5,0x000001d9, - 0x0000023a,0x0000023b,0x0000023c,0x0000023d,0x00000179,0x000001de,0x0000023e,0x0000023f, - 0x00000240,0x00000241,0x00000179,0x0000017f,0x00000242,0x00000243,0x00000244,0x00000245, - 0x00000179,0x000001ec,0x0000023a,0x00000246,0x00000247,0x00000248,0x00000179,0x00000184, - 0x00000236,0x00000249,0x0000024a,0x0000024b,0x00000189,0x0000024c,0x0000024d,0x0000024e, - 0x0000024f,0x00000250,0x00000189,0x000001f4,0x00000251,0x00000252,0x00000253,0x00000254, - 0x0000018f,0x000001f8,0x00000255,0x00000256,0x00000257,0x00000258,0x0000018f,0x00000259, - 0x0000025a,0x0000025b,0x0000025c,0x0000025d,0x00000195,0x000001fc,0x0000025e,0x0000025f, - 0x00000260,0x00000261,0x0000019b,0x000001fc,0x00000262,0x00000263,0x00000264,0x00000265, - 0x0000016b,0x000001fc,0x00000266,0x00000267,0x00000268,0x000001f0,0x000001a6,0x000001fc, - 0x00000269,0x0000026a,0x0000026b,0x000001fb,0x0000026c,0x00000190,0x0000026d,0x0000026e, - 0x0000026f,0x00000270,0x000001ac,0x000001fc,0x00000271,0x00000272,0x00000273,0x00000274, - 0x000001b2,0x00000259,0x00000275,0x00000276,0x000001c5,0x00000277,0x00000278,0x00000259, - 0x00000279,0x0000027a,0x0000027b,0x0000027c,0x000001b8,0x000001f8,0x0000027d,0x0000027e, - 0x0000027f,0x00000280,0x0000016f,0x0000018a,0x00000281,0x00000282,0x00000283,0x00000284, - 0x00000285,0x0000018a,0x00000286,0x00000287,0x000001ce,0x00000288,0x000001c3,0x0000024c, - 0x00000289,0x0000028a,0x0000028b,0x0000028c,0x000001c9,0x0000028d,0x0000028e,0x00000205, - 0x0000028f,0x00000290,0x00000174,0x00000291,0x00000292,0x00000293,0x00000294,0x00000295, - 0x00000296,0x00000291,0x00000297,0x00000298,0x00000299,0x0000029a,0x000001d4,0x0000029b, - 0x0000029c,0x0000029d,0x0000029e,0x0000029f,0x000002a0,0x0000017f,0x000002a1,0x000002a2, - 0x000002a3,0x000002a4,0x0000017a,0x000001e3,0x000002a5,0x000002a6,0x000002a7,0x000002a8, - 0x000001de,0x0000016d,0x000002a9,0x000002aa,0x000002aa,0x000002a9,0x0000016d,0x000001de, - 0x000002a8,0x000002a7,0x000002a6,0x000002a5,0x000001e3,0x0000017a,0x000002a4,0x000002a3, - 0x000002a2,0x000002a1,0x0000017f,0x000002a0,0x0000029f,0x0000029e,0x0000029d,0x0000029c, - 0x0000029b,0x000001d4,0x0000029a,0x00000299,0x00000298,0x00000297,0x00000291,0x00000296, - 0x00000295,0x00000294,0x00000293,0x00000292,0x00000291,0x00000174,0x00000290,0x0000028f, - 0x00000205,0x0000028e,0x0000028d,0x000001c9,0x0000028c,0x0000028b,0x0000028a,0x00000289, - 0x0000024c,0x000001c3,0x00000288,0x000001ce,0x00000287,0x00000286,0x0000018a,0x00000285, - 0x00000284,0x00000283,0x00000282,0x00000281,0x0000018a,0x0000016f,0x00000280,0x0000027f, - 0x0000027e,0x0000027d,0x000001f8,0x000001b8,0x0000027c,0x0000027b,0x0000027a,0x00000279, - 0x00000259,0x00000278,0x00000277,0x000001c5,0x00000276,0x00000275,0x00000259,0x000001b2, - 0x00000274,0x00000273,0x00000272,0x00000271,0x000001fc,0x000001ac,0x00000270,0x0000026f, - 0x0000026e,0x0000026d,0x00000190,0x0000026c,0x000001fb,0x0000026b,0x0000026a,0x00000269, - 0x000001fc,0x000001a6,0x000001f0,0x00000268,0x00000267,0x00000266,0x000001fc,0x0000016b, - 0x00000265,0x00000264,0x00000263,0x00000262,0x000001fc,0x0000019b,0x00000261,0x00000260, - 0x0000025f,0x0000025e,0x000001fc,0x00000195,0x0000025d,0x0000025c,0x0000025b,0x0000025a, - 0x00000259,0x0000018f,0x00000258,0x00000257,0x00000256,0x00000255,0x000001f8,0x0000018f, - 0x00000254,0x00000253,0x00000252,0x00000251,0x000001f4,0x00000189,0x00000250,0x0000024f, - 0x0000024e,0x0000024d,0x0000024c,0x00000189,0x0000024b,0x0000024a,0x00000249,0x00000236, - 0x00000184,0x00000179,0x00000248,0x00000247,0x00000246,0x0000023a,0x000001ec,0x00000179, - 0x00000245,0x00000244,0x00000243,0x00000242,0x0000017f,0x00000179,0x00000241,0x00000240, - 0x0000023f,0x0000023e,0x000001de,0x00000179,0x0000023d,0x0000023c,0x0000023b,0x0000023a, - 0x000001d9,0x000000a5,0x00000239,0x00000238,0x00000237,0x00000236,0x000001ce,0x000000a5, - 0x00000178,0x00000235,0x00000234,0x00000233,0x000001c3,0x00000179,0x00000173,0x00000232, - 0x00000231,0x00000230,0x000001b2,0x000000a5,0x0000022f,0x0000022e,0x0000022d,0x0000022c, - 0x0000016b,0x0004002b,0x00000006,0x000002bd,0x3ee66666,0x0004002b,0x00000006,0x000002bf, - 0x400e38e4,0x00040020,0x000002c5,0x00000006,0x00000006,0x0004003b,0x000002c5,0x000002c6, - 0x00000006,0x0004003b,0x000002c5,0x000002c9,0x00000006,0x0004003b,0x000002c5,0x000002d1, - 0x00000006,0x0004003b,0x000002c5,0x000002d4,0x00000006,0x0004002b,0x00000025,0x000002df, - 0x00000002,0x0004002b,0x00000025,0x000002e0,0x00000003,0x0004002b,0x00000025,0x000002e1, - 0x00000004,0x0004002b,0x00000025,0x000002e2,0x00000005,0x0004002b,0x00000006,0x00000384, - 0x3f000000,0x0004002b,0x00000031,0x0000038a,0x00000007,0x0004001c,0x0000038b,0x00000006, - 0x0000038a,0x00040020,0x0000038c,0x00000007,0x0000038b,0x0004002b,0x00000006,0x0000041d, - 0x42800000,0x0004002b,0x00000031,0x00000429,0x00000003,0x0005001e,0x000004d4,0x0000000e, - 0x0000000e,0x00000006,0x00040020,0x000004d5,0x00000009,0x000004d4,0x0004003b,0x000004d5, - 0x000004d6,0x00000009,0x00040020,0x000004d7,0x00000009,0x00000006,0x0004002b,0x00000006, - 0x000004e1,0x3fa00000,0x0004002b,0x00000006,0x000004e2,0x3fe00000,0x0004002b,0x00000006, - 0x000004ec,0x3ecccccd,0x0004002b,0x00000006,0x000004f0,0x3f99999a,0x0004002b,0x00000006, - 0x000004f5,0x3fcccccd,0x0004002b,0x00000006,0x000004f9,0x3fe66666,0x0004002b,0x00000006, - 0x000004ff,0x3dcccccd,0x0004002b,0x00000006,0x00000500,0x3e0f5c29,0x0004002b,0x00000006, - 0x00000504,0x3ea3d70a,0x0004002b,0x00000006,0x0000050c,0x3f19999a,0x00040017,0x00000512, - 0x00000006,0x00000002,0x00040020,0x00000513,0x00000007,0x00000512,0x00040020,0x00000515, - 0x00000009,0x0000000e,0x00040020,0x0000051e,0x00000001,0x00000512,0x0004003b,0x0000051e, - 0x0000051f,0x00000001,0x00040020,0x00000520,0x00000001,0x00000006,0x00090019,0x00000567, - 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, - 0x00000568,0x00000567,0x00040020,0x00000569,0x00000000,0x00000568,0x0004003b,0x00000569, - 0x0000056a,0x00000000,0x00040020,0x00000636,0x00000003,0x0000000e,0x0004003b,0x00000636, - 0x00000637,0x00000003,0x0004002b,0x00000006,0x00000641,0x41200000,0x0004002b,0x00000006, - 0x00000642,0x3f666666,0x0004002b,0x00000025,0x00000643,0x00000040,0x00050036,0x00000002, - 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d,0x000004d3, - 0x00000007,0x0004003b,0x0000000d,0x000004db,0x00000007,0x0004003b,0x0000000d,0x000004de, - 0x00000007,0x0004003b,0x0000000d,0x000004e4,0x00000007,0x0004003b,0x0000000d,0x000004e8, - 0x00000007,0x0004003b,0x0000000d,0x000004f4,0x00000007,0x0004003b,0x0000000d,0x00000508, - 0x00000007,0x0004003b,0x00000513,0x00000514,0x00000007,0x0004003b,0x00000513,0x00000519, - 0x00000007,0x0004003b,0x0000000d,0x0000051d,0x00000007,0x0004003b,0x0000000d,0x00000527, - 0x00000007,0x0004003b,0x0000000d,0x0000052e,0x00000007,0x0004003b,0x0000000d,0x00000531, - 0x00000007,0x0004003b,0x0000000d,0x00000534,0x00000007,0x0004003b,0x0000000d,0x00000538, - 0x00000007,0x0004003b,0x00000026,0x0000053c,0x00000007,0x0004003b,0x00000026,0x00000540, - 0x00000007,0x0004003b,0x00000026,0x00000544,0x00000007,0x0004003b,0x00000026,0x0000054c, - 0x00000007,0x0004003b,0x00000513,0x00000554,0x00000007,0x0004003b,0x0000003b,0x00000564, - 0x00000007,0x0004003b,0x00000008,0x0000056e,0x00000007,0x0004003b,0x0000001b,0x00000576, - 0x00000007,0x0004003b,0x0000000d,0x00000577,0x00000007,0x0004003b,0x0000000d,0x0000057a, - 0x00000007,0x0004003b,0x0000000d,0x0000057d,0x00000007,0x0004003b,0x0000000d,0x00000580, - 0x00000007,0x0004003b,0x0000000d,0x00000583,0x00000007,0x0004003b,0x0000000d,0x00000586, - 0x00000007,0x0004003b,0x0000000d,0x00000589,0x00000007,0x0004003b,0x0000000d,0x0000058c, - 0x00000007,0x0004003b,0x0000000d,0x0000058f,0x00000007,0x0004003b,0x0000001b,0x00000593, - 0x00000007,0x0004003b,0x0000000d,0x00000594,0x00000007,0x0004003b,0x0000000d,0x00000597, - 0x00000007,0x0004003b,0x0000000d,0x0000059a,0x00000007,0x0004003b,0x0000000d,0x0000059d, - 0x00000007,0x0004003b,0x0000000d,0x000005a0,0x00000007,0x0004003b,0x0000000d,0x000005a3, - 0x00000007,0x0004003b,0x0000000d,0x000005a6,0x00000007,0x0004003b,0x0000000d,0x000005a9, - 0x00000007,0x0004003b,0x0000000d,0x000005ac,0x00000007,0x0004003b,0x0000001b,0x000005b0, - 0x00000007,0x0004003b,0x0000000d,0x000005b1,0x00000007,0x0004003b,0x0000000d,0x000005b4, - 0x00000007,0x0004003b,0x0000000d,0x000005b7,0x00000007,0x0004003b,0x0000000d,0x000005ba, - 0x00000007,0x0004003b,0x0000000d,0x000005bd,0x00000007,0x0004003b,0x0000000d,0x000005c0, - 0x00000007,0x0004003b,0x0000000d,0x000005c3,0x00000007,0x0004003b,0x0000000d,0x000005c6, - 0x00000007,0x0004003b,0x0000000d,0x000005c9,0x00000007,0x0004003b,0x0000001b,0x000005cd, - 0x00000007,0x0004003b,0x0000000d,0x000005ce,0x00000007,0x0004003b,0x0000000d,0x000005d1, - 0x00000007,0x0004003b,0x0000000d,0x000005d4,0x00000007,0x0004003b,0x0000000d,0x000005d7, - 0x00000007,0x0004003b,0x0000000d,0x000005da,0x00000007,0x0004003b,0x0000000d,0x000005dd, - 0x00000007,0x0004003b,0x0000000d,0x000005e0,0x00000007,0x0004003b,0x0000000d,0x000005e3, - 0x00000007,0x0004003b,0x0000000d,0x000005e6,0x00000007,0x0004003b,0x0000001b,0x000005ea, - 0x00000007,0x0004003b,0x0000001b,0x000005eb,0x00000007,0x0004003b,0x0000001b,0x000005ed, - 0x00000007,0x0004003b,0x0000001b,0x000005ef,0x00000007,0x0004003b,0x0000001b,0x000005f1, - 0x00000007,0x0004003b,0x0000000d,0x000005f3,0x00000007,0x0004003b,0x0000000d,0x000005f5, - 0x00000007,0x0004003b,0x0000000d,0x000005f8,0x00000007,0x0004003b,0x0000000d,0x00000605, - 0x00000007,0x0004003b,0x0000003b,0x00000606,0x00000007,0x0004003b,0x00000026,0x00000608, - 0x00000007,0x0004003b,0x00000026,0x0000060a,0x00000007,0x0004003b,0x0000003b,0x0000060f, - 0x00000007,0x0004003b,0x0000000d,0x00000611,0x00000007,0x0004003b,0x0000000d,0x00000613, - 0x00000007,0x0004003b,0x00000026,0x00000615,0x00000007,0x0004003b,0x00000026,0x00000617, - 0x00000007,0x0004003b,0x0000001b,0x00000619,0x00000007,0x0004003b,0x0000001b,0x0000061e, - 0x00000007,0x0004003b,0x0000000d,0x00000622,0x00000007,0x0004003b,0x00000008,0x00000623, - 0x00000007,0x0004003b,0x0000000d,0x00000627,0x00000007,0x00050041,0x000004d7,0x000004d8, - 0x000004d6,0x000002df,0x0004003d,0x00000006,0x000004d9,0x000004d8,0x0008000c,0x00000006, - 0x000004da,0x00000001,0x0000002b,0x000004d9,0x000000a5,0x000000b2,0x0003003e,0x000004d3, - 0x000004da,0x0004003d,0x00000006,0x000004dc,0x000004d3,0x00050083,0x00000006,0x000004dd, - 0x000004dc,0x00000384,0x0003003e,0x000004db,0x000004dd,0x0004003d,0x00000006,0x000004df, - 0x000004db,0x000500be,0x000000a6,0x000004e0,0x000004df,0x000000a5,0x000600a9,0x00000006, - 0x000004e3,0x000004e0,0x000004e1,0x000004e2,0x0003003e,0x000004de,0x000004e3,0x0004003d, - 0x00000006,0x000004e5,0x000004db,0x000500be,0x000000a6,0x000004e6,0x000004e5,0x000000a5, - 0x000600a9,0x00000006,0x000004e7,0x000004e6,0x000004e1,0x000000b2,0x0003003e,0x000004e4, - 0x000004e7,0x0004003d,0x00000006,0x000004e9,0x000004db,0x000500be,0x000000a6,0x000004ea, - 0x000004e9,0x000000a5,0x000600a9,0x00000006,0x000004eb,0x000004ea,0x000004e1,0x000000b2, - 0x0003003e,0x000004e8,0x000004eb,0x0004003d,0x00000006,0x000004ed,0x000004db,0x0004003d, - 0x00000006,0x000004ee,0x000004e4,0x00050085,0x00000006,0x000004ef,0x000004ed,0x000004ee, - 0x00050085,0x00000006,0x000004f1,0x000004ef,0x000004f0,0x00050081,0x00000006,0x000004f2, - 0x000004ec,0x000004f1,0x0007000c,0x00000006,0x000004f3,0x00000001,0x00000028,0x000000a5, - 0x000004f2,0x0003003e,0x000002c9,0x000004f3,0x0004003d,0x00000006,0x000004f6,0x000004db, - 0x0004003d,0x00000006,0x000004f7,0x000004de,0x00050085,0x00000006,0x000004f8,0x000004f6, - 0x000004f7,0x00050085,0x00000006,0x000004fa,0x000004f8,0x000004f9,0x00050081,0x00000006, - 0x000004fb,0x000004f5,0x000004fa,0x0003003e,0x000004f4,0x000004fb,0x0004003d,0x00000006, - 0x000004fc,0x000004f4,0x0004003d,0x00000006,0x000004fd,0x000002c9,0x00050083,0x00000006, - 0x000004fe,0x000004fc,0x000004fd,0x0003003e,0x000002c6,0x000004fe,0x0004003d,0x00000006, - 0x00000501,0x000004db,0x0004003d,0x00000006,0x00000502,0x000004e8,0x00050085,0x00000006, - 0x00000503,0x00000501,0x00000502,0x00050085,0x00000006,0x00000505,0x00000503,0x00000504, - 0x00050081,0x00000006,0x00000506,0x00000500,0x00000505,0x0007000c,0x00000006,0x00000507, - 0x00000001,0x00000028,0x000004ff,0x00000506,0x0003003e,0x000002d4,0x00000507,0x0004003d, - 0x00000006,0x00000509,0x000004db,0x0004003d,0x00000006,0x0000050a,0x000004e8,0x00050085, - 0x00000006,0x0000050b,0x00000509,0x0000050a,0x00050085,0x00000006,0x0000050d,0x0000050b, - 0x0000050c,0x00050081,0x00000006,0x0000050e,0x00000384,0x0000050d,0x0003003e,0x00000508, - 0x0000050e,0x0004003d,0x00000006,0x0000050f,0x00000508,0x0004003d,0x00000006,0x00000510, - 0x000002d4,0x00050083,0x00000006,0x00000511,0x0000050f,0x00000510,0x0003003e,0x000002d1, - 0x00000511,0x00050041,0x00000515,0x00000516,0x000004d6,0x0000021f,0x0004003d,0x0000000e, - 0x00000517,0x00000516,0x0007004f,0x00000512,0x00000518,0x00000517,0x00000517,0x00000002, - 0x00000003,0x0003003e,0x00000514,0x00000518,0x00050041,0x00000515,0x0000051a,0x000004d6, - 0x0000021f,0x0004003d,0x0000000e,0x0000051b,0x0000051a,0x0007004f,0x00000512,0x0000051c, - 0x0000051b,0x0000051b,0x00000000,0x00000001,0x0003003e,0x00000519,0x0000051c,0x00050041, - 0x00000520,0x00000521,0x0000051f,0x0000004c,0x0004003d,0x00000006,0x00000522,0x00000521, - 0x00050041,0x0000000d,0x00000523,0x00000514,0x0000004c,0x0004003d,0x00000006,0x00000524, - 0x00000523,0x00050085,0x00000006,0x00000525,0x00000522,0x00000524,0x00050083,0x00000006, - 0x00000526,0x00000525,0x00000384,0x0003003e,0x0000051d,0x00000526,0x00050041,0x00000520, - 0x00000528,0x0000051f,0x00000051,0x0004003d,0x00000006,0x00000529,0x00000528,0x00050041, - 0x0000000d,0x0000052a,0x00000514,0x00000051,0x0004003d,0x00000006,0x0000052b,0x0000052a, - 0x00050085,0x00000006,0x0000052c,0x00000529,0x0000052b,0x00050083,0x00000006,0x0000052d, - 0x0000052c,0x00000384,0x0003003e,0x00000527,0x0000052d,0x0004003d,0x00000006,0x0000052f, - 0x0000051d,0x0006000c,0x00000006,0x00000530,0x00000001,0x00000008,0x0000052f,0x0003003e, - 0x0000052e,0x00000530,0x0004003d,0x00000006,0x00000532,0x00000527,0x0006000c,0x00000006, - 0x00000533,0x00000001,0x00000008,0x00000532,0x0003003e,0x00000531,0x00000533,0x0004003d, - 0x00000006,0x00000535,0x0000051d,0x0004003d,0x00000006,0x00000536,0x0000052e,0x00050083, - 0x00000006,0x00000537,0x00000535,0x00000536,0x0003003e,0x00000534,0x00000537,0x0004003d, - 0x00000006,0x00000539,0x00000527,0x0004003d,0x00000006,0x0000053a,0x00000531,0x00050083, - 0x00000006,0x0000053b,0x00000539,0x0000053a,0x0003003e,0x00000538,0x0000053b,0x0004003d, - 0x00000006,0x0000053d,0x00000534,0x00050085,0x00000006,0x0000053e,0x0000053d,0x0000041d, - 0x0004006e,0x00000025,0x0000053f,0x0000053e,0x0003003e,0x0000053c,0x0000053f,0x0004003d, - 0x00000006,0x00000541,0x00000538,0x00050085,0x00000006,0x00000542,0x00000541,0x0000041d, - 0x0004006e,0x00000025,0x00000543,0x00000542,0x0003003e,0x00000540,0x00000543,0x0003003e, - 0x00000544,0x0000015c,0x000200f9,0x00000545,0x000200f8,0x00000545,0x000400f6,0x00000547, - 0x00000548,0x00000000,0x000200f9,0x00000549,0x000200f8,0x00000549,0x0004003d,0x00000025, - 0x0000054a,0x00000544,0x000500b1,0x000000a6,0x0000054b,0x0000054a,0x00000167,0x000400fa, - 0x0000054b,0x00000546,0x00000547,0x000200f8,0x00000546,0x0003003e,0x0000054c,0x0000015c, - 0x000200f9,0x0000054d,0x000200f8,0x0000054d,0x000400f6,0x0000054f,0x00000550,0x00000000, - 0x000200f9,0x00000551,0x000200f8,0x00000551,0x0004003d,0x00000025,0x00000552,0x0000054c, - 0x000500b1,0x000000a6,0x00000553,0x00000552,0x00000167,0x000400fa,0x00000553,0x0000054e, - 0x0000054f,0x000200f8,0x0000054e,0x0004003d,0x00000006,0x00000555,0x0000052e,0x0004003d, - 0x00000025,0x00000556,0x0000054c,0x0004006f,0x00000006,0x00000557,0x00000556,0x00050081, - 0x00000006,0x00000558,0x00000555,0x00000557,0x00050083,0x00000006,0x00000559,0x00000558, - 0x00000152,0x0004003d,0x00000006,0x0000055a,0x00000531,0x0004003d,0x00000025,0x0000055b, - 0x00000544,0x0004006f,0x00000006,0x0000055c,0x0000055b,0x00050081,0x00000006,0x0000055d, - 0x0000055a,0x0000055c,0x00050083,0x00000006,0x0000055e,0x0000055d,0x00000152,0x00050050, - 0x00000512,0x0000055f,0x00000559,0x0000055e,0x00050050,0x00000512,0x00000560,0x00000384, - 0x00000384,0x00050081,0x00000512,0x00000561,0x0000055f,0x00000560,0x0004003d,0x00000512, - 0x00000562,0x00000519,0x00050085,0x00000512,0x00000563,0x00000561,0x00000562,0x0003003e, - 0x00000554,0x00000563,0x0004003d,0x00000025,0x00000565,0x00000544,0x0004003d,0x00000025, - 0x00000566,0x0000054c,0x0004003d,0x00000568,0x0000056b,0x0000056a,0x0004003d,0x00000512, - 0x0000056c,0x00000554,0x00070058,0x0000000e,0x0000056d,0x0000056b,0x0000056c,0x00000002, - 0x000000a5,0x0008004f,0x00000007,0x0000056f,0x0000056d,0x0000056d,0x00000000,0x00000001, - 0x00000002,0x0003003e,0x0000056e,0x0000056f,0x00050039,0x00000006,0x00000570,0x0000000b, - 0x0000056e,0x00060041,0x0000000d,0x00000571,0x00000564,0x00000565,0x00000566,0x0003003e, - 0x00000571,0x00000570,0x000200f9,0x00000550,0x000200f8,0x00000550,0x0004003d,0x00000025, - 0x00000572,0x0000054c,0x00050080,0x00000025,0x00000573,0x00000572,0x0000021f,0x0003003e, - 0x0000054c,0x00000573,0x000200f9,0x0000054d,0x000200f8,0x0000054f,0x000200f9,0x00000548, - 0x000200f8,0x00000548,0x0004003d,0x00000025,0x00000574,0x00000544,0x00050080,0x00000025, - 0x00000575,0x00000574,0x0000021f,0x0003003e,0x00000544,0x00000575,0x000200f9,0x00000545, - 0x000200f8,0x00000547,0x00060041,0x0000000d,0x00000578,0x00000564,0x0000021f,0x0000021f, - 0x0004003d,0x00000006,0x00000579,0x00000578,0x0003003e,0x00000577,0x00000579,0x00060041, - 0x0000000d,0x0000057b,0x00000564,0x0000021f,0x000002df,0x0004003d,0x00000006,0x0000057c, - 0x0000057b,0x0003003e,0x0000057a,0x0000057c,0x00060041,0x0000000d,0x0000057e,0x00000564, - 0x0000021f,0x000002e0,0x0004003d,0x00000006,0x0000057f,0x0000057e,0x0003003e,0x0000057d, - 0x0000057f,0x00060041,0x0000000d,0x00000581,0x00000564,0x000002df,0x0000021f,0x0004003d, - 0x00000006,0x00000582,0x00000581,0x0003003e,0x00000580,0x00000582,0x00060041,0x0000000d, - 0x00000584,0x00000564,0x000002df,0x000002df,0x0004003d,0x00000006,0x00000585,0x00000584, - 0x0003003e,0x00000583,0x00000585,0x00060041,0x0000000d,0x00000587,0x00000564,0x000002df, - 0x000002e0,0x0004003d,0x00000006,0x00000588,0x00000587,0x0003003e,0x00000586,0x00000588, - 0x00060041,0x0000000d,0x0000058a,0x00000564,0x000002e0,0x0000021f,0x0004003d,0x00000006, - 0x0000058b,0x0000058a,0x0003003e,0x00000589,0x0000058b,0x00060041,0x0000000d,0x0000058d, - 0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006,0x0000058e,0x0000058d,0x0003003e, - 0x0000058c,0x0000058e,0x00060041,0x0000000d,0x00000590,0x00000564,0x000002e0,0x000002e0, - 0x0004003d,0x00000006,0x00000591,0x00000590,0x0003003e,0x0000058f,0x00000591,0x000d0039, - 0x0000000e,0x00000592,0x00000019,0x00000577,0x0000057a,0x0000057d,0x00000580,0x00000583, - 0x00000586,0x00000589,0x0000058c,0x0000058f,0x0003003e,0x00000576,0x00000592,0x00060041, - 0x0000000d,0x00000595,0x00000564,0x0000021f,0x000002df,0x0004003d,0x00000006,0x00000596, - 0x00000595,0x0003003e,0x00000594,0x00000596,0x00060041,0x0000000d,0x00000598,0x00000564, - 0x0000021f,0x000002e0,0x0004003d,0x00000006,0x00000599,0x00000598,0x0003003e,0x00000597, - 0x00000599,0x00060041,0x0000000d,0x0000059b,0x00000564,0x0000021f,0x000002e1,0x0004003d, - 0x00000006,0x0000059c,0x0000059b,0x0003003e,0x0000059a,0x0000059c,0x00060041,0x0000000d, - 0x0000059e,0x00000564,0x000002df,0x000002df,0x0004003d,0x00000006,0x0000059f,0x0000059e, - 0x0003003e,0x0000059d,0x0000059f,0x00060041,0x0000000d,0x000005a1,0x00000564,0x000002df, - 0x000002e0,0x0004003d,0x00000006,0x000005a2,0x000005a1,0x0003003e,0x000005a0,0x000005a2, - 0x00060041,0x0000000d,0x000005a4,0x00000564,0x000002df,0x000002e1,0x0004003d,0x00000006, - 0x000005a5,0x000005a4,0x0003003e,0x000005a3,0x000005a5,0x00060041,0x0000000d,0x000005a7, - 0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006,0x000005a8,0x000005a7,0x0003003e, - 0x000005a6,0x000005a8,0x00060041,0x0000000d,0x000005aa,0x00000564,0x000002e0,0x000002e0, - 0x0004003d,0x00000006,0x000005ab,0x000005aa,0x0003003e,0x000005a9,0x000005ab,0x00060041, - 0x0000000d,0x000005ad,0x00000564,0x000002e0,0x000002e1,0x0004003d,0x00000006,0x000005ae, - 0x000005ad,0x0003003e,0x000005ac,0x000005ae,0x000d0039,0x0000000e,0x000005af,0x00000019, - 0x00000594,0x00000597,0x0000059a,0x0000059d,0x000005a0,0x000005a3,0x000005a6,0x000005a9, - 0x000005ac,0x0003003e,0x00000593,0x000005af,0x00060041,0x0000000d,0x000005b2,0x00000564, - 0x000002df,0x0000021f,0x0004003d,0x00000006,0x000005b3,0x000005b2,0x0003003e,0x000005b1, - 0x000005b3,0x00060041,0x0000000d,0x000005b5,0x00000564,0x000002df,0x000002df,0x0004003d, - 0x00000006,0x000005b6,0x000005b5,0x0003003e,0x000005b4,0x000005b6,0x00060041,0x0000000d, - 0x000005b8,0x00000564,0x000002df,0x000002e0,0x0004003d,0x00000006,0x000005b9,0x000005b8, - 0x0003003e,0x000005b7,0x000005b9,0x00060041,0x0000000d,0x000005bb,0x00000564,0x000002e0, - 0x0000021f,0x0004003d,0x00000006,0x000005bc,0x000005bb,0x0003003e,0x000005ba,0x000005bc, - 0x00060041,0x0000000d,0x000005be,0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006, - 0x000005bf,0x000005be,0x0003003e,0x000005bd,0x000005bf,0x00060041,0x0000000d,0x000005c1, - 0x00000564,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x000005c2,0x000005c1,0x0003003e, - 0x000005c0,0x000005c2,0x00060041,0x0000000d,0x000005c4,0x00000564,0x000002e1,0x0000021f, - 0x0004003d,0x00000006,0x000005c5,0x000005c4,0x0003003e,0x000005c3,0x000005c5,0x00060041, - 0x0000000d,0x000005c7,0x00000564,0x000002e1,0x000002df,0x0004003d,0x00000006,0x000005c8, - 0x000005c7,0x0003003e,0x000005c6,0x000005c8,0x00060041,0x0000000d,0x000005ca,0x00000564, - 0x000002e1,0x000002e0,0x0004003d,0x00000006,0x000005cb,0x000005ca,0x0003003e,0x000005c9, - 0x000005cb,0x000d0039,0x0000000e,0x000005cc,0x00000019,0x000005b1,0x000005b4,0x000005b7, - 0x000005ba,0x000005bd,0x000005c0,0x000005c3,0x000005c6,0x000005c9,0x0003003e,0x000005b0, - 0x000005cc,0x00060041,0x0000000d,0x000005cf,0x00000564,0x000002df,0x000002df,0x0004003d, - 0x00000006,0x000005d0,0x000005cf,0x0003003e,0x000005ce,0x000005d0,0x00060041,0x0000000d, - 0x000005d2,0x00000564,0x000002df,0x000002e0,0x0004003d,0x00000006,0x000005d3,0x000005d2, - 0x0003003e,0x000005d1,0x000005d3,0x00060041,0x0000000d,0x000005d5,0x00000564,0x000002df, - 0x000002e1,0x0004003d,0x00000006,0x000005d6,0x000005d5,0x0003003e,0x000005d4,0x000005d6, - 0x00060041,0x0000000d,0x000005d8,0x00000564,0x000002e0,0x000002df,0x0004003d,0x00000006, - 0x000005d9,0x000005d8,0x0003003e,0x000005d7,0x000005d9,0x00060041,0x0000000d,0x000005db, - 0x00000564,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x000005dc,0x000005db,0x0003003e, - 0x000005da,0x000005dc,0x00060041,0x0000000d,0x000005de,0x00000564,0x000002e0,0x000002e1, - 0x0004003d,0x00000006,0x000005df,0x000005de,0x0003003e,0x000005dd,0x000005df,0x00060041, - 0x0000000d,0x000005e1,0x00000564,0x000002e1,0x000002df,0x0004003d,0x00000006,0x000005e2, - 0x000005e1,0x0003003e,0x000005e0,0x000005e2,0x00060041,0x0000000d,0x000005e4,0x00000564, - 0x000002e1,0x000002e0,0x0004003d,0x00000006,0x000005e5,0x000005e4,0x0003003e,0x000005e3, - 0x000005e5,0x00060041,0x0000000d,0x000005e7,0x00000564,0x000002e1,0x000002e1,0x0004003d, - 0x00000006,0x000005e8,0x000005e7,0x0003003e,0x000005e6,0x000005e8,0x000d0039,0x0000000e, - 0x000005e9,0x00000019,0x000005ce,0x000005d1,0x000005d4,0x000005d7,0x000005da,0x000005dd, - 0x000005e0,0x000005e3,0x000005e6,0x0003003e,0x000005cd,0x000005e9,0x0004003d,0x0000000e, - 0x000005ec,0x00000576,0x0003003e,0x000005eb,0x000005ec,0x0004003d,0x0000000e,0x000005ee, - 0x00000593,0x0003003e,0x000005ed,0x000005ee,0x0004003d,0x0000000e,0x000005f0,0x000005b0, - 0x0003003e,0x000005ef,0x000005f0,0x0004003d,0x0000000e,0x000005f2,0x000005cd,0x0003003e, - 0x000005f1,0x000005f2,0x0004003d,0x00000006,0x000005f4,0x00000534,0x0003003e,0x000005f3, - 0x000005f4,0x0004003d,0x00000006,0x000005f6,0x00000538,0x0003003e,0x000005f5,0x000005f6, - 0x000a0039,0x0000000e,0x000005f7,0x00000023,0x000005eb,0x000005ed,0x000005ef,0x000005f1, - 0x000005f3,0x000005f5,0x0003003e,0x000005ea,0x000005f7,0x00050041,0x0000000d,0x000005f9, - 0x000005ea,0x0000004c,0x0004003d,0x00000006,0x000005fa,0x000005f9,0x00050083,0x00000006, - 0x000005fb,0x000000b2,0x000005fa,0x00050041,0x0000000d,0x000005fc,0x000005ea,0x00000051, - 0x0004003d,0x00000006,0x000005fd,0x000005fc,0x00050083,0x00000006,0x000005fe,0x000005fb, - 0x000005fd,0x00050041,0x0000000d,0x000005ff,0x000005ea,0x00000057,0x0004003d,0x00000006, - 0x00000600,0x000005ff,0x00050083,0x00000006,0x00000601,0x000005fe,0x00000600,0x00050041, - 0x0000000d,0x00000602,0x000005ea,0x00000429,0x0004003d,0x00000006,0x00000603,0x00000602, - 0x00050083,0x00000006,0x00000604,0x00000601,0x00000603,0x0003003e,0x000005f8,0x00000604, - 0x0004003d,0x0000003a,0x00000607,0x00000564,0x0003003e,0x00000606,0x00000607,0x0004003d, - 0x00000025,0x00000609,0x0000053c,0x0003003e,0x00000608,0x00000609,0x0004003d,0x00000025, - 0x0000060b,0x00000540,0x0003003e,0x0000060a,0x0000060b,0x00070039,0x00000006,0x0000060c, - 0x00000040,0x00000606,0x00000608,0x0000060a,0x0004003d,0x00000006,0x0000060d,0x000005f8, - 0x00050085,0x00000006,0x0000060e,0x0000060c,0x0000060d,0x0003003e,0x00000605,0x0000060e, - 0x0004003d,0x0000003a,0x00000610,0x00000564,0x0003003e,0x0000060f,0x00000610,0x0004003d, - 0x00000006,0x00000612,0x00000534,0x0003003e,0x00000611,0x00000612,0x0004003d,0x00000006, - 0x00000614,0x00000538,0x0003003e,0x00000613,0x00000614,0x0004003d,0x00000025,0x00000616, - 0x0000053c,0x0003003e,0x00000615,0x00000616,0x0004003d,0x00000025,0x00000618,0x00000540, - 0x0003003e,0x00000617,0x00000618,0x0004003d,0x0000000e,0x0000061a,0x000005ea,0x0003003e, - 0x00000619,0x0000061a,0x000a0039,0x00000006,0x0000061b,0x00000049,0x0000060f,0x00000611, - 0x00000613,0x00000615,0x00000617,0x00000619,0x0004003d,0x00000006,0x0000061c,0x00000605, - 0x00050081,0x00000006,0x0000061d,0x0000061c,0x0000061b,0x0003003e,0x00000605,0x0000061d, - 0x0004003d,0x00000568,0x0000061f,0x0000056a,0x0004003d,0x00000512,0x00000620,0x0000051f, - 0x00050057,0x0000000e,0x00000621,0x0000061f,0x00000620,0x0003003e,0x0000061e,0x00000621, - 0x0004003d,0x0000000e,0x00000624,0x0000061e,0x0008004f,0x00000007,0x00000625,0x00000624, - 0x00000624,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000623,0x00000625,0x00050039, - 0x00000006,0x00000626,0x0000000b,0x00000623,0x0003003e,0x00000622,0x00000626,0x0004003d, - 0x00000006,0x00000628,0x00000605,0x0004003d,0x00000006,0x00000629,0x00000622,0x00050083, - 0x00000006,0x0000062a,0x00000628,0x00000629,0x0003003e,0x00000627,0x0000062a,0x0004003d, - 0x00000006,0x0000062b,0x00000627,0x00060050,0x00000007,0x0000062c,0x0000062b,0x0000062b, - 0x0000062b,0x0004003d,0x0000000e,0x0000062d,0x0000061e,0x0008004f,0x00000007,0x0000062e, - 0x0000062d,0x0000062d,0x00000000,0x00000001,0x00000002,0x00050081,0x00000007,0x0000062f, - 0x0000062e,0x0000062c,0x00050041,0x0000000d,0x00000630,0x0000061e,0x0000004c,0x00050051, - 0x00000006,0x00000631,0x0000062f,0x00000000,0x0003003e,0x00000630,0x00000631,0x00050041, - 0x0000000d,0x00000632,0x0000061e,0x00000051,0x00050051,0x00000006,0x00000633,0x0000062f, - 0x00000001,0x0003003e,0x00000632,0x00000633,0x00050041,0x0000000d,0x00000634,0x0000061e, - 0x00000057,0x00050051,0x00000006,0x00000635,0x0000062f,0x00000002,0x0003003e,0x00000634, - 0x00000635,0x0004003d,0x0000000e,0x00000638,0x0000061e,0x0008004f,0x00000007,0x00000639, - 0x00000638,0x00000638,0x00000000,0x00000001,0x00000002,0x00060050,0x00000007,0x0000063a, - 0x000000a5,0x000000a5,0x000000a5,0x00060050,0x00000007,0x0000063b,0x000000b2,0x000000b2, - 0x000000b2,0x0008000c,0x00000007,0x0000063c,0x00000001,0x0000002b,0x00000639,0x0000063a, - 0x0000063b,0x00050051,0x00000006,0x0000063d,0x0000063c,0x00000000,0x00050051,0x00000006, - 0x0000063e,0x0000063c,0x00000001,0x00050051,0x00000006,0x0000063f,0x0000063c,0x00000002, - 0x00070050,0x0000000e,0x00000640,0x0000063d,0x0000063e,0x0000063f,0x000000b2,0x0003003e, - 0x00000637,0x00000640,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000b,0x00000000, - 0x00000009,0x00030037,0x00000008,0x0000000a,0x000200f8,0x0000000c,0x00050041,0x0000000d, - 0x0000004d,0x0000000a,0x0000004c,0x0004003d,0x00000006,0x0000004e,0x0000004d,0x00050085, - 0x00000006,0x0000004f,0x0000004b,0x0000004e,0x00050041,0x0000000d,0x00000052,0x0000000a, - 0x00000051,0x0004003d,0x00000006,0x00000053,0x00000052,0x00050085,0x00000006,0x00000054, - 0x00000050,0x00000053,0x00050081,0x00000006,0x00000055,0x0000004f,0x00000054,0x00050041, - 0x0000000d,0x00000058,0x0000000a,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000058, - 0x00050085,0x00000006,0x0000005a,0x00000056,0x00000059,0x00050081,0x00000006,0x0000005b, - 0x00000055,0x0000005a,0x000200fe,0x0000005b,0x00010038,0x00050036,0x0000000e,0x00000019, - 0x00000000,0x0000000f,0x00030037,0x0000000d,0x00000010,0x00030037,0x0000000d,0x00000011, - 0x00030037,0x0000000d,0x00000012,0x00030037,0x0000000d,0x00000013,0x00030037,0x0000000d, - 0x00000014,0x00030037,0x0000000d,0x00000015,0x00030037,0x0000000d,0x00000016,0x00030037, - 0x0000000d,0x00000017,0x00030037,0x0000000d,0x00000018,0x000200f8,0x0000001a,0x0004003b, - 0x0000000d,0x0000005e,0x00000007,0x0004003b,0x0000000d,0x0000006b,0x00000007,0x0004003b, - 0x0000000d,0x00000078,0x00000007,0x0004003b,0x0000000d,0x00000085,0x00000007,0x0004003b, - 0x0000000d,0x00000092,0x00000007,0x0004003b,0x0000000d,0x00000096,0x00000007,0x0004003b, - 0x0000000d,0x0000009a,0x00000007,0x0004003b,0x0000000d,0x0000009e,0x00000007,0x0004003b, - 0x0000000d,0x000000ac,0x00000007,0x0004003b,0x0000000d,0x000000b4,0x00000007,0x0004003b, - 0x000000b7,0x000000b8,0x00000007,0x0004003b,0x000000b7,0x000000c6,0x00000007,0x0004003b, - 0x000000b7,0x000000d2,0x00000007,0x0004003b,0x000000b7,0x000000d6,0x00000007,0x0004003b, - 0x0000000d,0x000000da,0x00000007,0x0004003b,0x0000000d,0x000000e0,0x00000007,0x0004003b, - 0x0000000d,0x000000e6,0x00000007,0x0004003b,0x0000000d,0x000000ec,0x00000007,0x0004003b, - 0x0000000d,0x000000f3,0x00000007,0x0004003b,0x0000000d,0x000000f9,0x00000007,0x0004003d, - 0x00000006,0x0000005f,0x00000010,0x0004003d,0x00000006,0x00000060,0x00000011,0x00050081, - 0x00000006,0x00000061,0x0000005f,0x00000060,0x0004003d,0x00000006,0x00000062,0x00000012, - 0x00050081,0x00000006,0x00000063,0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064, - 0x00000016,0x00050083,0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006, - 0x00000066,0x00000017,0x00050083,0x00000006,0x00000067,0x00000065,0x00000066,0x0004003d, - 0x00000006,0x00000068,0x00000018,0x00050083,0x00000006,0x00000069,0x00000067,0x00000068, - 0x0006000c,0x00000006,0x0000006a,0x00000001,0x00000004,0x00000069,0x0003003e,0x0000005e, - 0x0000006a,0x0004003d,0x00000006,0x0000006c,0x00000013,0x0004003d,0x00000006,0x0000006d, - 0x00000010,0x00050081,0x00000006,0x0000006e,0x0000006c,0x0000006d,0x0004003d,0x00000006, - 0x0000006f,0x00000011,0x00050081,0x00000006,0x00000070,0x0000006e,0x0000006f,0x0004003d, - 0x00000006,0x00000071,0x00000017,0x00050083,0x00000006,0x00000072,0x00000070,0x00000071, - 0x0004003d,0x00000006,0x00000073,0x00000018,0x00050083,0x00000006,0x00000074,0x00000072, - 0x00000073,0x0004003d,0x00000006,0x00000075,0x00000015,0x00050083,0x00000006,0x00000076, - 0x00000074,0x00000075,0x0006000c,0x00000006,0x00000077,0x00000001,0x00000004,0x00000076, - 0x0003003e,0x0000006b,0x00000077,0x0004003d,0x00000006,0x00000079,0x00000010,0x0004003d, - 0x00000006,0x0000007a,0x00000013,0x00050081,0x00000006,0x0000007b,0x00000079,0x0000007a, - 0x0004003d,0x00000006,0x0000007c,0x00000016,0x00050081,0x00000006,0x0000007d,0x0000007b, - 0x0000007c,0x0004003d,0x00000006,0x0000007e,0x00000012,0x00050083,0x00000006,0x0000007f, - 0x0000007d,0x0000007e,0x0004003d,0x00000006,0x00000080,0x00000015,0x00050083,0x00000006, - 0x00000081,0x0000007f,0x00000080,0x0004003d,0x00000006,0x00000082,0x00000018,0x00050083, - 0x00000006,0x00000083,0x00000081,0x00000082,0x0006000c,0x00000006,0x00000084,0x00000001, - 0x00000004,0x00000083,0x0003003e,0x00000078,0x00000084,0x0004003d,0x00000006,0x00000086, - 0x00000013,0x0004003d,0x00000006,0x00000087,0x00000016,0x00050081,0x00000006,0x00000088, - 0x00000086,0x00000087,0x0004003d,0x00000006,0x00000089,0x00000017,0x00050081,0x00000006, - 0x0000008a,0x00000088,0x00000089,0x0004003d,0x00000006,0x0000008b,0x00000011,0x00050083, - 0x00000006,0x0000008c,0x0000008a,0x0000008b,0x0004003d,0x00000006,0x0000008d,0x00000012, - 0x00050083,0x00000006,0x0000008e,0x0000008c,0x0000008d,0x0004003d,0x00000006,0x0000008f, - 0x00000015,0x00050083,0x00000006,0x00000090,0x0000008e,0x0000008f,0x0006000c,0x00000006, - 0x00000091,0x00000001,0x00000004,0x00000090,0x0003003e,0x00000085,0x00000091,0x0004003d, - 0x00000006,0x00000093,0x0000005e,0x0004003d,0x00000006,0x00000094,0x00000078,0x0007000c, - 0x00000006,0x00000095,0x00000001,0x00000028,0x00000093,0x00000094,0x0003003e,0x00000092, - 0x00000095,0x0004003d,0x00000006,0x00000097,0x0000005e,0x0004003d,0x00000006,0x00000098, - 0x00000078,0x0007000c,0x00000006,0x00000099,0x00000001,0x00000025,0x00000097,0x00000098, - 0x0003003e,0x00000096,0x00000099,0x0004003d,0x00000006,0x0000009b,0x0000006b,0x0004003d, - 0x00000006,0x0000009c,0x00000085,0x0007000c,0x00000006,0x0000009d,0x00000001,0x00000028, - 0x0000009b,0x0000009c,0x0003003e,0x0000009a,0x0000009d,0x0004003d,0x00000006,0x0000009f, - 0x0000006b,0x0004003d,0x00000006,0x000000a0,0x00000085,0x0007000c,0x00000006,0x000000a1, - 0x00000001,0x00000025,0x0000009f,0x000000a0,0x0003003e,0x0000009e,0x000000a1,0x0004003d, - 0x00000006,0x000000a2,0x00000092,0x0004003d,0x00000006,0x000000a3,0x0000009a,0x00050081, - 0x00000006,0x000000a4,0x000000a2,0x000000a3,0x000500b4,0x000000a6,0x000000a7,0x000000a4, - 0x000000a5,0x000300f7,0x000000a9,0x00000000,0x000400fa,0x000000a7,0x000000a8,0x000000a9, - 0x000200f8,0x000000a8,0x000200fe,0x000000aa,0x000200f8,0x000000a9,0x0004003d,0x00000006, - 0x000000ad,0x00000092,0x0004003d,0x00000006,0x000000ae,0x00000092,0x0004003d,0x00000006, - 0x000000af,0x0000009a,0x00050081,0x00000006,0x000000b0,0x000000ae,0x000000af,0x00050088, - 0x00000006,0x000000b1,0x000000ad,0x000000b0,0x0007000c,0x00000006,0x000000b3,0x00000001, - 0x00000025,0x000000b1,0x000000b2,0x0003003e,0x000000ac,0x000000b3,0x0004003d,0x00000006, - 0x000000b5,0x000000ac,0x00050083,0x00000006,0x000000b6,0x000000b2,0x000000b5,0x0003003e, - 0x000000b4,0x000000b6,0x0004003d,0x00000006,0x000000b9,0x00000092,0x0004003d,0x00000006, - 0x000000ba,0x00000096,0x00050085,0x00000006,0x000000bc,0x000000ba,0x000000bb,0x000500ba, - 0x000000a6,0x000000bd,0x000000b9,0x000000bc,0x0004003d,0x00000006,0x000000be,0x00000092, - 0x000500ba,0x000000a6,0x000000c0,0x000000be,0x000000bf,0x000500a7,0x000000a6,0x000000c1, - 0x000000bd,0x000000c0,0x0004003d,0x00000006,0x000000c2,0x00000092,0x0004003d,0x00000006, - 0x000000c3,0x0000009e,0x000500ba,0x000000a6,0x000000c4,0x000000c2,0x000000c3,0x000500a7, - 0x000000a6,0x000000c5,0x000000c1,0x000000c4,0x0003003e,0x000000b8,0x000000c5,0x0004003d, - 0x00000006,0x000000c7,0x0000009a,0x0004003d,0x00000006,0x000000c8,0x0000009e,0x00050085, - 0x00000006,0x000000c9,0x000000c8,0x000000bb,0x000500ba,0x000000a6,0x000000ca,0x000000c7, - 0x000000c9,0x0004003d,0x00000006,0x000000cb,0x0000009a,0x000500ba,0x000000a6,0x000000cc, - 0x000000cb,0x000000bf,0x000500a7,0x000000a6,0x000000cd,0x000000ca,0x000000cc,0x0004003d, - 0x00000006,0x000000ce,0x0000009a,0x0004003d,0x00000006,0x000000cf,0x00000096,0x000500ba, - 0x000000a6,0x000000d0,0x000000ce,0x000000cf,0x000500a7,0x000000a6,0x000000d1,0x000000cd, - 0x000000d0,0x0003003e,0x000000c6,0x000000d1,0x0004003d,0x00000006,0x000000d3,0x00000092, - 0x0004003d,0x00000006,0x000000d4,0x0000005e,0x000500b4,0x000000a6,0x000000d5,0x000000d3, - 0x000000d4,0x0003003e,0x000000d2,0x000000d5,0x0004003d,0x00000006,0x000000d7,0x0000009a, - 0x0004003d,0x00000006,0x000000d8,0x0000006b,0x000500b4,0x000000a6,0x000000d9,0x000000d7, - 0x000000d8,0x0003003e,0x000000d6,0x000000d9,0x0004003d,0x000000a6,0x000000db,0x000000b8, - 0x0004003d,0x000000a6,0x000000dc,0x000000c6,0x000500a7,0x000000a6,0x000000dd,0x000000db, - 0x000000dc,0x0004003d,0x00000006,0x000000de,0x000000ac,0x000600a9,0x00000006,0x000000df, - 0x000000dd,0x000000de,0x000000b2,0x0003003e,0x000000da,0x000000df,0x0004003d,0x000000a6, - 0x000000e1,0x000000b8,0x0004003d,0x000000a6,0x000000e2,0x000000c6,0x000500a7,0x000000a6, - 0x000000e3,0x000000e1,0x000000e2,0x0004003d,0x00000006,0x000000e4,0x000000b4,0x000600a9, - 0x00000006,0x000000e5,0x000000e3,0x000000e4,0x000000b2,0x0003003e,0x000000e0,0x000000e5, - 0x0004003d,0x000000a6,0x000000e7,0x000000b8,0x0004003d,0x000000a6,0x000000e8,0x000000d2, - 0x000500a7,0x000000a6,0x000000e9,0x000000e7,0x000000e8,0x0004003d,0x00000006,0x000000ea, - 0x000000da,0x000600a9,0x00000006,0x000000eb,0x000000e9,0x000000ea,0x000000a5,0x0003003e, - 0x000000e6,0x000000eb,0x0004003d,0x000000a6,0x000000ed,0x000000b8,0x0004003d,0x000000a6, - 0x000000ee,0x000000d2,0x000400a8,0x000000a6,0x000000ef,0x000000ee,0x000500a7,0x000000a6, - 0x000000f0,0x000000ed,0x000000ef,0x0004003d,0x00000006,0x000000f1,0x000000da,0x000600a9, - 0x00000006,0x000000f2,0x000000f0,0x000000f1,0x000000a5,0x0003003e,0x000000ec,0x000000f2, - 0x0004003d,0x000000a6,0x000000f4,0x000000c6,0x0004003d,0x000000a6,0x000000f5,0x000000d6, - 0x000500a7,0x000000a6,0x000000f6,0x000000f4,0x000000f5,0x0004003d,0x00000006,0x000000f7, - 0x000000e0,0x000600a9,0x00000006,0x000000f8,0x000000f6,0x000000f7,0x000000a5,0x0003003e, - 0x000000f3,0x000000f8,0x0004003d,0x000000a6,0x000000fa,0x000000c6,0x0004003d,0x000000a6, - 0x000000fb,0x000000d6,0x000400a8,0x000000a6,0x000000fc,0x000000fb,0x000500a7,0x000000a6, - 0x000000fd,0x000000fa,0x000000fc,0x0004003d,0x00000006,0x000000fe,0x000000e0,0x000600a9, - 0x00000006,0x000000ff,0x000000fd,0x000000fe,0x000000a5,0x0003003e,0x000000f9,0x000000ff, - 0x0004003d,0x00000006,0x00000100,0x000000e6,0x0004003d,0x00000006,0x00000101,0x000000ec, - 0x0004003d,0x00000006,0x00000102,0x000000f3,0x0004003d,0x00000006,0x00000103,0x000000f9, - 0x00070050,0x0000000e,0x00000104,0x00000100,0x00000101,0x00000102,0x00000103,0x000200fe, - 0x00000104,0x00010038,0x00050036,0x0000000e,0x00000023,0x00000000,0x0000001c,0x00030037, - 0x0000001b,0x0000001d,0x00030037,0x0000001b,0x0000001e,0x00030037,0x0000001b,0x0000001f, - 0x00030037,0x0000001b,0x00000020,0x00030037,0x0000000d,0x00000021,0x00030037,0x0000000d, - 0x00000022,0x000200f8,0x00000024,0x0004003b,0x0000001b,0x00000107,0x00000007,0x0004003b, - 0x0000001b,0x0000010d,0x00000007,0x0004003d,0x0000000e,0x00000108,0x0000001d,0x0004003d, - 0x0000000e,0x00000109,0x0000001e,0x0004003d,0x00000006,0x0000010a,0x00000021,0x00070050, - 0x0000000e,0x0000010b,0x0000010a,0x0000010a,0x0000010a,0x0000010a,0x0008000c,0x0000000e, - 0x0000010c,0x00000001,0x0000002e,0x00000108,0x00000109,0x0000010b,0x0003003e,0x00000107, - 0x0000010c,0x0004003d,0x0000000e,0x0000010e,0x0000001f,0x0004003d,0x0000000e,0x0000010f, - 0x00000020,0x0004003d,0x00000006,0x00000110,0x00000021,0x00070050,0x0000000e,0x00000111, - 0x00000110,0x00000110,0x00000110,0x00000110,0x0008000c,0x0000000e,0x00000112,0x00000001, - 0x0000002e,0x0000010e,0x0000010f,0x00000111,0x0003003e,0x0000010d,0x00000112,0x0004003d, - 0x0000000e,0x00000113,0x00000107,0x0004003d,0x0000000e,0x00000114,0x0000010d,0x0004003d, - 0x00000006,0x00000115,0x00000022,0x00070050,0x0000000e,0x00000116,0x00000115,0x00000115, - 0x00000115,0x00000115,0x0008000c,0x0000000e,0x00000117,0x00000001,0x0000002e,0x00000113, - 0x00000114,0x00000116,0x000200fe,0x00000117,0x00010038,0x00050036,0x00000006,0x0000002f, - 0x00000000,0x00000027,0x00030037,0x0000000d,0x00000028,0x00030037,0x0000000d,0x00000029, - 0x00030037,0x0000000d,0x0000002a,0x00030037,0x0000000d,0x0000002b,0x00030037,0x0000000d, - 0x0000002c,0x00030037,0x0000000d,0x0000002d,0x00030037,0x00000026,0x0000002e,0x000200f8, - 0x00000030,0x0004003b,0x000000b7,0x0000011a,0x00000007,0x0004003b,0x0000000d,0x0000011e, - 0x00000007,0x0004003b,0x0000000d,0x00000123,0x00000007,0x0004003b,0x0000000d,0x00000129, - 0x00000007,0x0004003b,0x0000000d,0x00000133,0x00000007,0x0004003b,0x0000000d,0x00000139, - 0x00000007,0x0004003b,0x0000000d,0x0000013f,0x00000007,0x0004003b,0x0000000d,0x00000143, - 0x00000007,0x0004003b,0x0000000d,0x00000147,0x00000007,0x0004003d,0x00000025,0x0000011b, - 0x0000002e,0x000500b3,0x000000a6,0x0000011d,0x0000011b,0x0000011c,0x0003003e,0x0000011a, - 0x0000011d,0x0004003d,0x000000a6,0x0000011f,0x0000011a,0x0004003d,0x00000006,0x00000120, - 0x00000028,0x0004003d,0x00000006,0x00000121,0x0000002b,0x000600a9,0x00000006,0x00000122, - 0x0000011f,0x00000120,0x00000121,0x0003003e,0x0000011e,0x00000122,0x0004003d,0x00000006, - 0x00000124,0x00000029,0x0004003d,0x00000006,0x00000125,0x0000002a,0x0007000c,0x00000006, - 0x00000126,0x00000001,0x00000025,0x00000124,0x00000125,0x0004003d,0x00000006,0x00000127, - 0x0000011e,0x0007000c,0x00000006,0x00000128,0x00000001,0x00000025,0x00000126,0x00000127, - 0x0003003e,0x00000123,0x00000128,0x0004003d,0x00000006,0x0000012a,0x00000029,0x0004003d, - 0x00000006,0x0000012b,0x0000002a,0x0007000c,0x00000006,0x0000012c,0x00000001,0x00000028, - 0x0000012a,0x0000012b,0x0004003d,0x00000006,0x0000012d,0x0000011e,0x0007000c,0x00000006, - 0x0000012e,0x00000001,0x00000028,0x0000012c,0x0000012d,0x0003003e,0x00000129,0x0000012e, - 0x0004003d,0x000000a6,0x0000012f,0x0000011a,0x0004003d,0x00000006,0x00000130,0x0000002a, - 0x0004003d,0x00000006,0x00000131,0x0000002d,0x000600a9,0x00000006,0x00000132,0x0000012f, - 0x00000130,0x00000131,0x0003003e,0x0000011e,0x00000132,0x0004003d,0x00000006,0x00000134, - 0x0000002b,0x0004003d,0x00000006,0x00000135,0x0000002c,0x0007000c,0x00000006,0x00000136, - 0x00000001,0x00000025,0x00000134,0x00000135,0x0004003d,0x00000006,0x00000137,0x0000011e, - 0x0007000c,0x00000006,0x00000138,0x00000001,0x00000025,0x00000136,0x00000137,0x0003003e, - 0x00000133,0x00000138,0x0004003d,0x00000006,0x0000013a,0x0000002b,0x0004003d,0x00000006, - 0x0000013b,0x0000002c,0x0007000c,0x00000006,0x0000013c,0x00000001,0x00000028,0x0000013a, - 0x0000013b,0x0004003d,0x00000006,0x0000013d,0x0000011e,0x0007000c,0x00000006,0x0000013e, - 0x00000001,0x00000028,0x0000013c,0x0000013d,0x0003003e,0x00000139,0x0000013e,0x0004003d, - 0x00000006,0x00000140,0x00000129,0x0004003d,0x00000006,0x00000141,0x00000123,0x00050083, - 0x00000006,0x00000142,0x00000140,0x00000141,0x0003003e,0x0000013f,0x00000142,0x0004003d, - 0x00000006,0x00000144,0x00000139,0x0004003d,0x00000006,0x00000145,0x00000133,0x00050083, - 0x00000006,0x00000146,0x00000144,0x00000145,0x0003003e,0x00000143,0x00000146,0x0004003d, - 0x00000006,0x00000148,0x0000013f,0x0004003d,0x00000006,0x00000149,0x00000143,0x0007000c, - 0x00000006,0x0000014a,0x00000001,0x00000028,0x00000148,0x00000149,0x0004003d,0x00000006, - 0x0000014b,0x0000013f,0x0004003d,0x00000006,0x0000014c,0x00000143,0x0007000c,0x00000006, - 0x0000014d,0x00000001,0x00000025,0x0000014b,0x0000014c,0x00050081,0x00000006,0x0000014f, - 0x0000014d,0x0000014e,0x00050088,0x00000006,0x00000150,0x0000014a,0x0000014f,0x0003003e, - 0x00000147,0x00000150,0x0004003d,0x00000006,0x00000151,0x00000147,0x00050083,0x00000006, - 0x00000153,0x00000151,0x00000152,0x00050085,0x00000006,0x00000155,0x00000153,0x00000154, - 0x0008000c,0x00000006,0x00000156,0x00000001,0x0000002b,0x00000155,0x000000a5,0x000000b2, - 0x00050083,0x00000006,0x00000157,0x000000b2,0x00000156,0x00050085,0x00000006,0x00000158, - 0x00000157,0x000000b2,0x000200fe,0x00000158,0x00010038,0x00050036,0x00000006,0x00000038, - 0x00000000,0x00000035,0x00030037,0x00000034,0x00000036,0x00030037,0x00000026,0x00000037, - 0x000200f8,0x00000039,0x0004003b,0x0000000d,0x0000015f,0x00000007,0x0004003b,0x00000026, - 0x00000160,0x00000007,0x0004003b,0x00000214,0x00000215,0x00000007,0x0004003b,0x0000000d, - 0x00000221,0x00000007,0x0004003b,0x00000026,0x00000222,0x00000007,0x0004003b,0x00000214, - 0x000002b0,0x00000007,0x0004003b,0x0000000d,0x000002bb,0x00000007,0x0004003b,0x0000000d, - 0x000002c3,0x00000007,0x0004003b,0x0000000d,0x000002cf,0x00000007,0x0004003b,0x0000000d, - 0x000002e3,0x00000007,0x0004003b,0x0000000d,0x000002e6,0x00000007,0x0004003b,0x0000000d, - 0x000002e9,0x00000007,0x0004003b,0x0000000d,0x000002ec,0x00000007,0x0004003b,0x0000000d, - 0x000002ef,0x00000007,0x0004003b,0x0000000d,0x000002f2,0x00000007,0x0004003b,0x00000026, - 0x000002f5,0x00000007,0x0004003d,0x00000025,0x0000015b,0x00000037,0x0008000c,0x00000025, - 0x0000015e,0x00000001,0x0000002d,0x0000015b,0x0000015c,0x0000015d,0x0003003e,0x00000037, - 0x0000015e,0x0003003e,0x0000015f,0x000000a5,0x0003003e,0x00000160,0x0000015c,0x000200f9, - 0x00000161,0x000200f8,0x00000161,0x000400f6,0x00000163,0x00000164,0x00000000,0x000200f9, - 0x00000165,0x000200f8,0x00000165,0x0004003d,0x00000025,0x00000166,0x00000160,0x000500b1, - 0x000000a6,0x00000168,0x00000166,0x00000167,0x000400fa,0x00000168,0x00000162,0x00000163, - 0x000200f8,0x00000162,0x0004003d,0x00000025,0x00000210,0x00000037,0x00050084,0x00000025, - 0x00000211,0x00000210,0x00000167,0x0004003d,0x00000025,0x00000212,0x00000160,0x00050080, - 0x00000025,0x00000213,0x00000211,0x00000212,0x0003003e,0x00000215,0x0000020f,0x00050041, - 0x0000000d,0x00000216,0x00000215,0x00000213,0x0004003d,0x00000006,0x00000217,0x00000216, - 0x0004003d,0x00000025,0x00000218,0x00000160,0x00050041,0x0000000d,0x00000219,0x00000036, - 0x00000218,0x0004003d,0x00000006,0x0000021a,0x00000219,0x00050085,0x00000006,0x0000021b, - 0x00000217,0x0000021a,0x0004003d,0x00000006,0x0000021c,0x0000015f,0x00050081,0x00000006, - 0x0000021d,0x0000021c,0x0000021b,0x0003003e,0x0000015f,0x0000021d,0x000200f9,0x00000164, - 0x000200f8,0x00000164,0x0004003d,0x00000025,0x0000021e,0x00000160,0x00050080,0x00000025, - 0x00000220,0x0000021e,0x0000021f,0x0003003e,0x00000160,0x00000220,0x000200f9,0x00000161, - 0x000200f8,0x00000163,0x0003003e,0x00000221,0x000000a5,0x0003003e,0x00000222,0x0000015c, - 0x000200f9,0x00000223,0x000200f8,0x00000223,0x000400f6,0x00000225,0x00000226,0x00000000, - 0x000200f9,0x00000227,0x000200f8,0x00000227,0x0004003d,0x00000025,0x00000228,0x00000222, - 0x000500b1,0x000000a6,0x00000229,0x00000228,0x00000167,0x000400fa,0x00000229,0x00000224, - 0x00000225,0x000200f8,0x00000224,0x0004003d,0x00000025,0x000002ac,0x00000037,0x00050084, - 0x00000025,0x000002ad,0x000002ac,0x00000167,0x0004003d,0x00000025,0x000002ae,0x00000222, - 0x00050080,0x00000025,0x000002af,0x000002ad,0x000002ae,0x0003003e,0x000002b0,0x000002ab, - 0x00050041,0x0000000d,0x000002b1,0x000002b0,0x000002af,0x0004003d,0x00000006,0x000002b2, - 0x000002b1,0x0004003d,0x00000025,0x000002b3,0x00000222,0x00050041,0x0000000d,0x000002b4, - 0x00000036,0x000002b3,0x0004003d,0x00000006,0x000002b5,0x000002b4,0x00050085,0x00000006, - 0x000002b6,0x000002b2,0x000002b5,0x0004003d,0x00000006,0x000002b7,0x00000221,0x00050081, - 0x00000006,0x000002b8,0x000002b7,0x000002b6,0x0003003e,0x00000221,0x000002b8,0x000200f9, - 0x00000226,0x000200f8,0x00000226,0x0004003d,0x00000025,0x000002b9,0x00000222,0x00050080, - 0x00000025,0x000002ba,0x000002b9,0x0000021f,0x0003003e,0x00000222,0x000002ba,0x000200f9, - 0x00000223,0x000200f8,0x00000225,0x0004003d,0x00000006,0x000002bc,0x0000015f,0x00050083, - 0x00000006,0x000002be,0x000002bc,0x000002bd,0x00050085,0x00000006,0x000002c0,0x000002be, - 0x000002bf,0x0008000c,0x00000006,0x000002c1,0x00000001,0x0000002b,0x000002c0,0x000000a5, - 0x000000b2,0x00050083,0x00000006,0x000002c2,0x000000b2,0x000002c1,0x0003003e,0x000002bb, - 0x000002c2,0x0004003d,0x00000006,0x000002c4,0x000002bb,0x0004003d,0x00000006,0x000002c7, - 0x000002c6,0x00050085,0x00000006,0x000002c8,0x000002c4,0x000002c7,0x0004003d,0x00000006, - 0x000002ca,0x000002c9,0x00050081,0x00000006,0x000002cb,0x000002c8,0x000002ca,0x0003003e, - 0x000002c3,0x000002cb,0x0004003d,0x00000006,0x000002cc,0x000002c3,0x0004003d,0x00000006, - 0x000002cd,0x00000221,0x00050085,0x00000006,0x000002ce,0x000002cd,0x000002cc,0x0003003e, - 0x00000221,0x000002ce,0x0004003d,0x00000006,0x000002d0,0x000002bb,0x0004003d,0x00000006, - 0x000002d2,0x000002d1,0x00050085,0x00000006,0x000002d3,0x000002d0,0x000002d2,0x0004003d, - 0x00000006,0x000002d5,0x000002d4,0x00050081,0x00000006,0x000002d6,0x000002d3,0x000002d5, - 0x0004003d,0x00000006,0x000002d7,0x0000015f,0x00050085,0x00000006,0x000002d8,0x000002d6, - 0x000002d7,0x0003003e,0x000002cf,0x000002d8,0x0004003d,0x00000006,0x000002d9,0x000002cf, - 0x0004003d,0x00000006,0x000002da,0x000002cf,0x0004007f,0x00000006,0x000002db,0x000002da, - 0x0004003d,0x00000006,0x000002dc,0x00000221,0x0007000c,0x00000006,0x000002dd,0x00000001, - 0x00000028,0x000002db,0x000002dc,0x0007000c,0x00000006,0x000002de,0x00000001,0x00000025, - 0x000002d9,0x000002dd,0x0003003e,0x00000221,0x000002de,0x00050041,0x0000000d,0x000002e4, - 0x00000036,0x0000015c,0x0004003d,0x00000006,0x000002e5,0x000002e4,0x0003003e,0x000002e3, - 0x000002e5,0x00050041,0x0000000d,0x000002e7,0x00000036,0x0000021f,0x0004003d,0x00000006, - 0x000002e8,0x000002e7,0x0003003e,0x000002e6,0x000002e8,0x00050041,0x0000000d,0x000002ea, - 0x00000036,0x000002df,0x0004003d,0x00000006,0x000002eb,0x000002ea,0x0003003e,0x000002e9, - 0x000002eb,0x00050041,0x0000000d,0x000002ed,0x00000036,0x000002e0,0x0004003d,0x00000006, - 0x000002ee,0x000002ed,0x0003003e,0x000002ec,0x000002ee,0x00050041,0x0000000d,0x000002f0, - 0x00000036,0x000002e1,0x0004003d,0x00000006,0x000002f1,0x000002f0,0x0003003e,0x000002ef, - 0x000002f1,0x00050041,0x0000000d,0x000002f3,0x00000036,0x000002e2,0x0004003d,0x00000006, - 0x000002f4,0x000002f3,0x0003003e,0x000002f2,0x000002f4,0x0004003d,0x00000025,0x000002f6, - 0x00000037,0x0003003e,0x000002f5,0x000002f6,0x000b0039,0x00000006,0x000002f7,0x0000002f, - 0x000002e3,0x000002e6,0x000002e9,0x000002ec,0x000002ef,0x000002f2,0x000002f5,0x0004003d, - 0x00000006,0x000002f8,0x00000221,0x00050085,0x00000006,0x000002f9,0x000002f8,0x000002f7, - 0x0003003e,0x00000221,0x000002f9,0x0004003d,0x00000006,0x000002fa,0x0000015f,0x0004003d, - 0x00000006,0x000002fb,0x00000221,0x00050081,0x00000006,0x000002fc,0x000002fa,0x000002fb, - 0x000200fe,0x000002fc,0x00010038,0x00050036,0x00000006,0x00000040,0x00000000,0x0000003c, + 0x00030005,0x00000053,0x00305f67,0x00040005,0x00000060,0x35345f67,0x00000000,0x00040005, + 0x0000006d,0x30395f67,0x00000000,0x00040005,0x0000007a,0x33315f67,0x00000035,0x00050005, + 0x00000087,0x5f305f67,0x6d5f3039,0x00007861,0x00050005,0x0000008b,0x5f305f67,0x6d5f3039, + 0x00006e69,0x00060005,0x0000008f,0x35345f67,0x3533315f,0x78616d5f,0x00000000,0x00060005, + 0x00000093,0x35345f67,0x3533315f,0x6e696d5f,0x00000000,0x00040005,0x000000a1,0x5f305f65, + 0x00003039,0x00050005,0x000000a7,0x35345f65,0x3533315f,0x00000000,0x00040005,0x000000ac, + 0x5f305f63,0x00003039,0x00050005,0x000000ba,0x35345f63,0x3533315f,0x00000000,0x00050005, + 0x000000c6,0x5f675f63,0x30395f30,0x00000000,0x00050005,0x000000ca,0x5f675f63,0x315f3534, + 0x00003533,0x00050005,0x000000ce,0x5f655f66,0x30395f30,0x00000000,0x00050005,0x000000d4, + 0x5f655f66,0x315f3534,0x00003533,0x00030005,0x000000da,0x00003077,0x00030005,0x000000e0, + 0x00303977,0x00030005,0x000000e7,0x00353477,0x00040005,0x000000ed,0x35333177,0x00000000, + 0x00030005,0x000000fb,0x00003068,0x00030005,0x00000101,0x00003168,0x00050005,0x0000010e, + 0x656c6573,0x726f7463,0x00000000,0x00030005,0x00000112,0x006c6573,0x00040005,0x00000117, + 0x696d5f61,0x0000006e,0x00040005,0x0000011d,0x616d5f61,0x00000078,0x00040005,0x00000127, + 0x696d5f62,0x0000006e,0x00040005,0x0000012d,0x616d5f62,0x00000078,0x00040005,0x00000133, + 0x6f635f61,0x0000746e,0x00040005,0x00000137,0x6f635f62,0x0000746e,0x00050005,0x0000013b, + 0x746e6f63,0x7461725f,0x00006f69,0x00030005,0x00000153,0x00000079,0x00040005,0x00000154, + 0x73755f79,0x0000006d,0x00030005,0x00000155,0x00000069,0x00050005,0x0000020a,0x65646e69, + 0x6c626178,0x00000065,0x00050005,0x00000299,0x65646e69,0x6c626178,0x00000065,0x00040005, + 0x000002a5,0x63735f79,0x00656c61,0x00050005,0x000002ad,0x68735f79,0x6e707261,0x00737365, + 0x00070005,0x000002b0,0x61685367,0x74537072,0x676e6572,0x63536874,0x00656c61,0x00070005, + 0x000002b3,0x61685367,0x74537072,0x676e6572,0x694d6874,0x0000006e,0x00070005,0x000002b9, + 0x68735f79,0x6e707261,0x5f737365,0x696d696c,0x00000074,0x00070005,0x000002bb,0x61685367, + 0x694c7072,0x5374696d,0x656c6163,0x00000000,0x00060005,0x000002be,0x61685367,0x694c7072, + 0x4d74696d,0x00006e69,0x00040005,0x000002cd,0x61726170,0x0000006d,0x00040005,0x000002d0, + 0x61726170,0x0000006d,0x00040005,0x000002d3,0x61726170,0x0000006d,0x00040005,0x000002d6, + 0x61726170,0x0000006d,0x00040005,0x000002d9,0x61726170,0x0000006d,0x00040005,0x000002dc, + 0x61726170,0x0000006d,0x00040005,0x000002df,0x61726170,0x0000006d,0x00040005,0x000002ed, + 0x63615f68,0x00000063,0x00030005,0x000002ee,0x0000006a,0x00040005,0x000002f6,0x63615f76, + 0x00000063,0x00030005,0x000002f7,0x00000069,0x00050005,0x00000307,0x65646e69,0x6c626178, + 0x00000065,0x00050005,0x00000314,0x65646e69,0x6c626178,0x00000065,0x00030005,0x0000031f, + 0x00000066,0x00030005,0x00000326,0x00000069,0x00050005,0x0000032e,0x65746e69,0x44307072, + 0x00006765,0x00040005,0x0000033b,0x61726170,0x0000006d,0x00040005,0x0000033d,0x61726170, + 0x0000006d,0x00030005,0x0000034b,0x00000069,0x00050005,0x00000353,0x65746e69,0x30397072, + 0x00676544,0x00040005,0x00000360,0x61726170,0x0000006d,0x00040005,0x00000362,0x61726170, + 0x0000006d,0x00050005,0x00000370,0x61687070,0x625f6573,0x00003534,0x00070005,0x0000037a, + 0x706d6574,0x746e695f,0x34707265,0x67654435,0x00000000,0x00030005,0x00000392,0x00000061, + 0x00030005,0x0000039e,0x00000062,0x00030005,0x000003aa,0x00000063,0x00030005,0x000003b6, + 0x00000064,0x00050005,0x000003de,0x61687070,0x705f6573,0x00003534,0x00030005,0x000003e6, + 0x00000069,0x00050005,0x000003ee,0x65746e69,0x35347072,0x00676544,0x00030005,0x000003fa, + 0x00000069,0x00040005,0x0000040d,0x61726170,0x0000006d,0x00040005,0x0000040f,0x61726170, + 0x0000006d,0x00050005,0x0000041c,0x61687070,0x625f6573,0x00353331,0x00070005,0x00000421, + 0x706d6574,0x746e695f,0x31707265,0x65443533,0x00000067,0x00030005,0x00000439,0x00000061, + 0x00030005,0x00000445,0x00000062,0x00030005,0x00000451,0x00000063,0x00030005,0x0000045d, + 0x00000064,0x00050005,0x00000485,0x61687070,0x705f6573,0x00353331,0x00030005,0x0000048e, + 0x00000069,0x00060005,0x00000496,0x65746e69,0x33317072,0x67654435,0x00000000,0x00030005, + 0x000004a2,0x00000069,0x00040005,0x000004b4,0x61726170,0x0000006d,0x00040005,0x000004b6, + 0x61726170,0x0000006d,0x00050005,0x000004c0,0x72616873,0x73656e70,0x00000073,0x00030005, + 0x000004c1,0x00004350,0x00040006,0x000004c1,0x00000000,0x0063646e,0x00070006,0x000004c1, + 0x00000001,0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00060006,0x000004c1,0x00000002, + 0x72616873,0x73656e70,0x00000073,0x00030005,0x000004c3,0x00006370,0x00060005,0x000004c8, + 0x72616873,0x5f6e6570,0x64696c73,0x00007265,0x00050005,0x000004cb,0x5378614d,0x656c6163, + 0x00000000,0x00050005,0x000004d1,0x536e694d,0x656c6163,0x00000000,0x00050005,0x000004d5, + 0x696d694c,0x61635374,0x0000656c,0x00070005,0x000004df,0x72616873,0x72745370,0x74676e65, + 0x78614d68,0x00000000,0x00060005,0x000004f3,0x72616873,0x6d694c70,0x614d7469,0x00000078, + 0x00040005,0x000004ff,0x69536e69,0x0000657a,0x00040005,0x00000504,0x49766e69,0x0000006e, + 0x00040005,0x00000508,0x58637273,0x00000000,0x00060005,0x0000050a,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x00000512,0x59637273,0x00000000,0x00030005,0x00000519, + 0x00787366,0x00030005,0x0000051c,0x00797366,0x00030005,0x0000051f,0x00007866,0x00030005, + 0x00000523,0x00007966,0x00040005,0x00000527,0x695f7866,0x0000746e,0x00040005,0x0000052b, + 0x695f7966,0x0000746e,0x00030005,0x0000052f,0x00000069,0x00030005,0x00000537,0x0000006a, + 0x00030005,0x0000053f,0x00006374,0x00030005,0x0000054f,0x00000070,0x00060005,0x00000555, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005,0x00000559,0x61726170,0x0000006d, + 0x00030005,0x00000561,0x00303065,0x00040005,0x00000562,0x61726170,0x0000006d,0x00040005, + 0x00000565,0x61726170,0x0000006d,0x00040005,0x00000568,0x61726170,0x0000006d,0x00040005, + 0x0000056b,0x61726170,0x0000006d,0x00040005,0x0000056e,0x61726170,0x0000006d,0x00040005, + 0x00000571,0x61726170,0x0000006d,0x00040005,0x00000574,0x61726170,0x0000006d,0x00040005, + 0x00000577,0x61726170,0x0000006d,0x00040005,0x0000057a,0x61726170,0x0000006d,0x00030005, + 0x0000057e,0x00313065,0x00040005,0x0000057f,0x61726170,0x0000006d,0x00040005,0x00000582, + 0x61726170,0x0000006d,0x00040005,0x00000585,0x61726170,0x0000006d,0x00040005,0x00000588, + 0x61726170,0x0000006d,0x00040005,0x0000058b,0x61726170,0x0000006d,0x00040005,0x0000058e, + 0x61726170,0x0000006d,0x00040005,0x00000591,0x61726170,0x0000006d,0x00040005,0x00000594, + 0x61726170,0x0000006d,0x00040005,0x00000597,0x61726170,0x0000006d,0x00030005,0x0000059b, + 0x00303165,0x00040005,0x0000059c,0x61726170,0x0000006d,0x00040005,0x0000059f,0x61726170, + 0x0000006d,0x00040005,0x000005a2,0x61726170,0x0000006d,0x00040005,0x000005a5,0x61726170, + 0x0000006d,0x00040005,0x000005a8,0x61726170,0x0000006d,0x00040005,0x000005ab,0x61726170, + 0x0000006d,0x00040005,0x000005ae,0x61726170,0x0000006d,0x00040005,0x000005b1,0x61726170, + 0x0000006d,0x00040005,0x000005b4,0x61726170,0x0000006d,0x00030005,0x000005b8,0x00313165, + 0x00040005,0x000005b9,0x61726170,0x0000006d,0x00040005,0x000005bc,0x61726170,0x0000006d, + 0x00040005,0x000005bf,0x61726170,0x0000006d,0x00040005,0x000005c2,0x61726170,0x0000006d, + 0x00040005,0x000005c5,0x61726170,0x0000006d,0x00040005,0x000005c8,0x61726170,0x0000006d, + 0x00040005,0x000005cb,0x61726170,0x0000006d,0x00040005,0x000005ce,0x61726170,0x0000006d, + 0x00040005,0x000005d1,0x61726170,0x0000006d,0x00030005,0x000005d5,0x00000077,0x00040005, + 0x000005d6,0x61726170,0x0000006d,0x00040005,0x000005d8,0x61726170,0x0000006d,0x00040005, + 0x000005da,0x61726170,0x0000006d,0x00040005,0x000005dc,0x61726170,0x0000006d,0x00040005, + 0x000005de,0x61726170,0x0000006d,0x00040005,0x000005e0,0x61726170,0x0000006d,0x00050005, + 0x000005e3,0x65736162,0x67696557,0x00007468,0x00030005,0x000005f0,0x0059706f,0x00040005, + 0x000005f1,0x61726170,0x0000006d,0x00040005,0x000005f3,0x61726170,0x0000006d,0x00040005, + 0x000005f5,0x61726170,0x0000006d,0x00040005,0x000005fa,0x61726170,0x0000006d,0x00040005, + 0x000005fc,0x61726170,0x0000006d,0x00040005,0x000005fe,0x61726170,0x0000006d,0x00040005, + 0x00000600,0x61726170,0x0000006d,0x00040005,0x00000602,0x61726170,0x0000006d,0x00040005, + 0x00000604,0x61726170,0x0000006d,0x00030005,0x00000609,0x0000706f,0x00030005,0x0000060d, + 0x00000079,0x00040005,0x0000060e,0x61726170,0x0000006d,0x00040005,0x00000612,0x72726f63, + 0x00000000,0x00050005,0x00000622,0x4374756f,0x726f6c6f,0x00000000,0x00030047,0x000004c1, + 0x00000002,0x00050048,0x000004c1,0x00000000,0x00000023,0x00000000,0x00050048,0x000004c1, + 0x00000001,0x00000023,0x00000010,0x00050048,0x000004c1,0x00000002,0x00000023,0x00000020, + 0x00040047,0x0000050a,0x0000001e,0x00000000,0x00040047,0x00000555,0x00000021,0x00000000, + 0x00040047,0x00000555,0x00000022,0x00000000,0x00040047,0x00000622,0x0000001e,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040017,0x00000007,0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,0x00000007, + 0x00040021,0x00000009,0x00000006,0x00000008,0x00040020,0x0000000d,0x00000007,0x00000006, + 0x00040017,0x0000000e,0x00000006,0x00000004,0x000c0021,0x0000000f,0x0000000e,0x0000000d, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d, + 0x00040020,0x0000001b,0x00000007,0x0000000e,0x00090021,0x0000001c,0x0000000e,0x0000001b, + 0x0000001b,0x0000001b,0x0000001b,0x0000000d,0x0000000d,0x00040015,0x00000025,0x00000020, + 0x00000001,0x00040020,0x00000026,0x00000007,0x00000025,0x000a0021,0x00000027,0x00000006, + 0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x0000000d,0x00000026,0x00040015, + 0x00000031,0x00000020,0x00000000,0x0004002b,0x00000031,0x00000032,0x00000006,0x0004001c, + 0x00000033,0x00000006,0x00000032,0x00040020,0x00000034,0x00000007,0x00000033,0x00050021, + 0x00000035,0x00000006,0x00000034,0x00000026,0x0004001c,0x0000003a,0x00000033,0x00000032, + 0x00040020,0x0000003b,0x00000007,0x0000003a,0x00060021,0x0000003c,0x00000006,0x0000003b, + 0x00000026,0x00000026,0x00090021,0x00000042,0x00000006,0x0000003b,0x0000000d,0x0000000d, + 0x00000026,0x00000026,0x0000001b,0x0004002b,0x00000006,0x0000004c,0x3e59b3d0,0x0004002b, + 0x00000006,0x0000004d,0x3f371759,0x0004002b,0x00000006,0x0000004e,0x3d93dd98,0x0006002c, + 0x00000007,0x0000004f,0x0000004c,0x0000004d,0x0000004e,0x0004002b,0x00000006,0x0000009a, + 0x00000000,0x00020014,0x0000009b,0x0007002c,0x0000000e,0x0000009f,0x0000009a,0x0000009a, + 0x0000009a,0x0000009a,0x0004002b,0x00000006,0x000000a8,0x3f800000,0x00040020,0x000000ab, + 0x00000007,0x0000009b,0x0004002b,0x00000006,0x000000af,0x400ce000,0x0004002b,0x00000006, + 0x000000b3,0x3d800000,0x0004002b,0x00000025,0x00000110,0x00000020,0x0004002b,0x00000006, + 0x00000142,0x3b808081,0x0004002b,0x00000006,0x00000146,0x40000000,0x0004002b,0x00000006, + 0x00000148,0x3e000000,0x0004002b,0x00000025,0x00000150,0x00000000,0x0004002b,0x00000025, + 0x00000151,0x0000003f,0x0004002b,0x00000025,0x0000015c,0x00000006,0x0004002b,0x00000031, + 0x0000015e,0x00000180,0x0004001c,0x0000015f,0x00000006,0x0000015e,0x0004002b,0x00000006, + 0x00000160,0x3b3e0ded,0x0004002b,0x00000006,0x00000161,0xbc5013a9,0x0004002b,0x00000006, + 0x00000162,0x3c5844d0,0x0004002b,0x00000006,0x00000163,0xbb5ed289,0x0004002b,0x00000006, + 0x00000164,0x3bce703b,0x0004002b,0x00000006,0x00000165,0xbccbfb16,0x0004002b,0x00000006, + 0x00000166,0x3f7f9db2,0x0004002b,0x00000006,0x00000167,0x3cdc5d64,0x0004002b,0x00000006, + 0x00000168,0xbbded289,0x0004002b,0x00000006,0x00000169,0x3c102de0,0x0004002b,0x00000006, + 0x0000016a,0xbd13dd98,0x0004002b,0x00000006,0x0000016b,0x3f7edfa4,0x0004002b,0x00000006, + 0x0000016c,0x3d29fbe7,0x0004002b,0x00000006,0x0000016d,0xbc28c155,0x0004002b,0x00000006, + 0x0000016e,0x3a03126f,0x0004002b,0x00000006,0x0000016f,0x3c3fb15b,0x0004002b,0x00000006, + 0x00000170,0xbd422681,0x0004002b,0x00000006,0x00000171,0x3f7e425b,0x0004002b,0x00000006, + 0x00000172,0x3d6631f9,0x0004002b,0x00000006,0x00000173,0xbc68a71e,0x0004002b,0x00000006, + 0x00000174,0x3c68a71e,0x0004002b,0x00000006,0x00000175,0xbd6bedfa,0x0004002b,0x00000006, + 0x00000176,0x3f7d5cfb,0x0004002b,0x00000006,0x00000177,0x3d9205bc,0x0004002b,0x00000006, + 0x00000178,0xbc944674,0x0004002b,0x00000006,0x00000179,0x3c87fcb9,0x0004002b,0x00000006, + 0x0000017a,0xbd8a0903,0x0004002b,0x00000006,0x0000017b,0x3f7c01a3,0x0004002b,0x00000006, + 0x0000017c,0x3db2fec5,0x0004002b,0x00000006,0x0000017d,0xbcb43958,0x0004002b,0x00000006, + 0x0000017e,0x3a83126f,0x0004002b,0x00000006,0x0000017f,0x3c985f07,0x0004002b,0x00000006, + 0x00000180,0xbd9c0ebf,0x0004002b,0x00000006,0x00000181,0x3f7a7efa,0x0004002b,0x00000006, + 0x00000182,0x3dd4fdf4,0x0004002b,0x00000006,0x00000183,0xbcd844d0,0x0004002b,0x00000006, + 0x00000184,0x3ac49ba6,0x0004002b,0x00000006,0x00000185,0x3ca7ef9e,0x0004002b,0x00000006, + 0x00000186,0xbdae147b,0x0004002b,0x00000006,0x00000187,0x3f7902de,0x0004002b,0x00000006, + 0x00000188,0x3df6fd22,0x0004002b,0x00000006,0x00000189,0xbcfc5048,0x0004002b,0x00000006, + 0x0000018a,0x3b03126f,0x0004002b,0x00000006,0x0000018b,0x3cb851ec,0x0004002b,0x00000006, + 0x0000018c,0xbdbe0ded,0x0004002b,0x00000006,0x0000018d,0x3f76fd22,0x0004002b,0x00000006, + 0x0000018e,0x3e0d844d,0x0004002b,0x00000006,0x0000018f,0xbd102de0,0x0004002b,0x00000006, + 0x00000190,0x3b1d4952,0x0004002b,0x00000006,0x00000191,0x3cc3c9ef,0x0004002b,0x00000006, + 0x00000192,0xbdce075f,0x0004002b,0x00000006,0x00000193,0x3f751eb8,0x0004002b,0x00000006, + 0x00000194,0x3e1f8a09,0x0004002b,0x00000006,0x00000195,0xbd22339c,0x0004002b,0x00000006, + 0x00000196,0x3cd013a9,0x0004002b,0x00000006,0x00000197,0xbddbf488,0x0004002b,0x00000006, + 0x00000198,0x3f72de01,0x0004002b,0x00000006,0x00000199,0x3e31f8a1,0x0004002b,0x00000006, + 0x0000019a,0xbd33d07d,0x0004002b,0x00000006,0x0000019b,0x3b5ed289,0x0004002b,0x00000006, + 0x0000019c,0x3cd844d0,0x0004002b,0x00000006,0x0000019d,0xbde90ff9,0x0004002b,0x00000006, + 0x0000019e,0x3f70624e,0x0004002b,0x00000006,0x0000019f,0x3e458794,0x0004002b,0x00000006, + 0x000001a0,0xbd47e282,0x0004002b,0x00000006,0x000001a1,0x3b902de0,0x0004002b,0x00000006, + 0x000001a2,0x3ce3bcd3,0x0004002b,0x00000006,0x000001a3,0xbdf3eab3,0x0004002b,0x00000006, + 0x000001a4,0x3f6d9e84,0x0004002b,0x00000006,0x000001a5,0x3e58fc50,0x0004002b,0x00000006, + 0x000001a6,0xbd5bf488,0x0004002b,0x00000006,0x000001a7,0x3ba0902e,0x0004002b,0x00000006, + 0x000001a8,0x3cebedfa,0x0004002b,0x00000006,0x000001a9,0xbdfef9db,0x0004002b,0x00000006, + 0x000001aa,0x3f6ac083,0x0004002b,0x00000006,0x000001ab,0x3e6c8b44,0x0004002b,0x00000006, + 0x000001ac,0xbd6dfa44,0x0004002b,0x00000006,0x000001ad,0x3bc154ca,0x0004002b,0x00000006, + 0x000001ae,0x3cf0068e,0x0004002b,0x00000006,0x000001af,0xbe04816f,0x0004002b,0x00000006, + 0x000001b0,0x3f67e282,0x0004002b,0x00000006,0x000001b1,0x3e808312,0x0004002b,0x00000006, + 0x000001b2,0xbd810625,0x0004002b,0x00000006,0x000001b3,0x3cf837b5,0x0004002b,0x00000006, + 0x000001b4,0xbe087fcc,0x0004002b,0x00000006,0x000001b5,0x3f64816f,0x0004002b,0x00000006, + 0x000001b6,0x3e8ac083,0x0004002b,0x00000006,0x000001b7,0xbd8b0f28,0x0004002b,0x00000006, + 0x000001b8,0x3bef34d7,0x0004002b,0x00000006,0x000001b9,0x3cfc5048,0x0004002b,0x00000006, + 0x000001ba,0xbe0bfb16,0x0004002b,0x00000006,0x000001bb,0x3f60ff97,0x0004002b,0x00000006, + 0x000001bc,0x3e953f7d,0x0004002b,0x00000006,0x000001bd,0xbd95182b,0x0004002b,0x00000006, + 0x000001be,0x3c07fcb9,0x0004002b,0x00000006,0x000001bf,0xbe0f7660,0x0004002b,0x00000006, + 0x000001c0,0x3f5d9e84,0x0004002b,0x00000006,0x000001c1,0x3e9fbe77,0x0004002b,0x00000006, + 0x000001c2,0xbd9eecc0,0x0004002b,0x00000006,0x000001c3,0x3c185f07,0x0004002b,0x00000006, + 0x000001c4,0x3d00346e,0x0004002b,0x00000006,0x000001c5,0xbe1205bc,0x0004002b,0x00000006, + 0x000001c6,0x3f59c0ec,0x0004002b,0x00000006,0x000001c7,0x3eaa7efa,0x0004002b,0x00000006, + 0x000001c8,0xbda8f5c3,0x0004002b,0x00000006,0x000001c9,0x3c28c155,0x0004002b,0x00000006, + 0x000001ca,0xbe13f7cf,0x0004002b,0x00000006,0x000001cb,0x3f55dcc6,0x0004002b,0x00000006, + 0x000001cc,0x3eb53f7d,0x0004002b,0x00000006,0x000001cd,0xbdb2fec5,0x0004002b,0x00000006, + 0x000001ce,0x3c378034,0x0004002b,0x00000006,0x000001cf,0xbe158106,0x0004002b,0x00000006, + 0x000001d0,0x3f51bda5,0x0004002b,0x00000006,0x000001d1,0x3ec04189,0x0004002b,0x00000006, + 0x000001d2,0xbdbd07c8,0x0004002b,0x00000006,0x000001d3,0x3c47e282,0x0004002b,0x00000006, + 0x000001d4,0xbe16872b,0x0004002b,0x00000006,0x000001d5,0x3f4d5cfb,0x0004002b,0x00000006, + 0x000001d6,0x3ecb020c,0x0004002b,0x00000006,0x000001d7,0xbdc60aa6,0x0004002b,0x00000006, + 0x000001d8,0x3c6075f7,0x0004002b,0x00000006,0x000001d9,0xbe177319,0x0004002b,0x00000006, + 0x000001da,0x3f491d15,0x0004002b,0x00000006,0x000001db,0x3ed645a2,0x0004002b,0x00000006, + 0x000001dc,0xbdd013a9,0x0004002b,0x00000006,0x000001dd,0x3c6f34d7,0x0004002b,0x00000006, + 0x000001de,0x3f44a234,0x0004002b,0x00000006,0x000001df,0x3ee13a93,0x0004002b,0x00000006, + 0x000001e0,0xbdd91687,0x0004002b,0x00000006,0x000001e1,0x3c7f9724,0x0004002b,0x00000006, + 0x000001e2,0x3cf41f21,0x0004002b,0x00000006,0x000001e3,0x3f4020c5,0x0004002b,0x00000006, + 0x000001e4,0x3eec3c9f,0x0004002b,0x00000006,0x000001e5,0xbde21965,0x0004002b,0x00000006, + 0x000001e6,0x3f3b3d08,0x0004002b,0x00000006,0x000001e7,0x3ef73eab,0x0004002b,0x00000006, + 0x000001e8,0xbdeae7d5,0x0004002b,0x00000006,0x000001e9,0x3c944674,0x0004002b,0x00000006, + 0x000001ea,0x3f363f14,0x0004002b,0x00000006,0x000001eb,0x3f014120,0x0004002b,0x00000006, + 0x000001ec,0xbdf318fc,0x0004002b,0x00000006,0x000001ed,0x3c9ba5e3,0x0004002b,0x00000006, + 0x000001ee,0x3f3161e5,0x0004002b,0x00000006,0x000001ef,0x3f06c227,0x0004002b,0x00000006, + 0x000001f0,0xbdfb15b5,0x0004002b,0x00000006,0x000001f1,0x3ca3d70a,0x0004002b,0x00000006, + 0x000001f2,0x3cdfa440,0x0004002b,0x00000006,0x000001f3,0xbe1288ce,0x0004002b,0x00000006, + 0x000001f4,0x3f2c2268,0x0004002b,0x00000006,0x000001f5,0x3f0c432d,0x0004002b,0x00000006, + 0x000001f6,0xbe010625,0x0004002b,0x00000006,0x000001f7,0x3cb020c5,0x0004002b,0x00000006, + 0x000001f8,0xbe107c85,0x0004002b,0x00000006,0x000001f9,0x3f271de7,0x0004002b,0x00000006, + 0x000001fa,0x3f11bda5,0x0004002b,0x00000006,0x000001fb,0xbe050481,0x0004002b,0x00000006, + 0x000001fc,0xbe0e075f,0x0004002b,0x00000006,0x000001fd,0x3f21de6a,0x0004002b,0x00000006, + 0x000001fe,0x3f171de7,0x0004002b,0x00000006,0x000001ff,0xbe07fcb9,0x0004002b,0x00000006, + 0x00000200,0x3cbfb15b,0x0004002b,0x00000006,0x00000201,0x3cc7e282,0x0004002b,0x00000006, + 0x00000202,0xbe0af4f1,0x0004002b,0x00000006,0x00000203,0x3f1c7e28,0x0183002c,0x0000015f, + 0x00000204,0x0000009a,0x0000009a,0x000000a8,0x0000009a,0x0000009a,0x0000009a,0x00000160, + 0x00000161,0x000000a8,0x00000162,0x00000163,0x0000009a,0x00000164,0x00000165,0x00000166, + 0x00000167,0x00000168,0x0000009a,0x00000169,0x0000016a,0x0000016b,0x0000016c,0x0000016d, + 0x0000016e,0x0000016f,0x00000170,0x00000171,0x00000172,0x00000173,0x0000016e,0x00000174, + 0x00000175,0x00000176,0x00000177,0x00000178,0x0000016e,0x00000179,0x0000017a,0x0000017b, + 0x0000017c,0x0000017d,0x0000017e,0x0000017f,0x00000180,0x00000181,0x00000182,0x00000183, + 0x00000184,0x00000185,0x00000186,0x00000187,0x00000188,0x00000189,0x0000018a,0x0000018b, + 0x0000018c,0x0000018d,0x0000018e,0x0000018f,0x00000190,0x00000191,0x00000192,0x00000193, + 0x00000194,0x00000195,0x00000160,0x00000196,0x00000197,0x00000198,0x00000199,0x0000019a, + 0x0000019b,0x0000019c,0x0000019d,0x0000019e,0x0000019f,0x000001a0,0x000001a1,0x000001a2, + 0x000001a3,0x000001a4,0x000001a5,0x000001a6,0x000001a7,0x000001a8,0x000001a9,0x000001aa, + 0x000001ab,0x000001ac,0x000001ad,0x000001ae,0x000001af,0x000001b0,0x000001b1,0x000001b2, + 0x00000164,0x000001b3,0x000001b4,0x000001b5,0x000001b6,0x000001b7,0x000001b8,0x000001b9, + 0x000001ba,0x000001bb,0x000001bc,0x000001bd,0x000001be,0x000001b9,0x000001bf,0x000001c0, + 0x000001c1,0x000001c2,0x000001c3,0x000001c4,0x000001c5,0x000001c6,0x000001c7,0x000001c8, + 0x000001c9,0x000001c4,0x000001ca,0x000001cb,0x000001cc,0x000001cd,0x000001ce,0x000001c4, + 0x000001cf,0x000001d0,0x000001d1,0x000001d2,0x000001d3,0x000001c4,0x000001d4,0x000001d5, + 0x000001d6,0x000001d7,0x000001d8,0x000001b9,0x000001d9,0x000001da,0x000001db,0x000001dc, + 0x000001dd,0x000001b3,0x000001d9,0x000001de,0x000001df,0x000001e0,0x000001e1,0x000001e2, + 0x000001d9,0x000001e3,0x000001e4,0x000001e5,0x00000179,0x000001ae,0x000001d4,0x000001e6, + 0x000001e7,0x000001e8,0x000001e9,0x000001a8,0x000001cf,0x000001ea,0x000001eb,0x000001ec, + 0x000001ed,0x000001a2,0x000001ca,0x000001ee,0x000001ef,0x000001f0,0x000001f1,0x000001f2, + 0x000001f3,0x000001f4,0x000001f5,0x000001f6,0x000001f7,0x0000019c,0x000001f8,0x000001f9, + 0x000001fa,0x000001fb,0x0000018b,0x00000196,0x000001fc,0x000001fd,0x000001fe,0x000001ff, + 0x00000200,0x00000201,0x00000202,0x00000203,0x00000203,0x00000202,0x00000201,0x00000200, + 0x000001ff,0x000001fe,0x000001fd,0x000001fc,0x00000196,0x0000018b,0x000001fb,0x000001fa, + 0x000001f9,0x000001f8,0x0000019c,0x000001f7,0x000001f6,0x000001f5,0x000001f4,0x000001f3, + 0x000001f2,0x000001f1,0x000001f0,0x000001ef,0x000001ee,0x000001ca,0x000001a2,0x000001ed, + 0x000001ec,0x000001eb,0x000001ea,0x000001cf,0x000001a8,0x000001e9,0x000001e8,0x000001e7, + 0x000001e6,0x000001d4,0x000001ae,0x00000179,0x000001e5,0x000001e4,0x000001e3,0x000001d9, + 0x000001e2,0x000001e1,0x000001e0,0x000001df,0x000001de,0x000001d9,0x000001b3,0x000001dd, + 0x000001dc,0x000001db,0x000001da,0x000001d9,0x000001b9,0x000001d8,0x000001d7,0x000001d6, + 0x000001d5,0x000001d4,0x000001c4,0x000001d3,0x000001d2,0x000001d1,0x000001d0,0x000001cf, + 0x000001c4,0x000001ce,0x000001cd,0x000001cc,0x000001cb,0x000001ca,0x000001c4,0x000001c9, + 0x000001c8,0x000001c7,0x000001c6,0x000001c5,0x000001c4,0x000001c3,0x000001c2,0x000001c1, + 0x000001c0,0x000001bf,0x000001b9,0x000001be,0x000001bd,0x000001bc,0x000001bb,0x000001ba, + 0x000001b9,0x000001b8,0x000001b7,0x000001b6,0x000001b5,0x000001b4,0x000001b3,0x00000164, + 0x000001b2,0x000001b1,0x000001b0,0x000001af,0x000001ae,0x000001ad,0x000001ac,0x000001ab, + 0x000001aa,0x000001a9,0x000001a8,0x000001a7,0x000001a6,0x000001a5,0x000001a4,0x000001a3, + 0x000001a2,0x000001a1,0x000001a0,0x0000019f,0x0000019e,0x0000019d,0x0000019c,0x0000019b, + 0x0000019a,0x00000199,0x00000198,0x00000197,0x00000196,0x00000160,0x00000195,0x00000194, + 0x00000193,0x00000192,0x00000191,0x00000190,0x0000018f,0x0000018e,0x0000018d,0x0000018c, + 0x0000018b,0x0000018a,0x00000189,0x00000188,0x00000187,0x00000186,0x00000185,0x00000184, + 0x00000183,0x00000182,0x00000181,0x00000180,0x0000017f,0x0000017e,0x0000017d,0x0000017c, + 0x0000017b,0x0000017a,0x00000179,0x0000016e,0x00000178,0x00000177,0x00000176,0x00000175, + 0x00000174,0x0000016e,0x00000173,0x00000172,0x00000171,0x00000170,0x0000016f,0x0000016e, + 0x0000016d,0x0000016c,0x0000016b,0x0000016a,0x00000169,0x0000009a,0x00000168,0x00000167, + 0x00000166,0x00000165,0x00000164,0x0000009a,0x00000163,0x00000162,0x000000a8,0x00000161, + 0x00000160,0x00040020,0x00000209,0x00000007,0x0000015f,0x0004002b,0x00000006,0x00000213, + 0xbf19a027,0x0004002b,0x00000006,0x00000214,0x3f99a027,0x0004002b,0x00000006,0x00000215, + 0xbf1bc01a,0x0004002b,0x00000006,0x00000216,0x3f996f00,0x0004002b,0x00000006,0x00000217, + 0xbf171de7,0x0004002b,0x00000006,0x00000218,0xbb3e0ded,0x0004002b,0x00000006,0x00000219, + 0xbf1d5cfb,0x0004002b,0x00000006,0x0000021a,0x3f990ff9,0x0004002b,0x00000006,0x0000021b, + 0xbf143fe6,0x0004002b,0x00000006,0x0000021c,0xbf1e9e1b,0x0004002b,0x00000006,0x0000021d, + 0x3f983127,0x0004002b,0x00000006,0x0000021e,0xbf10ded3,0x0004002b,0x00000006,0x0000021f, + 0xbf1f9db2,0x0004002b,0x00000006,0x00000220,0x3f9710cb,0x0004002b,0x00000006,0x00000221, + 0xbf0d21ff,0x0004002b,0x00000006,0x00000222,0xbc7765fe,0x0004002b,0x00000006,0x00000223, + 0xbf20624e,0x0004002b,0x00000006,0x00000224,0x3f95bf48,0x0004002b,0x00000006,0x00000225, + 0xbf0902de,0x0004002b,0x00000006,0x00000226,0xbc9fbe77,0x0004002b,0x00000006,0x00000227, + 0xbf208312,0x0004002b,0x00000006,0x00000228,0x3f943fe6,0x0004002b,0x00000006,0x00000229, + 0xbf04a234,0x0004002b,0x00000006,0x0000022a,0xbcd42c3d,0x0004002b,0x00000006,0x0000022b, + 0xbf20ded3,0x0004002b,0x00000006,0x0000022c,0x3f929fbe,0x0004002b,0x00000006,0x0000022d, + 0xbf0020c5,0x0004002b,0x00000006,0x0000022e,0xbd01d7dc,0x0004002b,0x00000006,0x0000022f, + 0x3f904ea5,0x0004002b,0x00000006,0x00000230,0xbef53f7d,0x0004002b,0x00000006,0x00000231, + 0xbd1e1b09,0x0004002b,0x00000006,0x00000232,0x3f8df06f,0x0004002b,0x00000006,0x00000233, + 0xbee9fbe7,0x0004002b,0x00000006,0x00000234,0xbd39f55a,0x0004002b,0x00000006,0x00000235, + 0x3c902de0,0x0004002b,0x00000006,0x00000236,0xbf1e6320,0x0004002b,0x00000006,0x00000237, + 0x3f8b404f,0x0004002b,0x00000006,0x00000238,0xbede83e4,0x0004002b,0x00000006,0x00000239, + 0xbd59e83e,0x0004002b,0x00000006,0x0000023a,0xbf1d21ff,0x0004002b,0x00000006,0x0000023b, + 0x3f886f69,0x0004002b,0x00000006,0x0000023c,0xbed205bc,0x0004002b,0x00000006,0x0000023d, + 0xbd7be76d,0x0004002b,0x00000006,0x0000023e,0xbf1b5dcc,0x0004002b,0x00000006,0x0000023f, + 0x3f852f1b,0x0004002b,0x00000006,0x00000240,0xbec4c2f8,0x0004002b,0x00000006,0x00000241, + 0xbd8ef34d,0x0004002b,0x00000006,0x00000242,0x3c9fbe77,0x0004002b,0x00000006,0x00000243, + 0xbf19c0ec,0x0004002b,0x00000006,0x00000244,0x3f820f91,0x0004002b,0x00000006,0x00000245, + 0xbeb6fd22,0x0004002b,0x00000006,0x00000246,0xbda30553,0x0004002b,0x00000006,0x00000247, + 0xbf17c1be,0x0004002b,0x00000006,0x00000248,0x3f7d42c4,0x0004002b,0x00000006,0x00000249, + 0xbea83e42,0x0004002b,0x00000006,0x0000024a,0xbdb7e910,0x0004002b,0x00000006,0x0000024b, + 0xbf14fdf4,0x0004002b,0x00000006,0x0000024c,0x3f753f7d,0x0004002b,0x00000006,0x0000024d, + 0xbe98fc50,0x0004002b,0x00000006,0x0000024e,0xbdcd013b,0x0004002b,0x00000006,0x0000024f, + 0xbf12a305,0x0004002b,0x00000006,0x00000250,0x3f6de00d,0x0004002b,0x00000006,0x00000251, + 0xbe89ba5e,0x0004002b,0x00000006,0x00000252,0xbf0fdf3b,0x0004002b,0x00000006,0x00000253, + 0x3f65c28f,0x0004002b,0x00000006,0x00000254,0xbe727bb3,0x0004002b,0x00000006,0x00000255, + 0x3b7f9724,0x0004002b,0x00000006,0x00000256,0xbf0cbfb1,0x0004002b,0x00000006,0x00000257, + 0x3f5d42c4,0x0004002b,0x00000006,0x00000258,0xbe5182aa,0x0004002b,0x00000006,0x00000259, + 0xbe0985f0,0x0004002b,0x00000006,0x0000025a,0xbf097f63,0x0004002b,0x00000006,0x0000025b, + 0x3f54816f,0x0004002b,0x00000006,0x0000025c,0xbe2f0069,0x0004002b,0x00000006,0x0000025d, + 0xbe160419,0x0004002b,0x00000006,0x0000025e,0xbf061e4f,0x0004002b,0x00000006,0x0000025f, + 0x3f4b5dcc,0x0004002b,0x00000006,0x00000260,0xbe228241,0x0004002b,0x00000006,0x00000261, + 0x3bb0f27c,0x0004002b,0x00000006,0x00000262,0xbf02bd3c,0x0004002b,0x00000006,0x00000263, + 0x3f428241,0x0004002b,0x00000006,0x00000264,0xbdd119ce,0x0004002b,0x00000006,0x00000265, + 0xbe3089a0,0x0004002b,0x00000006,0x00000266,0xbefe425b,0x0004002b,0x00000006,0x00000267, + 0x3f391d15,0x0004002b,0x00000006,0x00000268,0xbd84ea4b,0x0004002b,0x00000006,0x00000269, + 0xbe3ef9db,0x0004002b,0x00000006,0x0000026a,0xbef6bb99,0x0004002b,0x00000006,0x0000026b, + 0x3f2f41f2,0x0004002b,0x00000006,0x0000026c,0xbcebedfa,0x0004002b,0x00000006,0x0000026d, + 0xbe4c7e28,0x0004002b,0x00000006,0x0000026e,0x3bded289,0x0004002b,0x00000006,0x0000026f, + 0xbeef0069,0x0004002b,0x00000006,0x00000270,0x3f256042,0x0004002b,0x00000006,0x00000271, + 0xbe5b8bac,0x0004002b,0x00000006,0x00000272,0xbee6c227,0x0004002b,0x00000006,0x00000273, + 0x3f1b020c,0x0004002b,0x00000006,0x00000274,0x3d4432ca,0x0004002b,0x00000006,0x00000275, + 0xbe6a7efa,0x0004002b,0x00000006,0x00000276,0x3c8c154d,0x0004002b,0x00000006,0x00000277, + 0xbedfbe77,0x0004002b,0x00000006,0x00000278,0x3dafec57,0x0004002b,0x00000006,0x00000279, + 0xbe7a786c,0x0004002b,0x00000006,0x0000027a,0x3c83e426,0x0004002b,0x00000006,0x0000027b, + 0xbed6fd22,0x0004002b,0x00000006,0x0000027c,0x3f073eab,0x0004002b,0x00000006,0x0000027d, + 0x3e008312,0x0004002b,0x00000006,0x0000027e,0xbe850481,0x0004002b,0x00000006,0x0000027f, + 0x3c20902e,0x0004002b,0x00000006,0x00000280,0xbecf41f2,0x0004002b,0x00000006,0x00000281, + 0x3efa0275,0x0004002b,0x00000006,0x00000282,0x3e2978d5,0x0004002b,0x00000006,0x00000283, + 0xbe8d013b,0x0004002b,0x00000006,0x00000284,0x3c7765fe,0x0004002b,0x00000006,0x00000285, + 0xbec703b0,0x0004002b,0x00000006,0x00000286,0x3ee63f14,0x0004002b,0x00000006,0x00000287, + 0x3e50ff97,0x0004002b,0x00000006,0x00000288,0xbe94fdf4,0x0004002b,0x00000006,0x00000289, + 0x3c2f4f0e,0x0004002b,0x00000006,0x0000028a,0xbebe00d2,0x0004002b,0x00000006,0x0000028b, + 0x3ed07c85,0x0004002b,0x00000006,0x0000028c,0x3e7a786c,0x0004002b,0x00000006,0x0000028d, + 0xbe9cfaad,0x0004002b,0x00000006,0x0000028e,0xbeb60419,0x0004002b,0x00000006,0x0000028f, + 0x3ebc01a3,0x0004002b,0x00000006,0x00000290,0x3e9205bc,0x0004002b,0x00000006,0x00000291, + 0xbea5460b,0x0004002b,0x00000006,0x00000292,0xbeadc5d6,0x0004002b,0x00000006,0x00000293, + 0x3ea703b0,0x0183002c,0x0000015f,0x00000294,0x0000009a,0x00000213,0x00000214,0x00000213, + 0x0000009a,0x0000009a,0x00000160,0x00000215,0x00000216,0x00000217,0x00000218,0x0000009a, + 0x000001a7,0x00000219,0x0000021a,0x0000021b,0x00000168,0x0000016e,0x000001b8,0x0000021c, + 0x0000021d,0x0000021e,0x0000016d,0x0000009a,0x000001c3,0x0000021f,0x00000220,0x00000221, + 0x00000222,0x0000009a,0x000001ce,0x00000223,0x00000224,0x00000225,0x00000226,0x0000016e, + 0x000001d3,0x00000227,0x00000228,0x00000229,0x0000022a,0x0000016e,0x00000174,0x0000022b, + 0x0000022c,0x0000022d,0x0000022e,0x0000016e,0x000001e1,0x00000223,0x0000022f,0x00000230, + 0x00000231,0x0000016e,0x00000179,0x0000021f,0x00000232,0x00000233,0x00000234,0x0000017e, + 0x00000235,0x00000236,0x00000237,0x00000238,0x00000239,0x0000017e,0x000001e9,0x0000023a, + 0x0000023b,0x0000023c,0x0000023d,0x00000184,0x000001ed,0x0000023e,0x0000023f,0x00000240, + 0x00000241,0x00000184,0x00000242,0x00000243,0x00000244,0x00000245,0x00000246,0x0000018a, + 0x000001f1,0x00000247,0x00000248,0x00000249,0x0000024a,0x00000190,0x000001f1,0x0000024b, + 0x0000024c,0x0000024d,0x0000024e,0x00000160,0x000001f1,0x0000024f,0x00000250,0x00000251, + 0x000001e5,0x0000019b,0x000001f1,0x00000252,0x00000253,0x00000254,0x000001f0,0x00000255, + 0x00000185,0x00000256,0x00000257,0x00000258,0x00000259,0x000001a1,0x000001f1,0x0000025a, + 0x0000025b,0x0000025c,0x0000025d,0x000001a7,0x00000242,0x0000025e,0x0000025f,0x000001ba, + 0x00000260,0x00000261,0x00000242,0x00000262,0x00000263,0x00000264,0x00000265,0x000001ad, + 0x000001ed,0x00000266,0x00000267,0x00000268,0x00000269,0x00000164,0x0000017f,0x0000026a, + 0x0000026b,0x0000026c,0x0000026d,0x0000026e,0x0000017f,0x0000026f,0x00000270,0x000001c3, + 0x00000271,0x000001b8,0x00000235,0x00000272,0x00000273,0x00000274,0x00000275,0x000001be, + 0x00000276,0x00000277,0x000001fa,0x00000278,0x00000279,0x00000169,0x0000027a,0x0000027b, + 0x0000027c,0x0000027d,0x0000027e,0x0000027f,0x0000027a,0x00000280,0x00000281,0x00000282, + 0x00000283,0x000001c9,0x00000284,0x00000285,0x00000286,0x00000287,0x00000288,0x00000289, + 0x00000174,0x0000028a,0x0000028b,0x0000028c,0x0000028d,0x0000016f,0x000001d8,0x0000028e, + 0x0000028f,0x00000290,0x00000291,0x000001d3,0x00000162,0x00000292,0x00000293,0x00000293, + 0x00000292,0x00000162,0x000001d3,0x00000291,0x00000290,0x0000028f,0x0000028e,0x000001d8, + 0x0000016f,0x0000028d,0x0000028c,0x0000028b,0x0000028a,0x00000174,0x00000289,0x00000288, + 0x00000287,0x00000286,0x00000285,0x00000284,0x000001c9,0x00000283,0x00000282,0x00000281, + 0x00000280,0x0000027a,0x0000027f,0x0000027e,0x0000027d,0x0000027c,0x0000027b,0x0000027a, + 0x00000169,0x00000279,0x00000278,0x000001fa,0x00000277,0x00000276,0x000001be,0x00000275, + 0x00000274,0x00000273,0x00000272,0x00000235,0x000001b8,0x00000271,0x000001c3,0x00000270, + 0x0000026f,0x0000017f,0x0000026e,0x0000026d,0x0000026c,0x0000026b,0x0000026a,0x0000017f, + 0x00000164,0x00000269,0x00000268,0x00000267,0x00000266,0x000001ed,0x000001ad,0x00000265, + 0x00000264,0x00000263,0x00000262,0x00000242,0x00000261,0x00000260,0x000001ba,0x0000025f, + 0x0000025e,0x00000242,0x000001a7,0x0000025d,0x0000025c,0x0000025b,0x0000025a,0x000001f1, + 0x000001a1,0x00000259,0x00000258,0x00000257,0x00000256,0x00000185,0x00000255,0x000001f0, + 0x00000254,0x00000253,0x00000252,0x000001f1,0x0000019b,0x000001e5,0x00000251,0x00000250, + 0x0000024f,0x000001f1,0x00000160,0x0000024e,0x0000024d,0x0000024c,0x0000024b,0x000001f1, + 0x00000190,0x0000024a,0x00000249,0x00000248,0x00000247,0x000001f1,0x0000018a,0x00000246, + 0x00000245,0x00000244,0x00000243,0x00000242,0x00000184,0x00000241,0x00000240,0x0000023f, + 0x0000023e,0x000001ed,0x00000184,0x0000023d,0x0000023c,0x0000023b,0x0000023a,0x000001e9, + 0x0000017e,0x00000239,0x00000238,0x00000237,0x00000236,0x00000235,0x0000017e,0x00000234, + 0x00000233,0x00000232,0x0000021f,0x00000179,0x0000016e,0x00000231,0x00000230,0x0000022f, + 0x00000223,0x000001e1,0x0000016e,0x0000022e,0x0000022d,0x0000022c,0x0000022b,0x00000174, + 0x0000016e,0x0000022a,0x00000229,0x00000228,0x00000227,0x000001d3,0x0000016e,0x00000226, + 0x00000225,0x00000224,0x00000223,0x000001ce,0x0000009a,0x00000222,0x00000221,0x00000220, + 0x0000021f,0x000001c3,0x0000009a,0x0000016d,0x0000021e,0x0000021d,0x0000021c,0x000001b8, + 0x0000016e,0x00000168,0x0000021b,0x0000021a,0x00000219,0x000001a7,0x0000009a,0x00000218, + 0x00000217,0x00000216,0x00000215,0x00000160,0x0004002b,0x00000025,0x000002a3,0x00000001, + 0x0004002b,0x00000006,0x000002a7,0x3ee66666,0x0004002b,0x00000006,0x000002a9,0x400e38e4, + 0x00040020,0x000002af,0x00000006,0x00000006,0x0004003b,0x000002af,0x000002b0,0x00000006, + 0x0004003b,0x000002af,0x000002b3,0x00000006,0x0004003b,0x000002af,0x000002bb,0x00000006, + 0x0004003b,0x000002af,0x000002be,0x00000006,0x0004002b,0x00000025,0x000002c9,0x00000002, + 0x0004002b,0x00000025,0x000002ca,0x00000003,0x0004002b,0x00000025,0x000002cb,0x00000004, + 0x0004002b,0x00000025,0x000002cc,0x00000005,0x0004002b,0x00000031,0x00000320,0x00000000, + 0x0004002b,0x00000031,0x00000345,0x00000001,0x0004002b,0x00000031,0x0000036a,0x00000002, + 0x0004002b,0x00000006,0x00000371,0x3f000000,0x0004002b,0x00000031,0x00000377,0x00000007, + 0x0004001c,0x00000378,0x00000006,0x00000377,0x00040020,0x00000379,0x00000007,0x00000378, + 0x0004002b,0x00000006,0x0000040a,0x42800000,0x0004002b,0x00000031,0x00000416,0x00000003, + 0x0005001e,0x000004c1,0x0000000e,0x0000000e,0x00000006,0x00040020,0x000004c2,0x00000009, + 0x000004c1,0x0004003b,0x000004c2,0x000004c3,0x00000009,0x00040020,0x000004c4,0x00000009, + 0x00000006,0x0004002b,0x00000006,0x000004ce,0x3fa00000,0x0004002b,0x00000006,0x000004cf, + 0x3fe00000,0x0004002b,0x00000006,0x000004d7,0x3ecccccd,0x0004002b,0x00000006,0x000004db, + 0x3f99999a,0x0004002b,0x00000006,0x000004e0,0x3fcccccd,0x0004002b,0x00000006,0x000004e4, + 0x3fe66666,0x0004002b,0x00000006,0x000004ea,0x3dcccccd,0x0004002b,0x00000006,0x000004eb, + 0x3e0f5c29,0x0004002b,0x00000006,0x000004ef,0x3ea3d70a,0x0004002b,0x00000006,0x000004f7, + 0x3f19999a,0x00040017,0x000004fd,0x00000006,0x00000002,0x00040020,0x000004fe,0x00000007, + 0x000004fd,0x00040020,0x00000500,0x00000009,0x0000000e,0x00040020,0x00000509,0x00000001, + 0x000004fd,0x0004003b,0x00000509,0x0000050a,0x00000001,0x00040020,0x0000050b,0x00000001, + 0x00000006,0x00090019,0x00000552,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000, + 0x00000001,0x00000000,0x0003001b,0x00000553,0x00000552,0x00040020,0x00000554,0x00000000, + 0x00000553,0x0004003b,0x00000554,0x00000555,0x00000000,0x00040020,0x00000621,0x00000003, + 0x0000000e,0x0004003b,0x00000621,0x00000622,0x00000003,0x0004002b,0x00000006,0x0000062c, + 0x41200000,0x0004002b,0x00000006,0x0000062d,0x3f666666,0x0004002b,0x00000025,0x0000062e, + 0x00000040,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x0000000d,0x000004c0,0x00000007,0x0004003b,0x0000000d,0x000004c8,0x00000007, + 0x0004003b,0x0000000d,0x000004cb,0x00000007,0x0004003b,0x0000000d,0x000004d1,0x00000007, + 0x0004003b,0x0000000d,0x000004d5,0x00000007,0x0004003b,0x0000000d,0x000004df,0x00000007, + 0x0004003b,0x0000000d,0x000004f3,0x00000007,0x0004003b,0x000004fe,0x000004ff,0x00000007, + 0x0004003b,0x000004fe,0x00000504,0x00000007,0x0004003b,0x0000000d,0x00000508,0x00000007, + 0x0004003b,0x0000000d,0x00000512,0x00000007,0x0004003b,0x0000000d,0x00000519,0x00000007, + 0x0004003b,0x0000000d,0x0000051c,0x00000007,0x0004003b,0x0000000d,0x0000051f,0x00000007, + 0x0004003b,0x0000000d,0x00000523,0x00000007,0x0004003b,0x00000026,0x00000527,0x00000007, + 0x0004003b,0x00000026,0x0000052b,0x00000007,0x0004003b,0x00000026,0x0000052f,0x00000007, + 0x0004003b,0x00000026,0x00000537,0x00000007,0x0004003b,0x000004fe,0x0000053f,0x00000007, + 0x0004003b,0x0000003b,0x0000054f,0x00000007,0x0004003b,0x00000008,0x00000559,0x00000007, + 0x0004003b,0x0000001b,0x00000561,0x00000007,0x0004003b,0x0000000d,0x00000562,0x00000007, + 0x0004003b,0x0000000d,0x00000565,0x00000007,0x0004003b,0x0000000d,0x00000568,0x00000007, + 0x0004003b,0x0000000d,0x0000056b,0x00000007,0x0004003b,0x0000000d,0x0000056e,0x00000007, + 0x0004003b,0x0000000d,0x00000571,0x00000007,0x0004003b,0x0000000d,0x00000574,0x00000007, + 0x0004003b,0x0000000d,0x00000577,0x00000007,0x0004003b,0x0000000d,0x0000057a,0x00000007, + 0x0004003b,0x0000001b,0x0000057e,0x00000007,0x0004003b,0x0000000d,0x0000057f,0x00000007, + 0x0004003b,0x0000000d,0x00000582,0x00000007,0x0004003b,0x0000000d,0x00000585,0x00000007, + 0x0004003b,0x0000000d,0x00000588,0x00000007,0x0004003b,0x0000000d,0x0000058b,0x00000007, + 0x0004003b,0x0000000d,0x0000058e,0x00000007,0x0004003b,0x0000000d,0x00000591,0x00000007, + 0x0004003b,0x0000000d,0x00000594,0x00000007,0x0004003b,0x0000000d,0x00000597,0x00000007, + 0x0004003b,0x0000001b,0x0000059b,0x00000007,0x0004003b,0x0000000d,0x0000059c,0x00000007, + 0x0004003b,0x0000000d,0x0000059f,0x00000007,0x0004003b,0x0000000d,0x000005a2,0x00000007, + 0x0004003b,0x0000000d,0x000005a5,0x00000007,0x0004003b,0x0000000d,0x000005a8,0x00000007, + 0x0004003b,0x0000000d,0x000005ab,0x00000007,0x0004003b,0x0000000d,0x000005ae,0x00000007, + 0x0004003b,0x0000000d,0x000005b1,0x00000007,0x0004003b,0x0000000d,0x000005b4,0x00000007, + 0x0004003b,0x0000001b,0x000005b8,0x00000007,0x0004003b,0x0000000d,0x000005b9,0x00000007, + 0x0004003b,0x0000000d,0x000005bc,0x00000007,0x0004003b,0x0000000d,0x000005bf,0x00000007, + 0x0004003b,0x0000000d,0x000005c2,0x00000007,0x0004003b,0x0000000d,0x000005c5,0x00000007, + 0x0004003b,0x0000000d,0x000005c8,0x00000007,0x0004003b,0x0000000d,0x000005cb,0x00000007, + 0x0004003b,0x0000000d,0x000005ce,0x00000007,0x0004003b,0x0000000d,0x000005d1,0x00000007, + 0x0004003b,0x0000001b,0x000005d5,0x00000007,0x0004003b,0x0000001b,0x000005d6,0x00000007, + 0x0004003b,0x0000001b,0x000005d8,0x00000007,0x0004003b,0x0000001b,0x000005da,0x00000007, + 0x0004003b,0x0000001b,0x000005dc,0x00000007,0x0004003b,0x0000000d,0x000005de,0x00000007, + 0x0004003b,0x0000000d,0x000005e0,0x00000007,0x0004003b,0x0000000d,0x000005e3,0x00000007, + 0x0004003b,0x0000000d,0x000005f0,0x00000007,0x0004003b,0x0000003b,0x000005f1,0x00000007, + 0x0004003b,0x00000026,0x000005f3,0x00000007,0x0004003b,0x00000026,0x000005f5,0x00000007, + 0x0004003b,0x0000003b,0x000005fa,0x00000007,0x0004003b,0x0000000d,0x000005fc,0x00000007, + 0x0004003b,0x0000000d,0x000005fe,0x00000007,0x0004003b,0x00000026,0x00000600,0x00000007, + 0x0004003b,0x00000026,0x00000602,0x00000007,0x0004003b,0x0000001b,0x00000604,0x00000007, + 0x0004003b,0x0000001b,0x00000609,0x00000007,0x0004003b,0x0000000d,0x0000060d,0x00000007, + 0x0004003b,0x00000008,0x0000060e,0x00000007,0x0004003b,0x0000000d,0x00000612,0x00000007, + 0x00050041,0x000004c4,0x000004c5,0x000004c3,0x000002c9,0x0004003d,0x00000006,0x000004c6, + 0x000004c5,0x0008000c,0x00000006,0x000004c7,0x00000001,0x0000002b,0x000004c6,0x0000009a, + 0x000000a8,0x0003003e,0x000004c0,0x000004c7,0x0004003d,0x00000006,0x000004c9,0x000004c0, + 0x00050083,0x00000006,0x000004ca,0x000004c9,0x00000371,0x0003003e,0x000004c8,0x000004ca, + 0x0004003d,0x00000006,0x000004cc,0x000004c8,0x000500be,0x0000009b,0x000004cd,0x000004cc, + 0x0000009a,0x000600a9,0x00000006,0x000004d0,0x000004cd,0x000004ce,0x000004cf,0x0003003e, + 0x000004cb,0x000004d0,0x0004003d,0x00000006,0x000004d2,0x000004c8,0x000500be,0x0000009b, + 0x000004d3,0x000004d2,0x0000009a,0x000600a9,0x00000006,0x000004d4,0x000004d3,0x000004ce, + 0x000000a8,0x0003003e,0x000004d1,0x000004d4,0x0004003d,0x00000006,0x000004d6,0x000004d1, + 0x0003003e,0x000004d5,0x000004d6,0x0004003d,0x00000006,0x000004d8,0x000004c8,0x0004003d, + 0x00000006,0x000004d9,0x000004d1,0x00050085,0x00000006,0x000004da,0x000004d8,0x000004d9, + 0x00050085,0x00000006,0x000004dc,0x000004da,0x000004db,0x00050081,0x00000006,0x000004dd, + 0x000004d7,0x000004dc,0x0007000c,0x00000006,0x000004de,0x00000001,0x00000028,0x0000009a, + 0x000004dd,0x0003003e,0x000002b3,0x000004de,0x0004003d,0x00000006,0x000004e1,0x000004c8, + 0x0004003d,0x00000006,0x000004e2,0x000004cb,0x00050085,0x00000006,0x000004e3,0x000004e1, + 0x000004e2,0x00050085,0x00000006,0x000004e5,0x000004e3,0x000004e4,0x00050081,0x00000006, + 0x000004e6,0x000004e0,0x000004e5,0x0003003e,0x000004df,0x000004e6,0x0004003d,0x00000006, + 0x000004e7,0x000004df,0x0004003d,0x00000006,0x000004e8,0x000002b3,0x00050083,0x00000006, + 0x000004e9,0x000004e7,0x000004e8,0x0003003e,0x000002b0,0x000004e9,0x0004003d,0x00000006, + 0x000004ec,0x000004c8,0x0004003d,0x00000006,0x000004ed,0x000004d5,0x00050085,0x00000006, + 0x000004ee,0x000004ec,0x000004ed,0x00050085,0x00000006,0x000004f0,0x000004ee,0x000004ef, + 0x00050081,0x00000006,0x000004f1,0x000004eb,0x000004f0,0x0007000c,0x00000006,0x000004f2, + 0x00000001,0x00000028,0x000004ea,0x000004f1,0x0003003e,0x000002be,0x000004f2,0x0004003d, + 0x00000006,0x000004f4,0x000004c8,0x0004003d,0x00000006,0x000004f5,0x000004d5,0x00050085, + 0x00000006,0x000004f6,0x000004f4,0x000004f5,0x00050085,0x00000006,0x000004f8,0x000004f6, + 0x000004f7,0x00050081,0x00000006,0x000004f9,0x00000371,0x000004f8,0x0003003e,0x000004f3, + 0x000004f9,0x0004003d,0x00000006,0x000004fa,0x000004f3,0x0004003d,0x00000006,0x000004fb, + 0x000002be,0x00050083,0x00000006,0x000004fc,0x000004fa,0x000004fb,0x0003003e,0x000002bb, + 0x000004fc,0x00050041,0x00000500,0x00000501,0x000004c3,0x000002a3,0x0004003d,0x0000000e, + 0x00000502,0x00000501,0x0007004f,0x000004fd,0x00000503,0x00000502,0x00000502,0x00000002, + 0x00000003,0x0003003e,0x000004ff,0x00000503,0x00050041,0x00000500,0x00000505,0x000004c3, + 0x000002a3,0x0004003d,0x0000000e,0x00000506,0x00000505,0x0007004f,0x000004fd,0x00000507, + 0x00000506,0x00000506,0x00000000,0x00000001,0x0003003e,0x00000504,0x00000507,0x00050041, + 0x0000050b,0x0000050c,0x0000050a,0x00000320,0x0004003d,0x00000006,0x0000050d,0x0000050c, + 0x00050041,0x0000000d,0x0000050e,0x000004ff,0x00000320,0x0004003d,0x00000006,0x0000050f, + 0x0000050e,0x00050085,0x00000006,0x00000510,0x0000050d,0x0000050f,0x00050083,0x00000006, + 0x00000511,0x00000510,0x00000371,0x0003003e,0x00000508,0x00000511,0x00050041,0x0000050b, + 0x00000513,0x0000050a,0x00000345,0x0004003d,0x00000006,0x00000514,0x00000513,0x00050041, + 0x0000000d,0x00000515,0x000004ff,0x00000345,0x0004003d,0x00000006,0x00000516,0x00000515, + 0x00050085,0x00000006,0x00000517,0x00000514,0x00000516,0x00050083,0x00000006,0x00000518, + 0x00000517,0x00000371,0x0003003e,0x00000512,0x00000518,0x0004003d,0x00000006,0x0000051a, + 0x00000508,0x0006000c,0x00000006,0x0000051b,0x00000001,0x00000008,0x0000051a,0x0003003e, + 0x00000519,0x0000051b,0x0004003d,0x00000006,0x0000051d,0x00000512,0x0006000c,0x00000006, + 0x0000051e,0x00000001,0x00000008,0x0000051d,0x0003003e,0x0000051c,0x0000051e,0x0004003d, + 0x00000006,0x00000520,0x00000508,0x0004003d,0x00000006,0x00000521,0x00000519,0x00050083, + 0x00000006,0x00000522,0x00000520,0x00000521,0x0003003e,0x0000051f,0x00000522,0x0004003d, + 0x00000006,0x00000524,0x00000512,0x0004003d,0x00000006,0x00000525,0x0000051c,0x00050083, + 0x00000006,0x00000526,0x00000524,0x00000525,0x0003003e,0x00000523,0x00000526,0x0004003d, + 0x00000006,0x00000528,0x0000051f,0x00050085,0x00000006,0x00000529,0x00000528,0x0000040a, + 0x0004006e,0x00000025,0x0000052a,0x00000529,0x0003003e,0x00000527,0x0000052a,0x0004003d, + 0x00000006,0x0000052c,0x00000523,0x00050085,0x00000006,0x0000052d,0x0000052c,0x0000040a, + 0x0004006e,0x00000025,0x0000052e,0x0000052d,0x0003003e,0x0000052b,0x0000052e,0x0003003e, + 0x0000052f,0x00000150,0x000200f9,0x00000530,0x000200f8,0x00000530,0x000400f6,0x00000532, + 0x00000533,0x00000000,0x000200f9,0x00000534,0x000200f8,0x00000534,0x0004003d,0x00000025, + 0x00000535,0x0000052f,0x000500b1,0x0000009b,0x00000536,0x00000535,0x0000015c,0x000400fa, + 0x00000536,0x00000531,0x00000532,0x000200f8,0x00000531,0x0003003e,0x00000537,0x00000150, + 0x000200f9,0x00000538,0x000200f8,0x00000538,0x000400f6,0x0000053a,0x0000053b,0x00000000, + 0x000200f9,0x0000053c,0x000200f8,0x0000053c,0x0004003d,0x00000025,0x0000053d,0x00000537, + 0x000500b1,0x0000009b,0x0000053e,0x0000053d,0x0000015c,0x000400fa,0x0000053e,0x00000539, + 0x0000053a,0x000200f8,0x00000539,0x0004003d,0x00000006,0x00000540,0x00000519,0x0004003d, + 0x00000025,0x00000541,0x00000537,0x0004006f,0x00000006,0x00000542,0x00000541,0x00050081, + 0x00000006,0x00000543,0x00000540,0x00000542,0x00050083,0x00000006,0x00000544,0x00000543, + 0x00000146,0x0004003d,0x00000006,0x00000545,0x0000051c,0x0004003d,0x00000025,0x00000546, + 0x0000052f,0x0004006f,0x00000006,0x00000547,0x00000546,0x00050081,0x00000006,0x00000548, + 0x00000545,0x00000547,0x00050083,0x00000006,0x00000549,0x00000548,0x00000146,0x00050050, + 0x000004fd,0x0000054a,0x00000544,0x00000549,0x00050050,0x000004fd,0x0000054b,0x00000371, + 0x00000371,0x00050081,0x000004fd,0x0000054c,0x0000054a,0x0000054b,0x0004003d,0x000004fd, + 0x0000054d,0x00000504,0x00050085,0x000004fd,0x0000054e,0x0000054c,0x0000054d,0x0003003e, + 0x0000053f,0x0000054e,0x0004003d,0x00000025,0x00000550,0x0000052f,0x0004003d,0x00000025, + 0x00000551,0x00000537,0x0004003d,0x00000553,0x00000556,0x00000555,0x0004003d,0x000004fd, + 0x00000557,0x0000053f,0x00070058,0x0000000e,0x00000558,0x00000556,0x00000557,0x00000002, + 0x0000009a,0x0008004f,0x00000007,0x0000055a,0x00000558,0x00000558,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000559,0x0000055a,0x00050039,0x00000006,0x0000055b,0x0000000b, + 0x00000559,0x00060041,0x0000000d,0x0000055c,0x0000054f,0x00000550,0x00000551,0x0003003e, + 0x0000055c,0x0000055b,0x000200f9,0x0000053b,0x000200f8,0x0000053b,0x0004003d,0x00000025, + 0x0000055d,0x00000537,0x00050080,0x00000025,0x0000055e,0x0000055d,0x000002a3,0x0003003e, + 0x00000537,0x0000055e,0x000200f9,0x00000538,0x000200f8,0x0000053a,0x000200f9,0x00000533, + 0x000200f8,0x00000533,0x0004003d,0x00000025,0x0000055f,0x0000052f,0x00050080,0x00000025, + 0x00000560,0x0000055f,0x000002a3,0x0003003e,0x0000052f,0x00000560,0x000200f9,0x00000530, + 0x000200f8,0x00000532,0x00060041,0x0000000d,0x00000563,0x0000054f,0x000002a3,0x000002a3, + 0x0004003d,0x00000006,0x00000564,0x00000563,0x0003003e,0x00000562,0x00000564,0x00060041, + 0x0000000d,0x00000566,0x0000054f,0x000002a3,0x000002c9,0x0004003d,0x00000006,0x00000567, + 0x00000566,0x0003003e,0x00000565,0x00000567,0x00060041,0x0000000d,0x00000569,0x0000054f, + 0x000002a3,0x000002ca,0x0004003d,0x00000006,0x0000056a,0x00000569,0x0003003e,0x00000568, + 0x0000056a,0x00060041,0x0000000d,0x0000056c,0x0000054f,0x000002c9,0x000002a3,0x0004003d, + 0x00000006,0x0000056d,0x0000056c,0x0003003e,0x0000056b,0x0000056d,0x00060041,0x0000000d, + 0x0000056f,0x0000054f,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x00000570,0x0000056f, + 0x0003003e,0x0000056e,0x00000570,0x00060041,0x0000000d,0x00000572,0x0000054f,0x000002c9, + 0x000002ca,0x0004003d,0x00000006,0x00000573,0x00000572,0x0003003e,0x00000571,0x00000573, + 0x00060041,0x0000000d,0x00000575,0x0000054f,0x000002ca,0x000002a3,0x0004003d,0x00000006, + 0x00000576,0x00000575,0x0003003e,0x00000574,0x00000576,0x00060041,0x0000000d,0x00000578, + 0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000579,0x00000578,0x0003003e, + 0x00000577,0x00000579,0x00060041,0x0000000d,0x0000057b,0x0000054f,0x000002ca,0x000002ca, + 0x0004003d,0x00000006,0x0000057c,0x0000057b,0x0003003e,0x0000057a,0x0000057c,0x000d0039, + 0x0000000e,0x0000057d,0x00000019,0x00000562,0x00000565,0x00000568,0x0000056b,0x0000056e, + 0x00000571,0x00000574,0x00000577,0x0000057a,0x0003003e,0x00000561,0x0000057d,0x00060041, + 0x0000000d,0x00000580,0x0000054f,0x000002a3,0x000002c9,0x0004003d,0x00000006,0x00000581, + 0x00000580,0x0003003e,0x0000057f,0x00000581,0x00060041,0x0000000d,0x00000583,0x0000054f, + 0x000002a3,0x000002ca,0x0004003d,0x00000006,0x00000584,0x00000583,0x0003003e,0x00000582, + 0x00000584,0x00060041,0x0000000d,0x00000586,0x0000054f,0x000002a3,0x000002cb,0x0004003d, + 0x00000006,0x00000587,0x00000586,0x0003003e,0x00000585,0x00000587,0x00060041,0x0000000d, + 0x00000589,0x0000054f,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x0000058a,0x00000589, + 0x0003003e,0x00000588,0x0000058a,0x00060041,0x0000000d,0x0000058c,0x0000054f,0x000002c9, + 0x000002ca,0x0004003d,0x00000006,0x0000058d,0x0000058c,0x0003003e,0x0000058b,0x0000058d, + 0x00060041,0x0000000d,0x0000058f,0x0000054f,0x000002c9,0x000002cb,0x0004003d,0x00000006, + 0x00000590,0x0000058f,0x0003003e,0x0000058e,0x00000590,0x00060041,0x0000000d,0x00000592, + 0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000593,0x00000592,0x0003003e, + 0x00000591,0x00000593,0x00060041,0x0000000d,0x00000595,0x0000054f,0x000002ca,0x000002ca, + 0x0004003d,0x00000006,0x00000596,0x00000595,0x0003003e,0x00000594,0x00000596,0x00060041, + 0x0000000d,0x00000598,0x0000054f,0x000002ca,0x000002cb,0x0004003d,0x00000006,0x00000599, + 0x00000598,0x0003003e,0x00000597,0x00000599,0x000d0039,0x0000000e,0x0000059a,0x00000019, + 0x0000057f,0x00000582,0x00000585,0x00000588,0x0000058b,0x0000058e,0x00000591,0x00000594, + 0x00000597,0x0003003e,0x0000057e,0x0000059a,0x00060041,0x0000000d,0x0000059d,0x0000054f, + 0x000002c9,0x000002a3,0x0004003d,0x00000006,0x0000059e,0x0000059d,0x0003003e,0x0000059c, + 0x0000059e,0x00060041,0x0000000d,0x000005a0,0x0000054f,0x000002c9,0x000002c9,0x0004003d, + 0x00000006,0x000005a1,0x000005a0,0x0003003e,0x0000059f,0x000005a1,0x00060041,0x0000000d, + 0x000005a3,0x0000054f,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x000005a4,0x000005a3, + 0x0003003e,0x000005a2,0x000005a4,0x00060041,0x0000000d,0x000005a6,0x0000054f,0x000002ca, + 0x000002a3,0x0004003d,0x00000006,0x000005a7,0x000005a6,0x0003003e,0x000005a5,0x000005a7, + 0x00060041,0x0000000d,0x000005a9,0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006, + 0x000005aa,0x000005a9,0x0003003e,0x000005a8,0x000005aa,0x00060041,0x0000000d,0x000005ac, + 0x0000054f,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x000005ad,0x000005ac,0x0003003e, + 0x000005ab,0x000005ad,0x00060041,0x0000000d,0x000005af,0x0000054f,0x000002cb,0x000002a3, + 0x0004003d,0x00000006,0x000005b0,0x000005af,0x0003003e,0x000005ae,0x000005b0,0x00060041, + 0x0000000d,0x000005b2,0x0000054f,0x000002cb,0x000002c9,0x0004003d,0x00000006,0x000005b3, + 0x000005b2,0x0003003e,0x000005b1,0x000005b3,0x00060041,0x0000000d,0x000005b5,0x0000054f, + 0x000002cb,0x000002ca,0x0004003d,0x00000006,0x000005b6,0x000005b5,0x0003003e,0x000005b4, + 0x000005b6,0x000d0039,0x0000000e,0x000005b7,0x00000019,0x0000059c,0x0000059f,0x000005a2, + 0x000005a5,0x000005a8,0x000005ab,0x000005ae,0x000005b1,0x000005b4,0x0003003e,0x0000059b, + 0x000005b7,0x00060041,0x0000000d,0x000005ba,0x0000054f,0x000002c9,0x000002c9,0x0004003d, + 0x00000006,0x000005bb,0x000005ba,0x0003003e,0x000005b9,0x000005bb,0x00060041,0x0000000d, + 0x000005bd,0x0000054f,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x000005be,0x000005bd, + 0x0003003e,0x000005bc,0x000005be,0x00060041,0x0000000d,0x000005c0,0x0000054f,0x000002c9, + 0x000002cb,0x0004003d,0x00000006,0x000005c1,0x000005c0,0x0003003e,0x000005bf,0x000005c1, + 0x00060041,0x0000000d,0x000005c3,0x0000054f,0x000002ca,0x000002c9,0x0004003d,0x00000006, + 0x000005c4,0x000005c3,0x0003003e,0x000005c2,0x000005c4,0x00060041,0x0000000d,0x000005c6, + 0x0000054f,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x000005c7,0x000005c6,0x0003003e, + 0x000005c5,0x000005c7,0x00060041,0x0000000d,0x000005c9,0x0000054f,0x000002ca,0x000002cb, + 0x0004003d,0x00000006,0x000005ca,0x000005c9,0x0003003e,0x000005c8,0x000005ca,0x00060041, + 0x0000000d,0x000005cc,0x0000054f,0x000002cb,0x000002c9,0x0004003d,0x00000006,0x000005cd, + 0x000005cc,0x0003003e,0x000005cb,0x000005cd,0x00060041,0x0000000d,0x000005cf,0x0000054f, + 0x000002cb,0x000002ca,0x0004003d,0x00000006,0x000005d0,0x000005cf,0x0003003e,0x000005ce, + 0x000005d0,0x00060041,0x0000000d,0x000005d2,0x0000054f,0x000002cb,0x000002cb,0x0004003d, + 0x00000006,0x000005d3,0x000005d2,0x0003003e,0x000005d1,0x000005d3,0x000d0039,0x0000000e, + 0x000005d4,0x00000019,0x000005b9,0x000005bc,0x000005bf,0x000005c2,0x000005c5,0x000005c8, + 0x000005cb,0x000005ce,0x000005d1,0x0003003e,0x000005b8,0x000005d4,0x0004003d,0x0000000e, + 0x000005d7,0x00000561,0x0003003e,0x000005d6,0x000005d7,0x0004003d,0x0000000e,0x000005d9, + 0x0000057e,0x0003003e,0x000005d8,0x000005d9,0x0004003d,0x0000000e,0x000005db,0x0000059b, + 0x0003003e,0x000005da,0x000005db,0x0004003d,0x0000000e,0x000005dd,0x000005b8,0x0003003e, + 0x000005dc,0x000005dd,0x0004003d,0x00000006,0x000005df,0x0000051f,0x0003003e,0x000005de, + 0x000005df,0x0004003d,0x00000006,0x000005e1,0x00000523,0x0003003e,0x000005e0,0x000005e1, + 0x000a0039,0x0000000e,0x000005e2,0x00000023,0x000005d6,0x000005d8,0x000005da,0x000005dc, + 0x000005de,0x000005e0,0x0003003e,0x000005d5,0x000005e2,0x00050041,0x0000000d,0x000005e4, + 0x000005d5,0x00000320,0x0004003d,0x00000006,0x000005e5,0x000005e4,0x00050083,0x00000006, + 0x000005e6,0x000000a8,0x000005e5,0x00050041,0x0000000d,0x000005e7,0x000005d5,0x00000345, + 0x0004003d,0x00000006,0x000005e8,0x000005e7,0x00050083,0x00000006,0x000005e9,0x000005e6, + 0x000005e8,0x00050041,0x0000000d,0x000005ea,0x000005d5,0x0000036a,0x0004003d,0x00000006, + 0x000005eb,0x000005ea,0x00050083,0x00000006,0x000005ec,0x000005e9,0x000005eb,0x00050041, + 0x0000000d,0x000005ed,0x000005d5,0x00000416,0x0004003d,0x00000006,0x000005ee,0x000005ed, + 0x00050083,0x00000006,0x000005ef,0x000005ec,0x000005ee,0x0003003e,0x000005e3,0x000005ef, + 0x0004003d,0x0000003a,0x000005f2,0x0000054f,0x0003003e,0x000005f1,0x000005f2,0x0004003d, + 0x00000025,0x000005f4,0x00000527,0x0003003e,0x000005f3,0x000005f4,0x0004003d,0x00000025, + 0x000005f6,0x0000052b,0x0003003e,0x000005f5,0x000005f6,0x00070039,0x00000006,0x000005f7, + 0x00000040,0x000005f1,0x000005f3,0x000005f5,0x0004003d,0x00000006,0x000005f8,0x000005e3, + 0x00050085,0x00000006,0x000005f9,0x000005f7,0x000005f8,0x0003003e,0x000005f0,0x000005f9, + 0x0004003d,0x0000003a,0x000005fb,0x0000054f,0x0003003e,0x000005fa,0x000005fb,0x0004003d, + 0x00000006,0x000005fd,0x0000051f,0x0003003e,0x000005fc,0x000005fd,0x0004003d,0x00000006, + 0x000005ff,0x00000523,0x0003003e,0x000005fe,0x000005ff,0x0004003d,0x00000025,0x00000601, + 0x00000527,0x0003003e,0x00000600,0x00000601,0x0004003d,0x00000025,0x00000603,0x0000052b, + 0x0003003e,0x00000602,0x00000603,0x0004003d,0x0000000e,0x00000605,0x000005d5,0x0003003e, + 0x00000604,0x00000605,0x000a0039,0x00000006,0x00000606,0x00000049,0x000005fa,0x000005fc, + 0x000005fe,0x00000600,0x00000602,0x00000604,0x0004003d,0x00000006,0x00000607,0x000005f0, + 0x00050081,0x00000006,0x00000608,0x00000607,0x00000606,0x0003003e,0x000005f0,0x00000608, + 0x0004003d,0x00000553,0x0000060a,0x00000555,0x0004003d,0x000004fd,0x0000060b,0x0000050a, + 0x00050057,0x0000000e,0x0000060c,0x0000060a,0x0000060b,0x0003003e,0x00000609,0x0000060c, + 0x0004003d,0x0000000e,0x0000060f,0x00000609,0x0008004f,0x00000007,0x00000610,0x0000060f, + 0x0000060f,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000060e,0x00000610,0x00050039, + 0x00000006,0x00000611,0x0000000b,0x0000060e,0x0003003e,0x0000060d,0x00000611,0x0004003d, + 0x00000006,0x00000613,0x000005f0,0x0004003d,0x00000006,0x00000614,0x0000060d,0x00050083, + 0x00000006,0x00000615,0x00000613,0x00000614,0x0003003e,0x00000612,0x00000615,0x0004003d, + 0x00000006,0x00000616,0x00000612,0x00060050,0x00000007,0x00000617,0x00000616,0x00000616, + 0x00000616,0x0004003d,0x0000000e,0x00000618,0x00000609,0x0008004f,0x00000007,0x00000619, + 0x00000618,0x00000618,0x00000000,0x00000001,0x00000002,0x00050081,0x00000007,0x0000061a, + 0x00000619,0x00000617,0x00050041,0x0000000d,0x0000061b,0x00000609,0x00000320,0x00050051, + 0x00000006,0x0000061c,0x0000061a,0x00000000,0x0003003e,0x0000061b,0x0000061c,0x00050041, + 0x0000000d,0x0000061d,0x00000609,0x00000345,0x00050051,0x00000006,0x0000061e,0x0000061a, + 0x00000001,0x0003003e,0x0000061d,0x0000061e,0x00050041,0x0000000d,0x0000061f,0x00000609, + 0x0000036a,0x00050051,0x00000006,0x00000620,0x0000061a,0x00000002,0x0003003e,0x0000061f, + 0x00000620,0x0004003d,0x0000000e,0x00000623,0x00000609,0x0008004f,0x00000007,0x00000624, + 0x00000623,0x00000623,0x00000000,0x00000001,0x00000002,0x00060050,0x00000007,0x00000625, + 0x0000009a,0x0000009a,0x0000009a,0x00060050,0x00000007,0x00000626,0x000000a8,0x000000a8, + 0x000000a8,0x0008000c,0x00000007,0x00000627,0x00000001,0x0000002b,0x00000624,0x00000625, + 0x00000626,0x00050051,0x00000006,0x00000628,0x00000627,0x00000000,0x00050051,0x00000006, + 0x00000629,0x00000627,0x00000001,0x00050051,0x00000006,0x0000062a,0x00000627,0x00000002, + 0x00070050,0x0000000e,0x0000062b,0x00000628,0x00000629,0x0000062a,0x000000a8,0x0003003e, + 0x00000622,0x0000062b,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000b,0x00000000, + 0x00000009,0x00030037,0x00000008,0x0000000a,0x000200f8,0x0000000c,0x0004003d,0x00000007, + 0x0000004b,0x0000000a,0x00050094,0x00000006,0x00000050,0x0000004b,0x0000004f,0x000200fe, + 0x00000050,0x00010038,0x00050036,0x0000000e,0x00000019,0x00000000,0x0000000f,0x00030037, + 0x0000000d,0x00000010,0x00030037,0x0000000d,0x00000011,0x00030037,0x0000000d,0x00000012, + 0x00030037,0x0000000d,0x00000013,0x00030037,0x0000000d,0x00000014,0x00030037,0x0000000d, + 0x00000015,0x00030037,0x0000000d,0x00000016,0x00030037,0x0000000d,0x00000017,0x00030037, + 0x0000000d,0x00000018,0x000200f8,0x0000001a,0x0004003b,0x0000000d,0x00000053,0x00000007, + 0x0004003b,0x0000000d,0x00000060,0x00000007,0x0004003b,0x0000000d,0x0000006d,0x00000007, + 0x0004003b,0x0000000d,0x0000007a,0x00000007,0x0004003b,0x0000000d,0x00000087,0x00000007, + 0x0004003b,0x0000000d,0x0000008b,0x00000007,0x0004003b,0x0000000d,0x0000008f,0x00000007, + 0x0004003b,0x0000000d,0x00000093,0x00000007,0x0004003b,0x0000000d,0x000000a1,0x00000007, + 0x0004003b,0x0000000d,0x000000a7,0x00000007,0x0004003b,0x000000ab,0x000000ac,0x00000007, + 0x0004003b,0x000000ab,0x000000ba,0x00000007,0x0004003b,0x000000ab,0x000000c6,0x00000007, + 0x0004003b,0x000000ab,0x000000ca,0x00000007,0x0004003b,0x0000000d,0x000000ce,0x00000007, + 0x0004003b,0x0000000d,0x000000d4,0x00000007,0x0004003b,0x0000000d,0x000000da,0x00000007, + 0x0004003b,0x0000000d,0x000000e0,0x00000007,0x0004003b,0x0000000d,0x000000e7,0x00000007, + 0x0004003b,0x0000000d,0x000000ed,0x00000007,0x0004003d,0x00000006,0x00000054,0x00000010, + 0x0004003d,0x00000006,0x00000055,0x00000011,0x00050081,0x00000006,0x00000056,0x00000054, + 0x00000055,0x0004003d,0x00000006,0x00000057,0x00000012,0x00050081,0x00000006,0x00000058, + 0x00000056,0x00000057,0x0004003d,0x00000006,0x00000059,0x00000016,0x00050083,0x00000006, + 0x0000005a,0x00000058,0x00000059,0x0004003d,0x00000006,0x0000005b,0x00000017,0x00050083, + 0x00000006,0x0000005c,0x0000005a,0x0000005b,0x0004003d,0x00000006,0x0000005d,0x00000018, + 0x00050083,0x00000006,0x0000005e,0x0000005c,0x0000005d,0x0006000c,0x00000006,0x0000005f, + 0x00000001,0x00000004,0x0000005e,0x0003003e,0x00000053,0x0000005f,0x0004003d,0x00000006, + 0x00000061,0x00000013,0x0004003d,0x00000006,0x00000062,0x00000010,0x00050081,0x00000006, + 0x00000063,0x00000061,0x00000062,0x0004003d,0x00000006,0x00000064,0x00000011,0x00050081, + 0x00000006,0x00000065,0x00000063,0x00000064,0x0004003d,0x00000006,0x00000066,0x00000017, + 0x00050083,0x00000006,0x00000067,0x00000065,0x00000066,0x0004003d,0x00000006,0x00000068, + 0x00000018,0x00050083,0x00000006,0x00000069,0x00000067,0x00000068,0x0004003d,0x00000006, + 0x0000006a,0x00000015,0x00050083,0x00000006,0x0000006b,0x00000069,0x0000006a,0x0006000c, + 0x00000006,0x0000006c,0x00000001,0x00000004,0x0000006b,0x0003003e,0x00000060,0x0000006c, + 0x0004003d,0x00000006,0x0000006e,0x00000010,0x0004003d,0x00000006,0x0000006f,0x00000013, + 0x00050081,0x00000006,0x00000070,0x0000006e,0x0000006f,0x0004003d,0x00000006,0x00000071, + 0x00000016,0x00050081,0x00000006,0x00000072,0x00000070,0x00000071,0x0004003d,0x00000006, + 0x00000073,0x00000012,0x00050083,0x00000006,0x00000074,0x00000072,0x00000073,0x0004003d, + 0x00000006,0x00000075,0x00000015,0x00050083,0x00000006,0x00000076,0x00000074,0x00000075, + 0x0004003d,0x00000006,0x00000077,0x00000018,0x00050083,0x00000006,0x00000078,0x00000076, + 0x00000077,0x0006000c,0x00000006,0x00000079,0x00000001,0x00000004,0x00000078,0x0003003e, + 0x0000006d,0x00000079,0x0004003d,0x00000006,0x0000007b,0x00000013,0x0004003d,0x00000006, + 0x0000007c,0x00000016,0x00050081,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x0004003d, + 0x00000006,0x0000007e,0x00000017,0x00050081,0x00000006,0x0000007f,0x0000007d,0x0000007e, + 0x0004003d,0x00000006,0x00000080,0x00000011,0x00050083,0x00000006,0x00000081,0x0000007f, + 0x00000080,0x0004003d,0x00000006,0x00000082,0x00000012,0x00050083,0x00000006,0x00000083, + 0x00000081,0x00000082,0x0004003d,0x00000006,0x00000084,0x00000015,0x00050083,0x00000006, + 0x00000085,0x00000083,0x00000084,0x0006000c,0x00000006,0x00000086,0x00000001,0x00000004, + 0x00000085,0x0003003e,0x0000007a,0x00000086,0x0004003d,0x00000006,0x00000088,0x00000053, + 0x0004003d,0x00000006,0x00000089,0x0000006d,0x0007000c,0x00000006,0x0000008a,0x00000001, + 0x00000028,0x00000088,0x00000089,0x0003003e,0x00000087,0x0000008a,0x0004003d,0x00000006, + 0x0000008c,0x00000053,0x0004003d,0x00000006,0x0000008d,0x0000006d,0x0007000c,0x00000006, + 0x0000008e,0x00000001,0x00000025,0x0000008c,0x0000008d,0x0003003e,0x0000008b,0x0000008e, + 0x0004003d,0x00000006,0x00000090,0x00000060,0x0004003d,0x00000006,0x00000091,0x0000007a, + 0x0007000c,0x00000006,0x00000092,0x00000001,0x00000028,0x00000090,0x00000091,0x0003003e, + 0x0000008f,0x00000092,0x0004003d,0x00000006,0x00000094,0x00000060,0x0004003d,0x00000006, + 0x00000095,0x0000007a,0x0007000c,0x00000006,0x00000096,0x00000001,0x00000025,0x00000094, + 0x00000095,0x0003003e,0x00000093,0x00000096,0x0004003d,0x00000006,0x00000097,0x00000087, + 0x0004003d,0x00000006,0x00000098,0x0000008f,0x00050081,0x00000006,0x00000099,0x00000097, + 0x00000098,0x000500b4,0x0000009b,0x0000009c,0x00000099,0x0000009a,0x000300f7,0x0000009e, + 0x00000000,0x000400fa,0x0000009c,0x0000009d,0x0000009e,0x000200f8,0x0000009d,0x000200fe, + 0x0000009f,0x000200f8,0x0000009e,0x0004003d,0x00000006,0x000000a2,0x00000087,0x0004003d, + 0x00000006,0x000000a3,0x00000087,0x0004003d,0x00000006,0x000000a4,0x0000008f,0x00050081, + 0x00000006,0x000000a5,0x000000a3,0x000000a4,0x00050088,0x00000006,0x000000a6,0x000000a2, + 0x000000a5,0x0003003e,0x000000a1,0x000000a6,0x0004003d,0x00000006,0x000000a9,0x000000a1, + 0x00050083,0x00000006,0x000000aa,0x000000a8,0x000000a9,0x0003003e,0x000000a7,0x000000aa, + 0x0004003d,0x00000006,0x000000ad,0x00000087,0x0004003d,0x00000006,0x000000ae,0x0000008b, + 0x00050085,0x00000006,0x000000b0,0x000000ae,0x000000af,0x000500ba,0x0000009b,0x000000b1, + 0x000000ad,0x000000b0,0x0004003d,0x00000006,0x000000b2,0x00000087,0x000500ba,0x0000009b, + 0x000000b4,0x000000b2,0x000000b3,0x000500a7,0x0000009b,0x000000b5,0x000000b1,0x000000b4, + 0x0004003d,0x00000006,0x000000b6,0x00000087,0x0004003d,0x00000006,0x000000b7,0x00000093, + 0x000500ba,0x0000009b,0x000000b8,0x000000b6,0x000000b7,0x000500a7,0x0000009b,0x000000b9, + 0x000000b5,0x000000b8,0x0003003e,0x000000ac,0x000000b9,0x0004003d,0x00000006,0x000000bb, + 0x0000008f,0x0004003d,0x00000006,0x000000bc,0x00000093,0x00050085,0x00000006,0x000000bd, + 0x000000bc,0x000000af,0x000500ba,0x0000009b,0x000000be,0x000000bb,0x000000bd,0x0004003d, + 0x00000006,0x000000bf,0x0000008f,0x000500ba,0x0000009b,0x000000c0,0x000000bf,0x000000b3, + 0x000500a7,0x0000009b,0x000000c1,0x000000be,0x000000c0,0x0004003d,0x00000006,0x000000c2, + 0x0000008f,0x0004003d,0x00000006,0x000000c3,0x0000008b,0x000500ba,0x0000009b,0x000000c4, + 0x000000c2,0x000000c3,0x000500a7,0x0000009b,0x000000c5,0x000000c1,0x000000c4,0x0003003e, + 0x000000ba,0x000000c5,0x0004003d,0x00000006,0x000000c7,0x00000087,0x0004003d,0x00000006, + 0x000000c8,0x00000053,0x000500b4,0x0000009b,0x000000c9,0x000000c7,0x000000c8,0x0003003e, + 0x000000c6,0x000000c9,0x0004003d,0x00000006,0x000000cb,0x0000008f,0x0004003d,0x00000006, + 0x000000cc,0x00000060,0x000500b4,0x0000009b,0x000000cd,0x000000cb,0x000000cc,0x0003003e, + 0x000000ca,0x000000cd,0x0004003d,0x0000009b,0x000000cf,0x000000ac,0x0004003d,0x0000009b, + 0x000000d0,0x000000ba,0x000500a7,0x0000009b,0x000000d1,0x000000cf,0x000000d0,0x0004003d, + 0x00000006,0x000000d2,0x000000a1,0x000600a9,0x00000006,0x000000d3,0x000000d1,0x000000d2, + 0x000000a8,0x0003003e,0x000000ce,0x000000d3,0x0004003d,0x0000009b,0x000000d5,0x000000ac, + 0x0004003d,0x0000009b,0x000000d6,0x000000ba,0x000500a7,0x0000009b,0x000000d7,0x000000d5, + 0x000000d6,0x0004003d,0x00000006,0x000000d8,0x000000a7,0x000600a9,0x00000006,0x000000d9, + 0x000000d7,0x000000d8,0x000000a8,0x0003003e,0x000000d4,0x000000d9,0x0004003d,0x0000009b, + 0x000000db,0x000000ac,0x0004003d,0x0000009b,0x000000dc,0x000000c6,0x000500a7,0x0000009b, + 0x000000dd,0x000000db,0x000000dc,0x0004003d,0x00000006,0x000000de,0x000000ce,0x000600a9, + 0x00000006,0x000000df,0x000000dd,0x000000de,0x0000009a,0x0003003e,0x000000da,0x000000df, + 0x0004003d,0x0000009b,0x000000e1,0x000000ac,0x0004003d,0x0000009b,0x000000e2,0x000000c6, + 0x000400a8,0x0000009b,0x000000e3,0x000000e2,0x000500a7,0x0000009b,0x000000e4,0x000000e1, + 0x000000e3,0x0004003d,0x00000006,0x000000e5,0x000000ce,0x000600a9,0x00000006,0x000000e6, + 0x000000e4,0x000000e5,0x0000009a,0x0003003e,0x000000e0,0x000000e6,0x0004003d,0x0000009b, + 0x000000e8,0x000000ba,0x0004003d,0x0000009b,0x000000e9,0x000000ca,0x000500a7,0x0000009b, + 0x000000ea,0x000000e8,0x000000e9,0x0004003d,0x00000006,0x000000eb,0x000000d4,0x000600a9, + 0x00000006,0x000000ec,0x000000ea,0x000000eb,0x0000009a,0x0003003e,0x000000e7,0x000000ec, + 0x0004003d,0x0000009b,0x000000ee,0x000000ba,0x0004003d,0x0000009b,0x000000ef,0x000000ca, + 0x000400a8,0x0000009b,0x000000f0,0x000000ef,0x000500a7,0x0000009b,0x000000f1,0x000000ee, + 0x000000f0,0x0004003d,0x00000006,0x000000f2,0x000000d4,0x000600a9,0x00000006,0x000000f3, + 0x000000f1,0x000000f2,0x0000009a,0x0003003e,0x000000ed,0x000000f3,0x0004003d,0x00000006, + 0x000000f4,0x000000da,0x0004003d,0x00000006,0x000000f5,0x000000e0,0x0004003d,0x00000006, + 0x000000f6,0x000000e7,0x0004003d,0x00000006,0x000000f7,0x000000ed,0x00070050,0x0000000e, + 0x000000f8,0x000000f4,0x000000f5,0x000000f6,0x000000f7,0x000200fe,0x000000f8,0x00010038, + 0x00050036,0x0000000e,0x00000023,0x00000000,0x0000001c,0x00030037,0x0000001b,0x0000001d, + 0x00030037,0x0000001b,0x0000001e,0x00030037,0x0000001b,0x0000001f,0x00030037,0x0000001b, + 0x00000020,0x00030037,0x0000000d,0x00000021,0x00030037,0x0000000d,0x00000022,0x000200f8, + 0x00000024,0x0004003b,0x0000001b,0x000000fb,0x00000007,0x0004003b,0x0000001b,0x00000101, + 0x00000007,0x0004003d,0x0000000e,0x000000fc,0x0000001d,0x0004003d,0x0000000e,0x000000fd, + 0x0000001e,0x0004003d,0x00000006,0x000000fe,0x00000021,0x00070050,0x0000000e,0x000000ff, + 0x000000fe,0x000000fe,0x000000fe,0x000000fe,0x0008000c,0x0000000e,0x00000100,0x00000001, + 0x0000002e,0x000000fc,0x000000fd,0x000000ff,0x0003003e,0x000000fb,0x00000100,0x0004003d, + 0x0000000e,0x00000102,0x0000001f,0x0004003d,0x0000000e,0x00000103,0x00000020,0x0004003d, + 0x00000006,0x00000104,0x00000021,0x00070050,0x0000000e,0x00000105,0x00000104,0x00000104, + 0x00000104,0x00000104,0x0008000c,0x0000000e,0x00000106,0x00000001,0x0000002e,0x00000102, + 0x00000103,0x00000105,0x0003003e,0x00000101,0x00000106,0x0004003d,0x0000000e,0x00000107, + 0x000000fb,0x0004003d,0x0000000e,0x00000108,0x00000101,0x0004003d,0x00000006,0x00000109, + 0x00000022,0x00070050,0x0000000e,0x0000010a,0x00000109,0x00000109,0x00000109,0x00000109, + 0x0008000c,0x0000000e,0x0000010b,0x00000001,0x0000002e,0x00000107,0x00000108,0x0000010a, + 0x000200fe,0x0000010b,0x00010038,0x00050036,0x00000006,0x0000002f,0x00000000,0x00000027, + 0x00030037,0x0000000d,0x00000028,0x00030037,0x0000000d,0x00000029,0x00030037,0x0000000d, + 0x0000002a,0x00030037,0x0000000d,0x0000002b,0x00030037,0x0000000d,0x0000002c,0x00030037, + 0x0000000d,0x0000002d,0x00030037,0x00000026,0x0000002e,0x000200f8,0x00000030,0x0004003b, + 0x000000ab,0x0000010e,0x00000007,0x0004003b,0x0000000d,0x00000112,0x00000007,0x0004003b, + 0x0000000d,0x00000117,0x00000007,0x0004003b,0x0000000d,0x0000011d,0x00000007,0x0004003b, + 0x0000000d,0x00000127,0x00000007,0x0004003b,0x0000000d,0x0000012d,0x00000007,0x0004003b, + 0x0000000d,0x00000133,0x00000007,0x0004003b,0x0000000d,0x00000137,0x00000007,0x0004003b, + 0x0000000d,0x0000013b,0x00000007,0x0004003d,0x00000025,0x0000010f,0x0000002e,0x000500b3, + 0x0000009b,0x00000111,0x0000010f,0x00000110,0x0003003e,0x0000010e,0x00000111,0x0004003d, + 0x0000009b,0x00000113,0x0000010e,0x0004003d,0x00000006,0x00000114,0x00000028,0x0004003d, + 0x00000006,0x00000115,0x0000002b,0x000600a9,0x00000006,0x00000116,0x00000113,0x00000114, + 0x00000115,0x0003003e,0x00000112,0x00000116,0x0004003d,0x00000006,0x00000118,0x00000029, + 0x0004003d,0x00000006,0x00000119,0x0000002a,0x0007000c,0x00000006,0x0000011a,0x00000001, + 0x00000025,0x00000118,0x00000119,0x0004003d,0x00000006,0x0000011b,0x00000112,0x0007000c, + 0x00000006,0x0000011c,0x00000001,0x00000025,0x0000011a,0x0000011b,0x0003003e,0x00000117, + 0x0000011c,0x0004003d,0x00000006,0x0000011e,0x00000029,0x0004003d,0x00000006,0x0000011f, + 0x0000002a,0x0007000c,0x00000006,0x00000120,0x00000001,0x00000028,0x0000011e,0x0000011f, + 0x0004003d,0x00000006,0x00000121,0x00000112,0x0007000c,0x00000006,0x00000122,0x00000001, + 0x00000028,0x00000120,0x00000121,0x0003003e,0x0000011d,0x00000122,0x0004003d,0x0000009b, + 0x00000123,0x0000010e,0x0004003d,0x00000006,0x00000124,0x0000002a,0x0004003d,0x00000006, + 0x00000125,0x0000002d,0x000600a9,0x00000006,0x00000126,0x00000123,0x00000124,0x00000125, + 0x0003003e,0x00000112,0x00000126,0x0004003d,0x00000006,0x00000128,0x0000002b,0x0004003d, + 0x00000006,0x00000129,0x0000002c,0x0007000c,0x00000006,0x0000012a,0x00000001,0x00000025, + 0x00000128,0x00000129,0x0004003d,0x00000006,0x0000012b,0x00000112,0x0007000c,0x00000006, + 0x0000012c,0x00000001,0x00000025,0x0000012a,0x0000012b,0x0003003e,0x00000127,0x0000012c, + 0x0004003d,0x00000006,0x0000012e,0x0000002b,0x0004003d,0x00000006,0x0000012f,0x0000002c, + 0x0007000c,0x00000006,0x00000130,0x00000001,0x00000028,0x0000012e,0x0000012f,0x0004003d, + 0x00000006,0x00000131,0x00000112,0x0007000c,0x00000006,0x00000132,0x00000001,0x00000028, + 0x00000130,0x00000131,0x0003003e,0x0000012d,0x00000132,0x0004003d,0x00000006,0x00000134, + 0x0000011d,0x0004003d,0x00000006,0x00000135,0x00000117,0x00050083,0x00000006,0x00000136, + 0x00000134,0x00000135,0x0003003e,0x00000133,0x00000136,0x0004003d,0x00000006,0x00000138, + 0x0000012d,0x0004003d,0x00000006,0x00000139,0x00000127,0x00050083,0x00000006,0x0000013a, + 0x00000138,0x00000139,0x0003003e,0x00000137,0x0000013a,0x0004003d,0x00000006,0x0000013c, + 0x00000133,0x0004003d,0x00000006,0x0000013d,0x00000137,0x0007000c,0x00000006,0x0000013e, + 0x00000001,0x00000028,0x0000013c,0x0000013d,0x0004003d,0x00000006,0x0000013f,0x00000133, + 0x0004003d,0x00000006,0x00000140,0x00000137,0x0007000c,0x00000006,0x00000141,0x00000001, + 0x00000025,0x0000013f,0x00000140,0x00050081,0x00000006,0x00000143,0x00000141,0x00000142, + 0x00050088,0x00000006,0x00000144,0x0000013e,0x00000143,0x0003003e,0x0000013b,0x00000144, + 0x0004003d,0x00000006,0x00000145,0x0000013b,0x00050083,0x00000006,0x00000147,0x00000145, + 0x00000146,0x00050085,0x00000006,0x00000149,0x00000147,0x00000148,0x0008000c,0x00000006, + 0x0000014a,0x00000001,0x0000002b,0x00000149,0x0000009a,0x000000a8,0x00050083,0x00000006, + 0x0000014b,0x000000a8,0x0000014a,0x00050085,0x00000006,0x0000014c,0x0000014b,0x000000a8, + 0x000200fe,0x0000014c,0x00010038,0x00050036,0x00000006,0x00000038,0x00000000,0x00000035, + 0x00030037,0x00000034,0x00000036,0x00030037,0x00000026,0x00000037,0x000200f8,0x00000039, + 0x0004003b,0x0000000d,0x00000153,0x00000007,0x0004003b,0x0000000d,0x00000154,0x00000007, + 0x0004003b,0x00000026,0x00000155,0x00000007,0x0004003b,0x00000209,0x0000020a,0x00000007, + 0x0004003b,0x00000209,0x00000299,0x00000007,0x0004003b,0x0000000d,0x000002a5,0x00000007, + 0x0004003b,0x0000000d,0x000002ad,0x00000007,0x0004003b,0x0000000d,0x000002b9,0x00000007, + 0x0004003b,0x0000000d,0x000002cd,0x00000007,0x0004003b,0x0000000d,0x000002d0,0x00000007, + 0x0004003b,0x0000000d,0x000002d3,0x00000007,0x0004003b,0x0000000d,0x000002d6,0x00000007, + 0x0004003b,0x0000000d,0x000002d9,0x00000007,0x0004003b,0x0000000d,0x000002dc,0x00000007, + 0x0004003b,0x00000026,0x000002df,0x00000007,0x0004003d,0x00000025,0x0000014f,0x00000037, + 0x0008000c,0x00000025,0x00000152,0x00000001,0x0000002d,0x0000014f,0x00000150,0x00000151, + 0x0003003e,0x00000037,0x00000152,0x0003003e,0x00000153,0x0000009a,0x0003003e,0x00000154, + 0x0000009a,0x0003003e,0x00000155,0x00000150,0x000200f9,0x00000156,0x000200f8,0x00000156, + 0x000400f6,0x00000158,0x00000159,0x00000000,0x000200f9,0x0000015a,0x000200f8,0x0000015a, + 0x0004003d,0x00000025,0x0000015b,0x00000155,0x000500b1,0x0000009b,0x0000015d,0x0000015b, + 0x0000015c,0x000400fa,0x0000015d,0x00000157,0x00000158,0x000200f8,0x00000157,0x0004003d, + 0x00000025,0x00000205,0x00000037,0x00050084,0x00000025,0x00000206,0x00000205,0x0000015c, + 0x0004003d,0x00000025,0x00000207,0x00000155,0x00050080,0x00000025,0x00000208,0x00000206, + 0x00000207,0x0003003e,0x0000020a,0x00000204,0x00050041,0x0000000d,0x0000020b,0x0000020a, + 0x00000208,0x0004003d,0x00000006,0x0000020c,0x0000020b,0x0004003d,0x00000025,0x0000020d, + 0x00000155,0x00050041,0x0000000d,0x0000020e,0x00000036,0x0000020d,0x0004003d,0x00000006, + 0x0000020f,0x0000020e,0x00050085,0x00000006,0x00000210,0x0000020c,0x0000020f,0x0004003d, + 0x00000006,0x00000211,0x00000153,0x00050081,0x00000006,0x00000212,0x00000211,0x00000210, + 0x0003003e,0x00000153,0x00000212,0x0004003d,0x00000025,0x00000295,0x00000037,0x00050084, + 0x00000025,0x00000296,0x00000295,0x0000015c,0x0004003d,0x00000025,0x00000297,0x00000155, + 0x00050080,0x00000025,0x00000298,0x00000296,0x00000297,0x0003003e,0x00000299,0x00000294, + 0x00050041,0x0000000d,0x0000029a,0x00000299,0x00000298,0x0004003d,0x00000006,0x0000029b, + 0x0000029a,0x0004003d,0x00000025,0x0000029c,0x00000155,0x00050041,0x0000000d,0x0000029d, + 0x00000036,0x0000029c,0x0004003d,0x00000006,0x0000029e,0x0000029d,0x00050085,0x00000006, + 0x0000029f,0x0000029b,0x0000029e,0x0004003d,0x00000006,0x000002a0,0x00000154,0x00050081, + 0x00000006,0x000002a1,0x000002a0,0x0000029f,0x0003003e,0x00000154,0x000002a1,0x000200f9, + 0x00000159,0x000200f8,0x00000159,0x0004003d,0x00000025,0x000002a2,0x00000155,0x00050080, + 0x00000025,0x000002a4,0x000002a2,0x000002a3,0x0003003e,0x00000155,0x000002a4,0x000200f9, + 0x00000156,0x000200f8,0x00000158,0x0004003d,0x00000006,0x000002a6,0x00000153,0x00050083, + 0x00000006,0x000002a8,0x000002a6,0x000002a7,0x00050085,0x00000006,0x000002aa,0x000002a8, + 0x000002a9,0x0008000c,0x00000006,0x000002ab,0x00000001,0x0000002b,0x000002aa,0x0000009a, + 0x000000a8,0x00050083,0x00000006,0x000002ac,0x000000a8,0x000002ab,0x0003003e,0x000002a5, + 0x000002ac,0x0004003d,0x00000006,0x000002ae,0x000002a5,0x0004003d,0x00000006,0x000002b1, + 0x000002b0,0x00050085,0x00000006,0x000002b2,0x000002ae,0x000002b1,0x0004003d,0x00000006, + 0x000002b4,0x000002b3,0x00050081,0x00000006,0x000002b5,0x000002b2,0x000002b4,0x0003003e, + 0x000002ad,0x000002b5,0x0004003d,0x00000006,0x000002b6,0x000002ad,0x0004003d,0x00000006, + 0x000002b7,0x00000154,0x00050085,0x00000006,0x000002b8,0x000002b7,0x000002b6,0x0003003e, + 0x00000154,0x000002b8,0x0004003d,0x00000006,0x000002ba,0x000002a5,0x0004003d,0x00000006, + 0x000002bc,0x000002bb,0x00050085,0x00000006,0x000002bd,0x000002ba,0x000002bc,0x0004003d, + 0x00000006,0x000002bf,0x000002be,0x00050081,0x00000006,0x000002c0,0x000002bd,0x000002bf, + 0x0004003d,0x00000006,0x000002c1,0x00000153,0x00050085,0x00000006,0x000002c2,0x000002c0, + 0x000002c1,0x0003003e,0x000002b9,0x000002c2,0x0004003d,0x00000006,0x000002c3,0x000002b9, + 0x0004003d,0x00000006,0x000002c4,0x000002b9,0x0004007f,0x00000006,0x000002c5,0x000002c4, + 0x0004003d,0x00000006,0x000002c6,0x00000154,0x0007000c,0x00000006,0x000002c7,0x00000001, + 0x00000028,0x000002c5,0x000002c6,0x0007000c,0x00000006,0x000002c8,0x00000001,0x00000025, + 0x000002c3,0x000002c7,0x0003003e,0x00000154,0x000002c8,0x00050041,0x0000000d,0x000002ce, + 0x00000036,0x00000150,0x0004003d,0x00000006,0x000002cf,0x000002ce,0x0003003e,0x000002cd, + 0x000002cf,0x00050041,0x0000000d,0x000002d1,0x00000036,0x000002a3,0x0004003d,0x00000006, + 0x000002d2,0x000002d1,0x0003003e,0x000002d0,0x000002d2,0x00050041,0x0000000d,0x000002d4, + 0x00000036,0x000002c9,0x0004003d,0x00000006,0x000002d5,0x000002d4,0x0003003e,0x000002d3, + 0x000002d5,0x00050041,0x0000000d,0x000002d7,0x00000036,0x000002ca,0x0004003d,0x00000006, + 0x000002d8,0x000002d7,0x0003003e,0x000002d6,0x000002d8,0x00050041,0x0000000d,0x000002da, + 0x00000036,0x000002cb,0x0004003d,0x00000006,0x000002db,0x000002da,0x0003003e,0x000002d9, + 0x000002db,0x00050041,0x0000000d,0x000002dd,0x00000036,0x000002cc,0x0004003d,0x00000006, + 0x000002de,0x000002dd,0x0003003e,0x000002dc,0x000002de,0x0004003d,0x00000025,0x000002e0, + 0x00000037,0x0003003e,0x000002df,0x000002e0,0x000b0039,0x00000006,0x000002e1,0x0000002f, + 0x000002cd,0x000002d0,0x000002d3,0x000002d6,0x000002d9,0x000002dc,0x000002df,0x0004003d, + 0x00000006,0x000002e2,0x00000154,0x00050085,0x00000006,0x000002e3,0x000002e2,0x000002e1, + 0x0003003e,0x00000154,0x000002e3,0x0004003d,0x00000006,0x000002e4,0x00000153,0x0004003d, + 0x00000006,0x000002e5,0x00000154,0x00050081,0x00000006,0x000002e6,0x000002e4,0x000002e5, + 0x000200fe,0x000002e6,0x00010038,0x00050036,0x00000006,0x00000040,0x00000000,0x0000003c, 0x00030037,0x0000003b,0x0000003d,0x00030037,0x00000026,0x0000003e,0x00030037,0x00000026, - 0x0000003f,0x000200f8,0x00000041,0x0004003b,0x0000000d,0x00000303,0x00000007,0x0004003b, - 0x00000026,0x00000304,0x00000007,0x0004003b,0x0000000d,0x0000030c,0x00000007,0x0004003b, - 0x00000026,0x0000030d,0x00000007,0x0004003b,0x00000214,0x0000031d,0x00000007,0x0004003b, - 0x00000214,0x0000032a,0x00000007,0x0004003d,0x00000025,0x000002ff,0x0000003e,0x0008000c, - 0x00000025,0x00000300,0x00000001,0x0000002d,0x000002ff,0x0000015c,0x0000015d,0x0003003e, - 0x0000003e,0x00000300,0x0004003d,0x00000025,0x00000301,0x0000003f,0x0008000c,0x00000025, - 0x00000302,0x00000001,0x0000002d,0x00000301,0x0000015c,0x0000015d,0x0003003e,0x0000003f, - 0x00000302,0x0003003e,0x00000303,0x000000a5,0x0003003e,0x00000304,0x0000015c,0x000200f9, - 0x00000305,0x000200f8,0x00000305,0x000400f6,0x00000307,0x00000308,0x00000000,0x000200f9, - 0x00000309,0x000200f8,0x00000309,0x0004003d,0x00000025,0x0000030a,0x00000304,0x000500b1, - 0x000000a6,0x0000030b,0x0000030a,0x00000167,0x000400fa,0x0000030b,0x00000306,0x00000307, - 0x000200f8,0x00000306,0x0003003e,0x0000030c,0x000000a5,0x0003003e,0x0000030d,0x0000015c, - 0x000200f9,0x0000030e,0x000200f8,0x0000030e,0x000400f6,0x00000310,0x00000311,0x00000000, - 0x000200f9,0x00000312,0x000200f8,0x00000312,0x0004003d,0x00000025,0x00000313,0x0000030d, - 0x000500b1,0x000000a6,0x00000314,0x00000313,0x00000167,0x000400fa,0x00000314,0x0000030f, - 0x00000310,0x000200f8,0x0000030f,0x0004003d,0x00000025,0x00000315,0x0000030d,0x0004003d, - 0x00000025,0x00000316,0x00000304,0x00060041,0x0000000d,0x00000317,0x0000003d,0x00000315, - 0x00000316,0x0004003d,0x00000006,0x00000318,0x00000317,0x0004003d,0x00000025,0x00000319, - 0x0000003f,0x00050084,0x00000025,0x0000031a,0x00000319,0x00000167,0x0004003d,0x00000025, - 0x0000031b,0x0000030d,0x00050080,0x00000025,0x0000031c,0x0000031a,0x0000031b,0x0003003e, - 0x0000031d,0x0000020f,0x00050041,0x0000000d,0x0000031e,0x0000031d,0x0000031c,0x0004003d, - 0x00000006,0x0000031f,0x0000031e,0x00050085,0x00000006,0x00000320,0x00000318,0x0000031f, - 0x0004003d,0x00000006,0x00000321,0x0000030c,0x00050081,0x00000006,0x00000322,0x00000321, - 0x00000320,0x0003003e,0x0000030c,0x00000322,0x000200f9,0x00000311,0x000200f8,0x00000311, - 0x0004003d,0x00000025,0x00000323,0x0000030d,0x00050080,0x00000025,0x00000324,0x00000323, - 0x0000021f,0x0003003e,0x0000030d,0x00000324,0x000200f9,0x0000030e,0x000200f8,0x00000310, - 0x0004003d,0x00000006,0x00000325,0x0000030c,0x0004003d,0x00000025,0x00000326,0x0000003e, - 0x00050084,0x00000025,0x00000327,0x00000326,0x00000167,0x0004003d,0x00000025,0x00000328, - 0x00000304,0x00050080,0x00000025,0x00000329,0x00000327,0x00000328,0x0003003e,0x0000032a, - 0x0000020f,0x00050041,0x0000000d,0x0000032b,0x0000032a,0x00000329,0x0004003d,0x00000006, - 0x0000032c,0x0000032b,0x00050085,0x00000006,0x0000032d,0x00000325,0x0000032c,0x0004003d, - 0x00000006,0x0000032e,0x00000303,0x00050081,0x00000006,0x0000032f,0x0000032e,0x0000032d, - 0x0003003e,0x00000303,0x0000032f,0x000200f9,0x00000308,0x000200f8,0x00000308,0x0004003d, - 0x00000025,0x00000330,0x00000304,0x00050080,0x00000025,0x00000331,0x00000330,0x0000021f, - 0x0003003e,0x00000304,0x00000331,0x000200f9,0x00000305,0x000200f8,0x00000307,0x0004003d, - 0x00000006,0x00000332,0x00000303,0x000200fe,0x00000332,0x00010038,0x00050036,0x00000006, + 0x0000003f,0x000200f8,0x00000041,0x0004003b,0x0000000d,0x000002ed,0x00000007,0x0004003b, + 0x00000026,0x000002ee,0x00000007,0x0004003b,0x0000000d,0x000002f6,0x00000007,0x0004003b, + 0x00000026,0x000002f7,0x00000007,0x0004003b,0x00000209,0x00000307,0x00000007,0x0004003b, + 0x00000209,0x00000314,0x00000007,0x0004003d,0x00000025,0x000002e9,0x0000003e,0x0008000c, + 0x00000025,0x000002ea,0x00000001,0x0000002d,0x000002e9,0x00000150,0x00000151,0x0003003e, + 0x0000003e,0x000002ea,0x0004003d,0x00000025,0x000002eb,0x0000003f,0x0008000c,0x00000025, + 0x000002ec,0x00000001,0x0000002d,0x000002eb,0x00000150,0x00000151,0x0003003e,0x0000003f, + 0x000002ec,0x0003003e,0x000002ed,0x0000009a,0x0003003e,0x000002ee,0x00000150,0x000200f9, + 0x000002ef,0x000200f8,0x000002ef,0x000400f6,0x000002f1,0x000002f2,0x00000000,0x000200f9, + 0x000002f3,0x000200f8,0x000002f3,0x0004003d,0x00000025,0x000002f4,0x000002ee,0x000500b1, + 0x0000009b,0x000002f5,0x000002f4,0x0000015c,0x000400fa,0x000002f5,0x000002f0,0x000002f1, + 0x000200f8,0x000002f0,0x0003003e,0x000002f6,0x0000009a,0x0003003e,0x000002f7,0x00000150, + 0x000200f9,0x000002f8,0x000200f8,0x000002f8,0x000400f6,0x000002fa,0x000002fb,0x00000000, + 0x000200f9,0x000002fc,0x000200f8,0x000002fc,0x0004003d,0x00000025,0x000002fd,0x000002f7, + 0x000500b1,0x0000009b,0x000002fe,0x000002fd,0x0000015c,0x000400fa,0x000002fe,0x000002f9, + 0x000002fa,0x000200f8,0x000002f9,0x0004003d,0x00000025,0x000002ff,0x000002f7,0x0004003d, + 0x00000025,0x00000300,0x000002ee,0x00060041,0x0000000d,0x00000301,0x0000003d,0x000002ff, + 0x00000300,0x0004003d,0x00000006,0x00000302,0x00000301,0x0004003d,0x00000025,0x00000303, + 0x0000003f,0x00050084,0x00000025,0x00000304,0x00000303,0x0000015c,0x0004003d,0x00000025, + 0x00000305,0x000002f7,0x00050080,0x00000025,0x00000306,0x00000304,0x00000305,0x0003003e, + 0x00000307,0x00000204,0x00050041,0x0000000d,0x00000308,0x00000307,0x00000306,0x0004003d, + 0x00000006,0x00000309,0x00000308,0x00050085,0x00000006,0x0000030a,0x00000302,0x00000309, + 0x0004003d,0x00000006,0x0000030b,0x000002f6,0x00050081,0x00000006,0x0000030c,0x0000030b, + 0x0000030a,0x0003003e,0x000002f6,0x0000030c,0x000200f9,0x000002fb,0x000200f8,0x000002fb, + 0x0004003d,0x00000025,0x0000030d,0x000002f7,0x00050080,0x00000025,0x0000030e,0x0000030d, + 0x000002a3,0x0003003e,0x000002f7,0x0000030e,0x000200f9,0x000002f8,0x000200f8,0x000002fa, + 0x0004003d,0x00000006,0x0000030f,0x000002f6,0x0004003d,0x00000025,0x00000310,0x0000003e, + 0x00050084,0x00000025,0x00000311,0x00000310,0x0000015c,0x0004003d,0x00000025,0x00000312, + 0x000002ee,0x00050080,0x00000025,0x00000313,0x00000311,0x00000312,0x0003003e,0x00000314, + 0x00000204,0x00050041,0x0000000d,0x00000315,0x00000314,0x00000313,0x0004003d,0x00000006, + 0x00000316,0x00000315,0x00050085,0x00000006,0x00000317,0x0000030f,0x00000316,0x0004003d, + 0x00000006,0x00000318,0x000002ed,0x00050081,0x00000006,0x00000319,0x00000318,0x00000317, + 0x0003003e,0x000002ed,0x00000319,0x000200f9,0x000002f2,0x000200f8,0x000002f2,0x0004003d, + 0x00000025,0x0000031a,0x000002ee,0x00050080,0x00000025,0x0000031b,0x0000031a,0x000002a3, + 0x0003003e,0x000002ee,0x0000031b,0x000200f9,0x000002ef,0x000200f8,0x000002f1,0x0004003d, + 0x00000006,0x0000031c,0x000002ed,0x000200fe,0x0000031c,0x00010038,0x00050036,0x00000006, 0x00000049,0x00000000,0x00000042,0x00030037,0x0000003b,0x00000043,0x00030037,0x0000000d, 0x00000044,0x00030037,0x0000000d,0x00000045,0x00030037,0x00000026,0x00000046,0x00030037, 0x00000026,0x00000047,0x00030037,0x0000001b,0x00000048,0x000200f8,0x0000004a,0x0004003b, - 0x0000000d,0x00000335,0x00000007,0x0004003b,0x00000026,0x0000033b,0x00000007,0x0004003b, - 0x00000034,0x00000343,0x00000007,0x0004003b,0x00000034,0x00000350,0x00000007,0x0004003b, - 0x00000026,0x00000352,0x00000007,0x0004003b,0x00000026,0x0000035f,0x00000007,0x0004003b, - 0x00000034,0x00000367,0x00000007,0x0004003b,0x00000034,0x00000374,0x00000007,0x0004003b, - 0x00000026,0x00000376,0x00000007,0x0004003b,0x0000000d,0x00000383,0x00000007,0x0004003b, - 0x0000038c,0x0000038d,0x00000007,0x0004003b,0x0000000d,0x000003a5,0x00000007,0x0004003b, - 0x0000000d,0x000003a8,0x00000007,0x0004003b,0x0000000d,0x000003b1,0x00000007,0x0004003b, - 0x0000000d,0x000003b4,0x00000007,0x0004003b,0x0000000d,0x000003bd,0x00000007,0x0004003b, - 0x0000000d,0x000003c0,0x00000007,0x0004003b,0x0000000d,0x000003c9,0x00000007,0x0004003b, - 0x0000000d,0x000003cc,0x00000007,0x0004003b,0x0000000d,0x000003f1,0x00000007,0x0004003b, - 0x00000026,0x000003f9,0x00000007,0x0004003b,0x00000034,0x00000401,0x00000007,0x0004003b, - 0x00000026,0x0000040d,0x00000007,0x0004003b,0x00000034,0x00000420,0x00000007,0x0004003b, - 0x00000026,0x00000422,0x00000007,0x0004003b,0x0000000d,0x0000042f,0x00000007,0x0004003b, - 0x0000038c,0x00000434,0x00000007,0x0004003b,0x0000000d,0x0000044c,0x00000007,0x0004003b, - 0x0000000d,0x0000044f,0x00000007,0x0004003b,0x0000000d,0x00000458,0x00000007,0x0004003b, - 0x0000000d,0x0000045b,0x00000007,0x0004003b,0x0000000d,0x00000464,0x00000007,0x0004003b, - 0x0000000d,0x00000467,0x00000007,0x0004003b,0x0000000d,0x00000470,0x00000007,0x0004003b, - 0x0000000d,0x00000473,0x00000007,0x0004003b,0x0000000d,0x00000498,0x00000007,0x0004003b, - 0x00000026,0x000004a1,0x00000007,0x0004003b,0x00000034,0x000004a9,0x00000007,0x0004003b, - 0x00000026,0x000004b5,0x00000007,0x0004003b,0x00000034,0x000004c7,0x00000007,0x0004003b, - 0x00000026,0x000004c9,0x00000007,0x0003003e,0x00000335,0x000000a5,0x00050041,0x0000000d, - 0x00000336,0x00000048,0x0000004c,0x0004003d,0x00000006,0x00000337,0x00000336,0x000500ba, - 0x000000a6,0x00000338,0x00000337,0x000000a5,0x000300f7,0x0000033a,0x00000000,0x000400fa, - 0x00000338,0x00000339,0x0000033a,0x000200f8,0x00000339,0x0003003e,0x0000033b,0x0000015c, - 0x000200f9,0x0000033c,0x000200f8,0x0000033c,0x000400f6,0x0000033e,0x0000033f,0x00000000, - 0x000200f9,0x00000340,0x000200f8,0x00000340,0x0004003d,0x00000025,0x00000341,0x0000033b, - 0x000500b1,0x000000a6,0x00000342,0x00000341,0x00000167,0x000400fa,0x00000342,0x0000033d, - 0x0000033e,0x000200f8,0x0000033d,0x0004003d,0x00000025,0x00000344,0x0000033b,0x0004003d, - 0x00000025,0x00000345,0x0000033b,0x00060041,0x0000000d,0x00000346,0x00000043,0x00000345, - 0x000002df,0x0004003d,0x00000006,0x00000347,0x00000346,0x0004003d,0x00000025,0x00000348, - 0x0000033b,0x00060041,0x0000000d,0x00000349,0x00000043,0x00000348,0x000002e0,0x0004003d, - 0x00000006,0x0000034a,0x00000349,0x0004003d,0x00000006,0x0000034b,0x00000044,0x0008000c, - 0x00000006,0x0000034c,0x00000001,0x0000002e,0x00000347,0x0000034a,0x0000034b,0x00050041, - 0x0000000d,0x0000034d,0x00000343,0x00000344,0x0003003e,0x0000034d,0x0000034c,0x000200f9, - 0x0000033f,0x000200f8,0x0000033f,0x0004003d,0x00000025,0x0000034e,0x0000033b,0x00050080, - 0x00000025,0x0000034f,0x0000034e,0x0000021f,0x0003003e,0x0000033b,0x0000034f,0x000200f9, - 0x0000033c,0x000200f8,0x0000033e,0x0004003d,0x00000033,0x00000351,0x00000343,0x0003003e, - 0x00000350,0x00000351,0x0004003d,0x00000025,0x00000353,0x00000047,0x0003003e,0x00000352, - 0x00000353,0x00060039,0x00000006,0x00000354,0x00000038,0x00000350,0x00000352,0x00050041, - 0x0000000d,0x00000355,0x00000048,0x0000004c,0x0004003d,0x00000006,0x00000356,0x00000355, - 0x00050085,0x00000006,0x00000357,0x00000354,0x00000356,0x0004003d,0x00000006,0x00000358, - 0x00000335,0x00050081,0x00000006,0x00000359,0x00000358,0x00000357,0x0003003e,0x00000335, - 0x00000359,0x000200f9,0x0000033a,0x000200f8,0x0000033a,0x00050041,0x0000000d,0x0000035a, - 0x00000048,0x00000051,0x0004003d,0x00000006,0x0000035b,0x0000035a,0x000500ba,0x000000a6, - 0x0000035c,0x0000035b,0x000000a5,0x000300f7,0x0000035e,0x00000000,0x000400fa,0x0000035c, - 0x0000035d,0x0000035e,0x000200f8,0x0000035d,0x0003003e,0x0000035f,0x0000015c,0x000200f9, - 0x00000360,0x000200f8,0x00000360,0x000400f6,0x00000362,0x00000363,0x00000000,0x000200f9, - 0x00000364,0x000200f8,0x00000364,0x0004003d,0x00000025,0x00000365,0x0000035f,0x000500b1, - 0x000000a6,0x00000366,0x00000365,0x00000167,0x000400fa,0x00000366,0x00000361,0x00000362, - 0x000200f8,0x00000361,0x0004003d,0x00000025,0x00000368,0x0000035f,0x0004003d,0x00000025, - 0x00000369,0x0000035f,0x00060041,0x0000000d,0x0000036a,0x00000043,0x000002df,0x00000369, - 0x0004003d,0x00000006,0x0000036b,0x0000036a,0x0004003d,0x00000025,0x0000036c,0x0000035f, - 0x00060041,0x0000000d,0x0000036d,0x00000043,0x000002e0,0x0000036c,0x0004003d,0x00000006, - 0x0000036e,0x0000036d,0x0004003d,0x00000006,0x0000036f,0x00000045,0x0008000c,0x00000006, - 0x00000370,0x00000001,0x0000002e,0x0000036b,0x0000036e,0x0000036f,0x00050041,0x0000000d, - 0x00000371,0x00000367,0x00000368,0x0003003e,0x00000371,0x00000370,0x000200f9,0x00000363, - 0x000200f8,0x00000363,0x0004003d,0x00000025,0x00000372,0x0000035f,0x00050080,0x00000025, - 0x00000373,0x00000372,0x0000021f,0x0003003e,0x0000035f,0x00000373,0x000200f9,0x00000360, - 0x000200f8,0x00000362,0x0004003d,0x00000033,0x00000375,0x00000367,0x0003003e,0x00000374, - 0x00000375,0x0004003d,0x00000025,0x00000377,0x00000046,0x0003003e,0x00000376,0x00000377, - 0x00060039,0x00000006,0x00000378,0x00000038,0x00000374,0x00000376,0x00050041,0x0000000d, - 0x00000379,0x00000048,0x00000051,0x0004003d,0x00000006,0x0000037a,0x00000379,0x00050085, - 0x00000006,0x0000037b,0x00000378,0x0000037a,0x0004003d,0x00000006,0x0000037c,0x00000335, - 0x00050081,0x00000006,0x0000037d,0x0000037c,0x0000037b,0x0003003e,0x00000335,0x0000037d, - 0x000200f9,0x0000035e,0x000200f8,0x0000035e,0x00050041,0x0000000d,0x0000037e,0x00000048, - 0x00000057,0x0004003d,0x00000006,0x0000037f,0x0000037e,0x000500ba,0x000000a6,0x00000380, - 0x0000037f,0x000000a5,0x000300f7,0x00000382,0x00000000,0x000400fa,0x00000380,0x00000381, - 0x00000382,0x000200f8,0x00000381,0x0004003d,0x00000006,0x00000385,0x00000044,0x0004003d, - 0x00000006,0x00000386,0x00000045,0x00050083,0x00000006,0x00000387,0x00000385,0x00000386, - 0x00050085,0x00000006,0x00000388,0x00000384,0x00000387,0x00050081,0x00000006,0x00000389, - 0x00000384,0x00000388,0x0003003e,0x00000383,0x00000389,0x00060041,0x0000000d,0x0000038e, - 0x00000043,0x000002df,0x0000021f,0x0004003d,0x00000006,0x0000038f,0x0000038e,0x00060041, - 0x0000000d,0x00000390,0x00000043,0x0000021f,0x000002df,0x0004003d,0x00000006,0x00000391, - 0x00000390,0x0004003d,0x00000006,0x00000392,0x00000383,0x0008000c,0x00000006,0x00000393, - 0x00000001,0x0000002e,0x0000038f,0x00000391,0x00000392,0x00050041,0x0000000d,0x00000394, - 0x0000038d,0x0000021f,0x0003003e,0x00000394,0x00000393,0x00060041,0x0000000d,0x00000395, - 0x00000043,0x000002e0,0x000002df,0x0004003d,0x00000006,0x00000396,0x00000395,0x00060041, - 0x0000000d,0x00000397,0x00000043,0x000002df,0x000002e0,0x0004003d,0x00000006,0x00000398, - 0x00000397,0x0004003d,0x00000006,0x00000399,0x00000383,0x0008000c,0x00000006,0x0000039a, - 0x00000001,0x0000002e,0x00000396,0x00000398,0x00000399,0x00050041,0x0000000d,0x0000039b, - 0x0000038d,0x000002e0,0x0003003e,0x0000039b,0x0000039a,0x00060041,0x0000000d,0x0000039c, - 0x00000043,0x000002e1,0x000002e0,0x0004003d,0x00000006,0x0000039d,0x0000039c,0x00060041, - 0x0000000d,0x0000039e,0x00000043,0x000002e0,0x000002e1,0x0004003d,0x00000006,0x0000039f, - 0x0000039e,0x0004003d,0x00000006,0x000003a0,0x00000383,0x0008000c,0x00000006,0x000003a1, - 0x00000001,0x0000002e,0x0000039d,0x0000039f,0x000003a0,0x00050041,0x0000000d,0x000003a2, - 0x0000038d,0x000002e2,0x0003003e,0x000003a2,0x000003a1,0x0004003d,0x00000006,0x000003a3, - 0x00000383,0x00050083,0x00000006,0x000003a4,0x000003a3,0x00000384,0x0003003e,0x00000383, - 0x000003a4,0x0004003d,0x00000006,0x000003a6,0x00000383,0x000500be,0x000000a6,0x000003a7, - 0x000003a6,0x000000a5,0x000300f7,0x000003aa,0x00000000,0x000400fa,0x000003a7,0x000003a9, - 0x000003ad,0x000200f8,0x000003a9,0x00060041,0x0000000d,0x000003ab,0x00000043,0x0000015c, - 0x000002df,0x0004003d,0x00000006,0x000003ac,0x000003ab,0x0003003e,0x000003a8,0x000003ac, - 0x000200f9,0x000003aa,0x000200f8,0x000003ad,0x00060041,0x0000000d,0x000003ae,0x00000043, - 0x000002df,0x0000015c,0x0004003d,0x00000006,0x000003af,0x000003ae,0x0003003e,0x000003a8, - 0x000003af,0x000200f9,0x000003aa,0x000200f8,0x000003aa,0x0004003d,0x00000006,0x000003b0, - 0x000003a8,0x0003003e,0x000003a5,0x000003b0,0x0004003d,0x00000006,0x000003b2,0x00000383, - 0x000500be,0x000000a6,0x000003b3,0x000003b2,0x000000a5,0x000300f7,0x000003b6,0x00000000, - 0x000400fa,0x000003b3,0x000003b5,0x000003b9,0x000200f8,0x000003b5,0x00060041,0x0000000d, - 0x000003b7,0x00000043,0x0000021f,0x000002e0,0x0004003d,0x00000006,0x000003b8,0x000003b7, - 0x0003003e,0x000003b4,0x000003b8,0x000200f9,0x000003b6,0x000200f8,0x000003b9,0x00060041, - 0x0000000d,0x000003ba,0x00000043,0x000002e0,0x0000021f,0x0004003d,0x00000006,0x000003bb, - 0x000003ba,0x0003003e,0x000003b4,0x000003bb,0x000200f9,0x000003b6,0x000200f8,0x000003b6, - 0x0004003d,0x00000006,0x000003bc,0x000003b4,0x0003003e,0x000003b1,0x000003bc,0x0004003d, - 0x00000006,0x000003be,0x00000383,0x000500be,0x000000a6,0x000003bf,0x000003be,0x000000a5, - 0x000300f7,0x000003c2,0x00000000,0x000400fa,0x000003bf,0x000003c1,0x000003c5,0x000200f8, - 0x000003c1,0x00060041,0x0000000d,0x000003c3,0x00000043,0x000002df,0x000002e1,0x0004003d, - 0x00000006,0x000003c4,0x000003c3,0x0003003e,0x000003c0,0x000003c4,0x000200f9,0x000003c2, - 0x000200f8,0x000003c5,0x00060041,0x0000000d,0x000003c6,0x00000043,0x000002e1,0x000002df, - 0x0004003d,0x00000006,0x000003c7,0x000003c6,0x0003003e,0x000003c0,0x000003c7,0x000200f9, - 0x000003c2,0x000200f8,0x000003c2,0x0004003d,0x00000006,0x000003c8,0x000003c0,0x0003003e, - 0x000003bd,0x000003c8,0x0004003d,0x00000006,0x000003ca,0x00000383,0x000500be,0x000000a6, - 0x000003cb,0x000003ca,0x000000a5,0x000300f7,0x000003ce,0x00000000,0x000400fa,0x000003cb, - 0x000003cd,0x000003d1,0x000200f8,0x000003cd,0x00060041,0x0000000d,0x000003cf,0x00000043, - 0x000002e0,0x000002e2,0x0004003d,0x00000006,0x000003d0,0x000003cf,0x0003003e,0x000003cc, - 0x000003d0,0x000200f9,0x000003ce,0x000200f8,0x000003d1,0x00060041,0x0000000d,0x000003d2, - 0x00000043,0x000002e2,0x000002e0,0x0004003d,0x00000006,0x000003d3,0x000003d2,0x0003003e, - 0x000003cc,0x000003d3,0x000200f9,0x000003ce,0x000200f8,0x000003ce,0x0004003d,0x00000006, - 0x000003d4,0x000003cc,0x0003003e,0x000003c9,0x000003d4,0x00060041,0x0000000d,0x000003d5, - 0x00000043,0x0000021f,0x0000021f,0x0004003d,0x00000006,0x000003d6,0x000003d5,0x0004003d, - 0x00000006,0x000003d7,0x000003a5,0x0004003d,0x00000006,0x000003d8,0x00000383,0x0006000c, - 0x00000006,0x000003d9,0x00000001,0x00000004,0x000003d8,0x0008000c,0x00000006,0x000003da, - 0x00000001,0x0000002e,0x000003d6,0x000003d7,0x000003d9,0x00050041,0x0000000d,0x000003db, - 0x0000038d,0x0000015c,0x0003003e,0x000003db,0x000003da,0x00060041,0x0000000d,0x000003dc, - 0x00000043,0x000002df,0x000002df,0x0004003d,0x00000006,0x000003dd,0x000003dc,0x0004003d, - 0x00000006,0x000003de,0x000003b1,0x0004003d,0x00000006,0x000003df,0x00000383,0x0006000c, - 0x00000006,0x000003e0,0x00000001,0x00000004,0x000003df,0x0008000c,0x00000006,0x000003e1, - 0x00000001,0x0000002e,0x000003dd,0x000003de,0x000003e0,0x00050041,0x0000000d,0x000003e2, - 0x0000038d,0x000002df,0x0003003e,0x000003e2,0x000003e1,0x00060041,0x0000000d,0x000003e3, - 0x00000043,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x000003e4,0x000003e3,0x0004003d, - 0x00000006,0x000003e5,0x000003bd,0x0004003d,0x00000006,0x000003e6,0x00000383,0x0006000c, - 0x00000006,0x000003e7,0x00000001,0x00000004,0x000003e6,0x0008000c,0x00000006,0x000003e8, - 0x00000001,0x0000002e,0x000003e4,0x000003e5,0x000003e7,0x00050041,0x0000000d,0x000003e9, - 0x0000038d,0x000002e1,0x0003003e,0x000003e9,0x000003e8,0x00060041,0x0000000d,0x000003ea, - 0x00000043,0x000002e1,0x000002e1,0x0004003d,0x00000006,0x000003eb,0x000003ea,0x0004003d, - 0x00000006,0x000003ec,0x000003c9,0x0004003d,0x00000006,0x000003ed,0x00000383,0x0006000c, - 0x00000006,0x000003ee,0x00000001,0x00000004,0x000003ed,0x0008000c,0x00000006,0x000003ef, - 0x00000001,0x0000002e,0x000003eb,0x000003ec,0x000003ee,0x00050041,0x0000000d,0x000003f0, - 0x0000038d,0x00000167,0x0003003e,0x000003f0,0x000003ef,0x0004003d,0x00000006,0x000003f2, - 0x00000044,0x0004003d,0x00000006,0x000003f3,0x00000045,0x00050081,0x00000006,0x000003f4, - 0x000003f2,0x000003f3,0x0003003e,0x000003f1,0x000003f4,0x0004003d,0x00000006,0x000003f5, - 0x000003f1,0x000500be,0x000000a6,0x000003f6,0x000003f5,0x000000b2,0x000300f7,0x000003f8, - 0x00000000,0x000400fa,0x000003f6,0x000003f7,0x0000040c,0x000200f8,0x000003f7,0x0003003e, - 0x000003f9,0x0000015c,0x000200f9,0x000003fa,0x000200f8,0x000003fa,0x000400f6,0x000003fc, - 0x000003fd,0x00000000,0x000200f9,0x000003fe,0x000200f8,0x000003fe,0x0004003d,0x00000025, - 0x000003ff,0x000003f9,0x000500b1,0x000000a6,0x00000400,0x000003ff,0x00000167,0x000400fa, - 0x00000400,0x000003fb,0x000003fc,0x000200f8,0x000003fb,0x0004003d,0x00000025,0x00000402, - 0x000003f9,0x0004003d,0x00000025,0x00000403,0x000003f9,0x00050080,0x00000025,0x00000404, - 0x00000403,0x0000021f,0x00050041,0x0000000d,0x00000405,0x0000038d,0x00000404,0x0004003d, - 0x00000006,0x00000406,0x00000405,0x00050041,0x0000000d,0x00000407,0x00000401,0x00000402, - 0x0003003e,0x00000407,0x00000406,0x000200f9,0x000003fd,0x000200f8,0x000003fd,0x0004003d, - 0x00000025,0x00000408,0x000003f9,0x00050080,0x00000025,0x00000409,0x00000408,0x0000021f, - 0x0003003e,0x000003f9,0x00000409,0x000200f9,0x000003fa,0x000200f8,0x000003fc,0x0004003d, - 0x00000006,0x0000040a,0x000003f1,0x00050083,0x00000006,0x0000040b,0x0000040a,0x000000b2, - 0x0003003e,0x000003f1,0x0000040b,0x000200f9,0x000003f8,0x000200f8,0x0000040c,0x0003003e, - 0x0000040d,0x0000015c,0x000200f9,0x0000040e,0x000200f8,0x0000040e,0x000400f6,0x00000410, - 0x00000411,0x00000000,0x000200f9,0x00000412,0x000200f8,0x00000412,0x0004003d,0x00000025, - 0x00000413,0x0000040d,0x000500b1,0x000000a6,0x00000414,0x00000413,0x00000167,0x000400fa, - 0x00000414,0x0000040f,0x00000410,0x000200f8,0x0000040f,0x0004003d,0x00000025,0x00000415, - 0x0000040d,0x0004003d,0x00000025,0x00000416,0x0000040d,0x00050041,0x0000000d,0x00000417, - 0x0000038d,0x00000416,0x0004003d,0x00000006,0x00000418,0x00000417,0x00050041,0x0000000d, - 0x00000419,0x00000401,0x00000415,0x0003003e,0x00000419,0x00000418,0x000200f9,0x00000411, - 0x000200f8,0x00000411,0x0004003d,0x00000025,0x0000041a,0x0000040d,0x00050080,0x00000025, - 0x0000041b,0x0000041a,0x0000021f,0x0003003e,0x0000040d,0x0000041b,0x000200f9,0x0000040e, - 0x000200f8,0x00000410,0x000200f9,0x000003f8,0x000200f8,0x000003f8,0x0004003d,0x00000006, - 0x0000041c,0x000003f1,0x00050085,0x00000006,0x0000041e,0x0000041c,0x0000041d,0x0004006e, - 0x00000025,0x0000041f,0x0000041e,0x0004003d,0x00000033,0x00000421,0x00000401,0x0003003e, - 0x00000420,0x00000421,0x0003003e,0x00000422,0x0000041f,0x00060039,0x00000006,0x00000423, - 0x00000038,0x00000420,0x00000422,0x00050041,0x0000000d,0x00000424,0x00000048,0x00000057, - 0x0004003d,0x00000006,0x00000425,0x00000424,0x00050085,0x00000006,0x00000426,0x00000423, - 0x00000425,0x0004003d,0x00000006,0x00000427,0x00000335,0x00050081,0x00000006,0x00000428, - 0x00000427,0x00000426,0x0003003e,0x00000335,0x00000428,0x000200f9,0x00000382,0x000200f8, - 0x00000382,0x00050041,0x0000000d,0x0000042a,0x00000048,0x00000429,0x0004003d,0x00000006, - 0x0000042b,0x0000042a,0x000500ba,0x000000a6,0x0000042c,0x0000042b,0x000000a5,0x000300f7, - 0x0000042e,0x00000000,0x000400fa,0x0000042c,0x0000042d,0x0000042e,0x000200f8,0x0000042d, - 0x0004003d,0x00000006,0x00000430,0x00000044,0x0004003d,0x00000006,0x00000431,0x00000045, - 0x00050081,0x00000006,0x00000432,0x00000430,0x00000431,0x00050085,0x00000006,0x00000433, - 0x00000384,0x00000432,0x0003003e,0x0000042f,0x00000433,0x00060041,0x0000000d,0x00000435, - 0x00000043,0x000002e0,0x0000021f,0x0004003d,0x00000006,0x00000436,0x00000435,0x00060041, - 0x0000000d,0x00000437,0x00000043,0x000002e1,0x000002df,0x0004003d,0x00000006,0x00000438, - 0x00000437,0x0004003d,0x00000006,0x00000439,0x0000042f,0x0008000c,0x00000006,0x0000043a, - 0x00000001,0x0000002e,0x00000436,0x00000438,0x00000439,0x00050041,0x0000000d,0x0000043b, - 0x00000434,0x0000021f,0x0003003e,0x0000043b,0x0000043a,0x00060041,0x0000000d,0x0000043c, - 0x00000043,0x000002df,0x000002df,0x0004003d,0x00000006,0x0000043d,0x0000043c,0x00060041, - 0x0000000d,0x0000043e,0x00000043,0x000002e0,0x000002e0,0x0004003d,0x00000006,0x0000043f, - 0x0000043e,0x0004003d,0x00000006,0x00000440,0x0000042f,0x0008000c,0x00000006,0x00000441, - 0x00000001,0x0000002e,0x0000043d,0x0000043f,0x00000440,0x00050041,0x0000000d,0x00000442, - 0x00000434,0x000002e0,0x0003003e,0x00000442,0x00000441,0x00060041,0x0000000d,0x00000443, - 0x00000043,0x0000021f,0x000002e0,0x0004003d,0x00000006,0x00000444,0x00000443,0x00060041, - 0x0000000d,0x00000445,0x00000043,0x000002df,0x000002e1,0x0004003d,0x00000006,0x00000446, - 0x00000445,0x0004003d,0x00000006,0x00000447,0x0000042f,0x0008000c,0x00000006,0x00000448, - 0x00000001,0x0000002e,0x00000444,0x00000446,0x00000447,0x00050041,0x0000000d,0x00000449, - 0x00000434,0x000002e2,0x0003003e,0x00000449,0x00000448,0x0004003d,0x00000006,0x0000044a, - 0x0000042f,0x00050083,0x00000006,0x0000044b,0x0000044a,0x00000384,0x0003003e,0x0000042f, - 0x0000044b,0x0004003d,0x00000006,0x0000044d,0x0000042f,0x000500be,0x000000a6,0x0000044e, - 0x0000044d,0x000000a5,0x000300f7,0x00000451,0x00000000,0x000400fa,0x0000044e,0x00000450, - 0x00000454,0x000200f8,0x00000450,0x00060041,0x0000000d,0x00000452,0x00000043,0x000002e2, - 0x000002df,0x0004003d,0x00000006,0x00000453,0x00000452,0x0003003e,0x0000044f,0x00000453, - 0x000200f9,0x00000451,0x000200f8,0x00000454,0x00060041,0x0000000d,0x00000455,0x00000043, - 0x000002e0,0x0000015c,0x0004003d,0x00000006,0x00000456,0x00000455,0x0003003e,0x0000044f, - 0x00000456,0x000200f9,0x00000451,0x000200f8,0x00000451,0x0004003d,0x00000006,0x00000457, - 0x0000044f,0x0003003e,0x0000044c,0x00000457,0x0004003d,0x00000006,0x00000459,0x0000042f, - 0x000500be,0x000000a6,0x0000045a,0x00000459,0x000000a5,0x000300f7,0x0000045d,0x00000000, - 0x000400fa,0x0000045a,0x0000045c,0x00000460,0x000200f8,0x0000045c,0x00060041,0x0000000d, - 0x0000045e,0x00000043,0x000002e1,0x000002e0,0x0004003d,0x00000006,0x0000045f,0x0000045e, - 0x0003003e,0x0000045b,0x0000045f,0x000200f9,0x0000045d,0x000200f8,0x00000460,0x00060041, - 0x0000000d,0x00000461,0x00000043,0x000002df,0x0000021f,0x0004003d,0x00000006,0x00000462, - 0x00000461,0x0003003e,0x0000045b,0x00000462,0x000200f9,0x0000045d,0x000200f8,0x0000045d, - 0x0004003d,0x00000006,0x00000463,0x0000045b,0x0003003e,0x00000458,0x00000463,0x0004003d, - 0x00000006,0x00000465,0x0000042f,0x000500be,0x000000a6,0x00000466,0x00000465,0x000000a5, - 0x000300f7,0x00000469,0x00000000,0x000400fa,0x00000466,0x00000468,0x0000046c,0x000200f8, - 0x00000468,0x00060041,0x0000000d,0x0000046a,0x00000043,0x000002e0,0x000002e1,0x0004003d, - 0x00000006,0x0000046b,0x0000046a,0x0003003e,0x00000467,0x0000046b,0x000200f9,0x00000469, - 0x000200f8,0x0000046c,0x00060041,0x0000000d,0x0000046d,0x00000043,0x0000021f,0x000002df, - 0x0004003d,0x00000006,0x0000046e,0x0000046d,0x0003003e,0x00000467,0x0000046e,0x000200f9, - 0x00000469,0x000200f8,0x00000469,0x0004003d,0x00000006,0x0000046f,0x00000467,0x0003003e, - 0x00000464,0x0000046f,0x0004003d,0x00000006,0x00000471,0x0000042f,0x000500be,0x000000a6, - 0x00000472,0x00000471,0x000000a5,0x000300f7,0x00000475,0x00000000,0x000400fa,0x00000472, - 0x00000474,0x00000478,0x000200f8,0x00000474,0x00060041,0x0000000d,0x00000476,0x00000043, - 0x000002df,0x000002e2,0x0004003d,0x00000006,0x00000477,0x00000476,0x0003003e,0x00000473, - 0x00000477,0x000200f9,0x00000475,0x000200f8,0x00000478,0x00060041,0x0000000d,0x00000479, - 0x00000043,0x0000015c,0x000002e0,0x0004003d,0x00000006,0x0000047a,0x00000479,0x0003003e, - 0x00000473,0x0000047a,0x000200f9,0x00000475,0x000200f8,0x00000475,0x0004003d,0x00000006, - 0x0000047b,0x00000473,0x0003003e,0x00000470,0x0000047b,0x00060041,0x0000000d,0x0000047c, - 0x00000043,0x000002e1,0x0000021f,0x0004003d,0x00000006,0x0000047d,0x0000047c,0x0004003d, - 0x00000006,0x0000047e,0x0000044c,0x0004003d,0x00000006,0x0000047f,0x0000042f,0x0006000c, - 0x00000006,0x00000480,0x00000001,0x00000004,0x0000047f,0x0008000c,0x00000006,0x00000481, - 0x00000001,0x0000002e,0x0000047d,0x0000047e,0x00000480,0x00050041,0x0000000d,0x00000482, - 0x00000434,0x0000015c,0x0003003e,0x00000482,0x00000481,0x00060041,0x0000000d,0x00000483, - 0x00000043,0x000002e0,0x000002df,0x0004003d,0x00000006,0x00000484,0x00000483,0x0004003d, - 0x00000006,0x00000485,0x00000458,0x0004003d,0x00000006,0x00000486,0x0000042f,0x0006000c, - 0x00000006,0x00000487,0x00000001,0x00000004,0x00000486,0x0008000c,0x00000006,0x00000488, - 0x00000001,0x0000002e,0x00000484,0x00000485,0x00000487,0x00050041,0x0000000d,0x00000489, - 0x00000434,0x000002df,0x0003003e,0x00000489,0x00000488,0x00060041,0x0000000d,0x0000048a, - 0x00000043,0x000002df,0x000002e0,0x0004003d,0x00000006,0x0000048b,0x0000048a,0x0004003d, - 0x00000006,0x0000048c,0x00000464,0x0004003d,0x00000006,0x0000048d,0x0000042f,0x0006000c, - 0x00000006,0x0000048e,0x00000001,0x00000004,0x0000048d,0x0008000c,0x00000006,0x0000048f, - 0x00000001,0x0000002e,0x0000048b,0x0000048c,0x0000048e,0x00050041,0x0000000d,0x00000490, - 0x00000434,0x000002e1,0x0003003e,0x00000490,0x0000048f,0x00060041,0x0000000d,0x00000491, - 0x00000043,0x0000021f,0x000002e1,0x0004003d,0x00000006,0x00000492,0x00000491,0x0004003d, - 0x00000006,0x00000493,0x00000470,0x0004003d,0x00000006,0x00000494,0x0000042f,0x0006000c, - 0x00000006,0x00000495,0x00000001,0x00000004,0x00000494,0x0008000c,0x00000006,0x00000496, - 0x00000001,0x0000002e,0x00000492,0x00000493,0x00000495,0x00050041,0x0000000d,0x00000497, - 0x00000434,0x00000167,0x0003003e,0x00000497,0x00000496,0x0004003d,0x00000006,0x00000499, - 0x00000044,0x0004003d,0x00000006,0x0000049a,0x00000045,0x00050083,0x00000006,0x0000049b, - 0x00000499,0x0000049a,0x00050081,0x00000006,0x0000049c,0x000000b2,0x0000049b,0x0003003e, - 0x00000498,0x0000049c,0x0004003d,0x00000006,0x0000049d,0x00000498,0x000500be,0x000000a6, - 0x0000049e,0x0000049d,0x000000b2,0x000300f7,0x000004a0,0x00000000,0x000400fa,0x0000049e, - 0x0000049f,0x000004b4,0x000200f8,0x0000049f,0x0003003e,0x000004a1,0x0000015c,0x000200f9, - 0x000004a2,0x000200f8,0x000004a2,0x000400f6,0x000004a4,0x000004a5,0x00000000,0x000200f9, - 0x000004a6,0x000200f8,0x000004a6,0x0004003d,0x00000025,0x000004a7,0x000004a1,0x000500b1, - 0x000000a6,0x000004a8,0x000004a7,0x00000167,0x000400fa,0x000004a8,0x000004a3,0x000004a4, - 0x000200f8,0x000004a3,0x0004003d,0x00000025,0x000004aa,0x000004a1,0x0004003d,0x00000025, - 0x000004ab,0x000004a1,0x00050080,0x00000025,0x000004ac,0x000004ab,0x0000021f,0x00050041, - 0x0000000d,0x000004ad,0x00000434,0x000004ac,0x0004003d,0x00000006,0x000004ae,0x000004ad, - 0x00050041,0x0000000d,0x000004af,0x000004a9,0x000004aa,0x0003003e,0x000004af,0x000004ae, - 0x000200f9,0x000004a5,0x000200f8,0x000004a5,0x0004003d,0x00000025,0x000004b0,0x000004a1, - 0x00050080,0x00000025,0x000004b1,0x000004b0,0x0000021f,0x0003003e,0x000004a1,0x000004b1, - 0x000200f9,0x000004a2,0x000200f8,0x000004a4,0x0004003d,0x00000006,0x000004b2,0x00000498, - 0x00050083,0x00000006,0x000004b3,0x000004b2,0x000000b2,0x0003003e,0x00000498,0x000004b3, - 0x000200f9,0x000004a0,0x000200f8,0x000004b4,0x0003003e,0x000004b5,0x0000015c,0x000200f9, - 0x000004b6,0x000200f8,0x000004b6,0x000400f6,0x000004b8,0x000004b9,0x00000000,0x000200f9, - 0x000004ba,0x000200f8,0x000004ba,0x0004003d,0x00000025,0x000004bb,0x000004b5,0x000500b1, - 0x000000a6,0x000004bc,0x000004bb,0x00000167,0x000400fa,0x000004bc,0x000004b7,0x000004b8, - 0x000200f8,0x000004b7,0x0004003d,0x00000025,0x000004bd,0x000004b5,0x0004003d,0x00000025, - 0x000004be,0x000004b5,0x00050041,0x0000000d,0x000004bf,0x00000434,0x000004be,0x0004003d, - 0x00000006,0x000004c0,0x000004bf,0x00050041,0x0000000d,0x000004c1,0x000004a9,0x000004bd, - 0x0003003e,0x000004c1,0x000004c0,0x000200f9,0x000004b9,0x000200f8,0x000004b9,0x0004003d, - 0x00000025,0x000004c2,0x000004b5,0x00050080,0x00000025,0x000004c3,0x000004c2,0x0000021f, - 0x0003003e,0x000004b5,0x000004c3,0x000200f9,0x000004b6,0x000200f8,0x000004b8,0x000200f9, - 0x000004a0,0x000200f8,0x000004a0,0x0004003d,0x00000006,0x000004c4,0x00000498,0x00050085, - 0x00000006,0x000004c5,0x000004c4,0x0000041d,0x0004006e,0x00000025,0x000004c6,0x000004c5, - 0x0004003d,0x00000033,0x000004c8,0x000004a9,0x0003003e,0x000004c7,0x000004c8,0x0003003e, - 0x000004c9,0x000004c6,0x00060039,0x00000006,0x000004ca,0x00000038,0x000004c7,0x000004c9, - 0x00050041,0x0000000d,0x000004cb,0x00000048,0x00000429,0x0004003d,0x00000006,0x000004cc, - 0x000004cb,0x00050085,0x00000006,0x000004cd,0x000004ca,0x000004cc,0x0004003d,0x00000006, - 0x000004ce,0x00000335,0x00050081,0x00000006,0x000004cf,0x000004ce,0x000004cd,0x0003003e, - 0x00000335,0x000004cf,0x000200f9,0x0000042e,0x000200f8,0x0000042e,0x0004003d,0x00000006, - 0x000004d0,0x00000335,0x000200fe,0x000004d0,0x00010038 + 0x0000000d,0x0000031f,0x00000007,0x0004003b,0x00000026,0x00000326,0x00000007,0x0004003b, + 0x00000034,0x0000032e,0x00000007,0x0004003b,0x00000034,0x0000033b,0x00000007,0x0004003b, + 0x00000026,0x0000033d,0x00000007,0x0004003b,0x00000026,0x0000034b,0x00000007,0x0004003b, + 0x00000034,0x00000353,0x00000007,0x0004003b,0x00000034,0x00000360,0x00000007,0x0004003b, + 0x00000026,0x00000362,0x00000007,0x0004003b,0x0000000d,0x00000370,0x00000007,0x0004003b, + 0x00000379,0x0000037a,0x00000007,0x0004003b,0x0000000d,0x00000392,0x00000007,0x0004003b, + 0x0000000d,0x00000395,0x00000007,0x0004003b,0x0000000d,0x0000039e,0x00000007,0x0004003b, + 0x0000000d,0x000003a1,0x00000007,0x0004003b,0x0000000d,0x000003aa,0x00000007,0x0004003b, + 0x0000000d,0x000003ad,0x00000007,0x0004003b,0x0000000d,0x000003b6,0x00000007,0x0004003b, + 0x0000000d,0x000003b9,0x00000007,0x0004003b,0x0000000d,0x000003de,0x00000007,0x0004003b, + 0x00000026,0x000003e6,0x00000007,0x0004003b,0x00000034,0x000003ee,0x00000007,0x0004003b, + 0x00000026,0x000003fa,0x00000007,0x0004003b,0x00000034,0x0000040d,0x00000007,0x0004003b, + 0x00000026,0x0000040f,0x00000007,0x0004003b,0x0000000d,0x0000041c,0x00000007,0x0004003b, + 0x00000379,0x00000421,0x00000007,0x0004003b,0x0000000d,0x00000439,0x00000007,0x0004003b, + 0x0000000d,0x0000043c,0x00000007,0x0004003b,0x0000000d,0x00000445,0x00000007,0x0004003b, + 0x0000000d,0x00000448,0x00000007,0x0004003b,0x0000000d,0x00000451,0x00000007,0x0004003b, + 0x0000000d,0x00000454,0x00000007,0x0004003b,0x0000000d,0x0000045d,0x00000007,0x0004003b, + 0x0000000d,0x00000460,0x00000007,0x0004003b,0x0000000d,0x00000485,0x00000007,0x0004003b, + 0x00000026,0x0000048e,0x00000007,0x0004003b,0x00000034,0x00000496,0x00000007,0x0004003b, + 0x00000026,0x000004a2,0x00000007,0x0004003b,0x00000034,0x000004b4,0x00000007,0x0004003b, + 0x00000026,0x000004b6,0x00000007,0x0003003e,0x0000031f,0x0000009a,0x00050041,0x0000000d, + 0x00000321,0x00000048,0x00000320,0x0004003d,0x00000006,0x00000322,0x00000321,0x000500ba, + 0x0000009b,0x00000323,0x00000322,0x0000009a,0x000300f7,0x00000325,0x00000000,0x000400fa, + 0x00000323,0x00000324,0x00000325,0x000200f8,0x00000324,0x0003003e,0x00000326,0x00000150, + 0x000200f9,0x00000327,0x000200f8,0x00000327,0x000400f6,0x00000329,0x0000032a,0x00000000, + 0x000200f9,0x0000032b,0x000200f8,0x0000032b,0x0004003d,0x00000025,0x0000032c,0x00000326, + 0x000500b1,0x0000009b,0x0000032d,0x0000032c,0x0000015c,0x000400fa,0x0000032d,0x00000328, + 0x00000329,0x000200f8,0x00000328,0x0004003d,0x00000025,0x0000032f,0x00000326,0x0004003d, + 0x00000025,0x00000330,0x00000326,0x00060041,0x0000000d,0x00000331,0x00000043,0x00000330, + 0x000002c9,0x0004003d,0x00000006,0x00000332,0x00000331,0x0004003d,0x00000025,0x00000333, + 0x00000326,0x00060041,0x0000000d,0x00000334,0x00000043,0x00000333,0x000002ca,0x0004003d, + 0x00000006,0x00000335,0x00000334,0x0004003d,0x00000006,0x00000336,0x00000044,0x0008000c, + 0x00000006,0x00000337,0x00000001,0x0000002e,0x00000332,0x00000335,0x00000336,0x00050041, + 0x0000000d,0x00000338,0x0000032e,0x0000032f,0x0003003e,0x00000338,0x00000337,0x000200f9, + 0x0000032a,0x000200f8,0x0000032a,0x0004003d,0x00000025,0x00000339,0x00000326,0x00050080, + 0x00000025,0x0000033a,0x00000339,0x000002a3,0x0003003e,0x00000326,0x0000033a,0x000200f9, + 0x00000327,0x000200f8,0x00000329,0x0004003d,0x00000033,0x0000033c,0x0000032e,0x0003003e, + 0x0000033b,0x0000033c,0x0004003d,0x00000025,0x0000033e,0x00000047,0x0003003e,0x0000033d, + 0x0000033e,0x00060039,0x00000006,0x0000033f,0x00000038,0x0000033b,0x0000033d,0x00050041, + 0x0000000d,0x00000340,0x00000048,0x00000320,0x0004003d,0x00000006,0x00000341,0x00000340, + 0x00050085,0x00000006,0x00000342,0x0000033f,0x00000341,0x0004003d,0x00000006,0x00000343, + 0x0000031f,0x00050081,0x00000006,0x00000344,0x00000343,0x00000342,0x0003003e,0x0000031f, + 0x00000344,0x000200f9,0x00000325,0x000200f8,0x00000325,0x00050041,0x0000000d,0x00000346, + 0x00000048,0x00000345,0x0004003d,0x00000006,0x00000347,0x00000346,0x000500ba,0x0000009b, + 0x00000348,0x00000347,0x0000009a,0x000300f7,0x0000034a,0x00000000,0x000400fa,0x00000348, + 0x00000349,0x0000034a,0x000200f8,0x00000349,0x0003003e,0x0000034b,0x00000150,0x000200f9, + 0x0000034c,0x000200f8,0x0000034c,0x000400f6,0x0000034e,0x0000034f,0x00000000,0x000200f9, + 0x00000350,0x000200f8,0x00000350,0x0004003d,0x00000025,0x00000351,0x0000034b,0x000500b1, + 0x0000009b,0x00000352,0x00000351,0x0000015c,0x000400fa,0x00000352,0x0000034d,0x0000034e, + 0x000200f8,0x0000034d,0x0004003d,0x00000025,0x00000354,0x0000034b,0x0004003d,0x00000025, + 0x00000355,0x0000034b,0x00060041,0x0000000d,0x00000356,0x00000043,0x000002c9,0x00000355, + 0x0004003d,0x00000006,0x00000357,0x00000356,0x0004003d,0x00000025,0x00000358,0x0000034b, + 0x00060041,0x0000000d,0x00000359,0x00000043,0x000002ca,0x00000358,0x0004003d,0x00000006, + 0x0000035a,0x00000359,0x0004003d,0x00000006,0x0000035b,0x00000045,0x0008000c,0x00000006, + 0x0000035c,0x00000001,0x0000002e,0x00000357,0x0000035a,0x0000035b,0x00050041,0x0000000d, + 0x0000035d,0x00000353,0x00000354,0x0003003e,0x0000035d,0x0000035c,0x000200f9,0x0000034f, + 0x000200f8,0x0000034f,0x0004003d,0x00000025,0x0000035e,0x0000034b,0x00050080,0x00000025, + 0x0000035f,0x0000035e,0x000002a3,0x0003003e,0x0000034b,0x0000035f,0x000200f9,0x0000034c, + 0x000200f8,0x0000034e,0x0004003d,0x00000033,0x00000361,0x00000353,0x0003003e,0x00000360, + 0x00000361,0x0004003d,0x00000025,0x00000363,0x00000046,0x0003003e,0x00000362,0x00000363, + 0x00060039,0x00000006,0x00000364,0x00000038,0x00000360,0x00000362,0x00050041,0x0000000d, + 0x00000365,0x00000048,0x00000345,0x0004003d,0x00000006,0x00000366,0x00000365,0x00050085, + 0x00000006,0x00000367,0x00000364,0x00000366,0x0004003d,0x00000006,0x00000368,0x0000031f, + 0x00050081,0x00000006,0x00000369,0x00000368,0x00000367,0x0003003e,0x0000031f,0x00000369, + 0x000200f9,0x0000034a,0x000200f8,0x0000034a,0x00050041,0x0000000d,0x0000036b,0x00000048, + 0x0000036a,0x0004003d,0x00000006,0x0000036c,0x0000036b,0x000500ba,0x0000009b,0x0000036d, + 0x0000036c,0x0000009a,0x000300f7,0x0000036f,0x00000000,0x000400fa,0x0000036d,0x0000036e, + 0x0000036f,0x000200f8,0x0000036e,0x0004003d,0x00000006,0x00000372,0x00000044,0x0004003d, + 0x00000006,0x00000373,0x00000045,0x00050083,0x00000006,0x00000374,0x00000372,0x00000373, + 0x00050085,0x00000006,0x00000375,0x00000371,0x00000374,0x00050081,0x00000006,0x00000376, + 0x00000371,0x00000375,0x0003003e,0x00000370,0x00000376,0x00060041,0x0000000d,0x0000037b, + 0x00000043,0x000002c9,0x000002a3,0x0004003d,0x00000006,0x0000037c,0x0000037b,0x00060041, + 0x0000000d,0x0000037d,0x00000043,0x000002a3,0x000002c9,0x0004003d,0x00000006,0x0000037e, + 0x0000037d,0x0004003d,0x00000006,0x0000037f,0x00000370,0x0008000c,0x00000006,0x00000380, + 0x00000001,0x0000002e,0x0000037c,0x0000037e,0x0000037f,0x00050041,0x0000000d,0x00000381, + 0x0000037a,0x000002a3,0x0003003e,0x00000381,0x00000380,0x00060041,0x0000000d,0x00000382, + 0x00000043,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000383,0x00000382,0x00060041, + 0x0000000d,0x00000384,0x00000043,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x00000385, + 0x00000384,0x0004003d,0x00000006,0x00000386,0x00000370,0x0008000c,0x00000006,0x00000387, + 0x00000001,0x0000002e,0x00000383,0x00000385,0x00000386,0x00050041,0x0000000d,0x00000388, + 0x0000037a,0x000002ca,0x0003003e,0x00000388,0x00000387,0x00060041,0x0000000d,0x00000389, + 0x00000043,0x000002cb,0x000002ca,0x0004003d,0x00000006,0x0000038a,0x00000389,0x00060041, + 0x0000000d,0x0000038b,0x00000043,0x000002ca,0x000002cb,0x0004003d,0x00000006,0x0000038c, + 0x0000038b,0x0004003d,0x00000006,0x0000038d,0x00000370,0x0008000c,0x00000006,0x0000038e, + 0x00000001,0x0000002e,0x0000038a,0x0000038c,0x0000038d,0x00050041,0x0000000d,0x0000038f, + 0x0000037a,0x000002cc,0x0003003e,0x0000038f,0x0000038e,0x0004003d,0x00000006,0x00000390, + 0x00000370,0x00050083,0x00000006,0x00000391,0x00000390,0x00000371,0x0003003e,0x00000370, + 0x00000391,0x0004003d,0x00000006,0x00000393,0x00000370,0x000500be,0x0000009b,0x00000394, + 0x00000393,0x0000009a,0x000300f7,0x00000397,0x00000000,0x000400fa,0x00000394,0x00000396, + 0x0000039a,0x000200f8,0x00000396,0x00060041,0x0000000d,0x00000398,0x00000043,0x00000150, + 0x000002c9,0x0004003d,0x00000006,0x00000399,0x00000398,0x0003003e,0x00000395,0x00000399, + 0x000200f9,0x00000397,0x000200f8,0x0000039a,0x00060041,0x0000000d,0x0000039b,0x00000043, + 0x000002c9,0x00000150,0x0004003d,0x00000006,0x0000039c,0x0000039b,0x0003003e,0x00000395, + 0x0000039c,0x000200f9,0x00000397,0x000200f8,0x00000397,0x0004003d,0x00000006,0x0000039d, + 0x00000395,0x0003003e,0x00000392,0x0000039d,0x0004003d,0x00000006,0x0000039f,0x00000370, + 0x000500be,0x0000009b,0x000003a0,0x0000039f,0x0000009a,0x000300f7,0x000003a3,0x00000000, + 0x000400fa,0x000003a0,0x000003a2,0x000003a6,0x000200f8,0x000003a2,0x00060041,0x0000000d, + 0x000003a4,0x00000043,0x000002a3,0x000002ca,0x0004003d,0x00000006,0x000003a5,0x000003a4, + 0x0003003e,0x000003a1,0x000003a5,0x000200f9,0x000003a3,0x000200f8,0x000003a6,0x00060041, + 0x0000000d,0x000003a7,0x00000043,0x000002ca,0x000002a3,0x0004003d,0x00000006,0x000003a8, + 0x000003a7,0x0003003e,0x000003a1,0x000003a8,0x000200f9,0x000003a3,0x000200f8,0x000003a3, + 0x0004003d,0x00000006,0x000003a9,0x000003a1,0x0003003e,0x0000039e,0x000003a9,0x0004003d, + 0x00000006,0x000003ab,0x00000370,0x000500be,0x0000009b,0x000003ac,0x000003ab,0x0000009a, + 0x000300f7,0x000003af,0x00000000,0x000400fa,0x000003ac,0x000003ae,0x000003b2,0x000200f8, + 0x000003ae,0x00060041,0x0000000d,0x000003b0,0x00000043,0x000002c9,0x000002cb,0x0004003d, + 0x00000006,0x000003b1,0x000003b0,0x0003003e,0x000003ad,0x000003b1,0x000200f9,0x000003af, + 0x000200f8,0x000003b2,0x00060041,0x0000000d,0x000003b3,0x00000043,0x000002cb,0x000002c9, + 0x0004003d,0x00000006,0x000003b4,0x000003b3,0x0003003e,0x000003ad,0x000003b4,0x000200f9, + 0x000003af,0x000200f8,0x000003af,0x0004003d,0x00000006,0x000003b5,0x000003ad,0x0003003e, + 0x000003aa,0x000003b5,0x0004003d,0x00000006,0x000003b7,0x00000370,0x000500be,0x0000009b, + 0x000003b8,0x000003b7,0x0000009a,0x000300f7,0x000003bb,0x00000000,0x000400fa,0x000003b8, + 0x000003ba,0x000003be,0x000200f8,0x000003ba,0x00060041,0x0000000d,0x000003bc,0x00000043, + 0x000002ca,0x000002cc,0x0004003d,0x00000006,0x000003bd,0x000003bc,0x0003003e,0x000003b9, + 0x000003bd,0x000200f9,0x000003bb,0x000200f8,0x000003be,0x00060041,0x0000000d,0x000003bf, + 0x00000043,0x000002cc,0x000002ca,0x0004003d,0x00000006,0x000003c0,0x000003bf,0x0003003e, + 0x000003b9,0x000003c0,0x000200f9,0x000003bb,0x000200f8,0x000003bb,0x0004003d,0x00000006, + 0x000003c1,0x000003b9,0x0003003e,0x000003b6,0x000003c1,0x00060041,0x0000000d,0x000003c2, + 0x00000043,0x000002a3,0x000002a3,0x0004003d,0x00000006,0x000003c3,0x000003c2,0x0004003d, + 0x00000006,0x000003c4,0x00000392,0x0004003d,0x00000006,0x000003c5,0x00000370,0x0006000c, + 0x00000006,0x000003c6,0x00000001,0x00000004,0x000003c5,0x0008000c,0x00000006,0x000003c7, + 0x00000001,0x0000002e,0x000003c3,0x000003c4,0x000003c6,0x00050041,0x0000000d,0x000003c8, + 0x0000037a,0x00000150,0x0003003e,0x000003c8,0x000003c7,0x00060041,0x0000000d,0x000003c9, + 0x00000043,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x000003ca,0x000003c9,0x0004003d, + 0x00000006,0x000003cb,0x0000039e,0x0004003d,0x00000006,0x000003cc,0x00000370,0x0006000c, + 0x00000006,0x000003cd,0x00000001,0x00000004,0x000003cc,0x0008000c,0x00000006,0x000003ce, + 0x00000001,0x0000002e,0x000003ca,0x000003cb,0x000003cd,0x00050041,0x0000000d,0x000003cf, + 0x0000037a,0x000002c9,0x0003003e,0x000003cf,0x000003ce,0x00060041,0x0000000d,0x000003d0, + 0x00000043,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x000003d1,0x000003d0,0x0004003d, + 0x00000006,0x000003d2,0x000003aa,0x0004003d,0x00000006,0x000003d3,0x00000370,0x0006000c, + 0x00000006,0x000003d4,0x00000001,0x00000004,0x000003d3,0x0008000c,0x00000006,0x000003d5, + 0x00000001,0x0000002e,0x000003d1,0x000003d2,0x000003d4,0x00050041,0x0000000d,0x000003d6, + 0x0000037a,0x000002cb,0x0003003e,0x000003d6,0x000003d5,0x00060041,0x0000000d,0x000003d7, + 0x00000043,0x000002cb,0x000002cb,0x0004003d,0x00000006,0x000003d8,0x000003d7,0x0004003d, + 0x00000006,0x000003d9,0x000003b6,0x0004003d,0x00000006,0x000003da,0x00000370,0x0006000c, + 0x00000006,0x000003db,0x00000001,0x00000004,0x000003da,0x0008000c,0x00000006,0x000003dc, + 0x00000001,0x0000002e,0x000003d8,0x000003d9,0x000003db,0x00050041,0x0000000d,0x000003dd, + 0x0000037a,0x0000015c,0x0003003e,0x000003dd,0x000003dc,0x0004003d,0x00000006,0x000003df, + 0x00000044,0x0004003d,0x00000006,0x000003e0,0x00000045,0x00050081,0x00000006,0x000003e1, + 0x000003df,0x000003e0,0x0003003e,0x000003de,0x000003e1,0x0004003d,0x00000006,0x000003e2, + 0x000003de,0x000500be,0x0000009b,0x000003e3,0x000003e2,0x000000a8,0x000300f7,0x000003e5, + 0x00000000,0x000400fa,0x000003e3,0x000003e4,0x000003f9,0x000200f8,0x000003e4,0x0003003e, + 0x000003e6,0x00000150,0x000200f9,0x000003e7,0x000200f8,0x000003e7,0x000400f6,0x000003e9, + 0x000003ea,0x00000000,0x000200f9,0x000003eb,0x000200f8,0x000003eb,0x0004003d,0x00000025, + 0x000003ec,0x000003e6,0x000500b1,0x0000009b,0x000003ed,0x000003ec,0x0000015c,0x000400fa, + 0x000003ed,0x000003e8,0x000003e9,0x000200f8,0x000003e8,0x0004003d,0x00000025,0x000003ef, + 0x000003e6,0x0004003d,0x00000025,0x000003f0,0x000003e6,0x00050080,0x00000025,0x000003f1, + 0x000003f0,0x000002a3,0x00050041,0x0000000d,0x000003f2,0x0000037a,0x000003f1,0x0004003d, + 0x00000006,0x000003f3,0x000003f2,0x00050041,0x0000000d,0x000003f4,0x000003ee,0x000003ef, + 0x0003003e,0x000003f4,0x000003f3,0x000200f9,0x000003ea,0x000200f8,0x000003ea,0x0004003d, + 0x00000025,0x000003f5,0x000003e6,0x00050080,0x00000025,0x000003f6,0x000003f5,0x000002a3, + 0x0003003e,0x000003e6,0x000003f6,0x000200f9,0x000003e7,0x000200f8,0x000003e9,0x0004003d, + 0x00000006,0x000003f7,0x000003de,0x00050083,0x00000006,0x000003f8,0x000003f7,0x000000a8, + 0x0003003e,0x000003de,0x000003f8,0x000200f9,0x000003e5,0x000200f8,0x000003f9,0x0003003e, + 0x000003fa,0x00000150,0x000200f9,0x000003fb,0x000200f8,0x000003fb,0x000400f6,0x000003fd, + 0x000003fe,0x00000000,0x000200f9,0x000003ff,0x000200f8,0x000003ff,0x0004003d,0x00000025, + 0x00000400,0x000003fa,0x000500b1,0x0000009b,0x00000401,0x00000400,0x0000015c,0x000400fa, + 0x00000401,0x000003fc,0x000003fd,0x000200f8,0x000003fc,0x0004003d,0x00000025,0x00000402, + 0x000003fa,0x0004003d,0x00000025,0x00000403,0x000003fa,0x00050041,0x0000000d,0x00000404, + 0x0000037a,0x00000403,0x0004003d,0x00000006,0x00000405,0x00000404,0x00050041,0x0000000d, + 0x00000406,0x000003ee,0x00000402,0x0003003e,0x00000406,0x00000405,0x000200f9,0x000003fe, + 0x000200f8,0x000003fe,0x0004003d,0x00000025,0x00000407,0x000003fa,0x00050080,0x00000025, + 0x00000408,0x00000407,0x000002a3,0x0003003e,0x000003fa,0x00000408,0x000200f9,0x000003fb, + 0x000200f8,0x000003fd,0x000200f9,0x000003e5,0x000200f8,0x000003e5,0x0004003d,0x00000006, + 0x00000409,0x000003de,0x00050085,0x00000006,0x0000040b,0x00000409,0x0000040a,0x0004006e, + 0x00000025,0x0000040c,0x0000040b,0x0004003d,0x00000033,0x0000040e,0x000003ee,0x0003003e, + 0x0000040d,0x0000040e,0x0003003e,0x0000040f,0x0000040c,0x00060039,0x00000006,0x00000410, + 0x00000038,0x0000040d,0x0000040f,0x00050041,0x0000000d,0x00000411,0x00000048,0x0000036a, + 0x0004003d,0x00000006,0x00000412,0x00000411,0x00050085,0x00000006,0x00000413,0x00000410, + 0x00000412,0x0004003d,0x00000006,0x00000414,0x0000031f,0x00050081,0x00000006,0x00000415, + 0x00000414,0x00000413,0x0003003e,0x0000031f,0x00000415,0x000200f9,0x0000036f,0x000200f8, + 0x0000036f,0x00050041,0x0000000d,0x00000417,0x00000048,0x00000416,0x0004003d,0x00000006, + 0x00000418,0x00000417,0x000500ba,0x0000009b,0x00000419,0x00000418,0x0000009a,0x000300f7, + 0x0000041b,0x00000000,0x000400fa,0x00000419,0x0000041a,0x0000041b,0x000200f8,0x0000041a, + 0x0004003d,0x00000006,0x0000041d,0x00000044,0x0004003d,0x00000006,0x0000041e,0x00000045, + 0x00050081,0x00000006,0x0000041f,0x0000041d,0x0000041e,0x00050085,0x00000006,0x00000420, + 0x00000371,0x0000041f,0x0003003e,0x0000041c,0x00000420,0x00060041,0x0000000d,0x00000422, + 0x00000043,0x000002ca,0x000002a3,0x0004003d,0x00000006,0x00000423,0x00000422,0x00060041, + 0x0000000d,0x00000424,0x00000043,0x000002cb,0x000002c9,0x0004003d,0x00000006,0x00000425, + 0x00000424,0x0004003d,0x00000006,0x00000426,0x0000041c,0x0008000c,0x00000006,0x00000427, + 0x00000001,0x0000002e,0x00000423,0x00000425,0x00000426,0x00050041,0x0000000d,0x00000428, + 0x00000421,0x000002a3,0x0003003e,0x00000428,0x00000427,0x00060041,0x0000000d,0x00000429, + 0x00000043,0x000002c9,0x000002c9,0x0004003d,0x00000006,0x0000042a,0x00000429,0x00060041, + 0x0000000d,0x0000042b,0x00000043,0x000002ca,0x000002ca,0x0004003d,0x00000006,0x0000042c, + 0x0000042b,0x0004003d,0x00000006,0x0000042d,0x0000041c,0x0008000c,0x00000006,0x0000042e, + 0x00000001,0x0000002e,0x0000042a,0x0000042c,0x0000042d,0x00050041,0x0000000d,0x0000042f, + 0x00000421,0x000002ca,0x0003003e,0x0000042f,0x0000042e,0x00060041,0x0000000d,0x00000430, + 0x00000043,0x000002a3,0x000002ca,0x0004003d,0x00000006,0x00000431,0x00000430,0x00060041, + 0x0000000d,0x00000432,0x00000043,0x000002c9,0x000002cb,0x0004003d,0x00000006,0x00000433, + 0x00000432,0x0004003d,0x00000006,0x00000434,0x0000041c,0x0008000c,0x00000006,0x00000435, + 0x00000001,0x0000002e,0x00000431,0x00000433,0x00000434,0x00050041,0x0000000d,0x00000436, + 0x00000421,0x000002cc,0x0003003e,0x00000436,0x00000435,0x0004003d,0x00000006,0x00000437, + 0x0000041c,0x00050083,0x00000006,0x00000438,0x00000437,0x00000371,0x0003003e,0x0000041c, + 0x00000438,0x0004003d,0x00000006,0x0000043a,0x0000041c,0x000500be,0x0000009b,0x0000043b, + 0x0000043a,0x0000009a,0x000300f7,0x0000043e,0x00000000,0x000400fa,0x0000043b,0x0000043d, + 0x00000441,0x000200f8,0x0000043d,0x00060041,0x0000000d,0x0000043f,0x00000043,0x000002cc, + 0x000002c9,0x0004003d,0x00000006,0x00000440,0x0000043f,0x0003003e,0x0000043c,0x00000440, + 0x000200f9,0x0000043e,0x000200f8,0x00000441,0x00060041,0x0000000d,0x00000442,0x00000043, + 0x000002ca,0x00000150,0x0004003d,0x00000006,0x00000443,0x00000442,0x0003003e,0x0000043c, + 0x00000443,0x000200f9,0x0000043e,0x000200f8,0x0000043e,0x0004003d,0x00000006,0x00000444, + 0x0000043c,0x0003003e,0x00000439,0x00000444,0x0004003d,0x00000006,0x00000446,0x0000041c, + 0x000500be,0x0000009b,0x00000447,0x00000446,0x0000009a,0x000300f7,0x0000044a,0x00000000, + 0x000400fa,0x00000447,0x00000449,0x0000044d,0x000200f8,0x00000449,0x00060041,0x0000000d, + 0x0000044b,0x00000043,0x000002cb,0x000002ca,0x0004003d,0x00000006,0x0000044c,0x0000044b, + 0x0003003e,0x00000448,0x0000044c,0x000200f9,0x0000044a,0x000200f8,0x0000044d,0x00060041, + 0x0000000d,0x0000044e,0x00000043,0x000002c9,0x000002a3,0x0004003d,0x00000006,0x0000044f, + 0x0000044e,0x0003003e,0x00000448,0x0000044f,0x000200f9,0x0000044a,0x000200f8,0x0000044a, + 0x0004003d,0x00000006,0x00000450,0x00000448,0x0003003e,0x00000445,0x00000450,0x0004003d, + 0x00000006,0x00000452,0x0000041c,0x000500be,0x0000009b,0x00000453,0x00000452,0x0000009a, + 0x000300f7,0x00000456,0x00000000,0x000400fa,0x00000453,0x00000455,0x00000459,0x000200f8, + 0x00000455,0x00060041,0x0000000d,0x00000457,0x00000043,0x000002ca,0x000002cb,0x0004003d, + 0x00000006,0x00000458,0x00000457,0x0003003e,0x00000454,0x00000458,0x000200f9,0x00000456, + 0x000200f8,0x00000459,0x00060041,0x0000000d,0x0000045a,0x00000043,0x000002a3,0x000002c9, + 0x0004003d,0x00000006,0x0000045b,0x0000045a,0x0003003e,0x00000454,0x0000045b,0x000200f9, + 0x00000456,0x000200f8,0x00000456,0x0004003d,0x00000006,0x0000045c,0x00000454,0x0003003e, + 0x00000451,0x0000045c,0x0004003d,0x00000006,0x0000045e,0x0000041c,0x000500be,0x0000009b, + 0x0000045f,0x0000045e,0x0000009a,0x000300f7,0x00000462,0x00000000,0x000400fa,0x0000045f, + 0x00000461,0x00000465,0x000200f8,0x00000461,0x00060041,0x0000000d,0x00000463,0x00000043, + 0x000002c9,0x000002cc,0x0004003d,0x00000006,0x00000464,0x00000463,0x0003003e,0x00000460, + 0x00000464,0x000200f9,0x00000462,0x000200f8,0x00000465,0x00060041,0x0000000d,0x00000466, + 0x00000043,0x00000150,0x000002ca,0x0004003d,0x00000006,0x00000467,0x00000466,0x0003003e, + 0x00000460,0x00000467,0x000200f9,0x00000462,0x000200f8,0x00000462,0x0004003d,0x00000006, + 0x00000468,0x00000460,0x0003003e,0x0000045d,0x00000468,0x00060041,0x0000000d,0x00000469, + 0x00000043,0x000002cb,0x000002a3,0x0004003d,0x00000006,0x0000046a,0x00000469,0x0004003d, + 0x00000006,0x0000046b,0x00000439,0x0004003d,0x00000006,0x0000046c,0x0000041c,0x0006000c, + 0x00000006,0x0000046d,0x00000001,0x00000004,0x0000046c,0x0008000c,0x00000006,0x0000046e, + 0x00000001,0x0000002e,0x0000046a,0x0000046b,0x0000046d,0x00050041,0x0000000d,0x0000046f, + 0x00000421,0x00000150,0x0003003e,0x0000046f,0x0000046e,0x00060041,0x0000000d,0x00000470, + 0x00000043,0x000002ca,0x000002c9,0x0004003d,0x00000006,0x00000471,0x00000470,0x0004003d, + 0x00000006,0x00000472,0x00000445,0x0004003d,0x00000006,0x00000473,0x0000041c,0x0006000c, + 0x00000006,0x00000474,0x00000001,0x00000004,0x00000473,0x0008000c,0x00000006,0x00000475, + 0x00000001,0x0000002e,0x00000471,0x00000472,0x00000474,0x00050041,0x0000000d,0x00000476, + 0x00000421,0x000002c9,0x0003003e,0x00000476,0x00000475,0x00060041,0x0000000d,0x00000477, + 0x00000043,0x000002c9,0x000002ca,0x0004003d,0x00000006,0x00000478,0x00000477,0x0004003d, + 0x00000006,0x00000479,0x00000451,0x0004003d,0x00000006,0x0000047a,0x0000041c,0x0006000c, + 0x00000006,0x0000047b,0x00000001,0x00000004,0x0000047a,0x0008000c,0x00000006,0x0000047c, + 0x00000001,0x0000002e,0x00000478,0x00000479,0x0000047b,0x00050041,0x0000000d,0x0000047d, + 0x00000421,0x000002cb,0x0003003e,0x0000047d,0x0000047c,0x00060041,0x0000000d,0x0000047e, + 0x00000043,0x000002a3,0x000002cb,0x0004003d,0x00000006,0x0000047f,0x0000047e,0x0004003d, + 0x00000006,0x00000480,0x0000045d,0x0004003d,0x00000006,0x00000481,0x0000041c,0x0006000c, + 0x00000006,0x00000482,0x00000001,0x00000004,0x00000481,0x0008000c,0x00000006,0x00000483, + 0x00000001,0x0000002e,0x0000047f,0x00000480,0x00000482,0x00050041,0x0000000d,0x00000484, + 0x00000421,0x0000015c,0x0003003e,0x00000484,0x00000483,0x0004003d,0x00000006,0x00000486, + 0x00000044,0x0004003d,0x00000006,0x00000487,0x00000045,0x00050083,0x00000006,0x00000488, + 0x00000486,0x00000487,0x00050081,0x00000006,0x00000489,0x000000a8,0x00000488,0x0003003e, + 0x00000485,0x00000489,0x0004003d,0x00000006,0x0000048a,0x00000485,0x000500be,0x0000009b, + 0x0000048b,0x0000048a,0x000000a8,0x000300f7,0x0000048d,0x00000000,0x000400fa,0x0000048b, + 0x0000048c,0x000004a1,0x000200f8,0x0000048c,0x0003003e,0x0000048e,0x00000150,0x000200f9, + 0x0000048f,0x000200f8,0x0000048f,0x000400f6,0x00000491,0x00000492,0x00000000,0x000200f9, + 0x00000493,0x000200f8,0x00000493,0x0004003d,0x00000025,0x00000494,0x0000048e,0x000500b1, + 0x0000009b,0x00000495,0x00000494,0x0000015c,0x000400fa,0x00000495,0x00000490,0x00000491, + 0x000200f8,0x00000490,0x0004003d,0x00000025,0x00000497,0x0000048e,0x0004003d,0x00000025, + 0x00000498,0x0000048e,0x00050080,0x00000025,0x00000499,0x00000498,0x000002a3,0x00050041, + 0x0000000d,0x0000049a,0x00000421,0x00000499,0x0004003d,0x00000006,0x0000049b,0x0000049a, + 0x00050041,0x0000000d,0x0000049c,0x00000496,0x00000497,0x0003003e,0x0000049c,0x0000049b, + 0x000200f9,0x00000492,0x000200f8,0x00000492,0x0004003d,0x00000025,0x0000049d,0x0000048e, + 0x00050080,0x00000025,0x0000049e,0x0000049d,0x000002a3,0x0003003e,0x0000048e,0x0000049e, + 0x000200f9,0x0000048f,0x000200f8,0x00000491,0x0004003d,0x00000006,0x0000049f,0x00000485, + 0x00050083,0x00000006,0x000004a0,0x0000049f,0x000000a8,0x0003003e,0x00000485,0x000004a0, + 0x000200f9,0x0000048d,0x000200f8,0x000004a1,0x0003003e,0x000004a2,0x00000150,0x000200f9, + 0x000004a3,0x000200f8,0x000004a3,0x000400f6,0x000004a5,0x000004a6,0x00000000,0x000200f9, + 0x000004a7,0x000200f8,0x000004a7,0x0004003d,0x00000025,0x000004a8,0x000004a2,0x000500b1, + 0x0000009b,0x000004a9,0x000004a8,0x0000015c,0x000400fa,0x000004a9,0x000004a4,0x000004a5, + 0x000200f8,0x000004a4,0x0004003d,0x00000025,0x000004aa,0x000004a2,0x0004003d,0x00000025, + 0x000004ab,0x000004a2,0x00050041,0x0000000d,0x000004ac,0x00000421,0x000004ab,0x0004003d, + 0x00000006,0x000004ad,0x000004ac,0x00050041,0x0000000d,0x000004ae,0x00000496,0x000004aa, + 0x0003003e,0x000004ae,0x000004ad,0x000200f9,0x000004a6,0x000200f8,0x000004a6,0x0004003d, + 0x00000025,0x000004af,0x000004a2,0x00050080,0x00000025,0x000004b0,0x000004af,0x000002a3, + 0x0003003e,0x000004a2,0x000004b0,0x000200f9,0x000004a3,0x000200f8,0x000004a5,0x000200f9, + 0x0000048d,0x000200f8,0x0000048d,0x0004003d,0x00000006,0x000004b1,0x00000485,0x00050085, + 0x00000006,0x000004b2,0x000004b1,0x0000040a,0x0004006e,0x00000025,0x000004b3,0x000004b2, + 0x0004003d,0x00000033,0x000004b5,0x00000496,0x0003003e,0x000004b4,0x000004b5,0x0003003e, + 0x000004b6,0x000004b3,0x00060039,0x00000006,0x000004b7,0x00000038,0x000004b4,0x000004b6, + 0x00050041,0x0000000d,0x000004b8,0x00000048,0x00000416,0x0004003d,0x00000006,0x000004b9, + 0x000004b8,0x00050085,0x00000006,0x000004ba,0x000004b7,0x000004b9,0x0004003d,0x00000006, + 0x000004bb,0x0000031f,0x00050081,0x00000006,0x000004bc,0x000004bb,0x000004ba,0x0003003e, + 0x0000031f,0x000004bc,0x000200f9,0x0000041b,0x000200f8,0x0000041b,0x0004003d,0x00000006, + 0x000004bd,0x0000031f,0x000200fe,0x000004bd,0x00010038 }; diff --git a/app/src/main/cpp/shaders/nis_luma.frag b/app/src/main/cpp/shaders/nis_luma.frag new file mode 100644 index 0000000000..b1bdbebcb7 --- /dev/null +++ b/app/src/main/cpp/shaders/nis_luma.frag @@ -0,0 +1,36 @@ +#version 450 + +// ============================================================================= +// NIS prepass for nis3.frag: the game image copied 1:1 with its NIS luma in +// alpha (the compositor never uses the alpha of these targets). nis3.frag then +// reads four luma texels per textureGather instead of computing luma for each +// of 36 fetches per output pixel. +// +// Runs at the game (input) resolution into a target of the same size, so the +// output pixel reads its input pixel 1:1 (texelFetch at gl_FragCoord). +// Luma weights = nis.frag getY() (NVIDIA NIS, SDR: BT.709). +// ============================================================================= + +// DD_HALF: colour and luma in mediump; the texel address from gl_FragCoord stays highp +// (no default mediump: a 16-bit gl_FragCoord rounds pixel centres past x = 1024, e.g. +// 1279.5 -> 1280, and texelFetch then reads the wrong or an outside texel). +#ifdef DD_HALF +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D InputTexture; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0); full target +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out BL_MP vec4 outColor; + +void main() { + highp ivec2 p = ivec2(gl_FragCoord.xy); + BL_MP vec3 c = texelFetch(InputTexture, p, 0).rgb; + outColor = vec4(c, 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b); +} diff --git a/app/src/main/cpp/shaders/nis_luma_half_frag.h b/app/src/main/cpp/shaders/nis_luma_half_frag.h new file mode 100644 index 0000000000..f03f042715 --- /dev/null +++ b/app/src/main/cpp/shaders/nis_luma_half_frag.h @@ -0,0 +1,58 @@ + // 1116.2.0 + #pragma once +const uint32_t nis_luma_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000003e,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x00000020,0x0000003d, + 0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004, + 0x6e69616d,0x00000000,0x00030005,0x00000009,0x00000070,0x00060005,0x0000000d,0x465f6c67, + 0x43676172,0x64726f6f,0x00000000,0x00030005,0x00000014,0x00000063,0x00060005,0x00000018, + 0x75706e49,0x78655474,0x65727574,0x00000000,0x00050005,0x00000020,0x4374756f,0x726f6c6f, + 0x00000000,0x00030005,0x00000039,0x00004350,0x00040006,0x00000039,0x00000000,0x0063646e, + 0x00030005,0x0000003b,0x00006370,0x00060005,0x0000003d,0x67617266,0x43786554,0x64726f6f, + 0x00000000,0x00040047,0x0000000d,0x0000000b,0x0000000f,0x00030047,0x00000014,0x00000000, + 0x00030047,0x00000018,0x00000000,0x00040047,0x00000018,0x00000021,0x00000000,0x00040047, + 0x00000018,0x00000022,0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001d, + 0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047,0x00000020,0x00000000,0x00040047, + 0x00000020,0x0000001e,0x00000000,0x00030047,0x00000021,0x00000000,0x00030047,0x00000027, + 0x00000000,0x00030047,0x00000028,0x00000000,0x00030047,0x0000002c,0x00000000,0x00030047, + 0x0000002d,0x00000000,0x00030047,0x0000002e,0x00000000,0x00030047,0x00000032,0x00000000, + 0x00030047,0x00000033,0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000035, + 0x00000000,0x00030047,0x00000036,0x00000000,0x00030047,0x00000037,0x00000000,0x00030047, + 0x00000038,0x00000000,0x00030047,0x00000039,0x00000002,0x00050048,0x00000039,0x00000000, + 0x00000023,0x00000000,0x00040047,0x0000003d,0x0000001e,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017, + 0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00030016, + 0x0000000a,0x00000020,0x00040017,0x0000000b,0x0000000a,0x00000004,0x00040020,0x0000000c, + 0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040017,0x0000000e, + 0x0000000a,0x00000002,0x00040017,0x00000012,0x0000000a,0x00000003,0x00040020,0x00000013, + 0x00000007,0x00000012,0x00090019,0x00000015,0x0000000a,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000001,0x00000000,0x0003001b,0x00000016,0x00000015,0x00040020,0x00000017, + 0x00000000,0x00000016,0x0004003b,0x00000017,0x00000018,0x00000000,0x0004002b,0x00000006, + 0x0000001b,0x00000000,0x00040020,0x0000001f,0x00000003,0x0000000b,0x0004003b,0x0000001f, + 0x00000020,0x00000003,0x0004002b,0x0000000a,0x00000022,0x3e59b3d0,0x00040015,0x00000023, + 0x00000020,0x00000000,0x0004002b,0x00000023,0x00000024,0x00000000,0x00040020,0x00000025, + 0x00000007,0x0000000a,0x0004002b,0x0000000a,0x00000029,0x3f371759,0x0004002b,0x00000023, + 0x0000002a,0x00000001,0x0004002b,0x0000000a,0x0000002f,0x3d93dd98,0x0004002b,0x00000023, + 0x00000030,0x00000002,0x0003001e,0x00000039,0x0000000b,0x00040020,0x0000003a,0x00000009, + 0x00000039,0x0004003b,0x0000003a,0x0000003b,0x00000009,0x00040020,0x0000003c,0x00000001, + 0x0000000e,0x0004003b,0x0000003c,0x0000003d,0x00000001,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007, + 0x0004003b,0x00000013,0x00000014,0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d, + 0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001,0x0004006e, + 0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d,0x00000016, + 0x00000019,0x00000018,0x0004003d,0x00000007,0x0000001a,0x00000009,0x00040064,0x00000015, + 0x0000001c,0x00000019,0x0007005f,0x0000000b,0x0000001d,0x0000001c,0x0000001a,0x00000002, + 0x0000001b,0x0008004f,0x00000012,0x0000001e,0x0000001d,0x0000001d,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000014,0x0000001e,0x0004003d,0x00000012,0x00000021,0x00000014, + 0x00050041,0x00000025,0x00000026,0x00000014,0x00000024,0x0004003d,0x0000000a,0x00000027, + 0x00000026,0x00050085,0x0000000a,0x00000028,0x00000022,0x00000027,0x00050041,0x00000025, + 0x0000002b,0x00000014,0x0000002a,0x0004003d,0x0000000a,0x0000002c,0x0000002b,0x00050085, + 0x0000000a,0x0000002d,0x00000029,0x0000002c,0x00050081,0x0000000a,0x0000002e,0x00000028, + 0x0000002d,0x00050041,0x00000025,0x00000031,0x00000014,0x00000030,0x0004003d,0x0000000a, + 0x00000032,0x00000031,0x00050085,0x0000000a,0x00000033,0x0000002f,0x00000032,0x00050081, + 0x0000000a,0x00000034,0x0000002e,0x00000033,0x00050051,0x0000000a,0x00000035,0x00000021, + 0x00000000,0x00050051,0x0000000a,0x00000036,0x00000021,0x00000001,0x00050051,0x0000000a, + 0x00000037,0x00000021,0x00000002,0x00070050,0x0000000b,0x00000038,0x00000035,0x00000036, + 0x00000037,0x00000034,0x0003003e,0x00000020,0x00000038,0x000100fd,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/ntsc.frag b/app/src/main/cpp/shaders/ntsc.frag new file mode 100644 index 0000000000..9a57fa230f --- /dev/null +++ b/app/src/main/cpp/shaders/ntsc.frag @@ -0,0 +1,73 @@ +#version 450 + +// ============================================================================= +// NTSC composite-signal artifacts (YIQ chroma modulation + chromatic +// aberration + scanlines + subtle barrel warp) post effect. +// +// Ported verbatim from the OpenGL NTSCCombinedEffect.java shader. GL sampled +// with the varying vUV; here fragTexCoord IS that uv. GL's TextureSize and +// resolution uniforms were both the screen size -> we feed both from pc.resolution. +// Chroma offsets are fixed; this effect does not animate its color phase. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// Runs after HDR, before CRT in the canonical chain (analog signal, then tube). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // screen size in px (= TextureSize = resolution in GL) +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +#define PI 3.14159265 +#define SCANLINE_INTENSITY 0.35 +#define CHROMA_OFFSET 0.005 +#define BLUR_RADIUS 0.002 +#define WARP_AMOUNT 0.01 +#define SCANLINE_DARKEN 0.5 + +const mat3 yiq_mat = mat3( + 0.299, 0.587, 0.114, + 0.596, -0.275, -0.321, + 0.212, -0.523, 0.311 +); +const mat3 yiq2rgb_mat = mat3( + 1.0, 0.956, 0.621, + 1.0, -0.272, -0.647, + 1.0, -1.106, 1.705 +); + +vec3 applyNTSC(vec2 uv) { + return vec3( + texture(InputTexture, uv + vec2(CHROMA_OFFSET, 0.0)).r, + texture(InputTexture, uv + vec2(0.0, BLUR_RADIUS)).g, + texture(InputTexture, uv - vec2(CHROMA_OFFSET, 0.0)).b + ); +} + +vec3 applyScanlines(vec2 uv, vec3 col) { + float scanline = abs(sin(uv.y * pc.resolution.y * 2.0)) * SCANLINE_INTENSITY; + col *= 1.0 - (scanline * SCANLINE_DARKEN); + return col; +} + +vec2 applyWarp(vec2 uv) { + uv = uv * 2.0 - 1.0; + float r = sqrt(uv.x * uv.x + uv.y * uv.y); + uv += uv * (r * r) * WARP_AMOUNT; + return uv * 0.5 + 0.5; +} + +void main() { + vec2 warpedUV = applyWarp(fragTexCoord); + vec3 centerColor = texture(InputTexture, warpedUV).rgb; + vec3 ntscColor = applyNTSC(warpedUV); + vec3 scanlineColor = applyScanlines(warpedUV, centerColor); + vec3 finalColor = mix(ntscColor, scanlineColor, 0.7); + outColor = vec4(finalColor, 1.0); +} diff --git a/app/src/main/cpp/shaders/ntsc_frag.h b/app/src/main/cpp/shaders/ntsc_frag.h index 409c9d90f0..2b22036f66 100644 --- a/app/src/main/cpp/shaders/ntsc_frag.h +++ b/app/src/main/cpp/shaders/ntsc_frag.h @@ -1,153 +1,126 @@ + // 1116.3.0 #pragma once const uint32_t ntsc_code[] = { - 0x07230203,0x00010000,0x0008000b,0x000000d5,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010000,0x0008000b,0x000000af,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000bc,0x000000cf,0x00030010, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000077,0x00000091,0x00030010, 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00060005,0x0000000c,0x6c707061,0x53544e79,0x66762843,0x00003b32,0x00030005, - 0x0000000b,0x00007675,0x00070005,0x0000000f,0x6c707061,0x61635379,0x6e696c6e,0x76287365, - 0x003b3266,0x00030005,0x0000000e,0x00007675,0x00060005,0x00000013,0x6c707061,0x72615779, - 0x66762870,0x00003b32,0x00030005,0x00000012,0x00007675,0x00030005,0x00000016,0x006c6f63, - 0x00060005,0x0000001a,0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000020, - 0x00716979,0x00050005,0x00000032,0x6f726863,0x6850616d,0x00657361,0x00030005,0x00000038, - 0x00004350,0x00040006,0x00000038,0x00000000,0x0063646e,0x00060006,0x00000038,0x00000001, - 0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000038,0x00000002,0x6d617266,0x756f4365, - 0x0000746e,0x00030005,0x0000003a,0x00006370,0x00030005,0x00000058,0x00626772,0x00050005, - 0x00000066,0x616e6966,0x6c6f436c,0x0000726f,0x00030005,0x00000082,0x006c6f63,0x00050005, - 0x00000087,0x6e616373,0x656e696c,0x00000000,0x00030005,0x0000009e,0x00000072,0x00050005, - 0x000000ba,0x70726177,0x56556465,0x00000000,0x00060005,0x000000bc,0x67617266,0x43786554, - 0x64726f6f,0x00000000,0x00040005,0x000000bd,0x61726170,0x0000006d,0x00050005,0x000000c0, - 0x6373746e,0x6f6c6f43,0x00000072,0x00040005,0x000000c1,0x61726170,0x0000006d,0x00060005, - 0x000000c4,0x6e616373,0x656e696c,0x6f6c6f43,0x00000072,0x00040005,0x000000c5,0x61726170, - 0x0000006d,0x00050005,0x000000c8,0x616e6966,0x6c6f436c,0x0000726f,0x00050005,0x000000cf, - 0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000001a,0x00000021,0x00000000,0x00040047, - 0x0000001a,0x00000022,0x00000000,0x00030047,0x00000038,0x00000002,0x00050048,0x00000038, - 0x00000000,0x00000023,0x00000000,0x00050048,0x00000038,0x00000001,0x00000023,0x00000010, - 0x00050048,0x00000038,0x00000002,0x00000023,0x00000018,0x00040047,0x000000bc,0x0000001e, - 0x00000000,0x00040047,0x000000cf,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021, - 0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006, - 0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040017,0x00000009,0x00000006, - 0x00000003,0x00040021,0x0000000a,0x00000009,0x00000008,0x00040021,0x00000011,0x00000007, - 0x00000008,0x00040020,0x00000015,0x00000007,0x00000009,0x00090019,0x00000017,0x00000006, - 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000018, - 0x00000017,0x00040020,0x00000019,0x00000000,0x00000018,0x0004003b,0x00000019,0x0000001a, - 0x00000000,0x00040017,0x0000001d,0x00000006,0x00000004,0x00040018,0x00000022,0x00000009, - 0x00000003,0x0004002b,0x00000006,0x00000023,0x3e991687,0x0004002b,0x00000006,0x00000024, - 0x3f1645a2,0x0004002b,0x00000006,0x00000025,0x3de978d5,0x0006002c,0x00000009,0x00000026, - 0x00000023,0x00000024,0x00000025,0x0004002b,0x00000006,0x00000027,0x3f189375,0x0004002b, - 0x00000006,0x00000028,0xbe8ccccd,0x0004002b,0x00000006,0x00000029,0xbea45a1d,0x0006002c, - 0x00000009,0x0000002a,0x00000027,0x00000028,0x00000029,0x0004002b,0x00000006,0x0000002b, - 0x3e591687,0x0004002b,0x00000006,0x0000002c,0xbf05e354,0x0004002b,0x00000006,0x0000002d, - 0x3e9f3b64,0x0006002c,0x00000009,0x0000002e,0x0000002b,0x0000002c,0x0000002d,0x0006002c, - 0x00000022,0x0000002f,0x00000026,0x0000002a,0x0000002e,0x00040020,0x00000031,0x00000007, - 0x00000006,0x0004002b,0x00000006,0x00000033,0x40490fdb,0x00040015,0x00000034,0x00000020, - 0x00000000,0x0004002b,0x00000034,0x00000035,0x00000001,0x0005001e,0x00000038,0x0000001d, - 0x00000007,0x00000006,0x00040020,0x00000039,0x00000009,0x00000038,0x0004003b,0x00000039, - 0x0000003a,0x00000009,0x00040015,0x0000003b,0x00000020,0x00000001,0x0004002b,0x0000003b, - 0x0000003c,0x00000001,0x00040020,0x0000003d,0x00000009,0x00000006,0x0004002b,0x00000006, - 0x00000041,0x40000000,0x0004002b,0x0000003b,0x00000043,0x00000002,0x0004002b,0x00000006, - 0x00000049,0x3f000000,0x0004002b,0x00000034,0x00000053,0x00000002,0x0004002b,0x00000006, - 0x0000005a,0x3f800000,0x0004002b,0x00000006,0x0000005b,0x3f74bc6a,0x0004002b,0x00000006, - 0x0000005c,0x3f1ef9db,0x0006002c,0x00000009,0x0000005d,0x0000005a,0x0000005b,0x0000005c, - 0x0004002b,0x00000006,0x0000005e,0xbe8b4396,0x0004002b,0x00000006,0x0000005f,0xbf25a1cb, - 0x0006002c,0x00000009,0x00000060,0x0000005a,0x0000005e,0x0000005f,0x0004002b,0x00000006, - 0x00000061,0xbf8d9168,0x0004002b,0x00000006,0x00000062,0x3fda3d71,0x0006002c,0x00000009, - 0x00000063,0x0000005a,0x00000061,0x00000062,0x0006002c,0x00000022,0x00000064,0x0000005d, - 0x00000060,0x00000063,0x0004002b,0x00000006,0x00000069,0x3ba3d70a,0x0004002b,0x00000006, - 0x0000006a,0x00000000,0x0005002c,0x00000007,0x0000006b,0x00000069,0x0000006a,0x0004002b, - 0x00000034,0x0000006e,0x00000000,0x0004002b,0x00000006,0x00000073,0x3b03126f,0x0005002c, - 0x00000007,0x00000074,0x0000006a,0x00000073,0x0004002b,0x00000006,0x00000090,0x3eb33333, - 0x0004002b,0x00000006,0x000000b0,0x3c23d70a,0x00040020,0x000000bb,0x00000001,0x00000007, - 0x0004003b,0x000000bb,0x000000bc,0x00000001,0x0004002b,0x00000006,0x000000cb,0x3f333333, - 0x00040020,0x000000ce,0x00000003,0x0000001d,0x0004003b,0x000000ce,0x000000cf,0x00000003, + 0x0000000b,0x00007675,0x00080005,0x00000012,0x6c707061,0x61635379,0x6e696c6e,0x76287365, + 0x763b3266,0x003b3366,0x00030005,0x00000010,0x00007675,0x00030005,0x00000011,0x006c6f63, + 0x00060005,0x00000016,0x6c707061,0x72615779,0x66762870,0x00003b32,0x00030005,0x00000015, + 0x00007675,0x00060005,0x0000001b,0x75706e49,0x78655474,0x65727574,0x00000000,0x00050005, + 0x00000039,0x6e616373,0x656e696c,0x00000000,0x00030005,0x0000003c,0x00004350,0x00040006, + 0x0000003c,0x00000000,0x0063646e,0x00060006,0x0000003c,0x00000001,0x6f736572,0x6974756c, + 0x00006e6f,0x00030005,0x0000003e,0x00006370,0x00030005,0x00000059,0x00000072,0x00050005, + 0x00000075,0x70726177,0x56556465,0x00000000,0x00060005,0x00000077,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x00000078,0x61726170,0x0000006d,0x00050005,0x0000007b, + 0x746e6563,0x6f437265,0x00726f6c,0x00050005,0x00000080,0x6373746e,0x6f6c6f43,0x00000072, + 0x00040005,0x00000081,0x61726170,0x0000006d,0x00060005,0x00000084,0x6e616373,0x656e696c, + 0x6f6c6f43,0x00000072,0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000087, + 0x61726170,0x0000006d,0x00050005,0x0000008a,0x616e6966,0x6c6f436c,0x0000726f,0x00050005, + 0x00000091,0x4374756f,0x726f6c6f,0x00000000,0x00040047,0x0000001b,0x00000021,0x00000000, + 0x00040047,0x0000001b,0x00000022,0x00000000,0x00030047,0x0000003c,0x00000002,0x00050048, + 0x0000003c,0x00000000,0x00000023,0x00000000,0x00050048,0x0000003c,0x00000001,0x00000023, + 0x00000010,0x00040047,0x00000077,0x0000001e,0x00000000,0x00040047,0x00000091,0x0000001e, + 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, + 0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, + 0x00000007,0x00040017,0x00000009,0x00000006,0x00000003,0x00040021,0x0000000a,0x00000009, + 0x00000008,0x00040020,0x0000000e,0x00000007,0x00000009,0x00050021,0x0000000f,0x00000009, + 0x00000008,0x0000000e,0x00040021,0x00000014,0x00000007,0x00000008,0x00090019,0x00000018, + 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, + 0x00000019,0x00000018,0x00040020,0x0000001a,0x00000000,0x00000019,0x0004003b,0x0000001a, + 0x0000001b,0x00000000,0x0004002b,0x00000006,0x0000001e,0x3ba3d70a,0x0004002b,0x00000006, + 0x0000001f,0x00000000,0x0005002c,0x00000007,0x00000020,0x0000001e,0x0000001f,0x00040017, + 0x00000022,0x00000006,0x00000004,0x00040015,0x00000024,0x00000020,0x00000000,0x0004002b, + 0x00000024,0x00000025,0x00000000,0x0004002b,0x00000006,0x00000029,0x3b03126f,0x0005002c, + 0x00000007,0x0000002a,0x0000001f,0x00000029,0x0004002b,0x00000024,0x0000002d,0x00000001, + 0x0004002b,0x00000024,0x00000033,0x00000002,0x00040020,0x00000038,0x00000007,0x00000006, + 0x0004001e,0x0000003c,0x00000022,0x00000007,0x00040020,0x0000003d,0x00000009,0x0000003c, + 0x0004003b,0x0000003d,0x0000003e,0x00000009,0x00040015,0x0000003f,0x00000020,0x00000001, + 0x0004002b,0x0000003f,0x00000040,0x00000001,0x00040020,0x00000041,0x00000009,0x00000006, + 0x0004002b,0x00000006,0x00000045,0x40000000,0x0004002b,0x00000006,0x00000049,0x3eb33333, + 0x0004002b,0x00000006,0x0000004b,0x3f800000,0x0004002b,0x00000006,0x0000004d,0x3f000000, + 0x0004002b,0x00000006,0x0000006b,0x3c23d70a,0x00040020,0x00000076,0x00000001,0x00000007, + 0x0004003b,0x00000076,0x00000077,0x00000001,0x0004002b,0x00000006,0x0000008d,0x3f333333, + 0x00040020,0x00000090,0x00000003,0x00000022,0x0004003b,0x00000090,0x00000091,0x00000003, + 0x00040018,0x00000097,0x00000009,0x00000003,0x0004002b,0x00000006,0x00000098,0x3e991687, + 0x0004002b,0x00000006,0x00000099,0x3f1645a2,0x0004002b,0x00000006,0x0000009a,0x3de978d5, + 0x0006002c,0x00000009,0x0000009b,0x00000098,0x00000099,0x0000009a,0x0004002b,0x00000006, + 0x0000009c,0x3f189375,0x0004002b,0x00000006,0x0000009d,0xbe8ccccd,0x0004002b,0x00000006, + 0x0000009e,0xbea45a1d,0x0006002c,0x00000009,0x0000009f,0x0000009c,0x0000009d,0x0000009e, + 0x0004002b,0x00000006,0x000000a0,0x3e591687,0x0004002b,0x00000006,0x000000a1,0xbf05e354, + 0x0004002b,0x00000006,0x000000a2,0x3e9f3b64,0x0006002c,0x00000009,0x000000a3,0x000000a0, + 0x000000a1,0x000000a2,0x0006002c,0x00000097,0x000000a4,0x0000009b,0x0000009f,0x000000a3, + 0x0004002b,0x00000006,0x000000a5,0x3f74bc6a,0x0004002b,0x00000006,0x000000a6,0x3f1ef9db, + 0x0006002c,0x00000009,0x000000a7,0x0000004b,0x000000a5,0x000000a6,0x0004002b,0x00000006, + 0x000000a8,0xbe8b4396,0x0004002b,0x00000006,0x000000a9,0xbf25a1cb,0x0006002c,0x00000009, + 0x000000aa,0x0000004b,0x000000a8,0x000000a9,0x0004002b,0x00000006,0x000000ab,0xbf8d9168, + 0x0004002b,0x00000006,0x000000ac,0x3fda3d71,0x0006002c,0x00000009,0x000000ad,0x0000004b, + 0x000000ab,0x000000ac,0x0006002c,0x00000097,0x000000ae,0x000000a7,0x000000aa,0x000000ad, 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b, - 0x00000008,0x000000ba,0x00000007,0x0004003b,0x00000008,0x000000bd,0x00000007,0x0004003b, - 0x00000015,0x000000c0,0x00000007,0x0004003b,0x00000008,0x000000c1,0x00000007,0x0004003b, - 0x00000015,0x000000c4,0x00000007,0x0004003b,0x00000008,0x000000c5,0x00000007,0x0004003b, - 0x00000015,0x000000c8,0x00000007,0x0004003d,0x00000007,0x000000be,0x000000bc,0x0003003e, - 0x000000bd,0x000000be,0x00050039,0x00000007,0x000000bf,0x00000013,0x000000bd,0x0003003e, - 0x000000ba,0x000000bf,0x0004003d,0x00000007,0x000000c2,0x000000ba,0x0003003e,0x000000c1, - 0x000000c2,0x00050039,0x00000009,0x000000c3,0x0000000c,0x000000c1,0x0003003e,0x000000c0, - 0x000000c3,0x0004003d,0x00000007,0x000000c6,0x000000ba,0x0003003e,0x000000c5,0x000000c6, - 0x00050039,0x00000009,0x000000c7,0x0000000f,0x000000c5,0x0003003e,0x000000c4,0x000000c7, - 0x0004003d,0x00000009,0x000000c9,0x000000c0,0x0004003d,0x00000009,0x000000ca,0x000000c4, - 0x00060050,0x00000009,0x000000cc,0x000000cb,0x000000cb,0x000000cb,0x0008000c,0x00000009, - 0x000000cd,0x00000001,0x0000002e,0x000000c9,0x000000ca,0x000000cc,0x0003003e,0x000000c8, - 0x000000cd,0x0004003d,0x00000009,0x000000d0,0x000000c8,0x00050051,0x00000006,0x000000d1, - 0x000000d0,0x00000000,0x00050051,0x00000006,0x000000d2,0x000000d0,0x00000001,0x00050051, - 0x00000006,0x000000d3,0x000000d0,0x00000002,0x00070050,0x0000001d,0x000000d4,0x000000d1, - 0x000000d2,0x000000d3,0x0000005a,0x0003003e,0x000000cf,0x000000d4,0x000100fd,0x00010038, + 0x00000008,0x00000075,0x00000007,0x0004003b,0x00000008,0x00000078,0x00000007,0x0004003b, + 0x0000000e,0x0000007b,0x00000007,0x0004003b,0x0000000e,0x00000080,0x00000007,0x0004003b, + 0x00000008,0x00000081,0x00000007,0x0004003b,0x0000000e,0x00000084,0x00000007,0x0004003b, + 0x00000008,0x00000085,0x00000007,0x0004003b,0x0000000e,0x00000087,0x00000007,0x0004003b, + 0x0000000e,0x0000008a,0x00000007,0x0004003d,0x00000007,0x00000079,0x00000077,0x0003003e, + 0x00000078,0x00000079,0x00050039,0x00000007,0x0000007a,0x00000016,0x00000078,0x0003003e, + 0x00000075,0x0000007a,0x0004003d,0x00000019,0x0000007c,0x0000001b,0x0004003d,0x00000007, + 0x0000007d,0x00000075,0x00050057,0x00000022,0x0000007e,0x0000007c,0x0000007d,0x0008004f, + 0x00000009,0x0000007f,0x0000007e,0x0000007e,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x0000007b,0x0000007f,0x0004003d,0x00000007,0x00000082,0x00000075,0x0003003e,0x00000081, + 0x00000082,0x00050039,0x00000009,0x00000083,0x0000000c,0x00000081,0x0003003e,0x00000080, + 0x00000083,0x0004003d,0x00000007,0x00000086,0x00000075,0x0003003e,0x00000085,0x00000086, + 0x0004003d,0x00000009,0x00000088,0x0000007b,0x0003003e,0x00000087,0x00000088,0x00060039, + 0x00000009,0x00000089,0x00000012,0x00000085,0x00000087,0x0003003e,0x00000084,0x00000089, + 0x0004003d,0x00000009,0x0000008b,0x00000080,0x0004003d,0x00000009,0x0000008c,0x00000084, + 0x00060050,0x00000009,0x0000008e,0x0000008d,0x0000008d,0x0000008d,0x0008000c,0x00000009, + 0x0000008f,0x00000001,0x0000002e,0x0000008b,0x0000008c,0x0000008e,0x0003003e,0x0000008a, + 0x0000008f,0x0004003d,0x00000009,0x00000092,0x0000008a,0x00050051,0x00000006,0x00000093, + 0x00000092,0x00000000,0x00050051,0x00000006,0x00000094,0x00000092,0x00000001,0x00050051, + 0x00000006,0x00000095,0x00000092,0x00000002,0x00070050,0x00000022,0x00000096,0x00000093, + 0x00000094,0x00000095,0x0000004b,0x0003003e,0x00000091,0x00000096,0x000100fd,0x00010038, 0x00050036,0x00000009,0x0000000c,0x00000000,0x0000000a,0x00030037,0x00000008,0x0000000b, - 0x000200f8,0x0000000d,0x0004003b,0x00000015,0x00000016,0x00000007,0x0004003b,0x00000015, - 0x00000020,0x00000007,0x0004003b,0x00000031,0x00000032,0x00000007,0x0004003b,0x00000015, - 0x00000058,0x00000007,0x0004003b,0x00000015,0x00000066,0x00000007,0x0004003d,0x00000018, - 0x0000001b,0x0000001a,0x0004003d,0x00000007,0x0000001c,0x0000000b,0x00050057,0x0000001d, - 0x0000001e,0x0000001b,0x0000001c,0x0008004f,0x00000009,0x0000001f,0x0000001e,0x0000001e, - 0x00000000,0x00000001,0x00000002,0x0003003e,0x00000016,0x0000001f,0x0004003d,0x00000009, - 0x00000021,0x00000016,0x00050090,0x00000009,0x00000030,0x00000021,0x0000002f,0x0003003e, - 0x00000020,0x00000030,0x00050041,0x00000031,0x00000036,0x0000000b,0x00000035,0x0004003d, - 0x00000006,0x00000037,0x00000036,0x00060041,0x0000003d,0x0000003e,0x0000003a,0x0000003c, - 0x00000035,0x0004003d,0x00000006,0x0000003f,0x0000003e,0x00050085,0x00000006,0x00000040, - 0x00000037,0x0000003f,0x0005008d,0x00000006,0x00000042,0x00000040,0x00000041,0x00050041, - 0x0000003d,0x00000044,0x0000003a,0x00000043,0x0004003d,0x00000006,0x00000045,0x00000044, - 0x00050081,0x00000006,0x00000046,0x00000042,0x00000045,0x00050085,0x00000006,0x00000047, - 0x00000033,0x00000046,0x0003003e,0x00000032,0x00000047,0x0004003d,0x00000006,0x00000048, - 0x00000032,0x00050085,0x00000006,0x0000004a,0x00000048,0x00000049,0x0006000c,0x00000006, - 0x0000004b,0x00000001,0x0000000e,0x0000004a,0x00050041,0x00000031,0x0000004c,0x00000020, - 0x00000035,0x0004003d,0x00000006,0x0000004d,0x0000004c,0x00050085,0x00000006,0x0000004e, - 0x0000004d,0x0000004b,0x00050041,0x00000031,0x0000004f,0x00000020,0x00000035,0x0003003e, - 0x0000004f,0x0000004e,0x0004003d,0x00000006,0x00000050,0x00000032,0x00050085,0x00000006, - 0x00000051,0x00000050,0x00000049,0x0006000c,0x00000006,0x00000052,0x00000001,0x0000000d, - 0x00000051,0x00050041,0x00000031,0x00000054,0x00000020,0x00000053,0x0004003d,0x00000006, - 0x00000055,0x00000054,0x00050085,0x00000006,0x00000056,0x00000055,0x00000052,0x00050041, - 0x00000031,0x00000057,0x00000020,0x00000053,0x0003003e,0x00000057,0x00000056,0x0004003d, - 0x00000009,0x00000059,0x00000020,0x00050090,0x00000009,0x00000065,0x00000059,0x00000064, - 0x0003003e,0x00000058,0x00000065,0x0004003d,0x00000018,0x00000067,0x0000001a,0x0004003d, - 0x00000007,0x00000068,0x0000000b,0x00050081,0x00000007,0x0000006c,0x00000068,0x0000006b, - 0x00050057,0x0000001d,0x0000006d,0x00000067,0x0000006c,0x00050051,0x00000006,0x0000006f, - 0x0000006d,0x00000000,0x00050041,0x00000031,0x00000070,0x00000066,0x0000006e,0x0003003e, - 0x00000070,0x0000006f,0x0004003d,0x00000018,0x00000071,0x0000001a,0x0004003d,0x00000007, - 0x00000072,0x0000000b,0x00050081,0x00000007,0x00000075,0x00000072,0x00000074,0x00050057, - 0x0000001d,0x00000076,0x00000071,0x00000075,0x00050051,0x00000006,0x00000077,0x00000076, - 0x00000001,0x00050041,0x00000031,0x00000078,0x00000066,0x00000035,0x0003003e,0x00000078, - 0x00000077,0x0004003d,0x00000018,0x00000079,0x0000001a,0x0004003d,0x00000007,0x0000007a, - 0x0000000b,0x00050083,0x00000007,0x0000007b,0x0000007a,0x0000006b,0x00050057,0x0000001d, - 0x0000007c,0x00000079,0x0000007b,0x00050051,0x00000006,0x0000007d,0x0000007c,0x00000002, - 0x00050041,0x00000031,0x0000007e,0x00000066,0x00000053,0x0003003e,0x0000007e,0x0000007d, - 0x0004003d,0x00000009,0x0000007f,0x00000066,0x000200fe,0x0000007f,0x00010038,0x00050036, - 0x00000009,0x0000000f,0x00000000,0x0000000a,0x00030037,0x00000008,0x0000000e,0x000200f8, - 0x00000010,0x0004003b,0x00000015,0x00000082,0x00000007,0x0004003b,0x00000031,0x00000087, - 0x00000007,0x0004003d,0x00000018,0x00000083,0x0000001a,0x0004003d,0x00000007,0x00000084, - 0x0000000e,0x00050057,0x0000001d,0x00000085,0x00000083,0x00000084,0x0008004f,0x00000009, - 0x00000086,0x00000085,0x00000085,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000082, - 0x00000086,0x00050041,0x00000031,0x00000088,0x0000000e,0x00000035,0x0004003d,0x00000006, - 0x00000089,0x00000088,0x00060041,0x0000003d,0x0000008a,0x0000003a,0x0000003c,0x00000035, - 0x0004003d,0x00000006,0x0000008b,0x0000008a,0x00050085,0x00000006,0x0000008c,0x00000089, - 0x0000008b,0x00050085,0x00000006,0x0000008d,0x0000008c,0x00000041,0x0006000c,0x00000006, - 0x0000008e,0x00000001,0x0000000d,0x0000008d,0x0006000c,0x00000006,0x0000008f,0x00000001, - 0x00000004,0x0000008e,0x00050085,0x00000006,0x00000091,0x0000008f,0x00000090,0x0003003e, - 0x00000087,0x00000091,0x0004003d,0x00000006,0x00000092,0x00000087,0x00050085,0x00000006, - 0x00000093,0x00000092,0x00000049,0x00050083,0x00000006,0x00000094,0x0000005a,0x00000093, - 0x0004003d,0x00000009,0x00000095,0x00000082,0x0005008e,0x00000009,0x00000096,0x00000095, - 0x00000094,0x0003003e,0x00000082,0x00000096,0x0004003d,0x00000009,0x00000097,0x00000082, - 0x000200fe,0x00000097,0x00010038,0x00050036,0x00000007,0x00000013,0x00000000,0x00000011, - 0x00030037,0x00000008,0x00000012,0x000200f8,0x00000014,0x0004003b,0x00000031,0x0000009e, - 0x00000007,0x0004003d,0x00000007,0x0000009a,0x00000012,0x0005008e,0x00000007,0x0000009b, - 0x0000009a,0x00000041,0x00050050,0x00000007,0x0000009c,0x0000005a,0x0000005a,0x00050083, - 0x00000007,0x0000009d,0x0000009b,0x0000009c,0x0003003e,0x00000012,0x0000009d,0x00050041, - 0x00000031,0x0000009f,0x00000012,0x0000006e,0x0004003d,0x00000006,0x000000a0,0x0000009f, - 0x00050041,0x00000031,0x000000a1,0x00000012,0x0000006e,0x0004003d,0x00000006,0x000000a2, - 0x000000a1,0x00050085,0x00000006,0x000000a3,0x000000a0,0x000000a2,0x00050041,0x00000031, - 0x000000a4,0x00000012,0x00000035,0x0004003d,0x00000006,0x000000a5,0x000000a4,0x00050041, - 0x00000031,0x000000a6,0x00000012,0x00000035,0x0004003d,0x00000006,0x000000a7,0x000000a6, - 0x00050085,0x00000006,0x000000a8,0x000000a5,0x000000a7,0x00050081,0x00000006,0x000000a9, - 0x000000a3,0x000000a8,0x0006000c,0x00000006,0x000000aa,0x00000001,0x0000001f,0x000000a9, - 0x0003003e,0x0000009e,0x000000aa,0x0004003d,0x00000007,0x000000ab,0x00000012,0x0004003d, - 0x00000006,0x000000ac,0x0000009e,0x0004003d,0x00000006,0x000000ad,0x0000009e,0x00050085, - 0x00000006,0x000000ae,0x000000ac,0x000000ad,0x0005008e,0x00000007,0x000000af,0x000000ab, - 0x000000ae,0x0005008e,0x00000007,0x000000b1,0x000000af,0x000000b0,0x0004003d,0x00000007, - 0x000000b2,0x00000012,0x00050081,0x00000007,0x000000b3,0x000000b2,0x000000b1,0x0003003e, - 0x00000012,0x000000b3,0x0004003d,0x00000007,0x000000b4,0x00000012,0x0005008e,0x00000007, - 0x000000b5,0x000000b4,0x00000049,0x00050050,0x00000007,0x000000b6,0x00000049,0x00000049, - 0x00050081,0x00000007,0x000000b7,0x000000b5,0x000000b6,0x000200fe,0x000000b7,0x00010038 + 0x000200f8,0x0000000d,0x0004003d,0x00000019,0x0000001c,0x0000001b,0x0004003d,0x00000007, + 0x0000001d,0x0000000b,0x00050081,0x00000007,0x00000021,0x0000001d,0x00000020,0x00050057, + 0x00000022,0x00000023,0x0000001c,0x00000021,0x00050051,0x00000006,0x00000026,0x00000023, + 0x00000000,0x0004003d,0x00000019,0x00000027,0x0000001b,0x0004003d,0x00000007,0x00000028, + 0x0000000b,0x00050081,0x00000007,0x0000002b,0x00000028,0x0000002a,0x00050057,0x00000022, + 0x0000002c,0x00000027,0x0000002b,0x00050051,0x00000006,0x0000002e,0x0000002c,0x00000001, + 0x0004003d,0x00000019,0x0000002f,0x0000001b,0x0004003d,0x00000007,0x00000030,0x0000000b, + 0x00050083,0x00000007,0x00000031,0x00000030,0x00000020,0x00050057,0x00000022,0x00000032, + 0x0000002f,0x00000031,0x00050051,0x00000006,0x00000034,0x00000032,0x00000002,0x00060050, + 0x00000009,0x00000035,0x00000026,0x0000002e,0x00000034,0x000200fe,0x00000035,0x00010038, + 0x00050036,0x00000009,0x00000012,0x00000000,0x0000000f,0x00030037,0x00000008,0x00000010, + 0x00030037,0x0000000e,0x00000011,0x000200f8,0x00000013,0x0004003b,0x00000038,0x00000039, + 0x00000007,0x00050041,0x00000038,0x0000003a,0x00000010,0x0000002d,0x0004003d,0x00000006, + 0x0000003b,0x0000003a,0x00060041,0x00000041,0x00000042,0x0000003e,0x00000040,0x0000002d, + 0x0004003d,0x00000006,0x00000043,0x00000042,0x00050085,0x00000006,0x00000044,0x0000003b, + 0x00000043,0x00050085,0x00000006,0x00000046,0x00000044,0x00000045,0x0006000c,0x00000006, + 0x00000047,0x00000001,0x0000000d,0x00000046,0x0006000c,0x00000006,0x00000048,0x00000001, + 0x00000004,0x00000047,0x00050085,0x00000006,0x0000004a,0x00000048,0x00000049,0x0003003e, + 0x00000039,0x0000004a,0x0004003d,0x00000006,0x0000004c,0x00000039,0x00050085,0x00000006, + 0x0000004e,0x0000004c,0x0000004d,0x00050083,0x00000006,0x0000004f,0x0000004b,0x0000004e, + 0x0004003d,0x00000009,0x00000050,0x00000011,0x0005008e,0x00000009,0x00000051,0x00000050, + 0x0000004f,0x0003003e,0x00000011,0x00000051,0x0004003d,0x00000009,0x00000052,0x00000011, + 0x000200fe,0x00000052,0x00010038,0x00050036,0x00000007,0x00000016,0x00000000,0x00000014, + 0x00030037,0x00000008,0x00000015,0x000200f8,0x00000017,0x0004003b,0x00000038,0x00000059, + 0x00000007,0x0004003d,0x00000007,0x00000055,0x00000015,0x0005008e,0x00000007,0x00000056, + 0x00000055,0x00000045,0x00050050,0x00000007,0x00000057,0x0000004b,0x0000004b,0x00050083, + 0x00000007,0x00000058,0x00000056,0x00000057,0x0003003e,0x00000015,0x00000058,0x00050041, + 0x00000038,0x0000005a,0x00000015,0x00000025,0x0004003d,0x00000006,0x0000005b,0x0000005a, + 0x00050041,0x00000038,0x0000005c,0x00000015,0x00000025,0x0004003d,0x00000006,0x0000005d, + 0x0000005c,0x00050085,0x00000006,0x0000005e,0x0000005b,0x0000005d,0x00050041,0x00000038, + 0x0000005f,0x00000015,0x0000002d,0x0004003d,0x00000006,0x00000060,0x0000005f,0x00050041, + 0x00000038,0x00000061,0x00000015,0x0000002d,0x0004003d,0x00000006,0x00000062,0x00000061, + 0x00050085,0x00000006,0x00000063,0x00000060,0x00000062,0x00050081,0x00000006,0x00000064, + 0x0000005e,0x00000063,0x0006000c,0x00000006,0x00000065,0x00000001,0x0000001f,0x00000064, + 0x0003003e,0x00000059,0x00000065,0x0004003d,0x00000007,0x00000066,0x00000015,0x0004003d, + 0x00000006,0x00000067,0x00000059,0x0004003d,0x00000006,0x00000068,0x00000059,0x00050085, + 0x00000006,0x00000069,0x00000067,0x00000068,0x0005008e,0x00000007,0x0000006a,0x00000066, + 0x00000069,0x0005008e,0x00000007,0x0000006c,0x0000006a,0x0000006b,0x0004003d,0x00000007, + 0x0000006d,0x00000015,0x00050081,0x00000007,0x0000006e,0x0000006d,0x0000006c,0x0003003e, + 0x00000015,0x0000006e,0x0004003d,0x00000007,0x0000006f,0x00000015,0x0005008e,0x00000007, + 0x00000070,0x0000006f,0x0000004d,0x00050050,0x00000007,0x00000071,0x0000004d,0x0000004d, + 0x00050081,0x00000007,0x00000072,0x00000070,0x00000071,0x000200fe,0x00000072,0x00010038 }; diff --git a/app/src/main/cpp/shaders/sgsr.frag b/app/src/main/cpp/shaders/sgsr.frag new file mode 100644 index 0000000000..bd273e9ed7 --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr.frag @@ -0,0 +1,118 @@ +#version 450 + +// ============================================================================= +// Snapdragon Game Super Resolution (SGSR) 1.0 - spatial upscaler, mobile path. +// +// Ported from Qualcomm's reference shader: +// SnapdragonStudios/snapdragon-gsr sgsr/v1/include/glsl/sgsr1_shader_mobile.frag +// +// Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// +// Adapted for the Winlator native Vulkan compositor: +// - #version 450 (Vulkan GLSL) +// - ViewportInfo passed via push constant instead of a uniform block +// - specialised to OperationMode == 1 (RGBA); green channel is the edge luma +// - reuses window.vert (full-screen quad; fragTexCoord in [0,1] over the +// destination rect = normalised output position = normalised source position) +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in Qualcomm's +// reference; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D ps0; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float EdgeSharpness; // driven by the "Sharpness" slider (default 2.0) +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 out_Target0; + +const float EdgeThreshold = 8.0 / 255.0; + +float fastLanczos2(float x) { + float wA = x - 4.0; + float wB = x * wA - wA; + wA *= wA; + return wB * wA; +} + +vec2 weightY(float dx, float dy, float c, float std) { + float x = ((dx * dx) + (dy * dy)) * 0.55 + clamp(abs(c) * std, 0.0, 1.0); + float w = fastLanczos2(x); + return vec2(w, w * c); +} + +void main() { + highp vec4 ViewportInfo = pc.ViewportInfo; + highp vec2 uv = fragTexCoord; + + vec4 color; + color.xyz = textureLod(ps0, uv, 0.0).xyz; + + highp vec2 imgCoord = ((uv * ViewportInfo.zw) + vec2(-0.5, 0.5)); + highp vec2 imgCoordPixel = floor(imgCoord); + highp vec2 coord = (imgCoordPixel * ViewportInfo.xy); + vec2 pl = (imgCoord + (-imgCoordPixel)); + vec4 left = textureGather(ps0, coord, 1); + + float edgeVote = abs(left.z - left.y) + abs(color.y - left.y) + abs(color.y - left.z); + if (edgeVote > EdgeThreshold) { + coord.x += ViewportInfo.x; + + vec4 right = textureGather(ps0, coord + vec2(ViewportInfo.x, 0.0), 1); + vec4 upDown; + upDown.xy = textureGather(ps0, coord + vec2(0.0, -ViewportInfo.y), 1).wz; + upDown.zw = textureGather(ps0, coord + vec2(0.0, ViewportInfo.y), 1).yx; + + float mean = (left.y + left.z + right.x + right.w) * 0.25; + left = left - vec4(mean); + right = right - vec4(mean); + upDown = upDown - vec4(mean); + color.w = color.y - mean; + + float sum = (((((abs(left.x) + abs(left.y)) + abs(left.z)) + abs(left.w)) + + (((abs(right.x) + abs(right.y)) + abs(right.z)) + abs(right.w))) + + (((abs(upDown.x) + abs(upDown.y)) + abs(upDown.z)) + abs(upDown.w))); + float std = 2.181818 / sum; + + vec2 aWY = weightY(pl.x, pl.y + 1.0, upDown.x, std); + aWY += weightY(pl.x - 1.0, pl.y + 1.0, upDown.y, std); + aWY += weightY(pl.x - 1.0, pl.y - 2.0, upDown.z, std); + aWY += weightY(pl.x, pl.y - 2.0, upDown.w, std); + aWY += weightY(pl.x + 1.0, pl.y - 1.0, left.x, std); + aWY += weightY(pl.x, pl.y - 1.0, left.y, std); + aWY += weightY(pl.x, pl.y, left.z, std); + aWY += weightY(pl.x + 1.0, pl.y, left.w, std); + aWY += weightY(pl.x - 1.0, pl.y - 1.0, right.x, std); + aWY += weightY(pl.x - 2.0, pl.y - 1.0, right.y, std); + aWY += weightY(pl.x - 2.0, pl.y, right.z, std); + aWY += weightY(pl.x - 1.0, pl.y, right.w, std); + + float finalY = aWY.y / aWY.x; + + float maxY = max(max(left.y, left.z), max(right.x, right.w)); + float minY = min(min(left.y, left.z), min(right.x, right.w)); + finalY = clamp(pc.EdgeSharpness * finalY, minY, maxY); + + float deltaY = finalY - color.w; + deltaY = clamp(deltaY, -23.0 / 255.0, 23.0 / 255.0); + + color.x = clamp((color.x + deltaY), 0.0, 1.0); + color.y = clamp((color.y + deltaY), 0.0, 1.0); + color.z = clamp((color.z + deltaY), 0.0, 1.0); + } + + color.w = 1.0; // alpha channel unused by the compositor blit + out_Target0 = color; +} diff --git a/app/src/main/cpp/shaders/sgsr_half_frag.h b/app/src/main/cpp/shaders/sgsr_half_frag.h new file mode 100644 index 0000000000..12438b654b --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr_half_frag.h @@ -0,0 +1,530 @@ + // 1116.2.0 + #pragma once +const uint32_t sgsr_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x00000216,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000051,0x00000214,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00070005,0x0000000a,0x74736166,0x636e614c,0x32736f7a,0x3b316628,0x00000000, + 0x00030005,0x00000009,0x00000078,0x00080005,0x00000012,0x67696577,0x28597468,0x663b3166, + 0x31663b31,0x3b31663b,0x00000000,0x00030005,0x0000000e,0x00007864,0x00030005,0x0000000f, + 0x00007964,0x00030005,0x00000010,0x00000063,0x00030005,0x00000011,0x00647473,0x00030005, + 0x00000014,0x00004177,0x00030005,0x00000018,0x00004277,0x00030005,0x00000026,0x00000078, + 0x00030005,0x00000038,0x00000077,0x00040005,0x00000039,0x61726170,0x0000006d,0x00060005, + 0x00000045,0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00030005,0x00000046,0x00004350, + 0x00040006,0x00000046,0x00000000,0x0063646e,0x00070006,0x00000046,0x00000001,0x77656956, + 0x74726f70,0x6f666e49,0x00000000,0x00070006,0x00000046,0x00000002,0x65676445,0x72616853, + 0x73656e70,0x00000073,0x00030005,0x00000048,0x00006370,0x00030005,0x0000004f,0x00007675, + 0x00060005,0x00000051,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x00000053, + 0x6f6c6f63,0x00000072,0x00030005,0x00000057,0x00307370,0x00050005,0x00000067,0x43676d69, + 0x64726f6f,0x00000000,0x00060005,0x00000070,0x43676d69,0x64726f6f,0x65786950,0x0000006c, + 0x00040005,0x00000073,0x726f6f63,0x00000064,0x00030005,0x00000078,0x00006c70,0x00040005, + 0x0000007d,0x7466656c,0x00000000,0x00050005,0x00000081,0x65676465,0x65746f56,0x00000000, + 0x00040005,0x000000a2,0x68676972,0x00000074,0x00040005,0x000000aa,0x6f447075,0x00006e77, + 0x00040005,0x000000c5,0x6e61656d,0x00000000,0x00030005,0x000000e4,0x006d7573,0x00030005, + 0x00000114,0x00647473,0x00030005,0x00000118,0x00595761,0x00040005,0x0000011c,0x61726170, + 0x0000006d,0x00040005,0x0000011f,0x61726170,0x0000006d,0x00040005,0x00000120,0x61726170, + 0x0000006d,0x00040005,0x00000123,0x61726170,0x0000006d,0x00040005,0x0000012c,0x61726170, + 0x0000006d,0x00040005,0x0000012d,0x61726170,0x0000006d,0x00040005,0x0000012e,0x61726170, + 0x0000006d,0x00040005,0x00000131,0x61726170,0x0000006d,0x00040005,0x0000013d,0x61726170, + 0x0000006d,0x00040005,0x0000013e,0x61726170,0x0000006d,0x00040005,0x0000013f,0x61726170, + 0x0000006d,0x00040005,0x00000142,0x61726170,0x0000006d,0x00040005,0x0000014a,0x61726170, + 0x0000006d,0x00040005,0x0000014d,0x61726170,0x0000006d,0x00040005,0x0000014e,0x61726170, + 0x0000006d,0x00040005,0x00000151,0x61726170,0x0000006d,0x00040005,0x0000015c,0x61726170, + 0x0000006d,0x00040005,0x0000015d,0x61726170,0x0000006d,0x00040005,0x0000015e,0x61726170, + 0x0000006d,0x00040005,0x00000161,0x61726170,0x0000006d,0x00040005,0x00000169,0x61726170, + 0x0000006d,0x00040005,0x0000016c,0x61726170,0x0000006d,0x00040005,0x0000016d,0x61726170, + 0x0000006d,0x00040005,0x00000170,0x61726170,0x0000006d,0x00040005,0x00000175,0x61726170, + 0x0000006d,0x00040005,0x00000178,0x61726170,0x0000006d,0x00040005,0x0000017b,0x61726170, + 0x0000006d,0x00040005,0x0000017e,0x61726170,0x0000006d,0x00040005,0x00000186,0x61726170, + 0x0000006d,0x00040005,0x00000187,0x61726170,0x0000006d,0x00040005,0x0000018a,0x61726170, + 0x0000006d,0x00040005,0x0000018d,0x61726170,0x0000006d,0x00040005,0x00000198,0x61726170, + 0x0000006d,0x00040005,0x00000199,0x61726170,0x0000006d,0x00040005,0x0000019a,0x61726170, + 0x0000006d,0x00040005,0x0000019d,0x61726170,0x0000006d,0x00040005,0x000001a8,0x61726170, + 0x0000006d,0x00040005,0x000001a9,0x61726170,0x0000006d,0x00040005,0x000001aa,0x61726170, + 0x0000006d,0x00040005,0x000001ad,0x61726170,0x0000006d,0x00040005,0x000001b5,0x61726170, + 0x0000006d,0x00040005,0x000001b6,0x61726170,0x0000006d,0x00040005,0x000001b9,0x61726170, + 0x0000006d,0x00040005,0x000001bc,0x61726170,0x0000006d,0x00040005,0x000001c4,0x61726170, + 0x0000006d,0x00040005,0x000001c5,0x61726170,0x0000006d,0x00040005,0x000001c8,0x61726170, + 0x0000006d,0x00040005,0x000001cb,0x61726170,0x0000006d,0x00040005,0x000001d0,0x616e6966, + 0x0000596c,0x00040005,0x000001d6,0x5978616d,0x00000000,0x00040005,0x000001e2,0x596e696d, + 0x00000000,0x00040005,0x000001f7,0x746c6564,0x00005961,0x00050005,0x00000214,0x5f74756f, + 0x67726154,0x00307465,0x00030047,0x00000009,0x00000000,0x00030047,0x0000000a,0x00000000, + 0x00030047,0x0000000e,0x00000000,0x00030047,0x0000000f,0x00000000,0x00030047,0x00000010, + 0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000,0x00030047, + 0x00000014,0x00000000,0x00030047,0x00000015,0x00000000,0x00030047,0x00000017,0x00000000, + 0x00030047,0x00000018,0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001a, + 0x00000000,0x00030047,0x0000001b,0x00000000,0x00030047,0x0000001c,0x00000000,0x00030047, + 0x0000001d,0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047,0x0000001f,0x00000000, + 0x00030047,0x00000020,0x00000000,0x00030047,0x00000021,0x00000000,0x00030047,0x00000022, + 0x00000000,0x00030047,0x00000023,0x00000000,0x00030047,0x00000026,0x00000000,0x00030047, + 0x00000027,0x00000000,0x00030047,0x00000028,0x00000000,0x00030047,0x00000029,0x00000000, + 0x00030047,0x0000002a,0x00000000,0x00030047,0x0000002b,0x00000000,0x00030047,0x0000002c, + 0x00000000,0x00030047,0x0000002d,0x00000000,0x00030047,0x0000002f,0x00000000,0x00030047, + 0x00000030,0x00000000,0x00030047,0x00000031,0x00000000,0x00030047,0x00000032,0x00000000, + 0x00030047,0x00000033,0x00000000,0x00030047,0x00000036,0x00000000,0x00030047,0x00000037, + 0x00000000,0x00030047,0x00000038,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047, + 0x0000003a,0x00000000,0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003c,0x00000000, + 0x00030047,0x0000003d,0x00000000,0x00030047,0x0000003e,0x00000000,0x00030047,0x0000003f, + 0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000046,0x00000002,0x00050048, + 0x00000046,0x00000000,0x00000023,0x00000000,0x00050048,0x00000046,0x00000001,0x00000023, + 0x00000010,0x00040048,0x00000046,0x00000002,0x00000000,0x00050048,0x00000046,0x00000002, + 0x00000023,0x00000020,0x00040047,0x00000051,0x0000001e,0x00000000,0x00030047,0x00000053, + 0x00000000,0x00030047,0x00000057,0x00000000,0x00040047,0x00000057,0x00000021,0x00000000, + 0x00040047,0x00000057,0x00000022,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047, + 0x0000005a,0x00000000,0x00030047,0x0000005c,0x00000000,0x00030047,0x00000078,0x00000000, + 0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x00000080, + 0x00000000,0x00030047,0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,0x00030047, + 0x00000085,0x00000000,0x00030047,0x00000086,0x00000000,0x00030047,0x00000087,0x00000000, + 0x00030047,0x00000089,0x00000000,0x00030047,0x0000008b,0x00000000,0x00030047,0x0000008c, + 0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e,0x00000000,0x00030047, + 0x00000090,0x00000000,0x00030047,0x00000092,0x00000000,0x00030047,0x00000093,0x00000000, + 0x00030047,0x00000094,0x00000000,0x00030047,0x00000095,0x00000000,0x00030047,0x00000096, + 0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x000000a2,0x00000000,0x00030047, + 0x000000a3,0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000, + 0x00030047,0x000000ab,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3, + 0x00000000,0x00030047,0x000000b8,0x00000000,0x00030047,0x000000be,0x00000000,0x00030047, + 0x000000bf,0x00000000,0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c7,0x00000000, + 0x00030047,0x000000c9,0x00000000,0x00030047,0x000000ca,0x00000000,0x00030047,0x000000cc, + 0x00000000,0x00030047,0x000000cd,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047, + 0x000000d0,0x00000000,0x00030047,0x000000d2,0x00000000,0x00030047,0x000000d3,0x00000000, + 0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5,0x00000000,0x00030047,0x000000d6, + 0x00000000,0x00030047,0x000000d7,0x00000000,0x00030047,0x000000d8,0x00000000,0x00030047, + 0x000000d9,0x00000000,0x00030047,0x000000da,0x00000000,0x00030047,0x000000db,0x00000000, + 0x00030047,0x000000dc,0x00000000,0x00030047,0x000000dd,0x00000000,0x00030047,0x000000de, + 0x00000000,0x00030047,0x000000e0,0x00000000,0x00030047,0x000000e1,0x00000000,0x00030047, + 0x000000e2,0x00000000,0x00030047,0x000000e4,0x00000000,0x00030047,0x000000e6,0x00000000, + 0x00030047,0x000000e7,0x00000000,0x00030047,0x000000e9,0x00000000,0x00030047,0x000000ea, + 0x00000000,0x00030047,0x000000eb,0x00000000,0x00030047,0x000000ed,0x00000000,0x00030047, + 0x000000ee,0x00000000,0x00030047,0x000000ef,0x00000000,0x00030047,0x000000f1,0x00000000, + 0x00030047,0x000000f2,0x00000000,0x00030047,0x000000f3,0x00000000,0x00030047,0x000000f5, + 0x00000000,0x00030047,0x000000f6,0x00000000,0x00030047,0x000000f8,0x00000000,0x00030047, + 0x000000f9,0x00000000,0x00030047,0x000000fa,0x00000000,0x00030047,0x000000fc,0x00000000, + 0x00030047,0x000000fd,0x00000000,0x00030047,0x000000fe,0x00000000,0x00030047,0x00000100, + 0x00000000,0x00030047,0x00000101,0x00000000,0x00030047,0x00000102,0x00000000,0x00030047, + 0x00000103,0x00000000,0x00030047,0x00000105,0x00000000,0x00030047,0x00000106,0x00000000, + 0x00030047,0x00000108,0x00000000,0x00030047,0x00000109,0x00000000,0x00030047,0x0000010a, + 0x00000000,0x00030047,0x0000010c,0x00000000,0x00030047,0x0000010d,0x00000000,0x00030047, + 0x0000010e,0x00000000,0x00030047,0x00000110,0x00000000,0x00030047,0x00000111,0x00000000, + 0x00030047,0x00000112,0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114, + 0x00000000,0x00030047,0x00000116,0x00000000,0x00030047,0x00000117,0x00000000,0x00030047, + 0x00000118,0x00000000,0x00030047,0x0000011a,0x00000000,0x00030047,0x0000011b,0x00000000, + 0x00030047,0x0000011c,0x00000000,0x00030047,0x0000011e,0x00000000,0x00030047,0x0000011f, + 0x00000000,0x00030047,0x00000120,0x00000000,0x00030047,0x00000122,0x00000000,0x00030047, + 0x00000123,0x00000000,0x00030047,0x00000124,0x00000000,0x00030047,0x00000125,0x00000000, + 0x00030047,0x00000127,0x00000000,0x00030047,0x00000128,0x00000000,0x00030047,0x0000012a, + 0x00000000,0x00030047,0x0000012b,0x00000000,0x00030047,0x0000012c,0x00000000,0x00030047, + 0x0000012d,0x00000000,0x00030047,0x0000012e,0x00000000,0x00030047,0x00000130,0x00000000, + 0x00030047,0x00000131,0x00000000,0x00030047,0x00000132,0x00000000,0x00030047,0x00000133, + 0x00000000,0x00030047,0x00000134,0x00000000,0x00030047,0x00000135,0x00000000,0x00030047, + 0x00000137,0x00000000,0x00030047,0x00000138,0x00000000,0x00030047,0x0000013a,0x00000000, + 0x00030047,0x0000013c,0x00000000,0x00030047,0x0000013d,0x00000000,0x00030047,0x0000013e, + 0x00000000,0x00030047,0x0000013f,0x00000000,0x00030047,0x00000141,0x00000000,0x00030047, + 0x00000142,0x00000000,0x00030047,0x00000143,0x00000000,0x00030047,0x00000144,0x00000000, + 0x00030047,0x00000145,0x00000000,0x00030047,0x00000146,0x00000000,0x00030047,0x00000148, + 0x00000000,0x00030047,0x00000149,0x00000000,0x00030047,0x0000014a,0x00000000,0x00030047, + 0x0000014c,0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014e,0x00000000, + 0x00030047,0x00000150,0x00000000,0x00030047,0x00000151,0x00000000,0x00030047,0x00000152, + 0x00000000,0x00030047,0x00000153,0x00000000,0x00030047,0x00000154,0x00000000,0x00030047, + 0x00000155,0x00000000,0x00030047,0x00000157,0x00000000,0x00030047,0x00000158,0x00000000, + 0x00030047,0x0000015a,0x00000000,0x00030047,0x0000015b,0x00000000,0x00030047,0x0000015c, + 0x00000000,0x00030047,0x0000015d,0x00000000,0x00030047,0x0000015e,0x00000000,0x00030047, + 0x00000160,0x00000000,0x00030047,0x00000161,0x00000000,0x00030047,0x00000162,0x00000000, + 0x00030047,0x00000163,0x00000000,0x00030047,0x00000164,0x00000000,0x00030047,0x00000165, + 0x00000000,0x00030047,0x00000167,0x00000000,0x00030047,0x00000168,0x00000000,0x00030047, + 0x00000169,0x00000000,0x00030047,0x0000016b,0x00000000,0x00030047,0x0000016c,0x00000000, + 0x00030047,0x0000016d,0x00000000,0x00030047,0x0000016f,0x00000000,0x00030047,0x00000170, + 0x00000000,0x00030047,0x00000171,0x00000000,0x00030047,0x00000172,0x00000000,0x00030047, + 0x00000173,0x00000000,0x00030047,0x00000174,0x00000000,0x00030047,0x00000175,0x00000000, + 0x00030047,0x00000177,0x00000000,0x00030047,0x00000178,0x00000000,0x00030047,0x0000017a, + 0x00000000,0x00030047,0x0000017b,0x00000000,0x00030047,0x0000017d,0x00000000,0x00030047, + 0x0000017e,0x00000000,0x00030047,0x0000017f,0x00000000,0x00030047,0x00000180,0x00000000, + 0x00030047,0x00000181,0x00000000,0x00030047,0x00000182,0x00000000,0x00030047,0x00000184, + 0x00000000,0x00030047,0x00000185,0x00000000,0x00030047,0x00000186,0x00000000,0x00030047, + 0x00000187,0x00000000,0x00030047,0x00000189,0x00000000,0x00030047,0x0000018a,0x00000000, + 0x00030047,0x0000018c,0x00000000,0x00030047,0x0000018d,0x00000000,0x00030047,0x0000018e, + 0x00000000,0x00030047,0x0000018f,0x00000000,0x00030047,0x00000190,0x00000000,0x00030047, + 0x00000191,0x00000000,0x00030047,0x00000193,0x00000000,0x00030047,0x00000194,0x00000000, + 0x00030047,0x00000196,0x00000000,0x00030047,0x00000197,0x00000000,0x00030047,0x00000198, + 0x00000000,0x00030047,0x00000199,0x00000000,0x00030047,0x0000019a,0x00000000,0x00030047, + 0x0000019c,0x00000000,0x00030047,0x0000019d,0x00000000,0x00030047,0x0000019e,0x00000000, + 0x00030047,0x0000019f,0x00000000,0x00030047,0x000001a0,0x00000000,0x00030047,0x000001a1, + 0x00000000,0x00030047,0x000001a3,0x00000000,0x00030047,0x000001a4,0x00000000,0x00030047, + 0x000001a6,0x00000000,0x00030047,0x000001a7,0x00000000,0x00030047,0x000001a8,0x00000000, + 0x00030047,0x000001a9,0x00000000,0x00030047,0x000001aa,0x00000000,0x00030047,0x000001ac, + 0x00000000,0x00030047,0x000001ad,0x00000000,0x00030047,0x000001ae,0x00000000,0x00030047, + 0x000001af,0x00000000,0x00030047,0x000001b0,0x00000000,0x00030047,0x000001b1,0x00000000, + 0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4,0x00000000,0x00030047,0x000001b5, + 0x00000000,0x00030047,0x000001b6,0x00000000,0x00030047,0x000001b8,0x00000000,0x00030047, + 0x000001b9,0x00000000,0x00030047,0x000001bb,0x00000000,0x00030047,0x000001bc,0x00000000, + 0x00030047,0x000001bd,0x00000000,0x00030047,0x000001be,0x00000000,0x00030047,0x000001bf, + 0x00000000,0x00030047,0x000001c0,0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047, + 0x000001c3,0x00000000,0x00030047,0x000001c4,0x00000000,0x00030047,0x000001c5,0x00000000, + 0x00030047,0x000001c7,0x00000000,0x00030047,0x000001c8,0x00000000,0x00030047,0x000001ca, + 0x00000000,0x00030047,0x000001cb,0x00000000,0x00030047,0x000001cc,0x00000000,0x00030047, + 0x000001cd,0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047,0x000001cf,0x00000000, + 0x00030047,0x000001d0,0x00000000,0x00030047,0x000001d2,0x00000000,0x00030047,0x000001d4, + 0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d6,0x00000000,0x00030047, + 0x000001d8,0x00000000,0x00030047,0x000001da,0x00000000,0x00030047,0x000001db,0x00000000, + 0x00030047,0x000001dd,0x00000000,0x00030047,0x000001df,0x00000000,0x00030047,0x000001e0, + 0x00000000,0x00030047,0x000001e1,0x00000000,0x00030047,0x000001e2,0x00000000,0x00030047, + 0x000001e4,0x00000000,0x00030047,0x000001e6,0x00000000,0x00030047,0x000001e7,0x00000000, + 0x00030047,0x000001e9,0x00000000,0x00030047,0x000001eb,0x00000000,0x00030047,0x000001ec, + 0x00000000,0x00030047,0x000001ed,0x00000000,0x00030047,0x000001f1,0x00000000,0x00030047, + 0x000001f2,0x00000000,0x00030047,0x000001f3,0x00000000,0x00030047,0x000001f4,0x00000000, + 0x00030047,0x000001f5,0x00000000,0x00030047,0x000001f6,0x00000000,0x00030047,0x000001f7, + 0x00000000,0x00030047,0x000001f8,0x00000000,0x00030047,0x000001fa,0x00000000,0x00030047, + 0x000001fb,0x00000000,0x00030047,0x000001fc,0x00000000,0x00030047,0x000001ff,0x00000000, + 0x00030047,0x00000201,0x00000000,0x00030047,0x00000202,0x00000000,0x00030047,0x00000203, + 0x00000000,0x00030047,0x00000204,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047, + 0x00000208,0x00000000,0x00030047,0x00000209,0x00000000,0x00030047,0x0000020a,0x00000000, + 0x00030047,0x0000020d,0x00000000,0x00030047,0x0000020e,0x00000000,0x00030047,0x0000020f, + 0x00000000,0x00030047,0x00000210,0x00000000,0x00030047,0x00000214,0x00000000,0x00040047, + 0x00000214,0x0000001e,0x00000000,0x00030047,0x00000215,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040020,0x00000007, + 0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007,0x00040017,0x0000000c, + 0x00000006,0x00000002,0x00070021,0x0000000d,0x0000000c,0x00000007,0x00000007,0x00000007, + 0x00000007,0x0004002b,0x00000006,0x00000016,0x40800000,0x0004002b,0x00000006,0x0000002e, + 0x3f0ccccd,0x0004002b,0x00000006,0x00000034,0x00000000,0x0004002b,0x00000006,0x00000035, + 0x3f800000,0x00040017,0x00000043,0x00000006,0x00000004,0x00040020,0x00000044,0x00000007, + 0x00000043,0x0005001e,0x00000046,0x00000043,0x00000043,0x00000006,0x00040020,0x00000047, + 0x00000009,0x00000046,0x0004003b,0x00000047,0x00000048,0x00000009,0x00040015,0x00000049, + 0x00000020,0x00000001,0x0004002b,0x00000049,0x0000004a,0x00000001,0x00040020,0x0000004b, + 0x00000009,0x00000043,0x00040020,0x0000004e,0x00000007,0x0000000c,0x00040020,0x00000050, + 0x00000001,0x0000000c,0x0004003b,0x00000050,0x00000051,0x00000001,0x00090019,0x00000054, + 0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b, + 0x00000055,0x00000054,0x00040020,0x00000056,0x00000000,0x00000055,0x0004003b,0x00000056, + 0x00000057,0x00000000,0x00040017,0x0000005b,0x00000006,0x00000003,0x00040015,0x0000005d, + 0x00000020,0x00000000,0x0004002b,0x0000005d,0x0000005e,0x00000000,0x0004002b,0x0000005d, + 0x00000061,0x00000001,0x0004002b,0x0000005d,0x00000064,0x00000002,0x0004002b,0x00000006, + 0x0000006c,0xbf000000,0x0004002b,0x00000006,0x0000006d,0x3f000000,0x0005002c,0x0000000c, + 0x0000006e,0x0000006c,0x0000006d,0x0004002b,0x00000006,0x00000097,0x3d008081,0x00020014, + 0x00000098,0x0004002b,0x0000005d,0x000000c2,0x00000003,0x0004002b,0x00000006,0x000000d1, + 0x3e800000,0x0004002b,0x00000006,0x00000115,0x400ba2e8,0x0004002b,0x00000006,0x0000013b, + 0x40000000,0x0004002b,0x00000049,0x000001ee,0x00000002,0x00040020,0x000001ef,0x00000009, + 0x00000006,0x0004002b,0x00000006,0x000001fd,0xbdb8b8b9,0x0004002b,0x00000006,0x000001fe, + 0x3db8b8b9,0x00040020,0x00000213,0x00000003,0x00000043,0x0004003b,0x00000213,0x00000214, + 0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x00000044,0x00000045,0x00000007,0x0004003b,0x0000004e,0x0000004f,0x00000007, + 0x0004003b,0x00000044,0x00000053,0x00000007,0x0004003b,0x0000004e,0x00000067,0x00000007, + 0x0004003b,0x0000004e,0x00000070,0x00000007,0x0004003b,0x0000004e,0x00000073,0x00000007, + 0x0004003b,0x0000004e,0x00000078,0x00000007,0x0004003b,0x00000044,0x0000007d,0x00000007, + 0x0004003b,0x00000007,0x00000081,0x00000007,0x0004003b,0x00000044,0x000000a2,0x00000007, + 0x0004003b,0x00000044,0x000000aa,0x00000007,0x0004003b,0x00000007,0x000000c5,0x00000007, + 0x0004003b,0x00000007,0x000000e4,0x00000007,0x0004003b,0x00000007,0x00000114,0x00000007, + 0x0004003b,0x0000004e,0x00000118,0x00000007,0x0004003b,0x00000007,0x0000011c,0x00000007, + 0x0004003b,0x00000007,0x0000011f,0x00000007,0x0004003b,0x00000007,0x00000120,0x00000007, + 0x0004003b,0x00000007,0x00000123,0x00000007,0x0004003b,0x00000007,0x0000012c,0x00000007, + 0x0004003b,0x00000007,0x0000012d,0x00000007,0x0004003b,0x00000007,0x0000012e,0x00000007, + 0x0004003b,0x00000007,0x00000131,0x00000007,0x0004003b,0x00000007,0x0000013d,0x00000007, + 0x0004003b,0x00000007,0x0000013e,0x00000007,0x0004003b,0x00000007,0x0000013f,0x00000007, + 0x0004003b,0x00000007,0x00000142,0x00000007,0x0004003b,0x00000007,0x0000014a,0x00000007, + 0x0004003b,0x00000007,0x0000014d,0x00000007,0x0004003b,0x00000007,0x0000014e,0x00000007, + 0x0004003b,0x00000007,0x00000151,0x00000007,0x0004003b,0x00000007,0x0000015c,0x00000007, + 0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b,0x00000007,0x0000015e,0x00000007, + 0x0004003b,0x00000007,0x00000161,0x00000007,0x0004003b,0x00000007,0x00000169,0x00000007, + 0x0004003b,0x00000007,0x0000016c,0x00000007,0x0004003b,0x00000007,0x0000016d,0x00000007, + 0x0004003b,0x00000007,0x00000170,0x00000007,0x0004003b,0x00000007,0x00000175,0x00000007, + 0x0004003b,0x00000007,0x00000178,0x00000007,0x0004003b,0x00000007,0x0000017b,0x00000007, + 0x0004003b,0x00000007,0x0000017e,0x00000007,0x0004003b,0x00000007,0x00000186,0x00000007, + 0x0004003b,0x00000007,0x00000187,0x00000007,0x0004003b,0x00000007,0x0000018a,0x00000007, + 0x0004003b,0x00000007,0x0000018d,0x00000007,0x0004003b,0x00000007,0x00000198,0x00000007, + 0x0004003b,0x00000007,0x00000199,0x00000007,0x0004003b,0x00000007,0x0000019a,0x00000007, + 0x0004003b,0x00000007,0x0000019d,0x00000007,0x0004003b,0x00000007,0x000001a8,0x00000007, + 0x0004003b,0x00000007,0x000001a9,0x00000007,0x0004003b,0x00000007,0x000001aa,0x00000007, + 0x0004003b,0x00000007,0x000001ad,0x00000007,0x0004003b,0x00000007,0x000001b5,0x00000007, + 0x0004003b,0x00000007,0x000001b6,0x00000007,0x0004003b,0x00000007,0x000001b9,0x00000007, + 0x0004003b,0x00000007,0x000001bc,0x00000007,0x0004003b,0x00000007,0x000001c4,0x00000007, + 0x0004003b,0x00000007,0x000001c5,0x00000007,0x0004003b,0x00000007,0x000001c8,0x00000007, + 0x0004003b,0x00000007,0x000001cb,0x00000007,0x0004003b,0x00000007,0x000001d0,0x00000007, + 0x0004003b,0x00000007,0x000001d6,0x00000007,0x0004003b,0x00000007,0x000001e2,0x00000007, + 0x0004003b,0x00000007,0x000001f7,0x00000007,0x00050041,0x0000004b,0x0000004c,0x00000048, + 0x0000004a,0x0004003d,0x00000043,0x0000004d,0x0000004c,0x0003003e,0x00000045,0x0000004d, + 0x0004003d,0x0000000c,0x00000052,0x00000051,0x0003003e,0x0000004f,0x00000052,0x0004003d, + 0x00000055,0x00000058,0x00000057,0x0004003d,0x0000000c,0x00000059,0x0000004f,0x00070058, + 0x00000043,0x0000005a,0x00000058,0x00000059,0x00000002,0x00000034,0x0008004f,0x0000005b, + 0x0000005c,0x0000005a,0x0000005a,0x00000000,0x00000001,0x00000002,0x00050041,0x00000007, + 0x0000005f,0x00000053,0x0000005e,0x00050051,0x00000006,0x00000060,0x0000005c,0x00000000, + 0x0003003e,0x0000005f,0x00000060,0x00050041,0x00000007,0x00000062,0x00000053,0x00000061, + 0x00050051,0x00000006,0x00000063,0x0000005c,0x00000001,0x0003003e,0x00000062,0x00000063, + 0x00050041,0x00000007,0x00000065,0x00000053,0x00000064,0x00050051,0x00000006,0x00000066, + 0x0000005c,0x00000002,0x0003003e,0x00000065,0x00000066,0x0004003d,0x0000000c,0x00000068, + 0x0000004f,0x0004003d,0x00000043,0x00000069,0x00000045,0x0007004f,0x0000000c,0x0000006a, + 0x00000069,0x00000069,0x00000002,0x00000003,0x00050085,0x0000000c,0x0000006b,0x00000068, + 0x0000006a,0x00050081,0x0000000c,0x0000006f,0x0000006b,0x0000006e,0x0003003e,0x00000067, + 0x0000006f,0x0004003d,0x0000000c,0x00000071,0x00000067,0x0006000c,0x0000000c,0x00000072, + 0x00000001,0x00000008,0x00000071,0x0003003e,0x00000070,0x00000072,0x0004003d,0x0000000c, + 0x00000074,0x00000070,0x0004003d,0x00000043,0x00000075,0x00000045,0x0007004f,0x0000000c, + 0x00000076,0x00000075,0x00000075,0x00000000,0x00000001,0x00050085,0x0000000c,0x00000077, + 0x00000074,0x00000076,0x0003003e,0x00000073,0x00000077,0x0004003d,0x0000000c,0x00000079, + 0x00000067,0x0004003d,0x0000000c,0x0000007a,0x00000070,0x0004007f,0x0000000c,0x0000007b, + 0x0000007a,0x00050081,0x0000000c,0x0000007c,0x00000079,0x0000007b,0x0003003e,0x00000078, + 0x0000007c,0x0004003d,0x00000055,0x0000007e,0x00000057,0x0004003d,0x0000000c,0x0000007f, + 0x00000073,0x00060060,0x00000043,0x00000080,0x0000007e,0x0000007f,0x0000004a,0x0003003e, + 0x0000007d,0x00000080,0x00050041,0x00000007,0x00000082,0x0000007d,0x00000064,0x0004003d, + 0x00000006,0x00000083,0x00000082,0x00050041,0x00000007,0x00000084,0x0000007d,0x00000061, + 0x0004003d,0x00000006,0x00000085,0x00000084,0x00050083,0x00000006,0x00000086,0x00000083, + 0x00000085,0x0006000c,0x00000006,0x00000087,0x00000001,0x00000004,0x00000086,0x00050041, + 0x00000007,0x00000088,0x00000053,0x00000061,0x0004003d,0x00000006,0x00000089,0x00000088, + 0x00050041,0x00000007,0x0000008a,0x0000007d,0x00000061,0x0004003d,0x00000006,0x0000008b, + 0x0000008a,0x00050083,0x00000006,0x0000008c,0x00000089,0x0000008b,0x0006000c,0x00000006, + 0x0000008d,0x00000001,0x00000004,0x0000008c,0x00050081,0x00000006,0x0000008e,0x00000087, + 0x0000008d,0x00050041,0x00000007,0x0000008f,0x00000053,0x00000061,0x0004003d,0x00000006, + 0x00000090,0x0000008f,0x00050041,0x00000007,0x00000091,0x0000007d,0x00000064,0x0004003d, + 0x00000006,0x00000092,0x00000091,0x00050083,0x00000006,0x00000093,0x00000090,0x00000092, + 0x0006000c,0x00000006,0x00000094,0x00000001,0x00000004,0x00000093,0x00050081,0x00000006, + 0x00000095,0x0000008e,0x00000094,0x0003003e,0x00000081,0x00000095,0x0004003d,0x00000006, + 0x00000096,0x00000081,0x000500ba,0x00000098,0x00000099,0x00000096,0x00000097,0x000300f7, + 0x0000009b,0x00000000,0x000400fa,0x00000099,0x0000009a,0x0000009b,0x000200f8,0x0000009a, + 0x00050041,0x00000007,0x0000009c,0x00000045,0x0000005e,0x0004003d,0x00000006,0x0000009d, + 0x0000009c,0x00050041,0x00000007,0x0000009e,0x00000073,0x0000005e,0x0004003d,0x00000006, + 0x0000009f,0x0000009e,0x00050081,0x00000006,0x000000a0,0x0000009f,0x0000009d,0x00050041, + 0x00000007,0x000000a1,0x00000073,0x0000005e,0x0003003e,0x000000a1,0x000000a0,0x0004003d, + 0x00000055,0x000000a3,0x00000057,0x0004003d,0x0000000c,0x000000a4,0x00000073,0x00050041, + 0x00000007,0x000000a5,0x00000045,0x0000005e,0x0004003d,0x00000006,0x000000a6,0x000000a5, + 0x00050050,0x0000000c,0x000000a7,0x000000a6,0x00000034,0x00050081,0x0000000c,0x000000a8, + 0x000000a4,0x000000a7,0x00060060,0x00000043,0x000000a9,0x000000a3,0x000000a8,0x0000004a, + 0x0003003e,0x000000a2,0x000000a9,0x0004003d,0x00000055,0x000000ab,0x00000057,0x0004003d, + 0x0000000c,0x000000ac,0x00000073,0x00050041,0x00000007,0x000000ad,0x00000045,0x00000061, + 0x0004003d,0x00000006,0x000000ae,0x000000ad,0x0004007f,0x00000006,0x000000af,0x000000ae, + 0x00050050,0x0000000c,0x000000b0,0x00000034,0x000000af,0x00050081,0x0000000c,0x000000b1, + 0x000000ac,0x000000b0,0x00060060,0x00000043,0x000000b2,0x000000ab,0x000000b1,0x0000004a, + 0x0007004f,0x0000000c,0x000000b3,0x000000b2,0x000000b2,0x00000003,0x00000002,0x00050041, + 0x00000007,0x000000b4,0x000000aa,0x0000005e,0x00050051,0x00000006,0x000000b5,0x000000b3, + 0x00000000,0x0003003e,0x000000b4,0x000000b5,0x00050041,0x00000007,0x000000b6,0x000000aa, + 0x00000061,0x00050051,0x00000006,0x000000b7,0x000000b3,0x00000001,0x0003003e,0x000000b6, + 0x000000b7,0x0004003d,0x00000055,0x000000b8,0x00000057,0x0004003d,0x0000000c,0x000000b9, + 0x00000073,0x00050041,0x00000007,0x000000ba,0x00000045,0x00000061,0x0004003d,0x00000006, + 0x000000bb,0x000000ba,0x00050050,0x0000000c,0x000000bc,0x00000034,0x000000bb,0x00050081, + 0x0000000c,0x000000bd,0x000000b9,0x000000bc,0x00060060,0x00000043,0x000000be,0x000000b8, + 0x000000bd,0x0000004a,0x0007004f,0x0000000c,0x000000bf,0x000000be,0x000000be,0x00000001, + 0x00000000,0x00050041,0x00000007,0x000000c0,0x000000aa,0x00000064,0x00050051,0x00000006, + 0x000000c1,0x000000bf,0x00000000,0x0003003e,0x000000c0,0x000000c1,0x00050041,0x00000007, + 0x000000c3,0x000000aa,0x000000c2,0x00050051,0x00000006,0x000000c4,0x000000bf,0x00000001, + 0x0003003e,0x000000c3,0x000000c4,0x00050041,0x00000007,0x000000c6,0x0000007d,0x00000061, + 0x0004003d,0x00000006,0x000000c7,0x000000c6,0x00050041,0x00000007,0x000000c8,0x0000007d, + 0x00000064,0x0004003d,0x00000006,0x000000c9,0x000000c8,0x00050081,0x00000006,0x000000ca, + 0x000000c7,0x000000c9,0x00050041,0x00000007,0x000000cb,0x000000a2,0x0000005e,0x0004003d, + 0x00000006,0x000000cc,0x000000cb,0x00050081,0x00000006,0x000000cd,0x000000ca,0x000000cc, + 0x00050041,0x00000007,0x000000ce,0x000000a2,0x000000c2,0x0004003d,0x00000006,0x000000cf, + 0x000000ce,0x00050081,0x00000006,0x000000d0,0x000000cd,0x000000cf,0x00050085,0x00000006, + 0x000000d2,0x000000d0,0x000000d1,0x0003003e,0x000000c5,0x000000d2,0x0004003d,0x00000043, + 0x000000d3,0x0000007d,0x0004003d,0x00000006,0x000000d4,0x000000c5,0x00070050,0x00000043, + 0x000000d5,0x000000d4,0x000000d4,0x000000d4,0x000000d4,0x00050083,0x00000043,0x000000d6, + 0x000000d3,0x000000d5,0x0003003e,0x0000007d,0x000000d6,0x0004003d,0x00000043,0x000000d7, + 0x000000a2,0x0004003d,0x00000006,0x000000d8,0x000000c5,0x00070050,0x00000043,0x000000d9, + 0x000000d8,0x000000d8,0x000000d8,0x000000d8,0x00050083,0x00000043,0x000000da,0x000000d7, + 0x000000d9,0x0003003e,0x000000a2,0x000000da,0x0004003d,0x00000043,0x000000db,0x000000aa, + 0x0004003d,0x00000006,0x000000dc,0x000000c5,0x00070050,0x00000043,0x000000dd,0x000000dc, + 0x000000dc,0x000000dc,0x000000dc,0x00050083,0x00000043,0x000000de,0x000000db,0x000000dd, + 0x0003003e,0x000000aa,0x000000de,0x00050041,0x00000007,0x000000df,0x00000053,0x00000061, + 0x0004003d,0x00000006,0x000000e0,0x000000df,0x0004003d,0x00000006,0x000000e1,0x000000c5, + 0x00050083,0x00000006,0x000000e2,0x000000e0,0x000000e1,0x00050041,0x00000007,0x000000e3, + 0x00000053,0x000000c2,0x0003003e,0x000000e3,0x000000e2,0x00050041,0x00000007,0x000000e5, + 0x0000007d,0x0000005e,0x0004003d,0x00000006,0x000000e6,0x000000e5,0x0006000c,0x00000006, + 0x000000e7,0x00000001,0x00000004,0x000000e6,0x00050041,0x00000007,0x000000e8,0x0000007d, + 0x00000061,0x0004003d,0x00000006,0x000000e9,0x000000e8,0x0006000c,0x00000006,0x000000ea, + 0x00000001,0x00000004,0x000000e9,0x00050081,0x00000006,0x000000eb,0x000000e7,0x000000ea, + 0x00050041,0x00000007,0x000000ec,0x0000007d,0x00000064,0x0004003d,0x00000006,0x000000ed, + 0x000000ec,0x0006000c,0x00000006,0x000000ee,0x00000001,0x00000004,0x000000ed,0x00050081, + 0x00000006,0x000000ef,0x000000eb,0x000000ee,0x00050041,0x00000007,0x000000f0,0x0000007d, + 0x000000c2,0x0004003d,0x00000006,0x000000f1,0x000000f0,0x0006000c,0x00000006,0x000000f2, + 0x00000001,0x00000004,0x000000f1,0x00050081,0x00000006,0x000000f3,0x000000ef,0x000000f2, + 0x00050041,0x00000007,0x000000f4,0x000000a2,0x0000005e,0x0004003d,0x00000006,0x000000f5, + 0x000000f4,0x0006000c,0x00000006,0x000000f6,0x00000001,0x00000004,0x000000f5,0x00050041, + 0x00000007,0x000000f7,0x000000a2,0x00000061,0x0004003d,0x00000006,0x000000f8,0x000000f7, + 0x0006000c,0x00000006,0x000000f9,0x00000001,0x00000004,0x000000f8,0x00050081,0x00000006, + 0x000000fa,0x000000f6,0x000000f9,0x00050041,0x00000007,0x000000fb,0x000000a2,0x00000064, + 0x0004003d,0x00000006,0x000000fc,0x000000fb,0x0006000c,0x00000006,0x000000fd,0x00000001, + 0x00000004,0x000000fc,0x00050081,0x00000006,0x000000fe,0x000000fa,0x000000fd,0x00050041, + 0x00000007,0x000000ff,0x000000a2,0x000000c2,0x0004003d,0x00000006,0x00000100,0x000000ff, + 0x0006000c,0x00000006,0x00000101,0x00000001,0x00000004,0x00000100,0x00050081,0x00000006, + 0x00000102,0x000000fe,0x00000101,0x00050081,0x00000006,0x00000103,0x000000f3,0x00000102, + 0x00050041,0x00000007,0x00000104,0x000000aa,0x0000005e,0x0004003d,0x00000006,0x00000105, + 0x00000104,0x0006000c,0x00000006,0x00000106,0x00000001,0x00000004,0x00000105,0x00050041, + 0x00000007,0x00000107,0x000000aa,0x00000061,0x0004003d,0x00000006,0x00000108,0x00000107, + 0x0006000c,0x00000006,0x00000109,0x00000001,0x00000004,0x00000108,0x00050081,0x00000006, + 0x0000010a,0x00000106,0x00000109,0x00050041,0x00000007,0x0000010b,0x000000aa,0x00000064, + 0x0004003d,0x00000006,0x0000010c,0x0000010b,0x0006000c,0x00000006,0x0000010d,0x00000001, + 0x00000004,0x0000010c,0x00050081,0x00000006,0x0000010e,0x0000010a,0x0000010d,0x00050041, + 0x00000007,0x0000010f,0x000000aa,0x000000c2,0x0004003d,0x00000006,0x00000110,0x0000010f, + 0x0006000c,0x00000006,0x00000111,0x00000001,0x00000004,0x00000110,0x00050081,0x00000006, + 0x00000112,0x0000010e,0x00000111,0x00050081,0x00000006,0x00000113,0x00000103,0x00000112, + 0x0003003e,0x000000e4,0x00000113,0x0004003d,0x00000006,0x00000116,0x000000e4,0x00050088, + 0x00000006,0x00000117,0x00000115,0x00000116,0x0003003e,0x00000114,0x00000117,0x00050041, + 0x00000007,0x00000119,0x00000078,0x00000061,0x0004003d,0x00000006,0x0000011a,0x00000119, + 0x00050081,0x00000006,0x0000011b,0x0000011a,0x00000035,0x00050041,0x00000007,0x0000011d, + 0x00000078,0x0000005e,0x0004003d,0x00000006,0x0000011e,0x0000011d,0x0003003e,0x0000011c, + 0x0000011e,0x0003003e,0x0000011f,0x0000011b,0x00050041,0x00000007,0x00000121,0x000000aa, + 0x0000005e,0x0004003d,0x00000006,0x00000122,0x00000121,0x0003003e,0x00000120,0x00000122, + 0x0004003d,0x00000006,0x00000124,0x00000114,0x0003003e,0x00000123,0x00000124,0x00080039, + 0x0000000c,0x00000125,0x00000012,0x0000011c,0x0000011f,0x00000120,0x00000123,0x0003003e, + 0x00000118,0x00000125,0x00050041,0x00000007,0x00000126,0x00000078,0x0000005e,0x0004003d, + 0x00000006,0x00000127,0x00000126,0x00050083,0x00000006,0x00000128,0x00000127,0x00000035, + 0x00050041,0x00000007,0x00000129,0x00000078,0x00000061,0x0004003d,0x00000006,0x0000012a, + 0x00000129,0x00050081,0x00000006,0x0000012b,0x0000012a,0x00000035,0x0003003e,0x0000012c, + 0x00000128,0x0003003e,0x0000012d,0x0000012b,0x00050041,0x00000007,0x0000012f,0x000000aa, + 0x00000061,0x0004003d,0x00000006,0x00000130,0x0000012f,0x0003003e,0x0000012e,0x00000130, + 0x0004003d,0x00000006,0x00000132,0x00000114,0x0003003e,0x00000131,0x00000132,0x00080039, + 0x0000000c,0x00000133,0x00000012,0x0000012c,0x0000012d,0x0000012e,0x00000131,0x0004003d, + 0x0000000c,0x00000134,0x00000118,0x00050081,0x0000000c,0x00000135,0x00000134,0x00000133, + 0x0003003e,0x00000118,0x00000135,0x00050041,0x00000007,0x00000136,0x00000078,0x0000005e, + 0x0004003d,0x00000006,0x00000137,0x00000136,0x00050083,0x00000006,0x00000138,0x00000137, + 0x00000035,0x00050041,0x00000007,0x00000139,0x00000078,0x00000061,0x0004003d,0x00000006, + 0x0000013a,0x00000139,0x00050083,0x00000006,0x0000013c,0x0000013a,0x0000013b,0x0003003e, + 0x0000013d,0x00000138,0x0003003e,0x0000013e,0x0000013c,0x00050041,0x00000007,0x00000140, + 0x000000aa,0x00000064,0x0004003d,0x00000006,0x00000141,0x00000140,0x0003003e,0x0000013f, + 0x00000141,0x0004003d,0x00000006,0x00000143,0x00000114,0x0003003e,0x00000142,0x00000143, + 0x00080039,0x0000000c,0x00000144,0x00000012,0x0000013d,0x0000013e,0x0000013f,0x00000142, + 0x0004003d,0x0000000c,0x00000145,0x00000118,0x00050081,0x0000000c,0x00000146,0x00000145, + 0x00000144,0x0003003e,0x00000118,0x00000146,0x00050041,0x00000007,0x00000147,0x00000078, + 0x00000061,0x0004003d,0x00000006,0x00000148,0x00000147,0x00050083,0x00000006,0x00000149, + 0x00000148,0x0000013b,0x00050041,0x00000007,0x0000014b,0x00000078,0x0000005e,0x0004003d, + 0x00000006,0x0000014c,0x0000014b,0x0003003e,0x0000014a,0x0000014c,0x0003003e,0x0000014d, + 0x00000149,0x00050041,0x00000007,0x0000014f,0x000000aa,0x000000c2,0x0004003d,0x00000006, + 0x00000150,0x0000014f,0x0003003e,0x0000014e,0x00000150,0x0004003d,0x00000006,0x00000152, + 0x00000114,0x0003003e,0x00000151,0x00000152,0x00080039,0x0000000c,0x00000153,0x00000012, + 0x0000014a,0x0000014d,0x0000014e,0x00000151,0x0004003d,0x0000000c,0x00000154,0x00000118, + 0x00050081,0x0000000c,0x00000155,0x00000154,0x00000153,0x0003003e,0x00000118,0x00000155, + 0x00050041,0x00000007,0x00000156,0x00000078,0x0000005e,0x0004003d,0x00000006,0x00000157, + 0x00000156,0x00050081,0x00000006,0x00000158,0x00000157,0x00000035,0x00050041,0x00000007, + 0x00000159,0x00000078,0x00000061,0x0004003d,0x00000006,0x0000015a,0x00000159,0x00050083, + 0x00000006,0x0000015b,0x0000015a,0x00000035,0x0003003e,0x0000015c,0x00000158,0x0003003e, + 0x0000015d,0x0000015b,0x00050041,0x00000007,0x0000015f,0x0000007d,0x0000005e,0x0004003d, + 0x00000006,0x00000160,0x0000015f,0x0003003e,0x0000015e,0x00000160,0x0004003d,0x00000006, + 0x00000162,0x00000114,0x0003003e,0x00000161,0x00000162,0x00080039,0x0000000c,0x00000163, + 0x00000012,0x0000015c,0x0000015d,0x0000015e,0x00000161,0x0004003d,0x0000000c,0x00000164, + 0x00000118,0x00050081,0x0000000c,0x00000165,0x00000164,0x00000163,0x0003003e,0x00000118, + 0x00000165,0x00050041,0x00000007,0x00000166,0x00000078,0x00000061,0x0004003d,0x00000006, + 0x00000167,0x00000166,0x00050083,0x00000006,0x00000168,0x00000167,0x00000035,0x00050041, + 0x00000007,0x0000016a,0x00000078,0x0000005e,0x0004003d,0x00000006,0x0000016b,0x0000016a, + 0x0003003e,0x00000169,0x0000016b,0x0003003e,0x0000016c,0x00000168,0x00050041,0x00000007, + 0x0000016e,0x0000007d,0x00000061,0x0004003d,0x00000006,0x0000016f,0x0000016e,0x0003003e, + 0x0000016d,0x0000016f,0x0004003d,0x00000006,0x00000171,0x00000114,0x0003003e,0x00000170, + 0x00000171,0x00080039,0x0000000c,0x00000172,0x00000012,0x00000169,0x0000016c,0x0000016d, + 0x00000170,0x0004003d,0x0000000c,0x00000173,0x00000118,0x00050081,0x0000000c,0x00000174, + 0x00000173,0x00000172,0x0003003e,0x00000118,0x00000174,0x00050041,0x00000007,0x00000176, + 0x00000078,0x0000005e,0x0004003d,0x00000006,0x00000177,0x00000176,0x0003003e,0x00000175, + 0x00000177,0x00050041,0x00000007,0x00000179,0x00000078,0x00000061,0x0004003d,0x00000006, + 0x0000017a,0x00000179,0x0003003e,0x00000178,0x0000017a,0x00050041,0x00000007,0x0000017c, + 0x0000007d,0x00000064,0x0004003d,0x00000006,0x0000017d,0x0000017c,0x0003003e,0x0000017b, + 0x0000017d,0x0004003d,0x00000006,0x0000017f,0x00000114,0x0003003e,0x0000017e,0x0000017f, + 0x00080039,0x0000000c,0x00000180,0x00000012,0x00000175,0x00000178,0x0000017b,0x0000017e, + 0x0004003d,0x0000000c,0x00000181,0x00000118,0x00050081,0x0000000c,0x00000182,0x00000181, + 0x00000180,0x0003003e,0x00000118,0x00000182,0x00050041,0x00000007,0x00000183,0x00000078, + 0x0000005e,0x0004003d,0x00000006,0x00000184,0x00000183,0x00050081,0x00000006,0x00000185, + 0x00000184,0x00000035,0x0003003e,0x00000186,0x00000185,0x00050041,0x00000007,0x00000188, + 0x00000078,0x00000061,0x0004003d,0x00000006,0x00000189,0x00000188,0x0003003e,0x00000187, + 0x00000189,0x00050041,0x00000007,0x0000018b,0x0000007d,0x000000c2,0x0004003d,0x00000006, + 0x0000018c,0x0000018b,0x0003003e,0x0000018a,0x0000018c,0x0004003d,0x00000006,0x0000018e, + 0x00000114,0x0003003e,0x0000018d,0x0000018e,0x00080039,0x0000000c,0x0000018f,0x00000012, + 0x00000186,0x00000187,0x0000018a,0x0000018d,0x0004003d,0x0000000c,0x00000190,0x00000118, + 0x00050081,0x0000000c,0x00000191,0x00000190,0x0000018f,0x0003003e,0x00000118,0x00000191, + 0x00050041,0x00000007,0x00000192,0x00000078,0x0000005e,0x0004003d,0x00000006,0x00000193, + 0x00000192,0x00050083,0x00000006,0x00000194,0x00000193,0x00000035,0x00050041,0x00000007, + 0x00000195,0x00000078,0x00000061,0x0004003d,0x00000006,0x00000196,0x00000195,0x00050083, + 0x00000006,0x00000197,0x00000196,0x00000035,0x0003003e,0x00000198,0x00000194,0x0003003e, + 0x00000199,0x00000197,0x00050041,0x00000007,0x0000019b,0x000000a2,0x0000005e,0x0004003d, + 0x00000006,0x0000019c,0x0000019b,0x0003003e,0x0000019a,0x0000019c,0x0004003d,0x00000006, + 0x0000019e,0x00000114,0x0003003e,0x0000019d,0x0000019e,0x00080039,0x0000000c,0x0000019f, + 0x00000012,0x00000198,0x00000199,0x0000019a,0x0000019d,0x0004003d,0x0000000c,0x000001a0, + 0x00000118,0x00050081,0x0000000c,0x000001a1,0x000001a0,0x0000019f,0x0003003e,0x00000118, + 0x000001a1,0x00050041,0x00000007,0x000001a2,0x00000078,0x0000005e,0x0004003d,0x00000006, + 0x000001a3,0x000001a2,0x00050083,0x00000006,0x000001a4,0x000001a3,0x0000013b,0x00050041, + 0x00000007,0x000001a5,0x00000078,0x00000061,0x0004003d,0x00000006,0x000001a6,0x000001a5, + 0x00050083,0x00000006,0x000001a7,0x000001a6,0x00000035,0x0003003e,0x000001a8,0x000001a4, + 0x0003003e,0x000001a9,0x000001a7,0x00050041,0x00000007,0x000001ab,0x000000a2,0x00000061, + 0x0004003d,0x00000006,0x000001ac,0x000001ab,0x0003003e,0x000001aa,0x000001ac,0x0004003d, + 0x00000006,0x000001ae,0x00000114,0x0003003e,0x000001ad,0x000001ae,0x00080039,0x0000000c, + 0x000001af,0x00000012,0x000001a8,0x000001a9,0x000001aa,0x000001ad,0x0004003d,0x0000000c, + 0x000001b0,0x00000118,0x00050081,0x0000000c,0x000001b1,0x000001b0,0x000001af,0x0003003e, + 0x00000118,0x000001b1,0x00050041,0x00000007,0x000001b2,0x00000078,0x0000005e,0x0004003d, + 0x00000006,0x000001b3,0x000001b2,0x00050083,0x00000006,0x000001b4,0x000001b3,0x0000013b, + 0x0003003e,0x000001b5,0x000001b4,0x00050041,0x00000007,0x000001b7,0x00000078,0x00000061, + 0x0004003d,0x00000006,0x000001b8,0x000001b7,0x0003003e,0x000001b6,0x000001b8,0x00050041, + 0x00000007,0x000001ba,0x000000a2,0x00000064,0x0004003d,0x00000006,0x000001bb,0x000001ba, + 0x0003003e,0x000001b9,0x000001bb,0x0004003d,0x00000006,0x000001bd,0x00000114,0x0003003e, + 0x000001bc,0x000001bd,0x00080039,0x0000000c,0x000001be,0x00000012,0x000001b5,0x000001b6, + 0x000001b9,0x000001bc,0x0004003d,0x0000000c,0x000001bf,0x00000118,0x00050081,0x0000000c, + 0x000001c0,0x000001bf,0x000001be,0x0003003e,0x00000118,0x000001c0,0x00050041,0x00000007, + 0x000001c1,0x00000078,0x0000005e,0x0004003d,0x00000006,0x000001c2,0x000001c1,0x00050083, + 0x00000006,0x000001c3,0x000001c2,0x00000035,0x0003003e,0x000001c4,0x000001c3,0x00050041, + 0x00000007,0x000001c6,0x00000078,0x00000061,0x0004003d,0x00000006,0x000001c7,0x000001c6, + 0x0003003e,0x000001c5,0x000001c7,0x00050041,0x00000007,0x000001c9,0x000000a2,0x000000c2, + 0x0004003d,0x00000006,0x000001ca,0x000001c9,0x0003003e,0x000001c8,0x000001ca,0x0004003d, + 0x00000006,0x000001cc,0x00000114,0x0003003e,0x000001cb,0x000001cc,0x00080039,0x0000000c, + 0x000001cd,0x00000012,0x000001c4,0x000001c5,0x000001c8,0x000001cb,0x0004003d,0x0000000c, + 0x000001ce,0x00000118,0x00050081,0x0000000c,0x000001cf,0x000001ce,0x000001cd,0x0003003e, + 0x00000118,0x000001cf,0x00050041,0x00000007,0x000001d1,0x00000118,0x00000061,0x0004003d, + 0x00000006,0x000001d2,0x000001d1,0x00050041,0x00000007,0x000001d3,0x00000118,0x0000005e, + 0x0004003d,0x00000006,0x000001d4,0x000001d3,0x00050088,0x00000006,0x000001d5,0x000001d2, + 0x000001d4,0x0003003e,0x000001d0,0x000001d5,0x00050041,0x00000007,0x000001d7,0x0000007d, + 0x00000061,0x0004003d,0x00000006,0x000001d8,0x000001d7,0x00050041,0x00000007,0x000001d9, + 0x0000007d,0x00000064,0x0004003d,0x00000006,0x000001da,0x000001d9,0x0007000c,0x00000006, + 0x000001db,0x00000001,0x00000028,0x000001d8,0x000001da,0x00050041,0x00000007,0x000001dc, + 0x000000a2,0x0000005e,0x0004003d,0x00000006,0x000001dd,0x000001dc,0x00050041,0x00000007, + 0x000001de,0x000000a2,0x000000c2,0x0004003d,0x00000006,0x000001df,0x000001de,0x0007000c, + 0x00000006,0x000001e0,0x00000001,0x00000028,0x000001dd,0x000001df,0x0007000c,0x00000006, + 0x000001e1,0x00000001,0x00000028,0x000001db,0x000001e0,0x0003003e,0x000001d6,0x000001e1, + 0x00050041,0x00000007,0x000001e3,0x0000007d,0x00000061,0x0004003d,0x00000006,0x000001e4, + 0x000001e3,0x00050041,0x00000007,0x000001e5,0x0000007d,0x00000064,0x0004003d,0x00000006, + 0x000001e6,0x000001e5,0x0007000c,0x00000006,0x000001e7,0x00000001,0x00000025,0x000001e4, + 0x000001e6,0x00050041,0x00000007,0x000001e8,0x000000a2,0x0000005e,0x0004003d,0x00000006, + 0x000001e9,0x000001e8,0x00050041,0x00000007,0x000001ea,0x000000a2,0x000000c2,0x0004003d, + 0x00000006,0x000001eb,0x000001ea,0x0007000c,0x00000006,0x000001ec,0x00000001,0x00000025, + 0x000001e9,0x000001eb,0x0007000c,0x00000006,0x000001ed,0x00000001,0x00000025,0x000001e7, + 0x000001ec,0x0003003e,0x000001e2,0x000001ed,0x00050041,0x000001ef,0x000001f0,0x00000048, + 0x000001ee,0x0004003d,0x00000006,0x000001f1,0x000001f0,0x0004003d,0x00000006,0x000001f2, + 0x000001d0,0x00050085,0x00000006,0x000001f3,0x000001f1,0x000001f2,0x0004003d,0x00000006, + 0x000001f4,0x000001e2,0x0004003d,0x00000006,0x000001f5,0x000001d6,0x0008000c,0x00000006, + 0x000001f6,0x00000001,0x0000002b,0x000001f3,0x000001f4,0x000001f5,0x0003003e,0x000001d0, + 0x000001f6,0x0004003d,0x00000006,0x000001f8,0x000001d0,0x00050041,0x00000007,0x000001f9, + 0x00000053,0x000000c2,0x0004003d,0x00000006,0x000001fa,0x000001f9,0x00050083,0x00000006, + 0x000001fb,0x000001f8,0x000001fa,0x0003003e,0x000001f7,0x000001fb,0x0004003d,0x00000006, + 0x000001fc,0x000001f7,0x0008000c,0x00000006,0x000001ff,0x00000001,0x0000002b,0x000001fc, + 0x000001fd,0x000001fe,0x0003003e,0x000001f7,0x000001ff,0x00050041,0x00000007,0x00000200, + 0x00000053,0x0000005e,0x0004003d,0x00000006,0x00000201,0x00000200,0x0004003d,0x00000006, + 0x00000202,0x000001f7,0x00050081,0x00000006,0x00000203,0x00000201,0x00000202,0x0008000c, + 0x00000006,0x00000204,0x00000001,0x0000002b,0x00000203,0x00000034,0x00000035,0x00050041, + 0x00000007,0x00000205,0x00000053,0x0000005e,0x0003003e,0x00000205,0x00000204,0x00050041, + 0x00000007,0x00000206,0x00000053,0x00000061,0x0004003d,0x00000006,0x00000207,0x00000206, + 0x0004003d,0x00000006,0x00000208,0x000001f7,0x00050081,0x00000006,0x00000209,0x00000207, + 0x00000208,0x0008000c,0x00000006,0x0000020a,0x00000001,0x0000002b,0x00000209,0x00000034, + 0x00000035,0x00050041,0x00000007,0x0000020b,0x00000053,0x00000061,0x0003003e,0x0000020b, + 0x0000020a,0x00050041,0x00000007,0x0000020c,0x00000053,0x00000064,0x0004003d,0x00000006, + 0x0000020d,0x0000020c,0x0004003d,0x00000006,0x0000020e,0x000001f7,0x00050081,0x00000006, + 0x0000020f,0x0000020d,0x0000020e,0x0008000c,0x00000006,0x00000210,0x00000001,0x0000002b, + 0x0000020f,0x00000034,0x00000035,0x00050041,0x00000007,0x00000211,0x00000053,0x00000064, + 0x0003003e,0x00000211,0x00000210,0x000200f9,0x0000009b,0x000200f8,0x0000009b,0x00050041, + 0x00000007,0x00000212,0x00000053,0x000000c2,0x0003003e,0x00000212,0x00000035,0x0004003d, + 0x00000043,0x00000215,0x00000053,0x0003003e,0x00000214,0x00000215,0x000100fd,0x00010038, + 0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,0x00030037,0x00000007,0x00000009, + 0x000200f8,0x0000000b,0x0004003b,0x00000007,0x00000014,0x00000007,0x0004003b,0x00000007, + 0x00000018,0x00000007,0x0004003d,0x00000006,0x00000015,0x00000009,0x00050083,0x00000006, + 0x00000017,0x00000015,0x00000016,0x0003003e,0x00000014,0x00000017,0x0004003d,0x00000006, + 0x00000019,0x00000009,0x0004003d,0x00000006,0x0000001a,0x00000014,0x00050085,0x00000006, + 0x0000001b,0x00000019,0x0000001a,0x0004003d,0x00000006,0x0000001c,0x00000014,0x00050083, + 0x00000006,0x0000001d,0x0000001b,0x0000001c,0x0003003e,0x00000018,0x0000001d,0x0004003d, + 0x00000006,0x0000001e,0x00000014,0x0004003d,0x00000006,0x0000001f,0x00000014,0x00050085, + 0x00000006,0x00000020,0x0000001f,0x0000001e,0x0003003e,0x00000014,0x00000020,0x0004003d, + 0x00000006,0x00000021,0x00000018,0x0004003d,0x00000006,0x00000022,0x00000014,0x00050085, + 0x00000006,0x00000023,0x00000021,0x00000022,0x000200fe,0x00000023,0x00010038,0x00050036, + 0x0000000c,0x00000012,0x00000000,0x0000000d,0x00030037,0x00000007,0x0000000e,0x00030037, + 0x00000007,0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037,0x00000007,0x00000011, + 0x000200f8,0x00000013,0x0004003b,0x00000007,0x00000026,0x00000007,0x0004003b,0x00000007, + 0x00000038,0x00000007,0x0004003b,0x00000007,0x00000039,0x00000007,0x0004003d,0x00000006, + 0x00000027,0x0000000e,0x0004003d,0x00000006,0x00000028,0x0000000e,0x00050085,0x00000006, + 0x00000029,0x00000027,0x00000028,0x0004003d,0x00000006,0x0000002a,0x0000000f,0x0004003d, + 0x00000006,0x0000002b,0x0000000f,0x00050085,0x00000006,0x0000002c,0x0000002a,0x0000002b, + 0x00050081,0x00000006,0x0000002d,0x00000029,0x0000002c,0x00050085,0x00000006,0x0000002f, + 0x0000002d,0x0000002e,0x0004003d,0x00000006,0x00000030,0x00000010,0x0006000c,0x00000006, + 0x00000031,0x00000001,0x00000004,0x00000030,0x0004003d,0x00000006,0x00000032,0x00000011, + 0x00050085,0x00000006,0x00000033,0x00000031,0x00000032,0x0008000c,0x00000006,0x00000036, + 0x00000001,0x0000002b,0x00000033,0x00000034,0x00000035,0x00050081,0x00000006,0x00000037, + 0x0000002f,0x00000036,0x0003003e,0x00000026,0x00000037,0x0004003d,0x00000006,0x0000003a, + 0x00000026,0x0003003e,0x00000039,0x0000003a,0x00050039,0x00000006,0x0000003b,0x0000000a, + 0x00000039,0x0003003e,0x00000038,0x0000003b,0x0004003d,0x00000006,0x0000003c,0x00000038, + 0x0004003d,0x00000006,0x0000003d,0x00000038,0x0004003d,0x00000006,0x0000003e,0x00000010, + 0x00050085,0x00000006,0x0000003f,0x0000003d,0x0000003e,0x00050050,0x0000000c,0x00000040, + 0x0000003c,0x0000003f,0x000200fe,0x00000040,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/sgsr_quality.frag b/app/src/main/cpp/shaders/sgsr_quality.frag new file mode 100644 index 0000000000..2cab792e5f --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr_quality.frag @@ -0,0 +1,156 @@ +#version 450 + +// ============================================================================= +// Snapdragon Game Super Resolution (SGSR) 1 - "Quality" variant (edge direction). +// +// Ported from Qualcomm's reference shader: +// SnapdragonGameStudios/snapdragon-gsr +// sgsr/v1/include/glsl/sgsr1_shader_mobile_edge_direction.frag +// +// Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// +// Same single pass, inputs and push constants as sgsr.frag (the mode-3 "SGSR" +// shader, left untouched). Differences, both taken from the reference file: +// - UseEdgeDirection: the Lanczos weights are stretched along the local edge +// direction, so diagonal edges reconstruct cleaner ("minimal cost increase" +// per Qualcomm). +// - the reference's retuned contrast term: std = (10.14185 / sum)^2 +// (sgsr.frag keeps the older 2.181818 / sum). +// Adapted for the Winlator native Vulkan compositor exactly like sgsr.frag: +// - #version 450 (Vulkan GLSL), ViewportInfo via push constant +// - specialised to OperationMode == 1 (RGBA); green channel is the edge luma +// - reuses window.vert (full-screen quad over the destination rect) +// ============================================================================= + +// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and +// weight maths in mediump (RelaxedPrecision, 16-bit on Adreno) as in Qualcomm's +// reference; positions and texture coordinates stay highp. +#ifdef DD_HALF +precision mediump float; +#define BL_MP mediump +#else +#define BL_MP +#endif + +layout(binding = 0) uniform BL_MP sampler2D ps0; + +layout(push_constant) uniform PC { + highp vec4 ndc; // quad NDC rect, consumed by window.vert (offset 0) + highp vec4 ViewportInfo; // xy = 1/inputSize (texel size), zw = inputSize in pixels + float EdgeSharpness; // driven by the "Sharpness" slider +} pc; + +layout(location = 0) in highp vec2 fragTexCoord; +layout(location = 0) out vec4 out_Target0; + +const float EdgeThreshold = 8.0 / 255.0; + +float fastLanczos2(float x) { + float wA = x - 4.0; + float wB = x * wA - wA; + wA *= wA; + return wB * wA; +} + +// data.x = std, data.yz = normalised edge direction +vec2 weightY(float dx, float dy, float c, vec3 data) { + float std = data.x; + vec2 dir = data.yz; + float edgeDis = (dx * dir.y) + (dy * dir.x); + float x = ((dx * dx) + (dy * dy)) + + ((edgeDis * edgeDis) * ((clamp((c * c) * std, 0.0, 1.0) * 0.7) - 1.0)); + float w = fastLanczos2(x); + return vec2(w, w * c); +} + +vec2 edgeDirection(vec4 left, vec4 right) { + float RxLz = right.x - left.z; + float RwLy = right.w - left.y; + vec2 delta; + delta.x = RxLz + RwLy; + delta.y = RxLz - RwLy; +#ifdef DD_HALF + // 3.07574e-05 is below the smallest normal 16-bit float (6.1e-05) and is + // flushed to 0 where denormals are not kept: 0 * inf on a flat row. Highp here. + highp vec2 dh = delta; + float lengthInv = inversesqrt((dh.x * dh.x + 3.075740e-05) + (dh.y * dh.y)); +#else + float lengthInv = inversesqrt((delta.x * delta.x + 3.075740e-05) + (delta.y * delta.y)); +#endif + return delta * lengthInv; +} + +void main() { + highp vec4 ViewportInfo = pc.ViewportInfo; + highp vec2 uv = fragTexCoord; + + vec4 color; + color.xyz = textureLod(ps0, uv, 0.0).xyz; + + highp vec2 imgCoord = ((uv * ViewportInfo.zw) + vec2(-0.5, 0.5)); + highp vec2 imgCoordPixel = floor(imgCoord); + highp vec2 coord = (imgCoordPixel * ViewportInfo.xy); + vec2 pl = (imgCoord + (-imgCoordPixel)); + vec4 left = textureGather(ps0, coord, 1); + + float edgeVote = abs(left.z - left.y) + abs(color.y - left.y) + abs(color.y - left.z); + if (edgeVote > EdgeThreshold) { + coord.x += ViewportInfo.x; + + vec4 right = textureGather(ps0, coord + vec2(ViewportInfo.x, 0.0), 1); + vec4 upDown; + upDown.xy = textureGather(ps0, coord + vec2(0.0, -ViewportInfo.y), 1).wz; + upDown.zw = textureGather(ps0, coord + vec2(0.0, ViewportInfo.y), 1).yx; + + float mean = (left.y + left.z + right.x + right.w) * 0.25; + left = left - vec4(mean); + right = right - vec4(mean); + upDown = upDown - vec4(mean); + color.w = color.y - mean; + + float sum = (((((abs(left.x) + abs(left.y)) + abs(left.z)) + abs(left.w)) + + (((abs(right.x) + abs(right.y)) + abs(right.z)) + abs(right.w))) + + (((abs(upDown.x) + abs(upDown.y)) + abs(upDown.z)) + abs(upDown.w))); + float sumMean = 1.014185e+01 / sum; +#ifdef DD_HALF + // (10.14 / sum)^2 passes 65504 (16-bit max) once sum < ~0.04, and c * c * inf + // is NaN for c == 0. Capped: c * c * cap still saturates the clamp below for + // any c >= 1/255. + float std = min(sumMean * sumMean, 65504.0); +#else + float std = sumMean * sumMean; +#endif + + vec3 data = vec3(std, edgeDirection(left, right)); + + vec2 aWY = weightY(pl.x, pl.y + 1.0, upDown.x, data); + aWY += weightY(pl.x - 1.0, pl.y + 1.0, upDown.y, data); + aWY += weightY(pl.x - 1.0, pl.y - 2.0, upDown.z, data); + aWY += weightY(pl.x, pl.y - 2.0, upDown.w, data); + aWY += weightY(pl.x + 1.0, pl.y - 1.0, left.x, data); + aWY += weightY(pl.x, pl.y - 1.0, left.y, data); + aWY += weightY(pl.x, pl.y, left.z, data); + aWY += weightY(pl.x + 1.0, pl.y, left.w, data); + aWY += weightY(pl.x - 1.0, pl.y - 1.0, right.x, data); + aWY += weightY(pl.x - 2.0, pl.y - 1.0, right.y, data); + aWY += weightY(pl.x - 2.0, pl.y, right.z, data); + aWY += weightY(pl.x - 1.0, pl.y, right.w, data); + + float finalY = aWY.y / aWY.x; + + float maxY = max(max(left.y, left.z), max(right.x, right.w)); + float minY = min(min(left.y, left.z), min(right.x, right.w)); + finalY = clamp(pc.EdgeSharpness * finalY, minY, maxY); + + float deltaY = finalY - color.w; + deltaY = clamp(deltaY, -23.0 / 255.0, 23.0 / 255.0); + + color.x = clamp((color.x + deltaY), 0.0, 1.0); + color.y = clamp((color.y + deltaY), 0.0, 1.0); + color.z = clamp((color.z + deltaY), 0.0, 1.0); + } + + color.w = 1.0; // alpha channel unused by the compositor blit + out_Target0 = color; +} diff --git a/app/src/main/cpp/shaders/sgsr_quality_half_frag.h b/app/src/main/cpp/shaders/sgsr_quality_half_frag.h new file mode 100644 index 0000000000..d715a73972 --- /dev/null +++ b/app/src/main/cpp/shaders/sgsr_quality_half_frag.h @@ -0,0 +1,612 @@ + // 1116.2.0 + #pragma once +const uint32_t sgsr_quality_half_code[] = { + 0x07230203,0x00010000,0x0008000b,0x0000026d,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000009e,0x0000026b,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00070005,0x0000000a,0x74736166,0x636e614c,0x32736f7a,0x3b316628,0x00000000, + 0x00030005,0x00000009,0x00000078,0x00080005,0x00000014,0x67696577,0x28597468,0x663b3166, + 0x31663b31,0x3366763b,0x0000003b,0x00030005,0x00000010,0x00007864,0x00030005,0x00000011, + 0x00007964,0x00030005,0x00000012,0x00000063,0x00040005,0x00000013,0x61746164,0x00000000, + 0x00080005,0x0000001b,0x65676465,0x65726944,0x6f697463,0x6676286e,0x66763b34,0x00003b34, + 0x00040005,0x00000019,0x7466656c,0x00000000,0x00040005,0x0000001a,0x68676972,0x00000074, + 0x00030005,0x0000001d,0x00004177,0x00030005,0x00000021,0x00004277,0x00030005,0x0000002f, + 0x00647473,0x00030005,0x00000035,0x00726964,0x00040005,0x00000038,0x65676465,0x00736944, + 0x00030005,0x00000043,0x00000078,0x00030005,0x0000005b,0x00000077,0x00040005,0x0000005c, + 0x61726170,0x0000006d,0x00040005,0x00000066,0x7a4c7852,0x00000000,0x00040005,0x0000006d, + 0x794c7752,0x00000000,0x00040005,0x00000074,0x746c6564,0x00000061,0x00030005,0x0000007d, + 0x00006864,0x00050005,0x0000007f,0x676e656c,0x6e496874,0x00000076,0x00060005,0x00000093, + 0x77656956,0x74726f70,0x6f666e49,0x00000000,0x00030005,0x00000094,0x00004350,0x00040006, + 0x00000094,0x00000000,0x0063646e,0x00070006,0x00000094,0x00000001,0x77656956,0x74726f70, + 0x6f666e49,0x00000000,0x00070006,0x00000094,0x00000002,0x65676445,0x72616853,0x73656e70, + 0x00000073,0x00030005,0x00000096,0x00006370,0x00030005,0x0000009c,0x00007675,0x00060005, + 0x0000009e,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x000000a0,0x6f6c6f63, + 0x00000072,0x00030005,0x000000a4,0x00307370,0x00050005,0x000000af,0x43676d69,0x64726f6f, + 0x00000000,0x00060005,0x000000b8,0x43676d69,0x64726f6f,0x65786950,0x0000006c,0x00040005, + 0x000000bb,0x726f6f63,0x00000064,0x00030005,0x000000c0,0x00006c70,0x00040005,0x000000c5, + 0x7466656c,0x00000000,0x00050005,0x000000c9,0x65676465,0x65746f56,0x00000000,0x00040005, + 0x000000ea,0x68676972,0x00000074,0x00040005,0x000000f2,0x6f447075,0x00006e77,0x00040005, + 0x0000010c,0x6e61656d,0x00000000,0x00030005,0x0000012b,0x006d7573,0x00040005,0x0000015b, + 0x4d6d7573,0x006e6165,0x00030005,0x0000015f,0x00647473,0x00040005,0x00000165,0x61746164, + 0x00000000,0x00040005,0x00000167,0x61726170,0x0000006d,0x00040005,0x00000169,0x61726170, + 0x0000006d,0x00030005,0x0000016f,0x00595761,0x00040005,0x00000173,0x61726170,0x0000006d, + 0x00040005,0x00000176,0x61726170,0x0000006d,0x00040005,0x00000177,0x61726170,0x0000006d, + 0x00040005,0x0000017a,0x61726170,0x0000006d,0x00040005,0x00000183,0x61726170,0x0000006d, + 0x00040005,0x00000184,0x61726170,0x0000006d,0x00040005,0x00000185,0x61726170,0x0000006d, + 0x00040005,0x00000188,0x61726170,0x0000006d,0x00040005,0x00000194,0x61726170,0x0000006d, + 0x00040005,0x00000195,0x61726170,0x0000006d,0x00040005,0x00000196,0x61726170,0x0000006d, + 0x00040005,0x00000199,0x61726170,0x0000006d,0x00040005,0x000001a1,0x61726170,0x0000006d, + 0x00040005,0x000001a4,0x61726170,0x0000006d,0x00040005,0x000001a5,0x61726170,0x0000006d, + 0x00040005,0x000001a8,0x61726170,0x0000006d,0x00040005,0x000001b3,0x61726170,0x0000006d, + 0x00040005,0x000001b4,0x61726170,0x0000006d,0x00040005,0x000001b5,0x61726170,0x0000006d, + 0x00040005,0x000001b8,0x61726170,0x0000006d,0x00040005,0x000001c0,0x61726170,0x0000006d, + 0x00040005,0x000001c3,0x61726170,0x0000006d,0x00040005,0x000001c4,0x61726170,0x0000006d, + 0x00040005,0x000001c7,0x61726170,0x0000006d,0x00040005,0x000001cc,0x61726170,0x0000006d, + 0x00040005,0x000001cf,0x61726170,0x0000006d,0x00040005,0x000001d2,0x61726170,0x0000006d, + 0x00040005,0x000001d5,0x61726170,0x0000006d,0x00040005,0x000001dd,0x61726170,0x0000006d, + 0x00040005,0x000001de,0x61726170,0x0000006d,0x00040005,0x000001e1,0x61726170,0x0000006d, + 0x00040005,0x000001e4,0x61726170,0x0000006d,0x00040005,0x000001ef,0x61726170,0x0000006d, + 0x00040005,0x000001f0,0x61726170,0x0000006d,0x00040005,0x000001f1,0x61726170,0x0000006d, + 0x00040005,0x000001f4,0x61726170,0x0000006d,0x00040005,0x000001ff,0x61726170,0x0000006d, + 0x00040005,0x00000200,0x61726170,0x0000006d,0x00040005,0x00000201,0x61726170,0x0000006d, + 0x00040005,0x00000204,0x61726170,0x0000006d,0x00040005,0x0000020c,0x61726170,0x0000006d, + 0x00040005,0x0000020d,0x61726170,0x0000006d,0x00040005,0x00000210,0x61726170,0x0000006d, + 0x00040005,0x00000213,0x61726170,0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d, + 0x00040005,0x0000021c,0x61726170,0x0000006d,0x00040005,0x0000021f,0x61726170,0x0000006d, + 0x00040005,0x00000222,0x61726170,0x0000006d,0x00040005,0x00000227,0x616e6966,0x0000596c, + 0x00040005,0x0000022d,0x5978616d,0x00000000,0x00040005,0x00000239,0x596e696d,0x00000000, + 0x00040005,0x0000024e,0x746c6564,0x00005961,0x00050005,0x0000026b,0x5f74756f,0x67726154, + 0x00307465,0x00030047,0x00000009,0x00000000,0x00030047,0x0000000a,0x00000000,0x00030047, + 0x00000010,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000, + 0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,0x00030047,0x00000019, + 0x00000000,0x00030047,0x0000001a,0x00000000,0x00030047,0x0000001b,0x00000000,0x00030047, + 0x0000001d,0x00000000,0x00030047,0x0000001e,0x00000000,0x00030047,0x00000020,0x00000000, + 0x00030047,0x00000021,0x00000000,0x00030047,0x00000022,0x00000000,0x00030047,0x00000023, + 0x00000000,0x00030047,0x00000024,0x00000000,0x00030047,0x00000025,0x00000000,0x00030047, + 0x00000026,0x00000000,0x00030047,0x00000027,0x00000000,0x00030047,0x00000028,0x00000000, + 0x00030047,0x00000029,0x00000000,0x00030047,0x0000002a,0x00000000,0x00030047,0x0000002b, + 0x00000000,0x00030047,0x0000002c,0x00000000,0x00030047,0x0000002f,0x00000000,0x00030047, + 0x00000033,0x00000000,0x00030047,0x00000035,0x00000000,0x00030047,0x00000036,0x00000000, + 0x00030047,0x00000037,0x00000000,0x00030047,0x00000038,0x00000000,0x00030047,0x00000039, + 0x00000000,0x00030047,0x0000003c,0x00000000,0x00030047,0x0000003d,0x00000000,0x00030047, + 0x0000003e,0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000041,0x00000000, + 0x00030047,0x00000042,0x00000000,0x00030047,0x00000043,0x00000000,0x00030047,0x00000044, + 0x00000000,0x00030047,0x00000045,0x00000000,0x00030047,0x00000046,0x00000000,0x00030047, + 0x00000047,0x00000000,0x00030047,0x00000048,0x00000000,0x00030047,0x00000049,0x00000000, + 0x00030047,0x0000004a,0x00000000,0x00030047,0x0000004b,0x00000000,0x00030047,0x0000004c, + 0x00000000,0x00030047,0x0000004d,0x00000000,0x00030047,0x0000004e,0x00000000,0x00030047, + 0x0000004f,0x00000000,0x00030047,0x00000050,0x00000000,0x00030047,0x00000051,0x00000000, + 0x00030047,0x00000052,0x00000000,0x00030047,0x00000055,0x00000000,0x00030047,0x00000057, + 0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,0x00000059,0x00000000,0x00030047, + 0x0000005a,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x0000005c,0x00000000, + 0x00030047,0x0000005d,0x00000000,0x00030047,0x0000005e,0x00000000,0x00030047,0x0000005f, + 0x00000000,0x00030047,0x00000060,0x00000000,0x00030047,0x00000061,0x00000000,0x00030047, + 0x00000062,0x00000000,0x00030047,0x00000063,0x00000000,0x00030047,0x00000066,0x00000000, + 0x00030047,0x00000068,0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,0x0000006c, + 0x00000000,0x00030047,0x0000006d,0x00000000,0x00030047,0x00000070,0x00000000,0x00030047, + 0x00000072,0x00000000,0x00030047,0x00000073,0x00000000,0x00030047,0x00000074,0x00000000, + 0x00030047,0x00000075,0x00000000,0x00030047,0x00000076,0x00000000,0x00030047,0x00000077, + 0x00000000,0x00030047,0x00000079,0x00000000,0x00030047,0x0000007a,0x00000000,0x00030047, + 0x0000007b,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x0000007f,0x00000000, + 0x00030047,0x0000008e,0x00000000,0x00030047,0x0000008f,0x00000000,0x00030047,0x00000090, + 0x00000000,0x00030047,0x00000094,0x00000002,0x00050048,0x00000094,0x00000000,0x00000023, + 0x00000000,0x00050048,0x00000094,0x00000001,0x00000023,0x00000010,0x00040048,0x00000094, + 0x00000002,0x00000000,0x00050048,0x00000094,0x00000002,0x00000023,0x00000020,0x00040047, + 0x0000009e,0x0000001e,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047,0x000000a4, + 0x00000000,0x00040047,0x000000a4,0x00000021,0x00000000,0x00040047,0x000000a4,0x00000022, + 0x00000000,0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a7,0x00000000,0x00030047, + 0x000000a8,0x00000000,0x00030047,0x000000c0,0x00000000,0x00030047,0x000000c5,0x00000000, + 0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000c9, + 0x00000000,0x00030047,0x000000cb,0x00000000,0x00030047,0x000000cd,0x00000000,0x00030047, + 0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d1,0x00000000, + 0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5, + 0x00000000,0x00030047,0x000000d6,0x00000000,0x00030047,0x000000d8,0x00000000,0x00030047, + 0x000000da,0x00000000,0x00030047,0x000000db,0x00000000,0x00030047,0x000000dc,0x00000000, + 0x00030047,0x000000dd,0x00000000,0x00030047,0x000000de,0x00000000,0x00030047,0x000000df, + 0x00000000,0x00030047,0x000000ea,0x00000000,0x00030047,0x000000eb,0x00000000,0x00030047, + 0x000000f1,0x00000000,0x00030047,0x000000f2,0x00000000,0x00030047,0x000000f3,0x00000000, + 0x00030047,0x000000fa,0x00000000,0x00030047,0x000000fb,0x00000000,0x00030047,0x00000100, + 0x00000000,0x00030047,0x00000106,0x00000000,0x00030047,0x00000107,0x00000000,0x00030047, + 0x0000010c,0x00000000,0x00030047,0x0000010e,0x00000000,0x00030047,0x00000110,0x00000000, + 0x00030047,0x00000111,0x00000000,0x00030047,0x00000113,0x00000000,0x00030047,0x00000114, + 0x00000000,0x00030047,0x00000116,0x00000000,0x00030047,0x00000117,0x00000000,0x00030047, + 0x00000119,0x00000000,0x00030047,0x0000011a,0x00000000,0x00030047,0x0000011b,0x00000000, + 0x00030047,0x0000011c,0x00000000,0x00030047,0x0000011d,0x00000000,0x00030047,0x0000011e, + 0x00000000,0x00030047,0x0000011f,0x00000000,0x00030047,0x00000120,0x00000000,0x00030047, + 0x00000121,0x00000000,0x00030047,0x00000122,0x00000000,0x00030047,0x00000123,0x00000000, + 0x00030047,0x00000124,0x00000000,0x00030047,0x00000125,0x00000000,0x00030047,0x00000127, + 0x00000000,0x00030047,0x00000128,0x00000000,0x00030047,0x00000129,0x00000000,0x00030047, + 0x0000012b,0x00000000,0x00030047,0x0000012d,0x00000000,0x00030047,0x0000012e,0x00000000, + 0x00030047,0x00000130,0x00000000,0x00030047,0x00000131,0x00000000,0x00030047,0x00000132, + 0x00000000,0x00030047,0x00000134,0x00000000,0x00030047,0x00000135,0x00000000,0x00030047, + 0x00000136,0x00000000,0x00030047,0x00000138,0x00000000,0x00030047,0x00000139,0x00000000, + 0x00030047,0x0000013a,0x00000000,0x00030047,0x0000013c,0x00000000,0x00030047,0x0000013d, + 0x00000000,0x00030047,0x0000013f,0x00000000,0x00030047,0x00000140,0x00000000,0x00030047, + 0x00000141,0x00000000,0x00030047,0x00000143,0x00000000,0x00030047,0x00000144,0x00000000, + 0x00030047,0x00000145,0x00000000,0x00030047,0x00000147,0x00000000,0x00030047,0x00000148, + 0x00000000,0x00030047,0x00000149,0x00000000,0x00030047,0x0000014a,0x00000000,0x00030047, + 0x0000014c,0x00000000,0x00030047,0x0000014d,0x00000000,0x00030047,0x0000014f,0x00000000, + 0x00030047,0x00000150,0x00000000,0x00030047,0x00000151,0x00000000,0x00030047,0x00000153, + 0x00000000,0x00030047,0x00000154,0x00000000,0x00030047,0x00000155,0x00000000,0x00030047, + 0x00000157,0x00000000,0x00030047,0x00000158,0x00000000,0x00030047,0x00000159,0x00000000, + 0x00030047,0x0000015a,0x00000000,0x00030047,0x0000015b,0x00000000,0x00030047,0x0000015d, + 0x00000000,0x00030047,0x0000015e,0x00000000,0x00030047,0x0000015f,0x00000000,0x00030047, + 0x00000160,0x00000000,0x00030047,0x00000161,0x00000000,0x00030047,0x00000162,0x00000000, + 0x00030047,0x00000164,0x00000000,0x00030047,0x00000165,0x00000000,0x00030047,0x00000166, + 0x00000000,0x00030047,0x00000167,0x00000000,0x00030047,0x00000168,0x00000000,0x00030047, + 0x00000169,0x00000000,0x00030047,0x0000016a,0x00000000,0x00030047,0x0000016b,0x00000000, + 0x00030047,0x0000016c,0x00000000,0x00030047,0x0000016d,0x00000000,0x00030047,0x0000016e, + 0x00000000,0x00030047,0x0000016f,0x00000000,0x00030047,0x00000171,0x00000000,0x00030047, + 0x00000172,0x00000000,0x00030047,0x00000173,0x00000000,0x00030047,0x00000175,0x00000000, + 0x00030047,0x00000176,0x00000000,0x00030047,0x00000177,0x00000000,0x00030047,0x00000179, + 0x00000000,0x00030047,0x0000017a,0x00000000,0x00030047,0x0000017b,0x00000000,0x00030047, + 0x0000017c,0x00000000,0x00030047,0x0000017e,0x00000000,0x00030047,0x0000017f,0x00000000, + 0x00030047,0x00000181,0x00000000,0x00030047,0x00000182,0x00000000,0x00030047,0x00000183, + 0x00000000,0x00030047,0x00000184,0x00000000,0x00030047,0x00000185,0x00000000,0x00030047, + 0x00000187,0x00000000,0x00030047,0x00000188,0x00000000,0x00030047,0x00000189,0x00000000, + 0x00030047,0x0000018a,0x00000000,0x00030047,0x0000018b,0x00000000,0x00030047,0x0000018c, + 0x00000000,0x00030047,0x0000018e,0x00000000,0x00030047,0x0000018f,0x00000000,0x00030047, + 0x00000191,0x00000000,0x00030047,0x00000193,0x00000000,0x00030047,0x00000194,0x00000000, + 0x00030047,0x00000195,0x00000000,0x00030047,0x00000196,0x00000000,0x00030047,0x00000198, + 0x00000000,0x00030047,0x00000199,0x00000000,0x00030047,0x0000019a,0x00000000,0x00030047, + 0x0000019b,0x00000000,0x00030047,0x0000019c,0x00000000,0x00030047,0x0000019d,0x00000000, + 0x00030047,0x0000019f,0x00000000,0x00030047,0x000001a0,0x00000000,0x00030047,0x000001a1, + 0x00000000,0x00030047,0x000001a3,0x00000000,0x00030047,0x000001a4,0x00000000,0x00030047, + 0x000001a5,0x00000000,0x00030047,0x000001a7,0x00000000,0x00030047,0x000001a8,0x00000000, + 0x00030047,0x000001a9,0x00000000,0x00030047,0x000001aa,0x00000000,0x00030047,0x000001ab, + 0x00000000,0x00030047,0x000001ac,0x00000000,0x00030047,0x000001ae,0x00000000,0x00030047, + 0x000001af,0x00000000,0x00030047,0x000001b1,0x00000000,0x00030047,0x000001b2,0x00000000, + 0x00030047,0x000001b3,0x00000000,0x00030047,0x000001b4,0x00000000,0x00030047,0x000001b5, + 0x00000000,0x00030047,0x000001b7,0x00000000,0x00030047,0x000001b8,0x00000000,0x00030047, + 0x000001b9,0x00000000,0x00030047,0x000001ba,0x00000000,0x00030047,0x000001bb,0x00000000, + 0x00030047,0x000001bc,0x00000000,0x00030047,0x000001be,0x00000000,0x00030047,0x000001bf, + 0x00000000,0x00030047,0x000001c0,0x00000000,0x00030047,0x000001c2,0x00000000,0x00030047, + 0x000001c3,0x00000000,0x00030047,0x000001c4,0x00000000,0x00030047,0x000001c6,0x00000000, + 0x00030047,0x000001c7,0x00000000,0x00030047,0x000001c8,0x00000000,0x00030047,0x000001c9, + 0x00000000,0x00030047,0x000001ca,0x00000000,0x00030047,0x000001cb,0x00000000,0x00030047, + 0x000001cc,0x00000000,0x00030047,0x000001ce,0x00000000,0x00030047,0x000001cf,0x00000000, + 0x00030047,0x000001d1,0x00000000,0x00030047,0x000001d2,0x00000000,0x00030047,0x000001d4, + 0x00000000,0x00030047,0x000001d5,0x00000000,0x00030047,0x000001d6,0x00000000,0x00030047, + 0x000001d7,0x00000000,0x00030047,0x000001d8,0x00000000,0x00030047,0x000001d9,0x00000000, + 0x00030047,0x000001db,0x00000000,0x00030047,0x000001dc,0x00000000,0x00030047,0x000001dd, + 0x00000000,0x00030047,0x000001de,0x00000000,0x00030047,0x000001e0,0x00000000,0x00030047, + 0x000001e1,0x00000000,0x00030047,0x000001e3,0x00000000,0x00030047,0x000001e4,0x00000000, + 0x00030047,0x000001e5,0x00000000,0x00030047,0x000001e6,0x00000000,0x00030047,0x000001e7, + 0x00000000,0x00030047,0x000001e8,0x00000000,0x00030047,0x000001ea,0x00000000,0x00030047, + 0x000001eb,0x00000000,0x00030047,0x000001ed,0x00000000,0x00030047,0x000001ee,0x00000000, + 0x00030047,0x000001ef,0x00000000,0x00030047,0x000001f0,0x00000000,0x00030047,0x000001f1, + 0x00000000,0x00030047,0x000001f3,0x00000000,0x00030047,0x000001f4,0x00000000,0x00030047, + 0x000001f5,0x00000000,0x00030047,0x000001f6,0x00000000,0x00030047,0x000001f7,0x00000000, + 0x00030047,0x000001f8,0x00000000,0x00030047,0x000001fa,0x00000000,0x00030047,0x000001fb, + 0x00000000,0x00030047,0x000001fd,0x00000000,0x00030047,0x000001fe,0x00000000,0x00030047, + 0x000001ff,0x00000000,0x00030047,0x00000200,0x00000000,0x00030047,0x00000201,0x00000000, + 0x00030047,0x00000203,0x00000000,0x00030047,0x00000204,0x00000000,0x00030047,0x00000205, + 0x00000000,0x00030047,0x00000206,0x00000000,0x00030047,0x00000207,0x00000000,0x00030047, + 0x00000208,0x00000000,0x00030047,0x0000020a,0x00000000,0x00030047,0x0000020b,0x00000000, + 0x00030047,0x0000020c,0x00000000,0x00030047,0x0000020d,0x00000000,0x00030047,0x0000020f, + 0x00000000,0x00030047,0x00000210,0x00000000,0x00030047,0x00000212,0x00000000,0x00030047, + 0x00000213,0x00000000,0x00030047,0x00000214,0x00000000,0x00030047,0x00000215,0x00000000, + 0x00030047,0x00000216,0x00000000,0x00030047,0x00000217,0x00000000,0x00030047,0x00000219, + 0x00000000,0x00030047,0x0000021a,0x00000000,0x00030047,0x0000021b,0x00000000,0x00030047, + 0x0000021c,0x00000000,0x00030047,0x0000021e,0x00000000,0x00030047,0x0000021f,0x00000000, + 0x00030047,0x00000221,0x00000000,0x00030047,0x00000222,0x00000000,0x00030047,0x00000223, + 0x00000000,0x00030047,0x00000224,0x00000000,0x00030047,0x00000225,0x00000000,0x00030047, + 0x00000226,0x00000000,0x00030047,0x00000227,0x00000000,0x00030047,0x00000229,0x00000000, + 0x00030047,0x0000022b,0x00000000,0x00030047,0x0000022c,0x00000000,0x00030047,0x0000022d, + 0x00000000,0x00030047,0x0000022f,0x00000000,0x00030047,0x00000231,0x00000000,0x00030047, + 0x00000232,0x00000000,0x00030047,0x00000234,0x00000000,0x00030047,0x00000236,0x00000000, + 0x00030047,0x00000237,0x00000000,0x00030047,0x00000238,0x00000000,0x00030047,0x00000239, + 0x00000000,0x00030047,0x0000023b,0x00000000,0x00030047,0x0000023d,0x00000000,0x00030047, + 0x0000023e,0x00000000,0x00030047,0x00000240,0x00000000,0x00030047,0x00000242,0x00000000, + 0x00030047,0x00000243,0x00000000,0x00030047,0x00000244,0x00000000,0x00030047,0x00000248, + 0x00000000,0x00030047,0x00000249,0x00000000,0x00030047,0x0000024a,0x00000000,0x00030047, + 0x0000024b,0x00000000,0x00030047,0x0000024c,0x00000000,0x00030047,0x0000024d,0x00000000, + 0x00030047,0x0000024e,0x00000000,0x00030047,0x0000024f,0x00000000,0x00030047,0x00000251, + 0x00000000,0x00030047,0x00000252,0x00000000,0x00030047,0x00000253,0x00000000,0x00030047, + 0x00000256,0x00000000,0x00030047,0x00000258,0x00000000,0x00030047,0x00000259,0x00000000, + 0x00030047,0x0000025a,0x00000000,0x00030047,0x0000025b,0x00000000,0x00030047,0x0000025e, + 0x00000000,0x00030047,0x0000025f,0x00000000,0x00030047,0x00000260,0x00000000,0x00030047, + 0x00000261,0x00000000,0x00030047,0x00000264,0x00000000,0x00030047,0x00000265,0x00000000, + 0x00030047,0x00000266,0x00000000,0x00030047,0x00000267,0x00000000,0x00030047,0x0000026b, + 0x00000000,0x00040047,0x0000026b,0x0000001e,0x00000000,0x00030047,0x0000026c,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007, + 0x00040017,0x0000000c,0x00000006,0x00000003,0x00040020,0x0000000d,0x00000007,0x0000000c, + 0x00040017,0x0000000e,0x00000006,0x00000002,0x00070021,0x0000000f,0x0000000e,0x00000007, + 0x00000007,0x00000007,0x0000000d,0x00040017,0x00000016,0x00000006,0x00000004,0x00040020, + 0x00000017,0x00000007,0x00000016,0x00050021,0x00000018,0x0000000e,0x00000017,0x00000017, + 0x0004002b,0x00000006,0x0000001f,0x40800000,0x00040015,0x00000030,0x00000020,0x00000000, + 0x0004002b,0x00000030,0x00000031,0x00000000,0x00040020,0x00000034,0x00000007,0x0000000e, + 0x0004002b,0x00000030,0x0000003a,0x00000001,0x0004002b,0x00000006,0x00000053,0x00000000, + 0x0004002b,0x00000006,0x00000054,0x3f800000,0x0004002b,0x00000006,0x00000056,0x3f333333, + 0x0004002b,0x00000030,0x00000069,0x00000002,0x0004002b,0x00000030,0x0000006e,0x00000003, + 0x0004002b,0x00000006,0x00000085,0x38010182,0x0005001e,0x00000094,0x00000016,0x00000016, + 0x00000006,0x00040020,0x00000095,0x00000009,0x00000094,0x0004003b,0x00000095,0x00000096, + 0x00000009,0x00040015,0x00000097,0x00000020,0x00000001,0x0004002b,0x00000097,0x00000098, + 0x00000001,0x00040020,0x00000099,0x00000009,0x00000016,0x00040020,0x0000009d,0x00000001, + 0x0000000e,0x0004003b,0x0000009d,0x0000009e,0x00000001,0x00090019,0x000000a1,0x00000006, + 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x000000a2, + 0x000000a1,0x00040020,0x000000a3,0x00000000,0x000000a2,0x0004003b,0x000000a3,0x000000a4, + 0x00000000,0x0004002b,0x00000006,0x000000b4,0xbf000000,0x0004002b,0x00000006,0x000000b5, + 0x3f000000,0x0005002c,0x0000000e,0x000000b6,0x000000b4,0x000000b5,0x0004002b,0x00000006, + 0x000000df,0x3d008081,0x00020014,0x000000e0,0x0004002b,0x00000006,0x00000118,0x3e800000, + 0x0004002b,0x00000006,0x0000015c,0x41224505,0x0004002b,0x00000006,0x00000163,0x477fe000, + 0x0004002b,0x00000006,0x00000192,0x40000000,0x0004002b,0x00000097,0x00000245,0x00000002, + 0x00040020,0x00000246,0x00000009,0x00000006,0x0004002b,0x00000006,0x00000254,0xbdb8b8b9, + 0x0004002b,0x00000006,0x00000255,0x3db8b8b9,0x00040020,0x0000026a,0x00000003,0x00000016, + 0x0004003b,0x0000026a,0x0000026b,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000017,0x00000093,0x00000007,0x0004003b, + 0x00000034,0x0000009c,0x00000007,0x0004003b,0x00000017,0x000000a0,0x00000007,0x0004003b, + 0x00000034,0x000000af,0x00000007,0x0004003b,0x00000034,0x000000b8,0x00000007,0x0004003b, + 0x00000034,0x000000bb,0x00000007,0x0004003b,0x00000034,0x000000c0,0x00000007,0x0004003b, + 0x00000017,0x000000c5,0x00000007,0x0004003b,0x00000007,0x000000c9,0x00000007,0x0004003b, + 0x00000017,0x000000ea,0x00000007,0x0004003b,0x00000017,0x000000f2,0x00000007,0x0004003b, + 0x00000007,0x0000010c,0x00000007,0x0004003b,0x00000007,0x0000012b,0x00000007,0x0004003b, + 0x00000007,0x0000015b,0x00000007,0x0004003b,0x00000007,0x0000015f,0x00000007,0x0004003b, + 0x0000000d,0x00000165,0x00000007,0x0004003b,0x00000017,0x00000167,0x00000007,0x0004003b, + 0x00000017,0x00000169,0x00000007,0x0004003b,0x00000034,0x0000016f,0x00000007,0x0004003b, + 0x00000007,0x00000173,0x00000007,0x0004003b,0x00000007,0x00000176,0x00000007,0x0004003b, + 0x00000007,0x00000177,0x00000007,0x0004003b,0x0000000d,0x0000017a,0x00000007,0x0004003b, + 0x00000007,0x00000183,0x00000007,0x0004003b,0x00000007,0x00000184,0x00000007,0x0004003b, + 0x00000007,0x00000185,0x00000007,0x0004003b,0x0000000d,0x00000188,0x00000007,0x0004003b, + 0x00000007,0x00000194,0x00000007,0x0004003b,0x00000007,0x00000195,0x00000007,0x0004003b, + 0x00000007,0x00000196,0x00000007,0x0004003b,0x0000000d,0x00000199,0x00000007,0x0004003b, + 0x00000007,0x000001a1,0x00000007,0x0004003b,0x00000007,0x000001a4,0x00000007,0x0004003b, + 0x00000007,0x000001a5,0x00000007,0x0004003b,0x0000000d,0x000001a8,0x00000007,0x0004003b, + 0x00000007,0x000001b3,0x00000007,0x0004003b,0x00000007,0x000001b4,0x00000007,0x0004003b, + 0x00000007,0x000001b5,0x00000007,0x0004003b,0x0000000d,0x000001b8,0x00000007,0x0004003b, + 0x00000007,0x000001c0,0x00000007,0x0004003b,0x00000007,0x000001c3,0x00000007,0x0004003b, + 0x00000007,0x000001c4,0x00000007,0x0004003b,0x0000000d,0x000001c7,0x00000007,0x0004003b, + 0x00000007,0x000001cc,0x00000007,0x0004003b,0x00000007,0x000001cf,0x00000007,0x0004003b, + 0x00000007,0x000001d2,0x00000007,0x0004003b,0x0000000d,0x000001d5,0x00000007,0x0004003b, + 0x00000007,0x000001dd,0x00000007,0x0004003b,0x00000007,0x000001de,0x00000007,0x0004003b, + 0x00000007,0x000001e1,0x00000007,0x0004003b,0x0000000d,0x000001e4,0x00000007,0x0004003b, + 0x00000007,0x000001ef,0x00000007,0x0004003b,0x00000007,0x000001f0,0x00000007,0x0004003b, + 0x00000007,0x000001f1,0x00000007,0x0004003b,0x0000000d,0x000001f4,0x00000007,0x0004003b, + 0x00000007,0x000001ff,0x00000007,0x0004003b,0x00000007,0x00000200,0x00000007,0x0004003b, + 0x00000007,0x00000201,0x00000007,0x0004003b,0x0000000d,0x00000204,0x00000007,0x0004003b, + 0x00000007,0x0000020c,0x00000007,0x0004003b,0x00000007,0x0000020d,0x00000007,0x0004003b, + 0x00000007,0x00000210,0x00000007,0x0004003b,0x0000000d,0x00000213,0x00000007,0x0004003b, + 0x00000007,0x0000021b,0x00000007,0x0004003b,0x00000007,0x0000021c,0x00000007,0x0004003b, + 0x00000007,0x0000021f,0x00000007,0x0004003b,0x0000000d,0x00000222,0x00000007,0x0004003b, + 0x00000007,0x00000227,0x00000007,0x0004003b,0x00000007,0x0000022d,0x00000007,0x0004003b, + 0x00000007,0x00000239,0x00000007,0x0004003b,0x00000007,0x0000024e,0x00000007,0x00050041, + 0x00000099,0x0000009a,0x00000096,0x00000098,0x0004003d,0x00000016,0x0000009b,0x0000009a, + 0x0003003e,0x00000093,0x0000009b,0x0004003d,0x0000000e,0x0000009f,0x0000009e,0x0003003e, + 0x0000009c,0x0000009f,0x0004003d,0x000000a2,0x000000a5,0x000000a4,0x0004003d,0x0000000e, + 0x000000a6,0x0000009c,0x00070058,0x00000016,0x000000a7,0x000000a5,0x000000a6,0x00000002, + 0x00000053,0x0008004f,0x0000000c,0x000000a8,0x000000a7,0x000000a7,0x00000000,0x00000001, + 0x00000002,0x00050041,0x00000007,0x000000a9,0x000000a0,0x00000031,0x00050051,0x00000006, + 0x000000aa,0x000000a8,0x00000000,0x0003003e,0x000000a9,0x000000aa,0x00050041,0x00000007, + 0x000000ab,0x000000a0,0x0000003a,0x00050051,0x00000006,0x000000ac,0x000000a8,0x00000001, + 0x0003003e,0x000000ab,0x000000ac,0x00050041,0x00000007,0x000000ad,0x000000a0,0x00000069, + 0x00050051,0x00000006,0x000000ae,0x000000a8,0x00000002,0x0003003e,0x000000ad,0x000000ae, + 0x0004003d,0x0000000e,0x000000b0,0x0000009c,0x0004003d,0x00000016,0x000000b1,0x00000093, + 0x0007004f,0x0000000e,0x000000b2,0x000000b1,0x000000b1,0x00000002,0x00000003,0x00050085, + 0x0000000e,0x000000b3,0x000000b0,0x000000b2,0x00050081,0x0000000e,0x000000b7,0x000000b3, + 0x000000b6,0x0003003e,0x000000af,0x000000b7,0x0004003d,0x0000000e,0x000000b9,0x000000af, + 0x0006000c,0x0000000e,0x000000ba,0x00000001,0x00000008,0x000000b9,0x0003003e,0x000000b8, + 0x000000ba,0x0004003d,0x0000000e,0x000000bc,0x000000b8,0x0004003d,0x00000016,0x000000bd, + 0x00000093,0x0007004f,0x0000000e,0x000000be,0x000000bd,0x000000bd,0x00000000,0x00000001, + 0x00050085,0x0000000e,0x000000bf,0x000000bc,0x000000be,0x0003003e,0x000000bb,0x000000bf, + 0x0004003d,0x0000000e,0x000000c1,0x000000af,0x0004003d,0x0000000e,0x000000c2,0x000000b8, + 0x0004007f,0x0000000e,0x000000c3,0x000000c2,0x00050081,0x0000000e,0x000000c4,0x000000c1, + 0x000000c3,0x0003003e,0x000000c0,0x000000c4,0x0004003d,0x000000a2,0x000000c6,0x000000a4, + 0x0004003d,0x0000000e,0x000000c7,0x000000bb,0x00060060,0x00000016,0x000000c8,0x000000c6, + 0x000000c7,0x00000098,0x0003003e,0x000000c5,0x000000c8,0x00050041,0x00000007,0x000000ca, + 0x000000c5,0x00000069,0x0004003d,0x00000006,0x000000cb,0x000000ca,0x00050041,0x00000007, + 0x000000cc,0x000000c5,0x0000003a,0x0004003d,0x00000006,0x000000cd,0x000000cc,0x00050083, + 0x00000006,0x000000ce,0x000000cb,0x000000cd,0x0006000c,0x00000006,0x000000cf,0x00000001, + 0x00000004,0x000000ce,0x00050041,0x00000007,0x000000d0,0x000000a0,0x0000003a,0x0004003d, + 0x00000006,0x000000d1,0x000000d0,0x00050041,0x00000007,0x000000d2,0x000000c5,0x0000003a, + 0x0004003d,0x00000006,0x000000d3,0x000000d2,0x00050083,0x00000006,0x000000d4,0x000000d1, + 0x000000d3,0x0006000c,0x00000006,0x000000d5,0x00000001,0x00000004,0x000000d4,0x00050081, + 0x00000006,0x000000d6,0x000000cf,0x000000d5,0x00050041,0x00000007,0x000000d7,0x000000a0, + 0x0000003a,0x0004003d,0x00000006,0x000000d8,0x000000d7,0x00050041,0x00000007,0x000000d9, + 0x000000c5,0x00000069,0x0004003d,0x00000006,0x000000da,0x000000d9,0x00050083,0x00000006, + 0x000000db,0x000000d8,0x000000da,0x0006000c,0x00000006,0x000000dc,0x00000001,0x00000004, + 0x000000db,0x00050081,0x00000006,0x000000dd,0x000000d6,0x000000dc,0x0003003e,0x000000c9, + 0x000000dd,0x0004003d,0x00000006,0x000000de,0x000000c9,0x000500ba,0x000000e0,0x000000e1, + 0x000000de,0x000000df,0x000300f7,0x000000e3,0x00000000,0x000400fa,0x000000e1,0x000000e2, + 0x000000e3,0x000200f8,0x000000e2,0x00050041,0x00000007,0x000000e4,0x00000093,0x00000031, + 0x0004003d,0x00000006,0x000000e5,0x000000e4,0x00050041,0x00000007,0x000000e6,0x000000bb, + 0x00000031,0x0004003d,0x00000006,0x000000e7,0x000000e6,0x00050081,0x00000006,0x000000e8, + 0x000000e7,0x000000e5,0x00050041,0x00000007,0x000000e9,0x000000bb,0x00000031,0x0003003e, + 0x000000e9,0x000000e8,0x0004003d,0x000000a2,0x000000eb,0x000000a4,0x0004003d,0x0000000e, + 0x000000ec,0x000000bb,0x00050041,0x00000007,0x000000ed,0x00000093,0x00000031,0x0004003d, + 0x00000006,0x000000ee,0x000000ed,0x00050050,0x0000000e,0x000000ef,0x000000ee,0x00000053, + 0x00050081,0x0000000e,0x000000f0,0x000000ec,0x000000ef,0x00060060,0x00000016,0x000000f1, + 0x000000eb,0x000000f0,0x00000098,0x0003003e,0x000000ea,0x000000f1,0x0004003d,0x000000a2, + 0x000000f3,0x000000a4,0x0004003d,0x0000000e,0x000000f4,0x000000bb,0x00050041,0x00000007, + 0x000000f5,0x00000093,0x0000003a,0x0004003d,0x00000006,0x000000f6,0x000000f5,0x0004007f, + 0x00000006,0x000000f7,0x000000f6,0x00050050,0x0000000e,0x000000f8,0x00000053,0x000000f7, + 0x00050081,0x0000000e,0x000000f9,0x000000f4,0x000000f8,0x00060060,0x00000016,0x000000fa, + 0x000000f3,0x000000f9,0x00000098,0x0007004f,0x0000000e,0x000000fb,0x000000fa,0x000000fa, + 0x00000003,0x00000002,0x00050041,0x00000007,0x000000fc,0x000000f2,0x00000031,0x00050051, + 0x00000006,0x000000fd,0x000000fb,0x00000000,0x0003003e,0x000000fc,0x000000fd,0x00050041, + 0x00000007,0x000000fe,0x000000f2,0x0000003a,0x00050051,0x00000006,0x000000ff,0x000000fb, + 0x00000001,0x0003003e,0x000000fe,0x000000ff,0x0004003d,0x000000a2,0x00000100,0x000000a4, + 0x0004003d,0x0000000e,0x00000101,0x000000bb,0x00050041,0x00000007,0x00000102,0x00000093, + 0x0000003a,0x0004003d,0x00000006,0x00000103,0x00000102,0x00050050,0x0000000e,0x00000104, + 0x00000053,0x00000103,0x00050081,0x0000000e,0x00000105,0x00000101,0x00000104,0x00060060, + 0x00000016,0x00000106,0x00000100,0x00000105,0x00000098,0x0007004f,0x0000000e,0x00000107, + 0x00000106,0x00000106,0x00000001,0x00000000,0x00050041,0x00000007,0x00000108,0x000000f2, + 0x00000069,0x00050051,0x00000006,0x00000109,0x00000107,0x00000000,0x0003003e,0x00000108, + 0x00000109,0x00050041,0x00000007,0x0000010a,0x000000f2,0x0000006e,0x00050051,0x00000006, + 0x0000010b,0x00000107,0x00000001,0x0003003e,0x0000010a,0x0000010b,0x00050041,0x00000007, + 0x0000010d,0x000000c5,0x0000003a,0x0004003d,0x00000006,0x0000010e,0x0000010d,0x00050041, + 0x00000007,0x0000010f,0x000000c5,0x00000069,0x0004003d,0x00000006,0x00000110,0x0000010f, + 0x00050081,0x00000006,0x00000111,0x0000010e,0x00000110,0x00050041,0x00000007,0x00000112, + 0x000000ea,0x00000031,0x0004003d,0x00000006,0x00000113,0x00000112,0x00050081,0x00000006, + 0x00000114,0x00000111,0x00000113,0x00050041,0x00000007,0x00000115,0x000000ea,0x0000006e, + 0x0004003d,0x00000006,0x00000116,0x00000115,0x00050081,0x00000006,0x00000117,0x00000114, + 0x00000116,0x00050085,0x00000006,0x00000119,0x00000117,0x00000118,0x0003003e,0x0000010c, + 0x00000119,0x0004003d,0x00000016,0x0000011a,0x000000c5,0x0004003d,0x00000006,0x0000011b, + 0x0000010c,0x00070050,0x00000016,0x0000011c,0x0000011b,0x0000011b,0x0000011b,0x0000011b, + 0x00050083,0x00000016,0x0000011d,0x0000011a,0x0000011c,0x0003003e,0x000000c5,0x0000011d, + 0x0004003d,0x00000016,0x0000011e,0x000000ea,0x0004003d,0x00000006,0x0000011f,0x0000010c, + 0x00070050,0x00000016,0x00000120,0x0000011f,0x0000011f,0x0000011f,0x0000011f,0x00050083, + 0x00000016,0x00000121,0x0000011e,0x00000120,0x0003003e,0x000000ea,0x00000121,0x0004003d, + 0x00000016,0x00000122,0x000000f2,0x0004003d,0x00000006,0x00000123,0x0000010c,0x00070050, + 0x00000016,0x00000124,0x00000123,0x00000123,0x00000123,0x00000123,0x00050083,0x00000016, + 0x00000125,0x00000122,0x00000124,0x0003003e,0x000000f2,0x00000125,0x00050041,0x00000007, + 0x00000126,0x000000a0,0x0000003a,0x0004003d,0x00000006,0x00000127,0x00000126,0x0004003d, + 0x00000006,0x00000128,0x0000010c,0x00050083,0x00000006,0x00000129,0x00000127,0x00000128, + 0x00050041,0x00000007,0x0000012a,0x000000a0,0x0000006e,0x0003003e,0x0000012a,0x00000129, + 0x00050041,0x00000007,0x0000012c,0x000000c5,0x00000031,0x0004003d,0x00000006,0x0000012d, + 0x0000012c,0x0006000c,0x00000006,0x0000012e,0x00000001,0x00000004,0x0000012d,0x00050041, + 0x00000007,0x0000012f,0x000000c5,0x0000003a,0x0004003d,0x00000006,0x00000130,0x0000012f, + 0x0006000c,0x00000006,0x00000131,0x00000001,0x00000004,0x00000130,0x00050081,0x00000006, + 0x00000132,0x0000012e,0x00000131,0x00050041,0x00000007,0x00000133,0x000000c5,0x00000069, + 0x0004003d,0x00000006,0x00000134,0x00000133,0x0006000c,0x00000006,0x00000135,0x00000001, + 0x00000004,0x00000134,0x00050081,0x00000006,0x00000136,0x00000132,0x00000135,0x00050041, + 0x00000007,0x00000137,0x000000c5,0x0000006e,0x0004003d,0x00000006,0x00000138,0x00000137, + 0x0006000c,0x00000006,0x00000139,0x00000001,0x00000004,0x00000138,0x00050081,0x00000006, + 0x0000013a,0x00000136,0x00000139,0x00050041,0x00000007,0x0000013b,0x000000ea,0x00000031, + 0x0004003d,0x00000006,0x0000013c,0x0000013b,0x0006000c,0x00000006,0x0000013d,0x00000001, + 0x00000004,0x0000013c,0x00050041,0x00000007,0x0000013e,0x000000ea,0x0000003a,0x0004003d, + 0x00000006,0x0000013f,0x0000013e,0x0006000c,0x00000006,0x00000140,0x00000001,0x00000004, + 0x0000013f,0x00050081,0x00000006,0x00000141,0x0000013d,0x00000140,0x00050041,0x00000007, + 0x00000142,0x000000ea,0x00000069,0x0004003d,0x00000006,0x00000143,0x00000142,0x0006000c, + 0x00000006,0x00000144,0x00000001,0x00000004,0x00000143,0x00050081,0x00000006,0x00000145, + 0x00000141,0x00000144,0x00050041,0x00000007,0x00000146,0x000000ea,0x0000006e,0x0004003d, + 0x00000006,0x00000147,0x00000146,0x0006000c,0x00000006,0x00000148,0x00000001,0x00000004, + 0x00000147,0x00050081,0x00000006,0x00000149,0x00000145,0x00000148,0x00050081,0x00000006, + 0x0000014a,0x0000013a,0x00000149,0x00050041,0x00000007,0x0000014b,0x000000f2,0x00000031, + 0x0004003d,0x00000006,0x0000014c,0x0000014b,0x0006000c,0x00000006,0x0000014d,0x00000001, + 0x00000004,0x0000014c,0x00050041,0x00000007,0x0000014e,0x000000f2,0x0000003a,0x0004003d, + 0x00000006,0x0000014f,0x0000014e,0x0006000c,0x00000006,0x00000150,0x00000001,0x00000004, + 0x0000014f,0x00050081,0x00000006,0x00000151,0x0000014d,0x00000150,0x00050041,0x00000007, + 0x00000152,0x000000f2,0x00000069,0x0004003d,0x00000006,0x00000153,0x00000152,0x0006000c, + 0x00000006,0x00000154,0x00000001,0x00000004,0x00000153,0x00050081,0x00000006,0x00000155, + 0x00000151,0x00000154,0x00050041,0x00000007,0x00000156,0x000000f2,0x0000006e,0x0004003d, + 0x00000006,0x00000157,0x00000156,0x0006000c,0x00000006,0x00000158,0x00000001,0x00000004, + 0x00000157,0x00050081,0x00000006,0x00000159,0x00000155,0x00000158,0x00050081,0x00000006, + 0x0000015a,0x0000014a,0x00000159,0x0003003e,0x0000012b,0x0000015a,0x0004003d,0x00000006, + 0x0000015d,0x0000012b,0x00050088,0x00000006,0x0000015e,0x0000015c,0x0000015d,0x0003003e, + 0x0000015b,0x0000015e,0x0004003d,0x00000006,0x00000160,0x0000015b,0x0004003d,0x00000006, + 0x00000161,0x0000015b,0x00050085,0x00000006,0x00000162,0x00000160,0x00000161,0x0007000c, + 0x00000006,0x00000164,0x00000001,0x00000025,0x00000162,0x00000163,0x0003003e,0x0000015f, + 0x00000164,0x0004003d,0x00000006,0x00000166,0x0000015f,0x0004003d,0x00000016,0x00000168, + 0x000000c5,0x0003003e,0x00000167,0x00000168,0x0004003d,0x00000016,0x0000016a,0x000000ea, + 0x0003003e,0x00000169,0x0000016a,0x00060039,0x0000000e,0x0000016b,0x0000001b,0x00000167, + 0x00000169,0x00050051,0x00000006,0x0000016c,0x0000016b,0x00000000,0x00050051,0x00000006, + 0x0000016d,0x0000016b,0x00000001,0x00060050,0x0000000c,0x0000016e,0x00000166,0x0000016c, + 0x0000016d,0x0003003e,0x00000165,0x0000016e,0x00050041,0x00000007,0x00000170,0x000000c0, + 0x0000003a,0x0004003d,0x00000006,0x00000171,0x00000170,0x00050081,0x00000006,0x00000172, + 0x00000171,0x00000054,0x00050041,0x00000007,0x00000174,0x000000c0,0x00000031,0x0004003d, + 0x00000006,0x00000175,0x00000174,0x0003003e,0x00000173,0x00000175,0x0003003e,0x00000176, + 0x00000172,0x00050041,0x00000007,0x00000178,0x000000f2,0x00000031,0x0004003d,0x00000006, + 0x00000179,0x00000178,0x0003003e,0x00000177,0x00000179,0x0004003d,0x0000000c,0x0000017b, + 0x00000165,0x0003003e,0x0000017a,0x0000017b,0x00080039,0x0000000e,0x0000017c,0x00000014, + 0x00000173,0x00000176,0x00000177,0x0000017a,0x0003003e,0x0000016f,0x0000017c,0x00050041, + 0x00000007,0x0000017d,0x000000c0,0x00000031,0x0004003d,0x00000006,0x0000017e,0x0000017d, + 0x00050083,0x00000006,0x0000017f,0x0000017e,0x00000054,0x00050041,0x00000007,0x00000180, + 0x000000c0,0x0000003a,0x0004003d,0x00000006,0x00000181,0x00000180,0x00050081,0x00000006, + 0x00000182,0x00000181,0x00000054,0x0003003e,0x00000183,0x0000017f,0x0003003e,0x00000184, + 0x00000182,0x00050041,0x00000007,0x00000186,0x000000f2,0x0000003a,0x0004003d,0x00000006, + 0x00000187,0x00000186,0x0003003e,0x00000185,0x00000187,0x0004003d,0x0000000c,0x00000189, + 0x00000165,0x0003003e,0x00000188,0x00000189,0x00080039,0x0000000e,0x0000018a,0x00000014, + 0x00000183,0x00000184,0x00000185,0x00000188,0x0004003d,0x0000000e,0x0000018b,0x0000016f, + 0x00050081,0x0000000e,0x0000018c,0x0000018b,0x0000018a,0x0003003e,0x0000016f,0x0000018c, + 0x00050041,0x00000007,0x0000018d,0x000000c0,0x00000031,0x0004003d,0x00000006,0x0000018e, + 0x0000018d,0x00050083,0x00000006,0x0000018f,0x0000018e,0x00000054,0x00050041,0x00000007, + 0x00000190,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x00000191,0x00000190,0x00050083, + 0x00000006,0x00000193,0x00000191,0x00000192,0x0003003e,0x00000194,0x0000018f,0x0003003e, + 0x00000195,0x00000193,0x00050041,0x00000007,0x00000197,0x000000f2,0x00000069,0x0004003d, + 0x00000006,0x00000198,0x00000197,0x0003003e,0x00000196,0x00000198,0x0004003d,0x0000000c, + 0x0000019a,0x00000165,0x0003003e,0x00000199,0x0000019a,0x00080039,0x0000000e,0x0000019b, + 0x00000014,0x00000194,0x00000195,0x00000196,0x00000199,0x0004003d,0x0000000e,0x0000019c, + 0x0000016f,0x00050081,0x0000000e,0x0000019d,0x0000019c,0x0000019b,0x0003003e,0x0000016f, + 0x0000019d,0x00050041,0x00000007,0x0000019e,0x000000c0,0x0000003a,0x0004003d,0x00000006, + 0x0000019f,0x0000019e,0x00050083,0x00000006,0x000001a0,0x0000019f,0x00000192,0x00050041, + 0x00000007,0x000001a2,0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001a3,0x000001a2, + 0x0003003e,0x000001a1,0x000001a3,0x0003003e,0x000001a4,0x000001a0,0x00050041,0x00000007, + 0x000001a6,0x000000f2,0x0000006e,0x0004003d,0x00000006,0x000001a7,0x000001a6,0x0003003e, + 0x000001a5,0x000001a7,0x0004003d,0x0000000c,0x000001a9,0x00000165,0x0003003e,0x000001a8, + 0x000001a9,0x00080039,0x0000000e,0x000001aa,0x00000014,0x000001a1,0x000001a4,0x000001a5, + 0x000001a8,0x0004003d,0x0000000e,0x000001ab,0x0000016f,0x00050081,0x0000000e,0x000001ac, + 0x000001ab,0x000001aa,0x0003003e,0x0000016f,0x000001ac,0x00050041,0x00000007,0x000001ad, + 0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001ae,0x000001ad,0x00050081,0x00000006, + 0x000001af,0x000001ae,0x00000054,0x00050041,0x00000007,0x000001b0,0x000000c0,0x0000003a, + 0x0004003d,0x00000006,0x000001b1,0x000001b0,0x00050083,0x00000006,0x000001b2,0x000001b1, + 0x00000054,0x0003003e,0x000001b3,0x000001af,0x0003003e,0x000001b4,0x000001b2,0x00050041, + 0x00000007,0x000001b6,0x000000c5,0x00000031,0x0004003d,0x00000006,0x000001b7,0x000001b6, + 0x0003003e,0x000001b5,0x000001b7,0x0004003d,0x0000000c,0x000001b9,0x00000165,0x0003003e, + 0x000001b8,0x000001b9,0x00080039,0x0000000e,0x000001ba,0x00000014,0x000001b3,0x000001b4, + 0x000001b5,0x000001b8,0x0004003d,0x0000000e,0x000001bb,0x0000016f,0x00050081,0x0000000e, + 0x000001bc,0x000001bb,0x000001ba,0x0003003e,0x0000016f,0x000001bc,0x00050041,0x00000007, + 0x000001bd,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x000001be,0x000001bd,0x00050083, + 0x00000006,0x000001bf,0x000001be,0x00000054,0x00050041,0x00000007,0x000001c1,0x000000c0, + 0x00000031,0x0004003d,0x00000006,0x000001c2,0x000001c1,0x0003003e,0x000001c0,0x000001c2, + 0x0003003e,0x000001c3,0x000001bf,0x00050041,0x00000007,0x000001c5,0x000000c5,0x0000003a, + 0x0004003d,0x00000006,0x000001c6,0x000001c5,0x0003003e,0x000001c4,0x000001c6,0x0004003d, + 0x0000000c,0x000001c8,0x00000165,0x0003003e,0x000001c7,0x000001c8,0x00080039,0x0000000e, + 0x000001c9,0x00000014,0x000001c0,0x000001c3,0x000001c4,0x000001c7,0x0004003d,0x0000000e, + 0x000001ca,0x0000016f,0x00050081,0x0000000e,0x000001cb,0x000001ca,0x000001c9,0x0003003e, + 0x0000016f,0x000001cb,0x00050041,0x00000007,0x000001cd,0x000000c0,0x00000031,0x0004003d, + 0x00000006,0x000001ce,0x000001cd,0x0003003e,0x000001cc,0x000001ce,0x00050041,0x00000007, + 0x000001d0,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x000001d1,0x000001d0,0x0003003e, + 0x000001cf,0x000001d1,0x00050041,0x00000007,0x000001d3,0x000000c5,0x00000069,0x0004003d, + 0x00000006,0x000001d4,0x000001d3,0x0003003e,0x000001d2,0x000001d4,0x0004003d,0x0000000c, + 0x000001d6,0x00000165,0x0003003e,0x000001d5,0x000001d6,0x00080039,0x0000000e,0x000001d7, + 0x00000014,0x000001cc,0x000001cf,0x000001d2,0x000001d5,0x0004003d,0x0000000e,0x000001d8, + 0x0000016f,0x00050081,0x0000000e,0x000001d9,0x000001d8,0x000001d7,0x0003003e,0x0000016f, + 0x000001d9,0x00050041,0x00000007,0x000001da,0x000000c0,0x00000031,0x0004003d,0x00000006, + 0x000001db,0x000001da,0x00050081,0x00000006,0x000001dc,0x000001db,0x00000054,0x0003003e, + 0x000001dd,0x000001dc,0x00050041,0x00000007,0x000001df,0x000000c0,0x0000003a,0x0004003d, + 0x00000006,0x000001e0,0x000001df,0x0003003e,0x000001de,0x000001e0,0x00050041,0x00000007, + 0x000001e2,0x000000c5,0x0000006e,0x0004003d,0x00000006,0x000001e3,0x000001e2,0x0003003e, + 0x000001e1,0x000001e3,0x0004003d,0x0000000c,0x000001e5,0x00000165,0x0003003e,0x000001e4, + 0x000001e5,0x00080039,0x0000000e,0x000001e6,0x00000014,0x000001dd,0x000001de,0x000001e1, + 0x000001e4,0x0004003d,0x0000000e,0x000001e7,0x0000016f,0x00050081,0x0000000e,0x000001e8, + 0x000001e7,0x000001e6,0x0003003e,0x0000016f,0x000001e8,0x00050041,0x00000007,0x000001e9, + 0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001ea,0x000001e9,0x00050083,0x00000006, + 0x000001eb,0x000001ea,0x00000054,0x00050041,0x00000007,0x000001ec,0x000000c0,0x0000003a, + 0x0004003d,0x00000006,0x000001ed,0x000001ec,0x00050083,0x00000006,0x000001ee,0x000001ed, + 0x00000054,0x0003003e,0x000001ef,0x000001eb,0x0003003e,0x000001f0,0x000001ee,0x00050041, + 0x00000007,0x000001f2,0x000000ea,0x00000031,0x0004003d,0x00000006,0x000001f3,0x000001f2, + 0x0003003e,0x000001f1,0x000001f3,0x0004003d,0x0000000c,0x000001f5,0x00000165,0x0003003e, + 0x000001f4,0x000001f5,0x00080039,0x0000000e,0x000001f6,0x00000014,0x000001ef,0x000001f0, + 0x000001f1,0x000001f4,0x0004003d,0x0000000e,0x000001f7,0x0000016f,0x00050081,0x0000000e, + 0x000001f8,0x000001f7,0x000001f6,0x0003003e,0x0000016f,0x000001f8,0x00050041,0x00000007, + 0x000001f9,0x000000c0,0x00000031,0x0004003d,0x00000006,0x000001fa,0x000001f9,0x00050083, + 0x00000006,0x000001fb,0x000001fa,0x00000192,0x00050041,0x00000007,0x000001fc,0x000000c0, + 0x0000003a,0x0004003d,0x00000006,0x000001fd,0x000001fc,0x00050083,0x00000006,0x000001fe, + 0x000001fd,0x00000054,0x0003003e,0x000001ff,0x000001fb,0x0003003e,0x00000200,0x000001fe, + 0x00050041,0x00000007,0x00000202,0x000000ea,0x0000003a,0x0004003d,0x00000006,0x00000203, + 0x00000202,0x0003003e,0x00000201,0x00000203,0x0004003d,0x0000000c,0x00000205,0x00000165, + 0x0003003e,0x00000204,0x00000205,0x00080039,0x0000000e,0x00000206,0x00000014,0x000001ff, + 0x00000200,0x00000201,0x00000204,0x0004003d,0x0000000e,0x00000207,0x0000016f,0x00050081, + 0x0000000e,0x00000208,0x00000207,0x00000206,0x0003003e,0x0000016f,0x00000208,0x00050041, + 0x00000007,0x00000209,0x000000c0,0x00000031,0x0004003d,0x00000006,0x0000020a,0x00000209, + 0x00050083,0x00000006,0x0000020b,0x0000020a,0x00000192,0x0003003e,0x0000020c,0x0000020b, + 0x00050041,0x00000007,0x0000020e,0x000000c0,0x0000003a,0x0004003d,0x00000006,0x0000020f, + 0x0000020e,0x0003003e,0x0000020d,0x0000020f,0x00050041,0x00000007,0x00000211,0x000000ea, + 0x00000069,0x0004003d,0x00000006,0x00000212,0x00000211,0x0003003e,0x00000210,0x00000212, + 0x0004003d,0x0000000c,0x00000214,0x00000165,0x0003003e,0x00000213,0x00000214,0x00080039, + 0x0000000e,0x00000215,0x00000014,0x0000020c,0x0000020d,0x00000210,0x00000213,0x0004003d, + 0x0000000e,0x00000216,0x0000016f,0x00050081,0x0000000e,0x00000217,0x00000216,0x00000215, + 0x0003003e,0x0000016f,0x00000217,0x00050041,0x00000007,0x00000218,0x000000c0,0x00000031, + 0x0004003d,0x00000006,0x00000219,0x00000218,0x00050083,0x00000006,0x0000021a,0x00000219, + 0x00000054,0x0003003e,0x0000021b,0x0000021a,0x00050041,0x00000007,0x0000021d,0x000000c0, + 0x0000003a,0x0004003d,0x00000006,0x0000021e,0x0000021d,0x0003003e,0x0000021c,0x0000021e, + 0x00050041,0x00000007,0x00000220,0x000000ea,0x0000006e,0x0004003d,0x00000006,0x00000221, + 0x00000220,0x0003003e,0x0000021f,0x00000221,0x0004003d,0x0000000c,0x00000223,0x00000165, + 0x0003003e,0x00000222,0x00000223,0x00080039,0x0000000e,0x00000224,0x00000014,0x0000021b, + 0x0000021c,0x0000021f,0x00000222,0x0004003d,0x0000000e,0x00000225,0x0000016f,0x00050081, + 0x0000000e,0x00000226,0x00000225,0x00000224,0x0003003e,0x0000016f,0x00000226,0x00050041, + 0x00000007,0x00000228,0x0000016f,0x0000003a,0x0004003d,0x00000006,0x00000229,0x00000228, + 0x00050041,0x00000007,0x0000022a,0x0000016f,0x00000031,0x0004003d,0x00000006,0x0000022b, + 0x0000022a,0x00050088,0x00000006,0x0000022c,0x00000229,0x0000022b,0x0003003e,0x00000227, + 0x0000022c,0x00050041,0x00000007,0x0000022e,0x000000c5,0x0000003a,0x0004003d,0x00000006, + 0x0000022f,0x0000022e,0x00050041,0x00000007,0x00000230,0x000000c5,0x00000069,0x0004003d, + 0x00000006,0x00000231,0x00000230,0x0007000c,0x00000006,0x00000232,0x00000001,0x00000028, + 0x0000022f,0x00000231,0x00050041,0x00000007,0x00000233,0x000000ea,0x00000031,0x0004003d, + 0x00000006,0x00000234,0x00000233,0x00050041,0x00000007,0x00000235,0x000000ea,0x0000006e, + 0x0004003d,0x00000006,0x00000236,0x00000235,0x0007000c,0x00000006,0x00000237,0x00000001, + 0x00000028,0x00000234,0x00000236,0x0007000c,0x00000006,0x00000238,0x00000001,0x00000028, + 0x00000232,0x00000237,0x0003003e,0x0000022d,0x00000238,0x00050041,0x00000007,0x0000023a, + 0x000000c5,0x0000003a,0x0004003d,0x00000006,0x0000023b,0x0000023a,0x00050041,0x00000007, + 0x0000023c,0x000000c5,0x00000069,0x0004003d,0x00000006,0x0000023d,0x0000023c,0x0007000c, + 0x00000006,0x0000023e,0x00000001,0x00000025,0x0000023b,0x0000023d,0x00050041,0x00000007, + 0x0000023f,0x000000ea,0x00000031,0x0004003d,0x00000006,0x00000240,0x0000023f,0x00050041, + 0x00000007,0x00000241,0x000000ea,0x0000006e,0x0004003d,0x00000006,0x00000242,0x00000241, + 0x0007000c,0x00000006,0x00000243,0x00000001,0x00000025,0x00000240,0x00000242,0x0007000c, + 0x00000006,0x00000244,0x00000001,0x00000025,0x0000023e,0x00000243,0x0003003e,0x00000239, + 0x00000244,0x00050041,0x00000246,0x00000247,0x00000096,0x00000245,0x0004003d,0x00000006, + 0x00000248,0x00000247,0x0004003d,0x00000006,0x00000249,0x00000227,0x00050085,0x00000006, + 0x0000024a,0x00000248,0x00000249,0x0004003d,0x00000006,0x0000024b,0x00000239,0x0004003d, + 0x00000006,0x0000024c,0x0000022d,0x0008000c,0x00000006,0x0000024d,0x00000001,0x0000002b, + 0x0000024a,0x0000024b,0x0000024c,0x0003003e,0x00000227,0x0000024d,0x0004003d,0x00000006, + 0x0000024f,0x00000227,0x00050041,0x00000007,0x00000250,0x000000a0,0x0000006e,0x0004003d, + 0x00000006,0x00000251,0x00000250,0x00050083,0x00000006,0x00000252,0x0000024f,0x00000251, + 0x0003003e,0x0000024e,0x00000252,0x0004003d,0x00000006,0x00000253,0x0000024e,0x0008000c, + 0x00000006,0x00000256,0x00000001,0x0000002b,0x00000253,0x00000254,0x00000255,0x0003003e, + 0x0000024e,0x00000256,0x00050041,0x00000007,0x00000257,0x000000a0,0x00000031,0x0004003d, + 0x00000006,0x00000258,0x00000257,0x0004003d,0x00000006,0x00000259,0x0000024e,0x00050081, + 0x00000006,0x0000025a,0x00000258,0x00000259,0x0008000c,0x00000006,0x0000025b,0x00000001, + 0x0000002b,0x0000025a,0x00000053,0x00000054,0x00050041,0x00000007,0x0000025c,0x000000a0, + 0x00000031,0x0003003e,0x0000025c,0x0000025b,0x00050041,0x00000007,0x0000025d,0x000000a0, + 0x0000003a,0x0004003d,0x00000006,0x0000025e,0x0000025d,0x0004003d,0x00000006,0x0000025f, + 0x0000024e,0x00050081,0x00000006,0x00000260,0x0000025e,0x0000025f,0x0008000c,0x00000006, + 0x00000261,0x00000001,0x0000002b,0x00000260,0x00000053,0x00000054,0x00050041,0x00000007, + 0x00000262,0x000000a0,0x0000003a,0x0003003e,0x00000262,0x00000261,0x00050041,0x00000007, + 0x00000263,0x000000a0,0x00000069,0x0004003d,0x00000006,0x00000264,0x00000263,0x0004003d, + 0x00000006,0x00000265,0x0000024e,0x00050081,0x00000006,0x00000266,0x00000264,0x00000265, + 0x0008000c,0x00000006,0x00000267,0x00000001,0x0000002b,0x00000266,0x00000053,0x00000054, + 0x00050041,0x00000007,0x00000268,0x000000a0,0x00000069,0x0003003e,0x00000268,0x00000267, + 0x000200f9,0x000000e3,0x000200f8,0x000000e3,0x00050041,0x00000007,0x00000269,0x000000a0, + 0x0000006e,0x0003003e,0x00000269,0x00000054,0x0004003d,0x00000016,0x0000026c,0x000000a0, + 0x0003003e,0x0000026b,0x0000026c,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a, + 0x00000000,0x00000008,0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003b, + 0x00000007,0x0000001d,0x00000007,0x0004003b,0x00000007,0x00000021,0x00000007,0x0004003d, + 0x00000006,0x0000001e,0x00000009,0x00050083,0x00000006,0x00000020,0x0000001e,0x0000001f, + 0x0003003e,0x0000001d,0x00000020,0x0004003d,0x00000006,0x00000022,0x00000009,0x0004003d, + 0x00000006,0x00000023,0x0000001d,0x00050085,0x00000006,0x00000024,0x00000022,0x00000023, + 0x0004003d,0x00000006,0x00000025,0x0000001d,0x00050083,0x00000006,0x00000026,0x00000024, + 0x00000025,0x0003003e,0x00000021,0x00000026,0x0004003d,0x00000006,0x00000027,0x0000001d, + 0x0004003d,0x00000006,0x00000028,0x0000001d,0x00050085,0x00000006,0x00000029,0x00000028, + 0x00000027,0x0003003e,0x0000001d,0x00000029,0x0004003d,0x00000006,0x0000002a,0x00000021, + 0x0004003d,0x00000006,0x0000002b,0x0000001d,0x00050085,0x00000006,0x0000002c,0x0000002a, + 0x0000002b,0x000200fe,0x0000002c,0x00010038,0x00050036,0x0000000e,0x00000014,0x00000000, + 0x0000000f,0x00030037,0x00000007,0x00000010,0x00030037,0x00000007,0x00000011,0x00030037, + 0x00000007,0x00000012,0x00030037,0x0000000d,0x00000013,0x000200f8,0x00000015,0x0004003b, + 0x00000007,0x0000002f,0x00000007,0x0004003b,0x00000034,0x00000035,0x00000007,0x0004003b, + 0x00000007,0x00000038,0x00000007,0x0004003b,0x00000007,0x00000043,0x00000007,0x0004003b, + 0x00000007,0x0000005b,0x00000007,0x0004003b,0x00000007,0x0000005c,0x00000007,0x00050041, + 0x00000007,0x00000032,0x00000013,0x00000031,0x0004003d,0x00000006,0x00000033,0x00000032, + 0x0003003e,0x0000002f,0x00000033,0x0004003d,0x0000000c,0x00000036,0x00000013,0x0007004f, + 0x0000000e,0x00000037,0x00000036,0x00000036,0x00000001,0x00000002,0x0003003e,0x00000035, + 0x00000037,0x0004003d,0x00000006,0x00000039,0x00000010,0x00050041,0x00000007,0x0000003b, + 0x00000035,0x0000003a,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x00050085,0x00000006, + 0x0000003d,0x00000039,0x0000003c,0x0004003d,0x00000006,0x0000003e,0x00000011,0x00050041, + 0x00000007,0x0000003f,0x00000035,0x00000031,0x0004003d,0x00000006,0x00000040,0x0000003f, + 0x00050085,0x00000006,0x00000041,0x0000003e,0x00000040,0x00050081,0x00000006,0x00000042, + 0x0000003d,0x00000041,0x0003003e,0x00000038,0x00000042,0x0004003d,0x00000006,0x00000044, + 0x00000010,0x0004003d,0x00000006,0x00000045,0x00000010,0x00050085,0x00000006,0x00000046, + 0x00000044,0x00000045,0x0004003d,0x00000006,0x00000047,0x00000011,0x0004003d,0x00000006, + 0x00000048,0x00000011,0x00050085,0x00000006,0x00000049,0x00000047,0x00000048,0x00050081, + 0x00000006,0x0000004a,0x00000046,0x00000049,0x0004003d,0x00000006,0x0000004b,0x00000038, + 0x0004003d,0x00000006,0x0000004c,0x00000038,0x00050085,0x00000006,0x0000004d,0x0000004b, + 0x0000004c,0x0004003d,0x00000006,0x0000004e,0x00000012,0x0004003d,0x00000006,0x0000004f, + 0x00000012,0x00050085,0x00000006,0x00000050,0x0000004e,0x0000004f,0x0004003d,0x00000006, + 0x00000051,0x0000002f,0x00050085,0x00000006,0x00000052,0x00000050,0x00000051,0x0008000c, + 0x00000006,0x00000055,0x00000001,0x0000002b,0x00000052,0x00000053,0x00000054,0x00050085, + 0x00000006,0x00000057,0x00000055,0x00000056,0x00050083,0x00000006,0x00000058,0x00000057, + 0x00000054,0x00050085,0x00000006,0x00000059,0x0000004d,0x00000058,0x00050081,0x00000006, + 0x0000005a,0x0000004a,0x00000059,0x0003003e,0x00000043,0x0000005a,0x0004003d,0x00000006, + 0x0000005d,0x00000043,0x0003003e,0x0000005c,0x0000005d,0x00050039,0x00000006,0x0000005e, + 0x0000000a,0x0000005c,0x0003003e,0x0000005b,0x0000005e,0x0004003d,0x00000006,0x0000005f, + 0x0000005b,0x0004003d,0x00000006,0x00000060,0x0000005b,0x0004003d,0x00000006,0x00000061, + 0x00000012,0x00050085,0x00000006,0x00000062,0x00000060,0x00000061,0x00050050,0x0000000e, + 0x00000063,0x0000005f,0x00000062,0x000200fe,0x00000063,0x00010038,0x00050036,0x0000000e, + 0x0000001b,0x00000000,0x00000018,0x00030037,0x00000017,0x00000019,0x00030037,0x00000017, + 0x0000001a,0x000200f8,0x0000001c,0x0004003b,0x00000007,0x00000066,0x00000007,0x0004003b, + 0x00000007,0x0000006d,0x00000007,0x0004003b,0x00000034,0x00000074,0x00000007,0x0004003b, + 0x00000034,0x0000007d,0x00000007,0x0004003b,0x00000007,0x0000007f,0x00000007,0x00050041, + 0x00000007,0x00000067,0x0000001a,0x00000031,0x0004003d,0x00000006,0x00000068,0x00000067, + 0x00050041,0x00000007,0x0000006a,0x00000019,0x00000069,0x0004003d,0x00000006,0x0000006b, + 0x0000006a,0x00050083,0x00000006,0x0000006c,0x00000068,0x0000006b,0x0003003e,0x00000066, + 0x0000006c,0x00050041,0x00000007,0x0000006f,0x0000001a,0x0000006e,0x0004003d,0x00000006, + 0x00000070,0x0000006f,0x00050041,0x00000007,0x00000071,0x00000019,0x0000003a,0x0004003d, + 0x00000006,0x00000072,0x00000071,0x00050083,0x00000006,0x00000073,0x00000070,0x00000072, + 0x0003003e,0x0000006d,0x00000073,0x0004003d,0x00000006,0x00000075,0x00000066,0x0004003d, + 0x00000006,0x00000076,0x0000006d,0x00050081,0x00000006,0x00000077,0x00000075,0x00000076, + 0x00050041,0x00000007,0x00000078,0x00000074,0x00000031,0x0003003e,0x00000078,0x00000077, + 0x0004003d,0x00000006,0x00000079,0x00000066,0x0004003d,0x00000006,0x0000007a,0x0000006d, + 0x00050083,0x00000006,0x0000007b,0x00000079,0x0000007a,0x00050041,0x00000007,0x0000007c, + 0x00000074,0x0000003a,0x0003003e,0x0000007c,0x0000007b,0x0004003d,0x0000000e,0x0000007e, + 0x00000074,0x0003003e,0x0000007d,0x0000007e,0x00050041,0x00000007,0x00000080,0x0000007d, + 0x00000031,0x0004003d,0x00000006,0x00000081,0x00000080,0x00050041,0x00000007,0x00000082, + 0x0000007d,0x00000031,0x0004003d,0x00000006,0x00000083,0x00000082,0x00050085,0x00000006, + 0x00000084,0x00000081,0x00000083,0x00050081,0x00000006,0x00000086,0x00000084,0x00000085, + 0x00050041,0x00000007,0x00000087,0x0000007d,0x0000003a,0x0004003d,0x00000006,0x00000088, + 0x00000087,0x00050041,0x00000007,0x00000089,0x0000007d,0x0000003a,0x0004003d,0x00000006, + 0x0000008a,0x00000089,0x00050085,0x00000006,0x0000008b,0x00000088,0x0000008a,0x00050081, + 0x00000006,0x0000008c,0x00000086,0x0000008b,0x0006000c,0x00000006,0x0000008d,0x00000001, + 0x00000020,0x0000008c,0x0003003e,0x0000007f,0x0000008d,0x0004003d,0x0000000e,0x0000008e, + 0x00000074,0x0004003d,0x00000006,0x0000008f,0x0000007f,0x0005008e,0x0000000e,0x00000090, + 0x0000008e,0x0000008f,0x000200fe,0x00000090,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/smaa.frag b/app/src/main/cpp/shaders/smaa.frag deleted file mode 100644 index 55160fdcff..0000000000 --- a/app/src/main/cpp/shaders/smaa.frag +++ /dev/null @@ -1,100 +0,0 @@ -#version 450 - -layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 outColor; -layout(set = 0, binding = 0) uniform sampler2D InputTexture; -layout(push_constant) uniform Constants { - vec4 ndc; - vec2 resolution; - float extra; - float pad; -} pc; - -float luma(vec3 c) { - return dot(c, vec3(0.2126, 0.7152, 0.0722)); -} - -float edgeVertical(vec2 uv, vec2 px) { - float a = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb); - float b = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb); - return abs(a - b); -} - -float edgeHorizontal(vec2 uv, vec2 px) { - float a = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb); - float b = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb); - return abs(a - b); -} - -void main() { - vec2 px = 1.0 / max(pc.resolution, vec2(1.0)); - vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5); - vec4 center = texture(InputTexture, uv); - - float lc = luma(center.rgb); - float ll = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb); - float lr = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb); - float lu = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb); - float ld = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb); - - float dL = abs(lc - ll); - float dR = abs(lc - lr); - float dU = abs(lc - lu); - float dD = abs(lc - ld); - float localMin = min(lc, min(min(ll, lr), min(lu, ld))); - float localMax = max(lc, max(max(ll, lr), max(lu, ld))); - float localContrast = localMax - localMin; - float threshold = max(0.045, localContrast * 0.08); - - float vertical = max(dL, dR); - float horizontal = max(dU, dD); - float strongest = max(vertical, horizontal); - if (strongest <= threshold) { - outColor = center; - return; - } - - bool verticalEdge = vertical >= horizontal; - vec2 tangent = verticalEdge ? vec2(0.0, px.y) : vec2(px.x, 0.0); - vec2 normal = verticalEdge - ? vec2(dL >= dR ? -1.0 : 1.0, 0.0) - : vec2(0.0, dU >= dD ? -1.0 : 1.0); - - float negativeRun = 0.0; - float positiveRun = 0.0; - for (int i = 1; i <= 6; ++i) { - vec2 offset = tangent * float(i); - float edgeN = verticalEdge ? edgeVertical(uv - offset, px) : edgeHorizontal(uv - offset, px); - float edgeP = verticalEdge ? edgeVertical(uv + offset, px) : edgeHorizontal(uv + offset, px); - if (negativeRun == float(i - 1) && edgeN > threshold * 0.65) negativeRun = float(i); - if (positiveRun == float(i - 1) && edgeP > threshold * 0.65) positiveRun = float(i); - } - - float span = negativeRun + positiveRun; - float edgeConfidence = smoothstep(threshold, threshold * 2.5, strongest); - - float nw = luma(texture(InputTexture, uv + vec2(-px.x, -px.y)).rgb); - float ne = luma(texture(InputTexture, uv + vec2(px.x, -px.y)).rgb); - float sw = luma(texture(InputTexture, uv + vec2(-px.x, px.y)).rgb); - float se = luma(texture(InputTexture, uv + vec2(px.x, px.y)).rgb); - float endpointPattern = clamp(abs(negativeRun - positiveRun) / max(span, 1.0), 0.0, 1.0); - float endpointArea = endpointPattern / (1.0 + span * 0.055); - float crossingA = verticalEdge ? abs(nw - ne) : abs(nw - sw); - float crossingB = verticalEdge ? abs(sw - se) : abs(ne - se); - float crossingContrast = abs(crossingA - crossingB); - float crossingPattern = smoothstep(threshold, threshold * 2.5, crossingContrast); - float areaWeight = 0.38 * crossingPattern * clamp(span / 4.0, 0.0, 1.0); - float diagonalContrast = max(abs(nw - se), abs(ne - sw)); - float cornerFactor = 1.0 - 0.35 * smoothstep(threshold, threshold * 3.0, diagonalContrast); - float baseWeight = areaWeight * endpointArea * edgeConfidence * cornerFactor; - - float diagonalStrength = min(vertical, horizontal); - float diagonalPattern = smoothstep(threshold, threshold * 2.5, diagonalStrength); - float diagonalContinuity = smoothstep(1.0, 3.0, span); - float diagonalFallback = 0.16 * diagonalPattern * edgeConfidence - * cornerFactor * diagonalContinuity * crossingPattern; - - float weight = clamp(max(baseWeight, diagonalFallback), 0.0, 0.42); - vec3 across = texture(InputTexture, uv + normal * px).rgb; - outColor = vec4(mix(center.rgb, across, weight), center.a); -} diff --git a/app/src/main/cpp/shaders/smaa_blend.frag b/app/src/main/cpp/shaders/smaa_blend.frag new file mode 100644 index 0000000000..cd36894637 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_blend.frag @@ -0,0 +1,22 @@ +#version 450 +#extension GL_GOOGLE_include_directive : require + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; +layout(set = 0, binding = 0) uniform sampler2D InputTexture; +layout(set = 1, binding = 0) uniform sampler2D WeightTexture; +layout(push_constant) uniform Constants { + vec4 ndc; + vec4 metrics; // 1/width, 1/height, width, height +} pc; + +#define SMAA_RT_METRICS pc.metrics +#define SMAA_GLSL_4 +#define SMAA_PRESET_HIGH +#include "SMAA.hlsl" + +void main() { + vec4 offset; + SMAANeighborhoodBlendingVS(fragTexCoord, offset); + outColor = SMAANeighborhoodBlendingPS(fragTexCoord, offset, InputTexture, WeightTexture); +} diff --git a/app/src/main/cpp/shaders/smaa_blend_frag.h b/app/src/main/cpp/shaders/smaa_blend_frag.h new file mode 100644 index 0000000000..55ca213931 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_blend_frag.h @@ -0,0 +1,204 @@ + // 1116.6.0 + #pragma once +const uint32_t smaa_blend_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000000f8,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000e8,0x000000f0,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f, + 0x70635f45,0x74735f70,0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004, + 0x475f4c47,0x4c474f4f,0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00080005,0x00000010,0x41414d53,0x63766f4d,0x32627628, + 0x3266763b,0x3266763b,0x0000003b,0x00040005,0x0000000d,0x646e6f63,0x00000000,0x00050005, + 0x0000000e,0x69726176,0x656c6261,0x00000000,0x00040005,0x0000000f,0x756c6176,0x00000065, + 0x00080005,0x0000001a,0x41414d53,0x63766f4d,0x34627628,0x3466763b,0x3466763b,0x0000003b, + 0x00040005,0x00000017,0x646e6f63,0x00000000,0x00050005,0x00000018,0x69726176,0x656c6261, + 0x00000000,0x00040005,0x00000019,0x756c6176,0x00000065,0x000b0005,0x0000001f,0x41414d53, + 0x6769654e,0x726f6268,0x646f6f68,0x6e656c42,0x676e6964,0x76285356,0x763b3266,0x003b3466, + 0x00050005,0x0000001d,0x63786574,0x64726f6f,0x00000000,0x00040005,0x0000001e,0x7366666f, + 0x00007465,0x000d0005,0x00000029,0x41414d53,0x6769654e,0x726f6268,0x646f6f68,0x6e656c42, + 0x676e6964,0x76285350,0x763b3266,0x733b3466,0x733b3132,0x003b3132,0x00050005,0x00000025, + 0x63786574,0x64726f6f,0x00000000,0x00040005,0x00000026,0x7366666f,0x00007465,0x00050005, + 0x00000027,0x6f6c6f63,0x78655472,0x00000000,0x00050005,0x00000028,0x6e656c62,0x78655464, + 0x00000000,0x00040005,0x0000003e,0x61726170,0x0000006d,0x00040005,0x00000041,0x61726170, + 0x0000006d,0x00040005,0x00000044,0x61726170,0x0000006d,0x00040005,0x0000004d,0x61726170, + 0x0000006d,0x00040005,0x00000050,0x61726170,0x0000006d,0x00040005,0x00000053,0x61726170, + 0x0000006d,0x00050005,0x0000005e,0x736e6f43,0x746e6174,0x00000073,0x00040006,0x0000005e, + 0x00000000,0x0063646e,0x00050006,0x0000005e,0x00000001,0x7274656d,0x00736369,0x00030005, + 0x00000060,0x00006370,0x00030005,0x0000006d,0x00000061,0x00040005,0x00000089,0x6f6c6f63, + 0x00000072,0x00030005,0x00000090,0x00000068,0x00060005,0x0000009c,0x6e656c62,0x676e6964, + 0x7366664f,0x00007465,0x00060005,0x000000a2,0x6e656c62,0x676e6964,0x67696557,0x00007468, + 0x00040005,0x000000ac,0x61726170,0x0000006d,0x00040005,0x000000ad,0x61726170,0x0000006d, + 0x00040005,0x000000af,0x61726170,0x0000006d,0x00040005,0x000000b4,0x61726170,0x0000006d, + 0x00040005,0x000000b5,0x61726170,0x0000006d,0x00040005,0x000000b7,0x61726170,0x0000006d, + 0x00060005,0x000000c2,0x6e656c62,0x676e6964,0x726f6f43,0x00000064,0x00040005,0x000000d3, + 0x6f6c6f63,0x00000072,0x00060005,0x000000e8,0x67617266,0x43786554,0x64726f6f,0x00000000, + 0x00040005,0x000000e9,0x7366666f,0x00007465,0x00040005,0x000000ea,0x61726170,0x0000006d, + 0x00040005,0x000000ec,0x61726170,0x0000006d,0x00050005,0x000000f0,0x4374756f,0x726f6c6f, + 0x00000000,0x00060005,0x000000f1,0x75706e49,0x78655474,0x65727574,0x00000000,0x00060005, + 0x000000f2,0x67696557,0x65547468,0x72757478,0x00000065,0x00040005,0x000000f3,0x61726170, + 0x0000006d,0x00040005,0x000000f5,0x61726170,0x0000006d,0x00030047,0x0000005e,0x00000002, + 0x00050048,0x0000005e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000005e,0x00000001, + 0x00000023,0x00000010,0x00040047,0x000000e8,0x0000001e,0x00000000,0x00040047,0x000000f0, + 0x0000001e,0x00000000,0x00040047,0x000000f1,0x00000021,0x00000000,0x00040047,0x000000f1, + 0x00000022,0x00000000,0x00040047,0x000000f2,0x00000021,0x00000000,0x00040047,0x000000f2, + 0x00000022,0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00020014, + 0x00000006,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, + 0x00000007,0x00030016,0x00000009,0x00000020,0x00040017,0x0000000a,0x00000009,0x00000002, + 0x00040020,0x0000000b,0x00000007,0x0000000a,0x00060021,0x0000000c,0x00000002,0x00000008, + 0x0000000b,0x0000000b,0x00040017,0x00000012,0x00000006,0x00000004,0x00040020,0x00000013, + 0x00000007,0x00000012,0x00040017,0x00000014,0x00000009,0x00000004,0x00040020,0x00000015, + 0x00000007,0x00000014,0x00060021,0x00000016,0x00000002,0x00000013,0x00000015,0x00000015, + 0x00050021,0x0000001c,0x00000002,0x0000000b,0x00000015,0x00090019,0x00000021,0x00000009, + 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000022, + 0x00000021,0x00040020,0x00000023,0x00000000,0x00000022,0x00070021,0x00000024,0x00000014, + 0x0000000b,0x00000015,0x00000023,0x00000023,0x00040015,0x0000002b,0x00000020,0x00000000, + 0x0004002b,0x0000002b,0x0000002c,0x00000000,0x00040020,0x0000002d,0x00000007,0x00000006, + 0x00040020,0x00000032,0x00000007,0x00000009,0x0004002b,0x0000002b,0x00000036,0x00000001, + 0x0004002b,0x0000002b,0x00000058,0x00000002,0x0004002b,0x0000002b,0x0000005b,0x00000003, + 0x0004001e,0x0000005e,0x00000014,0x00000014,0x00040020,0x0000005f,0x00000009,0x0000005e, + 0x0004003b,0x0000005f,0x00000060,0x00000009,0x00040015,0x00000061,0x00000020,0x00000001, + 0x0004002b,0x00000061,0x00000062,0x00000001,0x00040020,0x00000063,0x00000009,0x00000014, + 0x0004002b,0x00000009,0x00000067,0x3f800000,0x0004002b,0x00000009,0x00000068,0x00000000, + 0x0007002c,0x00000014,0x00000069,0x00000067,0x00000068,0x00000068,0x00000067,0x0007002c, + 0x00000014,0x00000083,0x00000067,0x00000067,0x00000067,0x00000067,0x0004002b,0x00000009, + 0x00000085,0x3727c5ac,0x0005002c,0x0000000a,0x000000bd,0x00000067,0x00000067,0x00040020, + 0x000000e7,0x00000001,0x0000000a,0x0004003b,0x000000e7,0x000000e8,0x00000001,0x00040020, + 0x000000ef,0x00000003,0x00000014,0x0004003b,0x000000ef,0x000000f0,0x00000003,0x0004003b, + 0x00000023,0x000000f1,0x00000000,0x0004003b,0x00000023,0x000000f2,0x00000000,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000015, + 0x000000e9,0x00000007,0x0004003b,0x0000000b,0x000000ea,0x00000007,0x0004003b,0x00000015, + 0x000000ec,0x00000007,0x0004003b,0x0000000b,0x000000f3,0x00000007,0x0004003b,0x00000015, + 0x000000f5,0x00000007,0x0004003d,0x0000000a,0x000000eb,0x000000e8,0x0003003e,0x000000ea, + 0x000000eb,0x00060039,0x00000002,0x000000ed,0x0000001f,0x000000ea,0x000000ec,0x0004003d, + 0x00000014,0x000000ee,0x000000ec,0x0003003e,0x000000e9,0x000000ee,0x0004003d,0x0000000a, + 0x000000f4,0x000000e8,0x0003003e,0x000000f3,0x000000f4,0x0004003d,0x00000014,0x000000f6, + 0x000000e9,0x0003003e,0x000000f5,0x000000f6,0x00080039,0x00000014,0x000000f7,0x00000029, + 0x000000f3,0x000000f5,0x000000f1,0x000000f2,0x0003003e,0x000000f0,0x000000f7,0x000100fd, + 0x00010038,0x00050036,0x00000002,0x00000010,0x00000000,0x0000000c,0x00030037,0x00000008, + 0x0000000d,0x00030037,0x0000000b,0x0000000e,0x00030037,0x0000000b,0x0000000f,0x000200f8, + 0x00000011,0x00050041,0x0000002d,0x0000002e,0x0000000d,0x0000002c,0x0004003d,0x00000006, + 0x0000002f,0x0000002e,0x000300f7,0x00000031,0x00000000,0x000400fa,0x0000002f,0x00000030, + 0x00000031,0x000200f8,0x00000030,0x00050041,0x00000032,0x00000033,0x0000000f,0x0000002c, + 0x0004003d,0x00000009,0x00000034,0x00000033,0x00050041,0x00000032,0x00000035,0x0000000e, + 0x0000002c,0x0003003e,0x00000035,0x00000034,0x000200f9,0x00000031,0x000200f8,0x00000031, + 0x00050041,0x0000002d,0x00000037,0x0000000d,0x00000036,0x0004003d,0x00000006,0x00000038, + 0x00000037,0x000300f7,0x0000003a,0x00000000,0x000400fa,0x00000038,0x00000039,0x0000003a, + 0x000200f8,0x00000039,0x00050041,0x00000032,0x0000003b,0x0000000f,0x00000036,0x0004003d, + 0x00000009,0x0000003c,0x0000003b,0x00050041,0x00000032,0x0000003d,0x0000000e,0x00000036, + 0x0003003e,0x0000003d,0x0000003c,0x000200f9,0x0000003a,0x000200f8,0x0000003a,0x000100fd, + 0x00010038,0x00050036,0x00000002,0x0000001a,0x00000000,0x00000016,0x00030037,0x00000013, + 0x00000017,0x00030037,0x00000015,0x00000018,0x00030037,0x00000015,0x00000019,0x000200f8, + 0x0000001b,0x0004003b,0x00000008,0x0000003e,0x00000007,0x0004003b,0x0000000b,0x00000041, + 0x00000007,0x0004003b,0x0000000b,0x00000044,0x00000007,0x0004003b,0x00000008,0x0000004d, + 0x00000007,0x0004003b,0x0000000b,0x00000050,0x00000007,0x0004003b,0x0000000b,0x00000053, + 0x00000007,0x0004003d,0x00000012,0x0000003f,0x00000017,0x0007004f,0x00000007,0x00000040, + 0x0000003f,0x0000003f,0x00000000,0x00000001,0x0003003e,0x0000003e,0x00000040,0x0004003d, + 0x00000014,0x00000042,0x00000018,0x0007004f,0x0000000a,0x00000043,0x00000042,0x00000042, + 0x00000000,0x00000001,0x0003003e,0x00000041,0x00000043,0x0004003d,0x00000014,0x00000045, + 0x00000019,0x0007004f,0x0000000a,0x00000046,0x00000045,0x00000045,0x00000000,0x00000001, + 0x0003003e,0x00000044,0x00000046,0x00070039,0x00000002,0x00000047,0x00000010,0x0000003e, + 0x00000041,0x00000044,0x0004003d,0x0000000a,0x00000048,0x00000041,0x00050041,0x00000032, + 0x00000049,0x00000018,0x0000002c,0x00050051,0x00000009,0x0000004a,0x00000048,0x00000000, + 0x0003003e,0x00000049,0x0000004a,0x00050041,0x00000032,0x0000004b,0x00000018,0x00000036, + 0x00050051,0x00000009,0x0000004c,0x00000048,0x00000001,0x0003003e,0x0000004b,0x0000004c, + 0x0004003d,0x00000012,0x0000004e,0x00000017,0x0007004f,0x00000007,0x0000004f,0x0000004e, + 0x0000004e,0x00000002,0x00000003,0x0003003e,0x0000004d,0x0000004f,0x0004003d,0x00000014, + 0x00000051,0x00000018,0x0007004f,0x0000000a,0x00000052,0x00000051,0x00000051,0x00000002, + 0x00000003,0x0003003e,0x00000050,0x00000052,0x0004003d,0x00000014,0x00000054,0x00000019, + 0x0007004f,0x0000000a,0x00000055,0x00000054,0x00000054,0x00000002,0x00000003,0x0003003e, + 0x00000053,0x00000055,0x00070039,0x00000002,0x00000056,0x00000010,0x0000004d,0x00000050, + 0x00000053,0x0004003d,0x0000000a,0x00000057,0x00000050,0x00050041,0x00000032,0x00000059, + 0x00000018,0x00000058,0x00050051,0x00000009,0x0000005a,0x00000057,0x00000000,0x0003003e, + 0x00000059,0x0000005a,0x00050041,0x00000032,0x0000005c,0x00000018,0x0000005b,0x00050051, + 0x00000009,0x0000005d,0x00000057,0x00000001,0x0003003e,0x0000005c,0x0000005d,0x000100fd, + 0x00010038,0x00050036,0x00000002,0x0000001f,0x00000000,0x0000001c,0x00030037,0x0000000b, + 0x0000001d,0x00030037,0x00000015,0x0000001e,0x000200f8,0x00000020,0x00050041,0x00000063, + 0x00000064,0x00000060,0x00000062,0x0004003d,0x00000014,0x00000065,0x00000064,0x0009004f, + 0x00000014,0x00000066,0x00000065,0x00000065,0x00000000,0x00000001,0x00000000,0x00000001, + 0x0004003d,0x0000000a,0x0000006a,0x0000001d,0x0009004f,0x00000014,0x0000006b,0x0000006a, + 0x0000006a,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c,0x00000014,0x0000006c, + 0x00000001,0x00000032,0x00000066,0x00000069,0x0000006b,0x0003003e,0x0000001e,0x0000006c, + 0x000100fd,0x00010038,0x00050036,0x00000014,0x00000029,0x00000000,0x00000024,0x00030037, + 0x0000000b,0x00000025,0x00030037,0x00000015,0x00000026,0x00030037,0x00000023,0x00000027, + 0x00030037,0x00000023,0x00000028,0x000200f8,0x0000002a,0x0004003b,0x00000015,0x0000006d, + 0x00000007,0x0004003b,0x00000015,0x00000089,0x00000007,0x0004003b,0x0000002d,0x00000090, + 0x00000007,0x0004003b,0x00000015,0x0000009c,0x00000007,0x0004003b,0x0000000b,0x000000a2, + 0x00000007,0x0004003b,0x00000013,0x000000ac,0x00000007,0x0004003b,0x00000015,0x000000ad, + 0x00000007,0x0004003b,0x00000015,0x000000af,0x00000007,0x0004003b,0x00000008,0x000000b4, + 0x00000007,0x0004003b,0x0000000b,0x000000b5,0x00000007,0x0004003b,0x0000000b,0x000000b7, + 0x00000007,0x0004003b,0x00000015,0x000000c2,0x00000007,0x0004003b,0x00000015,0x000000d3, + 0x00000007,0x0004003d,0x00000022,0x0000006e,0x00000028,0x0004003d,0x00000014,0x0000006f, + 0x00000026,0x0007004f,0x0000000a,0x00000070,0x0000006f,0x0000006f,0x00000000,0x00000001, + 0x00050057,0x00000014,0x00000071,0x0000006e,0x00000070,0x00050051,0x00000009,0x00000072, + 0x00000071,0x00000003,0x00050041,0x00000032,0x00000073,0x0000006d,0x0000002c,0x0003003e, + 0x00000073,0x00000072,0x0004003d,0x00000022,0x00000074,0x00000028,0x0004003d,0x00000014, + 0x00000075,0x00000026,0x0007004f,0x0000000a,0x00000076,0x00000075,0x00000075,0x00000002, + 0x00000003,0x00050057,0x00000014,0x00000077,0x00000074,0x00000076,0x00050051,0x00000009, + 0x00000078,0x00000077,0x00000001,0x00050041,0x00000032,0x00000079,0x0000006d,0x00000036, + 0x0003003e,0x00000079,0x00000078,0x0004003d,0x00000022,0x0000007a,0x00000028,0x0004003d, + 0x0000000a,0x0000007b,0x00000025,0x00050057,0x00000014,0x0000007c,0x0000007a,0x0000007b, + 0x0007004f,0x0000000a,0x0000007d,0x0000007c,0x0000007c,0x00000000,0x00000002,0x00050041, + 0x00000032,0x0000007e,0x0000006d,0x0000005b,0x00050051,0x00000009,0x0000007f,0x0000007d, + 0x00000000,0x0003003e,0x0000007e,0x0000007f,0x00050041,0x00000032,0x00000080,0x0000006d, + 0x00000058,0x00050051,0x00000009,0x00000081,0x0000007d,0x00000001,0x0003003e,0x00000080, + 0x00000081,0x0004003d,0x00000014,0x00000082,0x0000006d,0x00050094,0x00000009,0x00000084, + 0x00000082,0x00000083,0x000500b8,0x00000006,0x00000086,0x00000084,0x00000085,0x000300f7, + 0x00000088,0x00000000,0x000400fa,0x00000086,0x00000087,0x0000008f,0x000200f8,0x00000087, + 0x0004003d,0x00000022,0x0000008a,0x00000027,0x0004003d,0x0000000a,0x0000008b,0x00000025, + 0x00070058,0x00000014,0x0000008c,0x0000008a,0x0000008b,0x00000002,0x00000068,0x0003003e, + 0x00000089,0x0000008c,0x0004003d,0x00000014,0x0000008d,0x00000089,0x000200fe,0x0000008d, + 0x000200f8,0x0000008f,0x00050041,0x00000032,0x00000091,0x0000006d,0x0000002c,0x0004003d, + 0x00000009,0x00000092,0x00000091,0x00050041,0x00000032,0x00000093,0x0000006d,0x00000058, + 0x0004003d,0x00000009,0x00000094,0x00000093,0x0007000c,0x00000009,0x00000095,0x00000001, + 0x00000028,0x00000092,0x00000094,0x00050041,0x00000032,0x00000096,0x0000006d,0x00000036, + 0x0004003d,0x00000009,0x00000097,0x00000096,0x00050041,0x00000032,0x00000098,0x0000006d, + 0x0000005b,0x0004003d,0x00000009,0x00000099,0x00000098,0x0007000c,0x00000009,0x0000009a, + 0x00000001,0x00000028,0x00000097,0x00000099,0x000500ba,0x00000006,0x0000009b,0x00000095, + 0x0000009a,0x0003003e,0x00000090,0x0000009b,0x00050041,0x00000032,0x0000009d,0x0000006d, + 0x00000036,0x0004003d,0x00000009,0x0000009e,0x0000009d,0x00050041,0x00000032,0x0000009f, + 0x0000006d,0x0000005b,0x0004003d,0x00000009,0x000000a0,0x0000009f,0x00070050,0x00000014, + 0x000000a1,0x00000068,0x0000009e,0x00000068,0x000000a0,0x0003003e,0x0000009c,0x000000a1, + 0x0004003d,0x00000014,0x000000a3,0x0000006d,0x0007004f,0x0000000a,0x000000a4,0x000000a3, + 0x000000a3,0x00000001,0x00000003,0x0003003e,0x000000a2,0x000000a4,0x0004003d,0x00000006, + 0x000000a5,0x00000090,0x00070050,0x00000012,0x000000a6,0x000000a5,0x000000a5,0x000000a5, + 0x000000a5,0x00050041,0x00000032,0x000000a7,0x0000006d,0x0000002c,0x0004003d,0x00000009, + 0x000000a8,0x000000a7,0x00050041,0x00000032,0x000000a9,0x0000006d,0x00000058,0x0004003d, + 0x00000009,0x000000aa,0x000000a9,0x00070050,0x00000014,0x000000ab,0x000000a8,0x00000068, + 0x000000aa,0x00000068,0x0003003e,0x000000ac,0x000000a6,0x0004003d,0x00000014,0x000000ae, + 0x0000009c,0x0003003e,0x000000ad,0x000000ae,0x0003003e,0x000000af,0x000000ab,0x00070039, + 0x00000002,0x000000b0,0x0000001a,0x000000ac,0x000000ad,0x000000af,0x0004003d,0x00000014, + 0x000000b1,0x000000ad,0x0003003e,0x0000009c,0x000000b1,0x0004003d,0x00000006,0x000000b2, + 0x00000090,0x00050050,0x00000007,0x000000b3,0x000000b2,0x000000b2,0x0003003e,0x000000b4, + 0x000000b3,0x0004003d,0x0000000a,0x000000b6,0x000000a2,0x0003003e,0x000000b5,0x000000b6, + 0x0004003d,0x00000014,0x000000b8,0x0000006d,0x0007004f,0x0000000a,0x000000b9,0x000000b8, + 0x000000b8,0x00000000,0x00000002,0x0003003e,0x000000b7,0x000000b9,0x00070039,0x00000002, + 0x000000ba,0x00000010,0x000000b4,0x000000b5,0x000000b7,0x0004003d,0x0000000a,0x000000bb, + 0x000000b5,0x0003003e,0x000000a2,0x000000bb,0x0004003d,0x0000000a,0x000000bc,0x000000a2, + 0x00050094,0x00000009,0x000000be,0x000000bc,0x000000bd,0x0004003d,0x0000000a,0x000000bf, + 0x000000a2,0x00050050,0x0000000a,0x000000c0,0x000000be,0x000000be,0x00050088,0x0000000a, + 0x000000c1,0x000000bf,0x000000c0,0x0003003e,0x000000a2,0x000000c1,0x0004003d,0x00000014, + 0x000000c3,0x0000009c,0x00050041,0x00000063,0x000000c4,0x00000060,0x00000062,0x0004003d, + 0x00000014,0x000000c5,0x000000c4,0x0007004f,0x0000000a,0x000000c6,0x000000c5,0x000000c5, + 0x00000000,0x00000001,0x00050041,0x00000063,0x000000c7,0x00000060,0x00000062,0x0004003d, + 0x00000014,0x000000c8,0x000000c7,0x0007004f,0x0000000a,0x000000c9,0x000000c8,0x000000c8, + 0x00000000,0x00000001,0x0004007f,0x0000000a,0x000000ca,0x000000c9,0x00050051,0x00000009, + 0x000000cb,0x000000c6,0x00000000,0x00050051,0x00000009,0x000000cc,0x000000c6,0x00000001, + 0x00050051,0x00000009,0x000000cd,0x000000ca,0x00000000,0x00050051,0x00000009,0x000000ce, + 0x000000ca,0x00000001,0x00070050,0x00000014,0x000000cf,0x000000cb,0x000000cc,0x000000cd, + 0x000000ce,0x0004003d,0x0000000a,0x000000d0,0x00000025,0x0009004f,0x00000014,0x000000d1, + 0x000000d0,0x000000d0,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c,0x00000014, + 0x000000d2,0x00000001,0x00000032,0x000000c3,0x000000cf,0x000000d1,0x0003003e,0x000000c2, + 0x000000d2,0x00050041,0x00000032,0x000000d4,0x000000a2,0x0000002c,0x0004003d,0x00000009, + 0x000000d5,0x000000d4,0x0004003d,0x00000022,0x000000d6,0x00000027,0x0004003d,0x00000014, + 0x000000d7,0x000000c2,0x0007004f,0x0000000a,0x000000d8,0x000000d7,0x000000d7,0x00000000, + 0x00000001,0x00070058,0x00000014,0x000000d9,0x000000d6,0x000000d8,0x00000002,0x00000068, + 0x0005008e,0x00000014,0x000000da,0x000000d9,0x000000d5,0x0003003e,0x000000d3,0x000000da, + 0x00050041,0x00000032,0x000000db,0x000000a2,0x00000036,0x0004003d,0x00000009,0x000000dc, + 0x000000db,0x0004003d,0x00000022,0x000000dd,0x00000027,0x0004003d,0x00000014,0x000000de, + 0x000000c2,0x0007004f,0x0000000a,0x000000df,0x000000de,0x000000de,0x00000002,0x00000003, + 0x00070058,0x00000014,0x000000e0,0x000000dd,0x000000df,0x00000002,0x00000068,0x0005008e, + 0x00000014,0x000000e1,0x000000e0,0x000000dc,0x0004003d,0x00000014,0x000000e2,0x000000d3, + 0x00050081,0x00000014,0x000000e3,0x000000e2,0x000000e1,0x0003003e,0x000000d3,0x000000e3, + 0x0004003d,0x00000014,0x000000e4,0x000000d3,0x000200fe,0x000000e4,0x000200f8,0x00000088, + 0x000100ff,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/smaa_edge.frag b/app/src/main/cpp/shaders/smaa_edge.frag new file mode 100644 index 0000000000..b4e40a9dad --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_edge.frag @@ -0,0 +1,21 @@ +#version 450 +#extension GL_GOOGLE_include_directive : require + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; +layout(set = 0, binding = 0) uniform sampler2D InputTexture; +layout(push_constant) uniform Constants { + vec4 ndc; + vec4 metrics; // 1/width, 1/height, width, height +} pc; + +#define SMAA_RT_METRICS pc.metrics +#define SMAA_GLSL_4 +#define SMAA_PRESET_HIGH +#include "SMAA.hlsl" + +void main() { + vec4 offset[3]; + SMAAEdgeDetectionVS(fragTexCoord, offset); + outColor = vec4(SMAALumaEdgeDetectionPS(fragTexCoord, offset, InputTexture), 0.0, 0.0); +} diff --git a/app/src/main/cpp/shaders/smaa_edge_frag.h b/app/src/main/cpp/shaders/smaa_edge_frag.h new file mode 100644 index 0000000000..300a5ca064 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_edge_frag.h @@ -0,0 +1,185 @@ + // 1116.6.0 + #pragma once +const uint32_t smaa_edge_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000000eb,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000d9,0x000000e1,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f, + 0x70635f45,0x74735f70,0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004, + 0x475f4c47,0x4c474f4f,0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x000a0005,0x00000011,0x41414d53,0x65676445,0x65746544, + 0x6f697463,0x2853566e,0x3b326676,0x5b346676,0x003b5d33,0x00050005,0x0000000f,0x63786574, + 0x64726f6f,0x00000000,0x00040005,0x00000010,0x7366666f,0x00007465,0x000c0005,0x0000001a, + 0x41414d53,0x616d754c,0x65676445,0x65746544,0x6f697463,0x2853506e,0x3b326676,0x5b346676, + 0x733b5d33,0x003b3132,0x00050005,0x00000017,0x63786574,0x64726f6f,0x00000000,0x00040005, + 0x00000018,0x7366666f,0x00007465,0x00050005,0x00000019,0x6f6c6f63,0x78655472,0x00000000, + 0x00050005,0x0000001e,0x736e6f43,0x746e6174,0x00000073,0x00040006,0x0000001e,0x00000000, + 0x0063646e,0x00050006,0x0000001e,0x00000001,0x7274656d,0x00736369,0x00030005,0x00000020, + 0x00006370,0x00050005,0x00000041,0x65726874,0x6c6f6873,0x00000064,0x00040005,0x00000046, + 0x67696577,0x00737468,0x00030005,0x0000004c,0x0000004c,0x00040005,0x00000053,0x66656c4c, + 0x00000074,0x00040005,0x0000005c,0x706f744c,0x00000000,0x00040005,0x00000065,0x746c6564, + 0x00000061,0x00040005,0x00000073,0x65676465,0x00000073,0x00040005,0x00000080,0x6769724c, + 0x00007468,0x00040005,0x00000089,0x746f624c,0x006d6f74,0x00050005,0x0000009e,0x4478616d, + 0x61746c65,0x00000000,0x00050005,0x000000a4,0x66656c4c,0x66656c74,0x00000074,0x00040005, + 0x000000ad,0x706f744c,0x00706f74,0x00050005,0x000000c6,0x616e6966,0x6c65446c,0x00006174, + 0x00060005,0x000000d9,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x000000da, + 0x7366666f,0x00007465,0x00040005,0x000000db,0x61726170,0x0000006d,0x00040005,0x000000dd, + 0x61726170,0x0000006d,0x00050005,0x000000e1,0x4374756f,0x726f6c6f,0x00000000,0x00060005, + 0x000000e2,0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005,0x000000e3,0x61726170, + 0x0000006d,0x00040005,0x000000e5,0x61726170,0x0000006d,0x00030047,0x0000001e,0x00000002, + 0x00050048,0x0000001e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001, + 0x00000023,0x00000010,0x00040047,0x000000d9,0x0000001e,0x00000000,0x00040047,0x000000e1, + 0x0000001e,0x00000000,0x00040047,0x000000e2,0x00000021,0x00000000,0x00040047,0x000000e2, + 0x00000022,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016, + 0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008, + 0x00000007,0x00000007,0x00040017,0x00000009,0x00000006,0x00000004,0x00040015,0x0000000a, + 0x00000020,0x00000000,0x0004002b,0x0000000a,0x0000000b,0x00000003,0x0004001c,0x0000000c, + 0x00000009,0x0000000b,0x00040020,0x0000000d,0x00000007,0x0000000c,0x00050021,0x0000000e, + 0x00000002,0x00000008,0x0000000d,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020, + 0x00000015,0x00000000,0x00000014,0x00060021,0x00000016,0x00000007,0x00000008,0x0000000d, + 0x00000015,0x00040015,0x0000001c,0x00000020,0x00000001,0x0004002b,0x0000001c,0x0000001d, + 0x00000000,0x0004001e,0x0000001e,0x00000009,0x00000009,0x00040020,0x0000001f,0x00000009, + 0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x0004002b,0x0000001c,0x00000021, + 0x00000001,0x00040020,0x00000022,0x00000009,0x00000009,0x0004002b,0x00000006,0x00000026, + 0xbf800000,0x0004002b,0x00000006,0x00000027,0x00000000,0x0007002c,0x00000009,0x00000028, + 0x00000026,0x00000027,0x00000027,0x00000026,0x00040020,0x0000002c,0x00000007,0x00000009, + 0x0004002b,0x00000006,0x00000031,0x3f800000,0x0007002c,0x00000009,0x00000032,0x00000031, + 0x00000027,0x00000027,0x00000031,0x0004002b,0x0000001c,0x00000037,0x00000002,0x0004002b, + 0x00000006,0x0000003b,0xc0000000,0x0007002c,0x00000009,0x0000003c,0x0000003b,0x00000027, + 0x00000027,0x0000003b,0x0004002b,0x00000006,0x00000042,0x3dcccccd,0x0005002c,0x00000007, + 0x00000043,0x00000042,0x00000042,0x00040017,0x00000044,0x00000006,0x00000003,0x00040020, + 0x00000045,0x00000007,0x00000044,0x0004002b,0x00000006,0x00000047,0x3e59b3d0,0x0004002b, + 0x00000006,0x00000048,0x3f371759,0x0004002b,0x00000006,0x00000049,0x3d93dd98,0x0006002c, + 0x00000044,0x0000004a,0x00000047,0x00000048,0x00000049,0x00040020,0x0000004b,0x00000007, + 0x00000006,0x0004002b,0x0000000a,0x0000006d,0x00000000,0x0004002b,0x0000000a,0x00000070, + 0x00000001,0x0005002c,0x00000007,0x00000079,0x00000031,0x00000031,0x00020014,0x0000007b, + 0x0004002b,0x0000000a,0x00000099,0x00000002,0x0004002b,0x00000006,0x000000cd,0x40000000, + 0x00040020,0x000000d8,0x00000001,0x00000007,0x0004003b,0x000000d8,0x000000d9,0x00000001, + 0x00040020,0x000000e0,0x00000003,0x00000009,0x0004003b,0x000000e0,0x000000e1,0x00000003, + 0x0004003b,0x00000015,0x000000e2,0x00000000,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d,0x000000da,0x00000007,0x0004003b, + 0x00000008,0x000000db,0x00000007,0x0004003b,0x0000000d,0x000000dd,0x00000007,0x0004003b, + 0x00000008,0x000000e3,0x00000007,0x0004003b,0x0000000d,0x000000e5,0x00000007,0x0004003d, + 0x00000007,0x000000dc,0x000000d9,0x0003003e,0x000000db,0x000000dc,0x00060039,0x00000002, + 0x000000de,0x00000011,0x000000db,0x000000dd,0x0004003d,0x0000000c,0x000000df,0x000000dd, + 0x0003003e,0x000000da,0x000000df,0x0004003d,0x00000007,0x000000e4,0x000000d9,0x0003003e, + 0x000000e3,0x000000e4,0x0004003d,0x0000000c,0x000000e6,0x000000da,0x0003003e,0x000000e5, + 0x000000e6,0x00070039,0x00000007,0x000000e7,0x0000001a,0x000000e3,0x000000e5,0x000000e2, + 0x00050051,0x00000006,0x000000e8,0x000000e7,0x00000000,0x00050051,0x00000006,0x000000e9, + 0x000000e7,0x00000001,0x00070050,0x00000009,0x000000ea,0x000000e8,0x000000e9,0x00000027, + 0x00000027,0x0003003e,0x000000e1,0x000000ea,0x000100fd,0x00010038,0x00050036,0x00000002, + 0x00000011,0x00000000,0x0000000e,0x00030037,0x00000008,0x0000000f,0x00030037,0x0000000d, + 0x00000010,0x000200f8,0x00000012,0x00050041,0x00000022,0x00000023,0x00000020,0x00000021, + 0x0004003d,0x00000009,0x00000024,0x00000023,0x0009004f,0x00000009,0x00000025,0x00000024, + 0x00000024,0x00000000,0x00000001,0x00000000,0x00000001,0x0004003d,0x00000007,0x00000029, + 0x0000000f,0x0009004f,0x00000009,0x0000002a,0x00000029,0x00000029,0x00000000,0x00000001, + 0x00000000,0x00000001,0x0008000c,0x00000009,0x0000002b,0x00000001,0x00000032,0x00000025, + 0x00000028,0x0000002a,0x00050041,0x0000002c,0x0000002d,0x00000010,0x0000001d,0x0003003e, + 0x0000002d,0x0000002b,0x00050041,0x00000022,0x0000002e,0x00000020,0x00000021,0x0004003d, + 0x00000009,0x0000002f,0x0000002e,0x0009004f,0x00000009,0x00000030,0x0000002f,0x0000002f, + 0x00000000,0x00000001,0x00000000,0x00000001,0x0004003d,0x00000007,0x00000033,0x0000000f, + 0x0009004f,0x00000009,0x00000034,0x00000033,0x00000033,0x00000000,0x00000001,0x00000000, + 0x00000001,0x0008000c,0x00000009,0x00000035,0x00000001,0x00000032,0x00000030,0x00000032, + 0x00000034,0x00050041,0x0000002c,0x00000036,0x00000010,0x00000021,0x0003003e,0x00000036, + 0x00000035,0x00050041,0x00000022,0x00000038,0x00000020,0x00000021,0x0004003d,0x00000009, + 0x00000039,0x00000038,0x0009004f,0x00000009,0x0000003a,0x00000039,0x00000039,0x00000000, + 0x00000001,0x00000000,0x00000001,0x0004003d,0x00000007,0x0000003d,0x0000000f,0x0009004f, + 0x00000009,0x0000003e,0x0000003d,0x0000003d,0x00000000,0x00000001,0x00000000,0x00000001, + 0x0008000c,0x00000009,0x0000003f,0x00000001,0x00000032,0x0000003a,0x0000003c,0x0000003e, + 0x00050041,0x0000002c,0x00000040,0x00000010,0x00000037,0x0003003e,0x00000040,0x0000003f, + 0x000100fd,0x00010038,0x00050036,0x00000007,0x0000001a,0x00000000,0x00000016,0x00030037, + 0x00000008,0x00000017,0x00030037,0x0000000d,0x00000018,0x00030037,0x00000015,0x00000019, + 0x000200f8,0x0000001b,0x0004003b,0x00000008,0x00000041,0x00000007,0x0004003b,0x00000045, + 0x00000046,0x00000007,0x0004003b,0x0000004b,0x0000004c,0x00000007,0x0004003b,0x0000004b, + 0x00000053,0x00000007,0x0004003b,0x0000004b,0x0000005c,0x00000007,0x0004003b,0x0000002c, + 0x00000065,0x00000007,0x0004003b,0x00000008,0x00000073,0x00000007,0x0004003b,0x0000004b, + 0x00000080,0x00000007,0x0004003b,0x0000004b,0x00000089,0x00000007,0x0004003b,0x00000008, + 0x0000009e,0x00000007,0x0004003b,0x0000004b,0x000000a4,0x00000007,0x0004003b,0x0000004b, + 0x000000ad,0x00000007,0x0004003b,0x0000004b,0x000000c6,0x00000007,0x0003003e,0x00000041, + 0x00000043,0x0003003e,0x00000046,0x0000004a,0x0004003d,0x00000014,0x0000004d,0x00000019, + 0x0004003d,0x00000007,0x0000004e,0x00000017,0x00050057,0x00000009,0x0000004f,0x0000004d, + 0x0000004e,0x0008004f,0x00000044,0x00000050,0x0000004f,0x0000004f,0x00000000,0x00000001, + 0x00000002,0x0004003d,0x00000044,0x00000051,0x00000046,0x00050094,0x00000006,0x00000052, + 0x00000050,0x00000051,0x0003003e,0x0000004c,0x00000052,0x0004003d,0x00000014,0x00000054, + 0x00000019,0x00050041,0x0000002c,0x00000055,0x00000018,0x0000001d,0x0004003d,0x00000009, + 0x00000056,0x00000055,0x0007004f,0x00000007,0x00000057,0x00000056,0x00000056,0x00000000, + 0x00000001,0x00050057,0x00000009,0x00000058,0x00000054,0x00000057,0x0008004f,0x00000044, + 0x00000059,0x00000058,0x00000058,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044, + 0x0000005a,0x00000046,0x00050094,0x00000006,0x0000005b,0x00000059,0x0000005a,0x0003003e, + 0x00000053,0x0000005b,0x0004003d,0x00000014,0x0000005d,0x00000019,0x00050041,0x0000002c, + 0x0000005e,0x00000018,0x0000001d,0x0004003d,0x00000009,0x0000005f,0x0000005e,0x0007004f, + 0x00000007,0x00000060,0x0000005f,0x0000005f,0x00000002,0x00000003,0x00050057,0x00000009, + 0x00000061,0x0000005d,0x00000060,0x0008004f,0x00000044,0x00000062,0x00000061,0x00000061, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,0x00000063,0x00000046,0x00050094, + 0x00000006,0x00000064,0x00000062,0x00000063,0x0003003e,0x0000005c,0x00000064,0x0004003d, + 0x00000006,0x00000066,0x0000004c,0x0004003d,0x00000006,0x00000067,0x00000053,0x0004003d, + 0x00000006,0x00000068,0x0000005c,0x00050050,0x00000007,0x00000069,0x00000067,0x00000068, + 0x00050050,0x00000007,0x0000006a,0x00000066,0x00000066,0x00050083,0x00000007,0x0000006b, + 0x0000006a,0x00000069,0x0006000c,0x00000007,0x0000006c,0x00000001,0x00000004,0x0000006b, + 0x00050041,0x0000004b,0x0000006e,0x00000065,0x0000006d,0x00050051,0x00000006,0x0000006f, + 0x0000006c,0x00000000,0x0003003e,0x0000006e,0x0000006f,0x00050041,0x0000004b,0x00000071, + 0x00000065,0x00000070,0x00050051,0x00000006,0x00000072,0x0000006c,0x00000001,0x0003003e, + 0x00000071,0x00000072,0x0004003d,0x00000007,0x00000074,0x00000041,0x0004003d,0x00000009, + 0x00000075,0x00000065,0x0007004f,0x00000007,0x00000076,0x00000075,0x00000075,0x00000000, + 0x00000001,0x0007000c,0x00000007,0x00000077,0x00000001,0x00000030,0x00000074,0x00000076, + 0x0003003e,0x00000073,0x00000077,0x0004003d,0x00000007,0x00000078,0x00000073,0x00050094, + 0x00000006,0x0000007a,0x00000078,0x00000079,0x000500b4,0x0000007b,0x0000007c,0x0000007a, + 0x00000027,0x000300f7,0x0000007e,0x00000000,0x000400fa,0x0000007c,0x0000007d,0x0000007e, + 0x000200f8,0x0000007d,0x000100fc,0x000200f8,0x0000007e,0x0004003d,0x00000014,0x00000081, + 0x00000019,0x00050041,0x0000002c,0x00000082,0x00000018,0x00000021,0x0004003d,0x00000009, + 0x00000083,0x00000082,0x0007004f,0x00000007,0x00000084,0x00000083,0x00000083,0x00000000, + 0x00000001,0x00050057,0x00000009,0x00000085,0x00000081,0x00000084,0x0008004f,0x00000044, + 0x00000086,0x00000085,0x00000085,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044, + 0x00000087,0x00000046,0x00050094,0x00000006,0x00000088,0x00000086,0x00000087,0x0003003e, + 0x00000080,0x00000088,0x0004003d,0x00000014,0x0000008a,0x00000019,0x00050041,0x0000002c, + 0x0000008b,0x00000018,0x00000021,0x0004003d,0x00000009,0x0000008c,0x0000008b,0x0007004f, + 0x00000007,0x0000008d,0x0000008c,0x0000008c,0x00000002,0x00000003,0x00050057,0x00000009, + 0x0000008e,0x0000008a,0x0000008d,0x0008004f,0x00000044,0x0000008f,0x0000008e,0x0000008e, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,0x00000090,0x00000046,0x00050094, + 0x00000006,0x00000091,0x0000008f,0x00000090,0x0003003e,0x00000089,0x00000091,0x0004003d, + 0x00000006,0x00000092,0x0000004c,0x0004003d,0x00000006,0x00000093,0x00000080,0x0004003d, + 0x00000006,0x00000094,0x00000089,0x00050050,0x00000007,0x00000095,0x00000093,0x00000094, + 0x00050050,0x00000007,0x00000096,0x00000092,0x00000092,0x00050083,0x00000007,0x00000097, + 0x00000096,0x00000095,0x0006000c,0x00000007,0x00000098,0x00000001,0x00000004,0x00000097, + 0x00050041,0x0000004b,0x0000009a,0x00000065,0x00000099,0x00050051,0x00000006,0x0000009b, + 0x00000098,0x00000000,0x0003003e,0x0000009a,0x0000009b,0x00050041,0x0000004b,0x0000009c, + 0x00000065,0x0000000b,0x00050051,0x00000006,0x0000009d,0x00000098,0x00000001,0x0003003e, + 0x0000009c,0x0000009d,0x0004003d,0x00000009,0x0000009f,0x00000065,0x0007004f,0x00000007, + 0x000000a0,0x0000009f,0x0000009f,0x00000000,0x00000001,0x0004003d,0x00000009,0x000000a1, + 0x00000065,0x0007004f,0x00000007,0x000000a2,0x000000a1,0x000000a1,0x00000002,0x00000003, + 0x0007000c,0x00000007,0x000000a3,0x00000001,0x00000028,0x000000a0,0x000000a2,0x0003003e, + 0x0000009e,0x000000a3,0x0004003d,0x00000014,0x000000a5,0x00000019,0x00050041,0x0000002c, + 0x000000a6,0x00000018,0x00000037,0x0004003d,0x00000009,0x000000a7,0x000000a6,0x0007004f, + 0x00000007,0x000000a8,0x000000a7,0x000000a7,0x00000000,0x00000001,0x00050057,0x00000009, + 0x000000a9,0x000000a5,0x000000a8,0x0008004f,0x00000044,0x000000aa,0x000000a9,0x000000a9, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,0x000000ab,0x00000046,0x00050094, + 0x00000006,0x000000ac,0x000000aa,0x000000ab,0x0003003e,0x000000a4,0x000000ac,0x0004003d, + 0x00000014,0x000000ae,0x00000019,0x00050041,0x0000002c,0x000000af,0x00000018,0x00000037, + 0x0004003d,0x00000009,0x000000b0,0x000000af,0x0007004f,0x00000007,0x000000b1,0x000000b0, + 0x000000b0,0x00000002,0x00000003,0x00050057,0x00000009,0x000000b2,0x000000ae,0x000000b1, + 0x0008004f,0x00000044,0x000000b3,0x000000b2,0x000000b2,0x00000000,0x00000001,0x00000002, + 0x0004003d,0x00000044,0x000000b4,0x00000046,0x00050094,0x00000006,0x000000b5,0x000000b3, + 0x000000b4,0x0003003e,0x000000ad,0x000000b5,0x0004003d,0x00000006,0x000000b6,0x00000053, + 0x0004003d,0x00000006,0x000000b7,0x0000005c,0x00050050,0x00000007,0x000000b8,0x000000b6, + 0x000000b7,0x0004003d,0x00000006,0x000000b9,0x000000a4,0x0004003d,0x00000006,0x000000ba, + 0x000000ad,0x00050050,0x00000007,0x000000bb,0x000000b9,0x000000ba,0x00050083,0x00000007, + 0x000000bc,0x000000b8,0x000000bb,0x0006000c,0x00000007,0x000000bd,0x00000001,0x00000004, + 0x000000bc,0x00050041,0x0000004b,0x000000be,0x00000065,0x00000099,0x00050051,0x00000006, + 0x000000bf,0x000000bd,0x00000000,0x0003003e,0x000000be,0x000000bf,0x00050041,0x0000004b, + 0x000000c0,0x00000065,0x0000000b,0x00050051,0x00000006,0x000000c1,0x000000bd,0x00000001, + 0x0003003e,0x000000c0,0x000000c1,0x0004003d,0x00000007,0x000000c2,0x0000009e,0x0004003d, + 0x00000009,0x000000c3,0x00000065,0x0007004f,0x00000007,0x000000c4,0x000000c3,0x000000c3, + 0x00000002,0x00000003,0x0007000c,0x00000007,0x000000c5,0x00000001,0x00000028,0x000000c2, + 0x000000c4,0x0003003e,0x0000009e,0x000000c5,0x00050041,0x0000004b,0x000000c7,0x0000009e, + 0x0000006d,0x0004003d,0x00000006,0x000000c8,0x000000c7,0x00050041,0x0000004b,0x000000c9, + 0x0000009e,0x00000070,0x0004003d,0x00000006,0x000000ca,0x000000c9,0x0007000c,0x00000006, + 0x000000cb,0x00000001,0x00000028,0x000000c8,0x000000ca,0x0003003e,0x000000c6,0x000000cb, + 0x0004003d,0x00000006,0x000000cc,0x000000c6,0x0004003d,0x00000009,0x000000ce,0x00000065, + 0x0007004f,0x00000007,0x000000cf,0x000000ce,0x000000ce,0x00000000,0x00000001,0x0005008e, + 0x00000007,0x000000d0,0x000000cf,0x000000cd,0x00050050,0x00000007,0x000000d1,0x000000cc, + 0x000000cc,0x0007000c,0x00000007,0x000000d2,0x00000001,0x00000030,0x000000d1,0x000000d0, + 0x0004003d,0x00000007,0x000000d3,0x00000073,0x00050085,0x00000007,0x000000d4,0x000000d3, + 0x000000d2,0x0003003e,0x00000073,0x000000d4,0x0004003d,0x00000007,0x000000d5,0x00000073, + 0x000200fe,0x000000d5,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/smaa_frag.h b/app/src/main/cpp/shaders/smaa_frag.h deleted file mode 100644 index 1467b4efc0..0000000000 --- a/app/src/main/cpp/shaders/smaa_frag.h +++ /dev/null @@ -1,443 +0,0 @@ -#pragma once -#include - -static const uint32_t smaa_code[] = { - 0x07230203u, 0x00010000u, 0x0008000bu, 0x00000251u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu, - 0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u, - 0x0007000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000072u, 0x000000f6u, 0x00030010u, - 0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u, 0x6e69616du, - 0x00000000u, 0x00050005u, 0x0000000bu, 0x616d756cu, 0x33667628u, 0x0000003bu, 0x00030005u, 0x0000000au, - 0x00000063u, 0x00080005u, 0x00000012u, 0x65676465u, 0x74726556u, 0x6c616369u, 0x32667628u, 0x3266763bu, - 0x0000003bu, 0x00030005u, 0x00000010u, 0x00007675u, 0x00030005u, 0x00000011u, 0x00007870u, 0x00080005u, - 0x00000016u, 0x65676465u, 0x69726f48u, 0x746e6f7au, 0x76286c61u, 0x763b3266u, 0x003b3266u, 0x00030005u, - 0x00000014u, 0x00007675u, 0x00030005u, 0x00000015u, 0x00007870u, 0x00030005u, 0x00000021u, 0x00000061u, - 0x00060005u, 0x00000025u, 0x75706e49u, 0x78655474u, 0x65727574u, 0x00000000u, 0x00040005u, 0x00000031u, - 0x61726170u, 0x0000006du, 0x00030005u, 0x00000034u, 0x00000062u, 0x00040005u, 0x0000003cu, 0x61726170u, - 0x0000006du, 0x00030005u, 0x00000045u, 0x00000061u, 0x00040005u, 0x0000004eu, 0x61726170u, 0x0000006du, - 0x00030005u, 0x00000051u, 0x00000062u, 0x00040005u, 0x00000059u, 0x61726170u, 0x0000006du, 0x00030005u, - 0x00000062u, 0x00007870u, 0x00050005u, 0x00000064u, 0x736e6f43u, 0x746e6174u, 0x00000073u, 0x00040006u, - 0x00000064u, 0x00000000u, 0x0063646eu, 0x00060006u, 0x00000064u, 0x00000001u, 0x6f736572u, 0x6974756cu, - 0x00006e6fu, 0x00050006u, 0x00000064u, 0x00000002u, 0x72747865u, 0x00000061u, 0x00040006u, 0x00000064u, - 0x00000003u, 0x00646170u, 0x00030005u, 0x00000066u, 0x00006370u, 0x00030005u, 0x00000070u, 0x00007675u, - 0x00060005u, 0x00000072u, 0x67617266u, 0x43786554u, 0x64726f6fu, 0x00000000u, 0x00040005u, 0x0000007cu, - 0x746e6563u, 0x00007265u, 0x00030005u, 0x00000080u, 0x0000636cu, 0x00040005u, 0x00000081u, 0x61726170u, - 0x0000006du, 0x00030005u, 0x00000085u, 0x00006c6cu, 0x00040005u, 0x0000008du, 0x61726170u, 0x0000006du, - 0x00030005u, 0x00000090u, 0x0000726cu, 0x00040005u, 0x00000098u, 0x61726170u, 0x0000006du, 0x00030005u, - 0x0000009bu, 0x0000756cu, 0x00040005u, 0x000000a3u, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000a6u, - 0x0000646cu, 0x00040005u, 0x000000aeu, 0x61726170u, 0x0000006du, 0x00030005u, 0x000000b1u, 0x00004c64u, - 0x00030005u, 0x000000b6u, 0x00005264u, 0x00030005u, 0x000000bbu, 0x00005564u, 0x00030005u, 0x000000c0u, - 0x00004464u, 0x00050005u, 0x000000c5u, 0x61636f6cu, 0x6e694d6cu, 0x00000000u, 0x00050005u, 0x000000cfu, - 0x61636f6cu, 0x78614d6cu, 0x00000000u, 0x00060005u, 0x000000d9u, 0x61636f6cu, 0x6e6f436cu, 0x73617274u, - 0x00000074u, 0x00050005u, 0x000000ddu, 0x65726874u, 0x6c6f6873u, 0x00000064u, 0x00050005u, 0x000000e3u, - 0x74726576u, 0x6c616369u, 0x00000000u, 0x00050005u, 0x000000e7u, 0x69726f68u, 0x746e6f7au, 0x00006c61u, - 0x00050005u, 0x000000ebu, 0x6f727473u, 0x7365676eu, 0x00000074u, 0x00050005u, 0x000000f6u, 0x4374756fu, - 0x726f6c6fu, 0x00000000u, 0x00060005u, 0x000000fau, 0x74726576u, 0x6c616369u, 0x65676445u, 0x00000000u, - 0x00040005u, 0x000000feu, 0x676e6174u, 0x00746e65u, 0x00040005u, 0x0000010bu, 0x6d726f6eu, 0x00006c61u, - 0x00050005u, 0x0000011du, 0x6167656eu, 0x65766974u, 0x006e7552u, 0x00050005u, 0x0000011eu, 0x69736f70u, - 0x65766974u, 0x006e7552u, 0x00030005u, 0x00000120u, 0x00000069u, 0x00040005u, 0x00000129u, 0x7366666fu, - 0x00007465u, 0x00040005u, 0x0000012eu, 0x65676465u, 0x0000004eu, 0x00040005u, 0x00000136u, 0x61726170u, - 0x0000006du, 0x00040005u, 0x00000137u, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000013eu, 0x61726170u, - 0x0000006du, 0x00040005u, 0x0000013fu, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000143u, 0x65676465u, - 0x00000050u, 0x00040005u, 0x0000014bu, 0x61726170u, 0x0000006du, 0x00040005u, 0x0000014cu, 0x61726170u, - 0x0000006du, 0x00040005u, 0x00000153u, 0x61726170u, 0x0000006du, 0x00040005u, 0x00000154u, 0x61726170u, - 0x0000006du, 0x00040005u, 0x0000017bu, 0x6e617073u, 0x00000000u, 0x00060005u, 0x0000017fu, 0x65676465u, - 0x666e6f43u, 0x6e656469u, 0x00006563u, 0x00030005u, 0x00000186u, 0x0000776eu, 0x00040005u, 0x00000192u, - 0x61726170u, 0x0000006du, 0x00030005u, 0x00000195u, 0x0000656eu, 0x00040005u, 0x000001a0u, 0x61726170u, - 0x0000006du, 0x00030005u, 0x000001a3u, 0x00007773u, 0x00040005u, 0x000001aeu, 0x61726170u, 0x0000006du, - 0x00030005u, 0x000001b1u, 0x00006573u, 0x00040005u, 0x000001bbu, 0x61726170u, 0x0000006du, 0x00060005u, - 0x000001beu, 0x70646e65u, 0x746e696fu, 0x74746150u, 0x006e7265u, 0x00060005u, 0x000001c7u, 0x70646e65u, - 0x746e696fu, 0x61657241u, 0x00000000u, 0x00050005u, 0x000001ceu, 0x736f7263u, 0x676e6973u, 0x00000041u, - 0x00050005u, 0x000001ddu, 0x736f7263u, 0x676e6973u, 0x00000042u, 0x00070005u, 0x000001ecu, 0x736f7263u, - 0x676e6973u, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x000001f1u, 0x736f7263u, 0x676e6973u, - 0x74746150u, 0x006e7265u, 0x00050005u, 0x000001f7u, 0x61657261u, 0x67696557u, 0x00007468u, 0x00070005u, - 0x00000200u, 0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x74736172u, 0x00000000u, 0x00060005u, 0x0000020au, - 0x6e726f63u, 0x61467265u, 0x726f7463u, 0x00000000u, 0x00050005u, 0x00000214u, 0x65736162u, 0x67696557u, - 0x00007468u, 0x00070005u, 0x0000021cu, 0x67616964u, 0x6c616e6fu, 0x65727453u, 0x6874676eu, 0x00000000u, - 0x00060005u, 0x00000220u, 0x67616964u, 0x6c616e6fu, 0x74746150u, 0x006e7265u, 0x00070005u, 0x00000226u, - 0x67616964u, 0x6c616e6fu, 0x746e6f43u, 0x69756e69u, 0x00007974u, 0x00070005u, 0x00000229u, 0x67616964u, - 0x6c616e6fu, 0x6c6c6146u, 0x6b636162u, 0x00000000u, 0x00040005u, 0x00000235u, 0x67696577u, 0x00007468u, - 0x00040005u, 0x0000023bu, 0x6f726361u, 0x00007373u, 0x00040047u, 0x00000025u, 0x00000021u, 0x00000000u, - 0x00040047u, 0x00000025u, 0x00000022u, 0x00000000u, 0x00030047u, 0x00000064u, 0x00000002u, 0x00050048u, - 0x00000064u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000064u, 0x00000001u, 0x00000023u, - 0x00000010u, 0x00050048u, 0x00000064u, 0x00000002u, 0x00000023u, 0x00000018u, 0x00050048u, 0x00000064u, - 0x00000003u, 0x00000023u, 0x0000001cu, 0x00040047u, 0x00000072u, 0x0000001eu, 0x00000000u, 0x00040047u, - 0x000000f6u, 0x0000001eu, 0x00000000u, 0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, - 0x00030016u, 0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u, 0x00000006u, 0x00000003u, 0x00040020u, - 0x00000008u, 0x00000007u, 0x00000007u, 0x00040021u, 0x00000009u, 0x00000006u, 0x00000008u, 0x00040017u, - 0x0000000du, 0x00000006u, 0x00000002u, 0x00040020u, 0x0000000eu, 0x00000007u, 0x0000000du, 0x00050021u, - 0x0000000fu, 0x00000006u, 0x0000000eu, 0x0000000eu, 0x0004002bu, 0x00000006u, 0x00000019u, 0x3e59b3d0u, - 0x0004002bu, 0x00000006u, 0x0000001au, 0x3f371759u, 0x0004002bu, 0x00000006u, 0x0000001bu, 0x3d93dd98u, - 0x0006002cu, 0x00000007u, 0x0000001cu, 0x00000019u, 0x0000001au, 0x0000001bu, 0x00040020u, 0x00000020u, - 0x00000007u, 0x00000006u, 0x00090019u, 0x00000022u, 0x00000006u, 0x00000001u, 0x00000000u, 0x00000000u, - 0x00000000u, 0x00000001u, 0x00000000u, 0x0003001bu, 0x00000023u, 0x00000022u, 0x00040020u, 0x00000024u, - 0x00000000u, 0x00000023u, 0x0004003bu, 0x00000024u, 0x00000025u, 0x00000000u, 0x00040015u, 0x00000028u, - 0x00000020u, 0x00000000u, 0x0004002bu, 0x00000028u, 0x00000029u, 0x00000000u, 0x0004002bu, 0x00000006u, - 0x0000002cu, 0x00000000u, 0x00040017u, 0x0000002fu, 0x00000006u, 0x00000004u, 0x0004002bu, 0x00000028u, - 0x00000048u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000063u, 0x3f800000u, 0x0006001eu, 0x00000064u, - 0x0000002fu, 0x0000000du, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000065u, 0x00000009u, 0x00000064u, - 0x0004003bu, 0x00000065u, 0x00000066u, 0x00000009u, 0x00040015u, 0x00000067u, 0x00000020u, 0x00000001u, - 0x0004002bu, 0x00000067u, 0x00000068u, 0x00000001u, 0x00040020u, 0x00000069u, 0x00000009u, 0x0000000du, - 0x0005002cu, 0x0000000du, 0x0000006cu, 0x00000063u, 0x00000063u, 0x00040020u, 0x00000071u, 0x00000001u, - 0x0000000du, 0x0004003bu, 0x00000071u, 0x00000072u, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000075u, - 0x3f000000u, 0x00040020u, 0x0000007bu, 0x00000007u, 0x0000002fu, 0x0004002bu, 0x00000006u, 0x000000deu, - 0x3d3851ecu, 0x0004002bu, 0x00000006u, 0x000000e0u, 0x3da3d70au, 0x00020014u, 0x000000f1u, 0x00040020u, - 0x000000f5u, 0x00000003u, 0x0000002fu, 0x0004003bu, 0x000000f5u, 0x000000f6u, 0x00000003u, 0x00040020u, - 0x000000f9u, 0x00000007u, 0x000000f1u, 0x0004002bu, 0x00000006u, 0x00000113u, 0xbf800000u, 0x00040020u, - 0x0000011fu, 0x00000007u, 0x00000067u, 0x0004002bu, 0x00000067u, 0x00000127u, 0x00000006u, 0x0004002bu, - 0x00000006u, 0x00000161u, 0x3f266666u, 0x0004002bu, 0x00000006u, 0x00000182u, 0x40200000u, 0x0004002bu, - 0x00000006u, 0x000001cau, 0x3d6147aeu, 0x0004002bu, 0x00000006u, 0x000001f8u, 0x3ec28f5cu, 0x0004002bu, - 0x00000006u, 0x000001fcu, 0x40800000u, 0x0004002bu, 0x00000006u, 0x0000020bu, 0x3eb33333u, 0x0004002bu, - 0x00000006u, 0x0000020eu, 0x40400000u, 0x0004002bu, 0x00000006u, 0x0000022au, 0x3e23d70au, 0x0004002bu, - 0x00000006u, 0x00000239u, 0x3ed70a3du, 0x0004002bu, 0x00000028u, 0x0000024au, 0x00000003u, 0x00050036u, - 0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu, 0x0000000eu, - 0x00000062u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000070u, 0x00000007u, 0x0004003bu, 0x0000007bu, - 0x0000007cu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000080u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x00000081u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000085u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x0000008du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000090u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x00000098u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000009bu, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000000a3u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000a6u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000000aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000b1u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000b6u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000bbu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000c0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000c5u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000cfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000d9u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000ddu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000e3u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000000e7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000000ebu, 0x00000007u, 0x0004003bu, 0x000000f9u, - 0x000000fau, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x000000feu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000100u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000010bu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x0000010du, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000011du, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x0000011eu, 0x00000007u, 0x0004003bu, 0x0000011fu, 0x00000120u, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000129u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000012eu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000130u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000136u, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000137u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000013eu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x0000013fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000143u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000145u, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x0000014bu, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x0000014cu, 0x00000007u, 0x0004003bu, 0x0000000eu, 0x00000153u, 0x00000007u, 0x0004003bu, 0x0000000eu, - 0x00000154u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000017bu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x0000017fu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000186u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x00000192u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000195u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000001a0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001a3u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000001aeu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001b1u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x000001bbu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001beu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001c7u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ceu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001d0u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ddu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001dfu, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001ecu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x000001f1u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x000001f7u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000200u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000020au, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000214u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x0000021cu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000220u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000226u, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000229u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000235u, 0x00000007u, 0x0004003bu, 0x00000008u, - 0x0000023bu, 0x00000007u, 0x00050041u, 0x00000069u, 0x0000006au, 0x00000066u, 0x00000068u, 0x0004003du, - 0x0000000du, 0x0000006bu, 0x0000006au, 0x0007000cu, 0x0000000du, 0x0000006du, 0x00000001u, 0x00000028u, - 0x0000006bu, 0x0000006cu, 0x00050050u, 0x0000000du, 0x0000006eu, 0x00000063u, 0x00000063u, 0x00050088u, - 0x0000000du, 0x0000006fu, 0x0000006eu, 0x0000006du, 0x0003003eu, 0x00000062u, 0x0000006fu, 0x0004003du, - 0x0000000du, 0x00000073u, 0x00000072u, 0x0004003du, 0x0000000du, 0x00000074u, 0x00000062u, 0x0005008eu, - 0x0000000du, 0x00000076u, 0x00000074u, 0x00000075u, 0x0004003du, 0x0000000du, 0x00000077u, 0x00000062u, - 0x0005008eu, 0x0000000du, 0x00000078u, 0x00000077u, 0x00000075u, 0x00050083u, 0x0000000du, 0x00000079u, - 0x0000006cu, 0x00000078u, 0x0008000cu, 0x0000000du, 0x0000007au, 0x00000001u, 0x0000002bu, 0x00000073u, - 0x00000076u, 0x00000079u, 0x0003003eu, 0x00000070u, 0x0000007au, 0x0004003du, 0x00000023u, 0x0000007du, - 0x00000025u, 0x0004003du, 0x0000000du, 0x0000007eu, 0x00000070u, 0x00050057u, 0x0000002fu, 0x0000007fu, - 0x0000007du, 0x0000007eu, 0x0003003eu, 0x0000007cu, 0x0000007fu, 0x0004003du, 0x0000002fu, 0x00000082u, - 0x0000007cu, 0x0008004fu, 0x00000007u, 0x00000083u, 0x00000082u, 0x00000082u, 0x00000000u, 0x00000001u, - 0x00000002u, 0x0003003eu, 0x00000081u, 0x00000083u, 0x00050039u, 0x00000006u, 0x00000084u, 0x0000000bu, - 0x00000081u, 0x0003003eu, 0x00000080u, 0x00000084u, 0x0004003du, 0x00000023u, 0x00000086u, 0x00000025u, - 0x0004003du, 0x0000000du, 0x00000087u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000088u, 0x00000062u, - 0x00000029u, 0x0004003du, 0x00000006u, 0x00000089u, 0x00000088u, 0x00050050u, 0x0000000du, 0x0000008au, - 0x00000089u, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000008bu, 0x00000087u, 0x0000008au, 0x00050057u, - 0x0000002fu, 0x0000008cu, 0x00000086u, 0x0000008bu, 0x0008004fu, 0x00000007u, 0x0000008eu, 0x0000008cu, - 0x0000008cu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000008du, 0x0000008eu, 0x00050039u, - 0x00000006u, 0x0000008fu, 0x0000000bu, 0x0000008du, 0x0003003eu, 0x00000085u, 0x0000008fu, 0x0004003du, - 0x00000023u, 0x00000091u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000092u, 0x00000070u, 0x00050041u, - 0x00000020u, 0x00000093u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000094u, 0x00000093u, - 0x00050050u, 0x0000000du, 0x00000095u, 0x00000094u, 0x0000002cu, 0x00050081u, 0x0000000du, 0x00000096u, - 0x00000092u, 0x00000095u, 0x00050057u, 0x0000002fu, 0x00000097u, 0x00000091u, 0x00000096u, 0x0008004fu, - 0x00000007u, 0x00000099u, 0x00000097u, 0x00000097u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, - 0x00000098u, 0x00000099u, 0x00050039u, 0x00000006u, 0x0000009au, 0x0000000bu, 0x00000098u, 0x0003003eu, - 0x00000090u, 0x0000009au, 0x0004003du, 0x00000023u, 0x0000009cu, 0x00000025u, 0x0004003du, 0x0000000du, - 0x0000009du, 0x00000070u, 0x00050041u, 0x00000020u, 0x0000009eu, 0x00000062u, 0x00000048u, 0x0004003du, - 0x00000006u, 0x0000009fu, 0x0000009eu, 0x00050050u, 0x0000000du, 0x000000a0u, 0x0000002cu, 0x0000009fu, - 0x00050083u, 0x0000000du, 0x000000a1u, 0x0000009du, 0x000000a0u, 0x00050057u, 0x0000002fu, 0x000000a2u, - 0x0000009cu, 0x000000a1u, 0x0008004fu, 0x00000007u, 0x000000a4u, 0x000000a2u, 0x000000a2u, 0x00000000u, - 0x00000001u, 0x00000002u, 0x0003003eu, 0x000000a3u, 0x000000a4u, 0x00050039u, 0x00000006u, 0x000000a5u, - 0x0000000bu, 0x000000a3u, 0x0003003eu, 0x0000009bu, 0x000000a5u, 0x0004003du, 0x00000023u, 0x000000a7u, - 0x00000025u, 0x0004003du, 0x0000000du, 0x000000a8u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000000a9u, - 0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000000aau, 0x000000a9u, 0x00050050u, 0x0000000du, - 0x000000abu, 0x0000002cu, 0x000000aau, 0x00050081u, 0x0000000du, 0x000000acu, 0x000000a8u, 0x000000abu, - 0x00050057u, 0x0000002fu, 0x000000adu, 0x000000a7u, 0x000000acu, 0x0008004fu, 0x00000007u, 0x000000afu, - 0x000000adu, 0x000000adu, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000000aeu, 0x000000afu, - 0x00050039u, 0x00000006u, 0x000000b0u, 0x0000000bu, 0x000000aeu, 0x0003003eu, 0x000000a6u, 0x000000b0u, - 0x0004003du, 0x00000006u, 0x000000b2u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b3u, 0x00000085u, - 0x00050083u, 0x00000006u, 0x000000b4u, 0x000000b2u, 0x000000b3u, 0x0006000cu, 0x00000006u, 0x000000b5u, - 0x00000001u, 0x00000004u, 0x000000b4u, 0x0003003eu, 0x000000b1u, 0x000000b5u, 0x0004003du, 0x00000006u, - 0x000000b7u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000b8u, 0x00000090u, 0x00050083u, 0x00000006u, - 0x000000b9u, 0x000000b7u, 0x000000b8u, 0x0006000cu, 0x00000006u, 0x000000bau, 0x00000001u, 0x00000004u, - 0x000000b9u, 0x0003003eu, 0x000000b6u, 0x000000bau, 0x0004003du, 0x00000006u, 0x000000bcu, 0x00000080u, - 0x0004003du, 0x00000006u, 0x000000bdu, 0x0000009bu, 0x00050083u, 0x00000006u, 0x000000beu, 0x000000bcu, - 0x000000bdu, 0x0006000cu, 0x00000006u, 0x000000bfu, 0x00000001u, 0x00000004u, 0x000000beu, 0x0003003eu, - 0x000000bbu, 0x000000bfu, 0x0004003du, 0x00000006u, 0x000000c1u, 0x00000080u, 0x0004003du, 0x00000006u, - 0x000000c2u, 0x000000a6u, 0x00050083u, 0x00000006u, 0x000000c3u, 0x000000c1u, 0x000000c2u, 0x0006000cu, - 0x00000006u, 0x000000c4u, 0x00000001u, 0x00000004u, 0x000000c3u, 0x0003003eu, 0x000000c0u, 0x000000c4u, - 0x0004003du, 0x00000006u, 0x000000c6u, 0x00000080u, 0x0004003du, 0x00000006u, 0x000000c7u, 0x00000085u, - 0x0004003du, 0x00000006u, 0x000000c8u, 0x00000090u, 0x0007000cu, 0x00000006u, 0x000000c9u, 0x00000001u, - 0x00000025u, 0x000000c7u, 0x000000c8u, 0x0004003du, 0x00000006u, 0x000000cau, 0x0000009bu, 0x0004003du, - 0x00000006u, 0x000000cbu, 0x000000a6u, 0x0007000cu, 0x00000006u, 0x000000ccu, 0x00000001u, 0x00000025u, - 0x000000cau, 0x000000cbu, 0x0007000cu, 0x00000006u, 0x000000cdu, 0x00000001u, 0x00000025u, 0x000000c9u, - 0x000000ccu, 0x0007000cu, 0x00000006u, 0x000000ceu, 0x00000001u, 0x00000025u, 0x000000c6u, 0x000000cdu, - 0x0003003eu, 0x000000c5u, 0x000000ceu, 0x0004003du, 0x00000006u, 0x000000d0u, 0x00000080u, 0x0004003du, - 0x00000006u, 0x000000d1u, 0x00000085u, 0x0004003du, 0x00000006u, 0x000000d2u, 0x00000090u, 0x0007000cu, - 0x00000006u, 0x000000d3u, 0x00000001u, 0x00000028u, 0x000000d1u, 0x000000d2u, 0x0004003du, 0x00000006u, - 0x000000d4u, 0x0000009bu, 0x0004003du, 0x00000006u, 0x000000d5u, 0x000000a6u, 0x0007000cu, 0x00000006u, - 0x000000d6u, 0x00000001u, 0x00000028u, 0x000000d4u, 0x000000d5u, 0x0007000cu, 0x00000006u, 0x000000d7u, - 0x00000001u, 0x00000028u, 0x000000d3u, 0x000000d6u, 0x0007000cu, 0x00000006u, 0x000000d8u, 0x00000001u, - 0x00000028u, 0x000000d0u, 0x000000d7u, 0x0003003eu, 0x000000cfu, 0x000000d8u, 0x0004003du, 0x00000006u, - 0x000000dau, 0x000000cfu, 0x0004003du, 0x00000006u, 0x000000dbu, 0x000000c5u, 0x00050083u, 0x00000006u, - 0x000000dcu, 0x000000dau, 0x000000dbu, 0x0003003eu, 0x000000d9u, 0x000000dcu, 0x0004003du, 0x00000006u, - 0x000000dfu, 0x000000d9u, 0x00050085u, 0x00000006u, 0x000000e1u, 0x000000dfu, 0x000000e0u, 0x0007000cu, - 0x00000006u, 0x000000e2u, 0x00000001u, 0x00000028u, 0x000000deu, 0x000000e1u, 0x0003003eu, 0x000000ddu, - 0x000000e2u, 0x0004003du, 0x00000006u, 0x000000e4u, 0x000000b1u, 0x0004003du, 0x00000006u, 0x000000e5u, - 0x000000b6u, 0x0007000cu, 0x00000006u, 0x000000e6u, 0x00000001u, 0x00000028u, 0x000000e4u, 0x000000e5u, - 0x0003003eu, 0x000000e3u, 0x000000e6u, 0x0004003du, 0x00000006u, 0x000000e8u, 0x000000bbu, 0x0004003du, - 0x00000006u, 0x000000e9u, 0x000000c0u, 0x0007000cu, 0x00000006u, 0x000000eau, 0x00000001u, 0x00000028u, - 0x000000e8u, 0x000000e9u, 0x0003003eu, 0x000000e7u, 0x000000eau, 0x0004003du, 0x00000006u, 0x000000ecu, - 0x000000e3u, 0x0004003du, 0x00000006u, 0x000000edu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x000000eeu, - 0x00000001u, 0x00000028u, 0x000000ecu, 0x000000edu, 0x0003003eu, 0x000000ebu, 0x000000eeu, 0x0004003du, - 0x00000006u, 0x000000efu, 0x000000ebu, 0x0004003du, 0x00000006u, 0x000000f0u, 0x000000ddu, 0x000500bcu, - 0x000000f1u, 0x000000f2u, 0x000000efu, 0x000000f0u, 0x000300f7u, 0x000000f4u, 0x00000000u, 0x000400fau, - 0x000000f2u, 0x000000f3u, 0x000000f4u, 0x000200f8u, 0x000000f3u, 0x0004003du, 0x0000002fu, 0x000000f7u, - 0x0000007cu, 0x0003003eu, 0x000000f6u, 0x000000f7u, 0x000100fdu, 0x000200f8u, 0x000000f4u, 0x0004003du, - 0x00000006u, 0x000000fbu, 0x000000e3u, 0x0004003du, 0x00000006u, 0x000000fcu, 0x000000e7u, 0x000500beu, - 0x000000f1u, 0x000000fdu, 0x000000fbu, 0x000000fcu, 0x0003003eu, 0x000000fau, 0x000000fdu, 0x0004003du, - 0x000000f1u, 0x000000ffu, 0x000000fau, 0x000300f7u, 0x00000102u, 0x00000000u, 0x000400fau, 0x000000ffu, - 0x00000101u, 0x00000106u, 0x000200f8u, 0x00000101u, 0x00050041u, 0x00000020u, 0x00000103u, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x00000104u, 0x00000103u, 0x00050050u, 0x0000000du, 0x00000105u, - 0x0000002cu, 0x00000104u, 0x0003003eu, 0x00000100u, 0x00000105u, 0x000200f9u, 0x00000102u, 0x000200f8u, - 0x00000106u, 0x00050041u, 0x00000020u, 0x00000107u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, - 0x00000108u, 0x00000107u, 0x00050050u, 0x0000000du, 0x00000109u, 0x00000108u, 0x0000002cu, 0x0003003eu, - 0x00000100u, 0x00000109u, 0x000200f9u, 0x00000102u, 0x000200f8u, 0x00000102u, 0x0004003du, 0x0000000du, - 0x0000010au, 0x00000100u, 0x0003003eu, 0x000000feu, 0x0000010au, 0x0004003du, 0x000000f1u, 0x0000010cu, - 0x000000fau, 0x000300f7u, 0x0000010fu, 0x00000000u, 0x000400fau, 0x0000010cu, 0x0000010eu, 0x00000116u, - 0x000200f8u, 0x0000010eu, 0x0004003du, 0x00000006u, 0x00000110u, 0x000000b1u, 0x0004003du, 0x00000006u, - 0x00000111u, 0x000000b6u, 0x000500beu, 0x000000f1u, 0x00000112u, 0x00000110u, 0x00000111u, 0x000600a9u, - 0x00000006u, 0x00000114u, 0x00000112u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x00000115u, - 0x00000114u, 0x0000002cu, 0x0003003eu, 0x0000010du, 0x00000115u, 0x000200f9u, 0x0000010fu, 0x000200f8u, - 0x00000116u, 0x0004003du, 0x00000006u, 0x00000117u, 0x000000bbu, 0x0004003du, 0x00000006u, 0x00000118u, - 0x000000c0u, 0x000500beu, 0x000000f1u, 0x00000119u, 0x00000117u, 0x00000118u, 0x000600a9u, 0x00000006u, - 0x0000011au, 0x00000119u, 0x00000113u, 0x00000063u, 0x00050050u, 0x0000000du, 0x0000011bu, 0x0000002cu, - 0x0000011au, 0x0003003eu, 0x0000010du, 0x0000011bu, 0x000200f9u, 0x0000010fu, 0x000200f8u, 0x0000010fu, - 0x0004003du, 0x0000000du, 0x0000011cu, 0x0000010du, 0x0003003eu, 0x0000010bu, 0x0000011cu, 0x0003003eu, - 0x0000011du, 0x0000002cu, 0x0003003eu, 0x0000011eu, 0x0000002cu, 0x0003003eu, 0x00000120u, 0x00000068u, - 0x000200f9u, 0x00000121u, 0x000200f8u, 0x00000121u, 0x000400f6u, 0x00000123u, 0x00000124u, 0x00000000u, - 0x000200f9u, 0x00000125u, 0x000200f8u, 0x00000125u, 0x0004003du, 0x00000067u, 0x00000126u, 0x00000120u, - 0x000500b3u, 0x000000f1u, 0x00000128u, 0x00000126u, 0x00000127u, 0x000400fau, 0x00000128u, 0x00000122u, - 0x00000123u, 0x000200f8u, 0x00000122u, 0x0004003du, 0x0000000du, 0x0000012au, 0x000000feu, 0x0004003du, - 0x00000067u, 0x0000012bu, 0x00000120u, 0x0004006fu, 0x00000006u, 0x0000012cu, 0x0000012bu, 0x0005008eu, - 0x0000000du, 0x0000012du, 0x0000012au, 0x0000012cu, 0x0003003eu, 0x00000129u, 0x0000012du, 0x0004003du, - 0x000000f1u, 0x0000012fu, 0x000000fau, 0x000300f7u, 0x00000132u, 0x00000000u, 0x000400fau, 0x0000012fu, - 0x00000131u, 0x0000013au, 0x000200f8u, 0x00000131u, 0x0004003du, 0x0000000du, 0x00000133u, 0x00000070u, - 0x0004003du, 0x0000000du, 0x00000134u, 0x00000129u, 0x00050083u, 0x0000000du, 0x00000135u, 0x00000133u, - 0x00000134u, 0x0003003eu, 0x00000136u, 0x00000135u, 0x0004003du, 0x0000000du, 0x00000138u, 0x00000062u, - 0x0003003eu, 0x00000137u, 0x00000138u, 0x00060039u, 0x00000006u, 0x00000139u, 0x00000012u, 0x00000136u, - 0x00000137u, 0x0003003eu, 0x00000130u, 0x00000139u, 0x000200f9u, 0x00000132u, 0x000200f8u, 0x0000013au, - 0x0004003du, 0x0000000du, 0x0000013bu, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000013cu, 0x00000129u, - 0x00050083u, 0x0000000du, 0x0000013du, 0x0000013bu, 0x0000013cu, 0x0003003eu, 0x0000013eu, 0x0000013du, - 0x0004003du, 0x0000000du, 0x00000140u, 0x00000062u, 0x0003003eu, 0x0000013fu, 0x00000140u, 0x00060039u, - 0x00000006u, 0x00000141u, 0x00000016u, 0x0000013eu, 0x0000013fu, 0x0003003eu, 0x00000130u, 0x00000141u, - 0x000200f9u, 0x00000132u, 0x000200f8u, 0x00000132u, 0x0004003du, 0x00000006u, 0x00000142u, 0x00000130u, - 0x0003003eu, 0x0000012eu, 0x00000142u, 0x0004003du, 0x000000f1u, 0x00000144u, 0x000000fau, 0x000300f7u, - 0x00000147u, 0x00000000u, 0x000400fau, 0x00000144u, 0x00000146u, 0x0000014fu, 0x000200f8u, 0x00000146u, - 0x0004003du, 0x0000000du, 0x00000148u, 0x00000070u, 0x0004003du, 0x0000000du, 0x00000149u, 0x00000129u, - 0x00050081u, 0x0000000du, 0x0000014au, 0x00000148u, 0x00000149u, 0x0003003eu, 0x0000014bu, 0x0000014au, - 0x0004003du, 0x0000000du, 0x0000014du, 0x00000062u, 0x0003003eu, 0x0000014cu, 0x0000014du, 0x00060039u, - 0x00000006u, 0x0000014eu, 0x00000012u, 0x0000014bu, 0x0000014cu, 0x0003003eu, 0x00000145u, 0x0000014eu, - 0x000200f9u, 0x00000147u, 0x000200f8u, 0x0000014fu, 0x0004003du, 0x0000000du, 0x00000150u, 0x00000070u, - 0x0004003du, 0x0000000du, 0x00000151u, 0x00000129u, 0x00050081u, 0x0000000du, 0x00000152u, 0x00000150u, - 0x00000151u, 0x0003003eu, 0x00000153u, 0x00000152u, 0x0004003du, 0x0000000du, 0x00000155u, 0x00000062u, - 0x0003003eu, 0x00000154u, 0x00000155u, 0x00060039u, 0x00000006u, 0x00000156u, 0x00000016u, 0x00000153u, - 0x00000154u, 0x0003003eu, 0x00000145u, 0x00000156u, 0x000200f9u, 0x00000147u, 0x000200f8u, 0x00000147u, - 0x0004003du, 0x00000006u, 0x00000157u, 0x00000145u, 0x0003003eu, 0x00000143u, 0x00000157u, 0x0004003du, - 0x00000006u, 0x00000158u, 0x0000011du, 0x0004003du, 0x00000067u, 0x00000159u, 0x00000120u, 0x00050082u, - 0x00000067u, 0x0000015au, 0x00000159u, 0x00000068u, 0x0004006fu, 0x00000006u, 0x0000015bu, 0x0000015au, - 0x000500b4u, 0x000000f1u, 0x0000015cu, 0x00000158u, 0x0000015bu, 0x000300f7u, 0x0000015eu, 0x00000000u, - 0x000400fau, 0x0000015cu, 0x0000015du, 0x0000015eu, 0x000200f8u, 0x0000015du, 0x0004003du, 0x00000006u, - 0x0000015fu, 0x0000012eu, 0x0004003du, 0x00000006u, 0x00000160u, 0x000000ddu, 0x00050085u, 0x00000006u, - 0x00000162u, 0x00000160u, 0x00000161u, 0x000500bau, 0x000000f1u, 0x00000163u, 0x0000015fu, 0x00000162u, - 0x000200f9u, 0x0000015eu, 0x000200f8u, 0x0000015eu, 0x000700f5u, 0x000000f1u, 0x00000164u, 0x0000015cu, - 0x00000147u, 0x00000163u, 0x0000015du, 0x000300f7u, 0x00000166u, 0x00000000u, 0x000400fau, 0x00000164u, - 0x00000165u, 0x00000166u, 0x000200f8u, 0x00000165u, 0x0004003du, 0x00000067u, 0x00000167u, 0x00000120u, - 0x0004006fu, 0x00000006u, 0x00000168u, 0x00000167u, 0x0003003eu, 0x0000011du, 0x00000168u, 0x000200f9u, - 0x00000166u, 0x000200f8u, 0x00000166u, 0x0004003du, 0x00000006u, 0x00000169u, 0x0000011eu, 0x0004003du, - 0x00000067u, 0x0000016au, 0x00000120u, 0x00050082u, 0x00000067u, 0x0000016bu, 0x0000016au, 0x00000068u, - 0x0004006fu, 0x00000006u, 0x0000016cu, 0x0000016bu, 0x000500b4u, 0x000000f1u, 0x0000016du, 0x00000169u, - 0x0000016cu, 0x000300f7u, 0x0000016fu, 0x00000000u, 0x000400fau, 0x0000016du, 0x0000016eu, 0x0000016fu, - 0x000200f8u, 0x0000016eu, 0x0004003du, 0x00000006u, 0x00000170u, 0x00000143u, 0x0004003du, 0x00000006u, - 0x00000171u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000172u, 0x00000171u, 0x00000161u, 0x000500bau, - 0x000000f1u, 0x00000173u, 0x00000170u, 0x00000172u, 0x000200f9u, 0x0000016fu, 0x000200f8u, 0x0000016fu, - 0x000700f5u, 0x000000f1u, 0x00000174u, 0x0000016du, 0x00000166u, 0x00000173u, 0x0000016eu, 0x000300f7u, - 0x00000176u, 0x00000000u, 0x000400fau, 0x00000174u, 0x00000175u, 0x00000176u, 0x000200f8u, 0x00000175u, - 0x0004003du, 0x00000067u, 0x00000177u, 0x00000120u, 0x0004006fu, 0x00000006u, 0x00000178u, 0x00000177u, - 0x0003003eu, 0x0000011eu, 0x00000178u, 0x000200f9u, 0x00000176u, 0x000200f8u, 0x00000176u, 0x000200f9u, - 0x00000124u, 0x000200f8u, 0x00000124u, 0x0004003du, 0x00000067u, 0x00000179u, 0x00000120u, 0x00050080u, - 0x00000067u, 0x0000017au, 0x00000179u, 0x00000068u, 0x0003003eu, 0x00000120u, 0x0000017au, 0x000200f9u, - 0x00000121u, 0x000200f8u, 0x00000123u, 0x0004003du, 0x00000006u, 0x0000017cu, 0x0000011du, 0x0004003du, - 0x00000006u, 0x0000017du, 0x0000011eu, 0x00050081u, 0x00000006u, 0x0000017eu, 0x0000017cu, 0x0000017du, - 0x0003003eu, 0x0000017bu, 0x0000017eu, 0x0004003du, 0x00000006u, 0x00000180u, 0x000000ddu, 0x0004003du, - 0x00000006u, 0x00000181u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000183u, 0x00000181u, 0x00000182u, - 0x0004003du, 0x00000006u, 0x00000184u, 0x000000ebu, 0x0008000cu, 0x00000006u, 0x00000185u, 0x00000001u, - 0x00000031u, 0x00000180u, 0x00000183u, 0x00000184u, 0x0003003eu, 0x0000017fu, 0x00000185u, 0x0004003du, - 0x00000023u, 0x00000187u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000188u, 0x00000070u, 0x00050041u, - 0x00000020u, 0x00000189u, 0x00000062u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000018au, 0x00000189u, - 0x0004007fu, 0x00000006u, 0x0000018bu, 0x0000018au, 0x00050041u, 0x00000020u, 0x0000018cu, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x0000018du, 0x0000018cu, 0x0004007fu, 0x00000006u, 0x0000018eu, - 0x0000018du, 0x00050050u, 0x0000000du, 0x0000018fu, 0x0000018bu, 0x0000018eu, 0x00050081u, 0x0000000du, - 0x00000190u, 0x00000188u, 0x0000018fu, 0x00050057u, 0x0000002fu, 0x00000191u, 0x00000187u, 0x00000190u, - 0x0008004fu, 0x00000007u, 0x00000193u, 0x00000191u, 0x00000191u, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x00000192u, 0x00000193u, 0x00050039u, 0x00000006u, 0x00000194u, 0x0000000bu, 0x00000192u, - 0x0003003eu, 0x00000186u, 0x00000194u, 0x0004003du, 0x00000023u, 0x00000196u, 0x00000025u, 0x0004003du, - 0x0000000du, 0x00000197u, 0x00000070u, 0x00050041u, 0x00000020u, 0x00000198u, 0x00000062u, 0x00000029u, - 0x0004003du, 0x00000006u, 0x00000199u, 0x00000198u, 0x00050041u, 0x00000020u, 0x0000019au, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x0000019bu, 0x0000019au, 0x0004007fu, 0x00000006u, 0x0000019cu, - 0x0000019bu, 0x00050050u, 0x0000000du, 0x0000019du, 0x00000199u, 0x0000019cu, 0x00050081u, 0x0000000du, - 0x0000019eu, 0x00000197u, 0x0000019du, 0x00050057u, 0x0000002fu, 0x0000019fu, 0x00000196u, 0x0000019eu, - 0x0008004fu, 0x00000007u, 0x000001a1u, 0x0000019fu, 0x0000019fu, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x000001a0u, 0x000001a1u, 0x00050039u, 0x00000006u, 0x000001a2u, 0x0000000bu, 0x000001a0u, - 0x0003003eu, 0x00000195u, 0x000001a2u, 0x0004003du, 0x00000023u, 0x000001a4u, 0x00000025u, 0x0004003du, - 0x0000000du, 0x000001a5u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001a6u, 0x00000062u, 0x00000029u, - 0x0004003du, 0x00000006u, 0x000001a7u, 0x000001a6u, 0x0004007fu, 0x00000006u, 0x000001a8u, 0x000001a7u, - 0x00050041u, 0x00000020u, 0x000001a9u, 0x00000062u, 0x00000048u, 0x0004003du, 0x00000006u, 0x000001aau, - 0x000001a9u, 0x00050050u, 0x0000000du, 0x000001abu, 0x000001a8u, 0x000001aau, 0x00050081u, 0x0000000du, - 0x000001acu, 0x000001a5u, 0x000001abu, 0x00050057u, 0x0000002fu, 0x000001adu, 0x000001a4u, 0x000001acu, - 0x0008004fu, 0x00000007u, 0x000001afu, 0x000001adu, 0x000001adu, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x000001aeu, 0x000001afu, 0x00050039u, 0x00000006u, 0x000001b0u, 0x0000000bu, 0x000001aeu, - 0x0003003eu, 0x000001a3u, 0x000001b0u, 0x0004003du, 0x00000023u, 0x000001b2u, 0x00000025u, 0x0004003du, - 0x0000000du, 0x000001b3u, 0x00000070u, 0x00050041u, 0x00000020u, 0x000001b4u, 0x00000062u, 0x00000029u, - 0x0004003du, 0x00000006u, 0x000001b5u, 0x000001b4u, 0x00050041u, 0x00000020u, 0x000001b6u, 0x00000062u, - 0x00000048u, 0x0004003du, 0x00000006u, 0x000001b7u, 0x000001b6u, 0x00050050u, 0x0000000du, 0x000001b8u, - 0x000001b5u, 0x000001b7u, 0x00050081u, 0x0000000du, 0x000001b9u, 0x000001b3u, 0x000001b8u, 0x00050057u, - 0x0000002fu, 0x000001bau, 0x000001b2u, 0x000001b9u, 0x0008004fu, 0x00000007u, 0x000001bcu, 0x000001bau, - 0x000001bau, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x000001bbu, 0x000001bcu, 0x00050039u, - 0x00000006u, 0x000001bdu, 0x0000000bu, 0x000001bbu, 0x0003003eu, 0x000001b1u, 0x000001bdu, 0x0004003du, - 0x00000006u, 0x000001bfu, 0x0000011du, 0x0004003du, 0x00000006u, 0x000001c0u, 0x0000011eu, 0x00050083u, - 0x00000006u, 0x000001c1u, 0x000001bfu, 0x000001c0u, 0x0006000cu, 0x00000006u, 0x000001c2u, 0x00000001u, - 0x00000004u, 0x000001c1u, 0x0004003du, 0x00000006u, 0x000001c3u, 0x0000017bu, 0x0007000cu, 0x00000006u, - 0x000001c4u, 0x00000001u, 0x00000028u, 0x000001c3u, 0x00000063u, 0x00050088u, 0x00000006u, 0x000001c5u, - 0x000001c2u, 0x000001c4u, 0x0008000cu, 0x00000006u, 0x000001c6u, 0x00000001u, 0x0000002bu, 0x000001c5u, - 0x0000002cu, 0x00000063u, 0x0003003eu, 0x000001beu, 0x000001c6u, 0x0004003du, 0x00000006u, 0x000001c8u, - 0x000001beu, 0x0004003du, 0x00000006u, 0x000001c9u, 0x0000017bu, 0x00050085u, 0x00000006u, 0x000001cbu, - 0x000001c9u, 0x000001cau, 0x00050081u, 0x00000006u, 0x000001ccu, 0x00000063u, 0x000001cbu, 0x00050088u, - 0x00000006u, 0x000001cdu, 0x000001c8u, 0x000001ccu, 0x0003003eu, 0x000001c7u, 0x000001cdu, 0x0004003du, - 0x000000f1u, 0x000001cfu, 0x000000fau, 0x000300f7u, 0x000001d2u, 0x00000000u, 0x000400fau, 0x000001cfu, - 0x000001d1u, 0x000001d7u, 0x000200f8u, 0x000001d1u, 0x0004003du, 0x00000006u, 0x000001d3u, 0x00000186u, - 0x0004003du, 0x00000006u, 0x000001d4u, 0x00000195u, 0x00050083u, 0x00000006u, 0x000001d5u, 0x000001d3u, - 0x000001d4u, 0x0006000cu, 0x00000006u, 0x000001d6u, 0x00000001u, 0x00000004u, 0x000001d5u, 0x0003003eu, - 0x000001d0u, 0x000001d6u, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d7u, 0x0004003du, 0x00000006u, - 0x000001d8u, 0x00000186u, 0x0004003du, 0x00000006u, 0x000001d9u, 0x000001a3u, 0x00050083u, 0x00000006u, - 0x000001dau, 0x000001d8u, 0x000001d9u, 0x0006000cu, 0x00000006u, 0x000001dbu, 0x00000001u, 0x00000004u, - 0x000001dau, 0x0003003eu, 0x000001d0u, 0x000001dbu, 0x000200f9u, 0x000001d2u, 0x000200f8u, 0x000001d2u, - 0x0004003du, 0x00000006u, 0x000001dcu, 0x000001d0u, 0x0003003eu, 0x000001ceu, 0x000001dcu, 0x0004003du, - 0x000000f1u, 0x000001deu, 0x000000fau, 0x000300f7u, 0x000001e1u, 0x00000000u, 0x000400fau, 0x000001deu, - 0x000001e0u, 0x000001e6u, 0x000200f8u, 0x000001e0u, 0x0004003du, 0x00000006u, 0x000001e2u, 0x000001a3u, - 0x0004003du, 0x00000006u, 0x000001e3u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x000001e4u, 0x000001e2u, - 0x000001e3u, 0x0006000cu, 0x00000006u, 0x000001e5u, 0x00000001u, 0x00000004u, 0x000001e4u, 0x0003003eu, - 0x000001dfu, 0x000001e5u, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e6u, 0x0004003du, 0x00000006u, - 0x000001e7u, 0x00000195u, 0x0004003du, 0x00000006u, 0x000001e8u, 0x000001b1u, 0x00050083u, 0x00000006u, - 0x000001e9u, 0x000001e7u, 0x000001e8u, 0x0006000cu, 0x00000006u, 0x000001eau, 0x00000001u, 0x00000004u, - 0x000001e9u, 0x0003003eu, 0x000001dfu, 0x000001eau, 0x000200f9u, 0x000001e1u, 0x000200f8u, 0x000001e1u, - 0x0004003du, 0x00000006u, 0x000001ebu, 0x000001dfu, 0x0003003eu, 0x000001ddu, 0x000001ebu, 0x0004003du, - 0x00000006u, 0x000001edu, 0x000001ceu, 0x0004003du, 0x00000006u, 0x000001eeu, 0x000001ddu, 0x00050083u, - 0x00000006u, 0x000001efu, 0x000001edu, 0x000001eeu, 0x0006000cu, 0x00000006u, 0x000001f0u, 0x00000001u, - 0x00000004u, 0x000001efu, 0x0003003eu, 0x000001ecu, 0x000001f0u, 0x0004003du, 0x00000006u, 0x000001f2u, - 0x000000ddu, 0x0004003du, 0x00000006u, 0x000001f3u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x000001f4u, - 0x000001f3u, 0x00000182u, 0x0004003du, 0x00000006u, 0x000001f5u, 0x000001ecu, 0x0008000cu, 0x00000006u, - 0x000001f6u, 0x00000001u, 0x00000031u, 0x000001f2u, 0x000001f4u, 0x000001f5u, 0x0003003eu, 0x000001f1u, - 0x000001f6u, 0x0004003du, 0x00000006u, 0x000001f9u, 0x000001f1u, 0x00050085u, 0x00000006u, 0x000001fau, - 0x000001f8u, 0x000001f9u, 0x0004003du, 0x00000006u, 0x000001fbu, 0x0000017bu, 0x00050088u, 0x00000006u, - 0x000001fdu, 0x000001fbu, 0x000001fcu, 0x0008000cu, 0x00000006u, 0x000001feu, 0x00000001u, 0x0000002bu, - 0x000001fdu, 0x0000002cu, 0x00000063u, 0x00050085u, 0x00000006u, 0x000001ffu, 0x000001fau, 0x000001feu, - 0x0003003eu, 0x000001f7u, 0x000001ffu, 0x0004003du, 0x00000006u, 0x00000201u, 0x00000186u, 0x0004003du, - 0x00000006u, 0x00000202u, 0x000001b1u, 0x00050083u, 0x00000006u, 0x00000203u, 0x00000201u, 0x00000202u, - 0x0006000cu, 0x00000006u, 0x00000204u, 0x00000001u, 0x00000004u, 0x00000203u, 0x0004003du, 0x00000006u, - 0x00000205u, 0x00000195u, 0x0004003du, 0x00000006u, 0x00000206u, 0x000001a3u, 0x00050083u, 0x00000006u, - 0x00000207u, 0x00000205u, 0x00000206u, 0x0006000cu, 0x00000006u, 0x00000208u, 0x00000001u, 0x00000004u, - 0x00000207u, 0x0007000cu, 0x00000006u, 0x00000209u, 0x00000001u, 0x00000028u, 0x00000204u, 0x00000208u, - 0x0003003eu, 0x00000200u, 0x00000209u, 0x0004003du, 0x00000006u, 0x0000020cu, 0x000000ddu, 0x0004003du, - 0x00000006u, 0x0000020du, 0x000000ddu, 0x00050085u, 0x00000006u, 0x0000020fu, 0x0000020du, 0x0000020eu, - 0x0004003du, 0x00000006u, 0x00000210u, 0x00000200u, 0x0008000cu, 0x00000006u, 0x00000211u, 0x00000001u, - 0x00000031u, 0x0000020cu, 0x0000020fu, 0x00000210u, 0x00050085u, 0x00000006u, 0x00000212u, 0x0000020bu, - 0x00000211u, 0x00050083u, 0x00000006u, 0x00000213u, 0x00000063u, 0x00000212u, 0x0003003eu, 0x0000020au, - 0x00000213u, 0x0004003du, 0x00000006u, 0x00000215u, 0x000001f7u, 0x0004003du, 0x00000006u, 0x00000216u, - 0x000001c7u, 0x00050085u, 0x00000006u, 0x00000217u, 0x00000215u, 0x00000216u, 0x0004003du, 0x00000006u, - 0x00000218u, 0x0000017fu, 0x00050085u, 0x00000006u, 0x00000219u, 0x00000217u, 0x00000218u, 0x0004003du, - 0x00000006u, 0x0000021au, 0x0000020au, 0x00050085u, 0x00000006u, 0x0000021bu, 0x00000219u, 0x0000021au, - 0x0003003eu, 0x00000214u, 0x0000021bu, 0x0004003du, 0x00000006u, 0x0000021du, 0x000000e3u, 0x0004003du, - 0x00000006u, 0x0000021eu, 0x000000e7u, 0x0007000cu, 0x00000006u, 0x0000021fu, 0x00000001u, 0x00000025u, - 0x0000021du, 0x0000021eu, 0x0003003eu, 0x0000021cu, 0x0000021fu, 0x0004003du, 0x00000006u, 0x00000221u, - 0x000000ddu, 0x0004003du, 0x00000006u, 0x00000222u, 0x000000ddu, 0x00050085u, 0x00000006u, 0x00000223u, - 0x00000222u, 0x00000182u, 0x0004003du, 0x00000006u, 0x00000224u, 0x0000021cu, 0x0008000cu, 0x00000006u, - 0x00000225u, 0x00000001u, 0x00000031u, 0x00000221u, 0x00000223u, 0x00000224u, 0x0003003eu, 0x00000220u, - 0x00000225u, 0x0004003du, 0x00000006u, 0x00000227u, 0x0000017bu, 0x0008000cu, 0x00000006u, 0x00000228u, - 0x00000001u, 0x00000031u, 0x00000063u, 0x0000020eu, 0x00000227u, 0x0003003eu, 0x00000226u, 0x00000228u, - 0x0004003du, 0x00000006u, 0x0000022bu, 0x00000220u, 0x00050085u, 0x00000006u, 0x0000022cu, 0x0000022au, - 0x0000022bu, 0x0004003du, 0x00000006u, 0x0000022du, 0x0000017fu, 0x00050085u, 0x00000006u, 0x0000022eu, - 0x0000022cu, 0x0000022du, 0x0004003du, 0x00000006u, 0x0000022fu, 0x0000020au, 0x00050085u, 0x00000006u, - 0x00000230u, 0x0000022eu, 0x0000022fu, 0x0004003du, 0x00000006u, 0x00000231u, 0x00000226u, 0x00050085u, - 0x00000006u, 0x00000232u, 0x00000230u, 0x00000231u, 0x0004003du, 0x00000006u, 0x00000233u, 0x000001f1u, - 0x00050085u, 0x00000006u, 0x00000234u, 0x00000232u, 0x00000233u, 0x0003003eu, 0x00000229u, 0x00000234u, - 0x0004003du, 0x00000006u, 0x00000236u, 0x00000214u, 0x0004003du, 0x00000006u, 0x00000237u, 0x00000229u, - 0x0007000cu, 0x00000006u, 0x00000238u, 0x00000001u, 0x00000028u, 0x00000236u, 0x00000237u, 0x0008000cu, - 0x00000006u, 0x0000023au, 0x00000001u, 0x0000002bu, 0x00000238u, 0x0000002cu, 0x00000239u, 0x0003003eu, - 0x00000235u, 0x0000023au, 0x0004003du, 0x00000023u, 0x0000023cu, 0x00000025u, 0x0004003du, 0x0000000du, - 0x0000023du, 0x00000070u, 0x0004003du, 0x0000000du, 0x0000023eu, 0x0000010bu, 0x0004003du, 0x0000000du, - 0x0000023fu, 0x00000062u, 0x00050085u, 0x0000000du, 0x00000240u, 0x0000023eu, 0x0000023fu, 0x00050081u, - 0x0000000du, 0x00000241u, 0x0000023du, 0x00000240u, 0x00050057u, 0x0000002fu, 0x00000242u, 0x0000023cu, - 0x00000241u, 0x0008004fu, 0x00000007u, 0x00000243u, 0x00000242u, 0x00000242u, 0x00000000u, 0x00000001u, - 0x00000002u, 0x0003003eu, 0x0000023bu, 0x00000243u, 0x0004003du, 0x0000002fu, 0x00000244u, 0x0000007cu, - 0x0008004fu, 0x00000007u, 0x00000245u, 0x00000244u, 0x00000244u, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0004003du, 0x00000007u, 0x00000246u, 0x0000023bu, 0x0004003du, 0x00000006u, 0x00000247u, 0x00000235u, - 0x00060050u, 0x00000007u, 0x00000248u, 0x00000247u, 0x00000247u, 0x00000247u, 0x0008000cu, 0x00000007u, - 0x00000249u, 0x00000001u, 0x0000002eu, 0x00000245u, 0x00000246u, 0x00000248u, 0x00050041u, 0x00000020u, - 0x0000024bu, 0x0000007cu, 0x0000024au, 0x0004003du, 0x00000006u, 0x0000024cu, 0x0000024bu, 0x00050051u, - 0x00000006u, 0x0000024du, 0x00000249u, 0x00000000u, 0x00050051u, 0x00000006u, 0x0000024eu, 0x00000249u, - 0x00000001u, 0x00050051u, 0x00000006u, 0x0000024fu, 0x00000249u, 0x00000002u, 0x00070050u, 0x0000002fu, - 0x00000250u, 0x0000024du, 0x0000024eu, 0x0000024fu, 0x0000024cu, 0x0003003eu, 0x000000f6u, 0x00000250u, - 0x000100fdu, 0x00010038u, 0x00050036u, 0x00000006u, 0x0000000bu, 0x00000000u, 0x00000009u, 0x00030037u, - 0x00000008u, 0x0000000au, 0x000200f8u, 0x0000000cu, 0x0004003du, 0x00000007u, 0x00000018u, 0x0000000au, - 0x00050094u, 0x00000006u, 0x0000001du, 0x00000018u, 0x0000001cu, 0x000200feu, 0x0000001du, 0x00010038u, - 0x00050036u, 0x00000006u, 0x00000012u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu, 0x00000010u, - 0x00030037u, 0x0000000eu, 0x00000011u, 0x000200f8u, 0x00000013u, 0x0004003bu, 0x00000020u, 0x00000021u, - 0x00000007u, 0x0004003bu, 0x00000008u, 0x00000031u, 0x00000007u, 0x0004003bu, 0x00000020u, 0x00000034u, - 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000003cu, 0x00000007u, 0x0004003du, 0x00000023u, 0x00000026u, - 0x00000025u, 0x0004003du, 0x0000000du, 0x00000027u, 0x00000010u, 0x00050041u, 0x00000020u, 0x0000002au, - 0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x0000002bu, 0x0000002au, 0x00050050u, 0x0000000du, - 0x0000002du, 0x0000002bu, 0x0000002cu, 0x00050083u, 0x0000000du, 0x0000002eu, 0x00000027u, 0x0000002du, - 0x00050057u, 0x0000002fu, 0x00000030u, 0x00000026u, 0x0000002eu, 0x0008004fu, 0x00000007u, 0x00000032u, - 0x00000030u, 0x00000030u, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x00000031u, 0x00000032u, - 0x00050039u, 0x00000006u, 0x00000033u, 0x0000000bu, 0x00000031u, 0x0003003eu, 0x00000021u, 0x00000033u, - 0x0004003du, 0x00000023u, 0x00000035u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000036u, 0x00000010u, - 0x00050041u, 0x00000020u, 0x00000037u, 0x00000011u, 0x00000029u, 0x0004003du, 0x00000006u, 0x00000038u, - 0x00000037u, 0x00050050u, 0x0000000du, 0x00000039u, 0x00000038u, 0x0000002cu, 0x00050081u, 0x0000000du, - 0x0000003au, 0x00000036u, 0x00000039u, 0x00050057u, 0x0000002fu, 0x0000003bu, 0x00000035u, 0x0000003au, - 0x0008004fu, 0x00000007u, 0x0000003du, 0x0000003bu, 0x0000003bu, 0x00000000u, 0x00000001u, 0x00000002u, - 0x0003003eu, 0x0000003cu, 0x0000003du, 0x00050039u, 0x00000006u, 0x0000003eu, 0x0000000bu, 0x0000003cu, - 0x0003003eu, 0x00000034u, 0x0000003eu, 0x0004003du, 0x00000006u, 0x0000003fu, 0x00000021u, 0x0004003du, - 0x00000006u, 0x00000040u, 0x00000034u, 0x00050083u, 0x00000006u, 0x00000041u, 0x0000003fu, 0x00000040u, - 0x0006000cu, 0x00000006u, 0x00000042u, 0x00000001u, 0x00000004u, 0x00000041u, 0x000200feu, 0x00000042u, - 0x00010038u, 0x00050036u, 0x00000006u, 0x00000016u, 0x00000000u, 0x0000000fu, 0x00030037u, 0x0000000eu, - 0x00000014u, 0x00030037u, 0x0000000eu, 0x00000015u, 0x000200f8u, 0x00000017u, 0x0004003bu, 0x00000020u, - 0x00000045u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000004eu, 0x00000007u, 0x0004003bu, 0x00000020u, - 0x00000051u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x00000059u, 0x00000007u, 0x0004003du, 0x00000023u, - 0x00000046u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000047u, 0x00000014u, 0x00050041u, 0x00000020u, - 0x00000049u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u, 0x0000004au, 0x00000049u, 0x00050050u, - 0x0000000du, 0x0000004bu, 0x0000002cu, 0x0000004au, 0x00050083u, 0x0000000du, 0x0000004cu, 0x00000047u, - 0x0000004bu, 0x00050057u, 0x0000002fu, 0x0000004du, 0x00000046u, 0x0000004cu, 0x0008004fu, 0x00000007u, - 0x0000004fu, 0x0000004du, 0x0000004du, 0x00000000u, 0x00000001u, 0x00000002u, 0x0003003eu, 0x0000004eu, - 0x0000004fu, 0x00050039u, 0x00000006u, 0x00000050u, 0x0000000bu, 0x0000004eu, 0x0003003eu, 0x00000045u, - 0x00000050u, 0x0004003du, 0x00000023u, 0x00000052u, 0x00000025u, 0x0004003du, 0x0000000du, 0x00000053u, - 0x00000014u, 0x00050041u, 0x00000020u, 0x00000054u, 0x00000015u, 0x00000048u, 0x0004003du, 0x00000006u, - 0x00000055u, 0x00000054u, 0x00050050u, 0x0000000du, 0x00000056u, 0x0000002cu, 0x00000055u, 0x00050081u, - 0x0000000du, 0x00000057u, 0x00000053u, 0x00000056u, 0x00050057u, 0x0000002fu, 0x00000058u, 0x00000052u, - 0x00000057u, 0x0008004fu, 0x00000007u, 0x0000005au, 0x00000058u, 0x00000058u, 0x00000000u, 0x00000001u, - 0x00000002u, 0x0003003eu, 0x00000059u, 0x0000005au, 0x00050039u, 0x00000006u, 0x0000005bu, 0x0000000bu, - 0x00000059u, 0x0003003eu, 0x00000051u, 0x0000005bu, 0x0004003du, 0x00000006u, 0x0000005cu, 0x00000045u, - 0x0004003du, 0x00000006u, 0x0000005du, 0x00000051u, 0x00050083u, 0x00000006u, 0x0000005eu, 0x0000005cu, - 0x0000005du, 0x0006000cu, 0x00000006u, 0x0000005fu, 0x00000001u, 0x00000004u, 0x0000005eu, 0x000200feu, - 0x0000005fu, 0x00010038u, -}; diff --git a/app/src/main/cpp/shaders/smaa_tables.h b/app/src/main/cpp/shaders/smaa_tables.h new file mode 100644 index 0000000000..ebc28d815b --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_tables.h @@ -0,0 +1,1375 @@ +/** + * Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) + * Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com) + * Copyright (C) 2013 Belen Masia (bmasia@unizar.es) + * Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com) + * Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to + * do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. As clarification, there + * is no requirement that the copyright notice and permission be included in + * binary distributions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* SMAA's lookup tables, from Textures/AreaTex.h and Textures/SearchTex.h of github.com/iryoku/smaa. + * SMAA 1x reads only the first 80 of the area table's 560 rows; the other rows are not included. */ +#pragma once + +#define SMAA_AREA_W 160 +#define SMAA_AREA_H 560 +#define SMAA_AREA_ROWS 80 +#define SMAA_SEARCH_W 64 +#define SMAA_SEARCH_H 16 + +static const unsigned char kSmaaArea[SMAA_AREA_W * SMAA_AREA_ROWS * 2] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x40,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x44,0x7b,0x41,0x5d,0x42,0x54,0x41,0x4f,0x42,0x4b,0x42,0x49,0x42,0x48,0x41,0x47,0x42,0x46,0x42,0x45, + 0x42,0x45,0x42,0x44,0x42,0x44,0x42,0x44,0x42,0x43,0x41,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43, + 0x04,0x7f,0x22,0x3d,0x2b,0x3d,0x30,0x3d,0x33,0x3d,0x35,0x3d,0x37,0x3d,0x38,0x3d,0x39,0x3d,0x39,0x3d, + 0x3a,0x3d,0x3a,0x3d,0x3b,0x3d,0x3b,0x3d,0x3b,0x3d,0x3c,0x3d,0x3c,0x3d,0x3c,0x3d,0x3c,0x3d,0x3c,0x3d, + 0x40,0x7f,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x0a,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x0a,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x62,0x20,0x4d,0x2a,0x48,0x30,0x44,0x33,0x44,0x35,0x44,0x36,0x43,0x37,0x42,0x38,0x43,0x39,0x42,0x39, + 0x42,0x3a,0x42,0x3a,0x42,0x3b,0x42,0x3b,0x42,0x3b,0x41,0x3b,0x42,0x3c,0x42,0x3c,0x42,0x3c,0x42,0x3c, + 0x00,0x5d,0x0c,0x49,0x16,0x43,0x1d,0x41,0x22,0x40,0x26,0x3f,0x29,0x3f,0x2c,0x3f,0x2e,0x3e,0x2f,0x3e, + 0x31,0x3e,0x32,0x3e,0x33,0x3e,0x33,0x3e,0x34,0x3e,0x35,0x3e,0x35,0x3e,0x36,0x3e,0x37,0x3e,0x37,0x3e, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,0x3f,0x00,0x03,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,0x3f,0x00, + 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x6d,0x0b,0x57,0x16,0x4f,0x1d,0x4a,0x22,0x48,0x26,0x47,0x29,0x46,0x2b,0x44,0x2d,0x44,0x2f,0x44,0x30, + 0x44,0x31,0x44,0x32,0x43,0x33,0x43,0x34,0x43,0x34,0x42,0x35,0x43,0x36,0x42,0x36,0x42,0x37,0x42,0x37, + 0x00,0x68,0x06,0x54,0x0d,0x4b,0x14,0x47,0x19,0x44,0x1d,0x43,0x20,0x41,0x23,0x41,0x26,0x40,0x27,0x40, + 0x29,0x3f,0x2b,0x3f,0x2c,0x3f,0x2d,0x3f,0x2e,0x3f,0x2f,0x3f,0x30,0x3f,0x30,0x3e,0x31,0x3e,0x32,0x3e, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x00,0x5c,0x00,0x2d,0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x00,0x5c,0x00, + 0x2d,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x42,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x72,0x06,0x5f,0x0d,0x56,0x14,0x4f,0x19,0x4d,0x1d,0x4a,0x20,0x49,0x23,0x47,0x25,0x46,0x27,0x46,0x29, + 0x45,0x2a,0x45,0x2c,0x44,0x2d,0x44,0x2e,0x44,0x2f,0x43,0x30,0x44,0x30,0x44,0x31,0x43,0x32,0x43,0x33, + 0x00,0x6d,0x04,0x5b,0x09,0x51,0x0e,0x4c,0x13,0x48,0x17,0x46,0x1a,0x44,0x1d,0x43,0x1f,0x42,0x22,0x42, + 0x24,0x41,0x25,0x41,0x27,0x40,0x28,0x40,0x29,0x40,0x2a,0x3f,0x2b,0x3f,0x2c,0x3f,0x2d,0x3f,0x2e,0x3f, + 0x42,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x6a,0x00,0x48,0x00,0x22, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x6a,0x00, + 0x48,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x75,0x03,0x64,0x09,0x5a,0x0e,0x54,0x13,0x51,0x17,0x4e,0x1a,0x4c,0x1d,0x49,0x1f,0x49,0x22,0x48,0x23, + 0x47,0x25,0x46,0x26,0x46,0x28,0x45,0x29,0x45,0x2a,0x44,0x2b,0x44,0x2c,0x44,0x2d,0x44,0x2e,0x44,0x2e, + 0x00,0x70,0x02,0x60,0x07,0x56,0x0b,0x50,0x0f,0x4c,0x12,0x49,0x16,0x47,0x18,0x46,0x1b,0x45,0x1d,0x44, + 0x1f,0x43,0x21,0x42,0x22,0x42,0x24,0x41,0x25,0x41,0x26,0x40,0x27,0x40,0x28,0x40,0x29,0x40,0x2a,0x3f, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0x00,0x71,0x00,0x59,0x00,0x3a, + 0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0x00,0x71,0x00, + 0x59,0x00,0x3a,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x77,0x02,0x68,0x06,0x5f,0x0b,0x58,0x0f,0x54,0x12,0x51,0x15,0x4f,0x18,0x4c,0x1b,0x4b,0x1d,0x4a,0x1f, + 0x49,0x21,0x48,0x22,0x48,0x23,0x47,0x25,0x46,0x26,0x45,0x27,0x45,0x28,0x45,0x29,0x45,0x2a,0x44,0x2b, + 0x00,0x72,0x02,0x64,0x05,0x5b,0x08,0x54,0x0c,0x50,0x0f,0x4d,0x12,0x4a,0x14,0x48,0x17,0x47,0x19,0x46, + 0x1b,0x45,0x1d,0x44,0x1f,0x44,0x20,0x42,0x21,0x42,0x22,0x42,0x24,0x41,0x25,0x41,0x26,0x41,0x27,0x40, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x75,0x00,0x63,0x00,0x4a, + 0x00,0x30,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x75,0x00, + 0x63,0x00,0x4a,0x00,0x30,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x78,0x02,0x6b,0x05,0x62,0x08,0x5b,0x0c,0x57,0x0f,0x54,0x12,0x51,0x14,0x4e,0x17,0x4d,0x19,0x4c,0x1b, + 0x4b,0x1d,0x4a,0x1e,0x49,0x20,0x48,0x21,0x48,0x22,0x46,0x24,0x46,0x25,0x46,0x26,0x46,0x27,0x45,0x27, + 0x00,0x74,0x01,0x66,0x04,0x5e,0x07,0x57,0x0a,0x53,0x0d,0x4f,0x10,0x4d,0x12,0x4b,0x14,0x49,0x16,0x48, + 0x18,0x46,0x1a,0x45,0x1b,0x45,0x1d,0x44,0x1e,0x44,0x20,0x43,0x21,0x42,0x22,0x42,0x23,0x42,0x24,0x41, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x78,0x00,0x6a,0x00,0x56, + 0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x78,0x00, + 0x6a,0x00,0x56,0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x79,0x01,0x6d,0x04,0x65,0x07,0x5e,0x0a,0x5a,0x0d,0x56,0x0f,0x54,0x12,0x51,0x14,0x4f,0x16,0x4e,0x18, + 0x4c,0x1a,0x4b,0x1b,0x4b,0x1d,0x4a,0x1e,0x49,0x1f,0x48,0x21,0x48,0x22,0x48,0x23,0x47,0x23,0x46,0x25, + 0x00,0x75,0x01,0x69,0x03,0x61,0x06,0x5a,0x08,0x56,0x0b,0x52,0x0d,0x4f,0x10,0x4d,0x12,0x4b,0x14,0x4a, + 0x16,0x48,0x17,0x47,0x19,0x46,0x1a,0x45,0x1c,0x45,0x1d,0x44,0x1e,0x44,0x1f,0x44,0x20,0x43,0x21,0x42, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x79,0x00,0x6e,0x00,0x5e, + 0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x79,0x00, + 0x6e,0x00,0x5e,0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7a,0x01,0x6f,0x03,0x67,0x06,0x60,0x08,0x5d,0x0b,0x59,0x0d,0x56,0x10,0x53,0x11,0x51,0x14,0x50,0x15, + 0x4e,0x17,0x4d,0x19,0x4c,0x1a,0x4b,0x1b,0x4b,0x1d,0x48,0x1e,0x49,0x1f,0x49,0x20,0x48,0x21,0x48,0x22, + 0x00,0x76,0x01,0x6b,0x03,0x63,0x05,0x5d,0x07,0x58,0x09,0x54,0x0c,0x52,0x0e,0x4f,0x10,0x4d,0x11,0x4c, + 0x13,0x4a,0x15,0x49,0x17,0x48,0x18,0x47,0x19,0x46,0x1b,0x45,0x1c,0x45,0x1d,0x44,0x1e,0x44,0x1f,0x44, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x7a,0x00,0x72,0x00,0x64, + 0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x7a,0x00, + 0x72,0x00,0x64,0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7b,0x01,0x71,0x02,0x69,0x05,0x63,0x07,0x5f,0x09,0x5b,0x0c,0x58,0x0e,0x55,0x10,0x53,0x11,0x52,0x13, + 0x50,0x15,0x4e,0x16,0x4e,0x18,0x4c,0x19,0x4c,0x1a,0x4a,0x1c,0x4b,0x1d,0x49,0x1e,0x49,0x1f,0x49,0x20, + 0x00,0x77,0x00,0x6c,0x02,0x65,0x04,0x5f,0x06,0x5a,0x08,0x57,0x0a,0x54,0x0c,0x51,0x0e,0x4f,0x10,0x4d, + 0x11,0x4c,0x13,0x4a,0x15,0x49,0x16,0x48,0x18,0x48,0x18,0x46,0x1a,0x46,0x1b,0x45,0x1c,0x45,0x1d,0x45, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7b,0x00,0x74,0x00,0x69, + 0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7b,0x00, + 0x74,0x00,0x69,0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7b,0x00,0x72,0x02,0x6b,0x04,0x64,0x06,0x61,0x08,0x5d,0x0a,0x5a,0x0c,0x56,0x0e,0x55,0x10,0x53,0x11, + 0x52,0x13,0x50,0x15,0x4f,0x16,0x4e,0x17,0x4d,0x18,0x4b,0x1a,0x4b,0x1a,0x4b,0x1c,0x4b,0x1d,0x49,0x1d, + 0x00,0x77,0x00,0x6e,0x02,0x66,0x04,0x61,0x05,0x5c,0x07,0x59,0x09,0x56,0x0b,0x53,0x0d,0x51,0x0f,0x4f, + 0x10,0x4e,0x11,0x4c,0x13,0x4b,0x14,0x4a,0x15,0x48,0x17,0x48,0x18,0x47,0x19,0x46,0x1b,0x46,0x1b,0x45, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00,0x76,0x00,0x6d, + 0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x76,0x00,0x6d,0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7c,0x00,0x73,0x02,0x6c,0x03,0x66,0x05,0x63,0x07,0x5e,0x09,0x5c,0x0b,0x58,0x0c,0x57,0x0e,0x55,0x10, + 0x53,0x11,0x52,0x13,0x50,0x14,0x4f,0x15,0x4e,0x17,0x4c,0x18,0x4c,0x19,0x4c,0x1a,0x4b,0x1a,0x4b,0x1c, + 0x00,0x77,0x00,0x6f,0x02,0x68,0x03,0x63,0x05,0x5e,0x06,0x5a,0x08,0x57,0x0a,0x55,0x0b,0x53,0x0d,0x50, + 0x0f,0x4f,0x10,0x4e,0x11,0x4c,0x13,0x4b,0x14,0x4a,0x15,0x49,0x16,0x48,0x18,0x48,0x18,0x46,0x19,0x46, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00,0x77,0x00,0x6f, + 0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x77,0x00,0x6f,0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7c,0x00,0x74,0x02,0x6e,0x03,0x68,0x05,0x64,0x06,0x60,0x08,0x5d,0x0a,0x5a,0x0b,0x58,0x0d,0x56,0x0e, + 0x55,0x10,0x53,0x11,0x52,0x13,0x50,0x14,0x50,0x15,0x4d,0x16,0x4e,0x18,0x4c,0x18,0x4c,0x19,0x4c,0x1a, + 0x00,0x78,0x00,0x70,0x01,0x69,0x03,0x64,0x04,0x60,0x06,0x5c,0x07,0x59,0x09,0x56,0x0b,0x54,0x0c,0x52, + 0x0d,0x50,0x0f,0x4f,0x10,0x4e,0x11,0x4c,0x13,0x4b,0x13,0x4a,0x15,0x4a,0x15,0x48,0x17,0x48,0x18,0x47, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x78,0x00,0x71, + 0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00,0x0a,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x78,0x00,0x71,0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00, + 0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x75,0x01,0x6f,0x02,0x69,0x04,0x65,0x06,0x62,0x07,0x5f,0x09,0x5b,0x0b,0x5a,0x0c,0x58,0x0d, + 0x56,0x0e,0x55,0x10,0x53,0x11,0x52,0x13,0x50,0x13,0x4f,0x15,0x4e,0x15,0x4e,0x17,0x4d,0x18,0x4c,0x18, + 0x00,0x78,0x00,0x71,0x01,0x6a,0x03,0x66,0x04,0x61,0x05,0x5d,0x06,0x5a,0x08,0x58,0x09,0x55,0x0b,0x53, + 0x0d,0x52,0x0e,0x50,0x0f,0x4e,0x10,0x4e,0x11,0x4c,0x13,0x4c,0x13,0x4a,0x15,0x4a,0x15,0x49,0x16,0x48, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x79,0x00,0x73, + 0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00,0x13,0x00,0x09, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x79,0x00,0x73,0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00, + 0x13,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x76,0x01,0x70,0x02,0x6a,0x03,0x67,0x05,0x63,0x06,0x60,0x08,0x5d,0x09,0x5b,0x0b,0x59,0x0c, + 0x57,0x0d,0x55,0x0e,0x55,0x10,0x53,0x11,0x52,0x13,0x4f,0x13,0x50,0x15,0x4f,0x15,0x4e,0x16,0x4e,0x18, + 0x00,0x79,0x00,0x71,0x01,0x6c,0x02,0x66,0x04,0x62,0x05,0x5f,0x06,0x5c,0x07,0x59,0x09,0x57,0x0a,0x55, + 0x0b,0x53,0x0d,0x51,0x0e,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4c,0x13,0x4c,0x13,0x4b,0x14,0x4a,0x15,0x4a, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x7a,0x00,0x75, + 0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00,0x1b,0x00,0x12, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x7a,0x00,0x75,0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00, + 0x1b,0x00,0x12,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x76,0x01,0x71,0x02,0x6c,0x03,0x68,0x05,0x64,0x06,0x61,0x07,0x5e,0x09,0x5c,0x0a,0x5a,0x0b, + 0x59,0x0c,0x57,0x0e,0x55,0x0e,0x55,0x11,0x52,0x11,0x51,0x12,0x51,0x13,0x50,0x14,0x4f,0x15,0x4e,0x15, + 0x00,0x79,0x00,0x72,0x01,0x6d,0x02,0x68,0x03,0x63,0x04,0x60,0x06,0x5d,0x07,0x5b,0x08,0x58,0x09,0x56, + 0x0b,0x54,0x0c,0x53,0x0d,0x51,0x0e,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4c,0x12,0x4c,0x13,0x4b,0x14,0x4a, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x1f,0x00,0x3f,0x00,0x66,0x00,0x72,0x00,0x78,0x00,0x7a,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d, + 0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7d,0x00,0x58,0x00,0x70,0x00,0x77, + 0x00,0x79,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e, + 0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x1f,0x00,0x3f, + 0x00,0x66,0x00,0x72,0x00,0x78,0x00,0x7a,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e, + 0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x1f,0x1f,0x00,0x3f,0x00,0x66,0x00,0x72,0x00,0x78,0x00,0x7a, + 0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x77,0x01,0x72,0x02,0x6d,0x03,0x69,0x04,0x66,0x06,0x63,0x07,0x5f,0x08,0x5e,0x09,0x5c,0x0b, + 0x5a,0x0c,0x58,0x0c,0x57,0x0e,0x55,0x0f,0x54,0x11,0x51,0x11,0x52,0x12,0x51,0x13,0x50,0x14,0x50,0x15, + 0x00,0x79,0x00,0x73,0x01,0x6d,0x02,0x69,0x03,0x65,0x04,0x61,0x05,0x5e,0x06,0x5c,0x07,0x59,0x09,0x57, + 0x0a,0x55,0x0b,0x54,0x0d,0x53,0x0d,0x51,0x0f,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4c,0x12,0x4c,0x13,0x4b, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x0a,0x00,0x3f,0x00,0x5c,0x00,0x6a,0x00,0x71,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a, + 0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x00,0x58,0x00,0x44,0x00,0x55,0x00,0x67, + 0x00,0x6e,0x00,0x72,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d, + 0x00,0x7d,0x00,0x7d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x0a,0x0a, + 0x00,0x3f,0x00,0x5c,0x00,0x6a,0x00,0x71,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c, + 0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x3f,0x00,0x0a,0x0a,0x00,0x3f,0x00,0x5c,0x00,0x6a,0x00,0x71, + 0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x78,0x01,0x72,0x02,0x6e,0x02,0x6a,0x03,0x67,0x05,0x64,0x06,0x60,0x07,0x5f,0x09,0x5c,0x0a, + 0x5b,0x0b,0x5a,0x0c,0x57,0x0c,0x56,0x0e,0x55,0x0f,0x53,0x11,0x52,0x11,0x52,0x12,0x51,0x13,0x50,0x13, + 0x00,0x79,0x00,0x73,0x01,0x6e,0x02,0x69,0x03,0x66,0x04,0x62,0x05,0x5f,0x06,0x5d,0x07,0x5b,0x08,0x58, + 0x09,0x56,0x0b,0x55,0x0b,0x53,0x0d,0x52,0x0d,0x50,0x0f,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4d,0x12,0x4c, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x2d,0x00,0x48,0x00,0x59,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72, + 0x00,0x74,0x00,0x76,0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x70,0x00,0x55,0x00,0x20,0x00,0x3e, + 0x00,0x50,0x00,0x5a,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76,0x00,0x77,0x00,0x78, + 0x00,0x79,0x00,0x7a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,0x3f,0x00, + 0x03,0x03,0x00,0x2d,0x00,0x48,0x00,0x59,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76, + 0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x66,0x00,0x3f,0x00,0x03,0x03,0x00,0x2d,0x00,0x48,0x00,0x59, + 0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76,0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7e,0x00,0x78,0x01,0x73,0x02,0x6e,0x02,0x6b,0x03,0x68,0x05,0x65,0x06,0x61,0x07,0x5f,0x07,0x5e,0x09, + 0x5c,0x0b,0x5a,0x0b,0x59,0x0c,0x57,0x0d,0x56,0x0e,0x54,0x0f,0x54,0x11,0x52,0x11,0x52,0x12,0x51,0x13, + 0x00,0x79,0x00,0x74,0x00,0x6f,0x02,0x6a,0x03,0x66,0x04,0x63,0x05,0x60,0x05,0x5e,0x06,0x5b,0x07,0x59, + 0x09,0x58,0x09,0x55,0x0b,0x55,0x0c,0x53,0x0d,0x52,0x0d,0x50,0x0f,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4d, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x22,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64, + 0x00,0x69,0x00,0x6d,0x00,0x6f,0x00,0x71,0x00,0x73,0x00,0x75,0x00,0x77,0x00,0x67,0x00,0x3e,0x00,0x0d, + 0x00,0x28,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d,0x00,0x6f,0x00,0x71, + 0x00,0x73,0x00,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x00,0x5c,0x00, + 0x2d,0x00,0x01,0x01,0x00,0x22,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d, + 0x00,0x6f,0x00,0x71,0x00,0x73,0x00,0x75,0x72,0x00,0x5c,0x00,0x2d,0x00,0x01,0x01,0x00,0x22,0x00,0x3a, + 0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d,0x00,0x6f,0x00,0x71,0x00,0x73,0x00,0x75, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7e,0x00,0x78,0x00,0x74,0x01,0x6f,0x02,0x6c,0x03,0x68,0x04,0x65,0x05,0x62,0x06,0x61,0x07,0x5f,0x09, + 0x5c,0x09,0x5b,0x0b,0x5a,0x0b,0x58,0x0c,0x57,0x0d,0x55,0x0e,0x55,0x0f,0x54,0x11,0x52,0x11,0x52,0x12, + 0x00,0x79,0x00,0x74,0x00,0x70,0x01,0x6b,0x02,0x67,0x03,0x64,0x04,0x61,0x05,0x5f,0x06,0x5d,0x07,0x5b, + 0x08,0x58,0x09,0x57,0x0a,0x55,0x0b,0x54,0x0c,0x53,0x0d,0x51,0x0e,0x50,0x0f,0x50,0x0f,0x4e,0x11,0x4e, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54, + 0x00,0x5b,0x00,0x61,0x00,0x65,0x00,0x68,0x00,0x6b,0x00,0x6e,0x00,0x79,0x00,0x6e,0x00,0x50,0x00,0x28, + 0x00,0x01,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61,0x00,0x65,0x00,0x68, + 0x00,0x6b,0x00,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x6a,0x00, + 0x48,0x00,0x22,0x00,0x00,0x00,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61, + 0x00,0x65,0x00,0x68,0x00,0x6b,0x00,0x6e,0x78,0x00,0x6a,0x00,0x48,0x00,0x22,0x00,0x00,0x00,0x00,0x1b, + 0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61,0x00,0x65,0x00,0x68,0x00,0x6b,0x00,0x6e, + 0x21,0x5d,0x0c,0x68,0x06,0x6d,0x04,0x71,0x02,0x72,0x02,0x74,0x01,0x75,0x01,0x76,0x01,0x77,0x00,0x77, + 0x00,0x77,0x00,0x78,0x00,0x78,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x7a, + 0x42,0x40,0x17,0x55,0x0c,0x60,0x08,0x66,0x05,0x6a,0x04,0x6d,0x03,0x6f,0x02,0x71,0x02,0x73,0x01,0x73, + 0x01,0x74,0x01,0x75,0x01,0x76,0x01,0x77,0x00,0x77,0x00,0x77,0x00,0x78,0x00,0x78,0x00,0x78,0x00,0x78, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x21,0x5d,0x0c,0x68,0x06,0x6d,0x04,0x71,0x02,0x72,0x02,0x74,0x01,0x75,0x01,0x76,0x01,0x77,0x00,0x77, + 0x00,0x77,0x00,0x78,0x00,0x78,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x79,0x00,0x7a, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42, + 0x00,0x4b,0x00,0x53,0x00,0x59,0x00,0x5e,0x00,0x62,0x00,0x65,0x00,0x7b,0x00,0x72,0x00,0x5a,0x00,0x3a, + 0x00,0x1b,0x00,0x01,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53,0x00,0x59,0x00,0x5e, + 0x00,0x62,0x00,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0x00,0x71,0x00, + 0x59,0x00,0x3a,0x00,0x1b,0x00,0x00,0x00,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53, + 0x00,0x59,0x00,0x5e,0x00,0x62,0x00,0x65,0x7a,0x00,0x71,0x00,0x59,0x00,0x3a,0x00,0x1b,0x00,0x00,0x00, + 0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53,0x00,0x59,0x00,0x5e,0x00,0x62,0x00,0x65, + 0x2b,0x49,0x16,0x53,0x0d,0x5b,0x09,0x60,0x07,0x64,0x05,0x67,0x04,0x69,0x03,0x6b,0x03,0x6c,0x02,0x6e, + 0x02,0x6f,0x02,0x70,0x01,0x71,0x01,0x71,0x01,0x72,0x01,0x73,0x01,0x73,0x01,0x74,0x00,0x74,0x00,0x75, + 0x57,0x16,0x2d,0x2c,0x1b,0x3b,0x12,0x45,0x0d,0x4d,0x0b,0x53,0x08,0x57,0x07,0x5b,0x05,0x5e,0x05,0x61, + 0x04,0x63,0x04,0x65,0x03,0x67,0x02,0x68,0x02,0x69,0x02,0x6b,0x02,0x6c,0x01,0x6d,0x01,0x6e,0x01,0x6f, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x2b,0x49,0x16,0x53,0x0d,0x5b,0x09,0x60,0x07,0x64,0x05,0x67,0x04,0x69,0x03,0x6b,0x03,0x6c,0x02,0x6e, + 0x02,0x6f,0x02,0x70,0x01,0x71,0x01,0x71,0x01,0x72,0x01,0x73,0x01,0x73,0x01,0x74,0x00,0x74,0x00,0x75, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30, + 0x00,0x3b,0x00,0x44,0x00,0x4c,0x00,0x52,0x00,0x57,0x00,0x5b,0x00,0x7c,0x00,0x75,0x00,0x63,0x00,0x4a, + 0x00,0x30,0x00,0x16,0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44,0x00,0x4c,0x00,0x52, + 0x00,0x57,0x00,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x75,0x00, + 0x63,0x00,0x4a,0x00,0x30,0x00,0x16,0x00,0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44, + 0x00,0x4c,0x00,0x52,0x00,0x57,0x00,0x5b,0x7c,0x00,0x75,0x00,0x63,0x00,0x4a,0x00,0x30,0x00,0x16,0x00, + 0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44,0x00,0x4c,0x00,0x52,0x00,0x57,0x00,0x5b, + 0x31,0x43,0x1d,0x4b,0x14,0x51,0x0e,0x56,0x0b,0x5b,0x08,0x5e,0x07,0x61,0x06,0x63,0x05,0x65,0x04,0x67, + 0x04,0x68,0x03,0x69,0x03,0x6a,0x03,0x6c,0x02,0x6d,0x02,0x6d,0x02,0x6e,0x02,0x6f,0x02,0x70,0x01,0x70, + 0x61,0x0c,0x3b,0x1b,0x28,0x28,0x1d,0x32,0x16,0x3a,0x11,0x41,0x0e,0x47,0x0c,0x4b,0x0a,0x4f,0x09,0x53, + 0x07,0x55,0x06,0x58,0x05,0x5a,0x05,0x5c,0x05,0x5e,0x04,0x60,0x04,0x61,0x04,0x63,0x03,0x64,0x02,0x66, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x31,0x43,0x1d,0x4b,0x14,0x51,0x0e,0x56,0x0b,0x5b,0x08,0x5e,0x07,0x61,0x06,0x63,0x05,0x65,0x04,0x67, + 0x04,0x68,0x03,0x69,0x03,0x6a,0x03,0x6c,0x02,0x6d,0x02,0x6d,0x02,0x6e,0x02,0x6f,0x02,0x70,0x01,0x70, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x1f, + 0x00,0x2b,0x00,0x35,0x00,0x3e,0x00,0x45,0x00,0x4c,0x00,0x51,0x00,0x7c,0x00,0x78,0x00,0x6a,0x00,0x56, + 0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35,0x00,0x3e,0x00,0x45, + 0x00,0x4c,0x00,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x78,0x00, + 0x6a,0x00,0x56,0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35, + 0x00,0x3e,0x00,0x45,0x00,0x4c,0x00,0x51,0x7c,0x00,0x78,0x00,0x6a,0x00,0x56,0x00,0x3f,0x00,0x28,0x00, + 0x13,0x00,0x00,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35,0x00,0x3e,0x00,0x45,0x00,0x4c,0x00,0x51, + 0x33,0x41,0x22,0x46,0x19,0x4c,0x13,0x50,0x0f,0x54,0x0c,0x57,0x0a,0x5a,0x08,0x5d,0x07,0x5f,0x06,0x61, + 0x05,0x63,0x05,0x64,0x04,0x66,0x04,0x66,0x04,0x68,0x03,0x69,0x03,0x69,0x03,0x6a,0x03,0x6b,0x02,0x6c, + 0x67,0x07,0x45,0x12,0x32,0x1d,0x26,0x26,0x1e,0x2e,0x18,0x34,0x14,0x3a,0x11,0x3f,0x0f,0x44,0x0c,0x47, + 0x0b,0x4b,0x0a,0x4d,0x09,0x51,0x07,0x52,0x07,0x55,0x06,0x57,0x05,0x58,0x05,0x5a,0x05,0x5c,0x04,0x5d, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x33,0x41,0x22,0x46,0x19,0x4c,0x13,0x50,0x0f,0x54,0x0c,0x57,0x0a,0x5a,0x08,0x5d,0x07,0x5f,0x06,0x61, + 0x05,0x63,0x05,0x64,0x04,0x66,0x04,0x66,0x04,0x68,0x03,0x69,0x03,0x69,0x03,0x6a,0x03,0x6b,0x02,0x6c, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e, + 0x00,0x1b,0x00,0x27,0x00,0x30,0x00,0x39,0x00,0x40,0x00,0x46,0x00,0x7d,0x00,0x79,0x00,0x6e,0x00,0x5e, + 0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27,0x00,0x30,0x00,0x39, + 0x00,0x40,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x79,0x00, + 0x6e,0x00,0x5e,0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27, + 0x00,0x30,0x00,0x39,0x00,0x40,0x00,0x46,0x7d,0x00,0x79,0x00,0x6e,0x00,0x5e,0x00,0x4b,0x00,0x37,0x00, + 0x23,0x00,0x10,0x00,0x00,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27,0x00,0x30,0x00,0x39,0x00,0x40,0x00,0x46, + 0x35,0x40,0x27,0x44,0x1d,0x48,0x17,0x4c,0x12,0x50,0x0f,0x53,0x0d,0x56,0x0b,0x58,0x09,0x5a,0x08,0x5c, + 0x07,0x5e,0x06,0x60,0x06,0x61,0x05,0x62,0x05,0x63,0x04,0x65,0x04,0x66,0x04,0x66,0x04,0x67,0x03,0x68, + 0x6b,0x05,0x4d,0x0d,0x3b,0x16,0x2e,0x1e,0x25,0x25,0x1f,0x2b,0x1a,0x31,0x16,0x36,0x13,0x3a,0x10,0x3e, + 0x0f,0x42,0x0d,0x45,0x0c,0x47,0x0a,0x4a,0x0a,0x4c,0x09,0x4f,0x07,0x51,0x07,0x52,0x07,0x54,0x06,0x56, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x35,0x40,0x27,0x44,0x1d,0x48,0x17,0x4c,0x12,0x50,0x0f,0x53,0x0d,0x56,0x0b,0x58,0x09,0x5a,0x08,0x5c, + 0x07,0x5e,0x06,0x60,0x06,0x61,0x05,0x62,0x05,0x63,0x04,0x65,0x04,0x66,0x04,0x66,0x04,0x67,0x03,0x68, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x0d,0x00,0x19,0x00,0x23,0x00,0x2c,0x00,0x34,0x00,0x3b,0x00,0x7d,0x00,0x7a,0x00,0x72,0x00,0x64, + 0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x0d,0x00,0x19,0x00,0x23,0x00,0x2c, + 0x00,0x34,0x00,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x7a,0x00, + 0x72,0x00,0x64,0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x00,0x0d,0x00,0x19, + 0x00,0x23,0x00,0x2c,0x00,0x34,0x00,0x3b,0x7d,0x00,0x7a,0x00,0x72,0x00,0x64,0x00,0x54,0x00,0x42,0x00, + 0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x00,0x0d,0x00,0x19,0x00,0x23,0x00,0x2c,0x00,0x34,0x00,0x3b, + 0x37,0x3f,0x29,0x43,0x21,0x46,0x1a,0x49,0x16,0x4d,0x12,0x50,0x10,0x52,0x0d,0x54,0x0c,0x57,0x0a,0x59, + 0x09,0x5a,0x08,0x5c,0x07,0x5d,0x06,0x5f,0x06,0x60,0x06,0x61,0x05,0x62,0x05,0x63,0x04,0x64,0x04,0x65, + 0x6e,0x04,0x53,0x0a,0x41,0x11,0x34,0x18,0x2b,0x1f,0x24,0x24,0x1f,0x29,0x1b,0x2e,0x17,0x33,0x15,0x37, + 0x12,0x3a,0x10,0x3d,0x0f,0x40,0x0d,0x43,0x0c,0x45,0x0c,0x48,0x0a,0x4a,0x0a,0x4c,0x09,0x4e,0x07,0x4f, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x37,0x3f,0x29,0x43,0x21,0x46,0x1a,0x49,0x16,0x4d,0x12,0x50,0x10,0x52,0x0d,0x54,0x0c,0x57,0x0a,0x59, + 0x09,0x5a,0x08,0x5c,0x07,0x5d,0x06,0x5f,0x06,0x60,0x06,0x61,0x05,0x62,0x05,0x63,0x04,0x64,0x04,0x65, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x0c,0x00,0x16,0x00,0x20,0x00,0x29,0x00,0x30,0x00,0x7e,0x00,0x7b,0x00,0x74,0x00,0x69, + 0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x0c,0x00,0x16,0x00,0x20, + 0x00,0x29,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7b,0x00, + 0x74,0x00,0x69,0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x00,0x0c, + 0x00,0x16,0x00,0x20,0x00,0x29,0x00,0x30,0x7e,0x00,0x7b,0x00,0x74,0x00,0x69,0x00,0x5b,0x00,0x4b,0x00, + 0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x00,0x0c,0x00,0x16,0x00,0x20,0x00,0x29,0x00,0x30, + 0x38,0x3f,0x2c,0x41,0x23,0x44,0x1d,0x47,0x19,0x4a,0x14,0x4d,0x12,0x4f,0x10,0x52,0x0e,0x54,0x0c,0x56, + 0x0b,0x57,0x0a,0x59,0x09,0x5a,0x08,0x5c,0x07,0x5d,0x07,0x5e,0x06,0x5f,0x06,0x61,0x05,0x61,0x05,0x62, + 0x70,0x03,0x58,0x08,0x47,0x0e,0x3a,0x14,0x31,0x1a,0x29,0x1f,0x24,0x24,0x20,0x28,0x1c,0x2d,0x19,0x31, + 0x16,0x34,0x14,0x37,0x12,0x3a,0x10,0x3d,0x0f,0x3f,0x0e,0x42,0x0c,0x44,0x0c,0x46,0x0b,0x47,0x0a,0x4a, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x38,0x3f,0x2c,0x41,0x23,0x44,0x1d,0x47,0x19,0x4a,0x14,0x4d,0x12,0x4f,0x10,0x52,0x0e,0x54,0x0c,0x56, + 0x0b,0x57,0x0a,0x59,0x09,0x5a,0x08,0x5c,0x07,0x5d,0x07,0x5e,0x06,0x5f,0x06,0x61,0x05,0x61,0x05,0x62, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x15,0x00,0x1e,0x00,0x26,0x00,0x7e,0x00,0x7c,0x00,0x76,0x00,0x6d, + 0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00,0x0b,0x00,0x15, + 0x00,0x1e,0x00,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x76,0x00,0x6d,0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00, + 0x00,0x0b,0x00,0x15,0x00,0x1e,0x00,0x26,0x7e,0x00,0x7c,0x00,0x76,0x00,0x6d,0x00,0x61,0x00,0x53,0x00, + 0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00,0x00,0x0b,0x00,0x15,0x00,0x1e,0x00,0x26, + 0x39,0x3f,0x2e,0x41,0x26,0x43,0x20,0x46,0x1b,0x48,0x17,0x4b,0x14,0x4d,0x12,0x4f,0x10,0x51,0x0e,0x53, + 0x0d,0x55,0x0b,0x56,0x0b,0x58,0x09,0x59,0x09,0x5b,0x08,0x5b,0x07,0x5d,0x07,0x5e,0x06,0x5f,0x06,0x60, + 0x71,0x02,0x5b,0x07,0x4c,0x0c,0x3f,0x11,0x36,0x16,0x2e,0x1b,0x29,0x20,0x24,0x23,0x20,0x28,0x1d,0x2b, + 0x19,0x2f,0x17,0x32,0x16,0x35,0x12,0x37,0x12,0x3a,0x10,0x3c,0x0f,0x3f,0x0e,0x41,0x0c,0x42,0x0c,0x45, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x39,0x3f,0x2e,0x41,0x26,0x43,0x20,0x46,0x1b,0x48,0x17,0x4b,0x14,0x4d,0x12,0x4f,0x10,0x51,0x0e,0x53, + 0x0d,0x55,0x0b,0x56,0x0b,0x58,0x09,0x59,0x09,0x5b,0x08,0x5b,0x07,0x5d,0x07,0x5e,0x06,0x5f,0x06,0x60, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x13,0x00,0x1b,0x00,0x7e,0x00,0x7c,0x00,0x77,0x00,0x6f, + 0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00,0x00,0x00,0x0a, + 0x00,0x13,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x77,0x00,0x6f,0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00, + 0x00,0x00,0x00,0x0a,0x00,0x13,0x00,0x1b,0x7e,0x00,0x7c,0x00,0x77,0x00,0x6f,0x00,0x65,0x00,0x59,0x00, + 0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00,0x00,0x00,0x00,0x0a,0x00,0x13,0x00,0x1b, + 0x39,0x3e,0x2f,0x40,0x28,0x42,0x22,0x45,0x1d,0x47,0x19,0x49,0x16,0x4b,0x14,0x4d,0x11,0x4f,0x10,0x51, + 0x0f,0x53,0x0d,0x54,0x0c,0x55,0x0b,0x57,0x0a,0x58,0x09,0x59,0x09,0x5b,0x08,0x5b,0x07,0x5c,0x07,0x5e, + 0x73,0x02,0x5e,0x05,0x4f,0x0a,0x44,0x0f,0x3a,0x13,0x33,0x18,0x2d,0x1c,0x27,0x20,0x23,0x23,0x20,0x27, + 0x1d,0x2a,0x1a,0x2d,0x18,0x30,0x16,0x33,0x14,0x35,0x12,0x38,0x12,0x3a,0x10,0x3c,0x0f,0x3e,0x0f,0x41, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x39,0x3e,0x2f,0x40,0x28,0x42,0x22,0x45,0x1d,0x47,0x19,0x49,0x16,0x4b,0x14,0x4d,0x11,0x4f,0x10,0x51, + 0x0f,0x53,0x0d,0x54,0x0c,0x55,0x0b,0x57,0x0a,0x58,0x09,0x59,0x09,0x5b,0x08,0x5b,0x07,0x5c,0x07,0x5e, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x12,0x00,0x7e,0x00,0x7d,0x00,0x78,0x00,0x71, + 0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00,0x0a,0x00,0x00, + 0x00,0x09,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x78,0x00,0x71,0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00, + 0x0a,0x00,0x00,0x00,0x00,0x09,0x00,0x12,0x7e,0x00,0x7d,0x00,0x78,0x00,0x71,0x00,0x68,0x00,0x5e,0x00, + 0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00,0x0a,0x00,0x00,0x00,0x00,0x09,0x00,0x12, + 0x3a,0x3e,0x31,0x40,0x29,0x42,0x23,0x44,0x1f,0x46,0x1b,0x48,0x18,0x4a,0x15,0x4c,0x13,0x4d,0x11,0x4f, + 0x10,0x50,0x0f,0x52,0x0d,0x53,0x0d,0x55,0x0b,0x56,0x0b,0x57,0x0a,0x58,0x09,0x59,0x09,0x5b,0x08,0x5b, + 0x74,0x01,0x62,0x05,0x53,0x08,0x47,0x0c,0x3e,0x11,0x37,0x15,0x31,0x19,0x2b,0x1d,0x27,0x20,0x23,0x23, + 0x20,0x26,0x1d,0x2a,0x1b,0x2c,0x19,0x2f,0x16,0x31,0x16,0x34,0x13,0x35,0x12,0x38,0x12,0x3b,0x0f,0x3b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3a,0x3e,0x31,0x40,0x29,0x42,0x23,0x44,0x1f,0x46,0x1b,0x48,0x18,0x4a,0x15,0x4c,0x13,0x4d,0x11,0x4f, + 0x10,0x50,0x0f,0x52,0x0d,0x53,0x0d,0x55,0x0b,0x56,0x0b,0x57,0x0a,0x58,0x09,0x59,0x09,0x5b,0x08,0x5b, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x7e,0x00,0x7d,0x00,0x79,0x00,0x73, + 0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00,0x13,0x00,0x09, + 0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x79,0x00,0x73,0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00, + 0x13,0x00,0x09,0x00,0x00,0x00,0x00,0x08,0x7e,0x00,0x7d,0x00,0x79,0x00,0x73,0x00,0x6b,0x00,0x62,0x00, + 0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00,0x13,0x00,0x09,0x00,0x00,0x00,0x00,0x08, + 0x3a,0x3e,0x32,0x3f,0x2b,0x41,0x25,0x43,0x21,0x45,0x1d,0x46,0x1a,0x48,0x17,0x4a,0x15,0x4c,0x13,0x4e, + 0x11,0x4f,0x10,0x50,0x0f,0x52,0x0e,0x53,0x0d,0x54,0x0c,0x55,0x0b,0x56,0x0b,0x58,0x09,0x58,0x09,0x59, + 0x75,0x01,0x64,0x04,0x56,0x07,0x4b,0x0b,0x42,0x0f,0x3a,0x12,0x34,0x16,0x2f,0x19,0x2a,0x1d,0x26,0x20, + 0x23,0x23,0x21,0x26,0x1d,0x29,0x1b,0x2b,0x19,0x2e,0x18,0x30,0x16,0x32,0x15,0x35,0x12,0x35,0x12,0x38, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3a,0x3e,0x32,0x3f,0x2b,0x41,0x25,0x43,0x21,0x45,0x1d,0x46,0x1a,0x48,0x17,0x4a,0x15,0x4c,0x13,0x4e, + 0x11,0x4f,0x10,0x50,0x0f,0x52,0x0e,0x53,0x0d,0x54,0x0c,0x55,0x0b,0x56,0x0b,0x58,0x09,0x58,0x09,0x59, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x7a,0x00,0x75, + 0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00,0x1b,0x00,0x12, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x7a,0x00,0x75,0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00, + 0x1b,0x00,0x12,0x00,0x08,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x7a,0x00,0x75,0x00,0x6e,0x00,0x65,0x00, + 0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00,0x1b,0x00,0x12,0x00,0x08,0x00,0x00,0x00, + 0x3b,0x3e,0x33,0x3f,0x2c,0x41,0x27,0x42,0x22,0x44,0x1f,0x45,0x1c,0x47,0x19,0x49,0x17,0x4a,0x15,0x4c, + 0x13,0x4e,0x11,0x4f,0x10,0x50,0x0f,0x51,0x0e,0x53,0x0d,0x54,0x0c,0x55,0x0b,0x55,0x0b,0x57,0x0a,0x58, + 0x76,0x01,0x66,0x04,0x58,0x06,0x4d,0x0a,0x45,0x0d,0x3e,0x10,0x37,0x14,0x32,0x17,0x2d,0x1a,0x2a,0x1d, + 0x26,0x21,0x22,0x22,0x21,0x26,0x1d,0x28,0x1c,0x2b,0x19,0x2c,0x19,0x30,0x16,0x30,0x16,0x33,0x14,0x35, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3b,0x3e,0x33,0x3f,0x2c,0x41,0x27,0x42,0x22,0x44,0x1f,0x45,0x1c,0x47,0x19,0x49,0x17,0x4a,0x15,0x4c, + 0x13,0x4e,0x11,0x4f,0x10,0x50,0x0f,0x51,0x0e,0x53,0x0d,0x54,0x0c,0x55,0x0b,0x55,0x0b,0x57,0x0a,0x58, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x3e,0x33,0x3f,0x2d,0x40,0x28,0x42,0x24,0x44,0x20,0x45,0x1d,0x46,0x1a,0x48,0x18,0x49,0x16,0x4b, + 0x14,0x4c,0x13,0x4e,0x11,0x4e,0x10,0x50,0x0f,0x51,0x0f,0x53,0x0d,0x53,0x0d,0x55,0x0b,0x55,0x0b,0x56, + 0x77,0x01,0x67,0x03,0x5a,0x05,0x51,0x09,0x48,0x0c,0x40,0x0f,0x3a,0x12,0x35,0x16,0x30,0x18,0x2c,0x1b, + 0x29,0x1d,0x26,0x21,0x22,0x22,0x21,0x26,0x1d,0x27,0x1d,0x2b,0x1a,0x2b,0x19,0x2e,0x17,0x30,0x16,0x31, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3b,0x3e,0x33,0x3f,0x2d,0x40,0x28,0x42,0x24,0x44,0x20,0x45,0x1d,0x46,0x1a,0x48,0x18,0x49,0x16,0x4b, + 0x14,0x4c,0x13,0x4e,0x11,0x4e,0x10,0x50,0x0f,0x51,0x0f,0x53,0x0d,0x53,0x0d,0x55,0x0b,0x55,0x0b,0x56, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3b,0x3e,0x34,0x3f,0x2e,0x40,0x29,0x41,0x25,0x43,0x21,0x44,0x1e,0x45,0x1c,0x47,0x19,0x48,0x18,0x4a, + 0x15,0x4b,0x14,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x52,0x0d,0x53,0x0d,0x54,0x0c,0x55, + 0x77,0x01,0x68,0x02,0x5d,0x05,0x52,0x07,0x4a,0x0a,0x43,0x0d,0x3d,0x10,0x38,0x12,0x33,0x16,0x2f,0x19, + 0x2b,0x1b,0x28,0x1d,0x26,0x21,0x22,0x22,0x21,0x26,0x1e,0x26,0x1d,0x2a,0x1a,0x2b,0x19,0x2d,0x18,0x30, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3b,0x3e,0x34,0x3f,0x2e,0x40,0x29,0x41,0x25,0x43,0x21,0x44,0x1e,0x45,0x1c,0x47,0x19,0x48,0x18,0x4a, + 0x15,0x4b,0x14,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x52,0x0d,0x53,0x0d,0x54,0x0c,0x55, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x3e,0x35,0x3f,0x2f,0x40,0x2a,0x41,0x26,0x42,0x22,0x44,0x20,0x45,0x1d,0x46,0x1b,0x48,0x18,0x48, + 0x17,0x4a,0x15,0x4b,0x13,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x52,0x0d,0x53,0x0d,0x53, + 0x77,0x00,0x6a,0x02,0x5e,0x04,0x55,0x07,0x4c,0x0a,0x45,0x0c,0x40,0x0f,0x3a,0x12,0x35,0x14,0x31,0x16, + 0x2e,0x19,0x2b,0x1c,0x27,0x1d,0x26,0x22,0x21,0x22,0x21,0x25,0x1e,0x26,0x1d,0x29,0x1b,0x2b,0x19,0x2b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3c,0x3e,0x35,0x3f,0x2f,0x40,0x2a,0x41,0x26,0x42,0x22,0x44,0x20,0x45,0x1d,0x46,0x1b,0x48,0x18,0x48, + 0x17,0x4a,0x15,0x4b,0x13,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x52,0x0d,0x53,0x0d,0x53, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x3e,0x35,0x3f,0x30,0x3f,0x2b,0x40,0x27,0x42,0x24,0x43,0x21,0x44,0x1e,0x45,0x1c,0x46,0x1a,0x48, + 0x18,0x49,0x16,0x4a,0x15,0x4c,0x13,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x51,0x0e,0x53, + 0x78,0x00,0x6b,0x02,0x60,0x04,0x57,0x06,0x4f,0x09,0x48,0x0c,0x42,0x0e,0x3c,0x10,0x38,0x12,0x34,0x16, + 0x30,0x18,0x2d,0x19,0x2b,0x1d,0x26,0x1e,0x25,0x22,0x21,0x22,0x21,0x25,0x1e,0x26,0x1d,0x28,0x1c,0x2b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3c,0x3e,0x35,0x3f,0x30,0x3f,0x2b,0x40,0x27,0x42,0x24,0x43,0x21,0x44,0x1e,0x45,0x1c,0x46,0x1a,0x48, + 0x18,0x49,0x16,0x4a,0x15,0x4c,0x13,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x51,0x0e,0x53, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x3e,0x36,0x3f,0x30,0x3f,0x2c,0x40,0x28,0x41,0x25,0x42,0x22,0x44,0x1f,0x45,0x1d,0x46,0x1b,0x47, + 0x19,0x48,0x18,0x4a,0x15,0x4a,0x15,0x4c,0x13,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x51, + 0x78,0x00,0x6d,0x02,0x61,0x04,0x58,0x05,0x51,0x07,0x4a,0x0a,0x44,0x0c,0x3f,0x0f,0x3a,0x12,0x35,0x14, + 0x32,0x16,0x30,0x19,0x2b,0x19,0x2a,0x1d,0x26,0x1e,0x25,0x22,0x21,0x22,0x21,0x25,0x1e,0x26,0x1d,0x27, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3c,0x3e,0x36,0x3f,0x30,0x3f,0x2c,0x40,0x28,0x41,0x25,0x42,0x22,0x44,0x1f,0x45,0x1d,0x46,0x1b,0x47, + 0x19,0x48,0x18,0x4a,0x15,0x4a,0x15,0x4c,0x13,0x4c,0x13,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50,0x0f,0x51, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x3e,0x37,0x3e,0x31,0x3f,0x2d,0x40,0x29,0x41,0x26,0x42,0x23,0x44,0x20,0x45,0x1e,0x45,0x1c,0x46, + 0x1a,0x48,0x18,0x48,0x17,0x4a,0x15,0x4a,0x14,0x4c,0x13,0x4c,0x12,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50, + 0x78,0x00,0x6d,0x02,0x63,0x04,0x5a,0x05,0x53,0x07,0x4c,0x0a,0x46,0x0c,0x41,0x0f,0x3c,0x0f,0x38,0x12, + 0x35,0x16,0x30,0x16,0x2e,0x19,0x2b,0x1a,0x29,0x1d,0x26,0x1e,0x25,0x22,0x21,0x22,0x21,0x25,0x1f,0x26, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3c,0x3e,0x37,0x3e,0x31,0x3f,0x2d,0x40,0x29,0x41,0x26,0x42,0x23,0x44,0x20,0x45,0x1e,0x45,0x1c,0x46, + 0x1a,0x48,0x18,0x48,0x17,0x4a,0x15,0x4a,0x14,0x4c,0x13,0x4c,0x12,0x4e,0x11,0x4e,0x11,0x50,0x0f,0x50, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x3e,0x37,0x3e,0x32,0x3f,0x2e,0x40,0x2a,0x41,0x27,0x42,0x24,0x43,0x21,0x44,0x1f,0x45,0x1d,0x46, + 0x1b,0x47,0x1a,0x48,0x18,0x49,0x16,0x4a,0x15,0x4b,0x14,0x4c,0x13,0x4d,0x12,0x4e,0x11,0x4e,0x11,0x50, + 0x78,0x00,0x6e,0x01,0x65,0x03,0x5c,0x05,0x54,0x07,0x4e,0x09,0x48,0x0b,0x43,0x0c,0x3e,0x0f,0x3b,0x12, + 0x36,0x12,0x33,0x16,0x30,0x17,0x2d,0x19,0x2b,0x1b,0x28,0x1d,0x26,0x1e,0x25,0x22,0x21,0x22,0x21,0x24, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3c,0x3e,0x37,0x3e,0x32,0x3f,0x2e,0x40,0x2a,0x41,0x27,0x42,0x24,0x43,0x21,0x44,0x1f,0x45,0x1d,0x46, + 0x1b,0x47,0x1a,0x48,0x18,0x49,0x16,0x4a,0x15,0x4b,0x14,0x4c,0x13,0x4d,0x12,0x4e,0x11,0x4e,0x11,0x50, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x3c,0x3e,0x37,0x3e,0x33,0x3f,0x2e,0x3f,0x2b,0x40,0x28,0x41,0x25,0x42,0x22,0x44,0x20,0x45,0x1e,0x45, + 0x1c,0x46,0x1b,0x48,0x19,0x48,0x18,0x4a,0x16,0x4a,0x15,0x4b,0x13,0x4c,0x13,0x4d,0x12,0x4e,0x11,0x4e, + 0x79,0x00,0x6f,0x01,0x66,0x02,0x5d,0x04,0x56,0x06,0x4f,0x07,0x4a,0x0a,0x45,0x0c,0x41,0x0f,0x3b,0x0f, + 0x38,0x12,0x35,0x14,0x31,0x16,0x30,0x18,0x2b,0x19,0x2b,0x1c,0x27,0x1d,0x26,0x1f,0x24,0x22,0x21,0x22, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b,0x00,0x7b, + 0x3c,0x3e,0x37,0x3e,0x33,0x3f,0x2e,0x3f,0x2b,0x40,0x28,0x41,0x25,0x42,0x22,0x44,0x20,0x45,0x1e,0x45, + 0x1c,0x46,0x1b,0x48,0x19,0x48,0x18,0x4a,0x16,0x4a,0x15,0x4b,0x13,0x4c,0x13,0x4d,0x12,0x4e,0x11,0x4e, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x62,0x00,0x6c,0x00,0x72,0x00,0x74,0x00,0x77,0x00,0x79,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7b,0x00, + 0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x00,0x7c,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00, + 0x81,0x00,0x82,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x08,0x00,0x44,0x00,0x56,0x00,0x61,0x00,0x67,0x00,0x6b,0x00,0x6e,0x00,0x70,0x00,0x71,0x00,0x73,0x00, + 0x74,0x00,0x75,0x00,0x76,0x00,0x76,0x00,0x77,0x00,0x77,0x00,0x77,0x00,0x78,0x00,0x78,0x00,0x78,0x00, + 0x44,0x00,0x63,0x00,0x6c,0x00,0x71,0x00,0x75,0x00,0x77,0x00,0x79,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00, + 0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7c,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x4c,0x0b,0x57,0x06,0x5f,0x03,0x63,0x02,0x68,0x02,0x6b,0x01,0x6d,0x01,0x6e,0x01,0x71,0x00,0x72,0x00, + 0x73,0x00,0x74,0x00,0x75,0x00,0x76,0x00,0x76,0x00,0x76,0x00,0x78,0x00,0x78,0x00,0x78,0x00,0x79,0x00, + 0x82,0x00,0x82,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x40,0x17,0x17,0x2c,0x0c,0x3b,0x07,0x45,0x05,0x4d,0x04,0x53,0x03,0x57,0x02,0x5c,0x02,0x5e,0x01, + 0x61,0x01,0x63,0x01,0x66,0x01,0x67,0x01,0x68,0x00,0x69,0x00,0x6b,0x00,0x6c,0x00,0x6d,0x00,0x6e,0x00, + 0x41,0x20,0x4d,0x0b,0x58,0x06,0x5e,0x03,0x64,0x02,0x68,0x02,0x6b,0x01,0x6c,0x01,0x6f,0x01,0x71,0x00, + 0x72,0x00,0x73,0x00,0x74,0x00,0x75,0x00,0x76,0x00,0x75,0x00,0x77,0x00,0x78,0x00,0x78,0x00,0x78,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x47,0x15,0x4f,0x0d,0x56,0x09,0x59,0x06,0x5f,0x05,0x62,0x04,0x65,0x03,0x67,0x02,0x69,0x02,0x6b,0x02, + 0x6c,0x02,0x6e,0x01,0x6f,0x01,0x70,0x01,0x71,0x01,0x70,0x01,0x72,0x00,0x73,0x00,0x74,0x00,0x74,0x00, + 0x83,0x00,0x82,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x55,0x0c,0x2c,0x1b,0x1b,0x27,0x12,0x32,0x0d,0x3a,0x0b,0x41,0x08,0x47,0x07,0x4c,0x05,0x4f,0x05, + 0x53,0x04,0x56,0x04,0x58,0x03,0x5a,0x02,0x5d,0x02,0x5e,0x02,0x60,0x02,0x61,0x01,0x63,0x01,0x64,0x01, + 0x41,0x2a,0x47,0x16,0x4f,0x0d,0x54,0x09,0x5b,0x06,0x5f,0x05,0x62,0x04,0x64,0x03,0x67,0x02,0x69,0x02, + 0x6b,0x02,0x6c,0x02,0x6e,0x01,0x6f,0x01,0x70,0x01,0x70,0x01,0x71,0x01,0x72,0x00,0x73,0x00,0x74,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x45,0x1d,0x4a,0x14,0x50,0x0e,0x54,0x0b,0x59,0x08,0x5c,0x07,0x5f,0x06,0x60,0x05,0x64,0x04,0x65,0x03, + 0x67,0x03,0x68,0x02,0x6a,0x02,0x6b,0x02,0x6c,0x02,0x6c,0x02,0x6e,0x02,0x6f,0x01,0x70,0x01,0x70,0x01, + 0x83,0x00,0x82,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x60,0x08,0x3b,0x12,0x28,0x1d,0x1d,0x26,0x16,0x2e,0x11,0x34,0x0e,0x3a,0x0c,0x3f,0x0a,0x44,0x08, + 0x47,0x07,0x4b,0x06,0x4d,0x05,0x51,0x05,0x52,0x04,0x55,0x04,0x57,0x04,0x58,0x04,0x5a,0x03,0x5c,0x02, + 0x42,0x30,0x45,0x1d,0x4b,0x14,0x4f,0x0e,0x55,0x0b,0x59,0x08,0x5c,0x07,0x5e,0x06,0x61,0x05,0x64,0x04, + 0x65,0x03,0x67,0x03,0x68,0x02,0x6a,0x02,0x6b,0x02,0x6b,0x02,0x6d,0x02,0x6e,0x02,0x6f,0x01,0x70,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x44,0x22,0x48,0x19,0x4d,0x13,0x50,0x0f,0x54,0x0c,0x57,0x0a,0x5a,0x08,0x5c,0x07,0x5f,0x06,0x61,0x05, + 0x63,0x05,0x64,0x04,0x65,0x03,0x67,0x03,0x68,0x03,0x68,0x02,0x6a,0x02,0x6b,0x02,0x6c,0x02,0x6d,0x02, + 0x83,0x00,0x82,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x66,0x05,0x45,0x0d,0x32,0x16,0x26,0x1e,0x1e,0x25,0x18,0x2b,0x14,0x31,0x11,0x36,0x0f,0x3a,0x0c, + 0x3e,0x0b,0x42,0x0a,0x45,0x09,0x47,0x07,0x4a,0x07,0x4c,0x06,0x4f,0x05,0x51,0x05,0x52,0x05,0x54,0x04, + 0x41,0x33,0x44,0x22,0x48,0x19,0x4c,0x13,0x51,0x0f,0x54,0x0c,0x57,0x0a,0x59,0x08,0x5d,0x07,0x5f,0x06, + 0x61,0x05,0x63,0x05,0x64,0x04,0x65,0x03,0x67,0x03,0x67,0x03,0x69,0x02,0x6a,0x02,0x6b,0x02,0x6c,0x02, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x43,0x26,0x47,0x1d,0x4a,0x17,0x4d,0x12,0x51,0x0f,0x54,0x0d,0x56,0x0b,0x58,0x09,0x5b,0x08,0x5d,0x07, + 0x5f,0x06,0x60,0x06,0x62,0x05,0x63,0x05,0x64,0x04,0x65,0x03,0x67,0x03,0x67,0x03,0x68,0x03,0x69,0x02, + 0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x6a,0x04,0x4d,0x0b,0x3a,0x11,0x2e,0x18,0x25,0x1f,0x1f,0x24,0x1a,0x29,0x16,0x2e,0x13,0x33,0x11, + 0x37,0x0f,0x3a,0x0d,0x3d,0x0c,0x40,0x0a,0x43,0x0a,0x45,0x09,0x48,0x07,0x4a,0x07,0x4c,0x07,0x4e,0x06, + 0x41,0x35,0x43,0x26,0x47,0x1d,0x49,0x17,0x4e,0x12,0x51,0x0f,0x54,0x0d,0x55,0x0b,0x59,0x09,0x5b,0x08, + 0x5d,0x07,0x5f,0x06,0x60,0x06,0x62,0x05,0x63,0x05,0x63,0x04,0x65,0x03,0x67,0x03,0x67,0x03,0x68,0x03, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x43,0x29,0x45,0x20,0x49,0x1a,0x4b,0x15,0x4f,0x12,0x51,0x0f,0x54,0x0d,0x55,0x0b,0x58,0x0a,0x5a,0x09, + 0x5b,0x08,0x5d,0x07,0x5f,0x06,0x60,0x06,0x61,0x05,0x62,0x05,0x64,0x05,0x65,0x04,0x65,0x03,0x66,0x03, + 0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x6d,0x03,0x52,0x08,0x41,0x0e,0x34,0x14,0x2b,0x1a,0x24,0x1f,0x1f,0x24,0x1b,0x28,0x17,0x2d,0x15, + 0x31,0x12,0x34,0x10,0x37,0x0f,0x3a,0x0d,0x3d,0x0c,0x40,0x0b,0x42,0x0a,0x44,0x0a,0x46,0x09,0x47,0x07, + 0x41,0x36,0x43,0x29,0x46,0x20,0x48,0x1a,0x4c,0x15,0x4f,0x12,0x51,0x0f,0x53,0x0d,0x56,0x0b,0x58,0x0a, + 0x5a,0x09,0x5b,0x08,0x5d,0x07,0x5f,0x06,0x60,0x06,0x60,0x05,0x62,0x05,0x64,0x05,0x65,0x04,0x65,0x03, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x43,0x2b,0x45,0x23,0x48,0x1d,0x49,0x18,0x4d,0x14,0x4f,0x12,0x51,0x10,0x53,0x0e,0x55,0x0c,0x57,0x0b, + 0x59,0x0a,0x5a,0x09,0x5c,0x08,0x5d,0x07,0x5f,0x07,0x5f,0x06,0x61,0x06,0x62,0x05,0x63,0x05,0x64,0x05, + 0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x6f,0x02,0x57,0x07,0x47,0x0c,0x3a,0x11,0x31,0x16,0x29,0x1b,0x24,0x20,0x20,0x23,0x1c,0x28,0x19, + 0x2b,0x16,0x2f,0x14,0x32,0x12,0x35,0x10,0x38,0x0f,0x3a,0x0e,0x3c,0x0c,0x3f,0x0c,0x41,0x0b,0x42,0x0a, + 0x41,0x37,0x43,0x2b,0x45,0x23,0x47,0x1d,0x4a,0x18,0x4d,0x14,0x4f,0x12,0x51,0x10,0x53,0x0e,0x55,0x0c, + 0x57,0x0b,0x59,0x0a,0x5a,0x09,0x5c,0x08,0x5d,0x07,0x5e,0x07,0x60,0x06,0x61,0x06,0x62,0x05,0x63,0x05, + 0x1f,0x00,0x3f,0x00,0x66,0x00,0x72,0x00,0x78,0x00,0x7a,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00, + 0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x1f,0x1f,0x3f,0x00,0x66,0x00,0x72,0x00, + 0x78,0x00,0x7a,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00, + 0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x58,0x00, + 0x70,0x00,0x77,0x00,0x79,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00, + 0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x1f,0x1f,0x3f,0x00,0x66,0x00,0x72,0x00,0x78,0x00,0x7a,0x00, + 0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00, + 0x43,0x2d,0x44,0x25,0x46,0x1f,0x48,0x1b,0x4b,0x17,0x4d,0x14,0x50,0x12,0x51,0x10,0x53,0x0e,0x55,0x0c, + 0x57,0x0b,0x58,0x0b,0x5a,0x09,0x5b,0x09,0x5c,0x08,0x5c,0x07,0x5f,0x07,0x60,0x06,0x61,0x06,0x62,0x06, + 0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x71,0x02,0x5b,0x05,0x4b,0x0a,0x3f,0x0f,0x36,0x13,0x2e,0x18,0x29,0x1c,0x23,0x20,0x20,0x23,0x1d, + 0x27,0x19,0x2a,0x17,0x2d,0x16,0x30,0x12,0x33,0x12,0x35,0x10,0x38,0x0f,0x3b,0x0e,0x3c,0x0c,0x3e,0x0c, + 0x41,0x38,0x43,0x2d,0x44,0x25,0x45,0x1f,0x49,0x1b,0x4b,0x17,0x4d,0x14,0x4f,0x11,0x51,0x10,0x53,0x0e, + 0x55,0x0c,0x57,0x0b,0x58,0x0b,0x5a,0x09,0x5b,0x09,0x5b,0x08,0x5e,0x07,0x5f,0x07,0x60,0x06,0x61,0x06, + 0x00,0x00,0x0a,0x00,0x3f,0x00,0x5c,0x00,0x6a,0x00,0x71,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00, + 0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x00,0x00,0x3f,0x0a,0x0a,0x3f,0x00,0x5c,0x00, + 0x6a,0x00,0x71,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00, + 0x7d,0x00,0x7d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x44,0x00, + 0x55,0x00,0x67,0x00,0x6e,0x00,0x72,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c,0x00, + 0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x00,0x00,0x3f,0x0a,0x0a,0x3f,0x00,0x5c,0x00,0x6a,0x00,0x71,0x00, + 0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x00, + 0x42,0x2f,0x44,0x27,0x46,0x22,0x47,0x1d,0x4a,0x19,0x4c,0x16,0x4e,0x13,0x4f,0x11,0x52,0x10,0x53,0x0e, + 0x55,0x0d,0x56,0x0c,0x58,0x0b,0x59,0x0a,0x5a,0x09,0x5b,0x09,0x5c,0x07,0x5e,0x07,0x5f,0x07,0x5f,0x06, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x73,0x01,0x5e,0x05,0x4f,0x08,0x44,0x0c,0x3a,0x10,0x33,0x15,0x2d,0x19,0x28,0x1d,0x23,0x20,0x20, + 0x23,0x1d,0x26,0x1a,0x2a,0x18,0x2c,0x16,0x2f,0x14,0x31,0x12,0x34,0x12,0x35,0x0f,0x38,0x0f,0x3b,0x0f, + 0x41,0x39,0x42,0x2f,0x44,0x27,0x45,0x22,0x48,0x1d,0x4a,0x19,0x4c,0x16,0x4d,0x14,0x50,0x11,0x52,0x10, + 0x53,0x0e,0x55,0x0d,0x56,0x0c,0x58,0x0b,0x59,0x0a,0x59,0x09,0x5c,0x09,0x5c,0x07,0x5e,0x07,0x5f,0x07, + 0x00,0x00,0x00,0x00,0x03,0x00,0x2d,0x00,0x48,0x00,0x59,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00, + 0x74,0x00,0x76,0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x00,0x66,0x00,0x3f,0x03,0x03,0x2d,0x00, + 0x48,0x00,0x59,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76,0x00,0x77,0x00,0x78,0x00, + 0x79,0x00,0x7a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x55,0x00, + 0x20,0x00,0x3e,0x00,0x50,0x00,0x5a,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76,0x00, + 0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x00,0x66,0x00,0x3f,0x03,0x03,0x2d,0x00,0x48,0x00,0x59,0x00, + 0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76,0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x00, + 0x42,0x30,0x44,0x29,0x45,0x23,0x46,0x1f,0x49,0x1b,0x4b,0x18,0x4c,0x15,0x4d,0x13,0x50,0x11,0x52,0x10, + 0x53,0x0e,0x55,0x0d,0x56,0x0c,0x57,0x0b,0x59,0x0b,0x59,0x09,0x5b,0x09,0x5c,0x09,0x5c,0x07,0x5e,0x07, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x73,0x01,0x61,0x04,0x52,0x07,0x47,0x0b,0x3e,0x0f,0x37,0x12,0x31,0x16,0x2b,0x19,0x27,0x1d,0x23, + 0x20,0x20,0x23,0x1d,0x26,0x1b,0x29,0x19,0x2b,0x16,0x2e,0x16,0x30,0x13,0x32,0x12,0x35,0x12,0x36,0x0f, + 0x41,0x39,0x42,0x30,0x44,0x29,0x44,0x23,0x47,0x1f,0x49,0x1b,0x4b,0x18,0x4c,0x15,0x4e,0x13,0x50,0x11, + 0x52,0x10,0x53,0x0e,0x55,0x0d,0x56,0x0c,0x57,0x0b,0x57,0x0b,0x5a,0x09,0x5b,0x09,0x5c,0x09,0x5c,0x07, + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x22,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00, + 0x69,0x00,0x6d,0x00,0x6f,0x00,0x71,0x00,0x73,0x00,0x75,0x00,0x00,0x72,0x00,0x5c,0x00,0x2d,0x01,0x01, + 0x22,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d,0x00,0x6f,0x00,0x71,0x00, + 0x73,0x00,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x00,0x67,0x00, + 0x3e,0x00,0x0d,0x00,0x28,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d,0x00, + 0x6f,0x00,0x71,0x00,0x73,0x00,0x75,0x00,0x00,0x72,0x00,0x5c,0x00,0x2d,0x01,0x01,0x22,0x00,0x3a,0x00, + 0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d,0x00,0x6f,0x00,0x71,0x00,0x73,0x00,0x75,0x00, + 0x42,0x32,0x44,0x2a,0x45,0x25,0x46,0x21,0x48,0x1d,0x4a,0x1a,0x4b,0x17,0x4c,0x15,0x4e,0x13,0x50,0x11, + 0x52,0x10,0x53,0x0e,0x55,0x0d,0x55,0x0c,0x57,0x0c,0x57,0x0b,0x5a,0x0a,0x5a,0x09,0x5b,0x09,0x5c,0x09, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x74,0x01,0x64,0x04,0x55,0x06,0x4a,0x0a,0x42,0x0d,0x3a,0x10,0x34,0x14,0x2f,0x17,0x2a,0x1a,0x26, + 0x1d,0x23,0x21,0x21,0x22,0x1d,0x26,0x1b,0x28,0x19,0x2b,0x18,0x2c,0x16,0x30,0x15,0x30,0x12,0x33,0x12, + 0x41,0x3a,0x42,0x32,0x44,0x2a,0x44,0x25,0x46,0x21,0x48,0x1d,0x4a,0x1a,0x4b,0x17,0x4d,0x15,0x4e,0x13, + 0x50,0x11,0x52,0x10,0x53,0x0e,0x55,0x0d,0x55,0x0c,0x56,0x0c,0x58,0x0b,0x5a,0x0a,0x5a,0x09,0x5b,0x09, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00, + 0x5b,0x00,0x61,0x00,0x65,0x00,0x68,0x00,0x6b,0x00,0x6e,0x00,0x00,0x78,0x00,0x6a,0x00,0x48,0x00,0x22, + 0x00,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61,0x00,0x65,0x00,0x68,0x00, + 0x6b,0x00,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x79,0x00,0x6e,0x00, + 0x50,0x00,0x28,0x00,0x01,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61,0x00, + 0x65,0x00,0x68,0x00,0x6b,0x00,0x6e,0x00,0x00,0x78,0x00,0x6a,0x00,0x48,0x00,0x22,0x00,0x00,0x1b,0x00, + 0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61,0x00,0x65,0x00,0x68,0x00,0x6b,0x00,0x6e,0x00, + 0x42,0x32,0x43,0x2c,0x44,0x26,0x45,0x22,0x48,0x1f,0x49,0x1b,0x4b,0x19,0x4c,0x16,0x4e,0x15,0x4f,0x13, + 0x50,0x11,0x52,0x10,0x53,0x0e,0x55,0x0e,0x55,0x0c,0x56,0x0c,0x57,0x0b,0x59,0x0b,0x5a,0x0a,0x5a,0x09, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x75,0x01,0x65,0x03,0x58,0x05,0x4d,0x09,0x45,0x0c,0x3e,0x0f,0x37,0x12,0x32,0x16,0x2d,0x18,0x2a, + 0x1b,0x26,0x1d,0x22,0x21,0x21,0x22,0x1d,0x26,0x1c,0x27,0x19,0x2b,0x19,0x2b,0x16,0x2e,0x16,0x30,0x14, + 0x41,0x3a,0x42,0x32,0x43,0x2c,0x44,0x26,0x46,0x22,0x48,0x1f,0x49,0x1b,0x4a,0x19,0x4c,0x16,0x4e,0x15, + 0x4f,0x13,0x50,0x11,0x52,0x10,0x53,0x0e,0x55,0x0e,0x54,0x0c,0x57,0x0c,0x57,0x0b,0x59,0x0b,0x5a,0x0a, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00, + 0x4b,0x00,0x53,0x00,0x59,0x00,0x5e,0x00,0x62,0x00,0x65,0x00,0x00,0x7a,0x00,0x71,0x00,0x59,0x00,0x3a, + 0x00,0x1b,0x00,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53,0x00,0x59,0x00,0x5e,0x00, + 0x62,0x00,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7b,0x00,0x72,0x00, + 0x5a,0x00,0x3a,0x00,0x1b,0x00,0x01,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53,0x00, + 0x59,0x00,0x5e,0x00,0x62,0x00,0x65,0x00,0x00,0x7a,0x00,0x71,0x00,0x59,0x00,0x3a,0x00,0x1b,0x00,0x00, + 0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53,0x00,0x59,0x00,0x5e,0x00,0x62,0x00,0x65,0x00, + 0x42,0x33,0x43,0x2d,0x44,0x28,0x45,0x23,0x47,0x20,0x48,0x1d,0x4a,0x1a,0x4a,0x18,0x4c,0x16,0x4e,0x14, + 0x4f,0x13,0x50,0x11,0x52,0x10,0x53,0x0e,0x55,0x0e,0x54,0x0d,0x57,0x0c,0x57,0x0b,0x58,0x0b,0x5a,0x0b, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x76,0x01,0x67,0x02,0x5a,0x05,0x50,0x07,0x47,0x0a,0x40,0x0d,0x3a,0x10,0x35,0x12,0x30,0x16,0x2c, + 0x19,0x29,0x1b,0x26,0x1d,0x22,0x21,0x21,0x22,0x1d,0x26,0x1d,0x26,0x1a,0x2a,0x19,0x2b,0x17,0x2d,0x16, + 0x41,0x3b,0x42,0x33,0x43,0x2d,0x44,0x28,0x45,0x23,0x47,0x20,0x48,0x1d,0x49,0x1a,0x4b,0x18,0x4c,0x16, + 0x4e,0x14,0x4f,0x13,0x50,0x11,0x52,0x10,0x53,0x0e,0x54,0x0e,0x55,0x0d,0x57,0x0c,0x57,0x0b,0x58,0x0b, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00, + 0x3b,0x00,0x44,0x00,0x4c,0x00,0x52,0x00,0x57,0x00,0x5b,0x00,0x00,0x7c,0x00,0x75,0x00,0x63,0x00,0x4a, + 0x00,0x30,0x00,0x16,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44,0x00,0x4c,0x00,0x52,0x00, + 0x57,0x00,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x75,0x00, + 0x63,0x00,0x4a,0x00,0x30,0x00,0x16,0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44,0x00, + 0x4c,0x00,0x52,0x00,0x57,0x00,0x5b,0x00,0x00,0x7c,0x00,0x75,0x00,0x63,0x00,0x4a,0x00,0x30,0x00,0x16, + 0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44,0x00,0x4c,0x00,0x52,0x00,0x57,0x00,0x5b,0x00, + 0x42,0x34,0x43,0x2e,0x44,0x29,0x45,0x25,0x46,0x21,0x48,0x1e,0x49,0x1b,0x4a,0x19,0x4c,0x17,0x4d,0x15, + 0x4e,0x14,0x50,0x13,0x50,0x11,0x52,0x11,0x52,0x0f,0x53,0x0e,0x55,0x0d,0x56,0x0c,0x57,0x0c,0x57,0x0b, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x77,0x00,0x68,0x02,0x5c,0x05,0x52,0x07,0x4a,0x0a,0x43,0x0c,0x3d,0x0f,0x37,0x12,0x33,0x14,0x2f, + 0x16,0x2b,0x19,0x28,0x1c,0x26,0x1d,0x22,0x21,0x22,0x21,0x1e,0x25,0x1d,0x26,0x1a,0x29,0x19,0x2b,0x18, + 0x41,0x3b,0x42,0x34,0x43,0x2e,0x44,0x29,0x45,0x25,0x46,0x21,0x48,0x1e,0x48,0x1b,0x4b,0x19,0x4c,0x17, + 0x4d,0x15,0x4e,0x14,0x50,0x13,0x50,0x11,0x52,0x11,0x51,0x0f,0x54,0x0e,0x55,0x0d,0x56,0x0c,0x57,0x0c, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x1f,0x00, + 0x2b,0x00,0x35,0x00,0x3e,0x00,0x45,0x00,0x4c,0x00,0x51,0x00,0x00,0x7c,0x00,0x78,0x00,0x6a,0x00,0x56, + 0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35,0x00,0x3e,0x00,0x45,0x00, + 0x4c,0x00,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x78,0x00, + 0x6a,0x00,0x56,0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35,0x00, + 0x3e,0x00,0x45,0x00,0x4c,0x00,0x51,0x00,0x00,0x7c,0x00,0x78,0x00,0x6a,0x00,0x56,0x00,0x3f,0x00,0x28, + 0x00,0x13,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35,0x00,0x3e,0x00,0x45,0x00,0x4c,0x00,0x51,0x00, + 0x42,0x34,0x43,0x2f,0x44,0x2a,0x44,0x26,0x46,0x22,0x47,0x1f,0x48,0x1d,0x49,0x1a,0x4b,0x18,0x4c,0x17, + 0x4e,0x15,0x4e,0x13,0x50,0x13,0x50,0x11,0x52,0x11,0x51,0x0f,0x54,0x0e,0x55,0x0d,0x56,0x0c,0x57,0x0c, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x77,0x00,0x69,0x02,0x5e,0x04,0x55,0x06,0x4c,0x09,0x45,0x0c,0x3f,0x0e,0x3a,0x10,0x35,0x12,0x31, + 0x16,0x2e,0x18,0x2b,0x19,0x27,0x1d,0x26,0x1e,0x22,0x21,0x22,0x21,0x1e,0x25,0x1d,0x26,0x1b,0x28,0x19, + 0x41,0x3b,0x42,0x34,0x43,0x2f,0x43,0x2a,0x45,0x26,0x46,0x22,0x47,0x1f,0x48,0x1d,0x4a,0x1a,0x4b,0x18, + 0x4c,0x17,0x4e,0x15,0x4e,0x13,0x50,0x13,0x50,0x11,0x51,0x11,0x52,0x0f,0x54,0x0e,0x55,0x0d,0x56,0x0c, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00, + 0x1b,0x00,0x27,0x00,0x30,0x00,0x39,0x00,0x40,0x00,0x46,0x00,0x00,0x7d,0x00,0x79,0x00,0x6e,0x00,0x5e, + 0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27,0x00,0x30,0x00,0x39,0x00, + 0x40,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x79,0x00, + 0x6e,0x00,0x5e,0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27,0x00, + 0x30,0x00,0x39,0x00,0x40,0x00,0x46,0x00,0x00,0x7d,0x00,0x79,0x00,0x6e,0x00,0x5e,0x00,0x4b,0x00,0x37, + 0x00,0x23,0x00,0x10,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27,0x00,0x30,0x00,0x39,0x00,0x40,0x00,0x46,0x00, + 0x42,0x35,0x43,0x30,0x44,0x2b,0x44,0x27,0x45,0x24,0x46,0x21,0x48,0x1e,0x48,0x1c,0x4b,0x1a,0x4b,0x18, + 0x4c,0x16,0x4e,0x15,0x4e,0x13,0x50,0x12,0x50,0x11,0x51,0x11,0x52,0x0f,0x54,0x0e,0x55,0x0e,0x55,0x0c, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x77,0x00,0x6b,0x02,0x60,0x04,0x57,0x05,0x4f,0x07,0x48,0x0a,0x42,0x0c,0x3c,0x0f,0x38,0x12,0x34, + 0x14,0x30,0x16,0x2c,0x19,0x2b,0x19,0x26,0x1d,0x25,0x1e,0x22,0x21,0x22,0x21,0x1e,0x25,0x1d,0x26,0x1c, + 0x41,0x3b,0x42,0x35,0x43,0x30,0x43,0x2b,0x44,0x27,0x45,0x24,0x46,0x21,0x47,0x1e,0x49,0x1c,0x4b,0x1a, + 0x4b,0x18,0x4c,0x16,0x4e,0x15,0x4e,0x13,0x50,0x12,0x50,0x11,0x52,0x11,0x52,0x0f,0x54,0x0e,0x55,0x0e, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x0d,0x00,0x19,0x00,0x23,0x00,0x2c,0x00,0x34,0x00,0x3b,0x00,0x00,0x7d,0x00,0x7a,0x00,0x72,0x00,0x64, + 0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x0d,0x00,0x19,0x00,0x23,0x00,0x2c,0x00, + 0x34,0x00,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x7a,0x00, + 0x72,0x00,0x64,0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x0d,0x00,0x19,0x00, + 0x23,0x00,0x2c,0x00,0x34,0x00,0x3b,0x00,0x00,0x7d,0x00,0x7a,0x00,0x72,0x00,0x64,0x00,0x54,0x00,0x42, + 0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x0d,0x00,0x19,0x00,0x23,0x00,0x2c,0x00,0x34,0x00,0x3b,0x00, + 0x42,0x36,0x43,0x30,0x44,0x2c,0x44,0x28,0x45,0x25,0x46,0x22,0x48,0x1f,0x48,0x1d,0x49,0x1a,0x4b,0x19, + 0x4c,0x18,0x4d,0x15,0x4e,0x15,0x4f,0x13,0x50,0x12,0x50,0x11,0x52,0x11,0x52,0x0f,0x54,0x0e,0x55,0x0e, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x77,0x00,0x6c,0x02,0x61,0x04,0x58,0x05,0x51,0x07,0x4a,0x0a,0x44,0x0c,0x3f,0x0f,0x3a,0x10,0x35, + 0x12,0x32,0x16,0x30,0x16,0x2b,0x19,0x2a,0x1a,0x26,0x1d,0x25,0x1e,0x22,0x21,0x22,0x21,0x1e,0x25,0x1d, + 0x41,0x3b,0x42,0x36,0x43,0x30,0x43,0x2c,0x44,0x28,0x45,0x25,0x46,0x22,0x47,0x1f,0x49,0x1d,0x49,0x1a, + 0x4b,0x19,0x4c,0x18,0x4d,0x15,0x4e,0x15,0x4f,0x13,0x4f,0x12,0x51,0x11,0x52,0x11,0x52,0x0f,0x54,0x0e, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x0c,0x00,0x16,0x00,0x20,0x00,0x29,0x00,0x30,0x00,0x00,0x7e,0x00,0x7b,0x00,0x74,0x00,0x69, + 0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x0c,0x00,0x16,0x00,0x20,0x00, + 0x29,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7b,0x00, + 0x74,0x00,0x69,0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x0c,0x00, + 0x16,0x00,0x20,0x00,0x29,0x00,0x30,0x00,0x00,0x7e,0x00,0x7b,0x00,0x74,0x00,0x69,0x00,0x5b,0x00,0x4b, + 0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x0c,0x00,0x16,0x00,0x20,0x00,0x29,0x00,0x30,0x00, + 0x42,0x36,0x42,0x31,0x43,0x2d,0x44,0x29,0x45,0x26,0x46,0x23,0x47,0x20,0x47,0x1e,0x49,0x1c,0x4b,0x1a, + 0x4b,0x18,0x4c,0x17,0x4d,0x15,0x4e,0x14,0x4f,0x13,0x4f,0x12,0x51,0x11,0x52,0x11,0x52,0x0f,0x54,0x0e, + 0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x78,0x00,0x6d,0x01,0x62,0x03,0x5a,0x05,0x52,0x07,0x4c,0x09,0x46,0x0b,0x41,0x0c,0x3c,0x0f,0x38, + 0x12,0x35,0x12,0x30,0x16,0x2e,0x17,0x2b,0x19,0x29,0x1b,0x26,0x1d,0x25,0x1e,0x22,0x21,0x22,0x21,0x1f, + 0x41,0x3c,0x42,0x36,0x42,0x31,0x43,0x2d,0x44,0x29,0x45,0x26,0x46,0x23,0x46,0x20,0x48,0x1e,0x49,0x1c, + 0x4b,0x1a,0x4b,0x18,0x4c,0x17,0x4d,0x15,0x4e,0x14,0x4e,0x13,0x50,0x12,0x51,0x11,0x52,0x11,0x52,0x0f, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x0b,0x00,0x15,0x00,0x1e,0x00,0x26,0x00,0x00,0x7e,0x00,0x7c,0x00,0x76,0x00,0x6d, + 0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x0b,0x00,0x15,0x00, + 0x1e,0x00,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x76,0x00,0x6d,0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00, + 0x0b,0x00,0x15,0x00,0x1e,0x00,0x26,0x00,0x00,0x7e,0x00,0x7c,0x00,0x76,0x00,0x6d,0x00,0x61,0x00,0x53, + 0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x0b,0x00,0x15,0x00,0x1e,0x00,0x26,0x00, + 0x42,0x37,0x42,0x32,0x43,0x2d,0x44,0x2a,0x45,0x27,0x45,0x23,0x46,0x21,0x47,0x1f,0x49,0x1d,0x49,0x1a, + 0x4b,0x19,0x4c,0x18,0x4c,0x16,0x4e,0x15,0x4e,0x14,0x4f,0x13,0x50,0x12,0x51,0x11,0x52,0x11,0x52,0x0f, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x82,0x00,0x83,0x00,0x83,0x00, + 0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x81,0x00,0x83,0x00,0x83,0x00,0x83,0x00,0x83,0x00, + 0x00,0x78,0x00,0x6e,0x01,0x64,0x02,0x5b,0x04,0x54,0x06,0x4e,0x07,0x47,0x0a,0x42,0x0c,0x3e,0x0f,0x3b, + 0x0f,0x35,0x12,0x33,0x14,0x30,0x16,0x2d,0x19,0x2b,0x19,0x28,0x1c,0x26,0x1d,0x25,0x1f,0x22,0x21,0x22, + 0x41,0x3c,0x42,0x37,0x42,0x32,0x43,0x2d,0x44,0x2a,0x45,0x27,0x45,0x23,0x46,0x21,0x48,0x1f,0x49,0x1d, + 0x49,0x1a,0x4b,0x19,0x4c,0x18,0x4c,0x16,0x4e,0x15,0x4d,0x14,0x50,0x13,0x50,0x12,0x51,0x11,0x52,0x11, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x13,0x00,0x1b,0x00,0x00,0x7e,0x00,0x7c,0x00,0x77,0x00,0x6f, + 0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00,0x00,0x0a,0x00, + 0x13,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x77,0x00,0x6f,0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00, + 0x00,0x00,0x0a,0x00,0x13,0x00,0x1b,0x00,0x00,0x7e,0x00,0x7c,0x00,0x77,0x00,0x6f,0x00,0x65,0x00,0x59, + 0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00,0x00,0x0a,0x00,0x13,0x00,0x1b,0x00, + 0x40,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x61,0x20,0x4d,0x2a,0x48,0x30,0x44,0x33,0x44,0x35,0x44,0x36,0x43,0x37,0x42,0x38,0x43,0x39,0x42,0x39, + 0x42,0x3a,0x42,0x3a,0x42,0x3b,0x42,0x3b,0x42,0x3b,0x41,0x3b,0x42,0x3c,0x42,0x3c,0x42,0x3c,0x42,0x3c, + 0x04,0x3d,0x22,0x3d,0x2b,0x3d,0x30,0x3d,0x33,0x3d,0x35,0x3d,0x37,0x3d,0x38,0x3d,0x39,0x3d,0x39,0x3d, + 0x3a,0x3d,0x3a,0x3d,0x3b,0x3d,0x3b,0x3d,0x3b,0x3d,0x3c,0x3d,0x3c,0x3d,0x3c,0x3d,0x3c,0x3d,0x3c,0x3d, + 0x40,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x12,0x00,0x00,0x7e,0x00,0x7d,0x00,0x78,0x00,0x71, + 0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00,0x0a,0x00,0x00, + 0x09,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x78,0x00,0x71,0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00, + 0x0a,0x00,0x00,0x00,0x09,0x00,0x12,0x00,0x00,0x7e,0x00,0x7d,0x00,0x78,0x00,0x71,0x00,0x68,0x00,0x5e, + 0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00,0x0a,0x00,0x00,0x09,0x00,0x12,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x6c,0x0b,0x57,0x16,0x4f,0x1d,0x4a,0x22,0x48,0x26,0x47,0x29,0x46,0x2b,0x44,0x2d,0x44,0x2f,0x44,0x30, + 0x44,0x31,0x44,0x32,0x43,0x33,0x43,0x34,0x43,0x34,0x42,0x35,0x43,0x36,0x42,0x36,0x42,0x37,0x42,0x37, + 0x00,0x5d,0x0c,0x49,0x16,0x43,0x1d,0x41,0x22,0x40,0x26,0x3f,0x29,0x3f,0x2c,0x3f,0x2e,0x3e,0x2f,0x3e, + 0x31,0x3e,0x32,0x3e,0x33,0x3e,0x33,0x3e,0x34,0x3e,0x35,0x3e,0x35,0x3e,0x36,0x3e,0x37,0x3e,0x37,0x3e, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x7e,0x00,0x7d,0x00,0x79,0x00,0x73, + 0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00,0x13,0x00,0x09, + 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x79,0x00,0x73,0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00, + 0x13,0x00,0x09,0x00,0x00,0x00,0x08,0x00,0x00,0x7e,0x00,0x7d,0x00,0x79,0x00,0x73,0x00,0x6b,0x00,0x62, + 0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00,0x13,0x00,0x09,0x00,0x00,0x08,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x72,0x06,0x5f,0x0d,0x56,0x14,0x4f,0x19,0x4d,0x1d,0x4a,0x20,0x49,0x23,0x47,0x25,0x46,0x27,0x46,0x29, + 0x45,0x2a,0x45,0x2c,0x44,0x2d,0x44,0x2e,0x44,0x2f,0x43,0x30,0x44,0x30,0x44,0x31,0x43,0x32,0x43,0x33, + 0x00,0x68,0x06,0x54,0x0d,0x4b,0x14,0x47,0x19,0x44,0x1d,0x43,0x20,0x41,0x23,0x41,0x26,0x40,0x27,0x40, + 0x29,0x3f,0x2b,0x3f,0x2c,0x3f,0x2d,0x3f,0x2e,0x3f,0x2f,0x3f,0x30,0x3f,0x30,0x3e,0x31,0x3e,0x32,0x3e, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x7a,0x00,0x75, + 0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00,0x1b,0x00,0x12, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x7a,0x00,0x75,0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00, + 0x1b,0x00,0x12,0x00,0x08,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x7a,0x00,0x75,0x00,0x6e,0x00,0x65, + 0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00,0x1b,0x00,0x12,0x00,0x08,0x00,0x00, + 0x42,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x75,0x03,0x64,0x09,0x5a,0x0e,0x54,0x13,0x51,0x17,0x4e,0x1a,0x4c,0x1d,0x49,0x1f,0x49,0x22,0x48,0x23, + 0x47,0x25,0x46,0x26,0x46,0x28,0x45,0x29,0x45,0x2a,0x44,0x2b,0x44,0x2c,0x44,0x2d,0x44,0x2e,0x44,0x2e, + 0x00,0x6d,0x04,0x5b,0x09,0x51,0x0e,0x4c,0x13,0x48,0x17,0x46,0x1a,0x44,0x1d,0x43,0x1f,0x42,0x22,0x42, + 0x24,0x41,0x25,0x41,0x27,0x40,0x28,0x40,0x29,0x40,0x2a,0x3f,0x2b,0x3f,0x2c,0x3f,0x2d,0x3f,0x2e,0x3f, + 0x42,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x1f,0x3f,0x00,0x66,0x00,0x72,0x00, + 0x78,0x00,0x7a,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00, + 0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x1f,0x00,0x3f, + 0x00,0x66,0x00,0x72,0x00,0x78,0x00,0x7a,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7e,0x00,0x7e, + 0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x77,0x02,0x68,0x06,0x5f,0x0b,0x58,0x0f,0x54,0x12,0x51,0x15,0x4f,0x18,0x4c,0x1b,0x4b,0x1d,0x4a,0x1f, + 0x49,0x21,0x48,0x22,0x48,0x23,0x47,0x25,0x46,0x26,0x45,0x27,0x45,0x28,0x45,0x29,0x45,0x2a,0x44,0x2b, + 0x00,0x70,0x02,0x60,0x07,0x56,0x0b,0x50,0x0f,0x4c,0x12,0x49,0x16,0x47,0x18,0x46,0x1b,0x45,0x1d,0x44, + 0x1f,0x43,0x21,0x42,0x22,0x42,0x24,0x41,0x25,0x41,0x26,0x40,0x27,0x40,0x28,0x40,0x29,0x40,0x2a,0x3f, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x0a,0x0a,0x3f,0x00,0x5c,0x00, + 0x6a,0x00,0x71,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c,0x00,0x7c,0x00,0x7d,0x00, + 0x7d,0x00,0x7d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x0a,0x0a, + 0x00,0x3f,0x00,0x5c,0x00,0x6a,0x00,0x71,0x00,0x75,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00,0x7c, + 0x00,0x7c,0x00,0x7d,0x00,0x7d,0x00,0x7d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x78,0x02,0x6b,0x05,0x62,0x08,0x5b,0x0c,0x57,0x0f,0x54,0x12,0x51,0x14,0x4e,0x17,0x4d,0x19,0x4c,0x1b, + 0x4b,0x1d,0x4a,0x1e,0x49,0x20,0x48,0x21,0x48,0x22,0x46,0x24,0x46,0x25,0x46,0x26,0x46,0x27,0x45,0x27, + 0x00,0x72,0x02,0x64,0x05,0x5b,0x08,0x54,0x0c,0x50,0x0f,0x4d,0x12,0x4a,0x14,0x48,0x17,0x47,0x19,0x46, + 0x1b,0x45,0x1d,0x44,0x1f,0x44,0x20,0x42,0x21,0x42,0x22,0x42,0x24,0x41,0x25,0x41,0x26,0x41,0x27,0x40, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,0x3f,0x03,0x03,0x2d,0x00, + 0x48,0x00,0x59,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76,0x00,0x77,0x00,0x78,0x00, + 0x79,0x00,0x7a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,0x3f,0x00, + 0x03,0x03,0x00,0x2d,0x00,0x48,0x00,0x59,0x00,0x63,0x00,0x6a,0x00,0x6e,0x00,0x72,0x00,0x74,0x00,0x76, + 0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x79,0x01,0x6d,0x04,0x65,0x07,0x5e,0x0a,0x5a,0x0d,0x56,0x0f,0x54,0x12,0x51,0x14,0x4f,0x16,0x4e,0x18, + 0x4c,0x1a,0x4b,0x1b,0x4b,0x1d,0x4a,0x1e,0x49,0x1f,0x48,0x21,0x48,0x22,0x48,0x23,0x47,0x23,0x46,0x25, + 0x00,0x74,0x01,0x66,0x04,0x5e,0x07,0x57,0x0a,0x53,0x0d,0x4f,0x10,0x4d,0x12,0x4b,0x14,0x49,0x16,0x48, + 0x18,0x46,0x1a,0x45,0x1b,0x45,0x1d,0x44,0x1e,0x44,0x20,0x43,0x21,0x42,0x22,0x42,0x23,0x42,0x24,0x41, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x00,0x5c,0x00,0x2d,0x01,0x01, + 0x22,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d,0x00,0x6f,0x00,0x71,0x00, + 0x73,0x00,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x00,0x5c,0x00, + 0x2d,0x00,0x01,0x01,0x00,0x22,0x00,0x3a,0x00,0x4a,0x00,0x56,0x00,0x5e,0x00,0x64,0x00,0x69,0x00,0x6d, + 0x00,0x6f,0x00,0x71,0x00,0x73,0x00,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7a,0x01,0x6f,0x03,0x67,0x06,0x60,0x08,0x5d,0x0b,0x59,0x0d,0x56,0x10,0x53,0x11,0x51,0x14,0x50,0x15, + 0x4e,0x17,0x4d,0x19,0x4c,0x1a,0x4b,0x1b,0x4b,0x1d,0x48,0x1e,0x49,0x1f,0x49,0x20,0x48,0x21,0x48,0x22, + 0x00,0x75,0x01,0x69,0x03,0x61,0x06,0x5a,0x08,0x56,0x0b,0x52,0x0d,0x4f,0x10,0x4d,0x12,0x4b,0x14,0x4a, + 0x16,0x48,0x17,0x47,0x19,0x46,0x1a,0x45,0x1c,0x45,0x1d,0x44,0x1e,0x44,0x1f,0x44,0x20,0x43,0x21,0x42, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x6a,0x00,0x48,0x00,0x22, + 0x00,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61,0x00,0x65,0x00,0x68,0x00, + 0x6b,0x00,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x6a,0x00, + 0x48,0x00,0x22,0x00,0x00,0x00,0x00,0x1b,0x00,0x30,0x00,0x3f,0x00,0x4b,0x00,0x54,0x00,0x5b,0x00,0x61, + 0x00,0x65,0x00,0x68,0x00,0x6b,0x00,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7b,0x01,0x71,0x02,0x69,0x05,0x62,0x07,0x5f,0x09,0x5b,0x0c,0x58,0x0e,0x55,0x10,0x53,0x11,0x52,0x13, + 0x50,0x15,0x4e,0x16,0x4e,0x18,0x4c,0x19,0x4c,0x1a,0x4a,0x1c,0x4b,0x1d,0x49,0x1e,0x49,0x1f,0x49,0x20, + 0x00,0x76,0x01,0x6b,0x03,0x63,0x05,0x5d,0x07,0x58,0x09,0x54,0x0c,0x52,0x0e,0x4f,0x10,0x4d,0x11,0x4c, + 0x13,0x4a,0x15,0x49,0x17,0x48,0x18,0x47,0x19,0x46,0x1b,0x45,0x1c,0x45,0x1d,0x44,0x1e,0x44,0x1f,0x44, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0x00,0x71,0x00,0x59,0x00,0x3a, + 0x00,0x1b,0x00,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53,0x00,0x59,0x00,0x5e,0x00, + 0x62,0x00,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7a,0x00,0x71,0x00, + 0x59,0x00,0x3a,0x00,0x1b,0x00,0x00,0x00,0x00,0x16,0x00,0x28,0x00,0x37,0x00,0x42,0x00,0x4b,0x00,0x53, + 0x00,0x59,0x00,0x5e,0x00,0x62,0x00,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7b,0x00,0x72,0x02,0x6b,0x04,0x64,0x06,0x61,0x08,0x5d,0x0a,0x5a,0x0c,0x56,0x0e,0x55,0x10,0x53,0x11, + 0x52,0x13,0x50,0x15,0x4f,0x16,0x4e,0x17,0x4d,0x18,0x4b,0x1a,0x4b,0x1a,0x4b,0x1c,0x4b,0x1d,0x49,0x1d, + 0x00,0x77,0x00,0x6c,0x02,0x65,0x04,0x5f,0x06,0x5a,0x08,0x57,0x0a,0x54,0x0c,0x51,0x0e,0x4f,0x10,0x4d, + 0x11,0x4c,0x13,0x4a,0x15,0x49,0x16,0x48,0x18,0x48,0x18,0x46,0x1a,0x46,0x1b,0x45,0x1c,0x45,0x1d,0x45, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x75,0x00,0x63,0x00,0x4a, + 0x00,0x30,0x00,0x16,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44,0x00,0x4c,0x00,0x52,0x00, + 0x57,0x00,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x75,0x00, + 0x63,0x00,0x4a,0x00,0x30,0x00,0x16,0x00,0x00,0x00,0x00,0x13,0x00,0x23,0x00,0x30,0x00,0x3b,0x00,0x44, + 0x00,0x4c,0x00,0x52,0x00,0x57,0x00,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7c,0x00,0x73,0x02,0x6c,0x03,0x66,0x05,0x63,0x07,0x5e,0x09,0x5c,0x0b,0x58,0x0c,0x57,0x0e,0x55,0x10, + 0x53,0x11,0x52,0x13,0x50,0x14,0x4f,0x15,0x4e,0x17,0x4c,0x18,0x4c,0x19,0x4c,0x1a,0x4b,0x1a,0x4b,0x1c, + 0x00,0x77,0x00,0x6e,0x02,0x66,0x04,0x61,0x05,0x5c,0x07,0x59,0x09,0x56,0x0b,0x53,0x0d,0x51,0x0f,0x4f, + 0x10,0x4e,0x11,0x4c,0x13,0x4b,0x14,0x4a,0x15,0x48,0x17,0x48,0x18,0x47,0x19,0x46,0x1b,0x46,0x1b,0x45, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x78,0x00,0x6a,0x00,0x56, + 0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35,0x00,0x3e,0x00,0x45,0x00, + 0x4c,0x00,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x78,0x00, + 0x6a,0x00,0x56,0x00,0x3f,0x00,0x28,0x00,0x13,0x00,0x00,0x00,0x00,0x10,0x00,0x1f,0x00,0x2b,0x00,0x35, + 0x00,0x3e,0x00,0x45,0x00,0x4c,0x00,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7c,0x00,0x74,0x02,0x6e,0x03,0x68,0x05,0x64,0x06,0x60,0x08,0x5d,0x0a,0x5a,0x0b,0x58,0x0d,0x56,0x0e, + 0x55,0x10,0x53,0x11,0x52,0x13,0x50,0x14,0x50,0x15,0x4d,0x16,0x4e,0x18,0x4c,0x18,0x4c,0x19,0x4c,0x1a, + 0x00,0x77,0x00,0x6f,0x02,0x68,0x03,0x63,0x05,0x5e,0x06,0x5a,0x08,0x57,0x0a,0x55,0x0b,0x53,0x0d,0x50, + 0x0f,0x4f,0x10,0x4e,0x11,0x4c,0x13,0x4b,0x14,0x4a,0x15,0x49,0x16,0x48,0x18,0x48,0x18,0x46,0x19,0x46, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x79,0x00,0x6e,0x00,0x5e, + 0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27,0x00,0x30,0x00,0x39,0x00, + 0x40,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x79,0x00, + 0x6e,0x00,0x5e,0x00,0x4b,0x00,0x37,0x00,0x23,0x00,0x10,0x00,0x00,0x00,0x00,0x0e,0x00,0x1b,0x00,0x27, + 0x00,0x30,0x00,0x39,0x00,0x40,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x75,0x01,0x6f,0x02,0x69,0x04,0x65,0x06,0x62,0x07,0x5f,0x09,0x5b,0x0b,0x5a,0x0c,0x58,0x0d, + 0x56,0x0e,0x55,0x10,0x53,0x11,0x52,0x13,0x50,0x13,0x4f,0x15,0x4e,0x15,0x4e,0x17,0x4d,0x18,0x4c,0x18, + 0x00,0x78,0x00,0x70,0x01,0x69,0x03,0x64,0x04,0x60,0x06,0x5c,0x07,0x59,0x09,0x56,0x0b,0x54,0x0c,0x52, + 0x0d,0x50,0x0f,0x4f,0x10,0x4e,0x11,0x4c,0x13,0x4b,0x13,0x4a,0x15,0x4a,0x15,0x48,0x17,0x48,0x18,0x47, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x7a,0x00,0x72,0x00,0x64, + 0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x0d,0x00,0x19,0x00,0x23,0x00,0x2c,0x00, + 0x34,0x00,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x7a,0x00, + 0x72,0x00,0x64,0x00,0x54,0x00,0x42,0x00,0x30,0x00,0x1f,0x00,0x0e,0x00,0x00,0x00,0x00,0x0d,0x00,0x19, + 0x00,0x23,0x00,0x2c,0x00,0x34,0x00,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x76,0x01,0x70,0x02,0x6a,0x03,0x67,0x05,0x63,0x06,0x60,0x08,0x5d,0x09,0x5b,0x0b,0x59,0x0c, + 0x57,0x0d,0x55,0x0e,0x55,0x10,0x53,0x11,0x52,0x13,0x4f,0x13,0x50,0x15,0x4f,0x15,0x4e,0x16,0x4e,0x18, + 0x00,0x78,0x00,0x71,0x01,0x6a,0x03,0x66,0x04,0x61,0x05,0x5d,0x06,0x5a,0x08,0x58,0x09,0x55,0x0b,0x53, + 0x0d,0x52,0x0e,0x50,0x0f,0x4e,0x10,0x4e,0x11,0x4c,0x13,0x4c,0x13,0x4a,0x15,0x4a,0x15,0x49,0x16,0x48, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7b,0x00,0x74,0x00,0x69, + 0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x0c,0x00,0x16,0x00,0x20,0x00, + 0x29,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7b,0x00, + 0x74,0x00,0x69,0x00,0x5b,0x00,0x4b,0x00,0x3b,0x00,0x2b,0x00,0x1b,0x00,0x0d,0x00,0x00,0x00,0x00,0x0c, + 0x00,0x16,0x00,0x20,0x00,0x29,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x76,0x01,0x71,0x02,0x6c,0x03,0x68,0x05,0x64,0x06,0x61,0x07,0x5e,0x09,0x5c,0x0a,0x5a,0x0b, + 0x59,0x0c,0x57,0x0e,0x55,0x0e,0x55,0x11,0x52,0x11,0x51,0x12,0x51,0x13,0x50,0x14,0x4f,0x15,0x4e,0x15, + 0x00,0x79,0x00,0x71,0x01,0x6c,0x02,0x66,0x04,0x62,0x05,0x5f,0x06,0x5c,0x07,0x59,0x09,0x57,0x0a,0x55, + 0x0b,0x53,0x0d,0x51,0x0e,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4c,0x13,0x4c,0x13,0x4b,0x14,0x4a,0x15,0x4a, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00,0x76,0x00,0x6d, + 0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x0b,0x00,0x15,0x00, + 0x1e,0x00,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x76,0x00,0x6d,0x00,0x61,0x00,0x53,0x00,0x44,0x00,0x35,0x00,0x27,0x00,0x19,0x00,0x0c,0x00,0x00,0x00, + 0x00,0x0b,0x00,0x15,0x00,0x1e,0x00,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x77,0x01,0x72,0x02,0x6d,0x03,0x69,0x04,0x66,0x06,0x63,0x07,0x5f,0x08,0x5e,0x09,0x5c,0x0b, + 0x5a,0x0c,0x58,0x0c,0x57,0x0e,0x55,0x0f,0x54,0x11,0x51,0x11,0x52,0x12,0x51,0x13,0x50,0x14,0x50,0x15, + 0x00,0x79,0x00,0x72,0x01,0x6d,0x02,0x68,0x03,0x63,0x04,0x60,0x06,0x5d,0x07,0x5b,0x08,0x58,0x09,0x56, + 0x0b,0x54,0x0c,0x53,0x0d,0x51,0x0e,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4c,0x12,0x4c,0x13,0x4b,0x14,0x4a, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00,0x77,0x00,0x6f, + 0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00,0x00,0x0a,0x00, + 0x13,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7c,0x00, + 0x77,0x00,0x6f,0x00,0x65,0x00,0x59,0x00,0x4c,0x00,0x3e,0x00,0x30,0x00,0x23,0x00,0x16,0x00,0x0b,0x00, + 0x00,0x00,0x00,0x0a,0x00,0x13,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7d,0x00,0x78,0x01,0x72,0x02,0x6e,0x02,0x6a,0x03,0x67,0x05,0x64,0x06,0x60,0x07,0x5f,0x09,0x5c,0x0a, + 0x5b,0x0b,0x5a,0x0c,0x57,0x0c,0x56,0x0e,0x55,0x0f,0x53,0x11,0x52,0x11,0x52,0x12,0x51,0x13,0x50,0x13, + 0x00,0x79,0x00,0x73,0x01,0x6d,0x02,0x69,0x03,0x65,0x04,0x61,0x05,0x5e,0x06,0x5c,0x07,0x59,0x09,0x57, + 0x0a,0x55,0x0b,0x54,0x0d,0x53,0x0d,0x51,0x0f,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4c,0x12,0x4c,0x13,0x4b, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x78,0x00,0x71, + 0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00,0x0a,0x00,0x00, + 0x09,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x78,0x00,0x71,0x00,0x68,0x00,0x5e,0x00,0x52,0x00,0x45,0x00,0x39,0x00,0x2c,0x00,0x20,0x00,0x15,0x00, + 0x0a,0x00,0x00,0x00,0x00,0x09,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7e,0x00,0x78,0x01,0x73,0x02,0x6e,0x02,0x6b,0x03,0x68,0x05,0x65,0x06,0x62,0x07,0x5f,0x07,0x5e,0x09, + 0x5c,0x0b,0x5a,0x0b,0x59,0x0c,0x57,0x0d,0x56,0x0e,0x54,0x0f,0x54,0x11,0x52,0x11,0x52,0x12,0x51,0x13, + 0x00,0x79,0x00,0x73,0x01,0x6e,0x02,0x69,0x03,0x66,0x04,0x62,0x05,0x5f,0x06,0x5d,0x07,0x5b,0x08,0x58, + 0x09,0x56,0x0b,0x55,0x0b,0x53,0x0d,0x52,0x0d,0x50,0x0f,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4d,0x12,0x4c, + 0x41,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x79,0x00,0x73, + 0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00,0x13,0x00,0x09, + 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x79,0x00,0x73,0x00,0x6b,0x00,0x62,0x00,0x57,0x00,0x4c,0x00,0x40,0x00,0x34,0x00,0x29,0x00,0x1e,0x00, + 0x13,0x00,0x09,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7e,0x00,0x78,0x00,0x74,0x01,0x6f,0x02,0x6c,0x03,0x68,0x04,0x65,0x05,0x62,0x06,0x61,0x07,0x5f,0x09, + 0x5c,0x09,0x5b,0x0b,0x5a,0x0b,0x58,0x0c,0x57,0x0d,0x55,0x0e,0x55,0x0f,0x54,0x11,0x52,0x11,0x52,0x12, + 0x00,0x79,0x00,0x74,0x00,0x6f,0x02,0x6a,0x03,0x66,0x04,0x63,0x05,0x60,0x05,0x5e,0x06,0x5b,0x07,0x59, + 0x09,0x58,0x09,0x55,0x0b,0x55,0x0c,0x53,0x0d,0x52,0x0d,0x50,0x0f,0x50,0x0f,0x4e,0x11,0x4e,0x11,0x4d, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00,0x7a,0x00,0x75, + 0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00,0x1b,0x00,0x12, + 0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x7d,0x00, + 0x7a,0x00,0x75,0x00,0x6e,0x00,0x65,0x00,0x5b,0x00,0x51,0x00,0x46,0x00,0x3b,0x00,0x30,0x00,0x26,0x00, + 0x1b,0x00,0x12,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, + 0x7e,0x00,0x79,0x00,0x74,0x01,0x70,0x02,0x6c,0x03,0x69,0x03,0x66,0x05,0x63,0x06,0x62,0x07,0x5f,0x07, + 0x5e,0x09,0x5c,0x0a,0x5a,0x0b,0x5a,0x0c,0x57,0x0c,0x56,0x0e,0x55,0x0e,0x55,0x0f,0x54,0x11,0x52,0x11, + 0x00,0x79,0x00,0x74,0x00,0x70,0x01,0x6b,0x02,0x67,0x03,0x64,0x04,0x61,0x05,0x5f,0x06,0x5d,0x07,0x5b, + 0x08,0x58,0x09,0x57,0x0a,0x55,0x0b,0x54,0x0c,0x53,0x0d,0x51,0x0e,0x50,0x0f,0x50,0x0f,0x4e,0x11,0x4e, + 0x41,0x3d,0x41,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d, + 0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x41,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d,0x42,0x3d, +}; + +static const unsigned char kSmaaSearch[SMAA_SEARCH_W * SMAA_SEARCH_H] = { + 0xfe,0xfe,0x00,0x7f,0x7f,0x00,0x00,0xfe,0xfe,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00, + 0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xfe,0xfe,0x00,0x7f,0x7f,0x00,0x00,0xfe,0xfe,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0xfe,0x7f,0x00, + 0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0x00,0x7f,0x7f,0x00,0x00,0xfe, + 0xfe,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00, + 0x7f,0x7f,0x00,0x7f,0x7f,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0x00,0x7f, + 0x7f,0x00,0x00,0xfe,0xfe,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00, + 0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f, + 0x7f,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f, + 0x7f,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00, + 0x7f,0x7f,0x00,0x7f,0x7f,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00, + 0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00,0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x7f,0x7f,0x00, + 0x00,0x00,0x00,0x00,0x7f,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, +}; diff --git a/app/src/main/cpp/shaders/smaa_weights.frag b/app/src/main/cpp/shaders/smaa_weights.frag new file mode 100644 index 0000000000..3d6bca5601 --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_weights.frag @@ -0,0 +1,25 @@ +#version 450 +#extension GL_GOOGLE_include_directive : require + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; +layout(set = 0, binding = 0) uniform sampler2D EdgeTexture; +layout(set = 1, binding = 0) uniform sampler2D AreaTexture; +layout(set = 2, binding = 0) uniform sampler2D SearchTexture; +layout(push_constant) uniform Constants { + vec4 ndc; + vec4 metrics; // 1/width, 1/height, width, height +} pc; + +#define SMAA_RT_METRICS pc.metrics +#define SMAA_GLSL_4 +#define SMAA_PRESET_HIGH +#include "SMAA.hlsl" + +void main() { + vec2 pixcoord; + vec4 offset[3]; + SMAABlendingWeightCalculationVS(fragTexCoord, pixcoord, offset); + outColor = SMAABlendingWeightCalculationPS(fragTexCoord, pixcoord, offset, EdgeTexture, + AreaTexture, SearchTexture, vec4(0.0)); +} diff --git a/app/src/main/cpp/shaders/smaa_weights_frag.h b/app/src/main/cpp/shaders/smaa_weights_frag.h new file mode 100644 index 0000000000..5802838e6e --- /dev/null +++ b/app/src/main/cpp/shaders/smaa_weights_frag.h @@ -0,0 +1,986 @@ + // 1116.6.0 + #pragma once +const uint32_t smaa_weights_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000004fe,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000004e7,0x000004f2,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f, + 0x70635f45,0x74735f70,0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004, + 0x475f4c47,0x4c474f4f,0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00080005,0x00000010,0x41414d53,0x63766f4d,0x32627628, + 0x3266763b,0x3266763b,0x0000003b,0x00040005,0x0000000d,0x646e6f63,0x00000000,0x00050005, + 0x0000000e,0x69726176,0x656c6261,0x00000000,0x00040005,0x0000000f,0x756c6176,0x00000065, + 0x000e0005,0x0000001b,0x41414d53,0x6e656c42,0x676e6964,0x67696557,0x61437468,0x6c75636c, + 0x6f697461,0x2853566e,0x3b326676,0x3b326676,0x5b346676,0x003b5d33,0x00050005,0x00000018, + 0x63786574,0x64726f6f,0x00000000,0x00050005,0x00000019,0x63786970,0x64726f6f,0x00000000, + 0x00040005,0x0000001a,0x7366666f,0x00007465,0x000b0005,0x0000001f,0x41414d53,0x6f636544, + 0x69446564,0x69426761,0x656e696c,0x63417261,0x73736563,0x32667628,0x0000003b,0x00030005, + 0x0000001e,0x00000065,0x000b0005,0x00000024,0x41414d53,0x6f636544,0x69446564,0x69426761, + 0x656e696c,0x63417261,0x73736563,0x34667628,0x0000003b,0x00030005,0x00000023,0x00000065, + 0x000b0005,0x0000002e,0x41414d53,0x72616553,0x69446863,0x28316761,0x3b313273,0x3b326676, + 0x3b326676,0x3b326676,0x00000000,0x00050005,0x0000002a,0x65676465,0x78655473,0x00000000, + 0x00050005,0x0000002b,0x63786574,0x64726f6f,0x00000000,0x00030005,0x0000002c,0x00726964, + 0x00030005,0x0000002d,0x00000065,0x000b0005,0x00000034,0x41414d53,0x72616553,0x69446863, + 0x28326761,0x3b313273,0x3b326676,0x3b326676,0x3b326676,0x00000000,0x00050005,0x00000030, + 0x65676465,0x78655473,0x00000000,0x00050005,0x00000031,0x63786574,0x64726f6f,0x00000000, + 0x00030005,0x00000032,0x00726964,0x00030005,0x00000033,0x00000065,0x000a0005,0x0000003c, + 0x41414d53,0x61657241,0x67616944,0x31327328,0x3266763b,0x3266763b,0x3b31663b,0x00000000, + 0x00040005,0x00000038,0x61657261,0x00786554,0x00040005,0x00000039,0x74736964,0x00000000, + 0x00030005,0x0000003a,0x00000065,0x00040005,0x0000003b,0x7366666f,0x00007465,0x000e0005, + 0x00000044,0x41414d53,0x636c6143,0x74616c75,0x61694465,0x69655767,0x73746867,0x31327328, + 0x3132733b,0x3266763b,0x3266763b,0x3466763b,0x0000003b,0x00050005,0x0000003f,0x65676465, + 0x78655473,0x00000000,0x00040005,0x00000040,0x61657261,0x00786554,0x00050005,0x00000041, + 0x63786574,0x64726f6f,0x00000000,0x00030005,0x00000042,0x00000065,0x00070005,0x00000043, + 0x73627573,0x6c706d61,0x646e4965,0x73656369,0x00000000,0x000a0005,0x0000004a,0x41414d53, + 0x72616553,0x654c6863,0x6874676e,0x31327328,0x3266763b,0x3b31663b,0x00000000,0x00050005, + 0x00000047,0x72616573,0x65546863,0x00000078,0x00030005,0x00000048,0x00000065,0x00040005, + 0x00000049,0x7366666f,0x00007465,0x000a0005,0x00000051,0x41414d53,0x72616553,0x4c586863, + 0x28746665,0x3b313273,0x3b313273,0x3b326676,0x003b3166,0x00050005,0x0000004d,0x65676465, + 0x78655473,0x00000000,0x00050005,0x0000004e,0x72616573,0x65546863,0x00000078,0x00050005, + 0x0000004f,0x63786574,0x64726f6f,0x00000000,0x00030005,0x00000050,0x00646e65,0x000b0005, + 0x00000057,0x41414d53,0x72616553,0x52586863,0x74686769,0x31327328,0x3132733b,0x3266763b, + 0x3b31663b,0x00000000,0x00050005,0x00000053,0x65676465,0x78655473,0x00000000,0x00050005, + 0x00000054,0x72616573,0x65546863,0x00000078,0x00050005,0x00000055,0x63786574,0x64726f6f, + 0x00000000,0x00030005,0x00000056,0x00646e65,0x000a0005,0x0000005d,0x41414d53,0x72616553, + 0x55596863,0x32732870,0x32733b31,0x66763b31,0x31663b32,0x0000003b,0x00050005,0x00000059, + 0x65676465,0x78655473,0x00000000,0x00050005,0x0000005a,0x72616573,0x65546863,0x00000078, + 0x00050005,0x0000005b,0x63786574,0x64726f6f,0x00000000,0x00030005,0x0000005c,0x00646e65, + 0x000a0005,0x00000063,0x41414d53,0x72616553,0x44596863,0x286e776f,0x3b313273,0x3b313273, + 0x3b326676,0x003b3166,0x00050005,0x0000005f,0x65676465,0x78655473,0x00000000,0x00050005, + 0x00000060,0x72616573,0x65546863,0x00000078,0x00050005,0x00000061,0x63786574,0x64726f6f, + 0x00000000,0x00030005,0x00000062,0x00646e65,0x00090005,0x0000006b,0x41414d53,0x61657241, + 0x31327328,0x3266763b,0x3b31663b,0x663b3166,0x00003b31,0x00040005,0x00000066,0x61657261, + 0x00786554,0x00040005,0x00000067,0x74736964,0x00000000,0x00030005,0x00000068,0x00003165, + 0x00030005,0x00000069,0x00003265,0x00040005,0x0000006a,0x7366666f,0x00007465,0x000f0005, + 0x00000072,0x41414d53,0x65746544,0x6f487463,0x6f7a6972,0x6c61746e,0x6e726f43,0x61507265, + 0x72657474,0x3273286e,0x66763b31,0x66763b32,0x66763b34,0x00003b32,0x00050005,0x0000006e, + 0x65676465,0x78655473,0x00000000,0x00040005,0x0000006f,0x67696577,0x00737468,0x00050005, + 0x00000070,0x63786574,0x64726f6f,0x00000000,0x00030005,0x00000071,0x00000064,0x000f0005, + 0x00000078,0x41414d53,0x65746544,0x65567463,0x63697472,0x6f436c61,0x72656e72,0x74746150, + 0x286e7265,0x3b313273,0x3b326676,0x3b346676,0x3b326676,0x00000000,0x00050005,0x00000074, + 0x65676465,0x78655473,0x00000000,0x00040005,0x00000075,0x67696577,0x00737468,0x00050005, + 0x00000076,0x63786574,0x64726f6f,0x00000000,0x00030005,0x00000077,0x00000064,0x00120005, + 0x00000082,0x41414d53,0x6e656c42,0x676e6964,0x67696557,0x61437468,0x6c75636c,0x6f697461, + 0x2853506e,0x3b326676,0x3b326676,0x5b346676,0x733b5d33,0x733b3132,0x733b3132,0x763b3132, + 0x003b3466,0x00050005,0x0000007b,0x63786574,0x64726f6f,0x00000000,0x00050005,0x0000007c, + 0x63786970,0x64726f6f,0x00000000,0x00040005,0x0000007d,0x7366666f,0x00007465,0x00050005, + 0x0000007e,0x65676465,0x78655473,0x00000000,0x00040005,0x0000007f,0x61657261,0x00786554, + 0x00050005,0x00000080,0x72616573,0x65546863,0x00000078,0x00070005,0x00000081,0x73627573, + 0x6c706d61,0x646e4965,0x73656369,0x00000000,0x00050005,0x00000096,0x736e6f43,0x746e6174, + 0x00000073,0x00040006,0x00000096,0x00000000,0x0063646e,0x00050006,0x00000096,0x00000001, + 0x7274656d,0x00736369,0x00030005,0x00000098,0x00006370,0x00040005,0x000000e9,0x726f6f63, + 0x00000064,0x00030005,0x000000f2,0x00000074,0x00040005,0x00000126,0x726f6f63,0x00000064, + 0x00030005,0x00000134,0x00000074,0x00040005,0x0000015c,0x61726170,0x0000006d,0x00050005, + 0x00000166,0x63786574,0x64726f6f,0x00000000,0x00040005,0x00000185,0x67696577,0x00737468, + 0x00030005,0x0000018c,0x00000064,0x00030005,0x0000018e,0x00646e65,0x00040005,0x0000018f, + 0x61726170,0x0000006d,0x00040005,0x00000191,0x61726170,0x0000006d,0x00040005,0x00000192, + 0x61726170,0x0000006d,0x00040005,0x000001a7,0x61726170,0x0000006d,0x00040005,0x000001a9, + 0x61726170,0x0000006d,0x00040005,0x000001aa,0x61726170,0x0000006d,0x00040005,0x000001ba, + 0x726f6f63,0x00007364,0x00030005,0x000001ce,0x00000063,0x00040005,0x000001e5,0x61726170, + 0x0000006d,0x00030005,0x000001ea,0x00006363,0x00040005,0x000001f6,0x61726170,0x0000006d, + 0x00040005,0x000001f7,0x61726170,0x0000006d,0x00040005,0x000001f9,0x61726170,0x0000006d, + 0x00040005,0x000001fc,0x61726170,0x0000006d,0x00040005,0x000001ff,0x61726170,0x0000006d, + 0x00040005,0x00000201,0x61726170,0x0000006d,0x00040005,0x00000208,0x61726170,0x0000006d, + 0x00040005,0x0000020a,0x61726170,0x0000006d,0x00040005,0x0000020b,0x61726170,0x0000006d, + 0x00040005,0x0000021a,0x61726170,0x0000006d,0x00040005,0x0000021c,0x61726170,0x0000006d, + 0x00040005,0x0000021d,0x61726170,0x0000006d,0x00040005,0x00000239,0x726f6f63,0x00007364, + 0x00030005,0x0000024b,0x00000063,0x00030005,0x00000262,0x00006363,0x00040005,0x0000026d, + 0x61726170,0x0000006d,0x00040005,0x0000026e,0x61726170,0x0000006d,0x00040005,0x00000270, + 0x61726170,0x0000006d,0x00040005,0x00000273,0x61726170,0x0000006d,0x00040005,0x00000276, + 0x61726170,0x0000006d,0x00040005,0x00000278,0x61726170,0x0000006d,0x00040005,0x00000282, + 0x6c616373,0x00000065,0x00040005,0x00000286,0x73616962,0x00000000,0x00030005,0x000002a2, + 0x00000065,0x00040005,0x000002c6,0x7366666f,0x00007465,0x00040005,0x000002c8,0x61726170, + 0x0000006d,0x00040005,0x000002ca,0x61726170,0x0000006d,0x00030005,0x000002d6,0x00000065, + 0x00040005,0x000002f6,0x7366666f,0x00007465,0x00040005,0x000002f7,0x61726170,0x0000006d, + 0x00040005,0x000002f9,0x61726170,0x0000006d,0x00030005,0x00000305,0x00000065,0x00040005, + 0x00000326,0x7366666f,0x00007465,0x00040005,0x00000327,0x61726170,0x0000006d,0x00040005, + 0x0000032a,0x61726170,0x0000006d,0x00030005,0x00000335,0x00000065,0x00040005,0x00000355, + 0x7366666f,0x00007465,0x00040005,0x00000356,0x61726170,0x0000006d,0x00040005,0x00000359, + 0x61726170,0x0000006d,0x00050005,0x00000365,0x63786574,0x64726f6f,0x00000000,0x00050005, + 0x0000037d,0x7466656c,0x68676952,0x00000074,0x00050005,0x00000382,0x6e756f72,0x676e6964, + 0x00000000,0x00040005,0x0000038e,0x74636166,0x0000726f,0x00050005,0x000003ca,0x7466656c, + 0x68676952,0x00000074,0x00050005,0x000003cf,0x6e756f72,0x676e6964,0x00000000,0x00040005, + 0x000003da,0x74636166,0x0000726f,0x00040005,0x00000413,0x67696577,0x00737468,0x00030005, + 0x00000415,0x00000065,0x00040005,0x0000041f,0x61726170,0x0000006d,0x00040005,0x00000421, + 0x61726170,0x0000006d,0x00040005,0x00000423,0x61726170,0x0000006d,0x00040005,0x00000432, + 0x726f6f63,0x00007364,0x00040005,0x00000433,0x61726170,0x0000006d,0x00040005,0x00000437, + 0x61726170,0x0000006d,0x00030005,0x0000043f,0x00000064,0x00030005,0x00000443,0x00003165, + 0x00040005,0x00000449,0x61726170,0x0000006d,0x00040005,0x0000044d,0x61726170,0x0000006d, + 0x00040005,0x0000045f,0x74727173,0x0000645f,0x00030005,0x00000462,0x00003265,0x00040005, + 0x00000468,0x61726170,0x0000006d,0x00040005,0x0000046a,0x61726170,0x0000006d,0x00040005, + 0x0000046c,0x61726170,0x0000006d,0x00040005,0x0000046e,0x61726170,0x0000006d,0x00040005, + 0x00000479,0x61726170,0x0000006d,0x00040005,0x0000047c,0x61726170,0x0000006d,0x00040005, + 0x0000047f,0x61726170,0x0000006d,0x00040005,0x0000048e,0x726f6f63,0x00007364,0x00040005, + 0x0000048f,0x61726170,0x0000006d,0x00040005,0x00000493,0x61726170,0x0000006d,0x00030005, + 0x0000049b,0x00000064,0x00030005,0x0000049f,0x00003165,0x00040005,0x000004a5,0x61726170, + 0x0000006d,0x00040005,0x000004a9,0x61726170,0x0000006d,0x00040005,0x000004bb,0x74727173, + 0x0000645f,0x00030005,0x000004be,0x00003265,0x00040005,0x000004c4,0x61726170,0x0000006d, + 0x00040005,0x000004c6,0x61726170,0x0000006d,0x00040005,0x000004c8,0x61726170,0x0000006d, + 0x00040005,0x000004ca,0x61726170,0x0000006d,0x00040005,0x000004d5,0x61726170,0x0000006d, + 0x00040005,0x000004d8,0x61726170,0x0000006d,0x00040005,0x000004db,0x61726170,0x0000006d, + 0x00060005,0x000004e7,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00050005,0x000004e8, + 0x63786970,0x64726f6f,0x00000000,0x00040005,0x000004e9,0x7366666f,0x00007465,0x00040005, + 0x000004ea,0x61726170,0x0000006d,0x00040005,0x000004ec,0x61726170,0x0000006d,0x00040005, + 0x000004ed,0x61726170,0x0000006d,0x00050005,0x000004f2,0x4374756f,0x726f6c6f,0x00000000, + 0x00050005,0x000004f3,0x65676445,0x74786554,0x00657275,0x00050005,0x000004f4,0x61657241, + 0x74786554,0x00657275,0x00060005,0x000004f5,0x72616553,0x65546863,0x72757478,0x00000065, + 0x00040005,0x000004f6,0x61726170,0x0000006d,0x00040005,0x000004f8,0x61726170,0x0000006d, + 0x00040005,0x000004fa,0x61726170,0x0000006d,0x00040005,0x000004fc,0x61726170,0x0000006d, + 0x00030047,0x00000096,0x00000002,0x00050048,0x00000096,0x00000000,0x00000023,0x00000000, + 0x00050048,0x00000096,0x00000001,0x00000023,0x00000010,0x00040047,0x000004e7,0x0000001e, + 0x00000000,0x00040047,0x000004f2,0x0000001e,0x00000000,0x00040047,0x000004f3,0x00000021, + 0x00000000,0x00040047,0x000004f3,0x00000022,0x00000000,0x00040047,0x000004f4,0x00000021, + 0x00000000,0x00040047,0x000004f4,0x00000022,0x00000001,0x00040047,0x000004f5,0x00000021, + 0x00000000,0x00040047,0x000004f5,0x00000022,0x00000002,0x00020013,0x00000002,0x00030021, + 0x00000003,0x00000002,0x00020014,0x00000006,0x00040017,0x00000007,0x00000006,0x00000002, + 0x00040020,0x00000008,0x00000007,0x00000007,0x00030016,0x00000009,0x00000020,0x00040017, + 0x0000000a,0x00000009,0x00000002,0x00040020,0x0000000b,0x00000007,0x0000000a,0x00060021, + 0x0000000c,0x00000002,0x00000008,0x0000000b,0x0000000b,0x00040017,0x00000012,0x00000009, + 0x00000004,0x00040015,0x00000013,0x00000020,0x00000000,0x0004002b,0x00000013,0x00000014, + 0x00000003,0x0004001c,0x00000015,0x00000012,0x00000014,0x00040020,0x00000016,0x00000007, + 0x00000015,0x00060021,0x00000017,0x00000002,0x0000000b,0x0000000b,0x00000016,0x00040021, + 0x0000001d,0x0000000a,0x0000000b,0x00040020,0x00000021,0x00000007,0x00000012,0x00040021, + 0x00000022,0x00000012,0x00000021,0x00090019,0x00000026,0x00000009,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000027,0x00000026,0x00040020, + 0x00000028,0x00000000,0x00000027,0x00070021,0x00000029,0x0000000a,0x00000028,0x0000000b, + 0x0000000b,0x0000000b,0x00040020,0x00000036,0x00000007,0x00000009,0x00070021,0x00000037, + 0x0000000a,0x00000028,0x0000000b,0x0000000b,0x00000036,0x00080021,0x0000003e,0x0000000a, + 0x00000028,0x00000028,0x0000000b,0x0000000b,0x00000021,0x00060021,0x00000046,0x00000009, + 0x00000028,0x0000000b,0x00000036,0x00070021,0x0000004c,0x00000009,0x00000028,0x00000028, + 0x0000000b,0x00000036,0x00080021,0x00000065,0x0000000a,0x00000028,0x0000000b,0x00000036, + 0x00000036,0x00000036,0x00070021,0x0000006d,0x00000002,0x00000028,0x0000000b,0x00000021, + 0x0000000b,0x000a0021,0x0000007a,0x00000012,0x0000000b,0x0000000b,0x00000016,0x00000028, + 0x00000028,0x00000028,0x00000021,0x0004002b,0x00000013,0x00000084,0x00000000,0x00040020, + 0x00000085,0x00000007,0x00000006,0x0004002b,0x00000013,0x0000008d,0x00000001,0x0004001e, + 0x00000096,0x00000012,0x00000012,0x00040020,0x00000097,0x00000009,0x00000096,0x0004003b, + 0x00000097,0x00000098,0x00000009,0x00040015,0x00000099,0x00000020,0x00000001,0x0004002b, + 0x00000099,0x0000009a,0x00000001,0x00040020,0x0000009b,0x00000009,0x00000012,0x0004002b, + 0x00000099,0x000000a0,0x00000000,0x0004002b,0x00000009,0x000000a4,0xbe800000,0x0004002b, + 0x00000009,0x000000a5,0xbe000000,0x0004002b,0x00000009,0x000000a6,0x3fa00000,0x0007002c, + 0x00000012,0x000000a7,0x000000a4,0x000000a5,0x000000a6,0x000000a5,0x0007002c,0x00000012, + 0x000000af,0x000000a5,0x000000a4,0x000000a5,0x000000a6,0x0004002b,0x00000099,0x000000b4, + 0x00000002,0x0004002b,0x00000009,0x000000b8,0xc2000000,0x0004002b,0x00000009,0x000000b9, + 0x42000000,0x0007002c,0x00000012,0x000000ba,0x000000b8,0x000000b9,0x000000b8,0x000000b9, + 0x0004002b,0x00000009,0x000000ca,0x40a00000,0x0004002b,0x00000009,0x000000ce,0x40700000, + 0x0004002b,0x00000013,0x000000e2,0x00000002,0x0004002b,0x00000009,0x000000eb,0xbf800000, + 0x0004002b,0x00000009,0x000000ec,0x3f800000,0x00040017,0x000000f0,0x00000009,0x00000003, + 0x00040020,0x000000f1,0x00000007,0x000000f0,0x0004002b,0x00000009,0x00000100,0x40e00000, + 0x0004002b,0x00000009,0x00000106,0x3f666666,0x0004002b,0x00000009,0x0000011a,0x00000000, + 0x0004002b,0x00000009,0x0000011e,0x3f000000,0x0005002c,0x0000000a,0x0000011f,0x0000011e, + 0x0000011e,0x0004002b,0x00000009,0x0000012b,0x3e800000,0x00040020,0x0000012c,0x00000009, + 0x00000009,0x0004002b,0x00000009,0x00000167,0x41a00000,0x0005002c,0x0000000a,0x00000168, + 0x00000167,0x00000167,0x0004002b,0x00000009,0x0000016c,0x3bcccccd,0x0004002b,0x00000009, + 0x0000016d,0x3aea0ea1,0x0005002c,0x0000000a,0x0000016e,0x0000016c,0x0000016d,0x0004002b, + 0x00000009,0x00000170,0x3b4ccccd,0x0004002b,0x00000009,0x00000171,0x3a6a0ea1,0x0005002c, + 0x0000000a,0x00000172,0x00000170,0x00000171,0x0004002b,0x00000009,0x00000178,0x3e124925, + 0x0005002c,0x0000000a,0x00000186,0x0000011a,0x0000011a,0x0005002c,0x0000000a,0x0000018d, + 0x000000eb,0x000000ec,0x0005002c,0x0000000a,0x000001a6,0x000000ec,0x000000eb,0x0004002b, + 0x00000009,0x000001b6,0x40000000,0x00040017,0x000001d2,0x00000099,0x00000002,0x0004002b, + 0x00000099,0x000001d3,0xffffffff,0x0005002c,0x000001d2,0x000001d4,0x000001d3,0x000000a0, + 0x0005002c,0x000001d2,0x000001de,0x0000009a,0x000000a0,0x0005002c,0x0000000a,0x000001eb, + 0x000001b6,0x000001b6,0x0005002c,0x0000000a,0x00000207,0x000000eb,0x000000eb,0x0005002c, + 0x0000000a,0x00000219,0x000000ec,0x000000ec,0x0005002c,0x000001d2,0x00000255,0x000000a0, + 0x000001d3,0x0004002b,0x00000009,0x00000283,0x42040000,0x0004002b,0x00000009,0x00000284, + 0xc2040000,0x0005002c,0x0000000a,0x00000285,0x00000283,0x00000284,0x0004002b,0x00000009, + 0x00000287,0x42840000,0x0005002c,0x0000000a,0x00000288,0x00000287,0x00000283,0x0004002b, + 0x00000009,0x0000028e,0xbf000000,0x0005002c,0x0000000a,0x0000028f,0x0000011e,0x0000028e, + 0x0004002b,0x00000009,0x00000292,0x3c800000,0x0004002b,0x00000009,0x00000293,0x3d800000, + 0x0005002c,0x0000000a,0x00000294,0x00000292,0x00000293,0x0005002c,0x0000000a,0x000002a3, + 0x0000011a,0x000000ec,0x0004002b,0x00000009,0x000002b1,0x3f53fe5d,0x0004002b,0x00000009, + 0x000002be,0xc0000000,0x0004002b,0x00000009,0x000002bf,0x80000000,0x0005002c,0x0000000a, + 0x000002c0,0x000002be,0x000002bf,0x0004002b,0x00000009,0x000002c7,0xc0008102,0x0004002b, + 0x00000009,0x000002cc,0x40500000,0x0005002c,0x0000000a,0x000002f0,0x000001b6,0x0000011a, + 0x0005002c,0x0000000a,0x00000306,0x000000ec,0x0000011a,0x0005002c,0x0000000a,0x00000320, + 0x000002bf,0x000002be,0x0005002c,0x0000000a,0x0000034f,0x0000011a,0x000001b6,0x0004002b, + 0x00000009,0x00000366,0x41800000,0x0005002c,0x0000000a,0x00000367,0x00000366,0x00000366, + 0x0004002b,0x00000009,0x00000368,0x40800000,0x0004002b,0x00000009,0x00000383,0x3f400000, + 0x0005002c,0x000001d2,0x00000394,0x000000a0,0x0000009a,0x0005002c,0x000001d2,0x000003a1, + 0x0000009a,0x0000009a,0x0004002b,0x00000099,0x000003ae,0xfffffffe,0x0005002c,0x000001d2, + 0x000003af,0x000000a0,0x000003ae,0x0005002c,0x000001d2,0x000003bc,0x0000009a,0x000003ae, + 0x0005002c,0x000001d2,0x000003f8,0x000003ae,0x000000a0,0x0005002c,0x000001d2,0x00000405, + 0x000003ae,0x0000009a,0x0007002c,0x00000012,0x00000414,0x0000011a,0x0000011a,0x0000011a, + 0x0000011a,0x00040020,0x000004e6,0x00000001,0x0000000a,0x0004003b,0x000004e6,0x000004e7, + 0x00000001,0x00040020,0x000004f1,0x00000003,0x00000012,0x0004003b,0x000004f1,0x000004f2, + 0x00000003,0x0004003b,0x00000028,0x000004f3,0x00000000,0x0004003b,0x00000028,0x000004f4, + 0x00000000,0x0004003b,0x00000028,0x000004f5,0x00000000,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000b,0x000004e8,0x00000007, + 0x0004003b,0x00000016,0x000004e9,0x00000007,0x0004003b,0x0000000b,0x000004ea,0x00000007, + 0x0004003b,0x0000000b,0x000004ec,0x00000007,0x0004003b,0x00000016,0x000004ed,0x00000007, + 0x0004003b,0x0000000b,0x000004f6,0x00000007,0x0004003b,0x0000000b,0x000004f8,0x00000007, + 0x0004003b,0x00000016,0x000004fa,0x00000007,0x0004003b,0x00000021,0x000004fc,0x00000007, + 0x0004003d,0x0000000a,0x000004eb,0x000004e7,0x0003003e,0x000004ea,0x000004eb,0x00070039, + 0x00000002,0x000004ee,0x0000001b,0x000004ea,0x000004ec,0x000004ed,0x0004003d,0x0000000a, + 0x000004ef,0x000004ec,0x0003003e,0x000004e8,0x000004ef,0x0004003d,0x00000015,0x000004f0, + 0x000004ed,0x0003003e,0x000004e9,0x000004f0,0x0004003d,0x0000000a,0x000004f7,0x000004e7, + 0x0003003e,0x000004f6,0x000004f7,0x0004003d,0x0000000a,0x000004f9,0x000004e8,0x0003003e, + 0x000004f8,0x000004f9,0x0004003d,0x00000015,0x000004fb,0x000004e9,0x0003003e,0x000004fa, + 0x000004fb,0x0003003e,0x000004fc,0x00000414,0x000b0039,0x00000012,0x000004fd,0x00000082, + 0x000004f6,0x000004f8,0x000004fa,0x000004f3,0x000004f4,0x000004f5,0x000004fc,0x0003003e, + 0x000004f2,0x000004fd,0x000100fd,0x00010038,0x00050036,0x00000002,0x00000010,0x00000000, + 0x0000000c,0x00030037,0x00000008,0x0000000d,0x00030037,0x0000000b,0x0000000e,0x00030037, + 0x0000000b,0x0000000f,0x000200f8,0x00000011,0x00050041,0x00000085,0x00000086,0x0000000d, + 0x00000084,0x0004003d,0x00000006,0x00000087,0x00000086,0x000300f7,0x00000089,0x00000000, + 0x000400fa,0x00000087,0x00000088,0x00000089,0x000200f8,0x00000088,0x00050041,0x00000036, + 0x0000008a,0x0000000f,0x00000084,0x0004003d,0x00000009,0x0000008b,0x0000008a,0x00050041, + 0x00000036,0x0000008c,0x0000000e,0x00000084,0x0003003e,0x0000008c,0x0000008b,0x000200f9, + 0x00000089,0x000200f8,0x00000089,0x00050041,0x00000085,0x0000008e,0x0000000d,0x0000008d, + 0x0004003d,0x00000006,0x0000008f,0x0000008e,0x000300f7,0x00000091,0x00000000,0x000400fa, + 0x0000008f,0x00000090,0x00000091,0x000200f8,0x00000090,0x00050041,0x00000036,0x00000092, + 0x0000000f,0x0000008d,0x0004003d,0x00000009,0x00000093,0x00000092,0x00050041,0x00000036, + 0x00000094,0x0000000e,0x0000008d,0x0003003e,0x00000094,0x00000093,0x000200f9,0x00000091, + 0x000200f8,0x00000091,0x000100fd,0x00010038,0x00050036,0x00000002,0x0000001b,0x00000000, + 0x00000017,0x00030037,0x0000000b,0x00000018,0x00030037,0x0000000b,0x00000019,0x00030037, + 0x00000016,0x0000001a,0x000200f8,0x0000001c,0x0004003d,0x0000000a,0x00000095,0x00000018, + 0x00050041,0x0000009b,0x0000009c,0x00000098,0x0000009a,0x0004003d,0x00000012,0x0000009d, + 0x0000009c,0x0007004f,0x0000000a,0x0000009e,0x0000009d,0x0000009d,0x00000002,0x00000003, + 0x00050085,0x0000000a,0x0000009f,0x00000095,0x0000009e,0x0003003e,0x00000019,0x0000009f, + 0x00050041,0x0000009b,0x000000a1,0x00000098,0x0000009a,0x0004003d,0x00000012,0x000000a2, + 0x000000a1,0x0009004f,0x00000012,0x000000a3,0x000000a2,0x000000a2,0x00000000,0x00000001, + 0x00000000,0x00000001,0x0004003d,0x0000000a,0x000000a8,0x00000018,0x0009004f,0x00000012, + 0x000000a9,0x000000a8,0x000000a8,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c, + 0x00000012,0x000000aa,0x00000001,0x00000032,0x000000a3,0x000000a7,0x000000a9,0x00050041, + 0x00000021,0x000000ab,0x0000001a,0x000000a0,0x0003003e,0x000000ab,0x000000aa,0x00050041, + 0x0000009b,0x000000ac,0x00000098,0x0000009a,0x0004003d,0x00000012,0x000000ad,0x000000ac, + 0x0009004f,0x00000012,0x000000ae,0x000000ad,0x000000ad,0x00000000,0x00000001,0x00000000, + 0x00000001,0x0004003d,0x0000000a,0x000000b0,0x00000018,0x0009004f,0x00000012,0x000000b1, + 0x000000b0,0x000000b0,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c,0x00000012, + 0x000000b2,0x00000001,0x00000032,0x000000ae,0x000000af,0x000000b1,0x00050041,0x00000021, + 0x000000b3,0x0000001a,0x0000009a,0x0003003e,0x000000b3,0x000000b2,0x00050041,0x0000009b, + 0x000000b5,0x00000098,0x0000009a,0x0004003d,0x00000012,0x000000b6,0x000000b5,0x0009004f, + 0x00000012,0x000000b7,0x000000b6,0x000000b6,0x00000000,0x00000000,0x00000001,0x00000001, + 0x00050041,0x00000021,0x000000bb,0x0000001a,0x000000a0,0x0004003d,0x00000012,0x000000bc, + 0x000000bb,0x0007004f,0x0000000a,0x000000bd,0x000000bc,0x000000bc,0x00000000,0x00000002, + 0x00050041,0x00000021,0x000000be,0x0000001a,0x0000009a,0x0004003d,0x00000012,0x000000bf, + 0x000000be,0x0007004f,0x0000000a,0x000000c0,0x000000bf,0x000000bf,0x00000001,0x00000003, + 0x00050051,0x00000009,0x000000c1,0x000000bd,0x00000000,0x00050051,0x00000009,0x000000c2, + 0x000000bd,0x00000001,0x00050051,0x00000009,0x000000c3,0x000000c0,0x00000000,0x00050051, + 0x00000009,0x000000c4,0x000000c0,0x00000001,0x00070050,0x00000012,0x000000c5,0x000000c1, + 0x000000c2,0x000000c3,0x000000c4,0x0008000c,0x00000012,0x000000c6,0x00000001,0x00000032, + 0x000000b7,0x000000ba,0x000000c5,0x00050041,0x00000021,0x000000c7,0x0000001a,0x000000b4, + 0x0003003e,0x000000c7,0x000000c6,0x000100fd,0x00010038,0x00050036,0x0000000a,0x0000001f, + 0x00000000,0x0000001d,0x00030037,0x0000000b,0x0000001e,0x000200f8,0x00000020,0x00050041, + 0x00000036,0x000000c8,0x0000001e,0x00000084,0x0004003d,0x00000009,0x000000c9,0x000000c8, + 0x00050041,0x00000036,0x000000cb,0x0000001e,0x00000084,0x0004003d,0x00000009,0x000000cc, + 0x000000cb,0x00050085,0x00000009,0x000000cd,0x000000ca,0x000000cc,0x00050083,0x00000009, + 0x000000cf,0x000000cd,0x000000ce,0x0006000c,0x00000009,0x000000d0,0x00000001,0x00000004, + 0x000000cf,0x00050085,0x00000009,0x000000d1,0x000000c9,0x000000d0,0x00050041,0x00000036, + 0x000000d2,0x0000001e,0x00000084,0x0003003e,0x000000d2,0x000000d1,0x0004003d,0x0000000a, + 0x000000d3,0x0000001e,0x0006000c,0x0000000a,0x000000d4,0x00000001,0x00000001,0x000000d3, + 0x000200fe,0x000000d4,0x00010038,0x00050036,0x00000012,0x00000024,0x00000000,0x00000022, + 0x00030037,0x00000021,0x00000023,0x000200f8,0x00000025,0x0004003d,0x00000012,0x000000d7, + 0x00000023,0x0007004f,0x0000000a,0x000000d8,0x000000d7,0x000000d7,0x00000000,0x00000002, + 0x0004003d,0x00000012,0x000000d9,0x00000023,0x0007004f,0x0000000a,0x000000da,0x000000d9, + 0x000000d9,0x00000000,0x00000002,0x0005008e,0x0000000a,0x000000db,0x000000da,0x000000ca, + 0x00050050,0x0000000a,0x000000dc,0x000000ce,0x000000ce,0x00050083,0x0000000a,0x000000dd, + 0x000000db,0x000000dc,0x0006000c,0x0000000a,0x000000de,0x00000001,0x00000004,0x000000dd, + 0x00050085,0x0000000a,0x000000df,0x000000d8,0x000000de,0x00050041,0x00000036,0x000000e0, + 0x00000023,0x00000084,0x00050051,0x00000009,0x000000e1,0x000000df,0x00000000,0x0003003e, + 0x000000e0,0x000000e1,0x00050041,0x00000036,0x000000e3,0x00000023,0x000000e2,0x00050051, + 0x00000009,0x000000e4,0x000000df,0x00000001,0x0003003e,0x000000e3,0x000000e4,0x0004003d, + 0x00000012,0x000000e5,0x00000023,0x0006000c,0x00000012,0x000000e6,0x00000001,0x00000001, + 0x000000e5,0x000200fe,0x000000e6,0x00010038,0x00050036,0x0000000a,0x0000002e,0x00000000, + 0x00000029,0x00030037,0x00000028,0x0000002a,0x00030037,0x0000000b,0x0000002b,0x00030037, + 0x0000000b,0x0000002c,0x00030037,0x0000000b,0x0000002d,0x000200f8,0x0000002f,0x0004003b, + 0x00000021,0x000000e9,0x00000007,0x0004003b,0x000000f1,0x000000f2,0x00000007,0x0004003d, + 0x0000000a,0x000000ea,0x0000002b,0x00050051,0x00000009,0x000000ed,0x000000ea,0x00000000, + 0x00050051,0x00000009,0x000000ee,0x000000ea,0x00000001,0x00070050,0x00000012,0x000000ef, + 0x000000ed,0x000000ee,0x000000eb,0x000000ec,0x0003003e,0x000000e9,0x000000ef,0x00050041, + 0x0000009b,0x000000f3,0x00000098,0x0000009a,0x0004003d,0x00000012,0x000000f4,0x000000f3, + 0x0007004f,0x0000000a,0x000000f5,0x000000f4,0x000000f4,0x00000000,0x00000001,0x00050051, + 0x00000009,0x000000f6,0x000000f5,0x00000000,0x00050051,0x00000009,0x000000f7,0x000000f5, + 0x00000001,0x00060050,0x000000f0,0x000000f8,0x000000f6,0x000000f7,0x000000ec,0x0003003e, + 0x000000f2,0x000000f8,0x000200f9,0x000000f9,0x000200f8,0x000000f9,0x000400f6,0x000000fb, + 0x000000fc,0x00000000,0x000200f9,0x000000fd,0x000200f8,0x000000fd,0x00050041,0x00000036, + 0x000000fe,0x000000e9,0x000000e2,0x0004003d,0x00000009,0x000000ff,0x000000fe,0x000500b8, + 0x00000006,0x00000101,0x000000ff,0x00000100,0x000300f7,0x00000103,0x00000000,0x000400fa, + 0x00000101,0x00000102,0x00000103,0x000200f8,0x00000102,0x00050041,0x00000036,0x00000104, + 0x000000e9,0x00000014,0x0004003d,0x00000009,0x00000105,0x00000104,0x000500ba,0x00000006, + 0x00000107,0x00000105,0x00000106,0x000200f9,0x00000103,0x000200f8,0x00000103,0x000700f5, + 0x00000006,0x00000108,0x00000101,0x000000fd,0x00000107,0x00000102,0x000400fa,0x00000108, + 0x000000fa,0x000000fb,0x000200f8,0x000000fa,0x0004003d,0x000000f0,0x00000109,0x000000f2, + 0x0004003d,0x0000000a,0x0000010a,0x0000002c,0x00050051,0x00000009,0x0000010b,0x0000010a, + 0x00000000,0x00050051,0x00000009,0x0000010c,0x0000010a,0x00000001,0x00060050,0x000000f0, + 0x0000010d,0x0000010b,0x0000010c,0x000000ec,0x0004003d,0x00000012,0x0000010e,0x000000e9, + 0x0008004f,0x000000f0,0x0000010f,0x0000010e,0x0000010e,0x00000000,0x00000001,0x00000002, + 0x0008000c,0x000000f0,0x00000110,0x00000001,0x00000032,0x00000109,0x0000010d,0x0000010f, + 0x00050041,0x00000036,0x00000111,0x000000e9,0x00000084,0x00050051,0x00000009,0x00000112, + 0x00000110,0x00000000,0x0003003e,0x00000111,0x00000112,0x00050041,0x00000036,0x00000113, + 0x000000e9,0x0000008d,0x00050051,0x00000009,0x00000114,0x00000110,0x00000001,0x0003003e, + 0x00000113,0x00000114,0x00050041,0x00000036,0x00000115,0x000000e9,0x000000e2,0x00050051, + 0x00000009,0x00000116,0x00000110,0x00000002,0x0003003e,0x00000115,0x00000116,0x0004003d, + 0x00000027,0x00000117,0x0000002a,0x0004003d,0x00000012,0x00000118,0x000000e9,0x0007004f, + 0x0000000a,0x00000119,0x00000118,0x00000118,0x00000000,0x00000001,0x00070058,0x00000012, + 0x0000011b,0x00000117,0x00000119,0x00000002,0x0000011a,0x0007004f,0x0000000a,0x0000011c, + 0x0000011b,0x0000011b,0x00000000,0x00000001,0x0003003e,0x0000002d,0x0000011c,0x0004003d, + 0x0000000a,0x0000011d,0x0000002d,0x00050094,0x00000009,0x00000120,0x0000011d,0x0000011f, + 0x00050041,0x00000036,0x00000121,0x000000e9,0x00000014,0x0003003e,0x00000121,0x00000120, + 0x000200f9,0x000000fc,0x000200f8,0x000000fc,0x000200f9,0x000000f9,0x000200f8,0x000000fb, + 0x0004003d,0x00000012,0x00000122,0x000000e9,0x0007004f,0x0000000a,0x00000123,0x00000122, + 0x00000122,0x00000002,0x00000003,0x000200fe,0x00000123,0x00010038,0x00050036,0x0000000a, + 0x00000034,0x00000000,0x00000029,0x00030037,0x00000028,0x00000030,0x00030037,0x0000000b, + 0x00000031,0x00030037,0x0000000b,0x00000032,0x00030037,0x0000000b,0x00000033,0x000200f8, + 0x00000035,0x0004003b,0x00000021,0x00000126,0x00000007,0x0004003b,0x000000f1,0x00000134, + 0x00000007,0x0004003b,0x0000000b,0x0000015c,0x00000007,0x0004003d,0x0000000a,0x00000127, + 0x00000031,0x00050051,0x00000009,0x00000128,0x00000127,0x00000000,0x00050051,0x00000009, + 0x00000129,0x00000127,0x00000001,0x00070050,0x00000012,0x0000012a,0x00000128,0x00000129, + 0x000000eb,0x000000ec,0x0003003e,0x00000126,0x0000012a,0x00060041,0x0000012c,0x0000012d, + 0x00000098,0x0000009a,0x00000084,0x0004003d,0x00000009,0x0000012e,0x0000012d,0x00050085, + 0x00000009,0x0000012f,0x0000012b,0x0000012e,0x00050041,0x00000036,0x00000130,0x00000126, + 0x00000084,0x0004003d,0x00000009,0x00000131,0x00000130,0x00050081,0x00000009,0x00000132, + 0x00000131,0x0000012f,0x00050041,0x00000036,0x00000133,0x00000126,0x00000084,0x0003003e, + 0x00000133,0x00000132,0x00050041,0x0000009b,0x00000135,0x00000098,0x0000009a,0x0004003d, + 0x00000012,0x00000136,0x00000135,0x0007004f,0x0000000a,0x00000137,0x00000136,0x00000136, + 0x00000000,0x00000001,0x00050051,0x00000009,0x00000138,0x00000137,0x00000000,0x00050051, + 0x00000009,0x00000139,0x00000137,0x00000001,0x00060050,0x000000f0,0x0000013a,0x00000138, + 0x00000139,0x000000ec,0x0003003e,0x00000134,0x0000013a,0x000200f9,0x0000013b,0x000200f8, + 0x0000013b,0x000400f6,0x0000013d,0x0000013e,0x00000000,0x000200f9,0x0000013f,0x000200f8, + 0x0000013f,0x00050041,0x00000036,0x00000140,0x00000126,0x000000e2,0x0004003d,0x00000009, + 0x00000141,0x00000140,0x000500b8,0x00000006,0x00000142,0x00000141,0x00000100,0x000300f7, + 0x00000144,0x00000000,0x000400fa,0x00000142,0x00000143,0x00000144,0x000200f8,0x00000143, + 0x00050041,0x00000036,0x00000145,0x00000126,0x00000014,0x0004003d,0x00000009,0x00000146, + 0x00000145,0x000500ba,0x00000006,0x00000147,0x00000146,0x00000106,0x000200f9,0x00000144, + 0x000200f8,0x00000144,0x000700f5,0x00000006,0x00000148,0x00000142,0x0000013f,0x00000147, + 0x00000143,0x000400fa,0x00000148,0x0000013c,0x0000013d,0x000200f8,0x0000013c,0x0004003d, + 0x000000f0,0x00000149,0x00000134,0x0004003d,0x0000000a,0x0000014a,0x00000032,0x00050051, + 0x00000009,0x0000014b,0x0000014a,0x00000000,0x00050051,0x00000009,0x0000014c,0x0000014a, + 0x00000001,0x00060050,0x000000f0,0x0000014d,0x0000014b,0x0000014c,0x000000ec,0x0004003d, + 0x00000012,0x0000014e,0x00000126,0x0008004f,0x000000f0,0x0000014f,0x0000014e,0x0000014e, + 0x00000000,0x00000001,0x00000002,0x0008000c,0x000000f0,0x00000150,0x00000001,0x00000032, + 0x00000149,0x0000014d,0x0000014f,0x00050041,0x00000036,0x00000151,0x00000126,0x00000084, + 0x00050051,0x00000009,0x00000152,0x00000150,0x00000000,0x0003003e,0x00000151,0x00000152, + 0x00050041,0x00000036,0x00000153,0x00000126,0x0000008d,0x00050051,0x00000009,0x00000154, + 0x00000150,0x00000001,0x0003003e,0x00000153,0x00000154,0x00050041,0x00000036,0x00000155, + 0x00000126,0x000000e2,0x00050051,0x00000009,0x00000156,0x00000150,0x00000002,0x0003003e, + 0x00000155,0x00000156,0x0004003d,0x00000027,0x00000157,0x00000030,0x0004003d,0x00000012, + 0x00000158,0x00000126,0x0007004f,0x0000000a,0x00000159,0x00000158,0x00000158,0x00000000, + 0x00000001,0x00070058,0x00000012,0x0000015a,0x00000157,0x00000159,0x00000002,0x0000011a, + 0x0007004f,0x0000000a,0x0000015b,0x0000015a,0x0000015a,0x00000000,0x00000001,0x0003003e, + 0x00000033,0x0000015b,0x0004003d,0x0000000a,0x0000015d,0x00000033,0x0003003e,0x0000015c, + 0x0000015d,0x00050039,0x0000000a,0x0000015e,0x0000001f,0x0000015c,0x0003003e,0x00000033, + 0x0000015e,0x0004003d,0x0000000a,0x0000015f,0x00000033,0x00050094,0x00000009,0x00000160, + 0x0000015f,0x0000011f,0x00050041,0x00000036,0x00000161,0x00000126,0x00000014,0x0003003e, + 0x00000161,0x00000160,0x000200f9,0x0000013e,0x000200f8,0x0000013e,0x000200f9,0x0000013b, + 0x000200f8,0x0000013d,0x0004003d,0x00000012,0x00000162,0x00000126,0x0007004f,0x0000000a, + 0x00000163,0x00000162,0x00000162,0x00000002,0x00000003,0x000200fe,0x00000163,0x00010038, + 0x00050036,0x0000000a,0x0000003c,0x00000000,0x00000037,0x00030037,0x00000028,0x00000038, + 0x00030037,0x0000000b,0x00000039,0x00030037,0x0000000b,0x0000003a,0x00030037,0x00000036, + 0x0000003b,0x000200f8,0x0000003d,0x0004003b,0x0000000b,0x00000166,0x00000007,0x0004003d, + 0x0000000a,0x00000169,0x0000003a,0x0004003d,0x0000000a,0x0000016a,0x00000039,0x0008000c, + 0x0000000a,0x0000016b,0x00000001,0x00000032,0x00000168,0x00000169,0x0000016a,0x0003003e, + 0x00000166,0x0000016b,0x0004003d,0x0000000a,0x0000016f,0x00000166,0x0008000c,0x0000000a, + 0x00000173,0x00000001,0x00000032,0x0000016e,0x0000016f,0x00000172,0x0003003e,0x00000166, + 0x00000173,0x00050041,0x00000036,0x00000174,0x00000166,0x00000084,0x0004003d,0x00000009, + 0x00000175,0x00000174,0x00050081,0x00000009,0x00000176,0x00000175,0x0000011e,0x00050041, + 0x00000036,0x00000177,0x00000166,0x00000084,0x0003003e,0x00000177,0x00000176,0x0004003d, + 0x00000009,0x00000179,0x0000003b,0x00050085,0x00000009,0x0000017a,0x00000178,0x00000179, + 0x00050041,0x00000036,0x0000017b,0x00000166,0x0000008d,0x0004003d,0x00000009,0x0000017c, + 0x0000017b,0x00050081,0x00000009,0x0000017d,0x0000017c,0x0000017a,0x00050041,0x00000036, + 0x0000017e,0x00000166,0x0000008d,0x0003003e,0x0000017e,0x0000017d,0x0004003d,0x00000027, + 0x0000017f,0x00000038,0x0004003d,0x0000000a,0x00000180,0x00000166,0x00070058,0x00000012, + 0x00000181,0x0000017f,0x00000180,0x00000002,0x0000011a,0x0007004f,0x0000000a,0x00000182, + 0x00000181,0x00000181,0x00000000,0x00000001,0x000200fe,0x00000182,0x00010038,0x00050036, + 0x0000000a,0x00000044,0x00000000,0x0000003e,0x00030037,0x00000028,0x0000003f,0x00030037, + 0x00000028,0x00000040,0x00030037,0x0000000b,0x00000041,0x00030037,0x0000000b,0x00000042, + 0x00030037,0x00000021,0x00000043,0x000200f8,0x00000045,0x0004003b,0x0000000b,0x00000185, + 0x00000007,0x0004003b,0x00000021,0x0000018c,0x00000007,0x0004003b,0x0000000b,0x0000018e, + 0x00000007,0x0004003b,0x0000000b,0x0000018f,0x00000007,0x0004003b,0x0000000b,0x00000191, + 0x00000007,0x0004003b,0x0000000b,0x00000192,0x00000007,0x0004003b,0x0000000b,0x000001a7, + 0x00000007,0x0004003b,0x0000000b,0x000001a9,0x00000007,0x0004003b,0x0000000b,0x000001aa, + 0x00000007,0x0004003b,0x00000021,0x000001ba,0x00000007,0x0004003b,0x00000021,0x000001ce, + 0x00000007,0x0004003b,0x00000021,0x000001e5,0x00000007,0x0004003b,0x0000000b,0x000001ea, + 0x00000007,0x0004003b,0x00000008,0x000001f6,0x00000007,0x0004003b,0x0000000b,0x000001f7, + 0x00000007,0x0004003b,0x0000000b,0x000001f9,0x00000007,0x0004003b,0x0000000b,0x000001fc, + 0x00000007,0x0004003b,0x0000000b,0x000001ff,0x00000007,0x0004003b,0x00000036,0x00000201, + 0x00000007,0x0004003b,0x0000000b,0x00000208,0x00000007,0x0004003b,0x0000000b,0x0000020a, + 0x00000007,0x0004003b,0x0000000b,0x0000020b,0x00000007,0x0004003b,0x0000000b,0x0000021a, + 0x00000007,0x0004003b,0x0000000b,0x0000021c,0x00000007,0x0004003b,0x0000000b,0x0000021d, + 0x00000007,0x0004003b,0x00000021,0x00000239,0x00000007,0x0004003b,0x00000021,0x0000024b, + 0x00000007,0x0004003b,0x0000000b,0x00000262,0x00000007,0x0004003b,0x00000008,0x0000026d, + 0x00000007,0x0004003b,0x0000000b,0x0000026e,0x00000007,0x0004003b,0x0000000b,0x00000270, + 0x00000007,0x0004003b,0x0000000b,0x00000273,0x00000007,0x0004003b,0x0000000b,0x00000276, + 0x00000007,0x0004003b,0x00000036,0x00000278,0x00000007,0x0003003e,0x00000185,0x00000186, + 0x00050041,0x00000036,0x00000187,0x00000042,0x00000084,0x0004003d,0x00000009,0x00000188, + 0x00000187,0x000500ba,0x00000006,0x00000189,0x00000188,0x0000011a,0x000300f7,0x0000018b, + 0x00000000,0x000400fa,0x00000189,0x0000018a,0x000001a1,0x000200f8,0x0000018a,0x0004003d, + 0x0000000a,0x00000190,0x00000041,0x0003003e,0x0000018f,0x00000190,0x0003003e,0x00000191, + 0x0000018d,0x00080039,0x0000000a,0x00000193,0x0000002e,0x0000003f,0x0000018f,0x00000191, + 0x00000192,0x0004003d,0x0000000a,0x00000194,0x00000192,0x0003003e,0x0000018e,0x00000194, + 0x00050041,0x00000036,0x00000195,0x0000018c,0x00000084,0x00050051,0x00000009,0x00000196, + 0x00000193,0x00000000,0x0003003e,0x00000195,0x00000196,0x00050041,0x00000036,0x00000197, + 0x0000018c,0x000000e2,0x00050051,0x00000009,0x00000198,0x00000193,0x00000001,0x0003003e, + 0x00000197,0x00000198,0x00050041,0x00000036,0x00000199,0x0000018e,0x0000008d,0x0004003d, + 0x00000009,0x0000019a,0x00000199,0x000500ba,0x00000006,0x0000019b,0x0000019a,0x00000106, + 0x000600a9,0x00000009,0x0000019c,0x0000019b,0x000000ec,0x0000011a,0x00050041,0x00000036, + 0x0000019d,0x0000018c,0x00000084,0x0004003d,0x00000009,0x0000019e,0x0000019d,0x00050081, + 0x00000009,0x0000019f,0x0000019e,0x0000019c,0x00050041,0x00000036,0x000001a0,0x0000018c, + 0x00000084,0x0003003e,0x000001a0,0x0000019f,0x000200f9,0x0000018b,0x000200f8,0x000001a1, + 0x00050041,0x00000036,0x000001a2,0x0000018c,0x00000084,0x00050051,0x00000009,0x000001a3, + 0x00000186,0x00000000,0x0003003e,0x000001a2,0x000001a3,0x00050041,0x00000036,0x000001a4, + 0x0000018c,0x000000e2,0x00050051,0x00000009,0x000001a5,0x00000186,0x00000001,0x0003003e, + 0x000001a4,0x000001a5,0x000200f9,0x0000018b,0x000200f8,0x0000018b,0x0004003d,0x0000000a, + 0x000001a8,0x00000041,0x0003003e,0x000001a7,0x000001a8,0x0003003e,0x000001a9,0x000001a6, + 0x00080039,0x0000000a,0x000001ab,0x0000002e,0x0000003f,0x000001a7,0x000001a9,0x000001aa, + 0x0004003d,0x0000000a,0x000001ac,0x000001aa,0x0003003e,0x0000018e,0x000001ac,0x00050041, + 0x00000036,0x000001ad,0x0000018c,0x0000008d,0x00050051,0x00000009,0x000001ae,0x000001ab, + 0x00000000,0x0003003e,0x000001ad,0x000001ae,0x00050041,0x00000036,0x000001af,0x0000018c, + 0x00000014,0x00050051,0x00000009,0x000001b0,0x000001ab,0x00000001,0x0003003e,0x000001af, + 0x000001b0,0x00050041,0x00000036,0x000001b1,0x0000018c,0x00000084,0x0004003d,0x00000009, + 0x000001b2,0x000001b1,0x00050041,0x00000036,0x000001b3,0x0000018c,0x0000008d,0x0004003d, + 0x00000009,0x000001b4,0x000001b3,0x00050081,0x00000009,0x000001b5,0x000001b2,0x000001b4, + 0x000500ba,0x00000006,0x000001b7,0x000001b5,0x000001b6,0x000300f7,0x000001b9,0x00000000, + 0x000400fa,0x000001b7,0x000001b8,0x000001b9,0x000200f8,0x000001b8,0x00050041,0x00000036, + 0x000001bb,0x0000018c,0x00000084,0x0004003d,0x00000009,0x000001bc,0x000001bb,0x0004007f, + 0x00000009,0x000001bd,0x000001bc,0x00050081,0x00000009,0x000001be,0x000001bd,0x0000012b, + 0x00050041,0x00000036,0x000001bf,0x0000018c,0x00000084,0x0004003d,0x00000009,0x000001c0, + 0x000001bf,0x00050041,0x00000036,0x000001c1,0x0000018c,0x0000008d,0x0004003d,0x00000009, + 0x000001c2,0x000001c1,0x00050041,0x00000036,0x000001c3,0x0000018c,0x0000008d,0x0004003d, + 0x00000009,0x000001c4,0x000001c3,0x0004007f,0x00000009,0x000001c5,0x000001c4,0x00050083, + 0x00000009,0x000001c6,0x000001c5,0x0000012b,0x00070050,0x00000012,0x000001c7,0x000001be, + 0x000001c0,0x000001c2,0x000001c6,0x00050041,0x0000009b,0x000001c8,0x00000098,0x0000009a, + 0x0004003d,0x00000012,0x000001c9,0x000001c8,0x0009004f,0x00000012,0x000001ca,0x000001c9, + 0x000001c9,0x00000000,0x00000001,0x00000000,0x00000001,0x0004003d,0x0000000a,0x000001cb, + 0x00000041,0x0009004f,0x00000012,0x000001cc,0x000001cb,0x000001cb,0x00000000,0x00000001, + 0x00000000,0x00000001,0x0008000c,0x00000012,0x000001cd,0x00000001,0x00000032,0x000001c7, + 0x000001ca,0x000001cc,0x0003003e,0x000001ba,0x000001cd,0x0004003d,0x00000027,0x000001cf, + 0x0000003f,0x0004003d,0x00000012,0x000001d0,0x000001ba,0x0007004f,0x0000000a,0x000001d1, + 0x000001d0,0x000001d0,0x00000000,0x00000001,0x00080058,0x00000012,0x000001d5,0x000001cf, + 0x000001d1,0x0000000a,0x0000011a,0x000001d4,0x0007004f,0x0000000a,0x000001d6,0x000001d5, + 0x000001d5,0x00000000,0x00000001,0x00050041,0x00000036,0x000001d7,0x000001ce,0x00000084, + 0x00050051,0x00000009,0x000001d8,0x000001d6,0x00000000,0x0003003e,0x000001d7,0x000001d8, + 0x00050041,0x00000036,0x000001d9,0x000001ce,0x0000008d,0x00050051,0x00000009,0x000001da, + 0x000001d6,0x00000001,0x0003003e,0x000001d9,0x000001da,0x0004003d,0x00000027,0x000001db, + 0x0000003f,0x0004003d,0x00000012,0x000001dc,0x000001ba,0x0007004f,0x0000000a,0x000001dd, + 0x000001dc,0x000001dc,0x00000002,0x00000003,0x00080058,0x00000012,0x000001df,0x000001db, + 0x000001dd,0x0000000a,0x0000011a,0x000001de,0x0007004f,0x0000000a,0x000001e0,0x000001df, + 0x000001df,0x00000000,0x00000001,0x00050041,0x00000036,0x000001e1,0x000001ce,0x000000e2, + 0x00050051,0x00000009,0x000001e2,0x000001e0,0x00000000,0x0003003e,0x000001e1,0x000001e2, + 0x00050041,0x00000036,0x000001e3,0x000001ce,0x00000014,0x00050051,0x00000009,0x000001e4, + 0x000001e0,0x00000001,0x0003003e,0x000001e3,0x000001e4,0x0004003d,0x00000012,0x000001e6, + 0x000001ce,0x0003003e,0x000001e5,0x000001e6,0x00050039,0x00000012,0x000001e7,0x00000024, + 0x000001e5,0x0004003d,0x00000012,0x000001e8,0x000001ce,0x0009004f,0x00000012,0x000001e9, + 0x000001e8,0x000001e7,0x00000005,0x00000004,0x00000007,0x00000006,0x0003003e,0x000001ce, + 0x000001e9,0x0004003d,0x00000012,0x000001ec,0x000001ce,0x0007004f,0x0000000a,0x000001ed, + 0x000001ec,0x000001ec,0x00000000,0x00000002,0x0004003d,0x00000012,0x000001ee,0x000001ce, + 0x0007004f,0x0000000a,0x000001ef,0x000001ee,0x000001ee,0x00000001,0x00000003,0x0008000c, + 0x0000000a,0x000001f0,0x00000001,0x00000032,0x000001eb,0x000001ed,0x000001ef,0x0003003e, + 0x000001ea,0x000001f0,0x0004003d,0x00000012,0x000001f1,0x0000018c,0x0007004f,0x0000000a, + 0x000001f2,0x000001f1,0x000001f1,0x00000002,0x00000003,0x00050050,0x0000000a,0x000001f3, + 0x00000106,0x00000106,0x0007000c,0x0000000a,0x000001f4,0x00000001,0x00000030,0x000001f3, + 0x000001f2,0x000500b7,0x00000007,0x000001f5,0x000001f4,0x00000186,0x0003003e,0x000001f6, + 0x000001f5,0x0004003d,0x0000000a,0x000001f8,0x000001ea,0x0003003e,0x000001f7,0x000001f8, + 0x0003003e,0x000001f9,0x00000186,0x00070039,0x00000002,0x000001fa,0x00000010,0x000001f6, + 0x000001f7,0x000001f9,0x0004003d,0x0000000a,0x000001fb,0x000001f7,0x0003003e,0x000001ea, + 0x000001fb,0x0004003d,0x00000012,0x000001fd,0x0000018c,0x0007004f,0x0000000a,0x000001fe, + 0x000001fd,0x000001fd,0x00000000,0x00000001,0x0003003e,0x000001fc,0x000001fe,0x0004003d, + 0x0000000a,0x00000200,0x000001ea,0x0003003e,0x000001ff,0x00000200,0x00050041,0x00000036, + 0x00000202,0x00000043,0x000000e2,0x0004003d,0x00000009,0x00000203,0x00000202,0x0003003e, + 0x00000201,0x00000203,0x00080039,0x0000000a,0x00000204,0x0000003c,0x00000040,0x000001fc, + 0x000001ff,0x00000201,0x0004003d,0x0000000a,0x00000205,0x00000185,0x00050081,0x0000000a, + 0x00000206,0x00000205,0x00000204,0x0003003e,0x00000185,0x00000206,0x000200f9,0x000001b9, + 0x000200f8,0x000001b9,0x0004003d,0x0000000a,0x00000209,0x00000041,0x0003003e,0x00000208, + 0x00000209,0x0003003e,0x0000020a,0x00000207,0x00080039,0x0000000a,0x0000020c,0x00000034, + 0x0000003f,0x00000208,0x0000020a,0x0000020b,0x0004003d,0x0000000a,0x0000020d,0x0000020b, + 0x0003003e,0x0000018e,0x0000020d,0x00050041,0x00000036,0x0000020e,0x0000018c,0x00000084, + 0x00050051,0x00000009,0x0000020f,0x0000020c,0x00000000,0x0003003e,0x0000020e,0x0000020f, + 0x00050041,0x00000036,0x00000210,0x0000018c,0x000000e2,0x00050051,0x00000009,0x00000211, + 0x0000020c,0x00000001,0x0003003e,0x00000210,0x00000211,0x0004003d,0x00000027,0x00000212, + 0x0000003f,0x0004003d,0x0000000a,0x00000213,0x00000041,0x00080058,0x00000012,0x00000214, + 0x00000212,0x00000213,0x0000000a,0x0000011a,0x000001de,0x00050051,0x00000009,0x00000215, + 0x00000214,0x00000000,0x000500ba,0x00000006,0x00000216,0x00000215,0x0000011a,0x000300f7, + 0x00000218,0x00000000,0x000400fa,0x00000216,0x00000217,0x0000022c,0x000200f8,0x00000217, + 0x0004003d,0x0000000a,0x0000021b,0x00000041,0x0003003e,0x0000021a,0x0000021b,0x0003003e, + 0x0000021c,0x00000219,0x00080039,0x0000000a,0x0000021e,0x00000034,0x0000003f,0x0000021a, + 0x0000021c,0x0000021d,0x0004003d,0x0000000a,0x0000021f,0x0000021d,0x0003003e,0x0000018e, + 0x0000021f,0x00050041,0x00000036,0x00000220,0x0000018c,0x0000008d,0x00050051,0x00000009, + 0x00000221,0x0000021e,0x00000000,0x0003003e,0x00000220,0x00000221,0x00050041,0x00000036, + 0x00000222,0x0000018c,0x00000014,0x00050051,0x00000009,0x00000223,0x0000021e,0x00000001, + 0x0003003e,0x00000222,0x00000223,0x00050041,0x00000036,0x00000224,0x0000018e,0x0000008d, + 0x0004003d,0x00000009,0x00000225,0x00000224,0x000500ba,0x00000006,0x00000226,0x00000225, + 0x00000106,0x000600a9,0x00000009,0x00000227,0x00000226,0x000000ec,0x0000011a,0x00050041, + 0x00000036,0x00000228,0x0000018c,0x0000008d,0x0004003d,0x00000009,0x00000229,0x00000228, + 0x00050081,0x00000009,0x0000022a,0x00000229,0x00000227,0x00050041,0x00000036,0x0000022b, + 0x0000018c,0x0000008d,0x0003003e,0x0000022b,0x0000022a,0x000200f9,0x00000218,0x000200f8, + 0x0000022c,0x00050041,0x00000036,0x0000022d,0x0000018c,0x0000008d,0x00050051,0x00000009, + 0x0000022e,0x00000186,0x00000000,0x0003003e,0x0000022d,0x0000022e,0x00050041,0x00000036, + 0x0000022f,0x0000018c,0x00000014,0x00050051,0x00000009,0x00000230,0x00000186,0x00000001, + 0x0003003e,0x0000022f,0x00000230,0x000200f9,0x00000218,0x000200f8,0x00000218,0x00050041, + 0x00000036,0x00000231,0x0000018c,0x00000084,0x0004003d,0x00000009,0x00000232,0x00000231, + 0x00050041,0x00000036,0x00000233,0x0000018c,0x0000008d,0x0004003d,0x00000009,0x00000234, + 0x00000233,0x00050081,0x00000009,0x00000235,0x00000232,0x00000234,0x000500ba,0x00000006, + 0x00000236,0x00000235,0x000001b6,0x000300f7,0x00000238,0x00000000,0x000400fa,0x00000236, + 0x00000237,0x00000238,0x000200f8,0x00000237,0x00050041,0x00000036,0x0000023a,0x0000018c, + 0x00000084,0x0004003d,0x00000009,0x0000023b,0x0000023a,0x0004007f,0x00000009,0x0000023c, + 0x0000023b,0x00050041,0x00000036,0x0000023d,0x0000018c,0x00000084,0x0004003d,0x00000009, + 0x0000023e,0x0000023d,0x0004007f,0x00000009,0x0000023f,0x0000023e,0x00050041,0x00000036, + 0x00000240,0x0000018c,0x0000008d,0x0004003d,0x00000009,0x00000241,0x00000240,0x00050041, + 0x00000036,0x00000242,0x0000018c,0x0000008d,0x0004003d,0x00000009,0x00000243,0x00000242, + 0x00070050,0x00000012,0x00000244,0x0000023c,0x0000023f,0x00000241,0x00000243,0x00050041, + 0x0000009b,0x00000245,0x00000098,0x0000009a,0x0004003d,0x00000012,0x00000246,0x00000245, + 0x0009004f,0x00000012,0x00000247,0x00000246,0x00000246,0x00000000,0x00000001,0x00000000, + 0x00000001,0x0004003d,0x0000000a,0x00000248,0x00000041,0x0009004f,0x00000012,0x00000249, + 0x00000248,0x00000248,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c,0x00000012, + 0x0000024a,0x00000001,0x00000032,0x00000244,0x00000247,0x00000249,0x0003003e,0x00000239, + 0x0000024a,0x0004003d,0x00000027,0x0000024c,0x0000003f,0x0004003d,0x00000012,0x0000024d, + 0x00000239,0x0007004f,0x0000000a,0x0000024e,0x0000024d,0x0000024d,0x00000000,0x00000001, + 0x00080058,0x00000012,0x0000024f,0x0000024c,0x0000024e,0x0000000a,0x0000011a,0x000001d4, + 0x00050051,0x00000009,0x00000250,0x0000024f,0x00000001,0x00050041,0x00000036,0x00000251, + 0x0000024b,0x00000084,0x0003003e,0x00000251,0x00000250,0x0004003d,0x00000027,0x00000252, + 0x0000003f,0x0004003d,0x00000012,0x00000253,0x00000239,0x0007004f,0x0000000a,0x00000254, + 0x00000253,0x00000253,0x00000000,0x00000001,0x00080058,0x00000012,0x00000256,0x00000252, + 0x00000254,0x0000000a,0x0000011a,0x00000255,0x00050051,0x00000009,0x00000257,0x00000256, + 0x00000000,0x00050041,0x00000036,0x00000258,0x0000024b,0x0000008d,0x0003003e,0x00000258, + 0x00000257,0x0004003d,0x00000027,0x00000259,0x0000003f,0x0004003d,0x00000012,0x0000025a, + 0x00000239,0x0007004f,0x0000000a,0x0000025b,0x0000025a,0x0000025a,0x00000002,0x00000003, + 0x00080058,0x00000012,0x0000025c,0x00000259,0x0000025b,0x0000000a,0x0000011a,0x000001de, + 0x0007004f,0x0000000a,0x0000025d,0x0000025c,0x0000025c,0x00000001,0x00000000,0x00050041, + 0x00000036,0x0000025e,0x0000024b,0x000000e2,0x00050051,0x00000009,0x0000025f,0x0000025d, + 0x00000000,0x0003003e,0x0000025e,0x0000025f,0x00050041,0x00000036,0x00000260,0x0000024b, + 0x00000014,0x00050051,0x00000009,0x00000261,0x0000025d,0x00000001,0x0003003e,0x00000260, + 0x00000261,0x0004003d,0x00000012,0x00000263,0x0000024b,0x0007004f,0x0000000a,0x00000264, + 0x00000263,0x00000263,0x00000000,0x00000002,0x0004003d,0x00000012,0x00000265,0x0000024b, + 0x0007004f,0x0000000a,0x00000266,0x00000265,0x00000265,0x00000001,0x00000003,0x0008000c, + 0x0000000a,0x00000267,0x00000001,0x00000032,0x000001eb,0x00000264,0x00000266,0x0003003e, + 0x00000262,0x00000267,0x0004003d,0x00000012,0x00000268,0x0000018c,0x0007004f,0x0000000a, + 0x00000269,0x00000268,0x00000268,0x00000002,0x00000003,0x00050050,0x0000000a,0x0000026a, + 0x00000106,0x00000106,0x0007000c,0x0000000a,0x0000026b,0x00000001,0x00000030,0x0000026a, + 0x00000269,0x000500b7,0x00000007,0x0000026c,0x0000026b,0x00000186,0x0003003e,0x0000026d, + 0x0000026c,0x0004003d,0x0000000a,0x0000026f,0x00000262,0x0003003e,0x0000026e,0x0000026f, + 0x0003003e,0x00000270,0x00000186,0x00070039,0x00000002,0x00000271,0x00000010,0x0000026d, + 0x0000026e,0x00000270,0x0004003d,0x0000000a,0x00000272,0x0000026e,0x0003003e,0x00000262, + 0x00000272,0x0004003d,0x00000012,0x00000274,0x0000018c,0x0007004f,0x0000000a,0x00000275, + 0x00000274,0x00000274,0x00000000,0x00000001,0x0003003e,0x00000273,0x00000275,0x0004003d, + 0x0000000a,0x00000277,0x00000262,0x0003003e,0x00000276,0x00000277,0x00050041,0x00000036, + 0x00000279,0x00000043,0x00000014,0x0004003d,0x00000009,0x0000027a,0x00000279,0x0003003e, + 0x00000278,0x0000027a,0x00080039,0x0000000a,0x0000027b,0x0000003c,0x00000040,0x00000273, + 0x00000276,0x00000278,0x0007004f,0x0000000a,0x0000027c,0x0000027b,0x0000027b,0x00000001, + 0x00000000,0x0004003d,0x0000000a,0x0000027d,0x00000185,0x00050081,0x0000000a,0x0000027e, + 0x0000027d,0x0000027c,0x0003003e,0x00000185,0x0000027e,0x000200f9,0x00000238,0x000200f8, + 0x00000238,0x0004003d,0x0000000a,0x0000027f,0x00000185,0x000200fe,0x0000027f,0x00010038, + 0x00050036,0x00000009,0x0000004a,0x00000000,0x00000046,0x00030037,0x00000028,0x00000047, + 0x00030037,0x0000000b,0x00000048,0x00030037,0x00000036,0x00000049,0x000200f8,0x0000004b, + 0x0004003b,0x0000000b,0x00000282,0x00000007,0x0004003b,0x0000000b,0x00000286,0x00000007, + 0x0003003e,0x00000282,0x00000285,0x0004003d,0x00000009,0x00000289,0x00000049,0x00050050, + 0x0000000a,0x0000028a,0x00000289,0x000000ec,0x00050085,0x0000000a,0x0000028b,0x00000288, + 0x0000028a,0x0003003e,0x00000286,0x0000028b,0x0004003d,0x0000000a,0x0000028c,0x00000282, + 0x00050081,0x0000000a,0x0000028d,0x0000028c,0x0000018d,0x0003003e,0x00000282,0x0000028d, + 0x0004003d,0x0000000a,0x00000290,0x00000286,0x00050081,0x0000000a,0x00000291,0x00000290, + 0x0000028f,0x0003003e,0x00000286,0x00000291,0x0004003d,0x0000000a,0x00000295,0x00000282, + 0x00050085,0x0000000a,0x00000296,0x00000295,0x00000294,0x0003003e,0x00000282,0x00000296, + 0x0004003d,0x0000000a,0x00000297,0x00000286,0x00050085,0x0000000a,0x00000298,0x00000297, + 0x00000294,0x0003003e,0x00000286,0x00000298,0x0004003d,0x00000027,0x00000299,0x00000047, + 0x0004003d,0x0000000a,0x0000029a,0x00000282,0x0004003d,0x0000000a,0x0000029b,0x00000048, + 0x0004003d,0x0000000a,0x0000029c,0x00000286,0x0008000c,0x0000000a,0x0000029d,0x00000001, + 0x00000032,0x0000029a,0x0000029b,0x0000029c,0x00070058,0x00000012,0x0000029e,0x00000299, + 0x0000029d,0x00000002,0x0000011a,0x00050051,0x00000009,0x0000029f,0x0000029e,0x00000000, + 0x000200fe,0x0000029f,0x00010038,0x00050036,0x00000009,0x00000051,0x00000000,0x0000004c, + 0x00030037,0x00000028,0x0000004d,0x00030037,0x00000028,0x0000004e,0x00030037,0x0000000b, + 0x0000004f,0x00030037,0x00000036,0x00000050,0x000200f8,0x00000052,0x0004003b,0x0000000b, + 0x000002a2,0x00000007,0x0004003b,0x00000036,0x000002c6,0x00000007,0x0004003b,0x0000000b, + 0x000002c8,0x00000007,0x0004003b,0x00000036,0x000002ca,0x00000007,0x0003003e,0x000002a2, + 0x000002a3,0x000200f9,0x000002a4,0x000200f8,0x000002a4,0x000400f6,0x000002a6,0x000002a7, + 0x00000000,0x000200f9,0x000002a8,0x000200f8,0x000002a8,0x00050041,0x00000036,0x000002a9, + 0x0000004f,0x00000084,0x0004003d,0x00000009,0x000002aa,0x000002a9,0x0004003d,0x00000009, + 0x000002ab,0x00000050,0x000500ba,0x00000006,0x000002ac,0x000002aa,0x000002ab,0x000300f7, + 0x000002ae,0x00000000,0x000400fa,0x000002ac,0x000002ad,0x000002ae,0x000200f8,0x000002ad, + 0x00050041,0x00000036,0x000002af,0x000002a2,0x0000008d,0x0004003d,0x00000009,0x000002b0, + 0x000002af,0x000500ba,0x00000006,0x000002b2,0x000002b0,0x000002b1,0x000200f9,0x000002ae, + 0x000200f8,0x000002ae,0x000700f5,0x00000006,0x000002b3,0x000002ac,0x000002a8,0x000002b2, + 0x000002ad,0x000300f7,0x000002b5,0x00000000,0x000400fa,0x000002b3,0x000002b4,0x000002b5, + 0x000200f8,0x000002b4,0x00050041,0x00000036,0x000002b6,0x000002a2,0x00000084,0x0004003d, + 0x00000009,0x000002b7,0x000002b6,0x000500b4,0x00000006,0x000002b8,0x000002b7,0x0000011a, + 0x000200f9,0x000002b5,0x000200f8,0x000002b5,0x000700f5,0x00000006,0x000002b9,0x000002b3, + 0x000002ae,0x000002b8,0x000002b4,0x000400fa,0x000002b9,0x000002a5,0x000002a6,0x000200f8, + 0x000002a5,0x0004003d,0x00000027,0x000002ba,0x0000004d,0x0004003d,0x0000000a,0x000002bb, + 0x0000004f,0x00070058,0x00000012,0x000002bc,0x000002ba,0x000002bb,0x00000002,0x0000011a, + 0x0007004f,0x0000000a,0x000002bd,0x000002bc,0x000002bc,0x00000000,0x00000001,0x0003003e, + 0x000002a2,0x000002bd,0x00050041,0x0000009b,0x000002c1,0x00000098,0x0000009a,0x0004003d, + 0x00000012,0x000002c2,0x000002c1,0x0007004f,0x0000000a,0x000002c3,0x000002c2,0x000002c2, + 0x00000000,0x00000001,0x0004003d,0x0000000a,0x000002c4,0x0000004f,0x0008000c,0x0000000a, + 0x000002c5,0x00000001,0x00000032,0x000002c0,0x000002c3,0x000002c4,0x0003003e,0x0000004f, + 0x000002c5,0x000200f9,0x000002a7,0x000200f8,0x000002a7,0x000200f9,0x000002a4,0x000200f8, + 0x000002a6,0x0004003d,0x0000000a,0x000002c9,0x000002a2,0x0003003e,0x000002c8,0x000002c9, + 0x0003003e,0x000002ca,0x0000011a,0x00070039,0x00000009,0x000002cb,0x0000004a,0x0000004e, + 0x000002c8,0x000002ca,0x0008000c,0x00000009,0x000002cd,0x00000001,0x00000032,0x000002c7, + 0x000002cb,0x000002cc,0x0003003e,0x000002c6,0x000002cd,0x00060041,0x0000012c,0x000002ce, + 0x00000098,0x0000009a,0x00000084,0x0004003d,0x00000009,0x000002cf,0x000002ce,0x0004003d, + 0x00000009,0x000002d0,0x000002c6,0x00050041,0x00000036,0x000002d1,0x0000004f,0x00000084, + 0x0004003d,0x00000009,0x000002d2,0x000002d1,0x0008000c,0x00000009,0x000002d3,0x00000001, + 0x00000032,0x000002cf,0x000002d0,0x000002d2,0x000200fe,0x000002d3,0x00010038,0x00050036, + 0x00000009,0x00000057,0x00000000,0x0000004c,0x00030037,0x00000028,0x00000053,0x00030037, + 0x00000028,0x00000054,0x00030037,0x0000000b,0x00000055,0x00030037,0x00000036,0x00000056, + 0x000200f8,0x00000058,0x0004003b,0x0000000b,0x000002d6,0x00000007,0x0004003b,0x00000036, + 0x000002f6,0x00000007,0x0004003b,0x0000000b,0x000002f7,0x00000007,0x0004003b,0x00000036, + 0x000002f9,0x00000007,0x0003003e,0x000002d6,0x000002a3,0x000200f9,0x000002d7,0x000200f8, + 0x000002d7,0x000400f6,0x000002d9,0x000002da,0x00000000,0x000200f9,0x000002db,0x000200f8, + 0x000002db,0x00050041,0x00000036,0x000002dc,0x00000055,0x00000084,0x0004003d,0x00000009, + 0x000002dd,0x000002dc,0x0004003d,0x00000009,0x000002de,0x00000056,0x000500b8,0x00000006, + 0x000002df,0x000002dd,0x000002de,0x000300f7,0x000002e1,0x00000000,0x000400fa,0x000002df, + 0x000002e0,0x000002e1,0x000200f8,0x000002e0,0x00050041,0x00000036,0x000002e2,0x000002d6, + 0x0000008d,0x0004003d,0x00000009,0x000002e3,0x000002e2,0x000500ba,0x00000006,0x000002e4, + 0x000002e3,0x000002b1,0x000200f9,0x000002e1,0x000200f8,0x000002e1,0x000700f5,0x00000006, + 0x000002e5,0x000002df,0x000002db,0x000002e4,0x000002e0,0x000300f7,0x000002e7,0x00000000, + 0x000400fa,0x000002e5,0x000002e6,0x000002e7,0x000200f8,0x000002e6,0x00050041,0x00000036, + 0x000002e8,0x000002d6,0x00000084,0x0004003d,0x00000009,0x000002e9,0x000002e8,0x000500b4, + 0x00000006,0x000002ea,0x000002e9,0x0000011a,0x000200f9,0x000002e7,0x000200f8,0x000002e7, + 0x000700f5,0x00000006,0x000002eb,0x000002e5,0x000002e1,0x000002ea,0x000002e6,0x000400fa, + 0x000002eb,0x000002d8,0x000002d9,0x000200f8,0x000002d8,0x0004003d,0x00000027,0x000002ec, + 0x00000053,0x0004003d,0x0000000a,0x000002ed,0x00000055,0x00070058,0x00000012,0x000002ee, + 0x000002ec,0x000002ed,0x00000002,0x0000011a,0x0007004f,0x0000000a,0x000002ef,0x000002ee, + 0x000002ee,0x00000000,0x00000001,0x0003003e,0x000002d6,0x000002ef,0x00050041,0x0000009b, + 0x000002f1,0x00000098,0x0000009a,0x0004003d,0x00000012,0x000002f2,0x000002f1,0x0007004f, + 0x0000000a,0x000002f3,0x000002f2,0x000002f2,0x00000000,0x00000001,0x0004003d,0x0000000a, + 0x000002f4,0x00000055,0x0008000c,0x0000000a,0x000002f5,0x00000001,0x00000032,0x000002f0, + 0x000002f3,0x000002f4,0x0003003e,0x00000055,0x000002f5,0x000200f9,0x000002da,0x000200f8, + 0x000002da,0x000200f9,0x000002d7,0x000200f8,0x000002d9,0x0004003d,0x0000000a,0x000002f8, + 0x000002d6,0x0003003e,0x000002f7,0x000002f8,0x0003003e,0x000002f9,0x0000011e,0x00070039, + 0x00000009,0x000002fa,0x0000004a,0x00000054,0x000002f7,0x000002f9,0x0008000c,0x00000009, + 0x000002fb,0x00000001,0x00000032,0x000002c7,0x000002fa,0x000002cc,0x0003003e,0x000002f6, + 0x000002fb,0x00060041,0x0000012c,0x000002fc,0x00000098,0x0000009a,0x00000084,0x0004003d, + 0x00000009,0x000002fd,0x000002fc,0x0004007f,0x00000009,0x000002fe,0x000002fd,0x0004003d, + 0x00000009,0x000002ff,0x000002f6,0x00050041,0x00000036,0x00000300,0x00000055,0x00000084, + 0x0004003d,0x00000009,0x00000301,0x00000300,0x0008000c,0x00000009,0x00000302,0x00000001, + 0x00000032,0x000002fe,0x000002ff,0x00000301,0x000200fe,0x00000302,0x00010038,0x00050036, + 0x00000009,0x0000005d,0x00000000,0x0000004c,0x00030037,0x00000028,0x00000059,0x00030037, + 0x00000028,0x0000005a,0x00030037,0x0000000b,0x0000005b,0x00030037,0x00000036,0x0000005c, + 0x000200f8,0x0000005e,0x0004003b,0x0000000b,0x00000305,0x00000007,0x0004003b,0x00000036, + 0x00000326,0x00000007,0x0004003b,0x0000000b,0x00000327,0x00000007,0x0004003b,0x00000036, + 0x0000032a,0x00000007,0x0003003e,0x00000305,0x00000306,0x000200f9,0x00000307,0x000200f8, + 0x00000307,0x000400f6,0x00000309,0x0000030a,0x00000000,0x000200f9,0x0000030b,0x000200f8, + 0x0000030b,0x00050041,0x00000036,0x0000030c,0x0000005b,0x0000008d,0x0004003d,0x00000009, + 0x0000030d,0x0000030c,0x0004003d,0x00000009,0x0000030e,0x0000005c,0x000500ba,0x00000006, + 0x0000030f,0x0000030d,0x0000030e,0x000300f7,0x00000311,0x00000000,0x000400fa,0x0000030f, + 0x00000310,0x00000311,0x000200f8,0x00000310,0x00050041,0x00000036,0x00000312,0x00000305, + 0x00000084,0x0004003d,0x00000009,0x00000313,0x00000312,0x000500ba,0x00000006,0x00000314, + 0x00000313,0x000002b1,0x000200f9,0x00000311,0x000200f8,0x00000311,0x000700f5,0x00000006, + 0x00000315,0x0000030f,0x0000030b,0x00000314,0x00000310,0x000300f7,0x00000317,0x00000000, + 0x000400fa,0x00000315,0x00000316,0x00000317,0x000200f8,0x00000316,0x00050041,0x00000036, + 0x00000318,0x00000305,0x0000008d,0x0004003d,0x00000009,0x00000319,0x00000318,0x000500b4, + 0x00000006,0x0000031a,0x00000319,0x0000011a,0x000200f9,0x00000317,0x000200f8,0x00000317, + 0x000700f5,0x00000006,0x0000031b,0x00000315,0x00000311,0x0000031a,0x00000316,0x000400fa, + 0x0000031b,0x00000308,0x00000309,0x000200f8,0x00000308,0x0004003d,0x00000027,0x0000031c, + 0x00000059,0x0004003d,0x0000000a,0x0000031d,0x0000005b,0x00070058,0x00000012,0x0000031e, + 0x0000031c,0x0000031d,0x00000002,0x0000011a,0x0007004f,0x0000000a,0x0000031f,0x0000031e, + 0x0000031e,0x00000000,0x00000001,0x0003003e,0x00000305,0x0000031f,0x00050041,0x0000009b, + 0x00000321,0x00000098,0x0000009a,0x0004003d,0x00000012,0x00000322,0x00000321,0x0007004f, + 0x0000000a,0x00000323,0x00000322,0x00000322,0x00000000,0x00000001,0x0004003d,0x0000000a, + 0x00000324,0x0000005b,0x0008000c,0x0000000a,0x00000325,0x00000001,0x00000032,0x00000320, + 0x00000323,0x00000324,0x0003003e,0x0000005b,0x00000325,0x000200f9,0x0000030a,0x000200f8, + 0x0000030a,0x000200f9,0x00000307,0x000200f8,0x00000309,0x0004003d,0x0000000a,0x00000328, + 0x00000305,0x0007004f,0x0000000a,0x00000329,0x00000328,0x00000328,0x00000001,0x00000000, + 0x0003003e,0x00000327,0x00000329,0x0003003e,0x0000032a,0x0000011a,0x00070039,0x00000009, + 0x0000032b,0x0000004a,0x0000005a,0x00000327,0x0000032a,0x0008000c,0x00000009,0x0000032c, + 0x00000001,0x00000032,0x000002c7,0x0000032b,0x000002cc,0x0003003e,0x00000326,0x0000032c, + 0x00060041,0x0000012c,0x0000032d,0x00000098,0x0000009a,0x0000008d,0x0004003d,0x00000009, + 0x0000032e,0x0000032d,0x0004003d,0x00000009,0x0000032f,0x00000326,0x00050041,0x00000036, + 0x00000330,0x0000005b,0x0000008d,0x0004003d,0x00000009,0x00000331,0x00000330,0x0008000c, + 0x00000009,0x00000332,0x00000001,0x00000032,0x0000032e,0x0000032f,0x00000331,0x000200fe, + 0x00000332,0x00010038,0x00050036,0x00000009,0x00000063,0x00000000,0x0000004c,0x00030037, + 0x00000028,0x0000005f,0x00030037,0x00000028,0x00000060,0x00030037,0x0000000b,0x00000061, + 0x00030037,0x00000036,0x00000062,0x000200f8,0x00000064,0x0004003b,0x0000000b,0x00000335, + 0x00000007,0x0004003b,0x00000036,0x00000355,0x00000007,0x0004003b,0x0000000b,0x00000356, + 0x00000007,0x0004003b,0x00000036,0x00000359,0x00000007,0x0003003e,0x00000335,0x00000306, + 0x000200f9,0x00000336,0x000200f8,0x00000336,0x000400f6,0x00000338,0x00000339,0x00000000, + 0x000200f9,0x0000033a,0x000200f8,0x0000033a,0x00050041,0x00000036,0x0000033b,0x00000061, + 0x0000008d,0x0004003d,0x00000009,0x0000033c,0x0000033b,0x0004003d,0x00000009,0x0000033d, + 0x00000062,0x000500b8,0x00000006,0x0000033e,0x0000033c,0x0000033d,0x000300f7,0x00000340, + 0x00000000,0x000400fa,0x0000033e,0x0000033f,0x00000340,0x000200f8,0x0000033f,0x00050041, + 0x00000036,0x00000341,0x00000335,0x00000084,0x0004003d,0x00000009,0x00000342,0x00000341, + 0x000500ba,0x00000006,0x00000343,0x00000342,0x000002b1,0x000200f9,0x00000340,0x000200f8, + 0x00000340,0x000700f5,0x00000006,0x00000344,0x0000033e,0x0000033a,0x00000343,0x0000033f, + 0x000300f7,0x00000346,0x00000000,0x000400fa,0x00000344,0x00000345,0x00000346,0x000200f8, + 0x00000345,0x00050041,0x00000036,0x00000347,0x00000335,0x0000008d,0x0004003d,0x00000009, + 0x00000348,0x00000347,0x000500b4,0x00000006,0x00000349,0x00000348,0x0000011a,0x000200f9, + 0x00000346,0x000200f8,0x00000346,0x000700f5,0x00000006,0x0000034a,0x00000344,0x00000340, + 0x00000349,0x00000345,0x000400fa,0x0000034a,0x00000337,0x00000338,0x000200f8,0x00000337, + 0x0004003d,0x00000027,0x0000034b,0x0000005f,0x0004003d,0x0000000a,0x0000034c,0x00000061, + 0x00070058,0x00000012,0x0000034d,0x0000034b,0x0000034c,0x00000002,0x0000011a,0x0007004f, + 0x0000000a,0x0000034e,0x0000034d,0x0000034d,0x00000000,0x00000001,0x0003003e,0x00000335, + 0x0000034e,0x00050041,0x0000009b,0x00000350,0x00000098,0x0000009a,0x0004003d,0x00000012, + 0x00000351,0x00000350,0x0007004f,0x0000000a,0x00000352,0x00000351,0x00000351,0x00000000, + 0x00000001,0x0004003d,0x0000000a,0x00000353,0x00000061,0x0008000c,0x0000000a,0x00000354, + 0x00000001,0x00000032,0x0000034f,0x00000352,0x00000353,0x0003003e,0x00000061,0x00000354, + 0x000200f9,0x00000339,0x000200f8,0x00000339,0x000200f9,0x00000336,0x000200f8,0x00000338, + 0x0004003d,0x0000000a,0x00000357,0x00000335,0x0007004f,0x0000000a,0x00000358,0x00000357, + 0x00000357,0x00000001,0x00000000,0x0003003e,0x00000356,0x00000358,0x0003003e,0x00000359, + 0x0000011e,0x00070039,0x00000009,0x0000035a,0x0000004a,0x00000060,0x00000356,0x00000359, + 0x0008000c,0x00000009,0x0000035b,0x00000001,0x00000032,0x000002c7,0x0000035a,0x000002cc, + 0x0003003e,0x00000355,0x0000035b,0x00060041,0x0000012c,0x0000035c,0x00000098,0x0000009a, + 0x0000008d,0x0004003d,0x00000009,0x0000035d,0x0000035c,0x0004007f,0x00000009,0x0000035e, + 0x0000035d,0x0004003d,0x00000009,0x0000035f,0x00000355,0x00050041,0x00000036,0x00000360, + 0x00000061,0x0000008d,0x0004003d,0x00000009,0x00000361,0x00000360,0x0008000c,0x00000009, + 0x00000362,0x00000001,0x00000032,0x0000035e,0x0000035f,0x00000361,0x000200fe,0x00000362, + 0x00010038,0x00050036,0x0000000a,0x0000006b,0x00000000,0x00000065,0x00030037,0x00000028, + 0x00000066,0x00030037,0x0000000b,0x00000067,0x00030037,0x00000036,0x00000068,0x00030037, + 0x00000036,0x00000069,0x00030037,0x00000036,0x0000006a,0x000200f8,0x0000006c,0x0004003b, + 0x0000000b,0x00000365,0x00000007,0x0004003d,0x00000009,0x00000369,0x00000068,0x0004003d, + 0x00000009,0x0000036a,0x00000069,0x00050050,0x0000000a,0x0000036b,0x00000369,0x0000036a, + 0x0005008e,0x0000000a,0x0000036c,0x0000036b,0x00000368,0x0006000c,0x0000000a,0x0000036d, + 0x00000001,0x00000001,0x0000036c,0x0004003d,0x0000000a,0x0000036e,0x00000067,0x0008000c, + 0x0000000a,0x0000036f,0x00000001,0x00000032,0x00000367,0x0000036d,0x0000036e,0x0003003e, + 0x00000365,0x0000036f,0x0004003d,0x0000000a,0x00000370,0x00000365,0x0008000c,0x0000000a, + 0x00000371,0x00000001,0x00000032,0x0000016e,0x00000370,0x00000172,0x0003003e,0x00000365, + 0x00000371,0x0004003d,0x00000009,0x00000372,0x0000006a,0x00050041,0x00000036,0x00000373, + 0x00000365,0x0000008d,0x0004003d,0x00000009,0x00000374,0x00000373,0x0008000c,0x00000009, + 0x00000375,0x00000001,0x00000032,0x00000178,0x00000372,0x00000374,0x00050041,0x00000036, + 0x00000376,0x00000365,0x0000008d,0x0003003e,0x00000376,0x00000375,0x0004003d,0x00000027, + 0x00000377,0x00000066,0x0004003d,0x0000000a,0x00000378,0x00000365,0x00070058,0x00000012, + 0x00000379,0x00000377,0x00000378,0x00000002,0x0000011a,0x0007004f,0x0000000a,0x0000037a, + 0x00000379,0x00000379,0x00000000,0x00000001,0x000200fe,0x0000037a,0x00010038,0x00050036, + 0x00000002,0x00000072,0x00000000,0x0000006d,0x00030037,0x00000028,0x0000006e,0x00030037, + 0x0000000b,0x0000006f,0x00030037,0x00000021,0x00000070,0x00030037,0x0000000b,0x00000071, + 0x000200f8,0x00000073,0x0004003b,0x0000000b,0x0000037d,0x00000007,0x0004003b,0x0000000b, + 0x00000382,0x00000007,0x0004003b,0x0000000b,0x0000038e,0x00000007,0x0004003d,0x0000000a, + 0x0000037e,0x00000071,0x0004003d,0x0000000a,0x0000037f,0x00000071,0x0007004f,0x0000000a, + 0x00000380,0x0000037f,0x0000037f,0x00000001,0x00000000,0x0007000c,0x0000000a,0x00000381, + 0x00000001,0x00000030,0x0000037e,0x00000380,0x0003003e,0x0000037d,0x00000381,0x0004003d, + 0x0000000a,0x00000384,0x0000037d,0x0005008e,0x0000000a,0x00000385,0x00000384,0x00000383, + 0x0003003e,0x00000382,0x00000385,0x00050041,0x00000036,0x00000386,0x0000037d,0x00000084, + 0x0004003d,0x00000009,0x00000387,0x00000386,0x00050041,0x00000036,0x00000388,0x0000037d, + 0x0000008d,0x0004003d,0x00000009,0x00000389,0x00000388,0x00050081,0x00000009,0x0000038a, + 0x00000387,0x00000389,0x0004003d,0x0000000a,0x0000038b,0x00000382,0x00050050,0x0000000a, + 0x0000038c,0x0000038a,0x0000038a,0x00050088,0x0000000a,0x0000038d,0x0000038b,0x0000038c, + 0x0003003e,0x00000382,0x0000038d,0x0003003e,0x0000038e,0x00000219,0x00050041,0x00000036, + 0x0000038f,0x00000382,0x00000084,0x0004003d,0x00000009,0x00000390,0x0000038f,0x0004003d, + 0x00000027,0x00000391,0x0000006e,0x0004003d,0x00000012,0x00000392,0x00000070,0x0007004f, + 0x0000000a,0x00000393,0x00000392,0x00000392,0x00000000,0x00000001,0x00080058,0x00000012, + 0x00000395,0x00000391,0x00000393,0x0000000a,0x0000011a,0x00000394,0x00050051,0x00000009, + 0x00000396,0x00000395,0x00000000,0x00050085,0x00000009,0x00000397,0x00000390,0x00000396, + 0x00050041,0x00000036,0x00000398,0x0000038e,0x00000084,0x0004003d,0x00000009,0x00000399, + 0x00000398,0x00050083,0x00000009,0x0000039a,0x00000399,0x00000397,0x00050041,0x00000036, + 0x0000039b,0x0000038e,0x00000084,0x0003003e,0x0000039b,0x0000039a,0x00050041,0x00000036, + 0x0000039c,0x00000382,0x0000008d,0x0004003d,0x00000009,0x0000039d,0x0000039c,0x0004003d, + 0x00000027,0x0000039e,0x0000006e,0x0004003d,0x00000012,0x0000039f,0x00000070,0x0007004f, + 0x0000000a,0x000003a0,0x0000039f,0x0000039f,0x00000002,0x00000003,0x00080058,0x00000012, + 0x000003a2,0x0000039e,0x000003a0,0x0000000a,0x0000011a,0x000003a1,0x00050051,0x00000009, + 0x000003a3,0x000003a2,0x00000000,0x00050085,0x00000009,0x000003a4,0x0000039d,0x000003a3, + 0x00050041,0x00000036,0x000003a5,0x0000038e,0x00000084,0x0004003d,0x00000009,0x000003a6, + 0x000003a5,0x00050083,0x00000009,0x000003a7,0x000003a6,0x000003a4,0x00050041,0x00000036, + 0x000003a8,0x0000038e,0x00000084,0x0003003e,0x000003a8,0x000003a7,0x00050041,0x00000036, + 0x000003a9,0x00000382,0x00000084,0x0004003d,0x00000009,0x000003aa,0x000003a9,0x0004003d, + 0x00000027,0x000003ab,0x0000006e,0x0004003d,0x00000012,0x000003ac,0x00000070,0x0007004f, + 0x0000000a,0x000003ad,0x000003ac,0x000003ac,0x00000000,0x00000001,0x00080058,0x00000012, + 0x000003b0,0x000003ab,0x000003ad,0x0000000a,0x0000011a,0x000003af,0x00050051,0x00000009, + 0x000003b1,0x000003b0,0x00000000,0x00050085,0x00000009,0x000003b2,0x000003aa,0x000003b1, + 0x00050041,0x00000036,0x000003b3,0x0000038e,0x0000008d,0x0004003d,0x00000009,0x000003b4, + 0x000003b3,0x00050083,0x00000009,0x000003b5,0x000003b4,0x000003b2,0x00050041,0x00000036, + 0x000003b6,0x0000038e,0x0000008d,0x0003003e,0x000003b6,0x000003b5,0x00050041,0x00000036, + 0x000003b7,0x00000382,0x0000008d,0x0004003d,0x00000009,0x000003b8,0x000003b7,0x0004003d, + 0x00000027,0x000003b9,0x0000006e,0x0004003d,0x00000012,0x000003ba,0x00000070,0x0007004f, + 0x0000000a,0x000003bb,0x000003ba,0x000003ba,0x00000002,0x00000003,0x00080058,0x00000012, + 0x000003bd,0x000003b9,0x000003bb,0x0000000a,0x0000011a,0x000003bc,0x00050051,0x00000009, + 0x000003be,0x000003bd,0x00000000,0x00050085,0x00000009,0x000003bf,0x000003b8,0x000003be, + 0x00050041,0x00000036,0x000003c0,0x0000038e,0x0000008d,0x0004003d,0x00000009,0x000003c1, + 0x000003c0,0x00050083,0x00000009,0x000003c2,0x000003c1,0x000003bf,0x00050041,0x00000036, + 0x000003c3,0x0000038e,0x0000008d,0x0003003e,0x000003c3,0x000003c2,0x0004003d,0x0000000a, + 0x000003c4,0x0000038e,0x00050050,0x0000000a,0x000003c5,0x0000011a,0x0000011a,0x00050050, + 0x0000000a,0x000003c6,0x000000ec,0x000000ec,0x0008000c,0x0000000a,0x000003c7,0x00000001, + 0x0000002b,0x000003c4,0x000003c5,0x000003c6,0x0004003d,0x0000000a,0x000003c8,0x0000006f, + 0x00050085,0x0000000a,0x000003c9,0x000003c8,0x000003c7,0x0003003e,0x0000006f,0x000003c9, + 0x000100fd,0x00010038,0x00050036,0x00000002,0x00000078,0x00000000,0x0000006d,0x00030037, + 0x00000028,0x00000074,0x00030037,0x0000000b,0x00000075,0x00030037,0x00000021,0x00000076, + 0x00030037,0x0000000b,0x00000077,0x000200f8,0x00000079,0x0004003b,0x0000000b,0x000003ca, + 0x00000007,0x0004003b,0x0000000b,0x000003cf,0x00000007,0x0004003b,0x0000000b,0x000003da, + 0x00000007,0x0004003d,0x0000000a,0x000003cb,0x00000077,0x0004003d,0x0000000a,0x000003cc, + 0x00000077,0x0007004f,0x0000000a,0x000003cd,0x000003cc,0x000003cc,0x00000001,0x00000000, + 0x0007000c,0x0000000a,0x000003ce,0x00000001,0x00000030,0x000003cb,0x000003cd,0x0003003e, + 0x000003ca,0x000003ce,0x0004003d,0x0000000a,0x000003d0,0x000003ca,0x0005008e,0x0000000a, + 0x000003d1,0x000003d0,0x00000383,0x0003003e,0x000003cf,0x000003d1,0x00050041,0x00000036, + 0x000003d2,0x000003ca,0x00000084,0x0004003d,0x00000009,0x000003d3,0x000003d2,0x00050041, + 0x00000036,0x000003d4,0x000003ca,0x0000008d,0x0004003d,0x00000009,0x000003d5,0x000003d4, + 0x00050081,0x00000009,0x000003d6,0x000003d3,0x000003d5,0x0004003d,0x0000000a,0x000003d7, + 0x000003cf,0x00050050,0x0000000a,0x000003d8,0x000003d6,0x000003d6,0x00050088,0x0000000a, + 0x000003d9,0x000003d7,0x000003d8,0x0003003e,0x000003cf,0x000003d9,0x0003003e,0x000003da, + 0x00000219,0x00050041,0x00000036,0x000003db,0x000003cf,0x00000084,0x0004003d,0x00000009, + 0x000003dc,0x000003db,0x0004003d,0x00000027,0x000003dd,0x00000074,0x0004003d,0x00000012, + 0x000003de,0x00000076,0x0007004f,0x0000000a,0x000003df,0x000003de,0x000003de,0x00000000, + 0x00000001,0x00080058,0x00000012,0x000003e0,0x000003dd,0x000003df,0x0000000a,0x0000011a, + 0x000001de,0x00050051,0x00000009,0x000003e1,0x000003e0,0x00000001,0x00050085,0x00000009, + 0x000003e2,0x000003dc,0x000003e1,0x00050041,0x00000036,0x000003e3,0x000003da,0x00000084, + 0x0004003d,0x00000009,0x000003e4,0x000003e3,0x00050083,0x00000009,0x000003e5,0x000003e4, + 0x000003e2,0x00050041,0x00000036,0x000003e6,0x000003da,0x00000084,0x0003003e,0x000003e6, + 0x000003e5,0x00050041,0x00000036,0x000003e7,0x000003cf,0x0000008d,0x0004003d,0x00000009, + 0x000003e8,0x000003e7,0x0004003d,0x00000027,0x000003e9,0x00000074,0x0004003d,0x00000012, + 0x000003ea,0x00000076,0x0007004f,0x0000000a,0x000003eb,0x000003ea,0x000003ea,0x00000002, + 0x00000003,0x00080058,0x00000012,0x000003ec,0x000003e9,0x000003eb,0x0000000a,0x0000011a, + 0x000003a1,0x00050051,0x00000009,0x000003ed,0x000003ec,0x00000001,0x00050085,0x00000009, + 0x000003ee,0x000003e8,0x000003ed,0x00050041,0x00000036,0x000003ef,0x000003da,0x00000084, + 0x0004003d,0x00000009,0x000003f0,0x000003ef,0x00050083,0x00000009,0x000003f1,0x000003f0, + 0x000003ee,0x00050041,0x00000036,0x000003f2,0x000003da,0x00000084,0x0003003e,0x000003f2, + 0x000003f1,0x00050041,0x00000036,0x000003f3,0x000003cf,0x00000084,0x0004003d,0x00000009, + 0x000003f4,0x000003f3,0x0004003d,0x00000027,0x000003f5,0x00000074,0x0004003d,0x00000012, + 0x000003f6,0x00000076,0x0007004f,0x0000000a,0x000003f7,0x000003f6,0x000003f6,0x00000000, + 0x00000001,0x00080058,0x00000012,0x000003f9,0x000003f5,0x000003f7,0x0000000a,0x0000011a, + 0x000003f8,0x00050051,0x00000009,0x000003fa,0x000003f9,0x00000001,0x00050085,0x00000009, + 0x000003fb,0x000003f4,0x000003fa,0x00050041,0x00000036,0x000003fc,0x000003da,0x0000008d, + 0x0004003d,0x00000009,0x000003fd,0x000003fc,0x00050083,0x00000009,0x000003fe,0x000003fd, + 0x000003fb,0x00050041,0x00000036,0x000003ff,0x000003da,0x0000008d,0x0003003e,0x000003ff, + 0x000003fe,0x00050041,0x00000036,0x00000400,0x000003cf,0x0000008d,0x0004003d,0x00000009, + 0x00000401,0x00000400,0x0004003d,0x00000027,0x00000402,0x00000074,0x0004003d,0x00000012, + 0x00000403,0x00000076,0x0007004f,0x0000000a,0x00000404,0x00000403,0x00000403,0x00000002, + 0x00000003,0x00080058,0x00000012,0x00000406,0x00000402,0x00000404,0x0000000a,0x0000011a, + 0x00000405,0x00050051,0x00000009,0x00000407,0x00000406,0x00000001,0x00050085,0x00000009, + 0x00000408,0x00000401,0x00000407,0x00050041,0x00000036,0x00000409,0x000003da,0x0000008d, + 0x0004003d,0x00000009,0x0000040a,0x00000409,0x00050083,0x00000009,0x0000040b,0x0000040a, + 0x00000408,0x00050041,0x00000036,0x0000040c,0x000003da,0x0000008d,0x0003003e,0x0000040c, + 0x0000040b,0x0004003d,0x0000000a,0x0000040d,0x000003da,0x00050050,0x0000000a,0x0000040e, + 0x0000011a,0x0000011a,0x00050050,0x0000000a,0x0000040f,0x000000ec,0x000000ec,0x0008000c, + 0x0000000a,0x00000410,0x00000001,0x0000002b,0x0000040d,0x0000040e,0x0000040f,0x0004003d, + 0x0000000a,0x00000411,0x00000075,0x00050085,0x0000000a,0x00000412,0x00000411,0x00000410, + 0x0003003e,0x00000075,0x00000412,0x000100fd,0x00010038,0x00050036,0x00000012,0x00000082, + 0x00000000,0x0000007a,0x00030037,0x0000000b,0x0000007b,0x00030037,0x0000000b,0x0000007c, + 0x00030037,0x00000016,0x0000007d,0x00030037,0x00000028,0x0000007e,0x00030037,0x00000028, + 0x0000007f,0x00030037,0x00000028,0x00000080,0x00030037,0x00000021,0x00000081,0x000200f8, + 0x00000083,0x0004003b,0x00000021,0x00000413,0x00000007,0x0004003b,0x0000000b,0x00000415, + 0x00000007,0x0004003b,0x0000000b,0x0000041f,0x00000007,0x0004003b,0x0000000b,0x00000421, + 0x00000007,0x0004003b,0x00000021,0x00000423,0x00000007,0x0004003b,0x000000f1,0x00000432, + 0x00000007,0x0004003b,0x0000000b,0x00000433,0x00000007,0x0004003b,0x00000036,0x00000437, + 0x00000007,0x0004003b,0x0000000b,0x0000043f,0x00000007,0x0004003b,0x00000036,0x00000443, + 0x00000007,0x0004003b,0x0000000b,0x00000449,0x00000007,0x0004003b,0x00000036,0x0000044d, + 0x00000007,0x0004003b,0x0000000b,0x0000045f,0x00000007,0x0004003b,0x00000036,0x00000462, + 0x00000007,0x0004003b,0x0000000b,0x00000468,0x00000007,0x0004003b,0x00000036,0x0000046a, + 0x00000007,0x0004003b,0x00000036,0x0000046c,0x00000007,0x0004003b,0x00000036,0x0000046e, + 0x00000007,0x0004003b,0x0000000b,0x00000479,0x00000007,0x0004003b,0x00000021,0x0000047c, + 0x00000007,0x0004003b,0x0000000b,0x0000047f,0x00000007,0x0004003b,0x000000f1,0x0000048e, + 0x00000007,0x0004003b,0x0000000b,0x0000048f,0x00000007,0x0004003b,0x00000036,0x00000493, + 0x00000007,0x0004003b,0x0000000b,0x0000049b,0x00000007,0x0004003b,0x00000036,0x0000049f, + 0x00000007,0x0004003b,0x0000000b,0x000004a5,0x00000007,0x0004003b,0x00000036,0x000004a9, + 0x00000007,0x0004003b,0x0000000b,0x000004bb,0x00000007,0x0004003b,0x00000036,0x000004be, + 0x00000007,0x0004003b,0x0000000b,0x000004c4,0x00000007,0x0004003b,0x00000036,0x000004c6, + 0x00000007,0x0004003b,0x00000036,0x000004c8,0x00000007,0x0004003b,0x00000036,0x000004ca, + 0x00000007,0x0004003b,0x0000000b,0x000004d5,0x00000007,0x0004003b,0x00000021,0x000004d8, + 0x00000007,0x0004003b,0x0000000b,0x000004db,0x00000007,0x0003003e,0x00000413,0x00000414, + 0x0004003d,0x00000027,0x00000416,0x0000007e,0x0004003d,0x0000000a,0x00000417,0x0000007b, + 0x00050057,0x00000012,0x00000418,0x00000416,0x00000417,0x0007004f,0x0000000a,0x00000419, + 0x00000418,0x00000418,0x00000000,0x00000001,0x0003003e,0x00000415,0x00000419,0x00050041, + 0x00000036,0x0000041a,0x00000415,0x0000008d,0x0004003d,0x00000009,0x0000041b,0x0000041a, + 0x000500ba,0x00000006,0x0000041c,0x0000041b,0x0000011a,0x000300f7,0x0000041e,0x00000000, + 0x000400fa,0x0000041c,0x0000041d,0x0000041e,0x000200f8,0x0000041d,0x0004003d,0x0000000a, + 0x00000420,0x0000007b,0x0003003e,0x0000041f,0x00000420,0x0004003d,0x0000000a,0x00000422, + 0x00000415,0x0003003e,0x00000421,0x00000422,0x0004003d,0x00000012,0x00000424,0x00000081, + 0x0003003e,0x00000423,0x00000424,0x00090039,0x0000000a,0x00000425,0x00000044,0x0000007e, + 0x0000007f,0x0000041f,0x00000421,0x00000423,0x00050041,0x00000036,0x00000426,0x00000413, + 0x00000084,0x00050051,0x00000009,0x00000427,0x00000425,0x00000000,0x0003003e,0x00000426, + 0x00000427,0x00050041,0x00000036,0x00000428,0x00000413,0x0000008d,0x00050051,0x00000009, + 0x00000429,0x00000425,0x00000001,0x0003003e,0x00000428,0x00000429,0x00050041,0x00000036, + 0x0000042a,0x00000413,0x00000084,0x0004003d,0x00000009,0x0000042b,0x0000042a,0x00050041, + 0x00000036,0x0000042c,0x00000413,0x0000008d,0x0004003d,0x00000009,0x0000042d,0x0000042c, + 0x0004007f,0x00000009,0x0000042e,0x0000042d,0x000500b4,0x00000006,0x0000042f,0x0000042b, + 0x0000042e,0x000300f7,0x00000431,0x00000000,0x000400fa,0x0000042f,0x00000430,0x00000487, + 0x000200f8,0x00000430,0x00050041,0x00000021,0x00000434,0x0000007d,0x000000a0,0x0004003d, + 0x00000012,0x00000435,0x00000434,0x0007004f,0x0000000a,0x00000436,0x00000435,0x00000435, + 0x00000000,0x00000001,0x0003003e,0x00000433,0x00000436,0x00060041,0x00000036,0x00000438, + 0x0000007d,0x000000b4,0x00000084,0x0004003d,0x00000009,0x00000439,0x00000438,0x0003003e, + 0x00000437,0x00000439,0x00080039,0x00000009,0x0000043a,0x00000051,0x0000007e,0x00000080, + 0x00000433,0x00000437,0x00050041,0x00000036,0x0000043b,0x00000432,0x00000084,0x0003003e, + 0x0000043b,0x0000043a,0x00060041,0x00000036,0x0000043c,0x0000007d,0x0000009a,0x0000008d, + 0x0004003d,0x00000009,0x0000043d,0x0000043c,0x00050041,0x00000036,0x0000043e,0x00000432, + 0x0000008d,0x0003003e,0x0000043e,0x0000043d,0x00050041,0x00000036,0x00000440,0x00000432, + 0x00000084,0x0004003d,0x00000009,0x00000441,0x00000440,0x00050041,0x00000036,0x00000442, + 0x0000043f,0x00000084,0x0003003e,0x00000442,0x00000441,0x0004003d,0x00000027,0x00000444, + 0x0000007e,0x0004003d,0x000000f0,0x00000445,0x00000432,0x0007004f,0x0000000a,0x00000446, + 0x00000445,0x00000445,0x00000000,0x00000001,0x00070058,0x00000012,0x00000447,0x00000444, + 0x00000446,0x00000002,0x0000011a,0x00050051,0x00000009,0x00000448,0x00000447,0x00000000, + 0x0003003e,0x00000443,0x00000448,0x00050041,0x00000021,0x0000044a,0x0000007d,0x000000a0, + 0x0004003d,0x00000012,0x0000044b,0x0000044a,0x0007004f,0x0000000a,0x0000044c,0x0000044b, + 0x0000044b,0x00000002,0x00000003,0x0003003e,0x00000449,0x0000044c,0x00060041,0x00000036, + 0x0000044e,0x0000007d,0x000000b4,0x0000008d,0x0004003d,0x00000009,0x0000044f,0x0000044e, + 0x0003003e,0x0000044d,0x0000044f,0x00080039,0x00000009,0x00000450,0x00000057,0x0000007e, + 0x00000080,0x00000449,0x0000044d,0x00050041,0x00000036,0x00000451,0x00000432,0x000000e2, + 0x0003003e,0x00000451,0x00000450,0x00050041,0x00000036,0x00000452,0x00000432,0x000000e2, + 0x0004003d,0x00000009,0x00000453,0x00000452,0x00050041,0x00000036,0x00000454,0x0000043f, + 0x0000008d,0x0003003e,0x00000454,0x00000453,0x00050041,0x0000009b,0x00000455,0x00000098, + 0x0000009a,0x0004003d,0x00000012,0x00000456,0x00000455,0x0007004f,0x0000000a,0x00000457, + 0x00000456,0x00000456,0x00000002,0x00000002,0x0004003d,0x0000000a,0x00000458,0x0000043f, + 0x0004003d,0x0000000a,0x00000459,0x0000007c,0x0007004f,0x0000000a,0x0000045a,0x00000459, + 0x00000459,0x00000000,0x00000000,0x0004007f,0x0000000a,0x0000045b,0x0000045a,0x0008000c, + 0x0000000a,0x0000045c,0x00000001,0x00000032,0x00000457,0x00000458,0x0000045b,0x0006000c, + 0x0000000a,0x0000045d,0x00000001,0x00000001,0x0000045c,0x0006000c,0x0000000a,0x0000045e, + 0x00000001,0x00000004,0x0000045d,0x0003003e,0x0000043f,0x0000045e,0x0004003d,0x0000000a, + 0x00000460,0x0000043f,0x0006000c,0x0000000a,0x00000461,0x00000001,0x0000001f,0x00000460, + 0x0003003e,0x0000045f,0x00000461,0x0004003d,0x00000027,0x00000463,0x0000007e,0x0004003d, + 0x000000f0,0x00000464,0x00000432,0x0007004f,0x0000000a,0x00000465,0x00000464,0x00000464, + 0x00000002,0x00000001,0x00080058,0x00000012,0x00000466,0x00000463,0x00000465,0x0000000a, + 0x0000011a,0x000001de,0x00050051,0x00000009,0x00000467,0x00000466,0x00000000,0x0003003e, + 0x00000462,0x00000467,0x0004003d,0x0000000a,0x00000469,0x0000045f,0x0003003e,0x00000468, + 0x00000469,0x0004003d,0x00000009,0x0000046b,0x00000443,0x0003003e,0x0000046a,0x0000046b, + 0x0004003d,0x00000009,0x0000046d,0x00000462,0x0003003e,0x0000046c,0x0000046d,0x00050041, + 0x00000036,0x0000046f,0x00000081,0x0000008d,0x0004003d,0x00000009,0x00000470,0x0000046f, + 0x0003003e,0x0000046e,0x00000470,0x00090039,0x0000000a,0x00000471,0x0000006b,0x0000007f, + 0x00000468,0x0000046a,0x0000046c,0x0000046e,0x00050041,0x00000036,0x00000472,0x00000413, + 0x00000084,0x00050051,0x00000009,0x00000473,0x00000471,0x00000000,0x0003003e,0x00000472, + 0x00000473,0x00050041,0x00000036,0x00000474,0x00000413,0x0000008d,0x00050051,0x00000009, + 0x00000475,0x00000471,0x00000001,0x0003003e,0x00000474,0x00000475,0x00050041,0x00000036, + 0x00000476,0x0000007b,0x0000008d,0x0004003d,0x00000009,0x00000477,0x00000476,0x00050041, + 0x00000036,0x00000478,0x00000432,0x0000008d,0x0003003e,0x00000478,0x00000477,0x0004003d, + 0x00000012,0x0000047a,0x00000413,0x0007004f,0x0000000a,0x0000047b,0x0000047a,0x0000047a, + 0x00000000,0x00000001,0x0003003e,0x00000479,0x0000047b,0x0004003d,0x000000f0,0x0000047d, + 0x00000432,0x0009004f,0x00000012,0x0000047e,0x0000047d,0x0000047d,0x00000000,0x00000001, + 0x00000002,0x00000001,0x0003003e,0x0000047c,0x0000047e,0x0004003d,0x0000000a,0x00000480, + 0x0000043f,0x0003003e,0x0000047f,0x00000480,0x00080039,0x00000002,0x00000481,0x00000072, + 0x0000007e,0x00000479,0x0000047c,0x0000047f,0x0004003d,0x0000000a,0x00000482,0x00000479, + 0x00050041,0x00000036,0x00000483,0x00000413,0x00000084,0x00050051,0x00000009,0x00000484, + 0x00000482,0x00000000,0x0003003e,0x00000483,0x00000484,0x00050041,0x00000036,0x00000485, + 0x00000413,0x0000008d,0x00050051,0x00000009,0x00000486,0x00000482,0x00000001,0x0003003e, + 0x00000485,0x00000486,0x000200f9,0x00000431,0x000200f8,0x00000487,0x00050041,0x00000036, + 0x00000488,0x00000415,0x00000084,0x0003003e,0x00000488,0x0000011a,0x000200f9,0x00000431, + 0x000200f8,0x00000431,0x000200f9,0x0000041e,0x000200f8,0x0000041e,0x00050041,0x00000036, + 0x00000489,0x00000415,0x00000084,0x0004003d,0x00000009,0x0000048a,0x00000489,0x000500ba, + 0x00000006,0x0000048b,0x0000048a,0x0000011a,0x000300f7,0x0000048d,0x00000000,0x000400fa, + 0x0000048b,0x0000048c,0x0000048d,0x000200f8,0x0000048c,0x00050041,0x00000021,0x00000490, + 0x0000007d,0x0000009a,0x0004003d,0x00000012,0x00000491,0x00000490,0x0007004f,0x0000000a, + 0x00000492,0x00000491,0x00000491,0x00000000,0x00000001,0x0003003e,0x0000048f,0x00000492, + 0x00060041,0x00000036,0x00000494,0x0000007d,0x000000b4,0x000000e2,0x0004003d,0x00000009, + 0x00000495,0x00000494,0x0003003e,0x00000493,0x00000495,0x00080039,0x00000009,0x00000496, + 0x0000005d,0x0000007e,0x00000080,0x0000048f,0x00000493,0x00050041,0x00000036,0x00000497, + 0x0000048e,0x0000008d,0x0003003e,0x00000497,0x00000496,0x00060041,0x00000036,0x00000498, + 0x0000007d,0x000000a0,0x00000084,0x0004003d,0x00000009,0x00000499,0x00000498,0x00050041, + 0x00000036,0x0000049a,0x0000048e,0x00000084,0x0003003e,0x0000049a,0x00000499,0x00050041, + 0x00000036,0x0000049c,0x0000048e,0x0000008d,0x0004003d,0x00000009,0x0000049d,0x0000049c, + 0x00050041,0x00000036,0x0000049e,0x0000049b,0x00000084,0x0003003e,0x0000049e,0x0000049d, + 0x0004003d,0x00000027,0x000004a0,0x0000007e,0x0004003d,0x000000f0,0x000004a1,0x0000048e, + 0x0007004f,0x0000000a,0x000004a2,0x000004a1,0x000004a1,0x00000000,0x00000001,0x00070058, + 0x00000012,0x000004a3,0x000004a0,0x000004a2,0x00000002,0x0000011a,0x00050051,0x00000009, + 0x000004a4,0x000004a3,0x00000001,0x0003003e,0x0000049f,0x000004a4,0x00050041,0x00000021, + 0x000004a6,0x0000007d,0x0000009a,0x0004003d,0x00000012,0x000004a7,0x000004a6,0x0007004f, + 0x0000000a,0x000004a8,0x000004a7,0x000004a7,0x00000002,0x00000003,0x0003003e,0x000004a5, + 0x000004a8,0x00060041,0x00000036,0x000004aa,0x0000007d,0x000000b4,0x00000014,0x0004003d, + 0x00000009,0x000004ab,0x000004aa,0x0003003e,0x000004a9,0x000004ab,0x00080039,0x00000009, + 0x000004ac,0x00000063,0x0000007e,0x00000080,0x000004a5,0x000004a9,0x00050041,0x00000036, + 0x000004ad,0x0000048e,0x000000e2,0x0003003e,0x000004ad,0x000004ac,0x00050041,0x00000036, + 0x000004ae,0x0000048e,0x000000e2,0x0004003d,0x00000009,0x000004af,0x000004ae,0x00050041, + 0x00000036,0x000004b0,0x0000049b,0x0000008d,0x0003003e,0x000004b0,0x000004af,0x00050041, + 0x0000009b,0x000004b1,0x00000098,0x0000009a,0x0004003d,0x00000012,0x000004b2,0x000004b1, + 0x0007004f,0x0000000a,0x000004b3,0x000004b2,0x000004b2,0x00000003,0x00000003,0x0004003d, + 0x0000000a,0x000004b4,0x0000049b,0x0004003d,0x0000000a,0x000004b5,0x0000007c,0x0007004f, + 0x0000000a,0x000004b6,0x000004b5,0x000004b5,0x00000001,0x00000001,0x0004007f,0x0000000a, + 0x000004b7,0x000004b6,0x0008000c,0x0000000a,0x000004b8,0x00000001,0x00000032,0x000004b3, + 0x000004b4,0x000004b7,0x0006000c,0x0000000a,0x000004b9,0x00000001,0x00000001,0x000004b8, + 0x0006000c,0x0000000a,0x000004ba,0x00000001,0x00000004,0x000004b9,0x0003003e,0x0000049b, + 0x000004ba,0x0004003d,0x0000000a,0x000004bc,0x0000049b,0x0006000c,0x0000000a,0x000004bd, + 0x00000001,0x0000001f,0x000004bc,0x0003003e,0x000004bb,0x000004bd,0x0004003d,0x00000027, + 0x000004bf,0x0000007e,0x0004003d,0x000000f0,0x000004c0,0x0000048e,0x0007004f,0x0000000a, + 0x000004c1,0x000004c0,0x000004c0,0x00000000,0x00000002,0x00080058,0x00000012,0x000004c2, + 0x000004bf,0x000004c1,0x0000000a,0x0000011a,0x00000394,0x00050051,0x00000009,0x000004c3, + 0x000004c2,0x00000001,0x0003003e,0x000004be,0x000004c3,0x0004003d,0x0000000a,0x000004c5, + 0x000004bb,0x0003003e,0x000004c4,0x000004c5,0x0004003d,0x00000009,0x000004c7,0x0000049f, + 0x0003003e,0x000004c6,0x000004c7,0x0004003d,0x00000009,0x000004c9,0x000004be,0x0003003e, + 0x000004c8,0x000004c9,0x00050041,0x00000036,0x000004cb,0x00000081,0x00000084,0x0004003d, + 0x00000009,0x000004cc,0x000004cb,0x0003003e,0x000004ca,0x000004cc,0x00090039,0x0000000a, + 0x000004cd,0x0000006b,0x0000007f,0x000004c4,0x000004c6,0x000004c8,0x000004ca,0x00050041, + 0x00000036,0x000004ce,0x00000413,0x000000e2,0x00050051,0x00000009,0x000004cf,0x000004cd, + 0x00000000,0x0003003e,0x000004ce,0x000004cf,0x00050041,0x00000036,0x000004d0,0x00000413, + 0x00000014,0x00050051,0x00000009,0x000004d1,0x000004cd,0x00000001,0x0003003e,0x000004d0, + 0x000004d1,0x00050041,0x00000036,0x000004d2,0x0000007b,0x00000084,0x0004003d,0x00000009, + 0x000004d3,0x000004d2,0x00050041,0x00000036,0x000004d4,0x0000048e,0x00000084,0x0003003e, + 0x000004d4,0x000004d3,0x0004003d,0x00000012,0x000004d6,0x00000413,0x0007004f,0x0000000a, + 0x000004d7,0x000004d6,0x000004d6,0x00000002,0x00000003,0x0003003e,0x000004d5,0x000004d7, + 0x0004003d,0x000000f0,0x000004d9,0x0000048e,0x0009004f,0x00000012,0x000004da,0x000004d9, + 0x000004d9,0x00000000,0x00000001,0x00000000,0x00000002,0x0003003e,0x000004d8,0x000004da, + 0x0004003d,0x0000000a,0x000004dc,0x0000049b,0x0003003e,0x000004db,0x000004dc,0x00080039, + 0x00000002,0x000004dd,0x00000078,0x0000007e,0x000004d5,0x000004d8,0x000004db,0x0004003d, + 0x0000000a,0x000004de,0x000004d5,0x00050041,0x00000036,0x000004df,0x00000413,0x000000e2, + 0x00050051,0x00000009,0x000004e0,0x000004de,0x00000000,0x0003003e,0x000004df,0x000004e0, + 0x00050041,0x00000036,0x000004e1,0x00000413,0x00000014,0x00050051,0x00000009,0x000004e2, + 0x000004de,0x00000001,0x0003003e,0x000004e1,0x000004e2,0x000200f9,0x0000048d,0x000200f8, + 0x0000048d,0x0004003d,0x00000012,0x000004e3,0x00000413,0x000200fe,0x000004e3,0x00010038 +}; diff --git a/app/src/main/cpp/shaders/toon.frag b/app/src/main/cpp/shaders/toon.frag new file mode 100644 index 0000000000..f55323caa8 --- /dev/null +++ b/app/src/main/cpp/shaders/toon.frag @@ -0,0 +1,44 @@ +#version 450 + +// ============================================================================= +// Toon / cel edge-outline post effect. +// +// Ported verbatim from the OpenGL ToonEffect.java shader. GL derived uv from +// gl_FragCoord.xy / resolution; here fragTexCoord already spans [0,1] across +// the output, so it IS that uv. edgeThreshold/offset constants unchanged. +// +// Conventions match upscale.vert: combined-image-sampler at binding 0, the +// push-constant block leads with vec4 ndc (offset 0), fragTexCoord in [0,1]. +// Runs after FXAA in the canonical chain (stylize the clean image). +// ============================================================================= + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; // quad NDC rect, consumed by upscale.vert (offset 0) + vec2 resolution; // input texture size in px +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec2 uv = fragTexCoord; + + float edgeThreshold = 0.2; // edge-detect threshold + vec2 offset = vec2(1.0) / pc.resolution; // 1-texel neighbour offset + + vec3 colorCenter = texture(InputTexture, uv).rgb; + vec3 colorLeft = texture(InputTexture, uv - vec2(offset.x, 0.0)).rgb; + vec3 colorRight = texture(InputTexture, uv + vec2(offset.x, 0.0)).rgb; + vec3 colorUp = texture(InputTexture, uv - vec2(0.0, offset.y)).rgb; + vec3 colorDown = texture(InputTexture, uv + vec2(0.0, offset.y)).rgb; + + float diffHorizontal = length(colorRight - colorLeft); + float diffVertical = length(colorUp - colorDown); + + float edgeFactor = step(edgeThreshold, diffHorizontal + diffVertical); + vec3 outlineColor = mix(colorCenter, vec3(0.0), edgeFactor); + + outColor = vec4(outlineColor, 1.0); +} diff --git a/app/src/main/cpp/shaders/toon_color.frag b/app/src/main/cpp/shaders/toon_color.frag new file mode 100644 index 0000000000..58f12d5aa2 --- /dev/null +++ b/app/src/main/cpp/shaders/toon_color.frag @@ -0,0 +1,51 @@ +#version 450 + +layout(binding = 0) uniform sampler2D InputTexture; + +layout(push_constant) uniform PC { + vec4 ndc; + vec2 resolution; + float brightness; + float contrast; + float gamma; + float saturation; +} pc; + +layout(location = 0) in vec2 fragTexCoord; +layout(location = 0) out vec4 outColor; + +void main() { + vec2 uv = fragTexCoord; + vec2 offset = vec2(1.0) / pc.resolution; + + vec3 center = texture(InputTexture, uv).rgb; + vec3 left = texture( + InputTexture, uv - vec2(offset.x, 0.0)).rgb; + vec3 right = texture( + InputTexture, uv + vec2(offset.x, 0.0)).rgb; + vec3 up = texture( + InputTexture, uv - vec2(0.0, offset.y)).rgb; + vec3 down = texture( + InputTexture, uv + vec2(0.0, offset.y)).rgb; + + float horizontal = length(right - left); + float vertical = length(up - down); + float edge = step(0.2, horizontal + vertical); + + vec3 color = mix(center, vec3(0.0), edge); + + color = roundEven(clamp(color, 0.0, 1.0) * 255.0) / 255.0; + + color = clamp(color + pc.brightness, 0.0, 1.0); + color = (color - 0.5) * + clamp(pc.contrast + 1.0, 0.5, 2.0) + 0.5; + + vec3 grey = vec3( + dot(color, vec3(0.2126, 0.7152, 0.0722))); + + color = mix(grey, color, clamp(pc.saturation, 0.0, 2.0)); + color = max(color, vec3(0.0)); + color = pow(color, vec3(1.0 / pc.gamma)); + + outColor = vec4(color, 1.0); +} diff --git a/app/src/main/cpp/shaders/toon_color_frag.h b/app/src/main/cpp/shaders/toon_color_frag.h new file mode 100644 index 0000000000..43a42b0634 --- /dev/null +++ b/app/src/main/cpp/shaders/toon_color_frag.h @@ -0,0 +1,133 @@ + // 1116.3.0 + #pragma once +const uint32_t toon_color_code[] = { + 0x07230203,0x00010000,0x0008000b,0x000000a4,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000009e,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, + 0x00000000,0x00030005,0x00000009,0x00007675,0x00060005,0x0000000b,0x67617266,0x43786554, + 0x64726f6f,0x00000000,0x00040005,0x0000000d,0x7366666f,0x00007465,0x00030005,0x00000011, + 0x00004350,0x00040006,0x00000011,0x00000000,0x0063646e,0x00060006,0x00000011,0x00000001, + 0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000011,0x00000002,0x67697262,0x656e7468, + 0x00007373,0x00060006,0x00000011,0x00000003,0x746e6f63,0x74736172,0x00000000,0x00050006, + 0x00000011,0x00000004,0x6d6d6167,0x00000061,0x00060006,0x00000011,0x00000005,0x75746173, + 0x69746172,0x00006e6f,0x00030005,0x00000013,0x00006370,0x00040005,0x0000001c,0x746e6563, + 0x00007265,0x00060005,0x00000020,0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005, + 0x00000025,0x7466656c,0x00000000,0x00040005,0x00000032,0x68676972,0x00000074,0x00030005, + 0x0000003b,0x00007075,0x00040005,0x00000045,0x6e776f64,0x00000000,0x00050005,0x0000004e, + 0x69726f68,0x746e6f7a,0x00006c61,0x00050005,0x00000053,0x74726576,0x6c616369,0x00000000, + 0x00040005,0x00000058,0x65676465,0x00000000,0x00040005,0x0000005e,0x6f6c6f63,0x00000072, + 0x00040005,0x00000084,0x79657267,0x00000000,0x00050005,0x0000009e,0x4374756f,0x726f6c6f, + 0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000,0x00030047,0x00000011,0x00000002, + 0x00050048,0x00000011,0x00000000,0x00000023,0x00000000,0x00050048,0x00000011,0x00000001, + 0x00000023,0x00000010,0x00050048,0x00000011,0x00000002,0x00000023,0x00000018,0x00050048, + 0x00000011,0x00000003,0x00000023,0x0000001c,0x00050048,0x00000011,0x00000004,0x00000023, + 0x00000020,0x00050048,0x00000011,0x00000005,0x00000023,0x00000024,0x00040047,0x00000020, + 0x00000021,0x00000000,0x00040047,0x00000020,0x00000022,0x00000000,0x00040047,0x0000009e, + 0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016, + 0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008, + 0x00000007,0x00000007,0x00040020,0x0000000a,0x00000001,0x00000007,0x0004003b,0x0000000a, + 0x0000000b,0x00000001,0x0004002b,0x00000006,0x0000000e,0x3f800000,0x0005002c,0x00000007, + 0x0000000f,0x0000000e,0x0000000e,0x00040017,0x00000010,0x00000006,0x00000004,0x0008001e, + 0x00000011,0x00000010,0x00000007,0x00000006,0x00000006,0x00000006,0x00000006,0x00040020, + 0x00000012,0x00000009,0x00000011,0x0004003b,0x00000012,0x00000013,0x00000009,0x00040015, + 0x00000014,0x00000020,0x00000001,0x0004002b,0x00000014,0x00000015,0x00000001,0x00040020, + 0x00000016,0x00000009,0x00000007,0x00040017,0x0000001a,0x00000006,0x00000003,0x00040020, + 0x0000001b,0x00000007,0x0000001a,0x00090019,0x0000001d,0x00000006,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000001e,0x0000001d,0x00040020, + 0x0000001f,0x00000000,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000000,0x00040015, + 0x00000028,0x00000020,0x00000000,0x0004002b,0x00000028,0x00000029,0x00000000,0x00040020, + 0x0000002a,0x00000007,0x00000006,0x0004002b,0x00000006,0x0000002d,0x00000000,0x0004002b, + 0x00000028,0x0000003e,0x00000001,0x0004002b,0x00000006,0x00000059,0x3e4ccccd,0x0006002c, + 0x0000001a,0x00000060,0x0000002d,0x0000002d,0x0000002d,0x0004002b,0x00000006,0x00000068, + 0x437f0000,0x0004002b,0x00000014,0x0000006e,0x00000002,0x00040020,0x0000006f,0x00000009, + 0x00000006,0x0004002b,0x00000006,0x00000078,0x3f000000,0x0004002b,0x00000014,0x0000007b, + 0x00000003,0x0004002b,0x00000006,0x0000007f,0x40000000,0x0004002b,0x00000006,0x00000086, + 0x3e59b3d0,0x0004002b,0x00000006,0x00000087,0x3f371759,0x0004002b,0x00000006,0x00000088, + 0x3d93dd98,0x0006002c,0x0000001a,0x00000089,0x00000086,0x00000087,0x00000088,0x0004002b, + 0x00000014,0x0000008e,0x00000005,0x0004002b,0x00000014,0x00000097,0x00000004,0x00040020, + 0x0000009d,0x00000003,0x00000010,0x0004003b,0x0000009d,0x0000009e,0x00000003,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008, + 0x00000009,0x00000007,0x0004003b,0x00000008,0x0000000d,0x00000007,0x0004003b,0x0000001b, + 0x0000001c,0x00000007,0x0004003b,0x0000001b,0x00000025,0x00000007,0x0004003b,0x0000001b, + 0x00000032,0x00000007,0x0004003b,0x0000001b,0x0000003b,0x00000007,0x0004003b,0x0000001b, + 0x00000045,0x00000007,0x0004003b,0x0000002a,0x0000004e,0x00000007,0x0004003b,0x0000002a, + 0x00000053,0x00000007,0x0004003b,0x0000002a,0x00000058,0x00000007,0x0004003b,0x0000001b, + 0x0000005e,0x00000007,0x0004003b,0x0000001b,0x00000084,0x00000007,0x0004003d,0x00000007, + 0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x00050041,0x00000016,0x00000017, + 0x00000013,0x00000015,0x0004003d,0x00000007,0x00000018,0x00000017,0x00050088,0x00000007, + 0x00000019,0x0000000f,0x00000018,0x0003003e,0x0000000d,0x00000019,0x0004003d,0x0000001e, + 0x00000021,0x00000020,0x0004003d,0x00000007,0x00000022,0x00000009,0x00050057,0x00000010, + 0x00000023,0x00000021,0x00000022,0x0008004f,0x0000001a,0x00000024,0x00000023,0x00000023, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000001c,0x00000024,0x0004003d,0x0000001e, + 0x00000026,0x00000020,0x0004003d,0x00000007,0x00000027,0x00000009,0x00050041,0x0000002a, + 0x0000002b,0x0000000d,0x00000029,0x0004003d,0x00000006,0x0000002c,0x0000002b,0x00050050, + 0x00000007,0x0000002e,0x0000002c,0x0000002d,0x00050083,0x00000007,0x0000002f,0x00000027, + 0x0000002e,0x00050057,0x00000010,0x00000030,0x00000026,0x0000002f,0x0008004f,0x0000001a, + 0x00000031,0x00000030,0x00000030,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000025, + 0x00000031,0x0004003d,0x0000001e,0x00000033,0x00000020,0x0004003d,0x00000007,0x00000034, + 0x00000009,0x00050041,0x0000002a,0x00000035,0x0000000d,0x00000029,0x0004003d,0x00000006, + 0x00000036,0x00000035,0x00050050,0x00000007,0x00000037,0x00000036,0x0000002d,0x00050081, + 0x00000007,0x00000038,0x00000034,0x00000037,0x00050057,0x00000010,0x00000039,0x00000033, + 0x00000038,0x0008004f,0x0000001a,0x0000003a,0x00000039,0x00000039,0x00000000,0x00000001, + 0x00000002,0x0003003e,0x00000032,0x0000003a,0x0004003d,0x0000001e,0x0000003c,0x00000020, + 0x0004003d,0x00000007,0x0000003d,0x00000009,0x00050041,0x0000002a,0x0000003f,0x0000000d, + 0x0000003e,0x0004003d,0x00000006,0x00000040,0x0000003f,0x00050050,0x00000007,0x00000041, + 0x0000002d,0x00000040,0x00050083,0x00000007,0x00000042,0x0000003d,0x00000041,0x00050057, + 0x00000010,0x00000043,0x0000003c,0x00000042,0x0008004f,0x0000001a,0x00000044,0x00000043, + 0x00000043,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000003b,0x00000044,0x0004003d, + 0x0000001e,0x00000046,0x00000020,0x0004003d,0x00000007,0x00000047,0x00000009,0x00050041, + 0x0000002a,0x00000048,0x0000000d,0x0000003e,0x0004003d,0x00000006,0x00000049,0x00000048, + 0x00050050,0x00000007,0x0000004a,0x0000002d,0x00000049,0x00050081,0x00000007,0x0000004b, + 0x00000047,0x0000004a,0x00050057,0x00000010,0x0000004c,0x00000046,0x0000004b,0x0008004f, + 0x0000001a,0x0000004d,0x0000004c,0x0000004c,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000045,0x0000004d,0x0004003d,0x0000001a,0x0000004f,0x00000032,0x0004003d,0x0000001a, + 0x00000050,0x00000025,0x00050083,0x0000001a,0x00000051,0x0000004f,0x00000050,0x0006000c, + 0x00000006,0x00000052,0x00000001,0x00000042,0x00000051,0x0003003e,0x0000004e,0x00000052, + 0x0004003d,0x0000001a,0x00000054,0x0000003b,0x0004003d,0x0000001a,0x00000055,0x00000045, + 0x00050083,0x0000001a,0x00000056,0x00000054,0x00000055,0x0006000c,0x00000006,0x00000057, + 0x00000001,0x00000042,0x00000056,0x0003003e,0x00000053,0x00000057,0x0004003d,0x00000006, + 0x0000005a,0x0000004e,0x0004003d,0x00000006,0x0000005b,0x00000053,0x00050081,0x00000006, + 0x0000005c,0x0000005a,0x0000005b,0x0007000c,0x00000006,0x0000005d,0x00000001,0x00000030, + 0x00000059,0x0000005c,0x0003003e,0x00000058,0x0000005d,0x0004003d,0x0000001a,0x0000005f, + 0x0000001c,0x0004003d,0x00000006,0x00000061,0x00000058,0x00060050,0x0000001a,0x00000062, + 0x00000061,0x00000061,0x00000061,0x0008000c,0x0000001a,0x00000063,0x00000001,0x0000002e, + 0x0000005f,0x00000060,0x00000062,0x0003003e,0x0000005e,0x00000063,0x0004003d,0x0000001a, + 0x00000064,0x0000005e,0x00060050,0x0000001a,0x00000065,0x0000002d,0x0000002d,0x0000002d, + 0x00060050,0x0000001a,0x00000066,0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x0000001a, + 0x00000067,0x00000001,0x0000002b,0x00000064,0x00000065,0x00000066,0x0005008e,0x0000001a, + 0x00000069,0x00000067,0x00000068,0x0006000c,0x0000001a,0x0000006a,0x00000001,0x00000002, + 0x00000069,0x00060050,0x0000001a,0x0000006b,0x00000068,0x00000068,0x00000068,0x00050088, + 0x0000001a,0x0000006c,0x0000006a,0x0000006b,0x0003003e,0x0000005e,0x0000006c,0x0004003d, + 0x0000001a,0x0000006d,0x0000005e,0x00050041,0x0000006f,0x00000070,0x00000013,0x0000006e, + 0x0004003d,0x00000006,0x00000071,0x00000070,0x00060050,0x0000001a,0x00000072,0x00000071, + 0x00000071,0x00000071,0x00050081,0x0000001a,0x00000073,0x0000006d,0x00000072,0x00060050, + 0x0000001a,0x00000074,0x0000002d,0x0000002d,0x0000002d,0x00060050,0x0000001a,0x00000075, + 0x0000000e,0x0000000e,0x0000000e,0x0008000c,0x0000001a,0x00000076,0x00000001,0x0000002b, + 0x00000073,0x00000074,0x00000075,0x0003003e,0x0000005e,0x00000076,0x0004003d,0x0000001a, + 0x00000077,0x0000005e,0x00060050,0x0000001a,0x00000079,0x00000078,0x00000078,0x00000078, + 0x00050083,0x0000001a,0x0000007a,0x00000077,0x00000079,0x00050041,0x0000006f,0x0000007c, + 0x00000013,0x0000007b,0x0004003d,0x00000006,0x0000007d,0x0000007c,0x00050081,0x00000006, + 0x0000007e,0x0000007d,0x0000000e,0x0008000c,0x00000006,0x00000080,0x00000001,0x0000002b, + 0x0000007e,0x00000078,0x0000007f,0x0005008e,0x0000001a,0x00000081,0x0000007a,0x00000080, + 0x00060050,0x0000001a,0x00000082,0x00000078,0x00000078,0x00000078,0x00050081,0x0000001a, + 0x00000083,0x00000081,0x00000082,0x0003003e,0x0000005e,0x00000083,0x0004003d,0x0000001a, + 0x00000085,0x0000005e,0x00050094,0x00000006,0x0000008a,0x00000085,0x00000089,0x00060050, + 0x0000001a,0x0000008b,0x0000008a,0x0000008a,0x0000008a,0x0003003e,0x00000084,0x0000008b, + 0x0004003d,0x0000001a,0x0000008c,0x00000084,0x0004003d,0x0000001a,0x0000008d,0x0000005e, + 0x00050041,0x0000006f,0x0000008f,0x00000013,0x0000008e,0x0004003d,0x00000006,0x00000090, + 0x0000008f,0x0008000c,0x00000006,0x00000091,0x00000001,0x0000002b,0x00000090,0x0000002d, + 0x0000007f,0x00060050,0x0000001a,0x00000092,0x00000091,0x00000091,0x00000091,0x0008000c, + 0x0000001a,0x00000093,0x00000001,0x0000002e,0x0000008c,0x0000008d,0x00000092,0x0003003e, + 0x0000005e,0x00000093,0x0004003d,0x0000001a,0x00000094,0x0000005e,0x0007000c,0x0000001a, + 0x00000095,0x00000001,0x00000028,0x00000094,0x00000060,0x0003003e,0x0000005e,0x00000095, + 0x0004003d,0x0000001a,0x00000096,0x0000005e,0x00050041,0x0000006f,0x00000098,0x00000013, + 0x00000097,0x0004003d,0x00000006,0x00000099,0x00000098,0x00050088,0x00000006,0x0000009a, + 0x0000000e,0x00000099,0x00060050,0x0000001a,0x0000009b,0x0000009a,0x0000009a,0x0000009a, + 0x0007000c,0x0000001a,0x0000009c,0x00000001,0x0000001a,0x00000096,0x0000009b,0x0003003e, + 0x0000005e,0x0000009c,0x0004003d,0x0000001a,0x0000009f,0x0000005e,0x00050051,0x00000006, + 0x000000a0,0x0000009f,0x00000000,0x00050051,0x00000006,0x000000a1,0x0000009f,0x00000001, + 0x00050051,0x00000006,0x000000a2,0x0000009f,0x00000002,0x00070050,0x00000010,0x000000a3, + 0x000000a0,0x000000a1,0x000000a2,0x0000000e,0x0003003e,0x0000009e,0x000000a3,0x000100fd, + 0x00010038 +}; diff --git a/app/src/main/cpp/shaders/upscale.vert b/app/src/main/cpp/shaders/upscale.vert new file mode 100644 index 0000000000..0be0bed0ab --- /dev/null +++ b/app/src/main/cpp/shaders/upscale.vert @@ -0,0 +1,23 @@ +#version 450 + +// Full-screen / sub-rect quad for the spatial-upscaler post passes (SGSR, FSR +// EASU/RCAS). Identical quad generation to window.vert, but the push-constant +// block is declared as a single vec4 `ndc` so it matches the leading member of +// the upscaler fragment shaders' push-constant blocks (cross-stage layout must +// agree). gl_VertexIndex 0..3 over a TRIANGLE_STRIP -> the rect; fragTexCoord +// spans [0,1] across that rect (= normalised output position). + +layout(push_constant) uniform PC { + vec4 ndc; // (x0, y0, x1, y1) destination rect in NDC +} pc; + +layout(location = 0) out vec2 fragTexCoord; + +void main() { + int xi = (gl_VertexIndex >> 1) & 1; + int yi = gl_VertexIndex & 1; + float x = xi == 1 ? pc.ndc.z : pc.ndc.x; + float y = yi == 1 ? pc.ndc.w : pc.ndc.y; + gl_Position = vec4(x, y, 0.0, 1.0); + fragTexCoord = vec2(float(xi), float(yi)); +} diff --git a/app/src/main/cpp/thirdparty/zerofg/README.DroidDeck.md b/app/src/main/cpp/thirdparty/zerofg/README.DroidDeck.md new file mode 100644 index 0000000000..0872e65ca9 --- /dev/null +++ b/app/src/main/cpp/thirdparty/zerofg/README.DroidDeck.md @@ -0,0 +1 @@ +ZeroFG is fetched by CMake from hy300leosquizz-ctrl/ZeroFG (the upstream repository) at pinned commit e6ca7ef9f9765db89847b6d8eed352e458f1a8bb. DroidDeck keeps ownership of presentation; the independent presenter is not used. License: Apache-2.0 OR GPL-2.0-or-later; see the fetched ZeroFG source tree for the license text. diff --git a/app/src/main/cpp/waylandcomp/CMakeLists.txt b/app/src/main/cpp/waylandcomp/CMakeLists.txt index 5bdc1e8385..2cd55b2761 100644 --- a/app/src/main/cpp/waylandcomp/CMakeLists.txt +++ b/app/src/main/cpp/waylandcomp/CMakeLists.txt @@ -42,6 +42,11 @@ add_library(droiddeckwayland SHARED src/hudframes.c src/hudframes_jni.c ) +option(DROIDDECK_FRAME_ACQUIRE_PROBE "Build opt-in signaled producer acquire protocol support" ON) +if (DROIDDECK_FRAME_ACQUIRE_PROBE) + target_sources(droiddeckwayland PRIVATE generated/droiddeck-frame-acquire-v1-protocol.c) + target_compile_definitions(droiddeckwayland PRIVATE DROIDDECK_FRAME_ACQUIRE_PROBE=1) +endif() target_compile_options(droiddeckwayland PRIVATE $<$:-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers>) target_include_directories(droiddeckwayland PRIVATE @@ -59,6 +64,7 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp message(STATUS "droiddeckwayland: frame-generation engines built in (LSFG Native, DD-FG Native)") target_sources(droiddeckwayland PRIVATE src/framegen_engine.cpp + src/framegen_zerofg.cpp ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_probe.cpp ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dll.cpp ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dxbc.cpp @@ -85,12 +91,12 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../framegen ) target_compile_options(droiddeckwayland PRIVATE - $<$:-std=c++17 -fvisibility=hidden>) + $<$:-std=c++20 -fvisibility=hidden>) target_compile_definitions(droiddeckwayland PRIVATE DDFG_UPSTREAM="${DDFG_UPSTREAM}" DDFG_CHAIN_HASH="${DDFG_CHAIN_HASH}" ) - target_link_libraries(droiddeckwayland dxbc atomic) + target_link_libraries(droiddeckwayland dxbc atomic zerofg::zerofg) else() message(STATUS "droiddeckwayland: frame-generation engines NOT built in (standalone build): stub") target_sources(droiddeckwayland PRIVATE src/framegen_engine_stub.c) diff --git a/app/src/main/cpp/waylandcomp/generated/droiddeck-frame-acquire-v1-protocol.c b/app/src/main/cpp/waylandcomp/generated/droiddeck-frame-acquire-v1-protocol.c new file mode 100644 index 0000000000..3d32474f56 --- /dev/null +++ b/app/src/main/cpp/waylandcomp/generated/droiddeck-frame-acquire-v1-protocol.c @@ -0,0 +1,35 @@ +/* Generated by wayland-scanner 1.22.0 */ + +#include +#include +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_buffer_interface; +extern const struct wl_interface wl_surface_interface; + +static const struct wl_interface *droiddeck_frame_acquire_v1_types[] = { + &wl_surface_interface, + &wl_buffer_interface, + NULL, +}; + +static const struct wl_message droiddeck_frame_acquire_v1_requests[] = { + { "destroy", "", droiddeck_frame_acquire_v1_types + 0 }, + { "set_acquire_fence", "ooh", droiddeck_frame_acquire_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface droiddeck_frame_acquire_v1_interface = { + "droiddeck_frame_acquire_v1", 1, + 2, droiddeck_frame_acquire_v1_requests, + 0, NULL, +}; diff --git a/app/src/main/cpp/waylandcomp/generated/droiddeck-frame-acquire-v1-server-protocol.h b/app/src/main/cpp/waylandcomp/generated/droiddeck-frame-acquire-v1-server-protocol.h new file mode 100644 index 0000000000..18f9466487 --- /dev/null +++ b/app/src/main/cpp/waylandcomp/generated/droiddeck-frame-acquire-v1-server-protocol.h @@ -0,0 +1,128 @@ +/* Generated by wayland-scanner 1.22.0 */ + +#ifndef DROIDDECK_FRAME_ACQUIRE_V1_SERVER_PROTOCOL_H +#define DROIDDECK_FRAME_ACQUIRE_V1_SERVER_PROTOCOL_H + +#include +#include +#include "wayland-server.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct wl_client; +struct wl_resource; + +/** + * @page page_droiddeck_frame_acquire_v1 The droiddeck_frame_acquire_v1 protocol + * @section page_ifaces_droiddeck_frame_acquire_v1 Interfaces + * - @subpage page_iface_droiddeck_frame_acquire_v1 - DroidDeck producer write completion for a single Wayland attachment + */ +struct droiddeck_frame_acquire_v1; +struct wl_buffer; +struct wl_surface; + +#ifndef DROIDDECK_FRAME_ACQUIRE_V1_INTERFACE +#define DROIDDECK_FRAME_ACQUIRE_V1_INTERFACE +/** + * @page page_iface_droiddeck_frame_acquire_v1 droiddeck_frame_acquire_v1 + * @section page_iface_droiddeck_frame_acquire_v1_desc Description + * + * Optional explicit acquire sideband independent of DRM syncobj and buffer + * allocation. Binding does not opt the client out of ordinary wl_buffer + * release or existing synchronization protocols. The server advertises it + * only when it implements all semantics for the selected display path. + * @section page_iface_droiddeck_frame_acquire_v1_api API + * See @ref iface_droiddeck_frame_acquire_v1. + */ +/** + * @defgroup iface_droiddeck_frame_acquire_v1 The droiddeck_frame_acquire_v1 interface + * + * Optional explicit acquire sideband independent of DRM syncobj and buffer + * allocation. Binding does not opt the client out of ordinary wl_buffer + * release or existing synchronization protocols. The server advertises it + * only when it implements all semantics for the selected display path. + */ +extern const struct wl_interface droiddeck_frame_acquire_v1_interface; +#endif + +#ifndef DROIDDECK_FRAME_ACQUIRE_V1_ERROR_ENUM +#define DROIDDECK_FRAME_ACQUIRE_V1_ERROR_ENUM +enum droiddeck_frame_acquire_v1_error { + /** + * not the same client's pending DMA-BUF attachment + */ + DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_ATTACHMENT = 0, + /** + * that attachment already has an acquire fence + */ + DROIDDECK_FRAME_ACQUIRE_V1_ERROR_DUPLICATE_FENCE = 1, + /** + * not a real successfully signaled Linux sync_file + */ + DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_FENCE = 2, + /** + * not the paired test peer + */ + DROIDDECK_FRAME_ACQUIRE_V1_ERROR_UNAUTHORIZED_PEER = 3, +}; +#endif /* DROIDDECK_FRAME_ACQUIRE_V1_ERROR_ENUM */ + +/** + * @ingroup iface_droiddeck_frame_acquire_v1 + * @struct droiddeck_frame_acquire_v1_interface + */ +struct droiddeck_frame_acquire_v1_interface { + /** + */ + void (*destroy)(struct wl_client *client, + struct wl_resource *resource); + /** + * set a one-shot kernel sync_file for the pending attachment + * + * After wl_surface.attach of a non-null buffer, and before its + * next wl_surface.commit, send the producer's final writer fence + * for that exact attachment. This outer probe requires that fence + * to have already successfully signaled. The fence must be a real + * Linux sync_file, not a dma-buf, eventfd, or Vulkan OPAQUE_FD. + * The server consumes its received descriptor once for that + * attachment; the caller closes its local FD after marshalling. + * + * The receiver validates the matching pending surface and buffer + * and validates the descriptor. A duplicate, invalid, pending or + * mismatched request is a protocol error; it is never downgraded + * to implicit sync. Another attach (even the same wl_buffer), + * detach, surface/resource loss or supersession makes the old + * proof inapplicable. Metadata-only commits may amend + * receiver-side still-pending state but cannot introduce or re-use + * a fence themselves. If no request was made, the receiver keeps + * its established safe path. If a valid fence has been accepted + * and later the layer is ineligible, the buffer must not be + * copied/read before that fence is satisfied or imported as the + * source dependency. Transport never implies readiness on missed + * deadlines and never changes release/retirement requirements. + * @param fence producer's native acquire sync_file + */ + void (*set_acquire_fence)(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *surface, + struct wl_resource *buffer, + int32_t fence); +}; + + +/** + * @ingroup iface_droiddeck_frame_acquire_v1 + */ +#define DROIDDECK_FRAME_ACQUIRE_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_droiddeck_frame_acquire_v1 + */ +#define DROIDDECK_FRAME_ACQUIRE_V1_SET_ACQUIRE_FENCE_SINCE_VERSION 1 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/app/src/main/cpp/waylandcomp/protocols/droiddeck-frame-acquire-v1.xml b/app/src/main/cpp/waylandcomp/protocols/droiddeck-frame-acquire-v1.xml new file mode 100644 index 0000000000..ae4c26535b --- /dev/null +++ b/app/src/main/cpp/waylandcomp/protocols/droiddeck-frame-acquire-v1.xml @@ -0,0 +1,45 @@ + + + + + Optional explicit acquire sideband independent of DRM syncobj and buffer + allocation. Binding does not opt the client out of ordinary wl_buffer + release or existing synchronization protocols. The server advertises it + only when it implements all semantics for the selected display path and + only to the test fixture's app-authorized Gamescope worker. + + + + + + + + + + + After wl_surface.attach of a non-null buffer, and before its next + wl_surface.commit, send the producer's final writer fence for that + exact attachment. This outer probe requires that fence to have already + successfully signaled. The fence must be a real Linux sync_file, not a + dma-buf, eventfd, or Vulkan OPAQUE_FD. The server consumes its received + descriptor once for that attachment; the caller closes its local FD + after marshalling. + + The receiver validates the matching pending surface and buffer and + validates the descriptor. A duplicate, invalid, pending or mismatched + request is a protocol error; it is never downgraded to implicit sync. Another attach (even the same + wl_buffer), detach, surface/resource loss or supersession makes the + old proof inapplicable. Metadata-only commits may amend receiver-side + still-pending state but cannot introduce or re-use a fence themselves. + If no request was made, the receiver keeps its established safe path. + If a valid fence has been accepted and later the layer is ineligible, + the buffer must not be copied/read before that fence is satisfied or + imported as the source dependency. Transport never implies readiness + on missed deadlines and never changes release/retirement requirements. + + + + + + + diff --git a/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c b/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c index c31915a45b..26618c67f6 100644 --- a/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c +++ b/app/src/main/cpp/waylandcomp/src/ahb_swapchain.c @@ -7,6 +7,7 @@ #include "droiddeck-ahb-v1-server-protocol.h" #include #include +#include #include #include #include @@ -53,6 +54,7 @@ static struct wl_list g_clients; static uint64_t g_next_id = 1; static struct wl_event_loop *g_loop; static unsigned g_stat_zero_copy; +static unsigned g_stat_producer_fence; static int g_export_failed_logged, g_import_failed_logged; static int g_advertised; static int g_mode_sent = -1; @@ -133,10 +135,10 @@ static void handle_released(uint64_t id, int fd) { if (fd >= 0) { struct droiddeck_dma_buf_sync_file imp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = fd}; int dmabuf_fd = droiddeck_dmabuf_fd(ab->b); - if (!ab->display && dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) { + if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &imp) == 0) { close(fd); } else { - if (!ab->display && !g_import_failed_logged) { + if (!g_import_failed_logged) { g_import_failed_logged = 1; droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_IMPORT_SYNC_FILE failed (%s): releases wait for the display's fence here instead", strerror(errno)); @@ -145,6 +147,12 @@ static void handle_released(uint64_t id, int fd) { if (poll(&p, 1, 0) > 0) { close(fd); } else { + if (ab->fence_src) { + struct sync_merge_data m = {.name = "droiddeck-release", .fd2 = fd}; + if (ioctl(ab->fence_fd, SYNC_IOC_MERGE, &m) == 0) { close(fd); fd = m.fence; } + wl_event_source_remove(ab->fence_src); + close(ab->fence_fd); + } ab->fence_fd = fd; ab->fence_src = wl_event_loop_add_fd(g_loop, fd, WL_EVENT_READABLE, on_fence_readable, ab); if (!ab->fence_src) { close(fd); ab->fence_fd = -1; } @@ -152,6 +160,7 @@ static void handle_released(uint64_t id, int fd) { } } } + if (ab->fence_src) return; send_deferred_release(ab); maybe_free(ab); } @@ -193,27 +202,47 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_ struct ahb_buf *ab = b ? *droiddeck_dmabuf_ahb_slot(b) : NULL; if (!ab) return -1; int dmabuf_fd = droiddeck_dmabuf_fd(b); - int acquire = -1; - struct droiddeck_dma_buf_sync_file exp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = -1}; - if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) { - acquire = exp.fd; - } else if (dmabuf_fd >= 0) { - if (!g_export_failed_logged) { - g_export_failed_logged = 1; - droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_EXPORT_SYNC_FILE failed (%s): waiting for each frame on the CPU instead", - strerror(errno)); + int acquire = droiddeck_surface_dup_acquire(s, b); + if (acquire == -2) return -1; +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + const int explicit_acquire = acquire >= 0; +#endif + if (acquire < 0) { + struct droiddeck_dma_buf_sync_file exp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = -1}; + if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) { + acquire = exp.fd; + } else { + if (!g_export_failed_logged) { + g_export_failed_logged = 1; + droiddeck_log("layer", "zero-copy: no acquire fence from the game's dma-buf (%s): %s", + dmabuf_fd >= 0 ? strerror(errno) : "no dma-buf fd", + draw ? "its frames are copied instead" : "it cannot be copied, so each frame is waited for on the CPU"); + } + if (dmabuf_fd >= 0) { + struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN}; + int r; + do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR); + } + if (draw) return -1; } - struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN}; - int r; - do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR); } int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h, draw, s ? droiddeck_surface_color(s) : NULL, ab->format); if (r < 0) return -1; if (r == 1) return 0; +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + static int explicit_logged; + if (explicit_acquire && !explicit_logged) { + explicit_logged = 1; + droiddeck_log("layer", "probe: SurfaceControl accepted a verified producer acquire fence"); + } +#endif if (!ab->on_layer) { ab->on_layer = 1; g_stat_zero_copy++; +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + if (explicit_acquire) g_stat_producer_fence++; +#endif g_last_zero_copy_ns = now_ns(); } if (s && g_announced != s) { @@ -253,6 +282,12 @@ unsigned ahb_swapchain_stats_take(void) { return n; } +unsigned ahb_swapchain_producer_fence_stats_take(void) { + unsigned n = g_stat_producer_fence; + g_stat_producer_fence = 0; + return n; +} + int ahb_swapchain_advertised(void) { return g_advertised; } uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b) { diff --git a/app/src/main/cpp/waylandcomp/src/ahb_swapchain.h b/app/src/main/cpp/waylandcomp/src/ahb_swapchain.h index 9002e6fc0a..95f1cd1418 100644 --- a/app/src/main/cpp/waylandcomp/src/ahb_swapchain.h +++ b/app/src/main/cpp/waylandcomp/src/ahb_swapchain.h @@ -20,7 +20,9 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_ int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *buffer, struct surface *s, int paced); void ahb_swapchain_surface_gone(struct surface *s); unsigned ahb_swapchain_stats_take(void); +unsigned ahb_swapchain_producer_fence_stats_take(void); int ahb_swapchain_advertised(void); +int droiddeck_surface_dup_acquire(const struct surface *s, const struct dmabuf_buffer *b); uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b); void ahb_swapchain_layer_released(void *token, int release_fd); diff --git a/app/src/main/cpp/waylandcomp/src/blend_pass.c b/app/src/main/cpp/waylandcomp/src/blend_pass.c index 9a4d48d0b8..5da97deaae 100644 --- a/app/src/main/cpp/waylandcomp/src/blend_pass.c +++ b/app/src/main/cpp/waylandcomp/src/blend_pass.c @@ -133,6 +133,24 @@ static void objects_destroy(void) { g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; } +void blendp_destroy(void) { + if (g_dev) { + for (int i = 0; i < NSRC; i++) src_release(i); + for (int i = 0; i < NDST; i++) dst_release(i); + for (int i = 0; i < NFMT; i++) { + if (g_out[i].pipe) g_vk.DestroyPipeline(g_dev, g_out[i].pipe, NULL); + if (g_out[i].rp) g_vk.DestroyRenderPass(g_dev, g_out[i].rp, NULL); + } + objects_destroy(); + } + memset(g_src, 0, sizeof(g_src)); + memset(g_dst, 0, sizeof(g_dst)); + memset(g_out, 0, sizeof(g_out)); + g_ready = 0; + g_frame = 1; + g_dev = VK_NULL_HANDLE; +} + static int objects_ensure(void) { if (g_ready) return g_ready == 1 ? 0 : -1; g_ready = -1; diff --git a/app/src/main/cpp/waylandcomp/src/blend_pass.h b/app/src/main/cpp/waylandcomp/src/blend_pass.h index d6f5a8fff2..9b3a56b879 100644 --- a/app/src/main/cpp/waylandcomp/src/blend_pass.h +++ b/app/src/main/cpp/waylandcomp/src/blend_pass.h @@ -4,6 +4,7 @@ #include void blendp_bind_device(VkDevice dev); +void blendp_destroy(void); void blendp_forget_image(VkImage img); void blendp_begin_frame(void); diff --git a/app/src/main/cpp/waylandcomp/src/cardboard.c b/app/src/main/cpp/waylandcomp/src/cardboard.c index 982c3bc47c..2c8c7120e1 100644 --- a/app/src/main/cpp/waylandcomp/src/cardboard.c +++ b/app/src/main/cpp/waylandcomp/src/cardboard.c @@ -311,6 +311,16 @@ static void objects_destroy(void) { g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE; } +void vkp_cardboard_destroy(void) { + if (g_dev) objects_destroy(); + g_dev = VK_NULL_HANDLE; + g_ready = 0; + memset(&g_t, 0, sizeof(g_t)); + memset(g_src, 0, sizeof(g_src)); + g_nsrc = 0; + memset(&g_mp, 0, sizeof(g_mp)); +} + static int objects_ensure(void) { if (g_ready) return g_ready == 1 ? 0 : -1; if (!g_dev || !g_vk.CreateGraphicsPipelines) goto fail; diff --git a/app/src/main/cpp/waylandcomp/src/cardboard.h b/app/src/main/cpp/waylandcomp/src/cardboard.h index 2950faec2f..c659661540 100644 --- a/app/src/main/cpp/waylandcomp/src/cardboard.h +++ b/app/src/main/cpp/waylandcomp/src/cardboard.h @@ -26,6 +26,7 @@ void vkp_cardboard_set_pose_file(const char *path); void vkp_cardboard_set_render_height(int height); void vkp_cardboard_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops); +void vkp_cardboard_destroy(void); int vkp_cardboard_active(void); int vkp_cardboard_source(void); int vkp_cardboard_pose_changed(void); diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index 3cb6e5746b..f17591cb16 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,14 @@ #include "linux-dmabuf-v1-server-protocol.h" #include "sc_layer.h" #include "ahb_swapchain.h" +#include "frame_acquire.h" +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE +#include "droiddeck-frame-acquire-v1-server-protocol.h" +#include +#include +#include +#include "frame_worker_peer.h" +#endif #include "display_buffers.h" #include "viewporter-server-protocol.h" #include "droiddeck-desktop-v1-server-protocol.h" @@ -210,6 +219,7 @@ struct surface { struct wl_list link; struct wl_resource *pending_buffer; + struct dd_frame_acquire pending_frame_acquire, frame_acquire; struct wl_listener pending_buffer_destroy; int pending_attach; int pending_src_set, pending_dst_set; @@ -237,10 +247,15 @@ struct surface { int drawn; int64_t next_release_ns; int releases_pending; + int release_pace_open; enum surface_role role; struct wl_resource *idle_buffer; struct wl_listener idle_buffer_destroy; + struct surface_state *waiting; + struct wl_event_source *waiting_source, *waiting_timer; + int waiting_fd; + int64_t waiting_since_ns; uint32_t *idle_px; int idle_w, idle_h; struct wl_resource *xdg_surface, *xdg_toplevel; @@ -288,6 +303,7 @@ static int g_scene_queues; static int g_tick_held; static int64_t g_hold_missed_ns; #define HOLD_RETRY_NS 1000000000LL +#define RELEASE_PACE_DEPTH 8 #define PACE_BUFFERS 32 static struct { unsigned ticks, ticks_late_2ms, renders, commit_renders, null_attaches, reattaches, presented, replaced, undrawn, distinct; @@ -327,6 +343,7 @@ volatile int g_hide_shell; volatile int g_zero_copy; static int g_zero_copy_paused; +static int g_mirror_capture; extern volatile int g_display_buffer_driver; extern void droiddeck_on_overlay_planes(int planes); static int g_overlay_planes_told = -1; @@ -371,6 +388,8 @@ static struct { unsigned copy_scenes; unsigned releases, releases_held; int64_t release_ns, release_max_ns; + unsigned commit_waits, commit_wait_limits; + int64_t commit_wait_ns, commit_wait_max_ns; } g_perf; static void schedule_render(void); @@ -548,13 +567,25 @@ static int on_release_timer(int fd, uint32_t mask, void *data) { return 0; } +static void describe(const struct surface *s, char *out, size_t size); + static void release_buffer(struct surface *s, struct wl_resource *buffer, int64_t since_ns, struct surface *holder) { /* No allocation or immediate-release fallback is allowed for a quarantined * DMA-BUF. Existing queued releases stay held; their timer is disarmed. */ if (buffer_release_blocked(buffer)) return; const int limit = g_fps_limit; const int64_t interval = limit > 0 ? 1000000000LL / limit : g_refresh_ns; - const int paced = !g_release_unpaced && interval > 0 && g_release_timer_fd >= 0; + int paced = !g_release_unpaced && interval > 0 && g_release_timer_fd >= 0; + if (paced && s->releases_pending >= RELEASE_PACE_DEPTH) { + paced = 0; + if (!s->release_pace_open) { + char name[160]; + describe(s, name, sizeof(name)); + droiddeck_log("pace", "%s keeps drawing into new buffers instead of waiting for releases: " + "its releases beyond %d are no longer held for the frame limit", name, RELEASE_PACE_DEPTH); + s->release_pace_open = 1; + } + } if (!paced && !holder) { send_buffer_release(buffer); perf_note_release(since_ns); return; } int64_t now = now_ns(); int64_t at = now; @@ -682,6 +713,8 @@ static struct surface *g_key_target; static struct surface *g_ime_click; static int g_input_pipe[2] = {-1, -1}; struct input_msg { int type; int p1; int p2; int p3; int p4; }; +static atomic_int g_zoom_request_percent = 100; +static atomic_int g_zoom_request_pending = 0; struct surface; static void constraints_surface_gone(struct surface *s); @@ -804,6 +837,7 @@ static void unmap_toplevel(struct surface *s) { } static void drop_dmabuf(struct surface *s, int paced) { + dd_frame_acquire_clear(&s->frame_acquire); if (s->dmabuf) { wl_list_remove(&s->dmabuf_destroy.link); if (buffer_shown_elsewhere(s->dmabuf, s)) { @@ -819,17 +853,72 @@ static void drop_dmabuf(struct surface *s, int paced) { static void on_dmabuf_destroyed(struct wl_listener *l, void *data) { struct surface *s = wl_container_of(l, s, dmabuf_destroy); + dd_frame_acquire_clear(&s->frame_acquire); wl_list_remove(&s->dmabuf_destroy.link); s->dmabuf = NULL; } static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) { struct surface *s = wl_container_of(l, s, pending_buffer_destroy); + dd_frame_acquire_clear(&s->pending_frame_acquire); wl_list_remove(&s->pending_buffer_destroy.link); wl_list_init(&s->pending_buffer_destroy.link); s->pending_buffer = NULL; } +struct surface_state { + struct dd_frame_acquire frame_acquire; + struct wl_resource *buffer; + struct wl_listener buffer_destroy; + int attach; + int src_set, dst_set, opaque_set; + float src[4]; + int dst[2], opaque[4]; + struct damage_list damage_buf, damage_local; + struct wl_list frames, feedback; +}; + +static void on_state_buffer_destroyed(struct wl_listener *l, void *data) { + struct surface_state *st = wl_container_of(l, st, buffer_destroy); + dd_frame_acquire_clear(&st->frame_acquire); + wl_list_remove(&st->buffer_destroy.link); + wl_list_init(&st->buffer_destroy.link); + st->buffer = NULL; + st->attach = 0; +} + +static void surface_state_take(struct surface *s, struct surface_state *st) { + st->attach = s->pending_attach; + st->frame_acquire = s->pending_frame_acquire; + s->pending_frame_acquire.fd_plus_one = 0; + st->buffer = s->pending_buffer; + wl_list_init(&st->buffer_destroy.link); + if (st->buffer) { + wl_list_remove(&s->pending_buffer_destroy.link); + wl_list_init(&s->pending_buffer_destroy.link); + st->buffer_destroy.notify = on_state_buffer_destroyed; + wl_resource_add_destroy_listener(st->buffer, &st->buffer_destroy); + } + s->pending_buffer = NULL; + s->pending_attach = 0; + st->src_set = s->pending_src_set; + memcpy(st->src, s->pending_src, sizeof(st->src)); + st->dst_set = s->pending_dst_set; + memcpy(st->dst, s->pending_dst, sizeof(st->dst)); + st->opaque_set = s->pending_opaque_set; + memcpy(st->opaque, s->pending_opaque, sizeof(st->opaque)); + s->pending_src_set = s->pending_dst_set = s->pending_opaque_set = 0; + st->damage_buf = s->pending_damage_buf; + st->damage_local = s->pending_damage_local; + s->pending_damage_buf.n = s->pending_damage_local.n = 0; + wl_list_init(&st->frames); + wl_list_insert_list(&st->frames, &s->pending_frames); + wl_list_init(&s->pending_frames); + wl_list_init(&st->feedback); + wl_list_insert_list(&st->feedback, &s->pending_feedback); + wl_list_init(&s->pending_feedback); +} + static void fire_frames(struct wl_list *frames) { struct wl_resource *cb, *tmp; uint32_t t; @@ -1114,6 +1203,7 @@ static void surface_attach(struct wl_client *c, struct wl_resource *r, if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link); wl_list_init(&s->pending_buffer_destroy.link); s->pending_buffer = buffer; + dd_frame_acquire_clear(&s->pending_frame_acquire); s->pending_attach = 1; if (buffer) { s->pending_buffer_destroy.notify = on_pending_buffer_destroyed; @@ -1184,6 +1274,14 @@ static uint32_t nominal_refresh_ns(void) { return (uint32_t)(1000000000000LL / (int64_t)mhz); } +static uint32_t feedback_refresh_ns(void) { + const int limit = g_fps_limit; + const uint32_t panel = nominal_refresh_ns(); + if (limit <= 0 || g_release_unpaced) return panel; + const uint32_t paced = (uint32_t)(1000000000LL / limit); + return paced > panel ? paced : panel; +} + static int64_t presented_ns(int64_t render_ns) { int64_t tick = g_tick_vsync_ns; int64_t refresh = (int64_t)nominal_refresh_ns(); @@ -1202,7 +1300,7 @@ static void feedback_present_all(struct wl_list *list, int64_t t) { uint32_t nsec = (uint32_t)(t % 1000000000LL); wl_resource_for_each_safe(fb, tmp, list) { wp_presentation_feedback_send_presented(fb, (uint32_t)(sec >> 32), (uint32_t)sec, nsec, - nominal_refresh_ns(), 0, 0, + feedback_refresh_ns(), 0, 0, WP_PRESENTATION_FEEDBACK_KIND_VSYNC); wl_resource_destroy(fb); g_pace.presented++; @@ -1339,35 +1437,23 @@ static void surface_drop_idle(struct surface *s) { if (buffer) send_buffer_release(buffer); } -static void surface_commit(struct wl_client *c, struct wl_resource *r) { - struct surface *s = wl_resource_get_user_data(r); +static void surface_state_apply(struct surface *s, struct surface_state *st) { struct surface *child; - if (s->xdg_toplevel && !s->toplevel_committed) { - s->toplevel_committed = 1; - send_toplevel_configure(s); + if (st->src_set) { + s->src_set = st->src[2] > 0; + memcpy(s->src, st->src, sizeof(s->src)); } + if (st->dst_set) { + s->dst_set = st->dst[0] > 0; + memcpy(s->dst, st->dst, sizeof(s->dst)); + } + if (st->opaque_set) memcpy(s->opaque, st->opaque, sizeof(s->opaque)); - if (s->pending_src_set) { - s->src_set = s->pending_src[2] > 0; - memcpy(s->src, s->pending_src, sizeof(s->src)); - s->pending_src_set = 0; - } - if (s->pending_dst_set) { - s->dst_set = s->pending_dst[0] > 0; - memcpy(s->dst, s->pending_dst, sizeof(s->dst)); - s->pending_dst_set = 0; - } - if (s->pending_opaque_set) { - memcpy(s->opaque, s->pending_opaque, sizeof(s->opaque)); - s->pending_opaque_set = 0; - } - - s->damage_buf = s->pending_damage_buf; - s->damage_local = s->pending_damage_local; - s->pending_damage_buf.n = s->pending_damage_local.n = 0; - if (s->pending_attach) { - struct wl_resource *buffer = s->pending_buffer; + s->damage_buf = st->damage_buf; + s->damage_local = st->damage_local; + if (st->attach) { + struct wl_resource *buffer = st->buffer; struct dmabuf_buffer *db = get_dmabuf(buffer); struct wl_shm_buffer *shm = buffer && !db ? wl_shm_buffer_get(buffer) : NULL; uint8_t pixel[4]; @@ -1376,15 +1462,14 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { if (!buffer) g_pace.null_attaches++; else if (!db) s->last_dmabuf = NULL; - if (buffer) { - wl_list_remove(&s->pending_buffer_destroy.link); - wl_list_init(&s->pending_buffer_destroy.link); - } - s->pending_buffer = NULL; - s->pending_attach = 0; + wl_list_remove(&st->buffer_destroy.link); + wl_list_init(&st->buffer_destroy.link); + st->buffer = NULL; + st->attach = 0; surface_drop_idle(s); buf_trace_attach(buffer); + dd_frame_acquire_clear(&s->frame_acquire); if (s->role == ROLE_CURSOR) { if (!buffer) { cursor_publish_hidden(); @@ -1396,6 +1481,8 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { if (buffer) surface_hold_idle(s, buffer); } else if (db) { take_dmabuf(s, db, buffer); + s->frame_acquire = st->frame_acquire; + st->frame_acquire.fd_plus_one = 0; } else if (shm) { drop_dmabuf(s, 1); take_shm(s, shm, buffer); @@ -1408,6 +1495,7 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { if (buffer) send_buffer_release(buffer); } } + dd_frame_acquire_clear(&st->frame_acquire); pending_releases_apply(s); wl_list_for_each(child, &s->children, child_link) { @@ -1418,10 +1506,10 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { } } - wl_list_insert_list(s->frames.prev, &s->pending_frames); - wl_list_init(&s->pending_frames); - wl_list_insert_list(s->feedback.prev, &s->pending_feedback); - wl_list_init(&s->pending_feedback); + wl_list_insert_list(s->frames.prev, &st->frames); + wl_list_init(&st->frames); + wl_list_insert_list(s->feedback.prev, &st->feedback); + wl_list_init(&st->feedback); constraints_surface_commit(s); droiddeck_color_commit(s->resource); @@ -1431,6 +1519,189 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) { } schedule_render(); } + +#define COMMIT_WAIT_LIMIT_MS 1000 + +static struct surface *g_zero_copy_shown, *g_unwaited; + +static int state_unfinished_fd(const struct surface *s, const struct surface_state *st, int *unwaited) { + struct dmabuf_buffer *db = st->attach ? get_dmabuf(st->buffer) : NULL; + int fd = -1; + *unwaited = 0; + for (int i = 0; db && fd < 0 && i < db->n_planes; i++) { + if (db->fd[i] < 0) continue; + struct pollfd p = {.fd = db->fd[i], .events = POLLIN}; + int r; + do { r = poll(&p, 1, 0); } while (r < 0 && errno == EINTR); + if (r == 0) fd = db->fd[i]; + } + if (fd >= 0 && s == g_zero_copy_shown && ahb_swapchain_has_ahb(db)) { + *unwaited = 1; + return -1; + } + return fd; +} + +static void settle_unwaited(void) { + struct surface *s = g_unwaited; + if (!s) return; + g_unwaited = NULL; + struct dmabuf_buffer *db = s->dmabuf_buf; + const int64_t deadline = now_ns() + 100000000LL; + for (int i = 0; db && i < db->n_planes; i++) { + if (db->fd[i] < 0) continue; + struct pollfd p = {.fd = db->fd[i], .events = POLLIN}; + for (;;) { + const int64_t left = deadline - now_ns(); + const int r = poll(&p, 1, left > 0 ? (int)((left + 999999) / 1000000) : 0); + if (r >= 0 || errno != EINTR || left <= 0) break; + } + } +} + +static void surface_state_discard(struct surface_state *st) { + dd_frame_acquire_clear(&st->frame_acquire); + struct wl_resource *cb, *tmp; + wl_list_remove(&st->buffer_destroy.link); + wl_resource_for_each_safe(cb, tmp, &st->frames) wl_resource_destroy(cb); + feedback_discard_all(&st->feedback); + free(st); +} + +static void surface_state_merge(struct surface_state *older, struct surface_state *newer) { + if (older->attach && !newer->attach) { + newer->attach = 1; + newer->buffer = older->buffer; + newer->frame_acquire = older->frame_acquire; + older->frame_acquire.fd_plus_one = 0; + wl_list_remove(&older->buffer_destroy.link); + wl_list_init(&older->buffer_destroy.link); + if (newer->buffer) { + newer->buffer_destroy.notify = on_state_buffer_destroyed; + wl_resource_add_destroy_listener(newer->buffer, &newer->buffer_destroy); + } + wl_list_insert_list(&newer->feedback, &older->feedback); + wl_list_init(&older->feedback); + } else if (older->attach) { + if (older->buffer && older->buffer != newer->buffer) send_buffer_release(older->buffer); + g_pace.replaced += feedback_discard_all(&older->feedback); + } + if (older->src_set && !newer->src_set) { + newer->src_set = 1; + memcpy(newer->src, older->src, sizeof(newer->src)); + } + if (older->dst_set && !newer->dst_set) { + newer->dst_set = 1; + memcpy(newer->dst, older->dst, sizeof(newer->dst)); + } + if (older->opaque_set && !newer->opaque_set) { + newer->opaque_set = 1; + memcpy(newer->opaque, older->opaque, sizeof(newer->opaque)); + } + for (int i = 0; i < older->damage_buf.n; i++) + note_damage(&newer->damage_buf, older->damage_buf.r[i][0], older->damage_buf.r[i][1], + older->damage_buf.r[i][2], older->damage_buf.r[i][3]); + for (int i = 0; i < older->damage_local.n; i++) + note_damage(&newer->damage_local, older->damage_local.r[i][0], older->damage_local.r[i][1], + older->damage_local.r[i][2], older->damage_local.r[i][3]); + wl_list_insert_list(&newer->frames, &older->frames); + wl_list_init(&older->frames); + surface_state_discard(older); +} + +static void surface_wait_stop(struct surface *s) { + if (s->waiting_source) wl_event_source_remove(s->waiting_source); + if (s->waiting_timer) wl_event_source_remove(s->waiting_timer); + if (s->waiting_fd >= 0) close(s->waiting_fd); + s->waiting_source = s->waiting_timer = NULL; + s->waiting_fd = -1; +} + +static void surface_wait_end(struct surface *s, int over_limit) { + struct surface_state *st = s->waiting; + if (!st) return; + surface_wait_stop(s); + s->waiting = NULL; + const int64_t waited = now_ns() - s->waiting_since_ns; + g_perf.commit_waits++; + g_perf.commit_wait_ns += waited; + if (waited > g_perf.commit_wait_max_ns) g_perf.commit_wait_max_ns = waited; + if (over_limit) g_perf.commit_wait_limits++; + if (st->attach && g_unwaited == s) g_unwaited = NULL; + surface_state_apply(s, st); + free(st); +} + +static int on_commit_ready(int fd, uint32_t mask, void *data) { + surface_wait_end(data, 0); + return 0; +} + +static int on_commit_wait_limit(void *data) { + static int said; + if (!said) { + said = 1; + droiddeck_log("compositor", "a client's GPU writes ran past %d ms; its frame is shown as it is", COMMIT_WAIT_LIMIT_MS); + } + surface_wait_end(data, 1); + return 0; +} + +static int surface_wait_start(struct surface *s, int fd, int timeout_ms) { + struct wl_event_loop *loop = wl_display_get_event_loop(g_display); + s->waiting_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (s->waiting_fd >= 0) { + s->waiting_source = wl_event_loop_add_fd(loop, s->waiting_fd, WL_EVENT_READABLE, on_commit_ready, s); + s->waiting_timer = wl_event_loop_add_timer(loop, on_commit_wait_limit, s); + } + if (!s->waiting_source || !s->waiting_timer || + wl_event_source_timer_update(s->waiting_timer, timeout_ms) != 0) { + surface_wait_stop(s); + return -1; + } + return 0; +} + +static void surface_commit(struct wl_client *c, struct wl_resource *r) { + struct surface *s = wl_resource_get_user_data(r); + + if (s->xdg_toplevel && !s->toplevel_committed) { + s->toplevel_committed = 1; + send_toplevel_configure(s); + } + struct surface_state *st = calloc(1, sizeof(*st)); + if (!st) { + struct surface_state now; + surface_state_take(s, &now); + surface_state_apply(s, &now); + return; + } + surface_state_take(s, st); + const int was_waiting = s->waiting != NULL; + if (was_waiting) { + surface_wait_stop(s); + surface_state_merge(s->waiting, st); + s->waiting = NULL; + } + int unwaited; + const int fd = state_unfinished_fd(s, st, &unwaited); + if (!was_waiting) s->waiting_since_ns = now_ns(); + const int64_t left_ms = COMMIT_WAIT_LIMIT_MS - (now_ns() - s->waiting_since_ns) / 1000000; + if (fd >= 0 && left_ms > 0 && surface_wait_start(s, fd, (int)left_ms) == 0) { + s->waiting = st; + return; + } + const int attaches = st->attach; + if (was_waiting) { + s->waiting = st; + surface_wait_end(s, fd >= 0 && left_ms <= 0); + } else { + surface_state_apply(s, st); + free(st); + } + if (unwaited) g_unwaited = s; + else if (attaches && g_unwaited == s) g_unwaited = NULL; +} static void surface_set_buffer_transform(struct wl_client *c, struct wl_resource *r, int32_t t) {} static void surface_set_buffer_scale(struct wl_client *c, struct wl_resource *r, int32_t s) {} static void surface_damage_buffer(struct wl_client *c, struct wl_resource *r, @@ -1454,6 +1725,210 @@ static const struct wl_surface_interface surface_impl = { .offset = surface_offset, }; +int droiddeck_surface_dup_acquire(const struct surface *s, const struct dmabuf_buffer *b) { + return s && s->dmabuf && s->dmabuf_buf == b ? dd_frame_acquire_dup(&s->frame_acquire) : -1; +} + +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE +// Private signed fixture: only the app-owned worker decision may issue a grant. +static pthread_mutex_t frame_worker_lock = PTHREAD_MUTEX_INITIALIZER; +static char frame_worker_file[PATH_MAX]; +static struct dd_worker_grant frame_worker_grant; +static int frame_worker_pidfd = -1; +static bool frame_worker_map_reported; + +static enum dd_worker_stat_result frame_worker_starttime(pid_t pid, uint64_t *out) { + char proc[64], line[4096]; + snprintf(proc, sizeof(proc), "/proc/%d/stat", pid); + FILE *f = fopen(proc, "re"); + if (!f) return dd_worker_open_failure(errno); + // Proc writes one bounded line; truncation is a read failure, not invisibility. + bool read = fgets(line, sizeof(line), f) != NULL && strchr(line, '\n') != NULL; + fclose(f); + return read ? dd_worker_parse_start(line, out) : DD_WORKER_STAT_READ; +} + +void droiddeck_frame_worker_revoke(int owner, int pid) { + pthread_mutex_lock(&frame_worker_lock); + if (frame_worker_grant.owner == (uint32_t)owner && + (!pid || frame_worker_grant.pid == (uint32_t)pid)) { + if (frame_worker_pidfd >= 0) close(frame_worker_pidfd); + frame_worker_pidfd = -1; + frame_worker_grant = (struct dd_worker_grant){0}; + } + pthread_mutex_unlock(&frame_worker_lock); +} + +int droiddeck_frame_worker_grant(int owner, pid_t pid, uint64_t expires, const char *path, + uint64_t expected_dev, uint64_t expected_ino, uint64_t receipt) { + struct stat st; + if (owner <= 0 || pid <= 1 || !receipt || !path || + strlen(path) >= sizeof(frame_worker_file) || lstat(path, &st) < 0 || !S_ISREG(st.st_mode) || + (uint64_t)st.st_dev != expected_dev || (uint64_t)st.st_ino != expected_ino || + st.st_uid != getuid()) { + droiddeck_log("probe", "worker_admission=NATIVE_FILE"); + return 0; + } + int pidfd = syscall(__NR_pidfd_open, pid, 0); + if (pidfd < 0) { + droiddeck_log("probe", "worker_admission=NATIVE_PIDFD"); + return 0; // No fallback to a recyclable PID. + } + struct pollfd alive = {.fd = pidfd, .events = POLLIN}; + uint64_t raw_start = 0; + enum dd_worker_stat_result stat = frame_worker_starttime(pid, &raw_start); + switch (stat) { + case DD_WORKER_STAT_OK: + if (raw_start != receipt) droiddeck_log("probe", "worker_admission=NATIVE_STAT_MISMATCH"); + break; + case DD_WORKER_STAT_DENIED: droiddeck_log("probe", "worker_admission=NATIVE_STAT_OPEN_DENIED"); break; + case DD_WORKER_STAT_HIDDEN: droiddeck_log("probe", "worker_admission=NATIVE_STAT_OPEN_HIDDEN"); break; + case DD_WORKER_STAT_OPEN: droiddeck_log("probe", "worker_admission=NATIVE_STAT_OPEN_OTHER"); break; + case DD_WORKER_STAT_READ: droiddeck_log("probe", "worker_admission=NATIVE_STAT_READ"); break; + case DD_WORKER_STAT_PARSE: droiddeck_log("probe", "worker_admission=NATIVE_STAT_PARSE"); break; + case DD_WORKER_STAT_ZERO: droiddeck_log("probe", "worker_admission=NATIVE_STAT_ZERO"); break; + } + if (!dd_worker_receipt_allows_reserve(stat, raw_start, receipt)) { close(pidfd); return 0; } + if (poll(&alive, 1, 0) != 0) { + droiddeck_log("probe", "worker_admission=NATIVE_PIDFD_NOT_LIVE"); + close(pidfd); + return 0; + } + pthread_mutex_lock(&frame_worker_lock); + if (frame_worker_pidfd < 0) { + strcpy(frame_worker_file, path); + frame_worker_grant = (struct dd_worker_grant){ + .owner = owner, .uid = getuid(), .pid = pid, .start_ticks = receipt, .expires = expires, + .dev_major = major(st.st_dev), .dev_minor = minor(st.st_dev), .ino = st.st_ino, + .canonical_file = frame_worker_file, .app_launch_verified = true, .final_go = true, + }; + frame_worker_map_reported = false; + frame_worker_pidfd = pidfd; + pidfd = -1; + } + pthread_mutex_unlock(&frame_worker_lock); + if (pidfd >= 0) { + droiddeck_log("probe", "worker_admission=NATIVE_ALREADY_RESERVED"); + close(pidfd); + return 0; + } + droiddeck_log("probe", "frame acquire reserved one app-verified worker"); + return 1; +} + +static bool frame_worker_verified_exec_locked(const struct dd_worker_grant *g, uint64_t now) { + char proc[64], line[PATH_MAX + 128]; + const char *failure = "worker_admission=MAP_STARTTIME"; + uint64_t raw_start = 0; + if (frame_worker_starttime(g->pid, &raw_start) != DD_WORKER_STAT_OK || raw_start != g->start_ticks) + goto reject; + snprintf(proc, sizeof(proc), "/proc/%u/maps", g->pid); + FILE *f = fopen(proc, "re"); + failure = "worker_admission=MAP_OPEN"; + if (!f) goto reject; + bool matched = false; + size_t budget = 2 * 1024 * 1024; + while (budget && fgets(line, sizeof(line), f)) { + size_t n = strlen(line); + if (!n || line[n - 1] != '\n' || n > budget) break; + budget -= n; + if (dd_worker_grant_matches(g, g->owner, g->uid, g->pid, raw_start, now, line)) { + matched = true; + break; + } + } + fclose(f); + if (matched) return true; + failure = "worker_admission=MAP_IDENTITY"; +reject: + if (!frame_worker_map_reported) { + frame_worker_map_reported = true; + droiddeck_log("probe", "%s", failure); + } + return false; +} + +static int frame_acquire_peer_allowed(const struct wl_client *client, bool verify_exec, bool bind) { + pid_t pid = 0; + uid_t uid = (uid_t)-1; + wl_client_get_credentials(client, &pid, &uid, NULL); + struct timespec t; + if (clock_gettime(CLOCK_BOOTTIME, &t) < 0) return 0; + uint64_t now = (uint64_t)t.tv_sec * 1000 + (uint64_t)t.tv_nsec / 1000000; + pthread_mutex_lock(&frame_worker_lock); + const struct dd_worker_grant *g = &frame_worker_grant; + struct pollfd alive = {.fd = frame_worker_pidfd, .events = POLLIN}; + bool allowed = frame_worker_pidfd >= 0 && uid == getuid() && pid > 1 && + g->pid == (uint32_t)pid && g->uid == uid && now < g->expires && + poll(&alive, 1, 0) == 0 && (!verify_exec || + (frame_worker_verified_exec_locked(g, now) && poll(&alive, 1, 0) == 0)); + // The short startup authorization may not be renewed by registry enumeration. + // Only an authenticated bind activates the grant for the lifetime of this live, + // unreplaced worker; session teardown revokes it independently of process exit. + if (allowed && bind) frame_worker_grant.expires = UINT64_MAX; + pthread_mutex_unlock(&frame_worker_lock); + return allowed; +} + +static bool frame_acquire_global_filter(const struct wl_client *client, const struct wl_global *global, void *data) { + return wl_global_get_interface(global) != &droiddeck_frame_acquire_v1_interface || + frame_acquire_peer_allowed(client, true, false); +} + +static void frame_acquire_destroy(struct wl_client *client, struct wl_resource *resource) { + wl_resource_destroy(resource); +} + +static void frame_acquire_set(struct wl_client *client, struct wl_resource *resource, + struct wl_resource *surface, struct wl_resource *buffer, int32_t fd) { + if (!frame_acquire_peer_allowed(client, false, false)) { + close(fd); + wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_UNAUTHORIZED_PEER, + "paired capture peer is not authorized"); + return; + } + struct surface *s = NULL; + if (surface && buffer && wl_resource_get_client(surface) == client && + wl_resource_get_client(buffer) == client && + wl_resource_instance_of(surface, &wl_surface_interface, &surface_impl) && + get_dmabuf(buffer)) + s = wl_resource_get_user_data(surface); + if (!s || !s->pending_attach || s->pending_buffer != buffer) { + close(fd); + wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_ATTACHMENT, + "fence does not match pending DMA-BUF attachment"); + return; + } + enum dd_frame_acquire_result result = dd_frame_acquire_set(&s->pending_frame_acquire, fd); + if (result == DD_ACQUIRE_DUPLICATE) + wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_DUPLICATE_FENCE, + "pending attachment already has a fence"); + else if (result == DD_ACQUIRE_INVALID) + wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_FENCE, + "expected an already signaled Linux sync_file"); +} + +static const struct droiddeck_frame_acquire_v1_interface frame_acquire_impl = { + .destroy = frame_acquire_destroy, + .set_acquire_fence = frame_acquire_set, +}; + +static void bind_frame_acquire(struct wl_client *client, void *data, uint32_t version, uint32_t id) { + if (!frame_acquire_peer_allowed(client, true, true)) { + wl_client_post_implementation_error(client, "paired capture peer is not authorized"); + return; + } + struct wl_resource *resource = + wl_resource_create(client, &droiddeck_frame_acquire_v1_interface, 1, id); + if (!resource) { + wl_client_post_no_memory(client); + return; + } + wl_resource_set_implementation(resource, &frame_acquire_impl, NULL, NULL); + droiddeck_log("probe", "frame acquire bound to app-issued worker and exact executable map"); +} +#endif + static void detach_from_parent(struct surface *s) { if (!s->parent) return; wl_list_remove(&s->child_link); @@ -1463,6 +1938,7 @@ static void detach_from_parent(struct surface *s) { static void surface_resource_destroy(struct wl_resource *r) { struct surface *s = wl_resource_get_user_data(r); + dd_frame_acquire_clear(&s->pending_frame_acquire); struct surface *child, *tmp; struct wl_resource *cb, *cbtmp; @@ -1492,6 +1968,13 @@ static void surface_resource_destroy(struct wl_resource *r) { child->parent = NULL; } if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link); + if (s->waiting) { + surface_wait_stop(s); + surface_state_discard(s->waiting); + s->waiting = NULL; + } + if (g_zero_copy_shown == s) g_zero_copy_shown = NULL; + if (g_unwaited == s) g_unwaited = NULL; pending_releases_forget_surface(s); drop_dmabuf(s, 0); ahb_swapchain_surface_gone(s); @@ -1555,6 +2038,7 @@ static void compositor_create_surface(struct wl_client *c, struct wl_resource *r wl_list_init(&s->child_link); wl_list_init(&s->toplevel_link); wl_list_init(&s->pending_buffer_destroy.link); + s->waiting_fd = -1; wl_list_init(&s->idle_buffer_destroy.link); wl_list_insert(&g_surfaces, &s->link); wl_resource_set_implementation(s->resource, &surface_impl, s, surface_resource_destroy); @@ -2019,6 +2503,69 @@ static void bind_output(struct wl_client *c, void *data, uint32_t ver, uint32_t struct draw_list { struct vkp_draw *d; int n, cap; }; +#define ZERO_COPY_FALLBACK_SIGNATURES 32u +enum zero_copy_fallback_reason { + ZERO_COPY_NO_SURFACE_BUFFER = 1, + ZERO_COPY_NO_GRALLOC_AHB = 2, + ZERO_COPY_AHB_PRESENT_FAILED = 3 +}; +struct zero_copy_fallback_signature { + uint32_t reason, format, stride, offset; + int width, height; + uint64_t modifier; +}; +static struct zero_copy_fallback_signature g_zero_copy_fallbacks[ZERO_COPY_FALLBACK_SIGNATURES]; +static uint32_t g_zero_copy_fallback_count; +static int g_zero_copy_fallback_limit_logged; + +static int zero_copy_fallback_should_log(const struct dmabuf_buffer *b, uint32_t reason) { + const struct zero_copy_fallback_signature key = { + .reason = reason, .format = b ? b->format : 0, + .stride = b && b->n_planes ? b->stride[0] : 0, + .offset = b && b->n_planes ? b->offset[0] : 0, + .width = b ? b->width : 0, .height = b ? b->height : 0, + .modifier = b ? b->modifier : 0}; + for (uint32_t i = 0; i < g_zero_copy_fallback_count; i++) { + const struct zero_copy_fallback_signature *seen = &g_zero_copy_fallbacks[i]; + if (seen->reason == key.reason && seen->format == key.format && seen->stride == key.stride && + seen->offset == key.offset && seen->width == key.width && seen->height == key.height && + seen->modifier == key.modifier) + return 0; + } + if (g_zero_copy_fallback_count >= ZERO_COPY_FALLBACK_SIGNATURES) { + if (!g_zero_copy_fallback_limit_logged) { + g_zero_copy_fallback_limit_logged = 1; + droiddeck_log("layer", "zero-copy: further fallback diagnostics suppressed after %u distinct buffer signatures", + ZERO_COPY_FALLBACK_SIGNATURES); + } + return 0; + } + g_zero_copy_fallbacks[g_zero_copy_fallback_count++] = key; + return 1; +} + +static void note_zero_copy_fallback(struct surface *s, const struct dmabuf_buffer *b, uint32_t reason, + int scene_w, int scene_h, int present_result) { + if (!zero_copy_fallback_should_log(b, reason)) return; + char name[160] = "unknown surface"; + if (s) describe(s, name, sizeof(name)); + if (reason == ZERO_COPY_NO_SURFACE_BUFFER) { + droiddeck_log("layer", "zero-copy: layer candidate %s has no associated Wayland surface buffer; using the layer-copy path", + name); + } else { + droiddeck_log("layer", "zero-copy: %s buffer %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx %s; " + "scene %dx%d will use the layer-copy path (direct-present result %d)", + name, b->format & 0xff, (b->format >> 8) & 0xff, (b->format >> 16) & 0xff, + (b->format >> 24) & 0xff, b->width, b->height, + b->n_planes ? b->stride[0] : 0, b->n_planes ? b->offset[0] : 0, + (unsigned long long)b->modifier, + reason == ZERO_COPY_NO_GRALLOC_AHB + ? "has no registered gralloc AHardwareBuffer" + : "has a registered gralloc AHardwareBuffer but direct presentation failed", + scene_w, scene_h, present_result); + } +} + static int add_cursor(struct draw_list *dl, int scene_w); static struct vkp_image *surface_image(struct surface *s) { @@ -2138,17 +2685,53 @@ static int black_fill_below(const struct draw_list *dl, int n) { return 1; } +#define LAYER_CANDIDATE_DIAGNOSTICS 32u +static unsigned g_layer_candidate_diag_count; +static int g_layer_candidate_diag_limit; + +static void note_layer_candidate_skip(const struct vkp_draw *d, int index, int reason, + int scene_w, int scene_h) { + static int seen[LAYER_CANDIDATE_DIAGNOSTICS][8]; + const int key[8] = {index, reason, scene_w, scene_h, d->dx, d->dy, d->dw, d->dh}; + for (unsigned i = 0; i < g_layer_candidate_diag_count; i++) + if (!memcmp(seen[i], key, sizeof(key))) return; + if (g_layer_candidate_diag_count >= LAYER_CANDIDATE_DIAGNOSTICS) { + if (!g_layer_candidate_diag_limit++) droiddeck_log("layer", "zero-copy: further candidate-rejection details suppressed after %u signatures", + LAYER_CANDIDATE_DIAGNOSTICS); + return; + } + memcpy(seen[g_layer_candidate_diag_count++], key, sizeof(key)); + const char *why = reason == 1 ? "translucent draw" : + reason == 2 ? "image is not DMA-BUF" : + reason == 3 ? "source rectangle is outside/invalid" : + reason == 4 ? "draw rectangle is outside scene or invalid" : + "not fullscreen and no black backing below"; + droiddeck_log("layer", "zero-copy: candidate draw %d rejected: %s; scene %dx%d, dst %dx%d at %d,%d, src %.2f,%.2f %.2fx%.2f, image %dx%d", + index, why, scene_w, scene_h, d->dw, d->dh, d->dx, d->dy, + d->sx, d->sy, d->sw, d->sh, vkp_image_width(d->img), vkp_image_height(d->img)); +} + static int layer_candidate(const struct draw_list *dl, int scene_w, int scene_h) { for (int i = dl->n - 1; i >= 0 && i >= dl->n - 2; i--) { const struct vkp_draw *d = &dl->d[i]; - if (d->blend) continue; - if (!vkp_image_is_dmabuf(d->img)) continue; + if (d->blend) { note_layer_candidate_skip(d, i, 1, scene_w, scene_h); continue; } + if (!vkp_image_is_dmabuf(d->img)) { note_layer_candidate_skip(d, i, 2, scene_w, scene_h); continue; } if (d->sx < 0 || d->sy < 0 || d->sw < 1.0f || d->sh < 1.0f || d->sx + d->sw >= vkp_image_width(d->img) + 1.0f || - d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) continue; + d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) { + note_layer_candidate_skip(d, i, 3, scene_w, scene_h); + continue; + } if (d->dx == 0 && d->dy == 0 && d->dw == scene_w && d->dh == scene_h) return i; if (d->dx < 0 || d->dy < 0 || d->dw <= 0 || d->dh <= 0 || d->dx + d->dw > scene_w || - d->dy + d->dh > scene_h || !black_fill_below(dl, i)) continue; + d->dy + d->dh > scene_h) { + note_layer_candidate_skip(d, i, 4, scene_w, scene_h); + continue; + } + if (!black_fill_below(dl, i)) { + note_layer_candidate_skip(d, i, 5, scene_w, scene_h); + continue; + } return i; } return -1; @@ -2169,6 +2752,56 @@ static void note_copy_scene(const struct draw_list *dl, int scene_w, int scene_h vkp_image_is_dmabuf(t->img) ? "GPU" : "memory", t->blend ? ", translucent" : ""); } +static struct surface *surface_for_image(const struct vkp_image *img); + +static void note_layer_candidate_rejected(const struct draw_list *dl, int scene_w, int scene_h) { + static int seen[32][14]; + static unsigned seen_count; + static int limit_logged; + static time_t window_start; + struct timespec now_ts; + const struct vkp_draw *a = dl->n > 0 ? &dl->d[dl->n - 1] : NULL; + const struct vkp_draw *b = dl->n > 1 ? &dl->d[dl->n - 2] : NULL; + struct surface *sa = a ? surface_for_image(a->img) : NULL; + struct surface *sb = b ? surface_for_image(b->img) : NULL; + const int signature[14] = { + dl->n, scene_w, scene_h, + a ? a->dw : 0, a ? a->dh : 0, + a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0, + a ? vkp_image_is_dmabuf(a->img) : 0, a ? a->blend : 0, sa && sa->dmabuf_buf ? 1 : 0, + b ? b->dw : 0, b ? b->dh : 0, b ? vkp_image_is_dmabuf(b->img) : 0, sb && sb->dmabuf_buf ? 1 : 0 + }; + clock_gettime(CLOCK_MONOTONIC, &now_ts); + if (!window_start || now_ts.tv_sec - window_start >= 30) { + seen_count = 0; + limit_logged = 0; + window_start = now_ts.tv_sec; + } + for (unsigned i = 0; i < seen_count; i++) + if (!memcmp(signature, seen[i], sizeof(signature))) return; + if (seen_count >= 32) { + if (!limit_logged++) droiddeck_log("layer", "zero-copy: further fullscreen-candidate rejection details suppressed after 32 signatures in 30 seconds"); + return; + } + memcpy(seen[seen_count++], signature, sizeof(signature)); + char below[48]; + if (b) + snprintf(below, sizeof(below), "%s %dx%d", + vkp_image_is_dmabuf(b->img) ? "DMA-BUF" : "non-DMA-BUF", b->dw, b->dh); + else + snprintf(below, sizeof(below), "none"); + droiddeck_log("layer", "zero-copy: no eligible fullscreen DMA-BUF layer candidate: scene %dx%d, %d draws; " + "top draw %dx%d at %d,%d image %dx%d %s%s surface=%s dmabuf=%s; " + "draw below %s", + scene_w, scene_h, dl->n, a ? a->dw : 0, a ? a->dh : 0, a ? a->dx : 0, a ? a->dy : 0, + a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0, + a && vkp_image_is_dmabuf(a->img) ? "DMA-BUF" : "non-DMA-BUF", + a && a->blend ? " blended" : "", + sa ? "associated" : "unassociated", + sa && sa->dmabuf_buf ? "yes" : "no", + below); +} + static struct surface *surface_for_image(const struct vkp_image *img) { struct surface *s; wl_list_for_each(s, &g_surfaces, link) @@ -2177,16 +2810,56 @@ static struct surface *surface_for_image(const struct vkp_image *img) { } static struct surface *ahb_layer_only_candidate(int scene_w, int scene_h) { + static struct { + const struct surface *surface; + int reason, scene_w, scene_h, w, h, buf_w, buf_h, x, y, src_set, dst_set, children; + } seen[32]; + static unsigned seen_count; + static int limit_logged; struct surface *s; - int w, h; + int w = 0, h = 0, reason = 0; if (wl_list_empty(&g_toplevels)) return NULL; s = wl_container_of(g_toplevels.prev, s, toplevel_link); - if (!s->dmabuf_buf || s->dmabuf_buf->img || !ahb_swapchain_has_ahb(s->dmabuf_buf)) return NULL; - if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) return NULL; - if (!wl_list_empty(&s->children)) return NULL; - if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) return NULL; + if (!s->dmabuf_buf) reason = 1; + else if (s->dmabuf_buf->img) reason = 2; + else if (!ahb_swapchain_has_ahb(s->dmabuf_buf)) reason = 3; + else if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) reason = 4; + else if (!wl_list_empty(&s->children)) reason = 5; + else if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) reason = 6; surface_size(s, &w, &h); - if (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h) return NULL; + if (!reason && (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h)) reason = 7; + if (reason) { + int found = 0; + for (unsigned i = 0; i < seen_count; i++) { + if (seen[i].surface == s && seen[i].reason == reason && seen[i].scene_w == scene_w && + seen[i].scene_h == scene_h && seen[i].w == w && seen[i].h == h && + seen[i].buf_w == s->buf_w && seen[i].buf_h == s->buf_h && seen[i].x == s->x && + seen[i].y == s->y && seen[i].src_set == s->src_set && seen[i].dst_set == s->dst_set && + seen[i].children == !wl_list_empty(&s->children)) { found = 1; break; } + } + if (!found && seen_count < 32) { + seen[seen_count].surface = s; seen[seen_count].reason = reason; + seen[seen_count].scene_w = scene_w; seen[seen_count].scene_h = scene_h; + seen[seen_count].w = w; seen[seen_count].h = h; seen[seen_count].buf_w = s->buf_w; seen[seen_count].buf_h = s->buf_h; + seen[seen_count].x = s->x; seen[seen_count].y = s->y; seen[seen_count].src_set = s->src_set; + seen[seen_count].dst_set = s->dst_set; seen[seen_count].children = !wl_list_empty(&s->children); + seen_count++; + const char *why = reason == 1 ? "no DMA-BUF buffer" : + reason == 2 ? "buffer is already importable by Vulkan" : + reason == 3 ? "no registered gralloc AHardwareBuffer" : + reason == 4 ? "surface is positioned/cropped/scaled" : + reason == 5 ? "surface has child surfaces" : + reason == 6 ? "hidden shell surface" : "surface or buffer dimensions differ from scene"; + char name[160]; describe(s, name, sizeof(name)); + droiddeck_log("layer", "zero-copy: AHardwareBuffer-only candidate rejected: %s; %s, scene %dx%d, surface %dx%d at %d,%d, buffer %dx%d, crop=%d destination=%d children=%d", + why, name, scene_w, scene_h, w, h, s->x, s->y, s->buf_w, s->buf_h, + s->src_set, s->dst_set, !wl_list_empty(&s->children)); + } else if (!found && !limit_logged) { + limit_logged = 1; + droiddeck_log("layer", "zero-copy: further AHardwareBuffer-only candidate diagnostics suppressed after 32 signatures"); + } + return NULL; + } return s; } @@ -2289,7 +2962,7 @@ static void hdr_note_route(int route, const struct hdr_scene *hs) { static int said = -1, said_tm = -1; static const char *said_why; const int tm = route != 0 && !droiddeck_color_output(); - if (route == said && tm == said_tm && (route != 1 || hs->why == said_why)) return; + if (route == said && tm == said_tm && (route < 1 || route > 2 || hs->why == said_why)) return; int was = said; said = route; said_why = hs->why; said_tm = tm; char name[160] = "the HDR game"; @@ -2306,6 +2979,10 @@ static void hdr_note_route(int route, const struct hdr_scene *hs) { "BT2020_PQ", name, hs->why ? hs->why : "?", droiddeck_color_sdr_white()); break; case 2: + if (g_mirror_capture) { + droiddeck_log("color", "Mirror: %s is composed through the screen swapchain", name); + break; + } if (tm) droiddeck_log("color", "HDR with frame generation for %s, HDR output switched off: the scene is tone-mapped to " "SDR and presented through an SDR screen swapchain", name); @@ -2478,7 +3155,13 @@ static int64_t scene_next_due(int64_t now, int64_t due, int limit) { static void render_scene(void) { g_scene_due_ns = scene_next_due(now_ns(), g_scene_due_ns, g_fps_limit); - if (atomic_load(&g_stream_on)) { g_dirty_since_ns = 0; render_stream(); return; } + if (atomic_load(&g_stream_on)) { + g_dirty_since_ns = 0; + g_zero_copy_shown = NULL; + settle_unwaited(); + render_stream(); + return; + } struct draw_list dl = {0}; struct surface *s; int w, h; @@ -2520,6 +3203,11 @@ static void render_scene(void) { const int cardboard = vkp_cardboard_active(); struct hdr_scene hs; int hdr_route = hdr_plan(&dl, w, h, fx_on, framegen, &hs); + /* Mirror's PixelCopy cannot see the separate game layer. Keep unimportable frames visible on top. */ + if (g_mirror_capture && hdr_route != 3 && hs.n_hdr > 0) { + hdr_route = 2; + hs.why = "Mirror needs the screen swapchain"; + } const char *hdr_copy = NULL; if (droiddeck_color_hdr_open()) { hdr_note_route(hdr_route, &hs); @@ -2552,6 +3240,8 @@ static void render_scene(void) { } else { cursor_hdr_said = 0; } + g_zero_copy_shown = NULL; + if (hdr_route == 1 || hdr_route == 2) settle_unwaited(); if (hdr_route == 1) { static int fell_back; vkp_apply_window_request(); @@ -2583,15 +3273,16 @@ static void render_scene(void) { else if (rendered && how == 2) droiddeck_color_frame_shown(hs.color, DROIDDECK_HDR_TONEMAPPED, 0); else if (rendered) hdr_copy = "the HDR composition pass is unavailable on this driver"; } - if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on && + if (hdr_route == 0 && !g_mirror_capture && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on && !ahb_only) { + settle_unwaited(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; } else if (hdr_route == 0 || hdr_route == 3) { const int pass_on = fx_on || framegen; tell_overlay_planes(); - const int fg_layer = framegen && hdr_route == 0 && framegen_fits_layer(); + const int fg_layer = framegen && !g_mirror_capture && hdr_route == 0 && framegen_fits_layer(); g_framegen_layer = fg_layer; - int li = (g_zero_copy && (!framegen || fg_layer) && !bfi && !cardboard && !cursor_on) ? layer_candidate(&dl, w, h) : -1; + int li = (g_zero_copy && !g_mirror_capture && (!framegen || fg_layer) && !bfi && !cardboard && !cursor_on) ? layer_candidate(&dl, w, h) : -1; int over = li >= 0 ? dl.n - 1 - li : 0; const int fx_blocks = (li >= 0 && fx_on && over > 0); if (fx_blocks) { li = -1; over = 0; } @@ -2620,7 +3311,10 @@ static void render_scene(void) { struct surface *ls = li >= 0 ? surface_for_image(dl.d[li].img) : NULL; const struct vkp_draw *ld = li >= 0 ? &dl.d[li] : NULL; if (li < 0) ls = layer_only; - if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) note_copy_scene(&dl, w, h, cursor_on); + if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) { + if (!cursor_on && !bfi) note_layer_candidate_rejected(&dl, w, h); + note_copy_scene(&dl, w, h, cursor_on); + } if (cardboard) ls = NULL; if (cursor_on) ls = NULL; if (bfi) ls = NULL; @@ -2634,6 +3328,7 @@ static void render_scene(void) { vkp_apply_window_request(); int r = -1; const int fg_pass = framegen && fx_on && li >= 0; + if (framegen && li >= 0) settle_unwaited(); const int generated = (framegen && li >= 0) ? sc_layer_present_generated(&dl.d[li], 1, NULL, w, h, fg_pass, ls ? droiddeck_surface_color(ls) : NULL) : 0; @@ -2647,16 +3342,34 @@ static void render_scene(void) { r = generated >= 0 ? 0 : -1; else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf)) r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld); - if (!fg_pass && generated >= 0 && r != 0 && li >= 0) - r = fx_on ? sc_layer_present_pass(&dl.d[li], 1, w, h) - : sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL); + if (!fg_pass && generated >= 0 && !fx_on && !framegen && r != 0) { + if (!ls || !ls->dmabuf_buf) + note_zero_copy_fallback(ls, NULL, ZERO_COPY_NO_SURFACE_BUFFER, w, h, r); + else if (!ahb_swapchain_has_ahb(ls->dmabuf_buf)) + note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_NO_GRALLOC_AHB, w, h, r); + else + note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_AHB_PRESENT_FAILED, w, h, r); + } + if (r == 0 && !fg_pass) g_zero_copy_shown = ls; + else settle_unwaited(); + int ov = 0, ov_done = 0; + if (!fg_pass && generated >= 0 && r != 0 && li >= 0) { + if (fx_on) { + r = sc_layer_present_pass(&dl.d[li], 1, w, h); + } else { + r = sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL, + over == 1 ? &dl.d[li + 1] : NULL, &ov); + ov_done = 1; + } + } if (r == 0) { if (ls) ls->drawn = 1; - int go[8], ov = 0; - if (over == 1 && li >= 0 && vkp_map_draw(&dl.d[li + 1], go)) + int go[8]; + if (!ov_done && over == 1 && li >= 0 && vkp_map_draw(&dl.d[li + 1], go)) ov = sc_layer_present_overlay(dl.d[li + 1].img, go, dl.d[li + 1].blend) == 0 ? 1 : -1; if (ov <= 0) sc_layer_hide_overlay(); if (ov < 0) { + settle_unwaited(); sc_layer_hide(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; copy = 1; @@ -2666,12 +3379,14 @@ static void render_scene(void) { g_scene_queues = sc_layer_queues(); } } else { + settle_unwaited(); sc_layer_hide(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; copy = 1; hdr_copy = "its display layer was unavailable this frame"; } } else { + settle_unwaited(); sc_layer_hide(); rendered = vkp_render(w, h, dl.d, dl.n) == 0; copy = 1; @@ -3522,6 +4237,15 @@ static void pointer_input(double x, double y, int relative, uint32_t button, int if (k) confine_clamp(k, &x, &y); g_ptr_x = x; g_ptr_y = y; g_ptr_known = 1; + if (relative && !button && (dx != 0.0 || dy != 0.0)) { + int ow, oh; + double ox, oy; + vkp_output_size(&ow, &oh); + if (ow > 0 && oh > 0 && + vkp_scene_to_output(g_ptr_x, g_ptr_y, &ox, &oy) && + vkp_zoom_pan_cursor(ox, oy)) + schedule_render(); + } if (atomic_load(&g_cursor_composite)) schedule_render(); if (k) { target = k->surface; @@ -3590,15 +4314,38 @@ static void pointer_button(uint32_t button, int pressed) { } static void deliver_pointer(const struct input_msg *m) { + static int last_x, last_y, last_valid; int w, h, ow, oh; double x, y; + int moved = last_valid && (m->p2 != last_x || m->p3 != last_y); + last_x = m->p2; + last_y = m->p3; + last_valid = 1; scene_size(&w, &h); vkp_output_size(&ow, &oh); - if (ow <= 0 || oh <= 0 || - !vkp_output_to_scene((double)m->p2 * ow / INPUT_SPACE_W, (double)m->p3 * oh / INPUT_SPACE_H, &x, &y)) { + + if (ow <= 0 || oh <= 0) { x = (double)m->p2 * w / INPUT_SPACE_W; y = (double)m->p3 * h / INPUT_SPACE_H; + } else { + double ox = (double)m->p2 * ow / INPUT_SPACE_W; + double oy = (double)m->p3 * oh / INPUT_SPACE_H; + if (m->p1 == 1 && !pointer_locked_for_cursor() && + (moved || ox <= 0.0 || oy <= 0.0 || ox >= ow || oy >= oh) && + vkp_zoom_pan_cursor(ox, oy)) + schedule_render(); + if (!vkp_output_to_scene(ox, oy, &x, &y)) { + schedule_render(); + if (g_ptr_known) { + x = g_ptr_x; + y = g_ptr_y; + } else { + x = (double)m->p2 * w / INPUT_SPACE_W; + y = (double)m->p3 * h / INPUT_SPACE_H; + } + } } + if (x < 0) x = 0; if (y < 0) y = 0; if (x > w - 1) x = w - 1; @@ -3610,6 +4357,7 @@ static void input_output_to_scene(double px, double py, double *x, double *y) { int w, h, ow, oh; scene_size(&w, &h); vkp_output_size(&ow, &oh); + if (ow <= 0 || oh <= 0 || !vkp_output_to_scene(px * ow / INPUT_SPACE_W, py * oh / INPUT_SPACE_H, x, y)) { *x = px * w / INPUT_SPACE_W; @@ -3833,12 +4581,63 @@ static void touch_up(int id, double x, double y) { } static void deliver_touch(const struct input_msg *m) { + static int last_x[MAX_TOUCH_POINTS], last_y[MAX_TOUCH_POINTS]; + static int pan_start_x[MAX_TOUCH_POINTS], pan_start_y[MAX_TOUCH_POINTS]; + static unsigned char last_valid[MAX_TOUCH_POINTS]; + static unsigned char pan_started[MAX_TOUCH_POINTS]; double x, y; + int id = m->p2; + int valid_id = id >= 0 && id < MAX_TOUCH_POINTS; + + if (valid_id && m->p1 == 0) { + pan_start_x[id] = m->p3; + pan_start_y[id] = m->p4; + pan_started[id] = 0; + } + if (valid_id && g_touch_points[id].surface && + m->p1 == 1 && last_valid[id] && !pan_started[id]) { + int dx = m->p3 - pan_start_x[id]; + int dy = m->p4 - pan_start_y[id]; + if (dx * dx + dy * dy >= 400) + pan_started[id] = 1; + } + if (valid_id && g_touch_points[id].surface && + m->p1 == 1 && pan_started[id] && last_valid[id] && + (m->p3 != last_x[id] || m->p4 != last_y[id])) { + int ow, oh; + vkp_output_size(&ow, &oh); + if (ow > 0 && oh > 0 && + vkp_zoom_pan_cursor((double)m->p3 * ow / INPUT_SPACE_W, + (double)m->p4 * oh / INPUT_SPACE_H)) + schedule_render(); + } + input_output_to_scene(m->p3, m->p4, &x, &y); - if (m->p1 == 0) touch_down(m->p2, x, y); - else if (m->p1 == 1) touch_motion(m->p2, x, y); - else if (m->p1 == 2) touch_up(m->p2, x, y); - else if (m->p1 == 3) touch_cancel_all(); + if (m->p1 == 0) { + if (valid_id) { + last_x[id] = m->p3; + last_y[id] = m->p4; + last_valid[id] = 1; + } + touch_down(id, x, y); + } else if (m->p1 == 1) { + if (valid_id) { + last_x[id] = m->p3; + last_y[id] = m->p4; + last_valid[id] = 1; + } + touch_motion(id, x, y); + } else if (m->p1 == 2) { + touch_up(id, x, y); + if (valid_id) { + last_valid[id] = 0; + pan_started[id] = 0; + } + } else if (m->p1 == 3) { + touch_cancel_all(); + memset(last_valid, 0, sizeof(last_valid)); + memset(pan_started, 0, sizeof(pan_started)); + } publish_query_state(); } @@ -4023,11 +4822,15 @@ static void output_resized(void) { wl_display_flush_clients(g_display); } -static int on_input_readable(int fd, uint32_t mask, void *data) { +static void dispatch_input(int fd, int remaining) { struct input_msg m; int vsync = 0; int64_t vsync_ns = 0; - while (read(fd, &m, sizeof(m)) == (ssize_t)sizeof(m)) { + while (remaining != 0) { + ssize_t n = read(fd, &m, sizeof(m)); + if (n < 0 && errno == EINTR) continue; + if (n != (ssize_t)sizeof(m)) break; + if (remaining > 0) --remaining; switch (m.type) { case 1: deliver_key(&m); break; case 2: pointer_event(m.p1, m.p2, 0, 0); break; @@ -4045,12 +4848,20 @@ static int on_input_readable(int fd, uint32_t mask, void *data) { case 11: axis_event(m.p1, m.p2, 0); break; case 12: axis_event(m.p1, m.p2, 1); break; case 13: deliver_pen(&m); break; + case 14: + atomic_store(&g_zoom_request_pending, 1); + break; case 20: stream_take(); break; case 21: if (!m.p1) stream_forget_all(); schedule_render(); break; case 22: schedule_render(); break; default: deliver_pointer(&m); break; } } + if (atomic_exchange(&g_zoom_request_pending, 0)) { + int zoom_percent = atomic_load(&g_zoom_request_percent); + vk_present_set_zoom((float)zoom_percent / 100.0f); + schedule_render(); + } if (atomic_exchange(&g_output_refresh_pending, 0) && atomic_load(&g_output_refresh_mhz) != g_output_announced_refresh_mhz) { output_notify_mode(); @@ -4061,9 +4872,27 @@ static int on_input_readable(int fd, uint32_t mask, void *data) { wl_display_flush_clients(g_display); } if (vsync) on_vsync(vsync_ns); +} + +static int on_input_readable(int fd, uint32_t mask, void *data) { + dispatch_input(fd, -1); return 0; } +void droiddeck_dispatch_pending_input(void) { + int fd = g_input_pipe[0]; + if (fd < 0) return; + + int bytes; + int result; + do { + result = ioctl(fd, FIONREAD, &bytes); + } while (result < 0 && errno == EINTR); + if (result == 0 && bytes >= (int)sizeof(struct input_msg)) { + dispatch_input(fd, bytes / (int)sizeof(struct input_msg)); + } +} + void droiddeck_wayland_set_scale_mode(int mode, int alignment) { if (g_input_pipe[1] < 0) { vk_present_set_scale_mode(mode, alignment); @@ -4074,6 +4903,23 @@ void droiddeck_wayland_set_scale_mode(int mode, int alignment) { (void)n; } +void droiddeck_wayland_set_zoom(int zoom_percent) { + if (zoom_percent < 100) zoom_percent = 100; + if (zoom_percent > 300) zoom_percent = 300; + if (g_input_pipe[1] < 0) { + vk_present_set_zoom((float)zoom_percent / 100.0f); + return; + } + atomic_store(&g_zoom_request_percent, zoom_percent); + atomic_store(&g_zoom_request_pending, 1); + struct input_msg m = { 14, zoom_percent, 0, 0, 0 }; + ssize_t n; + do { + n = write(g_input_pipe[1], &m, sizeof(m)); + } while (n < 0 && errno == EINTR); + (void)n; +} + void droiddeck_wayland_send_pointer(int action, int x, int y) { if (g_input_pipe[1] < 0) return; struct input_msg m = { 0, action, x, y, 0 }; @@ -4166,6 +5012,12 @@ const char *droiddeck_client_name(struct wl_client *client) { return client_name struct wl_display *droiddeck_get_display(void) { return g_display; } void droiddeck_request_redraw(void) { schedule_render(); } +void droiddeck_set_mirror_capture(int on) { + if (g_mirror_capture == on) return; + g_mirror_capture = on; + schedule_render(); +} + struct wl_resource *droiddeck_ime_target(void) { struct surface *s; if (g_ime_click && g_ime_click->mapped) return g_ime_click->resource; @@ -4183,6 +5035,11 @@ void droiddeck_surface_scene_origin(struct wl_resource *surface, int *x, int *y) void droiddeck_inject_key(uint32_t evdev, int pressed) { key_event(evdev, pressed); } +int droiddeck_key_is_down(uint32_t evdev) { + return evdev < sizeof(g_keys_down) * 8 && + (g_keys_down[evdev >> 3] & (1u << (evdev & 7))) != 0; +} + static struct wl_event_source *g_stats_timer; volatile unsigned g_zero_copy_last; @@ -4192,6 +5049,7 @@ static int on_stats_timer(void *data) { struct surface *s; wl_list_for_each(s, &g_toplevels, toplevel_link) windows++; unsigned zero_copy = ahb_swapchain_stats_take(); + unsigned verified = ahb_swapchain_producer_fence_stats_take(); unsigned layer_frames = sc_layer_frames_take(); g_zero_copy_last = zero_copy; unsigned generated = vkp_framegen_stats_take(); @@ -4200,7 +5058,8 @@ static int on_stats_timer(void *data) { int off = 0; if (g_zero_copy || zero_copy) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u zero-copy frames", zero_copy); if (layer_frames) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u layer frames", layer_frames); - if (generated) snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u generated frames", generated); + if (generated) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u generated frames", generated); + if (verified) snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u verified acquire frames", verified); droiddeck_log("stats", "last 10 s: %u frames on screen (%.1f fps) | %u GPU frames from games | %u window redraws | %d windows open%s", g_stat_frames + generated, (g_stat_frames + generated) / 10.0, g_stat_dmabuf, g_stat_shm, windows, extra); } @@ -4211,11 +5070,12 @@ static int on_stats_timer(void *data) { unsigned aimed_next, aimed_later, aimed_even; sc_layer_aim_take(&aimed_next, &aimed_later, &aimed_even); #define PERF_MS(sum, n) ((n) ? (double)(sum) / 1e6 / (double)(n) : 0.0) - if (g_perf.scenes || vp.presents || g_perf.releases || drops) + if (g_perf.scenes || vp.presents || g_perf.releases || drops || g_perf.commit_waits) droiddeck_log("perf", "last 10 s: %u ticks, %u scenes, %u on screen (copy %u, zero-copy %u, layer copy %u) | " "render_scene %.2f/%.2f ms | base %u black kept, %u presented | acquire %.2f/%.2f ms | " "present %.2f/%.2f ms (%u) | fence wait %.2f/%.2f ms (%u, %u GPU release waits) | " - "release %.2f/%.2f ms (%u, %u held) | %u pool drops | layer frames timed for the next refresh %u, " + "release %.2f/%.2f ms (%u, %u held) | commits held for client writes %.2f/%.2f ms (%u, %u past the limit) | " + "%u pool drops | layer frames timed for the next refresh %u, " "the one after %u, held to an even step %u", g_perf.ticks, g_perf.scenes, g_stat_frames, g_perf.copy_scenes, zero_copy, layer_frames, PERF_MS(g_perf.scene_ns, g_perf.scenes), (double)g_perf.scene_max_ns / 1e6, @@ -4224,7 +5084,9 @@ static int on_stats_timer(void *data) { PERF_MS(vp.present_ns, vp.presents), (double)vp.present_max_ns / 1e6, vp.presents, PERF_MS(vp.wait_ns, vp.waits), (double)vp.wait_max_ns / 1e6, vp.waits, vp.gpu_release_waits, PERF_MS(g_perf.release_ns, g_perf.releases), (double)g_perf.release_max_ns / 1e6, - g_perf.releases, g_perf.releases_held, drops, aimed_next, aimed_later, aimed_even); + g_perf.releases, g_perf.releases_held, + PERF_MS(g_perf.commit_wait_ns, g_perf.commit_waits), (double)g_perf.commit_wait_max_ns / 1e6, + g_perf.commit_waits, g_perf.commit_wait_limits, drops, aimed_next, aimed_later, aimed_even); #undef PERF_MS memset(&g_perf, 0, sizeof(g_perf)); } @@ -4398,6 +5260,12 @@ int droiddeck_wayland_run(void) { wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, 1, NULL, bind_relative_pointer_manager); droiddeck_ext_init(display); ahb_swapchain_init(display); +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + if (ahb_swapchain_advertised()) { + wl_display_set_global_filter(display, frame_acquire_global_filter, NULL); + wl_global_create(display, &droiddeck_frame_acquire_v1_interface, 1, NULL, bind_frame_acquire); + } +#endif display_buffers_init(display); diff --git a/app/src/main/cpp/waylandcomp/src/display_buffers.c b/app/src/main/cpp/waylandcomp/src/display_buffers.c index 99f6993a56..f6ee1eb0d3 100644 --- a/app/src/main/cpp/waylandcomp/src/display_buffers.c +++ b/app/src/main/cpp/waylandcomp/src/display_buffers.c @@ -62,8 +62,40 @@ struct entry { static struct wl_list g_entries; static struct wl_event_loop *g_loop; static uint64_t g_next_id = 1; -static int g_refused_logged; static int g_ubwc_promised; + +#define DISPLAY_BUFFER_MISMATCH_SIGNATURES 64u +struct display_buffer_mismatch_signature { + uint32_t kind, format, stride, offset; + int width, height; + uint64_t modifier; +}; +static struct display_buffer_mismatch_signature g_mismatch_signatures[DISPLAY_BUFFER_MISMATCH_SIGNATURES]; +static uint32_t g_mismatch_signature_count; +static int g_mismatch_limit_logged; + +static int mismatch_should_log(const struct dmabuf_buffer *b, uint32_t kind) { + const struct display_buffer_mismatch_signature key = { + .kind = kind, .format = b->format, .stride = b->stride[0], .offset = b->offset[0], + .width = b->width, .height = b->height, .modifier = b->modifier}; + for (uint32_t i = 0; i < g_mismatch_signature_count; i++) { + const struct display_buffer_mismatch_signature *seen = &g_mismatch_signatures[i]; + if (seen->kind == key.kind && seen->format == key.format && seen->stride == key.stride && + seen->offset == key.offset && seen->width == key.width && seen->height == key.height && + seen->modifier == key.modifier) + return 0; + } + if (g_mismatch_signature_count >= DISPLAY_BUFFER_MISMATCH_SIGNATURES) { + if (!g_mismatch_limit_logged) { + g_mismatch_limit_logged = 1; + droiddeck_log("layer", "display buffers: further mismatch diagnostics suppressed after %u distinct buffer signatures", + DISPLAY_BUFFER_MISMATCH_SIGNATURES); + } + return 0; + } + g_mismatch_signatures[g_mismatch_signature_count++] = key; + return 1; +} static int g_ubwc_probed[2]; static uint32_t ahb_format_of(uint32_t drm, uint64_t modifier) { @@ -238,16 +270,51 @@ static void handle_alloc(struct peer *p, const struct display_buffers_request *q } else { if (ahb) AHardwareBuffer_release(ahb); fd = -1; - if (sized && wanted && (compressed || !g_refused_logged)) { - g_refused_logged = 1; - droiddeck_log(compressed ? "error" : "layer", "display buffers: no gralloc buffer matches pid %d's %ux%u " - "%c%c%c%c %s layout (stride %u bytes, pixels at %u, %llu bytes; gralloc's layout has pixels at " - "%llu, %llu bytes): %s", (int)p->pid, q->width, q->height, - q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff, - compressed ? "UBWC" : "linear", q->stride, q->offset, (unsigned long long)q->size, - (unsigned long long)(compressed ? ubwc_meta_size(q->width, q->height) : 0), - (unsigned long long)(compressed ? ubwc_size(q->width, q->height, q->stride) : q->size), - compressed ? "its compressed frames cannot be shown" : "its frames keep the copy path"); + static struct { + pid_t pid; + uint32_t width, height, format, stride, offset, reason; + uint64_t size, modifier; + } refused[32]; + static unsigned refused_count; + static int refused_limit_logged; + uint32_t reason = !sized ? 1u : !sane ? 2u : !wanted ? 3u : + !ahb_swapchain_advertised() ? 4u : + p->count >= DISPLAY_BUFFERS_MAX_PER_CLIENT ? 5u : 6u; + int seen = 0; + for (unsigned i = 0; i < refused_count; i++) { + if (refused[i].pid == p->pid && refused[i].width == q->width && refused[i].height == q->height && + refused[i].format == q->format && refused[i].stride == q->stride && refused[i].offset == q->offset && + refused[i].size == q->size && refused[i].modifier == q->modifier && refused[i].reason == reason) { + seen = 1; + break; + } + } + if (!seen && refused_count < 32) { + refused[refused_count].pid = p->pid; + refused[refused_count].width = q->width; + refused[refused_count].height = q->height; + refused[refused_count].format = q->format; + refused[refused_count].stride = q->stride; + refused[refused_count].offset = q->offset; + refused[refused_count].size = q->size; + refused[refused_count].modifier = q->modifier; + refused[refused_count].reason = reason; + refused_count++; + const char *why = reason == 1 ? "invalid dimensions, format, or stride" : + reason == 2 ? "size/offset/layout sanity check failed" : + reason == 3 ? "zero-copy or UBWC offering is disabled" : + reason == 4 ? "AHardwareBuffer swapchain is not advertised" : + reason == 5 ? "per-client allocation limit reached" : + "gralloc allocation/fd/size validation failed"; + droiddeck_log(compressed ? "error" : "layer", + "display buffers: allocation refused for pid %d: %s; request %ux%u %c%c%c%c %s stride=%u offset=%u size=%llu modifier=0x%llx (client has %d allocations)", + (int)p->pid, why, q->width, q->height, + q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff, + compressed ? "UBWC" : "linear", q->stride, q->offset, + (unsigned long long)q->size, (unsigned long long)q->modifier, p->count); + } else if (!seen && !refused_limit_logged) { + refused_limit_logged = 1; + droiddeck_log("layer", "display buffers: further allocation-refusal diagnostics suppressed after 32 signatures"); } } if (reply(p, &r, fd) != 0 && e) entry_free(e); @@ -299,9 +366,18 @@ static int on_listen(int fd, uint32_t mask, void *data) { } void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b) { + static int invalid_logged; struct stat st; struct entry *e; - if (!g_loop || wl_list_empty(&g_entries) || b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) return; + if (!g_loop || wl_list_empty(&g_entries)) return; + if (b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) { + if (!invalid_logged) { + invalid_logged = 1; + droiddeck_log("layer", "display buffers: cannot associate %s's DMA-BUF with gralloc (plane count %u; expected one plane at offset 0, or fstat failed)", + droiddeck_client_name(c), b->n_planes); + } + return; + } wl_list_for_each(e, &g_entries, link) { if (e->dev != st.st_dev || e->ino != st.st_ino) continue; AHardwareBuffer_Desc d; @@ -311,11 +387,27 @@ void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, stru (uint32_t)b->height == e->height : (b->modifier == MOD_LINEAR || b->modifier == MOD_INVALID) && e->stride == b->stride[0]; - if (laid_out && e->format == ahb_format_of(b->format, e->modifier) && b->width > 0 && b->height > 0 && - (uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height) + const uint32_t expected_format = ahb_format_of(b->format, e->modifier); + const int dimensions = b->width > 0 && b->height > 0 && + (uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height; + if (laid_out && e->format == expected_format && dimensions) { ahb_swapchain_adopt(c, buffer, b, e->ahb, e->modifier); + } else if (mismatch_should_log(b, 2)) { + droiddeck_log("layer", "display buffers: gralloc DMA-BUF identity matched but layout was rejected for %s: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; gralloc %ux%u stride %u format 0x%x, expected format 0x%x (layout %s, dimensions %s)", + droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff, + (b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height, + b->stride[0], b->offset[0], (unsigned long long)b->modifier, + e->width, e->height, e->stride, e->format, expected_format, + laid_out ? "ok" : "mismatch", dimensions ? "ok" : "mismatch"); + } return; } + if (mismatch_should_log(b, 1)) { + droiddeck_log("layer", "display buffers: no registered gralloc allocation matches %s's DMA-BUF identity: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; imported normally, copy path only", + droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff, + (b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height, + b->stride[0], b->offset[0], (unsigned long long)b->modifier); + } } void display_buffers_init(struct wl_display *display) { diff --git a/app/src/main/cpp/waylandcomp/src/droiddeck_ext.c b/app/src/main/cpp/waylandcomp/src/droiddeck_ext.c index 1172c095b0..e4ce7e201d 100644 --- a/app/src/main/cpp/waylandcomp/src/droiddeck_ext.c +++ b/app/src/main/cpp/waylandcomp/src/droiddeck_ext.c @@ -4,12 +4,14 @@ #include #include #include +#include +#include #include #include "droiddeck_ext.h" #include "ahb_swapchain.h" #include "droiddeck_color.h" -enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT }; +enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT, HOST_KEY, HOST_SELECT_GAME_FIELD, HOST_MIRROR_CAPTURE }; struct host_msg { enum host_kind kind; @@ -23,6 +25,32 @@ static pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER; static struct host_msg *g_head, *g_tail; static int g_wake[2] = {-1, -1}; +/* Compositor-thread-only fallback ordering state. */ +static int g_pending_token, g_pending_submit; +static int g_fallback_failed; +static int g_next_token = 1; +static struct host_msg *g_deferred_head, *g_deferred_tail; +static size_t g_deferred_count, g_deferred_bytes; +static int g_deferred_overflow; +static int g_completed_token, g_completed_result; + +#define DROIDDECK_EVDEV_KEY_MAX 768 +#define DROIDDECK_TEXT_DEFERRED_LIMIT 256 +#define DROIDDECK_TEXT_DEFERRED_BYTES (256 * 1024) +static unsigned char g_ordered_key_down[DROIDDECK_EVDEV_KEY_MAX]; + +void droiddeck_host_text_input_fallback_complete(int token, int result) { + pthread_mutex_lock(&g_mu); + g_completed_token = token; + g_completed_result = result; + pthread_mutex_unlock(&g_mu); + if (g_wake[1] >= 0) { + char c = 1; + ssize_t n = write(g_wake[1], &c, 1); + (void)n; + } +} + static void host_post(enum host_kind kind, const char *text, size_t len, int a, int b) { struct host_msg *m = calloc(1, sizeof(*m)); if (!m) return; @@ -51,6 +79,9 @@ void droiddeck_host_clipboard_text(const char *utf8, int len) { void droiddeck_host_text_commit(const char *utf8, int len) { host_post(HOST_TEXT_COMMIT, utf8, len > 0 ? (size_t)len : 0, 0, 0); } +void droiddeck_host_text_commit_and_submit(const char *utf8, int len) { + if (len > 0) host_post(HOST_TEXT_COMMIT, utf8, (size_t)len, 1, 0); +} void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end) { host_post(HOST_TEXT_PREEDIT, utf8, len > 0 ? (size_t)len : 0, cursor_begin, cursor_end); } @@ -60,26 +91,179 @@ void droiddeck_host_text_delete(int before, int after) { void droiddeck_host_zero_copy(int on, int live) { host_post(HOST_ZERO_COPY, NULL, 0, on, live); } +void droiddeck_host_mirror_capture(int on) { + host_post(HOST_MIRROR_CAPTURE, NULL, 0, on, 0); +} void droiddeck_host_hdr_output(int on) { host_post(HOST_HDR_OUTPUT, NULL, 0, on, 0); } +void droiddeck_host_key(int evdev, int state) { + host_post(HOST_KEY, NULL, 0, evdev, state); +} + +void droiddeck_host_select_game_field(int copy) { + host_post(HOST_SELECT_GAME_FIELD, NULL, 0, copy, 0); +} + +static void tap_unheld_key(uint32_t key) { + if (droiddeck_key_is_down(key)) return; + droiddeck_inject_key(key, 1); + droiddeck_inject_key(key, 0); +} + +static void select_game_field(int copy) { + /* Apply pending raw releases before using the compositor's held-key state. */ + droiddeck_dispatch_pending_input(); + int temporary_ctrl = !droiddeck_key_is_down(KEY_LEFTCTRL) && !droiddeck_key_is_down(KEY_RIGHTCTRL); + if (temporary_ctrl) droiddeck_inject_key(KEY_LEFTCTRL, 1); + tap_unheld_key(KEY_A); + if (copy) tap_unheld_key(KEY_C); + if (temporary_ctrl) droiddeck_inject_key(KEY_LEFTCTRL, 0); +} + +static void restore_deferred_to_front(void) { + if (g_deferred_head) { + g_deferred_tail->next = g_head; + if (!g_head) g_tail = g_deferred_tail; + g_head = g_deferred_head; + g_deferred_head = g_deferred_tail = NULL; + g_deferred_count = g_deferred_bytes = 0; + } +} + +/* Only suppress the queued submit for this commit, not a later commit or a held-key release. */ +static void discard_queued_submit(void) { + struct host_msg *prev = NULL; + struct host_msg *m = g_head; + int enter_held = g_ordered_key_down[KEY_ENTER]; + int key_pad_enter_held = g_ordered_key_down[KEY_KPENTER]; + while (m) { + int soft_submit = 0; + if (m->kind == HOST_TEXT_COMMIT) { + if (m->a || m->len == 0) break; + soft_submit = 1; + size_t i = 0; + for (; i < m->len; i++) { + char c = m->text[i]; + if (c != '\r' && c != '\n') soft_submit = 0; + if (c != '\r' && c != '\n' && c != '\b' && c != '\t' && c != 0x7f) break; + } + if (i != m->len) break; + } + struct host_msg *next = m->next; + int *held = m->a == KEY_ENTER ? &enter_held : m->a == KEY_KPENTER ? &key_pad_enter_held : NULL; + if (soft_submit || (m->kind == HOST_KEY && held && (m->b != 0 || !*held))) { + if (prev) prev->next = next; else g_head = next; + if (g_tail == m) g_tail = prev; + free(m->text); + free(m); + } else { + if (m->kind == HOST_KEY && held) *held = 0; + prev = m; + } + m = next; + } +} + +static int release_held_key(const struct host_msg *m) { + int k = m->a; + if (m->kind != HOST_KEY || m->b != 0 || k < 0 || k >= DROIDDECK_EVDEV_KEY_MAX || + !g_ordered_key_down[k]) return 0; + g_ordered_key_down[k] = 0; + droiddeck_inject_key((uint32_t)k, 0); + return 1; +} + +static void discard_deferred_input(void) { + struct host_msg *m = g_deferred_head; + while (m) { + struct host_msg *next = m->next; + release_held_key(m); + free(m->text); + free(m); + m = next; + } + g_deferred_head = g_deferred_tail = NULL; + g_deferred_count = g_deferred_bytes = 0; +} static int on_wake(int fd, uint32_t mask, void *data) { char buf[64]; while (read(fd, buf, sizeof(buf)) > 0) {} for (;;) { + int deferred = 0, submit = 0; pthread_mutex_lock(&g_mu); + if (g_pending_token != 0 && g_completed_token == g_pending_token) { + int result = g_completed_result; + g_completed_token = 0; + restore_deferred_to_front(); + if (result != DROIDDECK_TEXT_DELIVERED) discard_queued_submit(); + if (result == DROIDDECK_TEXT_UNRESOLVED) { + g_fallback_failed = 1; + } else { + if (result == DROIDDECK_TEXT_DELIVERED) submit = g_pending_submit; + g_pending_submit = 0; + g_pending_token = 0; + g_fallback_failed = 0; + g_deferred_overflow = 0; + } + } struct host_msg *m = g_head; - if (m) { g_head = m->next; if (!g_head) g_tail = NULL; } + if (m) { g_head = m->next; if (!g_head) g_tail = NULL; m->next = NULL; } pthread_mutex_unlock(&g_mu); + if (submit) tap_unheld_key(KEY_ENTER); if (!m) break; + if (g_pending_token != 0 && + (m->kind == HOST_TEXT_COMMIT || m->kind == HOST_TEXT_PREEDIT || + m->kind == HOST_TEXT_DELETE || m->kind == HOST_KEY || + m->kind == HOST_SELECT_GAME_FIELD)) { + int released_during_recovery = g_fallback_failed && release_held_key(m); + if (released_during_recovery || g_deferred_overflow || + g_deferred_count == DROIDDECK_TEXT_DEFERRED_LIMIT || + m->len > DROIDDECK_TEXT_DEFERRED_BYTES - g_deferred_bytes) { + if (!released_during_recovery) { + /* An incomplete queue could replay a submit or lose a paired release. */ + if (!g_deferred_overflow) + droiddeck_log("text-input", "deferred input exceeded the recovery queue limit"); + discard_deferred_input(); + release_held_key(m); + g_deferred_overflow = 1; + } + free(m->text); + free(m); + continue; + } + if (g_deferred_tail) g_deferred_tail->next = m; else g_deferred_head = m; + g_deferred_tail = m; + g_deferred_count++; + g_deferred_bytes += m->len; + deferred = 1; + } + if (deferred) continue; switch (m->kind) { case HOST_CLIPBOARD: clipboard_host_text(m->text, m->len); m->text = NULL; break; case HOST_TEXT_COMMIT: - text_input_host_commit(m->text ? m->text : "", m->len); + if (!text_input_host_commit(m->text ? m->text : "", m->len)) { + int token = 0; + if (g_next_token == INT_MAX) g_next_token = 1; + else g_next_token++; + token = g_next_token; + g_pending_token = 0; + if (droiddeck_on_text_input_fallback(m->text ? m->text : "", (int)m->len, token)) { + g_pending_token = token; + g_pending_submit = m->a; + } else { + droiddeck_log("text-input", "fallback had no accepting Android listener"); + pthread_mutex_lock(&g_mu); + discard_queued_submit(); + pthread_mutex_unlock(&g_mu); + } + } else if (m->a) { + tap_unheld_key(KEY_ENTER); + } break; case HOST_TEXT_PREEDIT: text_input_host_preedit(m->text ? m->text : "", m->len, m->a, m->b); @@ -90,9 +274,25 @@ static int on_wake(int fd, uint32_t mask, void *data) { case HOST_ZERO_COPY: ahb_swapchain_set_mode(m->a, m->b); break; + case HOST_MIRROR_CAPTURE: + droiddeck_set_mirror_capture(m->a); + break; case HOST_HDR_OUTPUT: droiddeck_color_set_output(m->a); break; + case HOST_SELECT_GAME_FIELD: + select_game_field(m->a); + break; + case HOST_KEY: + if (m->b == 1) { + int k = m->a; + if (k >= 0 && k < DROIDDECK_EVDEV_KEY_MAX) g_ordered_key_down[k] = 1; + } else if (m->b == 0) { + int k = m->a; + if (k >= 0 && k < DROIDDECK_EVDEV_KEY_MAX) g_ordered_key_down[k] = 0; + } + droiddeck_inject_key((uint32_t)m->a, m->b); + break; } free(m->text); free(m); diff --git a/app/src/main/cpp/waylandcomp/src/droiddeck_ext.h b/app/src/main/cpp/waylandcomp/src/droiddeck_ext.h index ca359557e4..bc67469eff 100644 --- a/app/src/main/cpp/waylandcomp/src/droiddeck_ext.h +++ b/app/src/main/cpp/waylandcomp/src/droiddeck_ext.h @@ -15,22 +15,36 @@ struct wl_display *droiddeck_get_display(void); struct wl_resource *droiddeck_ime_target(void); void droiddeck_surface_scene_origin(struct wl_resource *surface, int *x, int *y); void droiddeck_inject_key(uint32_t evdev, int pressed); +int droiddeck_key_is_down(uint32_t evdev); +void droiddeck_dispatch_pending_input(void); void droiddeck_on_clipboard_text(const char *utf8, int len); +int droiddeck_on_text_input_fallback(const char *utf8, int len, int token); void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int w, int h); void droiddeck_host_clipboard_text(const char *utf8, int len); void droiddeck_host_text_commit(const char *utf8, int len); +void droiddeck_host_text_commit_and_submit(const char *utf8, int len); void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end); void droiddeck_host_text_delete(int before, int after); void droiddeck_host_zero_copy(int on, int live); +void droiddeck_host_mirror_capture(int on); +void droiddeck_set_mirror_capture(int on); void droiddeck_host_hdr_output(int on); +void droiddeck_host_key(int evdev, int state); +void droiddeck_host_select_game_field(int copy); +enum droiddeck_text_input_result { + DROIDDECK_TEXT_NOT_DELIVERED = 0, + DROIDDECK_TEXT_DELIVERED = 1, + DROIDDECK_TEXT_UNRESOLVED = 2, +}; +void droiddeck_host_text_input_fallback_complete(int token, int result); void clipboard_init(struct wl_display *display); void clipboard_host_text(char *utf8, size_t len); void text_input_init(struct wl_display *display); -void text_input_host_commit(const char *utf8, size_t len); +int text_input_host_commit(const char *utf8, size_t len); void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end); void text_input_host_delete(int before, int after); void toplevel_icon_init(struct wl_display *display); diff --git a/app/src/main/cpp/waylandcomp/src/effects_chain.c b/app/src/main/cpp/waylandcomp/src/effects_chain.c index 385a46b322..90423d2441 100644 --- a/app/src/main/cpp/waylandcomp/src/effects_chain.c +++ b/app/src/main/cpp/waylandcomp/src/effects_chain.c @@ -3,6 +3,7 @@ #include "blend_pass.h" #include "vk_loader.h" #include "vk_present.h" +#include "framegen_bridge.h" #include #include #include @@ -17,12 +18,29 @@ #include "cas_frag.h" #include "color_frag.h" #include "fxaa_frag.h" -#include "smaa_frag.h" +#include "fxaa_toon_frag.h" +#include "smaa_edge_frag.h" +#include "smaa_weights_frag.h" +#include "smaa_blend_frag.h" +#include "smaa_tables.h" #include "toon_frag.h" +#include "toon_color_frag.h" #include "hdr_frag.h" #include "ntsc_frag.h" #include "crt_frag.h" #include "deband_frag.h" +/* Half-precision upscaler/CAS set (shaders/gen_shaders.sh -DDD_HALF=1), ported from Bannerlator. */ +#include "sgsr_half_frag.h" +#include "sgsr_quality_half_frag.h" +#include "nis_luma_half_frag.h" +#include "nis3_half_frag.h" +#include "nis_coef.h" +#include "fsr_easu_half_frag.h" +#include "fsr_rcas_half_frag.h" +#include "cas_ffx_half_frag.h" +#ifdef __ANDROID__ +#include +#endif #define FX_FORMAT VK_FORMAT_R8G8B8A8_UNORM @@ -30,6 +48,7 @@ static VkFormat g_fx_fmt = FX_FORMAT, g_scene_fmt = FX_FORMAT; +static int g_scene_is_pq; #define FX_MAX_DIM 4096 @@ -52,6 +71,7 @@ static struct fx_settings g_set = { .gamma = 1.0f, .saturation = 1.0f, .s_raw = 100.0f, .look = "Off"}; static volatile int g_changed; static struct fx_settings g_cur; +static struct fx_settings g_generated_settings; static int g_cur_valid; static void set_begin(void) { pthread_mutex_lock(&g_lock); } @@ -104,10 +124,12 @@ static const char *scaling_name(int m) { } static int spatial_mode(int m) { return m >= 3 && m <= 8; } static int cas_active(const struct fx_settings *s) { return s->cas_on && s->cas_pct > 0; } +static int deband_active(const struct fx_settings *s) { return s->deband_on && s->deband_pct > 0; } static int effect_count(const struct fx_settings *s) { - return (s->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + s->deband_on; + return (s->aa_mode != 0) + s->toon + s->color_on + cas_active(s) + s->hdr_on + s->ntsc + s->crt + deband_active(s); } + static void log_settings(const struct fx_settings *s) { char line[400]; int n; @@ -129,7 +151,7 @@ static void log_settings(const struct fx_settings *s) { if (s->hdr_on) n += snprintf(line + n, sizeof(line) - n, ", HDR on"); if (s->ntsc) n += snprintf(line + n, sizeof(line) - n, ", NTSC on"); if (s->crt) n += snprintf(line + n, sizeof(line) - n, ", CRT on"); - if (s->deband_on) n += snprintf(line + n, sizeof(line) - n, ", Deband on %d%%", s->deband_pct); + if (deband_active(s)) n += snprintf(line + n, sizeof(line) - n, ", Deband on %d%%", s->deband_pct); (void)n; droiddeck_log("effects", "%s", line); } @@ -175,7 +197,13 @@ struct pc_sgsr { float ndc[4]; float vp[4]; float edge; }; struct pc_easu { float ndc[4]; uint32_t con0[4], con1[4], con2[4], con3[4]; float outW, outH; }; struct pc_rcas { float ndc[4]; uint32_t con[4]; float outW, outH; }; struct pc_res { float ndc[4]; float res[2]; float extra; float pad; }; +struct pc_smaa { float ndc[4]; float metrics[4]; }; struct pc_color { float ndc[4]; float b, c, g, s; }; +struct pc_toon_color { + float ndc[4]; float res[2]; float b, c, g, s; +}; +_Static_assert(sizeof(struct pc_toon_color) == 40, + "toon_color push constants layout mismatch"); #define PC_MAX_SIZE sizeof(struct pc_easu) static uint32_t packf(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } @@ -204,17 +232,41 @@ static VkDevice g_dev; static VkPhysicalDevice g_pd; static VkPhysicalDeviceMemoryProperties g_mp; static int g_ready; -static VkRenderPass g_rp; +static VkRenderPass g_rp, g_smaa_edge_rp, g_smaa_weights_rp; static VkDescriptorSetLayout g_dsl; static VkPipelineLayout g_pl; static VkDescriptorPool g_dpool; static VkSampler g_sampler; -enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_SMAA, P_TOON, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_COUNT }; +enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_FXAA_TOON, P_SMAA_EDGE, P_SMAA_WEIGHTS, P_SMAA_BLEND, P_TOON, P_TOON_COLOR, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_NIS_LUMA, P_COUNT }; static VkPipeline g_pipe[P_COUNT]; -static struct fx_target g_t[2], g_mid; +struct fx_context { + struct fx_target targets[2], mid, nissrc; + struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } scene; +}; +#define FX_CONTEXTS (VKP_FG_MAX_GENERATIONS + 2) +static struct fx_context g_contexts[FX_CONTEXTS]; +static int g_context; +#define g_t (g_contexts[g_context].targets) +#define g_mid (g_contexts[g_context].mid) +#define g_nissrc (g_contexts[g_context].nissrc) +static struct fx_target g_smaa_edges, g_smaa_weights, g_smaa_area, g_smaa_search; +static VkBuffer g_smaa_buf; +static VkDeviceMemory g_smaa_mem; +/* Half set: NIS = nis_luma prepass (scene rgb + luma in alpha, scene size) into g_nissrc, then + * nis3 gathers its luma from that alpha, its coefficient banks (nis_coef.h) in a uniform buffer + * at descriptor set 1 (g_pl_nis = {g_dsl, g_coef_dsl}, same push-constant range as g_pl). + * Old set (or no buffer): nis.frag on the scene, P_NIS_LUMA unused. */ +static int g_nis_fast; +static int g_nis_attempted; +static int g_upscale_half; +static VkDescriptorSetLayout g_coef_dsl; +static VkPipelineLayout g_pl_nis; +static VkDescriptorPool g_coef_pool; +static VkDescriptorSet g_coef_ds; +static VkBuffer g_coef_buf; +static VkDeviceMemory g_coef_mem; -static struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } g_scene; -static uint32_t g_ntsc_frame; +#define g_scene (g_contexts[g_context].scene) void vkp_effects_bind_device(VkDevice dev, VkPhysicalDevice pd, const VkPhysicalDeviceMemoryProperties *memprops) { @@ -260,15 +312,22 @@ static void target_destroy(struct fx_target *t) { memset(t, 0, sizeof(*t)); } -static int target_ensure(struct fx_target *t, int w, int h, const char *what) { +#define FX_TARGET_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | \ + VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT) +#define FX_SCRATCH_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT) +#define SMAA_EDGE_FORMAT VK_FORMAT_R8G8_UNORM + +static int target_ensure_format(struct fx_target *t, int w, int h, + VkImageUsageFlags usage, const char *what, + VkFormat format, VkRenderPass render_pass) { if (t->img && t->w == w && t->h == h) return 0; target_destroy(t); VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, .imageType = VK_IMAGE_TYPE_2D, - .format = g_fx_fmt, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1, + /* SMAA's own images need no views in other formats, and the GPU is faster without the flag. */ + .flags = render_pass == g_rp ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0, + .imageType = VK_IMAGE_TYPE_2D, .format = format, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1, .arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL, - .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | - VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, + .usage = usage, .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED}; VkResult r = g_vk.CreateImage(g_dev, &ii, NULL, &t->img); if (r != VK_SUCCESS) { droiddeck_log("error", "effects: %s image %dx%d: vkCreateImage %d", what, w, h, (int)r); return -1; } @@ -284,17 +343,26 @@ static int target_ensure(struct fx_target *t, int w, int h, const char *what) { (unsigned long long)req.size, (int)r); target_destroy(t); return -1; } - g_vk.BindImageMemory(g_dev, t->img, t->mem, 0); - if (!(t->view = make_view(t->img, g_fx_fmt))) { target_destroy(t); return -1; } - VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = g_rp, + r = g_vk.BindImageMemory(g_dev, t->img, t->mem, 0); + if (r != VK_SUCCESS) { + droiddeck_log("error", "effects: %s image %dx%d: vkBindImageMemory %d", what, w, h, (int)r); + target_destroy(t); return -1; + } + if (!(t->view = make_view(t->img, format))) { target_destroy(t); return -1; } + VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = render_pass, .attachmentCount = 1, .pAttachments = &t->view, .width = (uint32_t)w, .height = (uint32_t)h, .layers = 1}; - if (g_vk.CreateFramebuffer(g_dev, &fi, NULL, &t->fb) != VK_SUCCESS) { target_destroy(t); return -1; } + if (render_pass && g_vk.CreateFramebuffer(g_dev, &fi, NULL, &t->fb) != VK_SUCCESS) { target_destroy(t); return -1; } if (!(t->ds = alloc_ds(t->view))) { target_destroy(t); return -1; } t->w = w; t->h = h; return 0; } +static int target_ensure(struct fx_target *t, int w, int h, + VkImageUsageFlags usage, const char *what) { + return target_ensure_format(t, w, h, usage, what, g_fx_fmt, g_rp); +} + static void scene_release(void) { if (g_scene.ds) g_vk.FreeDescriptorSets(g_dev, g_dpool, 1, &g_scene.ds); if (g_scene.view) g_vk.DestroyImageView(g_dev, g_scene.view, NULL); @@ -302,7 +370,53 @@ static void scene_release(void) { } void vkp_effects_forget_image(VkImage img) { - if (img && g_scene.img == img) scene_release(); + int saved = g_context; + for (g_context = 0; g_context < FX_CONTEXTS; g_context++) + if (img && g_scene.img == img) scene_release(); + g_context = saved; +} + +VkImageView vkp_effects_framegen_image_view(VkImage img, int w, int h, VkFormat fmt) { + if (!g_dev || !img || w <= 0 || h <= 0 || fmt == VK_FORMAT_UNDEFINED) return VK_NULL_HANDLE; + + for (int i = 0; i < FX_CONTEXTS; ++i) { + struct fx_context *ctx = &g_contexts[i]; + if (ctx->scene.img == img && ctx->scene.view) return ctx->scene.view; + for (int j = 0; j < 2; ++j) + if (ctx->targets[j].img == img && ctx->targets[j].view) return ctx->targets[j].view; + if (ctx->mid.img == img && ctx->mid.view) return ctx->mid.view; + if (ctx->nissrc.img == img && ctx->nissrc.view) return ctx->nissrc.view; + } + if (g_smaa_edges.img == img && g_smaa_edges.view) return g_smaa_edges.view; + if (g_smaa_weights.img == img && g_smaa_weights.view) return g_smaa_weights.view; + + /* The effects chain can bypass every pass and return the compositor's scene image + * directly. Keep a view for that image in the existing per-context cache so the + * normal image-forget path destroys it before the image itself. */ + int saved = g_context; + g_context = 0; + if (g_scene.img != img || g_scene.view == VK_NULL_HANDLE || + g_scene.w != w || g_scene.h != h) { + scene_release(); + VkImageView view = make_view(img, fmt); + if (!view) { + g_context = saved; + return VK_NULL_HANDLE; + } + g_scene.img = img; + g_scene.view = view; + g_scene.w = w; + g_scene.h = h; + g_scene.ds = VK_NULL_HANDLE; + } + VkImageView result = g_scene.view; + g_context = saved; + return result; +} + +void vkp_effects_release_generated_sources(void) { + for (g_context = 1; g_context < FX_CONTEXTS; g_context++) scene_release(); + g_context = 0; } static int scene_ensure(VkImage img, int w, int h) { @@ -321,7 +435,9 @@ static VkShaderModule shader(const uint32_t *code, size_t size) { return m; } -static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, size_t frag_size, const char *name) { +static VkPipeline post_pipeline_for_renderpass(VkShaderModule vert, + const uint32_t *frag_code, size_t frag_size, VkRenderPass render_pass, + const char *name, VkPipelineLayout layout) { VkShaderModule frag = shader(frag_code, frag_size); if (!frag) { droiddeck_log("error", "effects: %s: vkCreateShaderModule failed", name); return VK_NULL_HANDLE; } VkPipelineShaderStageCreateInfo st[2] = { @@ -346,8 +462,8 @@ static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, VkGraphicsPipelineCreateInfo pi = {.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, .stageCount = 2, .pStages = st, .pVertexInputState = &vi, .pInputAssemblyState = &ia, .pViewportState = &vp, .pRasterizationState = &rs, .pMultisampleState = &ms, - .pColorBlendState = &cb, .pDynamicState = &ds, .layout = g_pl, - .renderPass = g_rp, .subpass = 0}; + .pColorBlendState = &cb, .pDynamicState = &ds, .layout = layout, + .renderPass = render_pass, .subpass = 0}; VkPipeline p = VK_NULL_HANDLE; VkResult r = g_vk.CreateGraphicsPipelines(g_dev, VK_NULL_HANDLE, 1, &pi, NULL, &p); g_vk.DestroyShaderModule(g_dev, frag, NULL); @@ -355,23 +471,135 @@ static VkPipeline post_pipeline(VkShaderModule vert, const uint32_t *frag_code, return p; } +/* The mapped memory of a new host-visible buffer. On failure: NULL, and the caller frees what there is. */ +static void *host_buffer(VkDeviceSize size, VkBufferUsageFlags usage, VkBuffer *buf, VkDeviceMemory *mem) { + VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .size = size, + .usage = usage, .sharingMode = VK_SHARING_MODE_EXCLUSIVE}; + if (g_vk.CreateBuffer(g_dev, &bci, NULL, buf) != VK_SUCCESS) return NULL; + VkMemoryRequirements req; + g_vk.GetBufferMemoryRequirements(g_dev, *buf, &req); + int idx = memtype(req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + if (idx < 0) return NULL; + VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = req.size, .memoryTypeIndex = (uint32_t)idx}; + if (g_vk.AllocateMemory(g_dev, &mai, NULL, mem) != VK_SUCCESS) return NULL; + if (g_vk.BindBufferMemory(g_dev, *buf, *mem, 0) != VK_SUCCESS) return NULL; + void *p = NULL; + return g_vk.MapMemory(g_dev, *mem, 0, size, 0, &p) == VK_SUCCESS ? p : NULL; +} + +static void coef_destroy(void) { + if (g_coef_pool) g_vk.DestroyDescriptorPool(g_dev, g_coef_pool, NULL); /* frees g_coef_ds */ + if (g_coef_buf) g_vk.DestroyBuffer(g_dev, g_coef_buf, NULL); + if (g_coef_mem) g_vk.FreeMemory(g_dev, g_coef_mem, NULL); + if (g_pl_nis) g_vk.DestroyPipelineLayout(g_dev, g_pl_nis, NULL); + if (g_coef_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_coef_dsl, NULL); + g_coef_pool = VK_NULL_HANDLE; g_coef_ds = VK_NULL_HANDLE; g_coef_buf = VK_NULL_HANDLE; + g_coef_mem = VK_NULL_HANDLE; g_pl_nis = VK_NULL_HANDLE; g_coef_dsl = VK_NULL_HANDLE; +} + +/* nis3's coefficient banks: a 4 KB host-visible uniform buffer (scale then usm), filled once. 0 = ok. */ +static int coef_create(void) { + VkDescriptorSetLayoutBinding b = {.binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + .descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT}; + VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &b}; + if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_coef_dsl) != VK_SUCCESS) goto fail; + VkDescriptorSetLayout sets[2] = {g_dsl, g_coef_dsl}; + VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE}; + VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = sets, + .pushConstantRangeCount = 1, .pPushConstantRanges = &pcr}; + if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl_nis) != VK_SUCCESS) goto fail; + void *p = host_buffer(4096, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, &g_coef_buf, &g_coef_mem); + if (!p) goto fail; + memcpy(p, kNisCoefScale, sizeof(kNisCoefScale)); + memcpy((char *)p + sizeof(kNisCoefScale), kNisCoefUsm, sizeof(kNisCoefUsm)); + g_vk.UnmapMemory(g_dev, g_coef_mem); + VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1}; + VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, .maxSets = 1, .poolSizeCount = 1, .pPoolSizes = &ps}; + if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_coef_pool) != VK_SUCCESS) goto fail; + VkDescriptorSetAllocateInfo ai = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, .descriptorPool = g_coef_pool, + .descriptorSetCount = 1, .pSetLayouts = &g_coef_dsl}; + if (g_vk.AllocateDescriptorSets(g_dev, &ai, &g_coef_ds) != VK_SUCCESS) goto fail; + VkDescriptorBufferInfo bi = {.buffer = g_coef_buf, .offset = 0, .range = 4096}; + VkWriteDescriptorSet wr = {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = g_coef_ds, .dstBinding = 0, + .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, .pBufferInfo = &bi}; + g_vk.UpdateDescriptorSets(g_dev, 1, &wr, 0, NULL); + return 0; +fail: + coef_destroy(); + return -1; +} + +static void smaa_tables_destroy(void) { + target_destroy(&g_smaa_area); target_destroy(&g_smaa_search); + if (g_smaa_buf) g_vk.DestroyBuffer(g_dev, g_smaa_buf, NULL); + if (g_smaa_mem) g_vk.FreeMemory(g_dev, g_smaa_mem, NULL); + g_smaa_buf = VK_NULL_HANDLE; g_smaa_mem = VK_NULL_HANDLE; +} + +static int smaa_tables_ensure(void) { + if (g_smaa_buf) return 0; + const VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + unsigned char *p = NULL; + if (target_ensure_format(&g_smaa_area, SMAA_AREA_W, SMAA_AREA_H, usage, "SMAA area table", + VK_FORMAT_R8G8_UNORM, VK_NULL_HANDLE) == 0 && + target_ensure_format(&g_smaa_search, SMAA_SEARCH_W, SMAA_SEARCH_H, usage, "SMAA search table", + VK_FORMAT_R8_UNORM, VK_NULL_HANDLE) == 0) + p = host_buffer(sizeof(kSmaaArea) + sizeof(kSmaaSearch), VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &g_smaa_buf, &g_smaa_mem); + if (!p) { smaa_tables_destroy(); return -1; } + memcpy(p, kSmaaArea, sizeof(kSmaaArea)); + memcpy(p + sizeof(kSmaaArea), kSmaaSearch, sizeof(kSmaaSearch)); + g_vk.UnmapMemory(g_dev, g_smaa_mem); + return 0; +} + +/* nis_luma keeps luma in the target's alpha: only formats with at least 8 alpha bits (not the + * 2-bit alpha of the 10-bit HDR composition format) can hold it. */ +static int fx_alpha_holds_luma(VkFormat f) { + return f == VK_FORMAT_R8G8B8A8_UNORM || f == VK_FORMAT_B8G8R8A8_UNORM || + f == VK_FORMAT_R16G16B16A16_SFLOAT || f == VK_FORMAT_R16G16B16A16_UNORM; +} + +/* The half-precision upscaler set unless debug.droiddeck.upscale.shaders is "old" (the fp32 + * shaders, for A/B comparisons). */ +static int upscale_half_set(void) { +#ifdef __ANDROID__ + char v[PROP_VALUE_MAX] = {0}; + if (__system_property_get("debug.droiddeck.upscale.shaders", v) > 0 && strcmp(v, "old") == 0) return 0; +#endif + return 1; +} + static void objects_destroy(void) { if (!g_dev) return; - scene_release(); - target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid); + int saved = g_context; + for (g_context = 0; g_context < FX_CONTEXTS; g_context++) { + scene_release(); + target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid); + target_destroy(&g_nissrc); + } + g_context = saved; + target_destroy(&g_smaa_edges); target_destroy(&g_smaa_weights); + smaa_tables_destroy(); for (int i = 0; i < P_COUNT; i++) { if (g_pipe[i]) g_vk.DestroyPipeline(g_dev, g_pipe[i], NULL); g_pipe[i] = VK_NULL_HANDLE; } if (g_dpool) g_vk.DestroyDescriptorPool(g_dev, g_dpool, NULL); if (g_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL); + coef_destroy(); if (g_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_dsl, NULL); if (g_sampler) g_vk.DestroySampler(g_dev, g_sampler, NULL); + if (g_smaa_edge_rp) g_vk.DestroyRenderPass(g_dev, g_smaa_edge_rp, NULL); + if (g_smaa_weights_rp) g_vk.DestroyRenderPass(g_dev, g_smaa_weights_rp, NULL); if (g_rp) g_vk.DestroyRenderPass(g_dev, g_rp, NULL); - g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE; g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE; + g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE; g_dsl = VK_NULL_HANDLE; + g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE; + g_smaa_edge_rp = VK_NULL_HANDLE; g_smaa_weights_rp = VK_NULL_HANDLE; + g_nis_fast = 0; g_nis_attempted = 0; g_upscale_half = 0; g_ready = 0; } void vkp_effects_destroy(void) { objects_destroy(); g_dev = VK_NULL_HANDLE; } -void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt) { +void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq) { + g_scene_is_pq = scene_is_pq != 0; if (target_fmt != g_fx_fmt) { if (g_ready) objects_destroy(); g_fx_fmt = target_fmt; @@ -384,7 +612,9 @@ void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt) { : target_fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? "the HDR picture for frame generation" : "the HDR composition's picture: PQ, or tone-mapped SDR with HDR output off"); } else if (scene_fmt != g_scene_fmt) { - scene_release(); + int saved = g_context; + for (g_context = 0; g_context < FX_CONTEXTS; g_context++) scene_release(); + g_context = saved; g_scene_fmt = scene_fmt; } } @@ -413,6 +643,15 @@ static int objects_ensure(void) { .subpassCount = 1, .pSubpasses = &sub, .dependencyCount = 2, .pDependencies = deps}; if (g_vk.CreateRenderPass(g_dev, &rci, NULL, &g_rp) != VK_SUCCESS) goto fail; + VkAttachmentDescription smaa_att = att; + smaa_att.format = FX_FORMAT; + smaa_att.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; /* SMAA.hlsl discards pixels without an edge */ + VkRenderPassCreateInfo smaa_rci = rci; + smaa_rci.pAttachments = &smaa_att; + if (g_vk.CreateRenderPass(g_dev, &smaa_rci, NULL, &g_smaa_weights_rp) != VK_SUCCESS) goto fail; + smaa_att.format = SMAA_EDGE_FORMAT; + if (g_vk.CreateRenderPass(g_dev, &smaa_rci, NULL, &g_smaa_edge_rp) != VK_SUCCESS) goto fail; + VkSamplerCreateInfo sci = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_LINEAR, .minFilter = VK_FILTER_LINEAR, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, @@ -425,36 +664,21 @@ static int objects_ensure(void) { VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &b}; if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_dsl) != VK_SUCCESS) goto fail; VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE}; - VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 1, .pSetLayouts = &g_dsl, + VkDescriptorSetLayout set_layouts[3] = {g_dsl, g_dsl, g_dsl}; + VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 3, .pSetLayouts = set_layouts, .pushConstantRangeCount = 1, .pPushConstantRanges = &pcr}; if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail; - VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 8}; + VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, FX_CONTEXTS * 5 + 4}; VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, - .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = 8, + .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = FX_CONTEXTS * 5 + 4, .poolSizeCount = 1, .pPoolSizes = &ps}; if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail; - VkShaderModule vert = shader(upscale_vert_code, sizeof(upscale_vert_code)); - if (!vert) goto fail; -#define MK(slot, code, name) do { g_pipe[slot] = post_pipeline(vert, code, sizeof(code), name); if (!g_pipe[slot]) { g_vk.DestroyShaderModule(g_dev, vert, NULL); goto fail; } } while (0) - MK(P_SGSR, sgsr_code, "sgsr"); - MK(P_SGSR_HQ, sgsr_quality_code, "sgsr_quality"); - MK(P_NIS, nis_code, "nis"); - MK(P_EASU, fsr_easu_code, "fsr_easu"); - MK(P_RCAS, fsr_rcas_code, "fsr_rcas"); - MK(P_CAS, cas_code, "cas"); - MK(P_COLOR, color_code, "color"); - MK(P_FXAA, fxaa_code, "fxaa"); - MK(P_SMAA, smaa_code, "smaa"); - MK(P_TOON, toon_code, "toon"); - MK(P_HDR, hdr_code, "hdr"); - MK(P_NTSC, ntsc_code, "ntsc"); - MK(P_CRT, crt_code, "crt"); - MK(P_DEBAND, deband_code, "deband"); -#undef MK - g_vk.DestroyShaderModule(g_dev, vert, NULL); + g_upscale_half = upscale_half_set(); + g_nis_fast = 0; + g_nis_attempted = 0; g_ready = 1; - droiddeck_log("effects", "chain ready: 14 pipelines (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, SMAA, Toon, HDR, NTSC, CRT, deband) on %s", vkp_gpu_name()); + droiddeck_log("effects", "shared resources ready on %s; effect pipelines are created when needed", vkp_gpu_name()); return 0; fail: objects_destroy(); @@ -463,6 +687,95 @@ fail: return -1; } +static int chain_failed(void) { + objects_destroy(); + g_ready = -1; + droiddeck_log("error", "effects: the screen-effect chain could not be built on this driver; effects are off for this session"); + return -1; +} + +static int pipelines_ensure(int spatial, const struct fx_settings *s) { + VkShaderModule vert = VK_NULL_HANDLE; +#define MKL(needed, slot, code, name, render_pass, layout) do { \ + if ((needed) && !g_pipe[slot]) { \ + if (!vert && !(vert = shader(upscale_vert_code, sizeof(upscale_vert_code)))) goto fail; \ + g_pipe[slot] = post_pipeline_for_renderpass(vert, code, sizeof(code), render_pass, name, layout); \ + if (!g_pipe[slot]) goto fail; \ + } \ +} while (0) +#define MK(needed, slot, code, name) MKL(needed, slot, code, name, g_rp, g_pl) + if (spatial == 3) { + if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code, "sgsr_half"); + else MK(1, P_SGSR, sgsr_code, "sgsr"); + } + if (spatial == 8) { + if (g_upscale_half) MK(1, P_SGSR_HQ, sgsr_quality_half_code, "sgsr_quality_half"); + else MK(1, P_SGSR_HQ, sgsr_quality_code, "sgsr_quality"); + } + if (spatial == 4 || spatial == 5) { + if (g_upscale_half) MK(1, P_EASU, fsr_easu_half_code, "fsr_easu_half"); + else MK(1, P_EASU, fsr_easu_code, "fsr_easu"); + if (s->sharp_pct != 0) { + if (g_upscale_half) MK(1, P_RCAS, fsr_rcas_half_code, "fsr_rcas_half"); + else MK(1, P_RCAS, fsr_rcas_code, "fsr_rcas"); + } + } + if (spatial == 6) { + if (g_upscale_half) MK(1, P_RCAS, fsr_rcas_half_code, "fsr_rcas_half"); + else MK(1, P_RCAS, fsr_rcas_code, "fsr_rcas"); + } + if (spatial == 7) { + if (g_upscale_half && !g_nis_attempted) { + g_nis_attempted = 1; + if (!fx_alpha_holds_luma(g_fx_fmt)) + droiddeck_log("effects", "NIS uses nis.frag: the chain format has no 8-bit alpha for the luma prepass"); + else if (coef_create() != 0) + droiddeck_log("effects", "NIS coefficient buffer unavailable; NIS uses nis.frag"); + else { + if (!vert && !(vert = shader(upscale_vert_code, sizeof(upscale_vert_code)))) goto fail; + g_pipe[P_NIS] = post_pipeline_for_renderpass(vert, nis3_half_code, sizeof(nis3_half_code), g_rp, "nis3_half", g_pl_nis); + if (g_pipe[P_NIS]) + g_pipe[P_NIS_LUMA] = post_pipeline_for_renderpass(vert, nis_luma_half_code, sizeof(nis_luma_half_code), g_rp, "nis_luma_half", g_pl); + if (g_pipe[P_NIS] && g_pipe[P_NIS_LUMA]) g_nis_fast = 1; + else { + if (g_pipe[P_NIS]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS], NULL); + if (g_pipe[P_NIS_LUMA]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS_LUMA], NULL); + g_pipe[P_NIS] = VK_NULL_HANDLE; + g_pipe[P_NIS_LUMA] = VK_NULL_HANDLE; + coef_destroy(); + droiddeck_log("effects", "fast NIS pipelines failed to build; NIS uses nis.frag"); + } + } + } + if (!g_nis_fast) MK(1, P_NIS, nis_code, "nis"); + else if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code, "sgsr_half"); + } + if (cas_active(s)) { + if (g_upscale_half) MK(1, P_CAS, cas_ffx_half_code, "cas_ffx_half"); + else MK(1, P_CAS, cas_code, "cas"); + } + if (s->color_on && !(s->toon && g_fx_fmt == FX_FORMAT)) MK(1, P_COLOR, color_code, "color"); + if (s->aa_mode == 1 || s->aa_mode == 2) MK(1, P_FXAA, fxaa_code, "fxaa"); + if (s->aa_mode == 2) { + MKL(1, P_SMAA_EDGE, smaa_edge_code, "smaa_edge", g_smaa_edge_rp, g_pl); + MKL(1, P_SMAA_WEIGHTS, smaa_weights_code, "smaa_weights", g_smaa_weights_rp, g_pl); + MK(1, P_SMAA_BLEND, smaa_blend_code, "smaa_blend"); + } + if (s->toon && s->color_on && g_fx_fmt == FX_FORMAT) MK(1, P_TOON_COLOR, toon_color_code, "toon_color"); + else if (s->toon) MK(1, P_TOON, toon_code, "toon"); + if (s->hdr_on) MK(1, P_HDR, hdr_code, "hdr"); + if (s->ntsc) MK(1, P_NTSC, ntsc_code, "ntsc"); + if (s->crt) MK(1, P_CRT, crt_code, "crt"); + if (deband_active(s)) MK(1, P_DEBAND, deband_code, "deband"); +#undef MK +#undef MKL + if (vert) g_vk.DestroyShaderModule(g_dev, vert, NULL); + return 0; +fail: + if (vert) g_vk.DestroyShaderModule(g_dev, vert, NULL); + return chain_failed(); +} + static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags src_stage, VkAccessFlags src_access, @@ -474,30 +787,74 @@ static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImag g_vk.CmdPipelineBarrier(cmd, src_stage, dst_stage, 0, 0, NULL, 0, NULL, 1, &b); } -static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst, VkDescriptorSet src, - const void *pc, uint32_t pcsz) { - VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = g_rp, .framebuffer = dst->fb, - .renderArea = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}}; - VkViewport vp = {0, 0, (float)dst->w, (float)dst->h, 0, 1}; - VkRect2D sc = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}; +/* The tables are copied into place in every frame: a recorded frame can be dropped before it is submitted. */ +static void smaa_tables_copy(VkCommandBuffer cmd) { + const VkBufferImageCopy area = {.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, + .imageExtent = {SMAA_AREA_W, SMAA_AREA_ROWS, 1}}; + const VkBufferImageCopy search = {.bufferOffset = sizeof(kSmaaArea), .imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, + .imageExtent = {SMAA_SEARCH_W, SMAA_SEARCH_H, 1}}; + const struct { VkImage img; const VkBufferImageCopy *copy; } t[2] = {{g_smaa_area.img, &area}, {g_smaa_search.img, &search}}; + for (int i = 0; i < 2; i++) { + barrier(cmd, t[i].img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT); + g_vk.CmdCopyBufferToImage(cmd, g_smaa_buf, t[i].img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, t[i].copy); + barrier(cmd, t[i].img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT); + } +} + +static void pass_sets(VkCommandBuffer cmd, VkRenderPass render_pass, VkPipeline p, struct fx_target *dst, + const VkDescriptorSet *src, uint32_t count, const void *pc, uint32_t pcsz) { + const VkClearValue clear = {0}; + VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = render_pass, .framebuffer = dst->fb, + .renderArea = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}, + .clearValueCount = 1, .pClearValues = &clear}; g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE); - g_vk.CmdSetViewport(cmd, 0, 1, &vp); - g_vk.CmdSetScissor(cmd, 0, 1, &sc); g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p); - g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, 1, &src, 0, NULL); + g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, count, src, 0, NULL); + if (g_nis_fast && p == g_pipe[P_NIS] && g_coef_ds) /* nis3: coefficient banks at set 1 */ + g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl_nis, 1, 1, &g_coef_ds, 0, NULL); g_vk.CmdPushConstants(cmd, g_pl, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, pcsz, pc); g_vk.CmdDraw(cmd, 4, 1, 0, 0); g_vk.CmdEndRenderPass(cmd); } +static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst, + VkDescriptorSet src, const void *pc, uint32_t pcsz) { + pass_sets(cmd, g_rp, p, dst, &src, 1, pc, pcsz); +} + static const float FULL_NDC[4] = {-1.0f, -1.0f, 1.0f, 1.0f}; #define SET_NDC(pc) memcpy((pc).ndc, FULL_NDC, sizeof(FULL_NDC)) -VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, - int out_w, int out_h, int *res_w, int *res_h) { +struct fx_source_state { + VkImageLayout layout; + VkPipelineStageFlags stage; + VkAccessFlags access; +}; + +/* NIS here is the SDR implementation and is documented for <=2x upscales: other outputs run FSR instead. */ +static int nis_falls_back(int scene_w, int scene_h, int cw, int ch) { + return g_scene_is_pq || cw < scene_w || ch < scene_h || (double)cw > (double)scene_w * 2.0 || + (double)ch > (double)scene_h * 2.0; +} + +static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, + int out_w, int out_h, int *res_w, int *res_h, + VkImageLayout input_layout, const struct fx_settings *frozen, + struct fx_source_state *source_state) { + struct fx_settings snapshot; const struct fx_settings *s; - vkp_effects_sync(); - s = &g_cur; + if (frozen) { + snapshot = *frozen; + } else { + vkp_effects_sync(); + pthread_mutex_lock(&g_lock); + snapshot = g_cur; + pthread_mutex_unlock(&g_lock); + } + s = &snapshot; *res_w = scene_w; *res_h = scene_h; int cw = out_w > 0 ? out_w : scene_w, ch = out_h > 0 ? out_h : scene_h; @@ -508,21 +865,55 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce const int upscaling = cw > scene_w || ch > scene_h; int spatial = 0; if (spatial_mode(s->scaling) && (s->scaling == 6 || upscaling)) spatial = s->scaling; + const int nis_fallback = spatial == 7 && nis_falls_back(scene_w, scene_h, cw, ch); + static int last_nis_fallback = 0; + const int was_nis_fallback = + __atomic_exchange_n(&last_nis_fallback, nis_fallback, __ATOMIC_RELAXED); + if (nis_fallback) { + spatial = 4; /* FSR fallback; keep the saved NIS selection unchanged. */ + if (!was_nis_fallback) + droiddeck_log("effects", "NIS unsupported for this output; FSR fallback active"); + } else if (was_nis_fallback && s->scaling == 7) { + droiddeck_log("effects", "NIS supported again; NIS active"); + } const int nfx = effect_count(s); const int resize = cw != scene_w || ch != scene_h; - const int npasses = ((spatial || resize) ? 1 : 0) + nfx; + const int fuse_toon_color = s->toon && s->color_on && g_fx_fmt == FX_FORMAT; + const int fuse_fxaa_toon = 0; + const int chain_passes = ((spatial || resize) ? 1 : 0) + + effect_count(s) - (fuse_toon_color ? 1 : 0) - + (fuse_fxaa_toon ? 1 : 0); + + if ((spatial || nfx) && objects_ensure() == 0 && pipelines_ensure(spatial, s) == 0 && scene_ensure(scene, scene_w, scene_h) == 0 && + target_ensure(&g_t[0], cw, ch, FX_TARGET_USAGE, "chain") == 0 && (chain_passes < 2 || target_ensure(&g_t[1], cw, ch, FX_TARGET_USAGE, "chain") == 0) && + (!(spatial == 4 || spatial == 5) || s->sharp_pct == 0 || + target_ensure(&g_mid, cw, ch, FX_SCRATCH_USAGE, "EASU") == 0)) { + if (s->aa_mode == 2 && + (target_ensure_format(&g_smaa_edges, cw, ch, FX_SCRATCH_USAGE, + "SMAA edges", SMAA_EDGE_FORMAT, g_smaa_edge_rp) != 0 || + target_ensure_format(&g_smaa_weights, cw, ch, FX_SCRATCH_USAGE, + "SMAA weights", FX_FORMAT, g_smaa_weights_rp) != 0 || + smaa_tables_ensure() != 0)) { + droiddeck_log("error", "effects: SMAA scratch allocation failed; falling back to FXAA"); + snapshot.aa_mode = 1; + s = &snapshot; + } - if ((spatial || nfx) && objects_ensure() == 0 && scene_ensure(scene, scene_w, scene_h) == 0 && - target_ensure(&g_t[0], cw, ch, "chain") == 0 && (npasses < 2 || target_ensure(&g_t[1], cw, ch, "chain") == 0) && - (!(spatial == 4 || spatial == 5) || target_ensure(&g_mid, cw, ch, "EASU") == 0)) { VkDescriptorSet cur_ds; struct fx_target *cur = NULL; #define FREE_TARGET() ((cur == &g_t[0]) ? &g_t[1] : &g_t[0]) const float sharp01 = (float)s->sharp_pct / 100.0f; + VkViewport chain_vp = {0, 0, (float)cw, (float)ch, 0, 1}; + VkRect2D chain_sc = {{0, 0}, {(uint32_t)cw, (uint32_t)ch}}; + g_vk.CmdSetViewport(cmd, 0, 1, &chain_vp); + g_vk.CmdSetScissor(cmd, 0, 1, &chain_sc); + if (spatial) { - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT); struct fx_target *dst = FREE_TARGET(); if (spatial == 3 || spatial == 8 || spatial == 7) { @@ -531,7 +922,31 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce pc.vp[0] = 1.0f / (float)scene_w; pc.vp[1] = 1.0f / (float)scene_h; pc.vp[2] = (float)scene_w; pc.vp[3] = (float)scene_h; pc.edge = spatial == 7 ? sharp01 : 0.5f + sharp01 * 4.0f; - pass(cmd, g_pipe[spatial == 3 ? P_SGSR : spatial == 8 ? P_SGSR_HQ : P_NIS], dst, g_scene.ds, &pc, sizeof(pc)); + VkDescriptorSet src = g_scene.ds; + int nis_pipe = P_NIS; + if (spatial == 7 && g_nis_fast && + target_ensure(&g_nissrc, scene_w, scene_h, FX_SCRATCH_USAGE, "NIS luma") != 0) { + /* nis3 needs the prepass image; without it this frame takes SGSR from the scene + * instead of dropping every effect */ + static int warned; + if (!__atomic_exchange_n(&warned, 1, __ATOMIC_RELAXED)) + droiddeck_log("error", "effects: NIS luma target allocation failed; SGSR instead"); + nis_pipe = P_SGSR; + pc.edge = 0.5f + sharp01 * 4.0f; + } else if (spatial == 7 && g_nis_fast) { + /* NIS prepass: scene -> g_nissrc 1:1 (rgb + luma in alpha); only ndc is read. */ + struct pc_res pl = {0}; + SET_NDC(pl); + VkViewport scene_vp = {0, 0, (float)scene_w, (float)scene_h, 0, 1}; + VkRect2D scene_sc = {{0, 0}, {(uint32_t)scene_w, (uint32_t)scene_h}}; + g_vk.CmdSetViewport(cmd, 0, 1, &scene_vp); + g_vk.CmdSetScissor(cmd, 0, 1, &scene_sc); + pass(cmd, g_pipe[P_NIS_LUMA], &g_nissrc, g_scene.ds, &pl, sizeof(pl.ndc)); + g_vk.CmdSetViewport(cmd, 0, 1, &chain_vp); + g_vk.CmdSetScissor(cmd, 0, 1, &chain_sc); + src = g_nissrc.ds; + } + pass(cmd, g_pipe[spatial == 3 ? P_SGSR : spatial == 8 ? P_SGSR_HQ : nis_pipe], dst, src, &pc, sizeof(pc)); } else if (spatial == 6) { struct pc_rcas pc = {0}; SET_NDC(pc); @@ -546,46 +961,58 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce SET_NDC(e); easu_con(&e, (float)scene_w, (float)scene_h, (float)cw, (float)ch); e.outW = (float)cw; e.outH = (float)ch; - pass(cmd, g_pipe[P_EASU], &g_mid, g_scene.ds, &e, sizeof(e)); - SET_NDC(r); - rcas_con(&r, sharp01); - r.outW = (float)cw; r.outH = (float)ch; - pass(cmd, g_pipe[P_RCAS], dst, g_mid.ds, &r, sizeof(r)); + struct fx_target *easu_dst = sharp01 == 0.0f ? dst : &g_mid; + pass(cmd, g_pipe[P_EASU], easu_dst, g_scene.ds, &e, sizeof(e)); + if (sharp01 != 0.0f) { + SET_NDC(r); + rcas_con(&r, sharp01); + r.outW = (float)cw; r.outH = (float)ch; + pass(cmd, g_pipe[P_RCAS], dst, g_mid.ds, &r, sizeof(r)); + } } cur = dst; cur_ds = dst->ds; } else if (resize) { struct fx_target *dst = FREE_TARGET(); - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); barrier(cmd, dst->img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT); VkImageBlit bl = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .srcOffsets = {{0, 0, 0}, {scene_w, scene_h, 1}}, .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{0, 0, 0}, {cw, ch, 1}}}; g_vk.CmdBlitImage(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst->img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, &bl, vkp_effects_blit_filter()); + 1, &bl, s->scaling == 2 ? VK_FILTER_NEAREST : VK_FILTER_LINEAR); barrier(cmd, dst->img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT); cur = dst; cur_ds = dst->ds; } else { - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT); cur = NULL; cur_ds = g_scene.ds; } - enum { FX_FXAA, FX_SMAA, FX_TOON, FX_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND }; + enum { FX_FXAA, FX_FXAA_TOON, FX_SMAA, FX_TOON, FX_COLOR, FX_TOON_COLOR, FX_CAS, FX_HDR, FX_NTSC, FX_CRT, FX_DEBAND }; int order[8], n = 0; - if (s->aa_mode == 1) order[n++] = FX_FXAA; + if (s->aa_mode == 1) + order[n++] = fuse_fxaa_toon ? FX_FXAA_TOON : FX_FXAA; else if (s->aa_mode == 2) order[n++] = FX_SMAA; - if (s->toon) order[n++] = FX_TOON; - if (s->color_on) order[n++] = FX_COLOR; + if (s->toon && s->color_on && g_fx_fmt == FX_FORMAT) { + order[n++] = FX_TOON_COLOR; + } else { + if (s->toon && !fuse_fxaa_toon) order[n++] = FX_TOON; + if (s->color_on) order[n++] = FX_COLOR; + } if (cas_active(s)) order[n++] = FX_CAS; if (s->hdr_on) order[n++] = FX_HDR; if (s->ntsc) order[n++] = FX_NTSC; if (s->crt) order[n++] = FX_CRT; - if (s->deband_on) order[n++] = FX_DEBAND; + if (deband_active(s)) order[n++] = FX_DEBAND; for (int i = 0; i < n; i++) { struct fx_target *dst = FREE_TARGET(); struct pc_res pr = {0}; @@ -593,8 +1020,32 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce pr.res[0] = (float)cw; pr.res[1] = (float)ch; switch (order[i]) { case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break; - case FX_SMAA: pass(cmd, g_pipe[P_SMAA], dst, cur_ds, &pr, sizeof(pr)); break; + case FX_FXAA_TOON: pass(cmd, g_pipe[P_FXAA_TOON], dst, cur_ds, &pr, sizeof(pr)); break; + case FX_SMAA: { + struct pc_smaa pc = {.metrics = {1.0f / (float)cw, 1.0f / (float)ch, (float)cw, (float)ch}}; + const VkDescriptorSet weigh[3] = {g_smaa_edges.ds, g_smaa_area.ds, g_smaa_search.ds}; + const VkDescriptorSet blend[2] = {cur_ds, g_smaa_weights.ds}; + SET_NDC(pc); + smaa_tables_copy(cmd); + pass_sets(cmd, g_smaa_edge_rp, g_pipe[P_SMAA_EDGE], &g_smaa_edges, &cur_ds, 1, &pc, sizeof(pc)); + pass_sets(cmd, g_smaa_weights_rp, g_pipe[P_SMAA_WEIGHTS], &g_smaa_weights, weigh, 3, &pc, sizeof(pc)); + pass_sets(cmd, g_rp, g_pipe[P_SMAA_BLEND], dst, blend, 2, &pc, sizeof(pc)); + break; + } case FX_TOON: pass(cmd, g_pipe[P_TOON], dst, cur_ds, &pr, sizeof(pr)); break; + case FX_TOON_COLOR: { + struct pc_toon_color pc = {0}; + SET_NDC(pc); + pc.res[0] = (float)cw; + pc.res[1] = (float)ch; + pc.b = s->brightness; + pc.c = s->contrast; + pc.g = s->gamma; + pc.s = s->saturation; + pass(cmd, g_pipe[P_TOON_COLOR], dst, cur_ds, + &pc, sizeof(pc)); + break; + } case FX_COLOR: { struct pc_color pc = {0}; SET_NDC(pc); @@ -605,7 +1056,6 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce case FX_CAS: pr.extra = (float)s->cas_pct / 100.0f; pass(cmd, g_pipe[P_CAS], dst, cur_ds, &pr, sizeof(pr)); break; case FX_HDR: pass(cmd, g_pipe[P_HDR], dst, cur_ds, &pr, sizeof(pr)); break; case FX_NTSC: - pr.extra = (float)(g_ntsc_frame++ & 3u); pass(cmd, g_pipe[P_NTSC], dst, cur_ds, &pr, sizeof(pr)); break; case FX_CRT: pass(cmd, g_pipe[P_CRT], dst, cur_ds, &pr, sizeof(pr)); break; @@ -628,8 +1078,69 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce return scene; } - barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, + if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT}; + barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); return scene; } + +VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, + int out_w, int out_h, int *res_w, int *res_h) { + return effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL, NULL); +} + +int vkp_effects_prepare_generated(int in_w, int in_h, int out_w, int out_h) { + vkp_effects_sync(); + pthread_mutex_lock(&g_lock); + g_generated_settings = g_cur; + pthread_mutex_unlock(&g_lock); + int spatial = g_generated_settings.scaling; + if (!spatial_mode(spatial) || spatial == 6 || effect_count(&g_generated_settings) != 0) return 0; + /* Build the spatial filter's pipelines now, before frame generation records commands that sample the + * chain's views: one failing later in the same pass would tear the chain down (chain_failed) under a + * recorded command buffer. Build only what effects_run will use for this output, as it decides it: + * NIS on an output it hands to FSR builds FSR, so a NIS that cannot build here costs nothing. */ + int cw = out_w > FX_MAX_DIM ? FX_MAX_DIM : out_w < 1 ? 1 : out_w; + int ch = out_h > FX_MAX_DIM ? FX_MAX_DIM : out_h < 1 ? 1 : out_h; + if (cw <= in_w && ch <= in_h) return 1; /* clamped, it no longer upscales: effects_run builds no filter */ + if (spatial == 7 && nis_falls_back(in_w, in_h, cw, ch)) spatial = 4; + if (objects_ensure() != 0 || pipelines_ensure(spatial, &g_generated_settings) != 0) return 0; + return 1; +} + +VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h, + int *res_w, int *res_h) { + struct fx_settings settings = g_generated_settings; + settings.scaling = 0; + return effects_run(cmd, scene, w, h, w, h, res_w, res_h, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &settings, NULL); +} + +VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, + int out_w, int out_h, int slot, int *res_w, int *res_h) { + if (slot < 0 || slot > VKP_FG_MAX_GENERATIONS) { + *res_w = scene_w; *res_h = scene_h; + return scene; + } + g_context = slot + 1; + struct fx_source_state source_state = {0}; + VkImage result = effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h, + VK_IMAGE_LAYOUT_GENERAL, &g_generated_settings, &source_state); + if (result != scene) { + barrier(cmd, result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + barrier(cmd, scene, source_state.layout, VK_IMAGE_LAYOUT_GENERAL, + source_state.stage, source_state.access, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT); + } else if (source_state.layout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { + barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT); + } + g_context = 0; + return result; +} diff --git a/app/src/main/cpp/waylandcomp/src/effects_chain.h b/app/src/main/cpp/waylandcomp/src/effects_chain.h index bb1ca5ae1f..b85becc0a5 100644 --- a/app/src/main/cpp/waylandcomp/src/effects_chain.h +++ b/app/src/main/cpp/waylandcomp/src/effects_chain.h @@ -18,12 +18,19 @@ VkFilter vkp_effects_blit_filter(void); VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, int out_w, int out_h, int *res_w, int *res_h); +int vkp_effects_prepare_generated(int in_w, int in_h, int out_w, int out_h); +void vkp_effects_release_generated_sources(void); +VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h, + int *res_w, int *res_h); +VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h, + int out_w, int out_h, int slot, int *res_w, int *res_h); void vkp_effects_destroy(void); void vkp_effects_forget_image(VkImage img); +VkImageView vkp_effects_framegen_image_view(VkImage img, int w, int h, VkFormat fmt); -void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt); +void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq); void vkp_effects_set_scaling(int mode); void vkp_effects_set_upscale_sharpness(int pct); diff --git a/app/src/main/cpp/waylandcomp/src/frame_acquire.h b/app/src/main/cpp/waylandcomp/src/frame_acquire.h new file mode 100644 index 0000000000..44ff28333a --- /dev/null +++ b/app/src/main/cpp/waylandcomp/src/frame_acquire.h @@ -0,0 +1,39 @@ +#ifndef DD_FRAME_ACQUIRE_H +#define DD_FRAME_ACQUIRE_H +#include +#include +#include +#include +#include + +/* A zero-initialized slot owns no descriptor. Only an already successful + * sync_file can enter this slot; display-side release ownership is separate. */ +struct dd_frame_acquire { int fd_plus_one; }; +enum dd_frame_acquire_result { DD_ACQUIRE_OK, DD_ACQUIRE_DUPLICATE, DD_ACQUIRE_INVALID }; + +static inline void dd_frame_acquire_clear(struct dd_frame_acquire *f) { + if (f->fd_plus_one) close(f->fd_plus_one - 1); + f->fd_plus_one = 0; +} + +static inline enum dd_frame_acquire_result +dd_frame_acquire_set(struct dd_frame_acquire *f, int fd) { + enum dd_frame_acquire_result result; + struct sync_file_info info = {0}; + if (f->fd_plus_one) result = DD_ACQUIRE_DUPLICATE; + else if (fd < 0 || fd == INT_MAX || ioctl(fd, SYNC_IOC_FILE_INFO, &info) != 0 || + info.status != 1 || info.num_fences == 0) result = DD_ACQUIRE_INVALID; + else { + f->fd_plus_one = fd + 1; + return DD_ACQUIRE_OK; + } + if (fd >= 0) close(fd); + return result; +} + +static inline int dd_frame_acquire_dup(const struct dd_frame_acquire *f) { + if (!f->fd_plus_one) return -1; /* Legacy: no explicit attachment proof. */ + int fd = fcntl(f->fd_plus_one - 1, F_DUPFD_CLOEXEC, 0); + return fd < 0 ? -2 : fd; /* Do not re-enter the legacy direct path. */ +} +#endif diff --git a/app/src/main/cpp/waylandcomp/src/frame_worker_peer.h b/app/src/main/cpp/waylandcomp/src/frame_worker_peer.h new file mode 100644 index 0000000000..989e59b336 --- /dev/null +++ b/app/src/main/cpp/waylandcomp/src/frame_worker_peer.h @@ -0,0 +1,81 @@ +#ifndef DD_WORKER_PEER_H +#define DD_WORKER_PEER_H +#include +#include +#include +#include +#include +#include +#include + +/* Model of one app-issued, session-bound authorization record. No callers, + * property access, proc traversal, or authorization is installed by this file. */ +struct dd_worker_grant { + uint32_t owner, uid, pid, dev_major, dev_minor; + uint64_t start_ticks, ino, expires; + const char *canonical_file; + bool app_launch_verified, final_go; +}; + +enum dd_worker_stat_result { + DD_WORKER_STAT_OK, DD_WORKER_STAT_DENIED, DD_WORKER_STAT_HIDDEN, DD_WORKER_STAT_OPEN, + DD_WORKER_STAT_READ, DD_WORKER_STAT_PARSE, DD_WORKER_STAT_ZERO, +}; + +static inline enum dd_worker_stat_result dd_worker_parse_start(const char *line, uint64_t *out) { + const char *p = strrchr(line, ')'); + if (!p || p[1] != ' ' || !p[2] || p[3] != ' ') return DD_WORKER_STAT_PARSE; + p += 2; + // State is field 3. The starttime (22) is always followed by vsize (23). + for (int field = 3; field < 22; ++field) { + p = strchr(p, ' '); + if (!p) return DD_WORKER_STAT_PARSE; + while (*p == ' ') ++p; + } + char *end; + if (*p < '0' || *p > '9') return DD_WORKER_STAT_PARSE; + errno = 0; + uint64_t value = strtoull(p, &end, 10); + if (errno || end == p || *end != ' ') return DD_WORKER_STAT_PARSE; + if (!value) return DD_WORKER_STAT_ZERO; + *out = value; + return DD_WORKER_STAT_OK; +} + +static inline enum dd_worker_stat_result dd_worker_open_failure(int error) { + if (error == EACCES || error == EPERM) return DD_WORKER_STAT_DENIED; + if (error == ENOENT || error == ESRCH) return DD_WORKER_STAT_HIDDEN; + return DD_WORKER_STAT_OPEN; +} + +static inline bool dd_worker_receipt_allows_reserve(enum dd_worker_stat_result stat, + uint64_t raw, uint64_t receipt) { + if (!receipt) return false; + if (stat == DD_WORKER_STAT_OK) return raw == receipt; + // Only a visibility denial can defer the broker-side stat check, not any + // bad read, malformed record, mismatched timestamp, or other open error. + return stat == DD_WORKER_STAT_DENIED || stat == DD_WORKER_STAT_HIDDEN; +} + +static inline bool dd_worker_map_matches(const struct dd_worker_grant *g, const char *line) { + unsigned major, minor; + uint64_t lo, hi, off, ino; + int prefix = 0; + char mode[5]; + if (!g->canonical_file || !*g->canonical_file || + sscanf(line, "%" SCNx64 "-%" SCNx64 " %4s %" SCNx64 " %x:%x %" SCNu64 " %n", + &lo,&hi,mode,&off,&major,&minor,&ino,&prefix)!=7 || + prefix <= 0 || hi <= lo || strlen(mode)!=4 || mode[2]!='x' || + major!=g->dev_major || minor!=g->dev_minor || !ino || ino!=g->ino) + return false; + size_t path_len=strcspn(line+prefix,"\r\n"); + return strlen(g->canonical_file)==path_len && !memcmp(line+prefix,g->canonical_file,path_len); +} + +static inline bool dd_worker_grant_matches(const struct dd_worker_grant *g, uint32_t owner, + uint32_t uid, uint32_t pid, uint64_t start, uint64_t now, const char *executable_map) { + return g && g->app_launch_verified && g->final_go && owner && owner==g->owner && + uid==g->uid && pid>1 && pid==g->pid && start && start==g->start_ticks && + nowexpires && executable_map && dd_worker_map_matches(g,executable_map); +} +#endif diff --git a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c index d29b328a05..b402dc0a8a 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c @@ -1,7 +1,9 @@ #define _POSIX_C_SOURCE 200809L #include "framegen_bridge.h" #include "framegen_engine.h" +#include "effects_chain.h" #include "vk_loader.h" +#include "sc_layer.h" #include #include #include @@ -35,7 +37,7 @@ static VkQueue g_queue; static uint32_t g_qfam; static _Atomic int g_dev_ready, g_dev_lost; static int g_features_enabled; -static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok; +static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok, g_caps_zero_ok; static VkPhysicalDeviceMemoryProperties g_memprops; static struct { PFN_vkCreateImage CreateImage; @@ -77,6 +79,24 @@ static int format_refused(VkFormat f) { static _Atomic unsigned g_stat_generated; static uint64_t g_total_generated; + +#define FG_PROVEN_FRAMES 120 +#define FG_HANG_STRIKES 2 +static _Atomic int g_hang_strikes; +static int g_submitted_since_ready; +static uint64_t g_generated_at_ready; + +// A driver that hangs on the engine's shaders loses the device on its first generated frame after every +// recovery, so the compositor would recover and hang again for as long as frame generation stays armed. +static int framegen_loss_strike(int submitted, uint64_t completed_since_ready) { + if (!submitted || completed_since_ready >= FG_PROVEN_FRAMES) { + atomic_store(&g_hang_strikes, 0); + return 0; + } + if (atomic_fetch_add(&g_hang_strikes, 1) + 1 < FG_HANG_STRIKES) return 0; + atomic_store(&g_hang_strikes, 0); + return 1; +} static float g_presented_rate, g_source_rate; static uint32_t g_present_accum, g_source_accum; static int64_t g_window_start_ns; @@ -86,12 +106,49 @@ static int64_t now_ns(void) { return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec; } +/* The pair the last run made, for the display probe and the pacer: when its real frame reached the + * compositor, the game moment each generated frame shows, and the refresh the pacer timed each for. */ +static _Atomic int g_pacer_on; +static int g_layer_path; +static int g_out_gens; +static int64_t g_out_planned[VKP_FG_MAX_GENERATIONS + 1]; +static int64_t g_completion_issue; +static int g_paced_route = 1; + +void vkp_framegen_set_pacer(int on) { + if (atomic_exchange(&g_pacer_on, on ? 1 : 0) != (on ? 1 : 0)) { + fge_pacer_reset(); + FGLOG("ZeroFG pacer %s", on ? "on: frame generation times its frames itself" : "off: the display layer times them"); + } +} + +static int pacer_wanted(void) { return atomic_load(&g_pacer_on); } + +void vkp_framegen_pacer_abort(void) { + g_completion_issue = 0; + fge_pacer_reset(); +} + +void vkp_framegen_output_planned(int k, int gens, int64_t *planned) { + *planned = (k < 0 || k >= gens || k >= g_out_gens) + ? g_out_planned[g_out_gens] : g_out_planned[k]; +} + +void vkp_framegen_completed(void) { + if (!g_completion_issue) return; + fge_pacer_completed(g_completion_issue, now_ns()); + g_completion_issue = 0; +} + +void vkp_framegen_real_shown(int64_t planned_ns, int64_t shown_ns) { fge_pacer_shown(planned_ns, shown_ns); } + void vkp_framegen_set_engine(int kind) { - if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_DDFG) kind = VKP_FG_ENGINE_LSFG; + if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_DDFG && kind != VKP_FG_ENGINE_ZEROFG) kind = VKP_FG_ENGINE_LSFG; atomic_store(&g_kind, kind); atomic_store(&g_failed_kind, -1); atomic_store(&g_cfg_dirty, 1); + atomic_store(&g_hang_strikes, 0); } void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) { @@ -117,6 +174,22 @@ void vkp_framegen_set_lsfg_cache_path(const char *path) { pthread_mutex_unlock(&g_lock); } +void vkp_framegen_set_layer_timing(int layer) { + g_layer_path = layer; + fge_set_layer_timing(layer); +} + +void vkp_framegen_set_paced_route(int composed) { + composed = composed != 0; + if (composed == g_paced_route) return; + g_paced_route = composed; + if (atomic_load(&g_pacer_on)) { + fge_pacer_reset(); + FGLOG("ZeroPacer %s", composed ? "times the layer's frames again (composed route)" + : "waits: the direct route presents the real frame on its own timing"); + } +} + void vkp_framegen_set_tuning(float flow_scale, float refresh_hz) { if (flow_scale < 0.25f) flow_scale = 0.25f; if (flow_scale > 1.0f) flow_scale = 1.0f; @@ -145,15 +218,15 @@ static void mark_failed(int kind) { int vkp_framegen_problem(void) { if (!atomic_load(&g_dev_ready)) return -1; int kind = atomic_load(&g_kind); - int caps_ok = kind == VKP_FG_ENGINE_DDFG - ? atomic_load(&g_caps_ddfg_ok) - : atomic_load(&g_caps_lsfg_ok); + int caps_ok = kind == VKP_FG_ENGINE_ZEROFG ? atomic_load(&g_caps_zero_ok) : + kind == VKP_FG_ENGINE_DDFG ? atomic_load(&g_caps_ddfg_ok) : + atomic_load(&g_caps_lsfg_ok); if (!caps_ok) return 1; if (start_failed_for(kind)) return 2; if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2; return 0; } -const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(); } +const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(atomic_load(&g_kind)); } void vkp_framegen_stats(float out[6]) { float accepted = 0.0f, src = 0.0f, thermal = -1.0f; @@ -186,15 +259,56 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled); atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG)); atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG)); + atomic_store(&g_caps_zero_ok, fge_caps_ok(VKP_FG_ENGINE_ZEROFG)); atomic_store(&g_dev_lost, 0); + g_submitted_since_ready = 0; + g_generated_at_ready = g_total_generated; atomic_store(&g_dev_ready, vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier); - FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), DD-FG Native %s", - fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(), - fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable"); + FGLOG("engines ready on compositor device: LSFG %s, DD-FG %s, ZeroFG %s", + fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", + fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable", + fge_caps_ok(VKP_FG_ENGINE_ZEROFG) ? "available" : "unavailable"); } -void vkp_framegen_device_lost(void) { atomic_store(&g_dev_lost, 1); } +// The compositor reports one loss twice: when it happens and again while releasing the lost device. +static int framegen_count_loss(void) { + if (atomic_exchange(&g_dev_lost, 1)) return 0; + int failed = framegen_loss_strike(g_submitted_since_ready, g_total_generated - g_generated_at_ready); + g_submitted_since_ready = 0; + return failed; +} + +void vkp_framegen_device_lost(void) { + if (framegen_count_loss()) { + int kind = atomic_load(&g_kind); + mark_failed(kind); + FGLOG("%s lost the GPU %d times in a row before its frames completed; frame generation stays off " + "until it is set again", fge_engine_name(kind), FG_HANG_STRIKES); + } + atomic_store(&g_dev_ready, 0); + fge_device_lost(); + if (g_dev) { + for (uint32_t i = 0; i < g_ring_n; i++) { + if (g_ring[i].view && vk.DestroyImageView) vk.DestroyImageView(g_dev, g_ring[i].view, NULL); + if (g_ring[i].img && vk.DestroyImage) vk.DestroyImage(g_dev, g_ring[i].img, NULL); + if (g_ring[i].mem && vk.FreeMemory) vk.FreeMemory(g_dev, g_ring[i].mem, NULL); + } + } + memset(g_ring, 0, sizeof(g_ring)); + g_ring_n = g_ring_w = g_ring_h = 0; + g_ring_fmt = VK_FORMAT_UNDEFINED; + g_engine_ok = 0; + g_engine_kind = -1; + g_engine_cache_gen = -1; + g_built_w = g_built_h = 0; + g_built_fmt = VK_FORMAT_UNDEFINED; + g_planned = 0; + memset(&vk, 0, sizeof(vk)); + g_dev = VK_NULL_HANDLE; + g_queue = VK_NULL_HANDLE; + g_qfam = 0; +} static void destroy_ring(void) { @@ -202,7 +316,10 @@ static void destroy_ring(void) { if (vk.DeviceWaitIdle) vk.DeviceWaitIdle(g_dev); for (uint32_t i = 0; i < g_ring_n; i++) { if (g_ring[i].view) vk.DestroyImageView(g_dev, g_ring[i].view, NULL); - if (g_ring[i].img) vk.DestroyImage(g_dev, g_ring[i].img, NULL); + if (g_ring[i].img) { + vkp_effects_forget_image(g_ring[i].img); + vk.DestroyImage(g_dev, g_ring[i].img, NULL); + } if (g_ring[i].mem) vk.FreeMemory(g_dev, g_ring[i].mem, NULL); memset(&g_ring[i], 0, sizeof(g_ring[i])); } @@ -255,16 +372,18 @@ static int engine_usable(void) { int kind = atomic_load(&g_kind); int ready = atomic_load(&g_dev_ready); int lost = atomic_load(&g_dev_lost); - int caps_ok = kind == VKP_FG_ENGINE_DDFG - ? atomic_load(&g_caps_ddfg_ok) - : atomic_load(&g_caps_lsfg_ok); + int caps_ok = kind == VKP_FG_ENGINE_ZEROFG ? atomic_load(&g_caps_zero_ok) : + kind == VKP_FG_ENGINE_DDFG ? atomic_load(&g_caps_ddfg_ok) : + atomic_load(&g_caps_lsfg_ok); return ready && !lost && caps_ok && !start_failed_for(kind); } int vkp_framegen_format_ok(VkFormat fmt) { - if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1; if (!g_dev_ready || g_dev_lost || format_refused(fmt)) return 0; - return fge_format_ok(fmt); + int kind = atomic_load(&g_kind); + if (kind == VKP_FG_ENGINE_ZEROFG) return fge_format_ok(VKP_FG_ENGINE_ZEROFG, fmt); + if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1; + return fge_format_ok(kind, fmt); } static void refuse_format(VkFormat fmt, int kind, int w, int h, const char *what) { @@ -349,11 +468,14 @@ static void log_arm_transition(int armed, int kind, int mult) { int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h, VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]) { - (void)scene_view; int kind = atomic_load(&g_kind); int armed = atomic_load(&g_armed); int mult = atomic_load(&g_mult); g_planned = 0; + const int64_t issue = now_ns(); + g_out_gens = 0; + memset(g_out_planned, 0, sizeof(g_out_planned)); + g_completion_issue = 0; if (!armed || !engine_usable() || w <= 0 || h <= 0) { log_arm_transition(0, kind, mult); return 0; } if (!ensure_engine(kind)) { log_arm_transition(0, kind, mult); return 0; } log_arm_transition(1, kind, mult); @@ -395,8 +517,31 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, ++g_source_frames; const uint64_t game_frames = droiddeck_game_frames(); - uint32_t n_gen = fge_plan(g_ring_n, game_frames ? game_frames : g_source_frames, g_presented_rate); + const uint64_t planning_sequence = game_frames ? game_frames : g_source_frames; + uint32_t n_gen = fge_plan(g_ring_n, planning_sequence, g_presented_rate); if (n_gen > g_ring_n) n_gen = g_ring_n; + if (kind == VKP_FG_ENGINE_ZEROFG && n_gen > 0 && !scene_view) { + scene_view = vkp_effects_framegen_image_view(scene, w, h, fmt); + if (!scene_view) { + static int view_warning; + if (!view_warning++) FGLOG("ZeroFG could not create a view for the source image; showing real frames only"); + n_gen = 0; + } + } + fge_set_phases(NULL, 0); + if (kind == VKP_FG_ENGINE_ZEROFG && pacer_wanted() && g_layer_path && g_paced_route) { + int64_t vsync = 0, period = 0; + sc_layer_timeline(&vsync, &period); + int64_t planned[VKP_FG_MAX_GENERATIONS + 1]; + float phases[VKP_FG_MAX_GENERATIONS + 1]; + const uint32_t count = period > 0 + ? fge_pacer_plan((uint32_t)mult, period, vsync, issue, n_gen, planned, phases) : 0; + if (count >= 1 && count - 1 <= n_gen) { + n_gen = count - 1; + for (uint32_t i = 0; i < count; i++) g_out_planned[i] = planned[i]; + fge_set_phases(phases, n_gen); + } + } g_planned = n_gen; VkImageMemoryBarrier bars[1 + VKP_FG_MAX_GENERATIONS]; @@ -424,21 +569,26 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, nb, bars); - fge_process(cmd, scene, (uint32_t)w, (uint32_t)h, n_gen); + if (n_gen) g_submitted_since_ready = 1; + fge_process(cmd, scene, scene_view, (uint32_t)w, (uint32_t)h, fmt, planning_sequence, n_gen); for (uint32_t g = 0; g < n_gen; g++) { fge_generate(cmd, g, n_gen, g_ring[g].img, g_ring[g].view, (uint32_t)w, (uint32_t)h); gens[g] = g_ring[g].img; } if (n_gen) { nb = 0; + const VkAccessFlags generated_access = kind == VKP_FG_ENGINE_ZEROFG + ? VK_ACCESS_MEMORY_WRITE_BIT : VK_ACCESS_SHADER_WRITE_BIT; + const VkPipelineStageFlags generated_stage = kind == VKP_FG_ENGINE_ZEROFG + ? VK_PIPELINE_STAGE_ALL_COMMANDS_BIT : VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; for (uint32_t g = 0; g < n_gen; g++) bars[nb++] = (VkImageMemoryBarrier){ .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, + .srcAccessMask = generated_access, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT, .oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .image = g_ring[g].img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}}; - vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, + vk.CmdPipelineBarrier(cmd, generated_stage, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, nb, bars); if (!g_generating_logged) { g_generating_logged = 1; @@ -448,6 +598,8 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? ", FP16: the HDR picture" : ""); } } + g_out_gens = (int)n_gen; + if (n_gen > 0) g_completion_issue = issue; return (int)n_gen; } diff --git a/app/src/main/cpp/waylandcomp/src/framegen_bridge.h b/app/src/main/cpp/waylandcomp/src/framegen_bridge.h index 573d6fd3c6..4b7e215446 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_bridge.h +++ b/app/src/main/cpp/waylandcomp/src/framegen_bridge.h @@ -6,7 +6,7 @@ #endif #include -enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_DDFG = 1 }; +enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_DDFG = 1, VKP_FG_ENGINE_ZEROFG = 2 }; #define VKP_FG_MAX_GENERATIONS 3 void vkp_framegen_set_engine(int kind); @@ -26,6 +26,21 @@ void vkp_framegen_device_lost(void); int vkp_framegen_active(void); int vkp_framegen_extra_images(void); +/* 1 when the next run's frames are shown through the scene layer's timed group, 0 through the swapchain's FIFO. */ +void vkp_framegen_set_layer_timing(int layer); +/* ZeroFG's pacer (include/zerofg/inline_pacer.h) times the layer's frames instead of the layer's own spacing. */ +void vkp_framegen_set_pacer(int on); +/* 1 when the layer pass presents the real frame itself after its generated frames (the composed route): only + * then can the pacer time the whole group. The direct route keeps the layer's own timing. */ +void vkp_framegen_set_paced_route(int composed); +/* Reset pacing history when a planned real-frame pair is aborted before presentation. */ +void vkp_framegen_pacer_abort(void); +/* Refresh planned for output k of the last run (k == gens: its real frame; 0: use layer timing). */ +void vkp_framegen_output_planned(int k, int gens, int64_t *planned); +/* The last run's GPU work finished (the compositor's fence signalled). */ +void vkp_framegen_completed(void); +/* A real frame the pacer timed for planned_ns was shown at shown_ns. */ +void vkp_framegen_real_shown(int64_t planned_ns, int64_t shown_ns); int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h, VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]); void vkp_framegen_presented(int generated); diff --git a/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp b/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp index be1b03e34a..6f0b6db6b0 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp +++ b/app/src/main/cpp/waylandcomp/src/framegen_engine.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -13,6 +14,9 @@ #include "lsfg/lsfg_probe.h" #include "lsfg/lsfg_vkd.h" #include "ddfg/ddfg_engine.h" +#include "framegen_zerofg.h" + +#include #define ELOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "framegen: " __VA_ARGS__) #define ELOGE(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "framegen: " __VA_ARGS__) @@ -22,15 +26,21 @@ namespace { VkTable g_table{}; lsfg::Caps g_caps{}; VkPhysicalDeviceVulkan12Features g_v12{}; +VkPhysicalDeviceVulkan13Features g_v13{}; VkPhysicalDeviceFeatures2 g_f2{}; VkPhysicalDevice g_pd = VK_NULL_HANDLE; VkDevice g_dev = VK_NULL_HANDLE; VkQueue g_queue = VK_NULL_HANDLE; uint32_t g_qfam = 0; bool g_probed = false, g_ready = false; +bool g_zero_supported = false, g_zero_enabled = false; +zerofg::InlinePacer g_pacer; +zerofg::InlineReadiness g_readiness; +std::mutex g_pacer_mutex; std::unique_ptr g_lsfg; std::unique_ptr g_ddfg; +std::vector> g_retained_ddfg; int g_kind = -1; char g_build[96] = ""; @@ -87,30 +97,57 @@ const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica if (n) enumExts(pd, nullptr, &n, exts.data()); } g_caps = lsfg::Caps{}; - - - g_caps.features = lsfg::queryFeatures(g_table, pd, exts, false); + g_caps.features = lsfg::queryFeatures(g_table, pd, exts, false); g_caps.probedFormat = ring_fmt; g_caps.storageOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties ? lsfg::probeStorageFormat(g_table, pd, ring_fmt) : false; g_caps.linearBlitOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties ? lsfg::probeLinearBlit(g_table, pd, ring_fmt) : false; g_probed = true; - if (!g_caps.features.deviceGatesPass()) { + + VkPhysicalDeviceProperties props{}; + if (g_table.GetPhysicalDeviceProperties) g_table.GetPhysicalDeviceProperties(pd, &props); + VkPhysicalDeviceVulkan13Features supported13{}; + supported13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; + VkPhysicalDeviceFeatures2 supported2{}; + supported2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + if (props.apiVersion >= VK_API_VERSION_1_3) supported2.pNext = &supported13; + if (g_table.GetPhysicalDeviceFeatures2) g_table.GetPhysicalDeviceFeatures2(pd, &supported2); + g_zero_supported = props.apiVersion >= VK_API_VERSION_1_3 && + supported13.synchronization2 == VK_TRUE && + supported2.features.shaderStorageImageExtendedFormats == VK_TRUE; + g_zero_enabled = false; + + const bool lsfg_supported = g_caps.features.deviceGatesPass(); + if (!lsfg_supported) { lsfg::explain(g_caps); ELOG("device gates for the LSFG chain fail: %s", g_caps.reason); + } + if (!lsfg_supported && !g_zero_supported) { + g_v12 = {}; + g_v13 = {}; + g_f2 = {}; return nullptr; } + g_v12 = VkPhysicalDeviceVulkan12Features{}; g_v12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; - g_v12.vulkanMemoryModel = VK_TRUE; + g_v12.vulkanMemoryModel = + g_caps.features.vulkanMemoryModel ? VK_TRUE : VK_FALSE; g_v12.vulkanMemoryModelDeviceScope = g_caps.features.vulkanMemoryModelDeviceScope ? VK_TRUE : VK_FALSE; + g_v13 = VkPhysicalDeviceVulkan13Features{}; + g_v13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; + g_v13.synchronization2 = g_zero_supported ? VK_TRUE : VK_FALSE; + if (g_zero_supported) g_v12.pNext = &g_v13; + g_f2 = VkPhysicalDeviceFeatures2{}; g_f2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; g_f2.pNext = &g_v12; - g_f2.features.shaderStorageImageWriteWithoutFormat = VK_TRUE; - g_f2.features.shaderStorageImageExtendedFormats = VK_TRUE; + g_f2.features.shaderStorageImageWriteWithoutFormat = + supported2.features.shaderStorageImageWriteWithoutFormat ? VK_TRUE : VK_FALSE; + g_f2.features.shaderStorageImageExtendedFormats = + supported2.features.shaderStorageImageExtendedFormats ? VK_TRUE : VK_FALSE; return &g_f2; } @@ -121,27 +158,80 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica fill_device(dev); g_caps.featuresEnabled = features_enabled != 0; lsfg::explain(g_caps); + VkPhysicalDeviceProperties props{}; + if (g_table.GetPhysicalDeviceProperties) g_table.GetPhysicalDeviceProperties(pd, &props); + g_zero_enabled = g_zero_supported && features_enabled != 0; + zfg_device_ready(gipa, inst, pd, dev, + props.apiVersion > VK_API_VERSION_1_3 ? VK_API_VERSION_1_3 : props.apiVersion, + g_zero_enabled, + g_zero_enabled && g_f2.features.shaderStorageImageExtendedFormats == VK_TRUE); g_ready = true; - ELOG("device ready: lsfg caps '%s', storage on ring format %d", g_caps.reason, - (int)g_caps.storageOnSwapchainFormat); + ELOG("device ready: lsfg caps '%s', storage on ring format %d, ZeroFG %s", + g_caps.reason, (int)g_caps.storageOnSwapchainFormat, + g_zero_enabled ? "available" : "unavailable"); +} + +void fge_device_lost(void) { + g_lsfg.reset(); + if (g_ddfg) { + if (g_ddfg->destroy()) g_ddfg.reset(); + else g_retained_ddfg.push_back(std::move(g_ddfg)); + } + // The device is being torn down. Unknown-completion resources must not be + // passed to Vulkan destruction calls; the VkDevice teardown reclaims them. + for (auto& engine : g_retained_ddfg) engine->abandon(); + g_retained_ddfg.clear(); + g_kind = -1; + g_dev = VK_NULL_HANDLE; + g_queue = VK_NULL_HANDLE; + g_pd = VK_NULL_HANDLE; + g_qfam = 0; + g_ready = false; + g_probed = false; + g_table = {}; + g_caps = {}; + g_v12 = {}; + g_f2 = {}; + g_build[0] = 0; + g_zero_supported = g_zero_enabled = false; + zfg_device_lost(); } int fge_caps_ok(int kind) { if (!g_ready) return 0; + if (kind == 2) return g_zero_enabled && zfg_caps_ok(); if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0; return g_caps.supported() ? 1 : 0; } -const char *fge_caps_reason(void) { return g_caps.reason; } +int fge_engine_available(int kind) { return fge_caps_ok(kind); } -int fge_format_ok(VkFormat fmt) { +const char *fge_caps_reason(int kind) { + if (kind == 2 && !g_zero_enabled) + return "ZeroFG requires Vulkan 1.3, synchronization2 and extended storage-image formats"; + if (kind == 2) return zfg_caps_reason(); + return g_caps.reason; +} + +int fge_format_ok(int kind, VkFormat fmt) { + if (kind == 2) return zfg_format_ok(fmt); if (!g_ready || !g_table.GetPhysicalDeviceFormatProperties || fmt == VK_FORMAT_UNDEFINED) return 0; return lsfg::probeStorageFormat(g_table, g_pd, fmt) && lsfg::probeLinearBlit(g_table, g_pd, fmt) ? 1 : 0; } int fge_start(int kind, const char *cache_path) { fge_stop(); + fge_pacer_reset(); if (!g_ready) return -1; + if (kind == 2) { + if (!g_zero_enabled || !zfg_start()) { + ELOGE("ZeroFG engine init failed"); + return -1; + } + g_kind = 2; + std::snprintf(g_build, sizeof(g_build), "ZeroFG ReallyZero, Vulkan 1.3 Compat"); + return 0; + } if (kind == 1) { auto e = std::make_unique(); if (!e->init(g_table, g_pd, g_dev, g_qfam, g_queue)) { @@ -176,13 +266,30 @@ int fge_start(int kind, const char *cache_path) { } void fge_stop(void) { - if ((g_lsfg || g_ddfg) && g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev); + if ((g_kind == 0 || g_kind == 2) && g_table.DeviceWaitIdle && g_dev) + g_table.DeviceWaitIdle(g_dev); + g_lsfg.reset(); - g_ddfg.reset(); + + for (auto it = g_retained_ddfg.begin(); it != g_retained_ddfg.end();) { + if ((*it)->destroy()) it = g_retained_ddfg.erase(it); + else ++it; + } + + if (g_ddfg) { + if (g_ddfg->destroy()) g_ddfg.reset(); + else { + ELOGE("ddfg-native: retaining engine until GPU completion is known or device teardown"); + g_retained_ddfg.push_back(std::move(g_ddfg)); + } + } + + zfg_stop(); g_kind = -1; } int fge_unavailable(void) { + if (g_kind == 2) return zfg_unavailable(); if (g_kind == 1) return g_ddfg && g_ddfg->unavailable() ? 1 : 0; return g_lsfg && g_lsfg->unavailable() ? 1 : 0; } @@ -190,11 +297,13 @@ int fge_unavailable(void) { void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, float refresh_hz, int model, int perf_preset) { if (multiplier < 2) multiplier = 2; + if (g_kind == 2) { zfg_configure(multiplier, refresh_hz); return; } if (g_kind == 1 && g_ddfg) g_ddfg->configure(multiplier, model, perf_preset, flow_scale); else if (g_lsfg) g_lsfg->configure(multiplier, target_fps, flow_scale, refresh_hz); } int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) { + if (g_kind == 2) return zfg_prepare(w, h, fmt); if (g_kind == 1) return g_ddfg && g_ddfg->prepare(w, h, fmt) ? 1 : 0; if (!g_lsfg) return 0; g_lsfg->setGuestExtent(w, h); @@ -202,24 +311,74 @@ int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) { } uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) { + if (g_kind == 2) return zfg_plan(capacity, source_frames); if (g_kind == 1) return g_ddfg ? g_ddfg->plan(capacity) : 0; if (!g_lsfg) return 0; g_lsfg->setPresentedRate(presented_rate); return g_lsfg->plan(capacity, source_frames); } -void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) { +void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view, + uint32_t w, uint32_t h, VkFormat fmt, uint64_t sequence, uint32_t gens) { + if (g_kind == 2) { + zfg_process(cmd, source, source_view, w, h, fmt, sequence, gens); + return; + } if (g_kind == 1) { if (g_ddfg) g_ddfg->process(cmd, source, w, h, gens); return; } if (g_lsfg) g_lsfg->process(cmd, source, w, h, gens); } void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view, uint32_t w, uint32_t h) { + if (g_kind == 2) { zfg_generate(cmd, g, count, img, view, w, h); return; } if (g_kind == 1) { if (g_ddfg) g_ddfg->generateInto(cmd, g, count, img, view, w, h); return; } if (g_lsfg) g_lsfg->generateInto(cmd, g, g, img, view, w, h); } +void fge_set_layer_timing(int layer) { zfg_set_layer_timing(layer); } + +void fge_set_phases(const float *phases, uint32_t count) { zfg_set_phases(phases, count); } + +float fge_phase(uint32_t index, uint32_t count) { + if (g_kind == 2) return zfg_phase(index, count); + return static_cast(index + 1) / static_cast(count + 1); +} + +uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated, + int64_t *present_ns, float *phases) { + if (period_ns <= 0 || issue_ns <= 0) return 0; + std::lock_guard lock(g_pacer_mutex); + g_pacer.SetMultiplier(multiplier); + g_pacer.ObserveVsync(static_cast(period_ns), static_cast(vsync_ns > 0 ? vsync_ns : 0)); + const uint64_t issue = static_cast(issue_ns); + const zerofg::InlinePacer::Plan plan = + g_pacer.PlanPair(issue, issue + g_readiness.MarginNs(static_cast(period_ns)), max_generated + 1); + for (uint32_t i = 0; i < plan.count; i++) { + present_ns[i] = static_cast(plan.outputs[i].present_ns); + phases[i] = plan.outputs[i].phase; + } + return plan.count; +} + +void fge_pacer_completed(int64_t issue_ns, int64_t done_ns) { + std::lock_guard lock(g_pacer_mutex); + if (issue_ns > 0 && done_ns > issue_ns) + g_readiness.ObserveCompleted(static_cast(issue_ns), static_cast(done_ns)); +} + +void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns) { + std::lock_guard lock(g_pacer_mutex); + if (planned_ns > 0 && shown_ns > 0) + g_pacer.ObserveRealShown(static_cast(planned_ns), static_cast(shown_ns)); +} + +void fge_pacer_reset(void) { + std::lock_guard lock(g_pacer_mutex); + g_pacer.Reset(); +} + void fge_forget_targets(void) { + if (g_kind == 2) { zfg_forget_targets(); return; } if (g_lsfg) g_lsfg->forgetTargets(); } @@ -229,10 +388,14 @@ void fge_telemetry(float *accepted, float *source_rate, float *thermal) { *accepted = (float)g_lsfg->acceptedGenerations(); *source_rate = g_lsfg->sourceRate(); *thermal = (float)g_lsfg->thermalStatus(); + } else if (g_kind == 2) { + zfg_telemetry(accepted, source_rate); } } -const char *fge_engine_name(int kind) { return kind == 1 ? "DD-FG Native" : "LSFG Native"; } +const char *fge_engine_name(int kind) { + return kind == 2 ? "ZeroFG" : kind == 1 ? "DD-FG Native" : "LSFG Native"; +} const char *fge_build_info(void) { return g_build; } } diff --git a/app/src/main/cpp/waylandcomp/src/framegen_engine.h b/app/src/main/cpp/waylandcomp/src/framegen_engine.h index 4257a7592e..8295a930f3 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_engine.h +++ b/app/src/main/cpp/waylandcomp/src/framegen_engine.h @@ -12,11 +12,13 @@ extern "C" { const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd, VkFormat ring_fmt); +void fge_device_lost(void); void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd, VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled); int fge_caps_ok(int kind); -const char *fge_caps_reason(void); -int fge_format_ok(VkFormat fmt); +const char *fge_caps_reason(int kind); +int fge_format_ok(int kind, VkFormat fmt); +int fge_engine_available(int kind); int fge_start(int kind, const char *cache_path); void fge_stop(void); @@ -25,10 +27,22 @@ void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, f int model, int perf_preset); int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt); uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate); -void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens); +void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view, + uint32_t w, uint32_t h, VkFormat fmt, uint64_t sequence, uint32_t gens); void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view, uint32_t w, uint32_t h); void fge_forget_targets(void); +void fge_set_layer_timing(int layer); +/* The phases the pacer chose for the next pair's generated frames (engines that can take any phase). */ +void fge_set_phases(const float *phases, uint32_t count); +/* The phase generated frame [index] of [count] shows. */ +float fge_phase(uint32_t index, uint32_t count); + +uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated, + int64_t *present_ns, float *phases); +void fge_pacer_completed(int64_t issue_ns, int64_t done_ns); +void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns); +void fge_pacer_reset(void); void fge_telemetry(float *accepted, float *source_rate, float *thermal); const char *fge_engine_name(int kind); const char *fge_build_info(void); diff --git a/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c b/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c index 310e10c341..6dcf3a8d5b 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_engine_stub.c @@ -9,9 +9,13 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled) { (void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled; } +void fge_device_lost(void) {} +void zfg_discard_history_update(void) {} +void zfg_commit_history_update(void) {} int fge_caps_ok(int kind) { (void)kind; return 0; } -const char *fge_caps_reason(void) { return "frame-generation engines not built into this compositor"; } -int fge_format_ok(VkFormat fmt) { (void)fmt; return 0; } +const char *fge_caps_reason(int kind) { (void)kind; return "frame-generation engines not built into this compositor"; } +int fge_format_ok(int kind, VkFormat fmt) { (void)kind; (void)fmt; return 0; } +int fge_engine_available(int kind) { (void)kind; return 0; } int fge_start(int kind, const char *cache_path) { (void)kind; (void)cache_path; return -1; } void fge_stop(void) {} int fge_unavailable(void) { return 1; } @@ -23,16 +27,28 @@ int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) { (void)w; (void)h; (void) uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) { (void)capacity; (void)source_frames; (void)presented_rate; return 0; } -void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) { - (void)cmd; (void)source; (void)w; (void)h; (void)gens; +void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view, uint32_t w, uint32_t h, + VkFormat fmt, uint64_t sequence, uint32_t gens) { + (void)cmd; (void)source; (void)source_view; (void)w; (void)h; (void)fmt; (void)sequence; (void)gens; } void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view, uint32_t w, uint32_t h) { (void)cmd; (void)g; (void)count; (void)img; (void)view; (void)w; (void)h; } void fge_forget_targets(void) {} +void fge_set_layer_timing(int layer) { (void)layer; } +void fge_set_phases(const float *phases, uint32_t count) { (void)phases; (void)count; } +float fge_phase(uint32_t index, uint32_t count) { return (float)(index + 1) / (float)(count + 1); } +uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated, + int64_t *present_ns, float *phases) { + (void)multiplier; (void)period_ns; (void)vsync_ns; (void)issue_ns; (void)max_generated; (void)present_ns; (void)phases; + return 0; +} +void fge_pacer_completed(int64_t issue_ns, int64_t done_ns) { (void)issue_ns; (void)done_ns; } +void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns) { (void)planned_ns; (void)shown_ns; } +void fge_pacer_reset(void) {} void fge_telemetry(float *accepted, float *source_rate, float *thermal) { *accepted = 0.0f; *source_rate = 0.0f; *thermal = -1.0f; } -const char *fge_engine_name(int kind) { return kind == 1 ? "DD-FG Native" : "LSFG Native"; } +const char *fge_engine_name(int kind) { return kind == 2 ? "ZeroFG" : kind == 1 ? "DD-FG Native" : "LSFG Native"; } const char *fge_build_info(void) { return "stub"; } diff --git a/app/src/main/cpp/waylandcomp/src/framegen_jni.c b/app/src/main/cpp/waylandcomp/src/framegen_jni.c index e5a51456ed..e210597b8f 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_jni.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_jni.c @@ -14,6 +14,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFrameGenArmed(JNI vkp_framegen_set_armed(armed ? 1 : 0, (int)multiplier, (int)targetFps); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFrameGenPacer(JNIEnv *env, jclass clazz, jboolean on) { + (void)env; (void)clazz; + vkp_framegen_set_pacer(on ? 1 : 0); +} + JNIEXPORT void JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLsfgCachePath(JNIEnv *env, jclass clazz, jstring path) { (void)clazz; diff --git a/app/src/main/cpp/waylandcomp/src/framegen_zerofg.cpp b/app/src/main/cpp/waylandcomp/src/framegen_zerofg.cpp new file mode 100644 index 0000000000..b0da6b2af1 --- /dev/null +++ b/app/src/main/cpp/waylandcomp/src/framegen_zerofg.cpp @@ -0,0 +1,624 @@ +#include "framegen_zerofg.h" +#include "sc_layer.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define ZFG_LOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "ZeroFG: " __VA_ARGS__) +#define ZFG_ERR(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "ZeroFG: " __VA_ARGS__) + +namespace { +PFN_vkGetInstanceProcAddr g_gipa = nullptr; +PFN_vkGetDeviceProcAddr g_gdpa = nullptr; +VkInstance g_instance = VK_NULL_HANDLE; +VkPhysicalDevice g_physical = VK_NULL_HANDLE; +VkDevice g_device = VK_NULL_HANDLE; +uint32_t g_api_version = VK_API_VERSION_1_0; +bool g_synchronization2 = false, g_extended_formats = false; +bool g_ready = false, g_supported = false, g_failed = false; +char g_reason[160] = "device has not been checked"; + +PFN_vkGetPhysicalDeviceMemoryProperties g_GetPhysicalDeviceMemoryProperties = nullptr; +PFN_vkGetPhysicalDeviceFormatProperties g_GetPhysicalDeviceFormatProperties = nullptr; +PFN_vkCreateImage g_CreateImage = nullptr; +PFN_vkDestroyImage g_DestroyImage = nullptr; +PFN_vkCreateImageView g_CreateImageView = nullptr; +PFN_vkDestroyImageView g_DestroyImageView = nullptr; +PFN_vkGetImageMemoryRequirements g_GetImageMemoryRequirements = nullptr; +PFN_vkAllocateMemory g_AllocateMemory = nullptr; +PFN_vkFreeMemory g_FreeMemory = nullptr; +PFN_vkBindImageMemory g_BindImageMemory = nullptr; +PFN_vkCmdPipelineBarrier g_CmdPipelineBarrier = nullptr; +PFN_vkCmdCopyImage g_CmdCopyImage = nullptr; +PFN_vkDeviceWaitIdle g_DeviceWaitIdle = nullptr; +VkPhysicalDeviceMemoryProperties g_memory_properties{}; + +std::unique_ptr g_interpolator; +VkImage g_history = VK_NULL_HANDLE; +VkImageView g_history_view = VK_NULL_HANDLE; +VkDeviceMemory g_history_memory = VK_NULL_HANDLE; +uint32_t g_width = 0, g_height = 0; +VkFormat g_format = VK_FORMAT_UNDEFINED; +bool g_history_layout_defined = false, g_history_valid = false; +uint64_t g_history_sequence = 0; +bool g_history_recorded_pending = false; +uint64_t g_history_recorded_sequence = 0; +std::array g_fallback_outputs{}; +VkImage g_current = VK_NULL_HANDLE; +VkImageView g_current_view = VK_NULL_HANDLE; +uint64_t g_current_sequence = 0; +bool g_pair_pending = false; +// The interpolator keeps per-pair work and the prepared Real by sequence. A pass dropped after recording +// Interpolate never ran on the GPU, so the next pair's A gets a fresh identity no record has seen: nothing the +// dropped pass would have prepared is reused, nor its flow start. The identity is stable for the whole pair, so +// its phases still share their work (and ReallyZero sees one pair, not a first picture per phase). +bool g_interpolate_uncommitted = false; +bool g_record_stale = false; +uint64_t g_pair_anonymous = 0; // the recovery pair's A identity, 0 for an ordinary pair +uint64_t g_anonymous_count = 0; +constexpr uint64_t kAnonymousSequence = 1ull << 63; // above any frame sequence the compositor hands out + +// Pacing. The compositor presents a pair's generated frames and its real frame back to back in FIFO, +// so they reach the panel on consecutive refreshes right after the tick that drew them. +constexpr uint64_t kBreakNs = 250000000ull; +constexpr size_t kIntervalWindow = 8; +constexpr size_t kMinIntervals = 4; +constexpr double kSlotTolerance = 0.15; +uint32_t g_multiplier = 2; +float g_refresh_hz = 0.0f; +bool g_layer_timing = false; +// The phases the pacer chose for this pair (count 0: none, the timing above decides). +std::array g_external_phases{}; +uint32_t g_external_count = 0; +uint64_t g_last_sequence = 0; +uint64_t g_last_issue_ns = 0; +uint64_t g_pair_interval_ns = 0; +uint32_t g_prev_count = 0, g_pair_count = 0; +std::array g_intervals{}; +size_t g_interval_count = 0, g_interval_next = 0; + +uint64_t now_ns() { + return static_cast(std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()).count()); +} + +void reset_pacing() { + g_last_issue_ns = 0; + g_pair_interval_ns = 0; + g_prev_count = g_pair_count = 0; + g_interval_count = g_interval_next = 0; +} + +uint64_t period_ns() { + return g_refresh_hz > 1.0f ? static_cast(1e9 / static_cast(g_refresh_hz)) : 0; +} + +uint64_t typical_interval_ns() { + if (g_interval_count < kMinIntervals) return 0; + std::array sorted = g_intervals; + std::sort(sorted.begin(), sorted.begin() + g_interval_count); + return sorted[g_interval_count / 2]; +} + +void note_sequence(uint64_t sequence) { + if (sequence == g_last_sequence) return; + const uint64_t now = now_ns(); + if (sequence < g_last_sequence) { + // The frame counter changed source (game frames vs compositor scenes): no pair across it. + g_history_valid = false; + g_history_sequence = 0; + reset_pacing(); + } else if (g_last_issue_ns && now > g_last_issue_ns) { + const uint64_t interval = now - g_last_issue_ns; + if (interval > kBreakNs) { + reset_pacing(); + } else { + g_pair_interval_ns = interval; + g_intervals[g_interval_next] = interval; + g_interval_next = (g_interval_next + 1) % kIntervalWindow; + g_interval_count = std::min(g_interval_count + 1, kIntervalWindow); + } + } + g_last_sequence = sequence; + g_last_issue_ns = now; +} + +// Generated frames a pair can show without its presents queueing past the next game frame: +// one refresh each, the real frame one more, all inside the game's typical frame interval. +uint32_t pair_capacity(uint32_t wanted) { + const uint64_t period = period_ns(); + const uint64_t typical = typical_interval_ns(); + if (!period || !typical) return wanted; + const double slots = std::floor(static_cast(typical) / static_cast(period) + kSlotTolerance); + return slots < 2.0 ? 0u : std::min(wanted, static_cast(slots) - 1u); +} + +// The scene layer (sc_layer.c) shows a group of [count] generated frames and then B, frame k of the group +// max(k, round(k * gap / (count + 1))) refreshes after the first, a group every game frame interval. +float layer_phase(uint32_t index, uint32_t count, uint64_t period) { + const float even = static_cast(index + 1) / static_cast(count + 1); + int64_t cadence_gap = 0; + int cadence_frames = 0; + sc_layer_cadence_info(&cadence_gap, &cadence_frames); + const uint64_t gap = cadence_gap > 0 ? static_cast(cadence_gap) : typical_interval_ns(); + const uint32_t group_frames = cadence_frames > static_cast(count) + ? static_cast(cadence_frames) : count + 1; + if (!gap) return even; + const int64_t slots = static_cast((gap + period / 2) / period); + if (slots < static_cast(group_frames)) return even; + const auto step = [&](uint32_t k) { + const int64_t s = static_cast((static_cast(k) * gap / group_frames + period / 2) / period); + return std::max(s, k); + }; + const double phase = static_cast(step(index) - step(count) + slots) / static_cast(slots); + return static_cast(std::clamp(phase, 0.05, 0.95)); +} + +// FIFO presents the generated group and B back-to-back; phase uses the measured real-frame span. +float pair_phase(uint32_t index, uint32_t count) { + if (g_external_count == count && index < count) return std::clamp(g_external_phases[index], 0.01f, 0.99f); + const float even = static_cast(index + 1) / static_cast(count + 1); + const uint64_t period = period_ns(); + if (!period) return even; + if (g_layer_timing) return layer_phase(index, count, period); + if (!g_pair_interval_ns) return even; + const double span = static_cast(g_pair_interval_ns) + + (static_cast(count) - static_cast(g_prev_count)) * static_cast(period); + if (span <= static_cast(period) * (count + 1)) return even; + const double phase = 1.0 - static_cast(count - index) * static_cast(period) / span; + return static_cast(std::clamp(phase, 0.05, 0.95)); +} + +void load_device_functions() { + if (g_gipa && g_instance) { + g_GetPhysicalDeviceMemoryProperties = + reinterpret_cast( + g_gipa(g_instance, "vkGetPhysicalDeviceMemoryProperties")); + g_GetPhysicalDeviceFormatProperties = + reinterpret_cast( + g_gipa(g_instance, "vkGetPhysicalDeviceFormatProperties")); + } + if (!g_gdpa || !g_device) return; +#define LOAD(name) g_##name = reinterpret_cast(g_gdpa(g_device, "vk" #name)) + LOAD(CreateImage); + LOAD(DestroyImage); + LOAD(CreateImageView); + LOAD(DestroyImageView); + LOAD(GetImageMemoryRequirements); + LOAD(AllocateMemory); + LOAD(FreeMemory); + LOAD(BindImageMemory); + LOAD(CmdPipelineBarrier); + LOAD(CmdCopyImage); + LOAD(DeviceWaitIdle); +#undef LOAD +} + +void clear_history_state() { + g_history_valid = false; + g_history_sequence = 0; + g_pair_pending = false; + g_current = VK_NULL_HANDLE; + g_current_view = VK_NULL_HANDLE; + g_current_sequence = 0; +} + +void destroy_history() { + if (g_device) { + if (g_history_view && g_DestroyImageView) g_DestroyImageView(g_device, g_history_view, nullptr); + if (g_history && g_DestroyImage) g_DestroyImage(g_device, g_history, nullptr); + if (g_history_memory && g_FreeMemory) g_FreeMemory(g_device, g_history_memory, nullptr); + } + g_history = VK_NULL_HANDLE; + g_history_view = VK_NULL_HANDLE; + g_history_memory = VK_NULL_HANDLE; + g_width = g_height = 0; + g_format = VK_FORMAT_UNDEFINED; + g_history_layout_defined = false; + clear_history_state(); +} + +uint32_t find_memory_type(uint32_t bits) { + uint32_t fallback = UINT32_MAX; + for (uint32_t i = 0; i < g_memory_properties.memoryTypeCount; ++i) { + if ((bits & (1u << i)) == 0) continue; + const auto flags = g_memory_properties.memoryTypes[i].propertyFlags; + if (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) return i; + if (fallback == UINT32_MAX) fallback = i; + } + return fallback; +} + +bool make_history(uint32_t width, uint32_t height, VkFormat format) { + if (!g_CreateImage || !g_GetImageMemoryRequirements || !g_AllocateMemory || + !g_BindImageMemory || !g_CreateImageView || !g_GetPhysicalDeviceMemoryProperties) { + std::snprintf(g_reason, sizeof(g_reason), "Vulkan image functions unavailable"); + return false; + } + VkImageCreateInfo image_info{}; + image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; + image_info.imageType = VK_IMAGE_TYPE_2D; + image_info.format = format; + image_info.extent = {width, height, 1}; + image_info.mipLevels = 1; + image_info.arrayLayers = 1; + image_info.samples = VK_SAMPLE_COUNT_1_BIT; + image_info.tiling = VK_IMAGE_TILING_OPTIMAL; + image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + if (g_CreateImage(g_device, &image_info, nullptr, &g_history) != VK_SUCCESS) { + std::snprintf(g_reason, sizeof(g_reason), "could not create temporal history image"); + return false; + } + + VkMemoryRequirements requirements{}; + g_GetImageMemoryRequirements(g_device, g_history, &requirements); + const uint32_t memory_index = find_memory_type(requirements.memoryTypeBits); + if (memory_index == UINT32_MAX) { + std::snprintf(g_reason, sizeof(g_reason), "no compatible memory for temporal history"); + destroy_history(); + return false; + } + VkMemoryAllocateInfo allocation{}; + allocation.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + allocation.allocationSize = requirements.size; + allocation.memoryTypeIndex = memory_index; + if (g_AllocateMemory(g_device, &allocation, nullptr, &g_history_memory) != VK_SUCCESS || + g_BindImageMemory(g_device, g_history, g_history_memory, 0) != VK_SUCCESS) { + std::snprintf(g_reason, sizeof(g_reason), "could not allocate temporal history memory"); + destroy_history(); + return false; + } + + VkImageViewCreateInfo view_info{}; + view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + view_info.image = g_history; + view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; + view_info.format = format; + view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + if (g_CreateImageView(g_device, &view_info, nullptr, &g_history_view) != VK_SUCCESS) { + std::snprintf(g_reason, sizeof(g_reason), "could not create temporal history view"); + destroy_history(); + return false; + } + g_width = width; + g_height = height; + g_format = format; + g_history_layout_defined = false; + g_history_recorded_pending = false; + g_history_recorded_sequence = 0; + clear_history_state(); + return true; +} + +void copy_current_to_history(VkCommandBuffer cmd, VkImage source, + uint32_t width, uint32_t height, uint64_t sequence) { + if (!g_history || !source || !g_CmdPipelineBarrier || !g_CmdCopyImage) return; + VkImageMemoryBarrier before{}; + before.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + const bool layout_defined = g_history_layout_defined || g_history_recorded_pending; + before.srcAccessMask = layout_defined ? VK_ACCESS_SHADER_READ_BIT : 0; + before.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + before.oldLayout = layout_defined ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED; + before.newLayout = VK_IMAGE_LAYOUT_GENERAL; + before.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + before.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + before.image = g_history; + before.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + g_CmdPipelineBarrier(cmd, + layout_defined ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT : VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &before); + + VkImageCopy region{}; + region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + region.extent = {width, height, 1}; + g_CmdCopyImage(cmd, source, VK_IMAGE_LAYOUT_GENERAL, g_history, VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); + + VkImageMemoryBarrier after{}; + after.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + after.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + after.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; + after.oldLayout = VK_IMAGE_LAYOUT_GENERAL; + after.newLayout = VK_IMAGE_LAYOUT_GENERAL; + after.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + after.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + after.image = g_history; + after.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, 0, nullptr, 0, nullptr, 1, &after); + g_history_recorded_pending = true; + g_history_recorded_sequence = sequence; + g_pair_pending = false; +} + +void copy_current_to_output(VkCommandBuffer cmd, VkImage output, uint32_t width, uint32_t height) { + if (!g_current || !output || !g_CmdPipelineBarrier || !g_CmdCopyImage) return; + VkImageMemoryBarrier before{}; + before.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + before.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT; + before.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + before.oldLayout = VK_IMAGE_LAYOUT_GENERAL; + before.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + before.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + before.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + before.image = output; + before.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, + 0, 0, nullptr, 0, nullptr, 1, &before); + VkImageCopy region{}; + region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + region.extent = {width, height, 1}; + g_CmdCopyImage(cmd, g_current, VK_IMAGE_LAYOUT_GENERAL, + output, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); + VkImageMemoryBarrier after{}; + after.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + after.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + after.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT; + after.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + after.newLayout = VK_IMAGE_LAYOUT_GENERAL; + after.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + after.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + after.image = output; + after.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, + 0, 0, nullptr, 0, nullptr, 1, &after); +} +} // namespace + +extern "C" { +void zfg_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance instance, + VkPhysicalDevice physical_device, VkDevice device, + uint32_t api_version, int synchronization2_enabled, + int extended_storage_formats_enabled) { + g_gipa = gipa; + g_instance = instance; + g_physical = physical_device; + g_device = device; + g_api_version = api_version; + g_synchronization2 = synchronization2_enabled != 0; + g_extended_formats = extended_storage_formats_enabled != 0; + g_gdpa = g_gipa && g_instance + ? reinterpret_cast(g_gipa(g_instance, "vkGetDeviceProcAddr")) + : nullptr; + load_device_functions(); + if (g_GetPhysicalDeviceMemoryProperties && g_physical) + g_GetPhysicalDeviceMemoryProperties(g_physical, &g_memory_properties); + g_ready = g_device != VK_NULL_HANDLE; + g_supported = g_ready && g_api_version >= VK_API_VERSION_1_3 && + g_synchronization2 && g_extended_formats; + g_failed = false; + std::snprintf(g_reason, sizeof(g_reason), "%s", g_supported ? "available" : + "requires Vulkan 1.3, synchronization2 and shaderStorageImageExtendedFormats"); +} + +void zfg_device_lost(void) { + g_interpolator.reset(); + destroy_history(); + g_gipa = nullptr; g_gdpa = nullptr; + g_instance = VK_NULL_HANDLE; g_physical = VK_NULL_HANDLE; g_device = VK_NULL_HANDLE; + g_ready = g_supported = g_failed = false; + g_synchronization2 = g_extended_formats = false; + g_api_version = VK_API_VERSION_1_0; + g_GetPhysicalDeviceMemoryProperties = nullptr; + g_GetPhysicalDeviceFormatProperties = nullptr; + g_CreateImage = nullptr; g_DestroyImage = nullptr; + g_CreateImageView = nullptr; g_DestroyImageView = nullptr; + g_GetImageMemoryRequirements = nullptr; g_AllocateMemory = nullptr; + g_FreeMemory = nullptr; g_BindImageMemory = nullptr; + g_CmdPipelineBarrier = nullptr; g_CmdCopyImage = nullptr; g_DeviceWaitIdle = nullptr; + g_memory_properties = {}; + std::snprintf(g_reason, sizeof(g_reason), "device lost"); +} + +int zfg_caps_ok(void) { return g_supported ? 1 : 0; } +const char *zfg_caps_reason(void) { return g_reason; } + +int zfg_start(void) { + if (!g_supported || !g_ready) return 0; + if (g_interpolator) return 1; + zerofg::CreateInfo info{}; + info.vulkan.instance = g_instance; + info.vulkan.physical_device = g_physical; + info.vulkan.device = g_device; + info.vulkan.get_instance_proc_addr = g_gipa; + info.mode = zerofg::Mode::kReallyZero; + info.backend = zerofg::Backend::kCompat; + info.frame_context_count = 4; + info.capabilities.effective_api_version = g_api_version; + info.capabilities.synchronization2_enabled = g_synchronization2; + info.capabilities.shader_storage_image_extended_formats_enabled = g_extended_formats; + zerofg::Status status = zerofg::Status::kSuccess; + g_interpolator = zerofg::Interpolator::Create(info, &status); + if (!g_interpolator) { + std::snprintf(g_reason, sizeof(g_reason), "interpolator creation failed (%d)", (int)status); + g_failed = true; + ZFG_ERR("%s", g_reason); + return 0; + } + g_failed = false; + ZFG_LOG("ReallyZero engine ready (Compat backend)"); + return 1; +} + +void zfg_stop(void) { + g_interpolator.reset(); + destroy_history(); + reset_pacing(); + g_last_sequence = 0; + g_failed = false; +} +int zfg_unavailable(void) { return g_failed || !g_interpolator ? 1 : 0; } + +int zfg_format_ok(VkFormat format) { + if (!g_supported || !g_GetPhysicalDeviceFormatProperties || format == VK_FORMAT_UNDEFINED) return 0; + VkFormatProperties input{}; + g_GetPhysicalDeviceFormatProperties(g_physical, format, &input); + const VkFormatFeatureFlags sampled = + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; + if ((input.optimalTilingFeatures & sampled) != sampled) return 0; + if (format == VK_FORMAT_A2B10G10R10_UNORM_PACK32) + return (input.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0; + VkFormatProperties internal{}; + g_GetPhysicalDeviceFormatProperties(g_physical, VK_FORMAT_A2B10G10R10_UNORM_PACK32, &internal); + const VkFormatFeatureFlags needed = VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT; + return (input.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT) != 0 && + (internal.optimalTilingFeatures & needed) == needed; +} + +int zfg_prepare(uint32_t width, uint32_t height, VkFormat format) { + if (!g_interpolator || g_failed || !width || !height) return 0; + if (!zfg_format_ok(format)) { + std::snprintf(g_reason, sizeof(g_reason), "unsupported input/output format %d", (int)format); + g_failed = true; + ZFG_ERR("%s", g_reason); + return 0; + } + if (g_width == width && g_height == height && g_format == format && g_history) return 1; + // ReallyZero's Resize accepts 64..16384 per side: refuse this frame only, before touching the + // engine's state, so a supported size later still generates. + if (width < 64 || height < 64 || width > 16384 || height > 16384) return 0; + if (g_DeviceWaitIdle) g_DeviceWaitIdle(g_device); + destroy_history(); + const zerofg::Status resized = g_interpolator->Resize(width, height, format, format); + if (resized != zerofg::Status::kSuccess) { + std::snprintf(g_reason, sizeof(g_reason), "resize failed (%d)", (int)resized); + g_failed = true; + ZFG_ERR("%s", g_reason); + return 0; + } + if (!make_history(width, height, format)) { + g_failed = true; + ZFG_ERR("%s", g_reason); + return 0; + } + ZFG_LOG("prepared %ux%u format %d", width, height, (int)format); + return 1; +} + +void zfg_configure(uint32_t multiplier, float refresh_hz) { + g_multiplier = std::clamp(multiplier, 2, 4); + g_refresh_hz = refresh_hz > 1.0f ? refresh_hz : 0.0f; +} + +void zfg_set_layer_timing(int layer) { g_layer_timing = layer != 0; } + +void zfg_set_phases(const float *phases, uint32_t count) { + g_external_count = phases ? std::min(count, static_cast(g_external_phases.size())) : 0; + for (uint32_t i = 0; i < g_external_count; i++) g_external_phases[i] = phases[i]; +} + +float zfg_phase(uint32_t index, uint32_t count) { return pair_phase(index, count); } + +uint32_t zfg_plan(uint32_t capacity, uint64_t sequence) { + if (!g_interpolator || g_failed) return 0; + note_sequence(sequence); + if (!g_history_valid || sequence <= g_history_sequence || !g_pair_interval_ns) return 0; + return pair_capacity(std::min({capacity, 3u, g_multiplier - 1})); +} + +void zfg_telemetry(float *generated, float *source_rate) { + const uint64_t typical = typical_interval_ns(); + *generated = static_cast(g_pair_count); + *source_rate = typical ? static_cast(1e9 / static_cast(typical)) : 0.0f; +} + +void zfg_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view, + uint32_t width, uint32_t height, VkFormat format, + uint64_t sequence, uint32_t generations) { + g_pair_pending = false; + g_fallback_outputs.fill(false); + if (!g_interpolator || g_failed || !source || !g_history || + format != g_format || width != g_width || height != g_height) return; + if (sequence > g_history_sequence) { + g_prev_count = g_pair_count; + g_pair_count = generations; + } + if (generations == 0 || !g_history_valid || sequence <= g_history_sequence) { + copy_current_to_history(cmd, source, width, height, sequence); + return; + } + if (!source_view) return; + g_current = source; + g_current_view = source_view; + g_current_sequence = sequence; + g_pair_pending = true; + g_pair_anonymous = g_record_stale ? (kAnonymousSequence | ++g_anonymous_count) : 0; + g_record_stale = false; +} + +void zfg_generate(VkCommandBuffer cmd, uint32_t index, uint32_t count, + VkImage output, VkImageView output_view, uint32_t width, uint32_t height) { + if (!g_pair_pending || !g_interpolator || !g_history_valid || index >= count || !output || !output_view) return; + const float phase = pair_phase(index, count); + zerofg::Image previous{}; + previous.image = g_history; previous.view = g_history_view; + previous.layout = VK_IMAGE_LAYOUT_GENERAL; previous.format = g_format; + previous.width = g_width; previous.height = g_height; + previous.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + previous.sequence = g_history_sequence; + zerofg::Image current{}; + current.image = g_current; current.view = g_current_view; + current.layout = VK_IMAGE_LAYOUT_GENERAL; current.format = g_format; + current.width = g_width; current.height = g_height; + current.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + current.sequence = g_current_sequence; + zerofg::Image result{}; + result.image = output; result.view = output_view; + result.layout = VK_IMAGE_LAYOUT_GENERAL; result.format = g_format; + result.width = width; result.height = height; + result.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if (g_pair_anonymous) previous.sequence = g_pair_anonymous; + g_interpolate_uncommitted = true; + + const zerofg::Status status = + g_interpolator->Interpolate(cmd, index, previous, current, phase, result); + if (status != zerofg::Status::kSuccess) { + ZFG_ERR("interpolation status %d; copying the real frame as fallback", (int)status); + g_fallback_outputs[index] = true; + copy_current_to_output(cmd, output, width, height); + } + if (index + 1 >= count) { + copy_current_to_history(cmd, g_current, width, height, g_current_sequence); + g_pair_pending = false; + } +} + +void zfg_commit_history_update(void) { + g_interpolate_uncommitted = false; + if (!g_history_recorded_pending) return; + g_history_layout_defined = true; + g_history_valid = true; + g_history_sequence = g_history_recorded_sequence; + g_history_recorded_pending = false; +} + +void zfg_discard_history_update(void) { + g_history_recorded_pending = false; + g_history_recorded_sequence = 0; + if (g_interpolate_uncommitted) g_record_stale = true; + g_interpolate_uncommitted = false; + g_pair_pending = false; +} + +void zfg_forget_targets(void) { + g_pair_pending = false; + if (g_interpolate_uncommitted) g_record_stale = true; + g_interpolate_uncommitted = false; + g_history_recorded_pending = false; + g_history_recorded_sequence = 0; + g_history_valid = false; + g_history_sequence = 0; + reset_pacing(); +} +} // extern "C" diff --git a/app/src/main/cpp/waylandcomp/src/framegen_zerofg.h b/app/src/main/cpp/waylandcomp/src/framegen_zerofg.h new file mode 100644 index 0000000000..83c9c39e24 --- /dev/null +++ b/app/src/main/cpp/waylandcomp/src/framegen_zerofg.h @@ -0,0 +1,38 @@ +#ifndef FRAMEGEN_ZEROFG_H +#define FRAMEGEN_ZEROFG_H +#include +#include +#ifdef __cplusplus +extern "C" { +#endif +void zfg_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance instance, + VkPhysicalDevice physical_device, VkDevice device, + uint32_t api_version, int synchronization2_enabled, + int extended_storage_formats_enabled); +void zfg_device_lost(void); +int zfg_caps_ok(void); +const char *zfg_caps_reason(void); +int zfg_start(void); +void zfg_stop(void); +int zfg_unavailable(void); +int zfg_format_ok(VkFormat format); +int zfg_prepare(uint32_t width, uint32_t height, VkFormat format); +void zfg_configure(uint32_t multiplier, float refresh_hz); +void zfg_set_layer_timing(int layer); +void zfg_set_phases(const float *phases, uint32_t count); +float zfg_phase(uint32_t index, uint32_t count); +uint32_t zfg_plan(uint32_t capacity, uint64_t sequence); +void zfg_telemetry(float *generated, float *source_rate); +void zfg_process(VkCommandBuffer command_buffer, VkImage source, VkImageView source_view, + uint32_t width, uint32_t height, VkFormat format, + uint64_t sequence, uint32_t generations); +void zfg_generate(VkCommandBuffer command_buffer, uint32_t index, uint32_t count, + VkImage output, VkImageView output_view, + uint32_t width, uint32_t height); +void zfg_forget_targets(void); +void zfg_commit_history_update(void); +void zfg_discard_history_update(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/app/src/main/cpp/waylandcomp/src/gpu_busy.c b/app/src/main/cpp/waylandcomp/src/gpu_busy.c index 48d565c20a..d7835293bb 100644 --- a/app/src/main/cpp/waylandcomp/src/gpu_busy.c +++ b/app/src/main/cpp/waylandcomp/src/gpu_busy.c @@ -73,8 +73,19 @@ void vkp_gpu_busy_device(VkPhysicalDevice pd, VkDevice dev, uint32_t family) { } void vkp_gpu_busy_device_lost(void) { + pthread_mutex_lock(&g_lock); atomic_store(&g_lost, 1); atomic_store(&g_timing, 0); + if (g_v.device) { + gpuload_ring_release(&g_ring, &g_v); + g_ring.state = 0; + } + if (g_vk.QueueSubmit == timed_submit && g_submit) g_vk.QueueSubmit = g_submit; + g_submit = NULL; + memset(&g_v, 0, sizeof(g_v)); + g_family = g_bits = 0; + g_was_on = 0; + pthread_mutex_unlock(&g_lock); } JNIEXPORT jlong JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeGpuBusyNs(JNIEnv *env, jclass cls) { diff --git a/app/src/main/cpp/waylandcomp/src/sc_layer.c b/app/src/main/cpp/waylandcomp/src/sc_layer.c index 74cd5d6b45..fb93305e4b 100644 --- a/app/src/main/cpp/waylandcomp/src/sc_layer.c +++ b/app/src/main/cpp/waylandcomp/src/sc_layer.c @@ -58,6 +58,7 @@ static struct { void (*reparent)(ASurfaceTransaction *, ASurfaceControl *, ASurfaceControl *); void (*setOnComplete)(ASurfaceTransaction *, void *, sc_complete_fn); int (*prevReleaseFence)(ASurfaceTransactionStats *, ASurfaceControl *); + int (*presentFence)(ASurfaceTransactionStats *); void (*setFrameRate)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t); void (*setFrameRateStrategy)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t, int8_t); void (*setBufferDataSpace)(ASurfaceTransaction *, ASurfaceControl *, int32_t); @@ -102,6 +103,7 @@ static int load_api(void) { SYM(reparent, "ASurfaceTransaction_reparent"); SYM(setOnComplete, "ASurfaceTransaction_setOnComplete"); SYM(prevReleaseFence, "ASurfaceTransactionStats_getPreviousReleaseFenceFd"); + SYM(presentFence, "ASurfaceTransactionStats_getPresentFenceFd"); SYM(setFrameRate, "ASurfaceTransaction_setFrameRate"); SYM(setFrameRateStrategy, "ASurfaceTransaction_setFrameRateWithChangeStrategy"); SYM(setBufferDataSpace, "ASurfaceTransaction_setBufferDataSpace"); @@ -148,6 +150,7 @@ struct slot { uint32_t fmt; int release_fd; int busy; + uint64_t generation; }; struct layer { @@ -175,6 +178,7 @@ struct layer { int votes_rate; float fps_applied; int recreate_pending; + int pending_callbacks; int32_t ds_applied; @@ -185,6 +189,8 @@ struct layer { static struct layer g_layers[SC_LAYER_COUNT]; static void apply_frame_rate(ASurfaceTransaction *tx, struct layer *l); static void coverage_text(const struct layer *l, char *out, size_t n); +static int overlay_slot(struct layer *l, struct vkp_image *src, int *idx, int *wait_fd); +static int overlay_shown(struct layer *l, int idx, const int geo[8], int translucent); static int g_layers_ready; static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; static int g_pending_cb; @@ -222,6 +228,7 @@ struct complete_ctx { ASurfaceControl *sc; int layer; int prev_slot; + uint64_t prev_generation; void *prev_token; int retire; }; @@ -260,7 +267,33 @@ static int64_t cadence_target(int64_t now, int64_t earliest, int64_t period) { return target; } +static int64_t g_planned_next_ns; + +void sc_layer_set_planned(int64_t present_ns) { + pthread_mutex_lock(&g_lock); + g_planned_next_ns = present_ns; + pthread_mutex_unlock(&g_lock); +} + +void sc_layer_timeline(int64_t *present_ns, int64_t *period_ns) { + pthread_mutex_lock(&g_timeline_lock); + *present_ns = g_timeline_present_ns; + *period_ns = g_timeline_period_ns; + pthread_mutex_unlock(&g_timeline_lock); +} + +void sc_layer_cadence_info(int64_t *gap_ns, int *group_frames) { + if (gap_ns) *gap_ns = g_cadence_gap_ns; + if (group_frames) *group_frames = g_group_frames; +} + static void apply_present_time(ASurfaceTransaction *tx, int game) { + pthread_mutex_lock(&g_lock); + const int64_t planned = game ? g_planned_next_ns : 0; + if (game) { + g_planned_next_ns = 0; + } + pthread_mutex_unlock(&g_lock); if (!api.setDesiredPresentTime) return; pthread_mutex_lock(&g_timeline_lock); const int64_t present = g_timeline_present_ns, deadline = g_timeline_deadline_ns, period = g_timeline_period_ns; @@ -280,6 +313,9 @@ static void apply_present_time(ASurfaceTransaction *tx, int game) { target = cadence_target(now, target, period); } if (game && g_group_frames > 1 && ++g_group_index >= g_group_frames) { g_group_index = 0; g_group_frames = 1; } + if (planned > 0) { + target = planned; + } api.setDesiredPresentTime(tx, target - period / 2); } @@ -288,12 +324,16 @@ static void on_complete(void *context, ASurfaceTransactionStats *stats) { pthread_mutex_lock(&g_lock); if (ctx->layer >= 0 && ctx->layer < SC_LAYER_COUNT && ctx->prev_slot >= 0 && ctx->prev_slot < POOL_MAX) { struct slot *s = &g_layers[ctx->layer].slots[ctx->prev_slot]; - int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1; - if (s->release_fd >= 0) close(s->release_fd); - s->release_fd = fd; - s->busy = 0; + if (s->generation == ctx->prev_generation) { + int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1; + if (s->release_fd >= 0) close(s->release_fd); + s->release_fd = fd; + s->busy = 0; + } } if (g_pending_cb > 0) g_pending_cb--; + if (ctx->layer >= 0 && ctx->layer < SC_LAYER_COUNT && g_layers[ctx->layer].pending_callbacks > 0) + g_layers[ctx->layer].pending_callbacks--; pthread_mutex_unlock(&g_lock); if (ctx->prev_token) { int fd = (stats && ctx->sc) ? api.prevReleaseFence(stats, ctx->sc) : -1; @@ -308,9 +348,15 @@ static int add_complete_on(ASurfaceTransaction *tx, struct layer *l, ASurfaceCon struct complete_ctx *ctx = calloc(1, sizeof(*ctx)); if (!ctx) return -1; ctx->sc = sc; ctx->layer = (int)(l - g_layers); ctx->prev_slot = prev_slot; + if (prev_slot >= 0 && prev_slot < POOL_MAX) { + pthread_mutex_lock(&g_lock); + ctx->prev_generation = l->slots[prev_slot].generation; + pthread_mutex_unlock(&g_lock); + } ctx->prev_token = prev_token; ctx->retire = retire; pthread_mutex_lock(&g_lock); g_pending_cb++; + l->pending_callbacks++; pthread_mutex_unlock(&g_lock); api.setOnComplete(tx, ctx, on_complete); return 0; @@ -397,12 +443,16 @@ static void retire_sc(struct layer *l) { ASurfaceTransaction *tx = api.txCreate(); if (tx) { retire_ops(tx, l->sc); - if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) api.release(l->sc); + if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) { + api.txDelete(tx); + droiddeck_log("layer", "%s: retirement deferred because its release callback could not be allocated", l->name); + return; + } api.txApply(tx); api.txDelete(tx); } else { - if (l->cur_token) ahb_swapchain_layer_released(l->cur_token, -1); - api.release(l->sc); + droiddeck_log("layer", "%s: retirement deferred because a transaction could not be allocated", l->name); + return; } droiddeck_log("layer", "%s: SurfaceControl retired (window %p)", l->name, (void *)l->win); l->sc = NULL; l->win = NULL; @@ -421,20 +471,28 @@ static void drain_and_free_pools(void) { if (!pending || now_ns() > deadline) break; usleep(2000); } - pthread_mutex_lock(&g_lock); for (int i = 0; i < SC_LAYER_COUNT; i++) { + struct layer *l = &g_layers[i]; + pthread_mutex_lock(&g_lock); + const int pending = l->pending_callbacks; + if (pending || l->sc) { + pthread_mutex_unlock(&g_lock); + droiddeck_log("layer", "pool drain deferred for %s (%s)", l->name, + pending ? "SurfaceControl callbacks are pending" : "SurfaceControl retirement is deferred"); + continue; + } for (int j = 0; j < POOL_MAX; j++) { - struct slot *s = &g_layers[i].slots[j]; + struct slot *s = &l->slots[j]; if (s->release_fd >= 0) { struct pollfd p = {.fd = s->release_fd, .events = POLLIN}; poll(&p, 1, 100); close(s->release_fd); } if (s->img) vkp_image_destroy(s->img); if (s->ahb) AHardwareBuffer_release(s->ahb); memset(s, 0, sizeof(*s)); s->release_fd = -1; } - g_layers[i].first_logged = 0; - g_layers[i].logged_w = g_layers[i].logged_h = 0; + l->first_logged = 0; + l->logged_w = l->logged_h = 0; + pthread_mutex_unlock(&g_lock); } - pthread_mutex_unlock(&g_lock); } static int sniff_modifier(const struct droiddeck_native_handle *h, uint64_t *mod) { @@ -612,7 +670,10 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait if (pending < 0) pending = i; } if (idx < 0) idx = pending; - if (idx >= 0) { fd = l->slots[idx].release_fd; l->slots[idx].release_fd = -1; } + if (idx >= 0) { + fd = l->slots[idx].release_fd; l->slots[idx].release_fd = -1; + l->slots[idx].generation++; + } pthread_mutex_unlock(&g_lock); if (idx < 0) return -1; if (fd >= 0 && fence_signalled(fd)) { close(fd); fd = -1; } @@ -620,7 +681,8 @@ static int take_free_slot(struct layer *l, int w, int h, uint32_t fmt, int *wait if (s->ahb && (s->w != w || s->h != h || s->fmt != fmt)) { if (fd >= 0) { close(fd); fd = -1; } vkp_image_destroy(s->img); AHardwareBuffer_release(s->ahb); - memset(s, 0, sizeof(*s)); s->release_fd = -1; + const uint64_t generation = s->generation; + memset(s, 0, sizeof(*s)); s->release_fd = -1; s->generation = generation; } if (fd >= 0 && !vkp_can_wait_sync_fd()) { if (fence_wait(fd, 100) == 0) { slot_keep_fence(s, fd); return -1; } @@ -659,7 +721,13 @@ static int ensure_sc(struct layer *l) { if (load_api() != 0) return -1; ANativeWindow *win = vkp_window(); if (!win) return -1; - if (l->sc && l->win != win) retire_sc(l); + if (l->sc && l->win != win) { + retire_sc(l); + if (l->sc) { + droiddeck_log("layer", "%s: keeping the old SurfaceControl until retirement completes", l->name); + return -1; + } + } if (!l->sc) { l->sc = api.createFromWindow(win, l->name); if (!l->sc) { droiddeck_log("error", "layer: ASurfaceControl_createFromWindow(%s) failed", l->name); return -1; } @@ -686,9 +754,15 @@ static int layer_geometry(int w, int h, int scene_w, int scene_h, const struct v static ARect g_game_src, g_game_dst; static int g_game_geo_known; +static void note_game_geometry(const int r[8]) { + g_game_src = (ARect){r[0], r[1], r[2], r[3]}; + g_game_dst = (ARect){r[4], r[5], r[6], r[7]}; + g_game_geo_known = 1; +} + static void apply_geometry(ASurfaceTransaction *tx, struct layer *l, const int r[8]) { ARect srcR = {r[0], r[1], r[2], r[3]}, dstR = {r[4], r[5], r[6], r[7]}; - if (l == &g_layers[SC_LAYER_GAME]) { g_game_src = srcR; g_game_dst = dstR; g_game_geo_known = 1; } + if (l == &g_layers[SC_LAYER_GAME]) note_game_geometry(r); if (!l->geo_valid || memcmp(&srcR, &l->geo_src, sizeof(srcR)) || memcmp(&dstR, &l->geo_dst, sizeof(dstR))) { api.setGeometry(tx, l->sc, &srcR, &dstR, 0 ); l->geo_src = srcR; l->geo_dst = dstR; l->geo_valid = 1; @@ -818,6 +892,7 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) { if (!win || win != l->win) return NULL; ASurfaceControl *fresh = api.createFromWindow(win, l->name); if (!fresh) { + l->recreate_pending = 1; droiddeck_log("error", "layer: %s: composition recovery could not create a new SurfaceControl", l->name); return NULL; } @@ -832,24 +907,47 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) { return old; } +static void rollback_swap_sc(struct layer *l, ASurfaceControl *old, int was_shown, + int32_t ds_applied, uint32_t md_applied, float hr_applied) { + if (!old) return; + ASurfaceControl *fresh = l->sc; + l->sc = old; + l->shown = was_shown; + l->recreate_pending = 1; + l->geo_valid = 0; + l->fps_applied = -1.0f; + l->ds_applied = ds_applied; l->md_applied = md_applied; l->hr_applied = hr_applied; + if (fresh) api.release(fresh); +} + static int present_slot(struct layer *l, int idx, const int r[8], const struct droiddeck_color *color, int translucent) { struct slot *s = &l->slots[idx]; ASurfaceTransaction *tx = api.txCreate(); - if (!tx) return -1; + if (!tx) { + return -1; + } + const int was_shown = l->shown; + const int32_t ds_applied = l->ds_applied; + const uint32_t md_applied = l->md_applied; + const float hr_applied = l->hr_applied; ASurfaceControl *old = swap_sc_begin(l); if (old) api.setZOrder(tx, l->sc, l->z); api.setBuffer(tx, l->sc, s->ahb, -1); if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true); api.setBufferTransparency(tx, l->sc, translucent ? ASC_TRANSPARENCY_TRANSLUCENT : ASC_TRANSPARENCY_OPAQUE); + if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW); + if (old) retire_ops(tx, old); + if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0) { + api.txDelete(tx); + rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied); + droiddeck_log("layer", "%s: frame transition skipped because its release callback could not be allocated", l->name); + return -1; + } apply_geometry(tx, l, r); apply_frame_rate(tx, l); apply_colour(tx, l, color); - if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW); - if (old) retire_ops(tx, old); - if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0 && old) - api.release(old); pthread_mutex_lock(&g_lock); s->busy = 1; pthread_mutex_unlock(&g_lock); @@ -904,23 +1002,27 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi } ASurfaceTransaction *tx = api.txCreate(); if (!tx) goto unavailable; + const int was_shown = l->shown; + const int32_t ds_applied = l->ds_applied; + const uint32_t md_applied = l->md_applied; + const float hr_applied = l->hr_applied; ASurfaceControl *old = swap_sc_begin(l); if (old) api.setZOrder(tx, l->sc, l->z); api.setBuffer(tx, l->sc, ahb, acquire_fd); if (api.setEnableBackPressure) api.setEnableBackPressure(tx, l->sc, true); api.setBufferTransparency(tx, l->sc, ASC_TRANSPARENCY_OPAQUE); - apply_geometry(tx, l, r); - apply_frame_rate(tx, l); - apply_colour(tx, l, color); if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW); if (old) retire_ops(tx, old); if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token == token ? NULL : l->cur_token, old ? 1 : 0) != 0) { api.txDelete(tx); - if (old) api.release(old); - l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f; + rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied); + droiddeck_log("layer", "zero-copy: frame transition skipped because its release callback could not be allocated"); return -1; } + apply_geometry(tx, l, r); + apply_frame_rate(tx, l); + apply_colour(tx, l, color); apply_present_time(tx, 1); api.txApply(tx); api.txDelete(tx); @@ -937,19 +1039,40 @@ unavailable: } int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw, - const struct droiddeck_color *color) { + const struct droiddeck_color *color, const struct vkp_draw *over, int *over_shown) { struct layer *l = layer_of(SC_LAYER_GAME); + *over_shown = 0; if (!src || ensure_sc(l) != 0) return -1; int sw = vkp_image_width(src), sh = vkp_image_height(src); int r[8]; int g = layer_geometry(sw, sh, scene_w, scene_h, draw, r); if (g < 0) return -1; - if (g == 0) { sc_layer_hide(); return 0; } + int og[8]; + if (over && !vkp_map_draw(over, og)) over = NULL; + if (g == 0) { + sc_layer_hide(); + if (over) *over_shown = sc_layer_present_overlay(over->img, og, over->blend) == 0 ? 1 : -1; + return 0; + } - int wait_fd; - int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd); - if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; } - if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1; + struct vkp_blit blits[2] = {{.src = src, .wait_fd = -1}, {.src = over ? over->img : NULL, .wait_fd = -1}}; + int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &blits[0].wait_fd); + if (idx < 0) { + log_drop(l); + if (g_alloc_failed) return -1; + if (over) *over_shown = sc_layer_present_overlay(over->img, og, over->blend) == 0 ? 1 : -1; + return 0; + } + blits[0].dst = l->slots[idx].img; + struct layer *ol = layer_of(SC_LAYER_OVERLAY); + int over_idx = -1; + if (over) { + note_game_geometry(r); + const int taken = overlay_slot(ol, over->img, &over_idx, &blits[1].wait_fd); + *over_shown = taken < 0 ? -1 : 1; + if (taken > 0) blits[1].dst = ol->slots[over_idx].img; + } + if (vkp_blit_images(blits, over_idx >= 0 ? 2 : 1) != 0) return -1; if (present_slot(l, idx, r, color, 0) != 0) return -1; if (color && color->dataspace) droiddeck_color_frame_shown(color, DROIDDECK_HDR_LAYER_COPY, AHB_RGBA8); if (!l->first_logged) { @@ -959,6 +1082,7 @@ int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const stru pool_kind(l->pool_modifier), l->pool_n); } vkp_signal_first_frame(); + if (over_idx >= 0 && overlay_shown(ol, over_idx, og, over->blend) != 0) *over_shown = -1; return 0; } @@ -1014,6 +1138,7 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const if (vkp_update_map(scene_w, scene_h) != 0) return -1; const int deep = hf && !hf->tonemap; if (hf) composed = 1; + vkp_framegen_set_paced_route(composed); if (hf && hf->tonemap) color = NULL; int n = vkp_pass_begin_generate(scene_w, scene_h, draws, n_draws, hf, &rw, &rh); if (n < 0) return -1; @@ -1023,7 +1148,7 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const if (!mapped) { vkp_pass_abort(); sc_layer_hide(); return 0; } idx[VKP_FG_MAX_GENERATIONS] = deep ? take_hdr_slot(l, rw, rh, &first_fd) : take_free_slot(l, rw, rh, AHB_RGBA8, &first_fd); - if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; } + if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); vkp_framegen_pacer_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; } pthread_mutex_lock(&g_lock); l->slots[idx[VKP_FG_MAX_GENERATIONS]].busy = 1; pthread_mutex_unlock(&g_lock); @@ -1045,13 +1170,18 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const if (!have_fd) { first_fd = fd; have_fd = 1; } } if (vkp_pass_copy_generated(dst, m, real, first_fd) != 0) { + vkp_framegen_pacer_abort(); slots_idle(l, idx, 0, m); if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1); return -1; } g_group_frames = m + 1; for (int k = 0; k < m; k++) { + int64_t planned; + vkp_framegen_output_planned(k, m, &planned); + sc_layer_set_planned(planned); if (present_slot(l, idx[k], r, color, 0) == 0) continue; + vkp_framegen_pacer_abort(); slots_idle(l, idx, k, m); if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1); g_group_index = 0; @@ -1060,7 +1190,11 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const } vkp_framegen_presented(m); if (real) { + int64_t planned; + vkp_framegen_output_planned(m, m, &planned); + sc_layer_set_planned(planned); if (present_slot(l, idx[VKP_FG_MAX_GENERATIONS], r, color, 0) != 0) { + vkp_framegen_pacer_abort(); slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1); g_group_index = 0; g_group_frames = 1; @@ -1148,17 +1282,19 @@ int sc_layer_overlay_affordable(void) { return ok; } -int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int translucent) { - struct layer *l = layer_of(SC_LAYER_OVERLAY); - if (!src || !geo) return -1; +static int overlay_slot(struct layer *l, struct vkp_image *src, int *idx, int *wait_fd) { + *wait_fd = -1; + if (!src) return -1; if (!sc_layer_overlay_affordable()) return -1; if (ensure_sc(l) != 0) return -1; int sw = vkp_image_width(src), sh = vkp_image_height(src); if (sw <= 0 || sh <= 0) return -1; - int wait_fd; - int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd); - if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; } - if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1; + *idx = take_free_slot(l, sw, sh, AHB_RGBA8, wait_fd); + if (*idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; } + return 1; +} + +static int overlay_shown(struct layer *l, int idx, const int geo[8], int translucent) { if (present_slot(l, idx, geo, NULL, translucent) != 0) return -1; if (!l->first_logged) { l->first_logged = 1; @@ -1167,15 +1303,38 @@ int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int transl return 0; } -static void hide_layer(struct layer *l) { - if (!l->sc || !l->shown || api.state != 1) return; +int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int translucent) { + struct layer *l = layer_of(SC_LAYER_OVERLAY); + if (!geo) return -1; + int idx; + struct vkp_blit blit = {.src = src, .wait_fd = -1}; + const int taken = overlay_slot(l, src, &idx, &blit.wait_fd); + if (taken <= 0) return taken; + blit.dst = l->slots[idx].img; + if (vkp_blit_images(&blit, 1) != 0) return -1; + return overlay_shown(l, idx, geo, translucent); +} + +static int hide_layer(struct layer *l) { + if (!l->sc || !l->shown || api.state != 1) return 0; ASurfaceTransaction *tx = api.txCreate(); - if (!tx) return; - replace_with_blank(tx, l); + if (!tx) return -1; api.setVisibility(tx, l->sc, ASC_VISIBILITY_HIDE); - add_complete(tx, l, l->cur_slot, l->cur_token, 0); + if (add_complete(tx, l, l->cur_slot, l->cur_token, 0) != 0) { + /* + * Keep the current buffer attached when its release callback cannot + * be allocated. The hide can still apply without releasing the slot. + */ + api.txApply(tx); + api.txDelete(tx); + l->shown = 0; + droiddeck_log("layer", "%s: hidden; buffer release deferred because its callback could not be allocated", l->name); + return 0; + } + replace_with_blank(tx, l); api.txApply(tx); api.txDelete(tx); l->shown = 0; l->cur_slot = -1; l->cur_token = NULL; + return 0; } void sc_layer_hide(void) { @@ -1183,17 +1342,20 @@ void sc_layer_hide(void) { int said = g_layers[SC_LAYER_GAME].shown || g_layers[SC_LAYER_OVERLAY].sc; if (g_layers[SC_LAYER_OVERLAY].sc) sc_layer_hide_overlay(); if (g_layers[SC_LAYER_GAME].shown) hide_layer(&g_layers[SC_LAYER_GAME]); - if (said) droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)"); + if (said && !g_layers[SC_LAYER_GAME].shown && !g_layers[SC_LAYER_OVERLAY].shown) + droiddeck_log("layer", "layers hidden (scene is not a single fullscreen window)"); } void sc_layer_hide_overlay(void) { layers_init(); struct layer *l = &g_layers[SC_LAYER_OVERLAY]; if (!l->sc) return; - if (l->shown) hide_layer(l); + if (l->shown && hide_layer(l) != 0) return; retire_sc(l); - droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name); - if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1; + if (!l->sc) { + droiddeck_log("layer", "%s: gone (nothing is above the game any more)", l->name); + if (g_layers[SC_LAYER_GAME].sc) g_layers[SC_LAYER_GAME].recreate_pending = 1; + } } void sc_layer_window_gone(void) { diff --git a/app/src/main/cpp/waylandcomp/src/sc_layer.h b/app/src/main/cpp/waylandcomp/src/sc_layer.h index 24a24fc25e..a7977378fa 100644 --- a/app/src/main/cpp/waylandcomp/src/sc_layer.h +++ b/app/src/main/cpp/waylandcomp/src/sc_layer.h @@ -4,6 +4,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + struct vkp_image; struct vkp_draw; struct droiddeck_color; @@ -22,7 +26,7 @@ void sc_layer_hdr_symbols(char *out, size_t size); int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw, - const struct droiddeck_color *color); + const struct droiddeck_color *color, const struct vkp_draw *over, int *over_shown); int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int scene_h); int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const struct vkp_hdr_frame *hf, @@ -51,7 +55,16 @@ void sc_layer_window_gone(void); void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns); void sc_layer_aim_take(unsigned *next, unsigned *later, unsigned *even); +/* The refresh the next game-layer frame is timed for, instead of the layer's own spacing (0: the layer's). */ +void sc_layer_set_planned(int64_t present_ns); +/* The display's frame timeline: the next expected present and the refresh period (0 until known). */ +void sc_layer_timeline(int64_t *present_ns, int64_t *period_ns); +void sc_layer_cadence_info(int64_t *gap_ns, int *group_frames); unsigned sc_layer_frames_take(void); unsigned sc_layer_drops_take(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/app/src/main/cpp/waylandcomp/src/vk_loader.h b/app/src/main/cpp/waylandcomp/src/vk_loader.h index c0782140f0..a54cc2cf3f 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_loader.h +++ b/app/src/main/cpp/waylandcomp/src/vk_loader.h @@ -15,9 +15,9 @@ X(GetPhysicalDeviceImageFormatProperties2) X(GetPhysicalDeviceProperties2) #define VK_DEVICE_FUNCS(X) \ - X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \ - X(CreateCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \ - X(DeviceWaitIdle) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \ + X(DestroyDevice) X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \ + X(CreateCommandPool) X(DestroyCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \ + X(DeviceWaitIdle) X(DestroyFence) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \ X(BindImageMemory) X(DestroyImage) X(FreeMemory) X(AcquireNextImageKHR) \ X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \ X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \ diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.c b/app/src/main/cpp/waylandcomp/src/vk_present.c index 61b2765c5b..8801c87286 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_present.c +++ b/app/src/main/cpp/waylandcomp/src/vk_present.c @@ -7,6 +7,7 @@ #include "effects_chain.h" #include "cardboard.h" #include "framegen_bridge.h" +#include "framegen_zerofg.h" #include "hdr_compose.h" #include "blend_pass.h" #include "gpu_busy.h" @@ -20,6 +21,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,6 +34,15 @@ #define LOGE(...) droiddeck_log("error", __VA_ARGS__) #define MOD_INVALID VKP_MOD_INVALID +enum vkp_image_source { + VKP_IMAGE_SOURCE_NONE = 0, + VKP_IMAGE_SOURCE_DMABUF, + VKP_IMAGE_SOURCE_AHB_WLEGL, + VKP_IMAGE_SOURCE_AHB_SOURCE, + VKP_IMAGE_SOURCE_AHB_TARGET, + VKP_IMAGE_SOURCE_SHM +}; + struct vkp_image { VkImage image; VkDeviceMemory mem; @@ -47,14 +59,61 @@ struct vkp_image { VkBuffer linear_buf; VkDeviceMemory linear_mem; VkBufferImageCopy linear_copy; + enum vkp_image_source source_type; + int source_fd; + uint32_t source_drm_format, source_stride, source_offset; + uint64_t source_modifier; + uint8_t *recovery_pixels; + struct vkp_image *next; }; +static struct vkp_image *g_client_images; +static struct vkp_image *g_rb; +static int g_recovery_attempted; + +static void image_register(struct vkp_image *img) { + if (!img) return; + img->next = g_client_images; + g_client_images = img; +} + +static void image_unregister(struct vkp_image *img) { + struct vkp_image **p = &g_client_images; + while (*p && *p != img) p = &(*p)->next; + if (*p) *p = img->next; + if (img) img->next = NULL; +} + +static void image_track_dmabuf(struct vkp_image *img, int fd, uint32_t drm_format, + uint64_t modifier, uint32_t stride, uint32_t offset) { + img->source_fd = dup(fd); + img->source_type = img->source_fd >= 0 ? VKP_IMAGE_SOURCE_DMABUF : VKP_IMAGE_SOURCE_NONE; + img->source_drm_format = drm_format; + img->source_modifier = modifier; + img->source_stride = stride; + img->source_offset = offset; + image_register(img); + if (img->source_type == VKP_IMAGE_SOURCE_NONE) + droiddeck_log("gpu", "device recovery unavailable for one DMA-BUF: source FD could not be retained"); +} + +static void image_track_ahb(struct vkp_image *img, AHardwareBuffer *buffer, + enum vkp_image_source source_type) { + AHardwareBuffer_acquire(buffer); + img->android_buffer = buffer; + img->source_type = source_type; + image_register(img); +} + +static void destroy_image_objects(struct vkp_image *img); + static ANativeWindow *g_window; static int g_ahb_import; static int g_drm_modifiers; static char *g_driver_path, *g_library_name, *g_native_lib_dir; static int g_allow_driver_fallback; static int g_dev_state; +static int dev_init(void); static void device_lost(const char *where); static const char *vk_result_name(VkResult r); @@ -105,7 +164,9 @@ static uint32_t g_qfam; static VkCommandPool g_pool; #define MAX_PRESENTS (1 + VKP_FG_MAX_GENERATIONS) static VkCommandBuffer g_cmds[MAX_PRESENTS]; -static VkSemaphore g_acqs[MAX_PRESENTS], g_rnds[MAX_PRESENTS]; +static VkSemaphore g_acqs[MAX_PRESENTS]; +static VkSemaphore *g_rnds; +static uint32_t g_rnd_count; static VkFence g_fence; static int g_swap_extra; #define SCENE_FMT VK_FORMAT_R8G8B8A8_UNORM @@ -174,6 +235,16 @@ static VkResult timed_wait(VkFence fence, uint64_t timeout) { return g_dev_state == -2 ? VK_ERROR_DEVICE_LOST : VK_ERROR_UNKNOWN; int64_t t0 = perf_now(); VkResult r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, timeout); + if (r == VK_TIMEOUT) { + droiddeck_log("gpu", "GPU fence delayed: retaining frame resources until completion"); + /* A scheduling delay does not invalidate the device. Keep this submission's + * resources and call stack alive, as the main render path already does. */ + do { + r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, UINT64_MAX); + } while (r == VK_TIMEOUT); + if (r == VK_SUCCESS) + droiddeck_log("gpu", "GPU fence completed: continuing presentation"); + } perf_add(&g_perf.wait_ns, &g_perf.wait_max_ns, &g_perf.waits, perf_now() - t0); if (r != VK_SUCCESS && r != VK_ERROR_DEVICE_LOST) quarantine_pending_work(r, "fence wait"); @@ -212,13 +283,16 @@ static pthread_cond_t g_req_condition = PTHREAD_COND_INITIALIZER; static volatile int g_mode = VKP_MODE_STRETCH, g_align = VKP_ALIGN_CENTER; +static volatile float g_zoom = 1.0f; static struct { int scene_w, scene_h, out_w, out_h, mode, align; float kx, ky, off_x, off_y; + float base_kx, base_ky, base_off_x, base_off_y, zoom; int rx, ry, rw, rh; int valid; } g_map; +static pthread_mutex_t g_map_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_game_picture_lock = PTHREAD_MUTEX_INITIALIZER; static float g_game_picture_rect[4]; static int g_game_picture_placed; @@ -264,12 +338,44 @@ static void reset_sync(void) { VkSemaphoreCreateInfo semci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; for (int k = 0; k < MAX_PRESENTS; k++) { if (g_acqs[k]) g_vk.DestroySemaphore(g_dev, g_acqs[k], NULL); - if (g_rnds[k]) g_vk.DestroySemaphore(g_dev, g_rnds[k], NULL); - g_vk.CreateSemaphore(g_dev, &semci, NULL, &g_acqs[k]); - g_vk.CreateSemaphore(g_dev, &semci, NULL, &g_rnds[k]); + g_acqs[k] = VK_NULL_HANDLE; + if (g_vk.CreateSemaphore(g_dev, &semci, NULL, &g_acqs[k]) != VK_SUCCESS) + droiddeck_log("error", "present: failed to recreate acquire semaphore %d", k); } } +static void destroy_present_semaphores(void) { + if (g_dev && g_vk.DestroySemaphore) { + for (uint32_t i = 0; i < g_rnd_count; i++) + if (g_rnds[i]) g_vk.DestroySemaphore(g_dev, g_rnds[i], NULL); + } + free(g_rnds); + g_rnds = NULL; + g_rnd_count = 0; +} + +static int create_present_semaphores(void) { + if (!g_nimg) return -1; + VkSemaphore *sems = calloc(g_nimg, sizeof(*sems)); + if (!sems) return -1; + VkSemaphoreCreateInfo semci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; + for (uint32_t i = 0; i < g_nimg; i++) { + VkResult r = g_vk.CreateSemaphore(g_dev, &semci, NULL, &sems[i]); + if (r != VK_SUCCESS) { + droiddeck_log("error", "present: failed to create image semaphore %u (%s)", + i, vk_result_name(r)); + for (uint32_t j = 0; j < i; j++) + if (sems[j]) g_vk.DestroySemaphore(g_dev, sems[j], NULL); + free(sems); + return -1; + } + } + destroy_present_semaphores(); + g_rnds = sems; + g_rnd_count = g_nimg; + return 0; +} + static void destroy_swapchain(void) { g_base_black = 0; if (g_dev_state != 1) return; @@ -279,10 +385,11 @@ static void destroy_swapchain(void) { else quarantine_pending_work(idle, "swapchain idle"); return; } - reset_sync(); for (uint32_t i = 0; i < g_nimg; i++) blendp_forget_image(g_images[i]); if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL); g_swapchain = VK_NULL_HANDLE; + destroy_present_semaphores(); + reset_sync(); g_swap_md_identity = 0; if (g_surface) g_vk.DestroySurfaceKHR(g_inst, g_surface, NULL); g_surface = VK_NULL_HANDLE; @@ -373,8 +480,21 @@ int vkp_completion_unknown(void) { return g_dev_state == -3; } void vk_present_set_scale_mode(int mode, int alignment) { if (mode < VKP_MODE_OFF || mode > VKP_MODE_INTEGER) mode = VKP_MODE_FIT; if (alignment < VKP_ALIGN_CENTER || alignment > VKP_ALIGN_PICTURE_RIGHT) alignment = VKP_ALIGN_CENTER; + pthread_mutex_lock(&g_map_lock); g_mode = mode; g_align = alignment; + pthread_mutex_unlock(&g_map_lock); +} + +void vk_present_set_zoom(float zoom) { + if (!(zoom >= 1.0f)) zoom = 1.0f; + if (zoom > 3.0f) zoom = 3.0f; + zoom = 1.0f + roundf((zoom - 1.0f) * 4.0f) * 0.25f; + pthread_mutex_lock(&g_map_lock); + if (g_zoom != zoom) { + g_zoom = zoom; + } + pthread_mutex_unlock(&g_map_lock); } static const char *mode_name(int m) { @@ -400,13 +520,18 @@ static const char *align_name(int a) { } static void update_map(int scene_w, int scene_h) { + pthread_mutex_lock(&g_map_lock); int mode = g_mode, align = g_align; + float zoom = g_zoom; int W = (int)g_extent.width, H = (int)g_extent.height; if (g_map.valid && g_map.scene_w == scene_w && g_map.scene_h == scene_h && g_map.out_w == W && - g_map.out_h == H && g_map.mode == mode && g_map.align == align) + g_map.out_h == H && g_map.mode == mode && g_map.align == align && g_map.zoom == zoom) { + pthread_mutex_unlock(&g_map_lock); return; + } + g_map.valid = 0; g_map.scene_w = scene_w; g_map.scene_h = scene_h; g_map.out_w = W; g_map.out_h = H; - g_map.mode = mode; g_map.align = align; + g_map.mode = mode; g_map.align = align; g_map.zoom = zoom; int half = H / 2; switch (align) { @@ -439,6 +564,86 @@ static void update_map(int scene_w, int scene_h) { else if (align == VKP_ALIGN_PICTURE_BOTTOM) g_map.off_y = H - scene_h * g_map.ky; else if (align == VKP_ALIGN_PICTURE_LEFT) g_map.off_x = 0; else if (align == VKP_ALIGN_PICTURE_RIGHT) g_map.off_x = W - scene_w * g_map.kx; + + g_map.base_kx = g_map.kx; + g_map.base_ky = g_map.ky; + g_map.base_off_x = g_map.off_x; + g_map.base_off_y = g_map.off_y; + + if (!(g_map.base_kx > 0.0f) || !(g_map.base_ky > 0.0f) || + !isfinite(g_map.base_kx) || !isfinite(g_map.base_ky) || + !isfinite(g_map.base_off_x) || !isfinite(g_map.base_off_y)) { + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_placed = 0; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return; + } + + if (zoom > 1.0f) { + float cx = (float)g_map.rx + (float)g_map.rw * 0.5f; + float cy = (float)g_map.ry + (float)g_map.rh * 0.5f; + float image_w, image_h; + + g_map.kx = g_map.base_kx * zoom; + g_map.ky = g_map.base_ky * zoom; + image_w = scene_w * g_map.kx; + image_h = scene_h * g_map.ky; + + g_map.off_x = cx + (g_map.base_off_x - cx) * zoom; + g_map.off_y = cy + (g_map.base_off_y - cy) * zoom; + + if (image_w >= g_map.rw) { + float min_x = (float)g_map.rx + g_map.rw - image_w; + if (g_map.off_x < min_x) g_map.off_x = min_x; + if (g_map.off_x > g_map.rx) g_map.off_x = (float)g_map.rx; + } else { + g_map.off_x = (float)g_map.rx + (g_map.rw - image_w) * 0.5f; + } + + if (image_h >= g_map.rh) { + float min_y = (float)g_map.ry + g_map.rh - image_h; + if (g_map.off_y < min_y) g_map.off_y = min_y; + if (g_map.off_y > g_map.ry) g_map.off_y = (float)g_map.ry; + } else if (align == VKP_ALIGN_PICTURE_TOP) { + g_map.off_y = 0; + } else if (align == VKP_ALIGN_PICTURE_BOTTOM) { + g_map.off_y = H - image_h; + } else { + g_map.off_y = (float)g_map.ry + (g_map.rh - image_h) * 0.5f; + } + } + + if (zoom > 1.0f && + (!(g_map.kx > 0.0f) || !(g_map.ky > 0.0f) || + !isfinite(g_map.kx) || !isfinite(g_map.ky) || + !isfinite(g_map.off_x) || !isfinite(g_map.off_y))) { + if (g_map.base_kx > 0.0f && g_map.base_ky > 0.0f && + isfinite(g_map.base_kx) && isfinite(g_map.base_ky) && + isfinite(g_map.base_off_x) && isfinite(g_map.base_off_y)) { + g_map.kx = g_map.base_kx; + g_map.ky = g_map.base_ky; + g_map.off_x = g_map.base_off_x; + g_map.off_y = g_map.base_off_y; + } else { + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_placed = 0; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return; + } + } + + if (!(g_map.kx > 0.0f) || !(g_map.ky > 0.0f) || + !isfinite(g_map.kx) || !isfinite(g_map.ky) || + !isfinite(g_map.off_x) || !isfinite(g_map.off_y)) { + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_placed = 0; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return; + } + g_map.valid = 1; pthread_mutex_lock(&g_game_picture_lock); g_game_picture_placed = mode == VKP_MODE_INTEGER || align == VKP_ALIGN_PICTURE_TOP || align == VKP_ALIGN_PICTURE_BOTTOM || align == VKP_ALIGN_PICTURE_LEFT || align == VKP_ALIGN_PICTURE_RIGHT; @@ -451,6 +656,7 @@ static void update_map(int scene_w, int scene_h) { mode_name(mode), align_name(align), scene_w, scene_h, (int)(scene_w * g_map.kx + 0.5f), (int)(scene_h * g_map.ky + 0.5f), (int)g_map.off_x, (int)g_map.off_y, W, H); + pthread_mutex_unlock(&g_map_lock); } int vkp_game_picture_rect(float rect[4]) { @@ -462,16 +668,26 @@ int vkp_game_picture_rect(float rect[4]) { } int vkp_output_to_scene(double ox, double oy, double *sx, double *sy) { - if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) return 0; + pthread_mutex_lock(&g_map_lock); + if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } *sx = (ox - g_map.off_x) / g_map.kx; *sy = (oy - g_map.off_y) / g_map.ky; + pthread_mutex_unlock(&g_map_lock); return 1; } int vkp_scene_to_output(double sx, double sy, double *ox, double *oy) { - if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) return 0; + pthread_mutex_lock(&g_map_lock); + if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } *ox = sx * g_map.kx + g_map.off_x; *oy = sy * g_map.ky + g_map.off_y; + pthread_mutex_unlock(&g_map_lock); return 1; } @@ -480,6 +696,99 @@ void vkp_output_size(int *w, int *h) { *h = (int)g_extent.height; } +int vkp_zoom_pan_cursor(double ox, double oy) { + double cursor_x, cursor_y; + float next_x, next_y; + float image_w, image_h; + int changed; + + pthread_mutex_lock(&g_map_lock); + if (!g_map.valid || g_map.zoom != g_zoom || g_map.mode != g_mode || + g_map.align != g_align || g_zoom <= 1.0f || g_zoom > 3.0f || + g_map.scene_w <= 0 || g_map.scene_h <= 0 || + g_map.rw <= 0 || g_map.rh <= 0 || + g_map.base_kx <= 0.0f || g_map.base_ky <= 0.0f || + g_map.kx <= 0.0f || g_map.ky <= 0.0f || + !isfinite(g_map.base_kx) || !isfinite(g_map.base_ky) || + !isfinite(g_map.kx) || !isfinite(g_map.ky) || + !isfinite(g_map.off_x) || !isfinite(g_map.off_y)) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + if (!isfinite(ox) || !isfinite(oy)) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + cursor_x = (ox - g_map.off_x) / g_map.kx; + cursor_y = (oy - g_map.off_y) / g_map.ky; + + if (cursor_x < 0.0) cursor_x = 0.0; + if (cursor_y < 0.0) cursor_y = 0.0; + if (cursor_x > g_map.scene_w - 1) cursor_x = g_map.scene_w - 1; + if (cursor_y > g_map.scene_h - 1) cursor_y = g_map.scene_h - 1; + + next_x = g_map.off_x; + next_y = g_map.off_y; + image_w = g_map.scene_w * g_map.kx; + image_h = g_map.scene_h * g_map.ky; + + if (image_w > g_map.rw) { + float left = ((float)g_map.rx - g_map.off_x) / g_map.kx; + float right = ((float)(g_map.rx + g_map.rw) - g_map.off_x) / g_map.kx; + float margin = (right - left) * 0.2f; + + if (cursor_x < left + margin) + next_x += (float)(left + margin - cursor_x) * g_map.kx * 0.5f; + else if (cursor_x > right - margin) + next_x -= (float)(cursor_x - (right - margin)) * g_map.kx * 0.5f; + + float min_x = (float)g_map.rx + g_map.rw - image_w; + if (next_x < min_x) next_x = min_x; + if (next_x > g_map.rx) next_x = (float)g_map.rx; + } + + if (image_h > g_map.rh) { + float top = ((float)g_map.ry - g_map.off_y) / g_map.ky; + float bottom = ((float)(g_map.ry + g_map.rh) - g_map.off_y) / g_map.ky; + float margin = (bottom - top) * 0.2f; + + if (cursor_y < top + margin) + next_y += (float)(top + margin - cursor_y) * g_map.ky * 0.5f; + else if (cursor_y > bottom - margin) + next_y -= (float)(cursor_y - (bottom - margin)) * g_map.ky * 0.5f; + + float min_y = (float)g_map.ry + g_map.rh - image_h; + if (next_y < min_y) next_y = min_y; + if (next_y > g_map.ry) next_y = (float)g_map.ry; + } + + if (!isfinite(next_x) || !isfinite(next_y)) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + changed = fabsf(next_x - g_map.off_x) >= 0.5f || + fabsf(next_y - g_map.off_y) >= 0.5f; + if (!changed) { + pthread_mutex_unlock(&g_map_lock); + return 0; + } + + g_map.off_x = next_x; + g_map.off_y = next_y; + + pthread_mutex_lock(&g_game_picture_lock); + g_game_picture_rect[0] = g_map.off_x; + g_game_picture_rect[1] = g_map.off_y; + g_game_picture_rect[2] = g_map.off_x + g_map.scene_w * g_map.kx; + g_game_picture_rect[3] = g_map.off_y + g_map.scene_h * g_map.ky; + pthread_mutex_unlock(&g_game_picture_lock); + pthread_mutex_unlock(&g_map_lock); + return 1; +} + static void init_black_image(void); static int has_ext(VkExtensionProperties *e, uint32_t n, const char *name) { @@ -518,7 +827,7 @@ static void log_display_driver(void) { g_library_name); } -static int dev_init(void) { +static int dev_init_once(void) { if (g_dev_state != 0) return g_dev_state == 1 ? 0 : -1; if (vk_loader_open(g_driver_path, g_library_name, g_native_lib_dir) != 0) { @@ -720,6 +1029,189 @@ static int dev_init(void) { return 0; } +static void suspend_client_images(void) { + for (struct vkp_image *img = g_client_images; img; img = img->next) { + if (img->source_type == VKP_IMAGE_SOURCE_SHM && !img->recovery_pixels) + img->source_type = VKP_IMAGE_SOURCE_NONE; + if (img->map && g_vk.UnmapMemory && g_dev) g_vk.UnmapMemory(g_dev, img->mem); + img->map = NULL; + destroy_image_objects(img); + } +} + +static int restore_client_image(struct vkp_image *img) { + if (!img || img->source_type == VKP_IMAGE_SOURCE_NONE) return -1; + struct vkp_image *replacement = NULL; + switch (img->source_type) { + case VKP_IMAGE_SOURCE_DMABUF: + if (img->source_fd >= 0) + replacement = vkp_image_import_dmabuf(img->source_fd, img->source_drm_format, img->source_modifier, + img->w, img->h, img->source_stride, img->source_offset, + img->blit_dst); + break; + case VKP_IMAGE_SOURCE_AHB_WLEGL: + replacement = vkp_image_from_android_buffer(img->android_buffer); + break; + case VKP_IMAGE_SOURCE_AHB_SOURCE: + replacement = vkp_image_from_ahb(img->android_buffer); + break; + case VKP_IMAGE_SOURCE_AHB_TARGET: + replacement = vkp_image_import_ahb(img->android_buffer, NULL, 0); + break; + case VKP_IMAGE_SOURCE_SHM: + replacement = vkp_image_create_shm(img->w, img->h); + break; + default: + break; + } + if (!replacement) return -1; + + struct vkp_image *next = img->next; + const enum vkp_image_source old_type = img->source_type; + const int old_fd = img->source_fd; + AHardwareBuffer *old_ahb = img->android_buffer; + uint8_t *pixels = img->recovery_pixels; + image_unregister(replacement); + *img = *replacement; + img->next = next; + free(replacement); + if (old_type == VKP_IMAGE_SOURCE_DMABUF && old_fd >= 0) close(old_fd); + if (old_ahb) AHardwareBuffer_release(old_ahb); + if (old_type == VKP_IMAGE_SOURCE_SHM && pixels && img->map) { + const size_t row_bytes = (size_t)img->w * 4; + for (int y = 0; y < img->h; y++) + memcpy((uint8_t *)img->map + img->offset + (size_t)y * img->row_pitch, + pixels + (size_t)y * row_bytes, row_bytes); + img->recovery_pixels = pixels; + pixels = NULL; + } + free(pixels); + return 0; +} + +static int restore_client_images(void) { + int failed = 0; + for (struct vkp_image *img = g_client_images; img; ) { + struct vkp_image *next = img->next; + if (restore_client_image(img) != 0) { + failed++; + droiddeck_log("error", "GPU recovery: could not re-import a retained %dx%d client buffer", + img->w, img->h); + } + img = next; + } + return failed ? -1 : 0; +} + +static void release_lost_device(void) { + vkp_pass_abort(); + blendp_destroy(); + vkp_effects_destroy(); + hdrc_destroy(); + vkp_cardboard_destroy(); + vkp_framegen_device_lost(); + vkp_gpu_busy_device_lost(); + suspend_client_images(); + + if (g_rb) { + vkp_image_destroy(g_rb); + g_rb = NULL; + } + if (g_scene.img) g_vk.DestroyImage(g_dev, g_scene.img, NULL); + if (g_scene.mem) g_vk.FreeMemory(g_dev, g_scene.mem, NULL); + memset(&g_scene, 0, sizeof(g_scene)); + struct vkp_img_slot *slots[] = {&g_mixed, &g_hdrscene, &g_fgscene}; + for (size_t i = 0; i < sizeof(slots) / sizeof(slots[0]); i++) { + if (slots[i]->img) g_vk.DestroyImage(g_dev, slots[i]->img, NULL); + if (slots[i]->mem) g_vk.FreeMemory(g_dev, slots[i]->mem, NULL); + memset(slots[i], 0, sizeof(*slots[i])); + } + if (g_black_img) g_vk.DestroyImage(g_dev, g_black_img, NULL); + if (g_black_mem) g_vk.FreeMemory(g_dev, g_black_mem, NULL); + g_black_img = VK_NULL_HANDLE; + g_black_mem = VK_NULL_HANDLE; + g_black_state = 0; + + for (int i = 0; i < MAX_PRESENTS; i++) { + if (g_acqs[i]) g_vk.DestroySemaphore(g_dev, g_acqs[i], NULL); + if (g_rnds[i]) g_vk.DestroySemaphore(g_dev, g_rnds[i], NULL); + g_acqs[i] = g_rnds[i] = VK_NULL_HANDLE; + } + if (g_wait_sem) g_vk.DestroySemaphore(g_dev, g_wait_sem, NULL); + g_wait_sem = VK_NULL_HANDLE; + if (g_fence) g_vk.DestroyFence(g_dev, g_fence, NULL); + g_fence = VK_NULL_HANDLE; + if (g_pool) g_vk.DestroyCommandPool(g_dev, g_pool, NULL); + g_pool = VK_NULL_HANDLE; + memset(g_cmds, 0, sizeof(g_cmds)); + + if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL); + g_swapchain = VK_NULL_HANDLE; + free(g_images); + g_images = NULL; + g_nimg = 0; + if (g_surface) g_vk.DestroySurfaceKHR(g_inst, g_surface, NULL); + g_surface = VK_NULL_HANDLE; + if (g_dev) g_vk.DestroyDevice(g_dev, NULL); + g_dev = VK_NULL_HANDLE; + if (g_inst) g_vk.DestroyInstance(g_inst, NULL); + g_inst = VK_NULL_HANDLE; + vk_loader_close(); + + g_pd = VK_NULL_HANDLE; + g_queue = VK_NULL_HANDLE; + g_qfam = 0; + memset(&g_memprops, 0, sizeof(g_memprops)); + memset(&g_map, 0, sizeof(g_map)); + memset(&g_extent, 0, sizeof(g_extent)); + memset(&g_caps_extent, 0, sizeof(g_caps_extent)); + g_surface_transform_known = 0; + g_surface_checked_ns = 0; + g_ahb_import = 0; + g_drm_modifiers = 0; + g_colorspace_ext = 0; + g_import_sem_fd = NULL; + g_ahb_properties = NULL; + g_set_hdr_metadata = NULL; + g_swap_extra = 0; + g_swap_is_hdr = 0; + g_swap_fmt = VK_FORMAT_UNDEFINED; + g_swap_md_identity = 0; + g_swap_retry_at_ns = 0; + g_swap_fail_logged = 0; + g_base_black = 0; + g_dev_state = 0; +} + +static int dev_init(void) { + if (g_dev_state != -2) return dev_init_once(); + if (g_recovery_attempted) return -1; + g_recovery_attempted = 1; + droiddeck_log("gpu", "VK_ERROR_DEVICE_LOST: attempting one in-process compositor recovery"); + release_lost_device(); + if (dev_init_once() != 0) { + if (g_dev_state == -3) { + droiddeck_log("error", "GPU recovery initialization left completion unknown; retaining resources"); + return -1; + } + release_lost_device(); + g_dev_state = -2; + droiddeck_log("error", "GPU recovery failed while recreating the Vulkan device; restart the session"); + set_fault("the display GPU was lost and in-process recovery failed"); + return -1; + } + if (restore_client_images() != 0) { + release_lost_device(); + g_dev_state = -2; + droiddeck_log("error", "GPU recovery could not restore every client buffer; restart the session"); + set_fault("the display GPU was lost and some client buffers could not be restored"); + return -1; + } + g_recovery_attempted = 0; + droiddeck_log("gpu", "Vulkan device and retained client buffers recovered"); + return 0; +} + int vkp_ready(void) { return dev_init(); } static int swap_init_locked(void); @@ -925,12 +1417,35 @@ static int swap_init_locked(void) { SWLOGE("present: vkCreateSwapchainKHR failed (%d)", (int)cr); return -1; } - g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, NULL); + cr = g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, NULL); + if (cr != VK_SUCCESS || !g_nimg) { + SWLOGE("present: vkGetSwapchainImagesKHR count failed (%s)", vk_result_name(cr)); + g_nimg = 0; + return -1; + } g_images = calloc(g_nimg, sizeof(VkImage)); - g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, g_images); + if (!g_images) { + SWLOGE("present: failed to allocate swapchain image list"); + g_nimg = 0; + return -1; + } + cr = g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, g_images); + if (cr != VK_SUCCESS) { + SWLOGE("present: vkGetSwapchainImagesKHR failed (%s)", vk_result_name(cr)); + free(g_images); + g_images = NULL; + g_nimg = 0; + return -1; + } + if (create_present_semaphores() != 0) { + SWLOGE("present: failed to initialize per-image present semaphores"); + return -1; + } droiddeck_log("gpu", "screen output %ux%u, %u buffers, vsync%s", g_extent.width, g_extent.height, g_nimg, g_swap_extra ? " (frame generation: several presents per frame)" : ""); + droiddeck_log("gpu", "present synchronization: %u render-finished semaphores, one per swapchain image", + g_rnd_count); return 0; } @@ -1216,6 +1731,8 @@ struct vkp_image *vkp_image_from_android_buffer(AHardwareBuffer *buffer) { if (result != VK_SUCCESS) goto fail; AHardwareBuffer_acquire(buffer); img->android_buffer = buffer; + img->source_type = VKP_IMAGE_SOURCE_AHB_WLEGL; + image_register(img); return img; fail: LOGE("android_wlegl: Vulkan buffer import failed: %s", vk_result_name(result)); @@ -1367,6 +1884,7 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) { if (padded_target) droiddeck_log("gpu", "linear layer target %dx%d writes at pitch %u via DMA-BUF", w, h, stride); + image_track_dmabuf(img, fd, drm_format, modifier, stride, offset); return img; } if (padded_target) { free(img); return NULL; } @@ -1436,11 +1954,12 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t g_vk.FreeMemory(g_dev, img->mem, NULL); g_vk.DestroyImage(g_dev, img->image, NULL); free(img); return NULL; } + image_track_dmabuf(img, fd, drm_format, modifier, stride, offset); return img; } void vkp_wait_idle(void) { - if (g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev); + if (g_dev_state == 1 && g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev); } struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) { @@ -1490,6 +2009,7 @@ struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) { if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL); g_vk.DestroyImage(g_dev, img->image, NULL); free(img); return NULL; } + image_track_ahb(img, ahb, VKP_IMAGE_SOURCE_AHB_SOURCE); return img; } @@ -1585,6 +2105,7 @@ struct vkp_image *vkp_image_import_ahb(struct AHardwareBuffer *ahb, char *info, if (info && info_n) snprintf(info, info_n, "VkFormat %d, %llu bytes, memory type %d of memoryTypeBits %#x", (int)fp.format, (unsigned long long)hp.allocationSize, idx, hp.memoryTypeBits); + image_track_ahb(img, ahb, VKP_IMAGE_SOURCE_AHB_TARGET); return img; } @@ -1638,13 +2159,34 @@ struct vkp_image *vkp_image_create_shm(int w, int h) { if (g_vk.MapMemory(g_dev, img->mem, 0, req.size, 0, &img->map) != VK_SUCCESS) { vkp_image_destroy(img); return NULL; } + img->source_type = VKP_IMAGE_SOURCE_SHM; + image_register(img); return img; } void vkp_image_upload_shm(struct vkp_image *img, const void *data, int stride) { - if (g_dev_state != 1 || !img || !img->map || !data) return; - size_t rowbytes = (size_t)img->w * 4; + if (!img || !data || img->w <= 0 || img->h <= 0 || stride <= 0 || + (size_t)img->w > SIZE_MAX / 4) + return; + + const size_t full_rowbytes = (size_t)img->w * 4; + size_t rowbytes = full_rowbytes; if ((size_t)stride < rowbytes) rowbytes = (size_t)stride; + + if (img->source_type == VKP_IMAGE_SOURCE_SHM && !img->recovery_pixels) { + if ((size_t)img->h <= SIZE_MAX / full_rowbytes) { + const size_t bytes = full_rowbytes * (size_t)img->h; + img->recovery_pixels = calloc(1, bytes); + } + if (!img->recovery_pixels) img->source_type = VKP_IMAGE_SOURCE_NONE; + } + if (img->source_type == VKP_IMAGE_SOURCE_SHM && img->recovery_pixels) { + for (int y = 0; y < img->h; y++) + memcpy(img->recovery_pixels + (size_t)y * full_rowbytes, + (const uint8_t *)data + (size_t)y * stride, rowbytes); + } + + if (g_dev_state != 1 || !img->map) return; for (int y = 0; y < img->h; y++) memcpy((uint8_t *)img->map + img->offset + (size_t)y * img->row_pitch, (const uint8_t *)data + (size_t)y * stride, rowbytes); @@ -1661,7 +2203,10 @@ void vkp_image_destroy(struct vkp_image *img) { if (img->map) g_vk.UnmapMemory(g_dev, img->mem); destroy_image_objects(img); } + image_unregister(img); + if (img->source_type == VKP_IMAGE_SOURCE_DMABUF && img->source_fd >= 0) close(img->source_fd); if (img->android_buffer) AHardwareBuffer_release(img->android_buffer); + free(img->recovery_pixels); free(img); } @@ -1925,14 +2470,23 @@ static int compose_hdr(VkCommandBuffer cmd, const struct vkp_draw *draws, int n, } static void device_lost(const char *where) { - if (g_dev_state == -2) return; + if (g_dev_state == -2 || g_dev_state == -3) return; + + if (g_dev_state == 1) { + VkResult idle = g_vk.DeviceWaitIdle ? g_vk.DeviceWaitIdle(g_dev) : VK_ERROR_UNKNOWN; + if (idle != VK_SUCCESS && idle != VK_ERROR_DEVICE_LOST) { + quarantine_pending_work(idle, "device-loss idle"); + return; + } + } + g_dev_state = -2; g_base_black = 0; vkp_framegen_device_lost(); vkp_gpu_busy_device_lost(); - droiddeck_log("error", "GPU device lost (VK_ERROR_DEVICE_LOST in %s): the compositor has stopped presenting; " - "restart the session", where); - set_fault("the display GPU was lost (VK_ERROR_DEVICE_LOST in %s)", where); + droiddeck_log("error", "GPU device lost (VK_ERROR_DEVICE_LOST in %s): the compositor will try one in-process recovery", + where); + set_fault("the display GPU was lost (VK_ERROR_DEVICE_LOST in %s); recovery pending", where); for (uint32_t i = 0; i < g_nimg; i++) blendp_forget_image(g_images[i]); if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL); g_swapchain = VK_NULL_HANDLE; @@ -2157,11 +2711,10 @@ static void send_hdr_metadata(const struct droiddeck_color *c) { static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf, int *how) { if (how) *how = 0; - if (g_dev_state < 0) return -1; + if (g_dev_state == -1 || g_dev_state == -3) return -1; vkp_apply_window_request(); sc_layer_hide_base(); check_surface_changed(); - if (g_dev_state == -2) return -1; if (dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1; if (g_swapchain && vkp_framegen_extra_images() != g_swap_extra) { @@ -2213,6 +2766,21 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i pass_n = 1; overlay_start = source_end; } + const int upscale_w = (int)(scene_w * g_map.kx + 0.5f); + const int upscale_h = (int)(scene_h * g_map.ky + 0.5f); + const int post_upscale = fx && fg && !hf && !cb && vkp_effects_upscaling() && + (upscale_w > input_w || upscale_h > input_h) && + vkp_effects_prepare_generated(input_w, input_h, upscale_w, upscale_h); + if (post_upscale) { + static int last_input_w, last_input_h, last_output_w, last_output_h; + if (input_w != last_input_w || input_h != last_input_h || + upscale_w != last_output_w || upscale_h != last_output_h) { + droiddeck_log("framegen", "post-upscale: interpolate %dx%d, spatial filter each present to %dx%d", + input_w, input_h, upscale_w, upscale_h); + last_input_w = input_w; last_input_h = input_h; + last_output_w = upscale_w; last_output_h = upscale_h; + } + } const int deep = hf && n > 0 && fg && g_swap_is_hdr && !hf->tonemap && vkp_framegen_format_ok(FG_HDR_FMT) && ensure_img(&g_fgscene, scene_w, scene_h, FG_HDR_FMT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | @@ -2309,11 +2877,15 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i int drawn = 0; int hdr_how = 0; - if (hf && pass && n > 0 && + const int hdr_compose_requested = hf && pass && n > 0; + int hdr_unconverted = 0; + if (hdr_compose_requested && compose_hdr(cmd, draws, n, hf, scene_w, scene_h, scene_img, scene_fmt, g_swap_is_hdr ? HDRC_OUT_PQ : HDRC_OUT_SDR) == 0) { hdr_how = g_swap_is_hdr ? 1 : 2; drawn = n; + } else if (hdr_compose_requested) { + hdr_unconverted = 1; } for (int i = 0; i < draw_n && !hdr_how; i++) { VkImageBlit blit; @@ -2328,6 +2900,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i if (!(pass && fx)) release_external_client_draws(cmd, draws, n); int ngen = 0; + int history_staged = 0; VkImage gens[VKP_FG_MAX_GENERATIONS] = {VK_NULL_HANDLE}; VkImage result = scene_img; int rw = input_w, rh = input_h; @@ -2344,8 +2917,11 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i if (fx) { int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f); if (fg && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; } - vkp_effects_set_formats(scene_fmt, scene_fmt); - result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh); + if (post_upscale) { mapped_w = input_w; mapped_h = input_h; } + vkp_effects_set_formats(scene_fmt, scene_fmt, hdr_how == 1 || hdr_unconverted); + result = post_upscale + ? vkp_effects_run_before_generated(cmd, scene_img, input_w, input_h, &rw, &rh) + : vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh); effects_overlay_draws(cmd, result, rw, rh, scene_w, scene_h, draws ? draws + overlay_start : NULL, n - overlay_start); release_external_client_draws(cmd, draws, n); @@ -2363,12 +2939,19 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i 0, 0, NULL, 0, NULL, 1, &b_general); if (fg) { + vkp_framegen_set_layer_timing(0); + history_staged = 1; ngen = vkp_framegen_run(cmd, result, VK_NULL_HANDLE, rw, rh, scene_fmt, gens); if (ngen < 0) ngen = 0; if (ngen > VKP_FG_MAX_GENERATIONS) ngen = VKP_FG_MAX_GENERATIONS; } - record_screen_blit(cmd, ngen ? gens[0] : result, rw, rh, scene_w, scene_h, img, blit_filter, cb); + VkImage screen = ngen ? gens[0] : result; + int screen_w = rw, screen_h = rh; + if (post_upscale) + screen = vkp_effects_run_generated(cmd, screen, rw, rh, upscale_w, upscale_h, + 0, &screen_w, &screen_h); + record_screen_blit(cmd, screen, screen_w, screen_h, scene_w, scene_h, img, blit_filter, cb); } g_vk.EndCommandBuffer(cmd); @@ -2383,7 +2966,10 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i /* Teardown may have retained this frame's pending work, or * acquire may have reported real device loss. Neither permits * a completion-marker submit or another fence wait. */ - if (g_dev_state != 1) return -1; + if (g_dev_state != 1) { + if (history_staged) zfg_discard_history_update(); + return -1; + } droiddeck_log("framegen", "present %d/%d: no swapchain image; the frame ends early", k + 1, presents); pr = VK_ERROR_OUT_OF_DATE_KHR; break; @@ -2392,44 +2978,80 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i VkCommandBuffer ck = g_cmds[k]; g_vk.ResetCommandBuffer(ck, 0); g_vk.BeginCommandBuffer(ck, &bi); - record_screen_blit(ck, k < ngen ? gens[k] : result, rw, rh, scene_w, scene_h, img, blit_filter, cb); + VkImage screen = k < ngen ? gens[k] : result; + int screen_w = rw, screen_h = rh; + if (post_upscale) + screen = vkp_effects_run_generated(ck, screen, rw, rh, upscale_w, upscale_h, + k, &screen_w, &screen_h); + record_screen_blit(ck, screen, screen_w, screen_h, scene_w, scene_h, img, blit_filter, cb); g_vk.EndCommandBuffer(ck); } const int last = (k + 1 == presents); VkPipelineStageFlags wait = VK_PIPELINE_STAGE_TRANSFER_BIT; + /* A present-wait semaphore is reused only after this exact swapchain image + * has been acquired again; a frame-slot fence cannot prove present completion. */ + if (img >= g_rnd_count || !g_rnds[img]) { + droiddeck_log("error", "present: image index %u exceeds semaphore count %u", + img, g_rnd_count); + if (history_staged) zfg_discard_history_update(); + destroy_swapchain(); + return -1; + } VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .waitSemaphoreCount = 1, .pWaitSemaphores = &g_acqs[k], .pWaitDstStageMask = &wait, .commandBufferCount = 1, - .pCommandBuffers = &g_cmds[k], .signalSemaphoreCount = 1, .pSignalSemaphores = &g_rnds[k]}; + .pCommandBuffers = &g_cmds[k], .signalSemaphoreCount = 1, .pSignalSemaphores = &g_rnds[img]}; VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, last ? g_fence : VK_NULL_HANDLE); if (qr != VK_SUCCESS) { + if (history_staged) zfg_discard_history_update(); if (qr == VK_ERROR_DEVICE_LOST) device_lost("submit"); else LOGE("present: submit %d/%d failed (%d)", k + 1, presents, (int)qr); if (g_dev_state != -2) destroy_swapchain(); return -1; } fence_submitted = last; + if (k == 0 && history_staged) { + zfg_commit_history_update(); + history_staged = 0; + } VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1, - .pWaitSemaphores = &g_rnds[k], .swapchainCount = 1, + .pWaitSemaphores = &g_rnds[img], .swapchainCount = 1, .pSwapchains = &g_swapchain, .pImageIndices = &img}; const int64_t t_pres = perf_now(); pr = g_vk.QueuePresentKHR(g_queue, &pi); perf_add(&g_perf.present_ns, &g_perf.present_max_ns, &g_perf.presents, perf_now() - t_pres); if (k < ngen) presented_gen++; - if (pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; } + if (pr == VK_ERROR_DEVICE_LOST) { + if (history_staged) zfg_discard_history_update(); + device_lost("present"); + return -1; + } if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) break; } if (!fence_submitted) { VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO}; VkResult marker = g_vk.QueueSubmit(g_queue, 1, &si, g_fence); if (marker != VK_SUCCESS) { + if (history_staged) zfg_discard_history_update(); if (marker == VK_ERROR_DEVICE_LOST) device_lost("frame completion submit"); else quarantine_pending_work(marker, "frame completion submit"); return -1; /* no fence was submitted; never wait on its unsignalled state */ } + if (history_staged) { + zfg_discard_history_update(); + history_staged = 0; + } } VkResult fr = timed_wait(g_fence, UINT64_MAX); - if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; } - if (fr != VK_SUCCESS) return -1; + if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { + if (history_staged) zfg_discard_history_update(); + device_lost("present"); + return -1; + } + if (fr != VK_SUCCESS) { + if (history_staged) zfg_discard_history_update(); + return -1; + } + vkp_effects_release_generated_sources(); if (fg) vkp_framegen_presented(presented_gen); if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) { droiddeck_log("gpu", "screen surface %s on present: rebuilding the swapchain", vk_result_name(pr)); @@ -2502,7 +3124,7 @@ void vkp_signal_first_frame(void) { } int vkp_update_map(int scene_w, int scene_h) { - if (g_dev_state == -2 || dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1; + if (dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1; if (vkp_quest_layer_presentation()) { int w = ANativeWindow_getWidth(g_window), h = ANativeWindow_getHeight(g_window); if (w <= 0 || h <= 0) return -1; @@ -2575,8 +3197,38 @@ static void blit_to_layer(VkCommandBuffer cmd, VkImage src, VkImageLayout src_la 0, 0, NULL, 0, NULL, 1, &release); } -int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) { - if (!src || src->blit_dst || !dst || !dst->blit_dst || g_dev_state == -2 || dev_init() != 0) { +static int merge_wait_fds(int a, int b) { + if (a < 0) return b; + if (b < 0) return a; + struct sync_merge_data m = {.name = "droiddeck-layer-copy", .fd2 = b}; + if (ioctl(a, SYNC_IOC_MERGE, &m) == 0) { + close(a); + close(b); + return m.fence; + } + struct pollfd p = {.fd = b, .events = POLLIN}; + int r; + do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR); + close(b); + if (r != 0) return a; + p.fd = a; + do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR); + close(a); + return -2; +} + +int vkp_blit_images(const struct vkp_blit *blits, int n) { + int wait_fd = -1; + for (int i = 0; i < n; i++) { + if (wait_fd == -2) { if (blits[i].wait_fd >= 0) close(blits[i].wait_fd); continue; } + wait_fd = merge_wait_fds(wait_fd, blits[i].wait_fd); + } + int valid = n > 0 && wait_fd != -2; + for (int i = 0; valid && i < n; i++) { + const struct vkp_image *src = blits[i].src, *dst = blits[i].dst; + if (!src || src->blit_dst || !dst || !dst->blit_dst) valid = 0; + } + if (!valid || dev_init() != 0) { if (wait_fd >= 0) close(wait_fd); return -1; } @@ -2589,32 +3241,35 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) { VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT}; g_vk.BeginCommandBuffer(g_cmd, &bi); - stage_linear_dmabuf(g_cmd, src); - struct vkp_external_client_barrier_pair src_pair; - const int src_external = vkp_external_client_barrier_pair( - src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair); - VkImageMemoryBarrier acq = src_external ? src_pair.acquire : (VkImageMemoryBarrier){ - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, - .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT}; - if (!src_external) { - acq.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED; - acq.newLayout = VK_IMAGE_LAYOUT_GENERAL; - acq.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; - src->in_general = 1; + for (int i = 0; i < n; i++) { + struct vkp_image *src = blits[i].src, *dst = blits[i].dst; + stage_linear_dmabuf(g_cmd, src); + struct vkp_external_client_barrier_pair src_pair; + const int src_external = vkp_external_client_barrier_pair( + src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair); + VkImageMemoryBarrier acq = src_external ? src_pair.acquire : (VkImageMemoryBarrier){ + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, + .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT}; + if (!src_external) { + acq.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED; + acq.newLayout = VK_IMAGE_LAYOUT_GENERAL; + acq.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; + src->in_general = 1; + } + g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &acq); + int bw = src->w < dst->w ? src->w : dst->w, bh = src->h < dst->h ? src->h : dst->h; + VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, + .srcOffsets = {{0, 0, 0}, {bw, bh, 1}}, + .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, + .dstOffsets = {{0, 0, 0}, {bw, bh, 1}}}; + blit_to_layer(g_cmd, src->image, src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL, + dst, &blit, VK_FILTER_NEAREST); + release_external_client_image(g_cmd, src); } - g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &acq); - int bw = src->w < dst->w ? src->w : dst->w, bh = src->h < dst->h ? src->h : dst->h; - VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, - .srcOffsets = {{0, 0, 0}, {bw, bh, 1}}, - .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, - .dstOffsets = {{0, 0, 0}, {bw, bh, 1}}}; - blit_to_layer(g_cmd, src->image, src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL, - dst, &blit, VK_FILTER_NEAREST); - release_external_client_image(g_cmd, src); g_vk.EndCommandBuffer(g_cmd); VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT; @@ -2639,11 +3294,9 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) { -static struct vkp_image *g_rb; - int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) { if (!src || src->blit_dst || !out || src->w <= 0 || src->h <= 0 || src->w * src->h > max_px || - g_dev_state == -2 || dev_init() != 0) + dev_init() != 0) return -1; if (g_rb && (g_rb->w != src->w || g_rb->h != src->h)) { vkp_image_destroy(g_rb); g_rb = NULL; } if (!g_rb) { @@ -2749,6 +3402,9 @@ static struct { int active; VkImage result; int rw, rh; + /* The layer buffers' size: rw x rh, or the spatial filter's output when it runs on each frame after generation. */ + int ow, oh; + int post_upscale; int ngen; VkImage gens[VKP_FG_MAX_GENERATIONS]; } g_pass; @@ -2869,7 +3525,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw g_vk.EndCommandBuffer(cmd); return -1; } - if (vkp_effects_active()) vkp_effects_set_formats(scene_fmt, scene_fmt); + if (vkp_effects_active()) vkp_effects_set_formats(scene_fmt, scene_fmt, !hf->tonemap); } else { VkClearColorValue black = {.float32 = {0.0f, 0.0f, 0.0f, 1.0f}}; g_vk.CmdClearColorImage(cmd, g_scene.img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &black, 1, &range); @@ -2884,14 +3540,34 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw record_draw(cmd, &pass_draws[i], &blit, g_scene.img, SCENE_FMT, input_w, input_h, VK_FILTER_LINEAR); } - if (vkp_effects_active()) vkp_effects_set_formats(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM); + if (vkp_effects_active()) vkp_effects_set_formats(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, 0); } int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f); + g_pass.post_upscale = generate && !hf && vkp_effects_active() && vkp_effects_upscaling() && + (mapped_w > input_w || mapped_h > input_h) && + vkp_effects_prepare_generated(input_w, input_h, mapped_w, mapped_h); + if (g_pass.post_upscale) { + static int last_input_w, last_input_h, last_output_w, last_output_h; + if (input_w != last_input_w || input_h != last_input_h || mapped_w != last_output_w || mapped_h != last_output_h) { + droiddeck_log("framegen", "post-upscale on the display layer: interpolate %dx%d, spatial filter each " + "frame to %dx%d", input_w, input_h, mapped_w, mapped_h); + last_input_w = input_w; last_input_h = input_h; + last_output_w = mapped_w; last_output_h = mapped_h; + } + } if (generate && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; } g_pass.rw = input_w; g_pass.rh = input_h; - g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, - &g_pass.rw, &g_pass.rh); + if (g_pass.post_upscale) { + g_pass.ow = (int)(scene_w * g_map.kx + 0.5f); + g_pass.oh = (int)(scene_h * g_map.ky + 0.5f); + g_pass.result = vkp_effects_run_before_generated(cmd, scene_img, input_w, input_h, &g_pass.rw, &g_pass.rh); + } else { + g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, + &g_pass.rw, &g_pass.rh); + g_pass.ow = g_pass.rw; + g_pass.oh = g_pass.rh; + } effects_overlay_draws(cmd, g_pass.result, g_pass.rw, g_pass.rh, scene_w, scene_h, draws ? draws + overlay_start : NULL, n - overlay_start); release_external_client_draws(cmd, draws, n); @@ -2906,38 +3582,45 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &b); + vkp_framegen_set_layer_timing(1); int ngen = vkp_framegen_run(cmd, g_pass.result, VK_NULL_HANDLE, g_pass.rw, g_pass.rh, scene_fmt, g_pass.gens); if (ngen < 0) ngen = 0; g_pass.ngen = ngen > VKP_FG_MAX_GENERATIONS ? VKP_FG_MAX_GENERATIONS : ngen; } g_pass.active = 1; - if (rw) *rw = g_pass.rw; - if (rh) *rh = g_pass.rh; + if (rw) *rw = g_pass.ow; + if (rh) *rh = g_pass.oh; return 0; } static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp_image *const *dsts, int n, int wait_fd) { - if (!g_pass.active) { if (wait_fd >= 0) close(wait_fd); return -1; } + if (!g_pass.active) { zfg_discard_history_update(); if (wait_fd >= 0) close(wait_fd); return -1; } g_pass.active = 0; - if (g_dev_state != 1) { if (wait_fd >= 0) close(wait_fd); return -1; } + if (g_dev_state != 1) { zfg_discard_history_update(); if (wait_fd >= 0) close(wait_fd); return -1; } VkCommandBuffer cmd = g_cmds[0]; for (int i = 0; i < n; i++) { if (dsts[i] && dsts[i]->blit_dst) continue; if (wait_fd >= 0) close(wait_fd); g_vk.EndCommandBuffer(cmd); + zfg_discard_history_update(); return -1; } const int gpu_wait = take_wait_fd(wait_fd); - if (gpu_wait < 0) { g_vk.EndCommandBuffer(cmd); return -1; } + if (gpu_wait < 0) { zfg_discard_history_update(); g_vk.EndCommandBuffer(cmd); return -1; } + const int post_upscale = g_pass.post_upscale && src_layout == VK_IMAGE_LAYOUT_GENERAL; for (int i = 0; i < n; i++) { struct vkp_image *dst = dsts[i]; + VkImage src = srcs[i]; + int sw = g_pass.rw, sh = g_pass.rh; + if (post_upscale) + src = vkp_effects_run_generated(cmd, src, g_pass.rw, g_pass.rh, g_pass.ow, g_pass.oh, i, &sw, &sh); VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, - .srcOffsets = {{0, 0, 0}, {g_pass.rw, g_pass.rh, 1}}, + .srcOffsets = {{0, 0, 0}, {sw, sh, 1}}, .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{0, 0, 0}, {dst->w, dst->h, 1}}}; - blit_to_layer(cmd, srcs[i], src_layout, dst, &blit, - (g_pass.rw == dst->w && g_pass.rh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR); + blit_to_layer(cmd, src, src_layout, dst, &blit, + (sw == dst->w && sh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR); } g_vk.EndCommandBuffer(cmd); @@ -2948,13 +3631,17 @@ static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp g_vk.ResetFences(g_dev, 1, &g_fence); VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, g_fence); if (qr != VK_SUCCESS) { + zfg_discard_history_update(); if (qr == VK_ERROR_DEVICE_LOST) device_lost("layer pass"); else LOGE("layer: effects pass submit failed (%d)", (int)qr); return -1; } + zfg_commit_history_update(); VkResult fr = timed_wait(g_fence, 1000000000ULL); if (fr == VK_ERROR_DEVICE_LOST) { device_lost("layer pass"); return -1; } if (fr != VK_SUCCESS) { LOGE("layer: effects pass fence wait -> %s", vk_result_name(fr)); return -1; } + if (post_upscale) vkp_effects_release_generated_sources(); + vkp_framegen_completed(); return 0; } @@ -2972,6 +3659,7 @@ int vkp_pass_copy_generated(struct vkp_image *const *dsts, int n, struct vkp_ima } void vkp_pass_abort(void) { + zfg_discard_history_update(); if (!g_pass.active) return; g_pass.active = 0; if (g_dev_state == 1) diff --git a/app/src/main/cpp/waylandcomp/src/vk_present.h b/app/src/main/cpp/waylandcomp/src/vk_present.h index 69af7dca23..f7bfaf781f 100644 --- a/app/src/main/cpp/waylandcomp/src/vk_present.h +++ b/app/src/main/cpp/waylandcomp/src/vk_present.h @@ -20,6 +20,8 @@ enum vkp_align { VKP_ALIGN_CENTER = 0, VKP_ALIGN_TOP = 1, VKP_ALIGN_BOTTOM = 2, VKP_ALIGN_PICTURE_TOP = 3, VKP_ALIGN_PICTURE_BOTTOM = 4, VKP_ALIGN_PICTURE_LEFT = 5, VKP_ALIGN_PICTURE_RIGHT = 6 }; void vk_present_set_scale_mode(int mode, int alignment); +void vk_present_set_zoom(float zoom); +int vkp_zoom_pan_cursor(double ox, double oy); int vkp_game_picture_rect(float rect[4]); int vkp_output_to_scene(double ox, double oy, double *sx, double *sy); int vkp_scene_to_output(double sx, double sy, double *ox, double *oy); @@ -103,7 +105,11 @@ int vkp_render_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n int vkp_pass_begin_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n, const struct vkp_hdr_frame *hf, int *rw, int *rh); -int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd); +struct vkp_blit { + struct vkp_image *src, *dst; + int wait_fd; +}; +int vkp_blit_images(const struct vkp_blit *blits, int n); int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px); int vkp_update_map(int scene_w, int scene_h); int vkp_map_draw(const struct vkp_draw *d, int out[8]); diff --git a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c index 308332f9b1..f22865c110 100644 --- a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c +++ b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c @@ -22,6 +22,7 @@ extern int droiddeck_wayland_run(void); extern void droiddeck_wayland_set_scale_mode(int mode, int alignment); +extern void droiddeck_wayland_set_zoom(int zoom_percent); extern void droiddeck_wayland_send_pointer(int action, int x, int y); extern void droiddeck_wayland_send_touch(int action, int pointer_id, int x, int y); extern void droiddeck_wayland_send_pen(int flags, int x, int y); @@ -67,6 +68,7 @@ static jmethodID g_on_compositor_frame; static jmethodID g_on_game_program; static jmethodID g_on_pointer_lock; static jmethodID g_on_clipboard; +static jmethodID g_on_text_input_fallback; static jmethodID g_on_text_input; static jmethodID g_on_overlay_planes; static jmethodID g_on_refresh_target; @@ -91,6 +93,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); g_on_game_program = NULL; } g_on_pointer_lock = (*env)->GetStaticMethodID(env, g_compositor_cls, "onPointerLock", "(ZII)V"); g_on_clipboard = (*env)->GetStaticMethodID(env, g_compositor_cls, "onClipboardText", "([B)V"); + g_on_text_input_fallback = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInputFallback", + "([BI)Z"); g_on_text_input = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInput", "(ZLjava/lang/String;IIII)V"); g_on_overlay_planes = (*env)->GetStaticMethodID(env, g_compositor_cls, "onOverlayPlanes", "(I)V"); @@ -202,6 +206,20 @@ void droiddeck_on_clipboard_text(const char *utf8, int len) { (*env)->DeleteLocalRef(env, arr); } +int droiddeck_on_text_input_fallback(const char *utf8, int len, int token) { + JNIEnv *env; + if (len <= 0 || token <= 0 || !utf8 || !g_compositor_cls || !g_on_text_input_fallback || !(env = thread_env())) + return 0; + jbyteArray arr = (*env)->NewByteArray(env, len); + if (!arr) { (*env)->ExceptionClear(env); return 0; } + (*env)->SetByteArrayRegion(env, arr, 0, len, (const jbyte *)utf8); + jboolean accepted = (*env)->CallStaticBooleanMethod(env, g_compositor_cls, g_on_text_input_fallback, arr, + (jint)token); + if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); accepted = JNI_FALSE; } + (*env)->DeleteLocalRef(env, arr); + return accepted == JNI_TRUE ? 1 : 0; +} + void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int w, int h) { JNIEnv *env; if (!g_compositor_cls || !g_on_text_input || !(env = thread_env())) return; @@ -375,6 +393,18 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendKey( droiddeck_wayland_send_key(evdev, state); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendKeyOrdered( + JNIEnv *env, jclass clazz, jint evdev, jint state) { + droiddeck_host_key(evdev, state); +} + +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSelectGameField( + JNIEnv *env, jclass clazz, jboolean copy) { + droiddeck_host_select_game_field(copy); +} + JNIEXPORT jboolean JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFocusTakesTouch( JNIEnv *env, jclass clazz) { @@ -431,6 +461,11 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZeroCopy(JNIEnv * __android_log_print(ANDROID_LOG_INFO, TAG, "zero-copy layer mode %s%s", on ? "on" : "off", live ? " (live)" : ""); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetMirrorCapture(JNIEnv *env, jclass clazz, jboolean on) { + droiddeck_host_mirror_capture(on ? 1 : 0); +} + JNIEXPORT void JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDisplayBufferDriver(JNIEnv *env, jclass clazz, jboolean on) { g_display_buffer_driver = on ? 1 : 0; @@ -511,6 +546,15 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetScaleMode(JNIEnv __android_log_print(ANDROID_LOG_INFO, TAG, "scale mode %d alignment %d", mode, alignment); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZoom(JNIEnv *env, jclass clazz, jfloat zoom) { + (void)env; + (void)clazz; + if (!(zoom >= 1.0f)) zoom = 1.0f; + if (zoom > 3.0f) zoom = 3.0f; + droiddeck_wayland_set_zoom((int)(zoom * 100.0f + 0.5f)); +} + JNIEXPORT jboolean JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeGamePictureRect(JNIEnv *env, jclass clazz, jfloatArray out) { @@ -797,6 +841,15 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputCommit(JNIE free(buf); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputCommitAndSubmit( + JNIEnv *env, jclass clazz, jbyteArray utf8) { + int len; + char *buf = dup_bytes(env, utf8, &len); + if (buf && len) droiddeck_host_text_commit_and_submit(buf, len); + free(buf); +} + JNIEXPORT void JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputPreedit(JNIEnv *env, jclass clazz, jbyteArray utf8, jint cursorBegin, jint cursorEnd) { @@ -811,6 +864,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputDelete(JNIE droiddeck_host_text_delete(before, after); } +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCompleteTextInputFallback( + JNIEnv *env, jclass clazz, jint token, jint result) { + droiddeck_host_text_input_fallback_complete(token, result); +} + extern void adrenotools_set_turbo(bool turbo); JNIEXPORT void JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *env, jclass clazz, jboolean on) { @@ -862,3 +921,42 @@ JNIEXPORT jint JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStreamFrames(JNIEnv *env, jclass clazz) { return (jint)droiddeck_stream_frames(); } + + +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE +extern int droiddeck_frame_worker_grant(int owner, pid_t pid, uint64_t expires, const char *path, + uint64_t dev, uint64_t ino, uint64_t receipt); +extern void droiddeck_frame_worker_revoke(int owner, int pid); +#endif + +JNIEXPORT jboolean JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_frameWorkerProbeEnabled(JNIEnv *env, jclass c) { +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + return JNI_TRUE; +#else + return JNI_FALSE; +#endif +} + +JNIEXPORT jboolean JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_frameWorkerProbeGrant(JNIEnv *env, jclass c, + jint owner, jint pid, jlong expires, jstring path, jlong dev, jlong ino, jlong start_ticks) { +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + if (!path || expires <= 0 || ino <= 0 || start_ticks <= 0) return JNI_FALSE; + const char *name = (*env)->GetStringUTFChars(env, path, NULL); + if (!name) return JNI_FALSE; + int granted = droiddeck_frame_worker_grant(owner, pid, (uint64_t)expires, name, (uint64_t)dev, (uint64_t)ino, (uint64_t)start_ticks); + (*env)->ReleaseStringUTFChars(env, path, name); + return granted ? JNI_TRUE : JNI_FALSE; +#else + return JNI_FALSE; +#endif +} + +JNIEXPORT void JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_frameWorkerProbeRevoke(JNIEnv *env, jclass c, + jint owner, jint pid) { +#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE + droiddeck_frame_worker_revoke(owner, pid); +#endif +} diff --git a/app/src/main/cpp/waylandcomp/src/wl_text_input.c b/app/src/main/cpp/waylandcomp/src/wl_text_input.c index 8b0ade227d..aaeff2de99 100644 --- a/app/src/main/cpp/waylandcomp/src/wl_text_input.c +++ b/app/src/main/cpp/waylandcomp/src/wl_text_input.c @@ -10,6 +10,12 @@ #ifndef KEY_DELETE #define KEY_DELETE 111 #endif +#ifndef KEY_ENTER +#define KEY_ENTER 28 +#endif +#ifndef KEY_TAB +#define KEY_TAB 15 +#endif static struct wl_display *g_disp; @@ -203,16 +209,43 @@ static int32_t utf8_offset(const char *s, size_t len, int chars) { return (int32_t)i; } -void text_input_host_commit(const char *utf8, size_t len) { +static int control_evdev(unsigned char c) { + switch (c) { + case '\r': case '\n': return KEY_ENTER; + case '\b': return KEY_BACKSPACE; + case 0x7f: return KEY_DELETE; + case '\t': return KEY_TAB; + default: return -1; + } +} + +static int all_controls(const char *utf8, size_t len) { + for (size_t i = 0; i < len; i++) + if (control_evdev((unsigned char)utf8[i]) < 0) return 0; + return 1; +} + +int text_input_host_commit(const char *utf8, size_t len) { struct text_input *ti = active_input(); if (!ti) { - droiddeck_log("text-input", "typed text (%zu chars) dropped: no program accepts text input", utf8_chars(utf8, len)); - return; + droiddeck_log("text-input", "typed text (%zu chars): no program accepts Wayland text input", utf8_chars(utf8, len)); + return 0; + } + if (len > 0 && all_controls(utf8, len)) { + /* Keep editing keys on the compositor queue so they cannot overtake text commits. */ + for (size_t i = 0; i < len; i++) { + int code = control_evdev((unsigned char)utf8[i]); + droiddeck_inject_key(code, 1); + droiddeck_inject_key(code, 0); + } + droiddeck_log("text-input", "injected %zu soft control(s) to %s", len, ti_program(ti)); + return 1; } if (ti->has_preedit) { zwp_text_input_v3_send_preedit_string(ti->res, "", 0, 0); ti->has_preedit = 0; } zwp_text_input_v3_send_commit_string(ti->res, utf8); zwp_text_input_v3_send_done(ti->res, ti->serial); droiddeck_log("text-input", "committed %zu chars to %s", utf8_chars(utf8, len), ti_program(ti)); + return 1; } void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end) { diff --git a/app/src/main/java/com/droiddeck/launcher/App.kt b/app/src/main/java/com/droiddeck/launcher/App.kt index 58e7e12b2c..f91157dd41 100644 --- a/app/src/main/java/com/droiddeck/launcher/App.kt +++ b/app/src/main/java/com/droiddeck/launcher/App.kt @@ -20,6 +20,10 @@ class App : Application() { override fun onCreate() { super.onCreate() + if (android.os.Build.VERSION.SDK_INT >= 28 && + com.droiddeck.launcher.runtime.GuestWorker.isWorkerProcess(this, Application.getProcessName())) return + if (android.os.Build.VERSION.SDK_INT >= 28 && Application.getProcessName() == packageName) + com.droiddeck.launcher.runtime.GuestWorkers.attach(this) com.droiddeck.launcher.runtime.NativeGuest.init(this) com.droiddeck.launcher.session.Onboarding.attach(this) Thread({ runCatching { EnhancedSessionLogShare.cleanupAbandonedStages(this) } }, "diagnostic-stage-cleanup").start() @@ -55,7 +59,7 @@ class App : Application() { com.droiddeck.launcher.session.QuestExperimental.initialize(this) com.droiddeck.launcher.session.SessionPrefs.applyNtsyncDefault(this) com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this) - com.droiddeck.launcher.session.SessionPrefs.settleStoresTabOrder(this, com.droiddeck.launcher.stores.Store.entries.map { it.id }) + com.droiddeck.launcher.session.SessionPrefs.settleStoresTabOrder(this, com.droiddeck.launcher.stores.Store.tabbed.map { it.id }) com.droiddeck.launcher.update.AppUpdates.init(this) com.droiddeck.launcher.update.UpdateWatch.sync(this, com.droiddeck.launcher.update.AppUpdates.follow(this, null)) com.droiddeck.launcher.core.DownloadSource.init(this) @@ -80,6 +84,7 @@ class App : Application() { com.droiddeck.launcher.stores.ea.EaBackend.app = this com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.ea.EaBackend) com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.rockstar.RockstarBackend) + com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.steam.SteamBackend) } private fun prefetchAddonPacks() { diff --git a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt index 925884b3c3..94b0e6c744 100644 --- a/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt +++ b/app/src/main/java/com/droiddeck/launcher/DriverMenus.kt @@ -430,21 +430,28 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl */ private fun useMaliFallback(missing: String?): String { val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity) - val venus = oldVulkan == null && com.droiddeck.launcher.session.VenusComponent.available(activity) + val venusByUser = venusExplicit() + val venus = MaliAutoRoute.venusStandsIn( + com.droiddeck.launcher.session.VenusComponent.available(activity), oldVulkan == null, + SessionPrefs.venus(activity), venusByUser, gpu.name, + ) if (oldVulkan != null) Log.i(TAG, "auto: Mali driver reports Vulkan $oldVulkan; Venus needs 1.2, the bridge stands in") val ownership = MaliAutoRoute.fallbackOwnership( venus, SessionPrefs.vkBridge(activity), bridgeExplicit(), - SessionPrefs.venus(activity), venusExplicit(), + SessionPrefs.venus(activity), venusByUser, ) if (venus && !SessionPrefs.venus(activity)) { SessionPrefs.setVenus(activity, true) if (SessionPrefs.vkBridge(activity) && !bridgeExplicit()) SessionPrefs.setVkBridge(activity, false) SessionPrefs.setMaliFallbackByAuto(activity, ownership) - } else if (!venus && !SessionPrefs.vkBridge(activity)) { - SessionPrefs.setVkBridge(activity, true) - SessionPrefs.setMaliFallbackByAuto(activity, ownership) + } else if (!venus) { + val venusOff = SessionPrefs.venus(activity) && !venusByUser + val bridgeOn = !SessionPrefs.vkBridge(activity) + if (venusOff) SessionPrefs.clearVenus(activity) + if (bridgeOn) SessionPrefs.setVkBridge(activity, true) + if (venusOff || bridgeOn || ownership != MaliAutoRoute.NONE) SessionPrefs.setMaliFallbackByAuto(activity, ownership) } else if (ownership != MaliAutoRoute.NONE) { SessionPrefs.setMaliFallbackByAuto(activity, ownership) } @@ -467,7 +474,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl /** A pair is installed for this Mali: the route Auto switched on in its place goes off again. */ private fun endMaliFallback() { when (SessionPrefs.maliFallbackByAuto(activity)) { - "venus" -> SessionPrefs.setVenus(activity, false) + "venus" -> SessionPrefs.clearVenus(activity) "bridge" -> SessionPrefs.setVkBridge(activity, false) else -> return } diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 56cb921e0f..dd63a08497 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -25,6 +25,7 @@ import android.widget.EditText import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -51,6 +52,7 @@ import com.droiddeck.launcher.ui.ComponentsPage import com.droiddeck.launcher.session.GameSaves import com.droiddeck.launcher.session.SessionLogShare import com.droiddeck.launcher.session.SessionPaths +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SteamRepair import com.droiddeck.launcher.session.LaunchCoordinator @@ -62,6 +64,7 @@ import com.droiddeck.launcher.core.PhantomProcessStatus import com.droiddeck.launcher.core.WirelessAdbFix import com.droiddeck.launcher.core.WifiDiscovery import com.droiddeck.launcher.core.SteamIntegration +import com.droiddeck.launcher.ui.SteamIntegrationFocusRequest import com.droiddeck.launcher.core.WirelessAdbPairingService import com.droiddeck.launcher.ui.CoreRow import com.droiddeck.launcher.ui.PerformancePage @@ -189,23 +192,29 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private var gamescopeRealtime by mutableStateOf(false) private var paceCores by mutableStateOf(true) private var gpuClockPin by mutableStateOf(false) - private var prootNoSeccomp by mutableStateOf(false) - private var prootFastPath by mutableStateOf(true) - private var nativeUserland by mutableStateOf(true) + private var desktopAsUser by mutableStateOf(false) private var cursorComposite by mutableStateOf(true) private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME) private var phantomWarning by mutableStateOf(null) private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE) private var showPhantomGate by mutableStateOf(false) private var directAudio by mutableStateOf(false) - private var picturePosition by mutableStateOf("center") + private var picturePositionLandscape by mutableStateOf("center") + private var picturePositionPortrait by mutableStateOf("top") private var integerScaling by mutableStateOf(false) private var stretch16x9 by mutableStateOf(false) private var avoidNotch by mutableStateOf(false) private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER) private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM) - private var launcherFullscreen by mutableStateOf(true) + private var launcherFullscreenMode by mutableStateOf(FullscreenMode.ALWAYS) + private var sessionFullscreenMode by mutableStateOf(FullscreenMode.ALWAYS) + private var launcherFrost by mutableStateOf(false) + private var frostWallpaper by mutableStateOf(true) + private var frostCards by mutableStateOf(true) + private var frostTransparency by mutableStateOf(com.droiddeck.launcher.ui.FROST_WALLPAPER_DEFAULT) + private var frostCardTransparency by mutableStateOf(com.droiddeck.launcher.ui.FROST_DEFAULT) + private val frost = com.droiddeck.launcher.ui.LauncherFrost(this) private var controllerHaptics by mutableStateOf(true) private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO) private var downloadMirror by mutableStateOf("") @@ -231,7 +240,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private var wifiDiscoveryAsked by mutableStateOf(false) private var wifiDiscoveryBlocked by mutableStateOf(false) private var integrationState by mutableStateOf(SteamIntegration.State()) - private var integrationFocus by mutableStateOf(null) + private var integrationFocus by mutableStateOf(null) private var pendingSessionLogExport: File? = null private val wifiLocationReceiver = object : android.content.BroadcastReceiver() { override fun onReceive(context: android.content.Context?, intent: Intent?) { @@ -296,9 +305,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet protons.installExperimental { progress -> com.droiddeck.launcher.session.ExperimentalProtons.installFromFile(this, zip, progress) } } } - private val pickLossless = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r -> - if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let { importLossless(it) } - } private val pickSaveZip = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r -> val then = onSavePicked.also { onSavePicked = null } ?: return@registerForActivityResult if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let(then) @@ -350,7 +356,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet SteamIntegration.dismissSuggestion(this) refreshWifiDiscovery() integrationState = readIntegration() - integrationFocus = feature + integrationFocus = SteamIntegrationFocusRequest(feature) navRequest = "setup:integration" } @@ -509,17 +515,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet bootMovieCustomName = com.droiddeck.launcher.session.BootMovie.customName(this) } - private fun importLossless(dll: File) { - Thread({ - val message = Lossless.message(this, Lossless.import(this, dll)) - val state = Lossless.state(this) - ui.post { - lossless = state - android.widget.Toast.makeText(this, message, android.widget.Toast.LENGTH_LONG).show() - } - }, "lossless-import").start() - } - private fun importSaves(name: String, game: () -> GameSaves.Game) { if (SessionState.running) { android.widget.Toast.makeText(this, R.string.main_saves_close_session, android.widget.Toast.LENGTH_LONG).show() @@ -617,6 +612,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private var appScale by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.DEFAULT_SCALE) private var hdrOn by mutableStateOf(false) private var zeroCopyOn by mutableStateOf(true) + private var producerAcquireFences by mutableStateOf(false) private var upscaler by mutableStateOf(0) private var upscaleSharpness by mutableStateOf(75) private var hdrReason by mutableStateOf(null) @@ -1092,6 +1088,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } else { putExtra(SessionService.EXTRA_STEAM_URL, com.droiddeck.launcher.frontend.GameLaunchLink.steamUrl(game.gameIdString)) + putExtra(SessionService.EXTRA_FRONTEND_STEAM_GAME, true) } } .playing(game), steamSession = true) @@ -1259,6 +1256,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } private fun startAfterSession(next: Intent) { + if (com.droiddeck.launcher.stores.steam.SteamStore.blocksSession(next)) { + android.widget.Toast.makeText(this, R.string.steam_store_session_wait, android.widget.Toast.LENGTH_SHORT).show() + return + } SessionService.stop(this) awaitSessionEnd(next, android.os.SystemClock.uptimeMillis() + SESSION_SWITCH_WAIT_MS) } @@ -1345,6 +1346,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet val shortcutsFilter = android.content.IntentFilter(SteamIntegration.SHORTCUTS_STATUS) if (android.os.Build.VERSION.SDK_INT >= 33) registerReceiver(shortcutsInstallStatus, shortcutsFilter, RECEIVER_NOT_EXPORTED) else registerReceiver(shortcutsInstallStatus, shortcutsFilter) + if (GameLaunchIntent.accepts(intent.action) && + GameLaunchIntent.replayed(intent, savedInstanceState != null, savedInstanceState?.getString(STATE_PROCESS), PROCESS)) + clearGameLinkIntent(intent) readGameIntent(intent) // A Lab build is usually the agent's work, so the app comes back where the agent is. if (savedInstanceState == null && navRequest == null && com.droiddeck.launcher.lab.LabOverlay.promoted && com.droiddeck.launcher.agent.AgentTab.visible) navRequest = "agent" @@ -1362,8 +1366,20 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet orientation = SessionPrefs.orientation(this) launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this) requestedOrientation = launcherOrientation + launcherFullscreenMode = SessionPrefs.launcherFullscreenMode(this) + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + applyLauncherFullscreen() homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this) - launcherFullscreen = SessionPrefs.launcherFullscreen(this) + launcherFullscreenMode = SessionPrefs.launcherFullscreenMode(this) + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + launcherFrost = SessionPrefs.launcherFrost(this) + frostWallpaper = SessionPrefs.frostWallpaper(this) + frostCards = SessionPrefs.frostCards(this) + frostTransparency = SessionPrefs.frostTransparency(this) + frostCardTransparency = SessionPrefs.frostCardTransparency(this) + frost.start() + frost.prepare(launcherFrost && frostWallpaper) + frost.show(frostShown()) controllerHaptics = SessionPrefs.controllerHaptics(this) downloadSource = DownloadSource.mode(this) downloadMirror = DownloadSource.mirror(this) @@ -1388,8 +1404,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } val appsTabShown = "android-apps" !in com.droiddeck.launcher.ui.NavTabs.hidden androidx.compose.runtime.LaunchedEffect(appsTabShown) { if (appsTabShown && androidApps.isEmpty()) refreshAndroidApps() } - DroidDeckTheme(theme, appScale = appScale) { - com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().exposeTestTags()) { + val frostShown = frostShown() + androidx.compose.runtime.LaunchedEffect(frostShown) { frost.show(frostShown) } + val frostChoice = if (frostShown) com.droiddeck.launcher.ui.FrostChoice(frostTransparency, frostCards, frostCardTransparency) else null + DroidDeckTheme(theme, appScale = appScale, frost = frostChoice) { + val palette = com.droiddeck.launcher.ui.LocalPalette.current + val veil = com.droiddeck.launcher.ui.LocalFrost.current + val ground = if (frost.prepared) androidx.compose.ui.Modifier.background(veil ?: palette.background) else androidx.compose.ui.Modifier + com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().then(ground).exposeTestTags()) { if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog( onConfirm = { decky.confirmPluginZip() }, onCancel = { decky.cancelPluginZip() }, ) @@ -1464,7 +1486,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet orientation = orientation, launcherOrientation = launcherOrientation, homePage = homePage, - launcherFullscreen = launcherFullscreen, + launcherFullscreenMode = launcherFullscreenMode, + sessionFullscreenMode = sessionFullscreenMode, + launcherFrost = launcherFrost, + frostWallpaper = frostWallpaper, + frostCards = frostCards, + frostTransparency = frostTransparency, + frostCardTransparency = frostCardTransparency, + frostSupported = frost.supported, controllerHaptics = controllerHaptics, downloadSource = downloadSource, downloadMirror = downloadMirror, @@ -1623,9 +1652,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet FrameGen.set(this, mode) frameGenLabel = FrameGen.label(this) }, - onImportLossless = { - pickLossless.launch(InAppFilePicker.buildIntent(this, listOf("dll"), getString(R.string.lsfg_pick_title))) - }, onProtons = { openProtons() }, onComponents = { focusContent -> openComponents(focusContent) }, onGameComponents = { game -> openComponents(gameKey = game.profileKey) }, @@ -1640,7 +1666,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet }, onSaveExport = { sg, layout -> exportSaves(sg.name, layout) { GameSaves.game(this@FrontEndActivity, sg) } }, onPerformance = { refreshCores(); showComponents = false; showMapping = false; showPerformance = true }, - performancePanel = { PerformanceHost(embedded = true) }, + performancePanel = { memory -> PerformanceHost(embedded = true, memory = memory) }, onRoms = { showRoms = true }, onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) }, onBrowseFiles = { dir -> @@ -1737,13 +1763,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } }, "delete-session-logs").start() }, - onClearLogs = { + onClearLogs = { done -> Thread({ val cleared = runCatching { SessionArtifacts.clearAll(this) }.getOrDefault(0) ui.post { android.widget.Toast.makeText(this, if (cleared == 0) getString(R.string.main_no_logs_to_clear) else resources.getQuantityString(R.plurals.main_logs_cleared, cleared, cleared), android.widget.Toast.LENGTH_SHORT).show() + done() } }, "clear-logs").start() }, @@ -1795,11 +1822,37 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet homePage = value }, onControllerHaptics = { on -> SessionPrefs.setControllerHaptics(this, on); controllerHaptics = on }, - onLauncherFullscreen = { on -> - SessionPrefs.setLauncherFullscreen(this, on) - launcherFullscreen = on + onLauncherFullscreenMode = { mode -> + SessionPrefs.setLauncherFullscreenMode(this, mode) + launcherFullscreenMode = mode applyLauncherFullscreen() }, + onSessionFullscreenMode = { mode -> + SessionPrefs.setSessionFullscreenMode(this, mode) + sessionFullscreenMode = mode + }, + onLauncherFrost = { on -> + SessionPrefs.setLauncherFrost(this, on) + launcherFrost = on + if (on && frostWallpaper && !frost.prepared) restartLauncher() + }, + onFrostWallpaper = { on -> + SessionPrefs.setFrostWallpaper(this, on) + frostWallpaper = on + if (on && !frost.prepared) restartLauncher() + }, + onFrostCards = { on -> + SessionPrefs.setFrostCards(this, on) + frostCards = on + }, + onFrostTransparency = { percent -> + SessionPrefs.setFrostTransparency(this, percent) + frostTransparency = SessionPrefs.frostTransparency(this) + }, + onFrostCardTransparency = { percent -> + SessionPrefs.setFrostCardTransparency(this, percent) + frostCardTransparency = SessionPrefs.frostCardTransparency(this) + }, onGameStoresSpeedTier = { tier -> SessionPrefs.setGameStoresSpeedTier(this, tier); gameStoresSpeedTier = tier }, onNavigated = { navRequest = null }, onStoresShowMature = { show -> SessionPrefs.setStoresShowMature(this, show); storesShowMature = show }, @@ -1986,11 +2039,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } } - val askAllFiles = Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.files.AllFilesAccess.missing() && - !SessionPrefs.allFilesAsked(this) - if (savedInstanceState == null) { - if (!askAllFiles) ui.post { startSteamAtStartupIfEnabled(cold = true) } - } + if (savedInstanceState == null) ui.post { startSteamAtStartupIfEnabled(cold = true) } saved?.let { state -> restoreCompatLaunch(state) pendingSwitch = savedIntent(state, KEY_PENDING_SWITCH) @@ -1998,13 +2047,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } val wanted = ArrayList() - if (Build.VERSION.SDK_INT >= 30) { - // From targetSdk 30, shared storage outside the app's own folders is all-files access or nothing. - if (askAllFiles) { - SessionPrefs.setAllFilesAsked(this) - com.droiddeck.launcher.files.AllFilesAccess.open(this) - } - } else if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + // From Android 11, shared storage outside the app's own folders is all-files access, which the file picker asks for when a shared drive is opened. + if (Build.VERSION.SDK_INT < 30 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { wanted.add(Manifest.permission.WRITE_EXTERNAL_STORAGE) } if (SessionPrefs.micEnabled(this) && !SessionPrefs.micAsked(this) @@ -2013,6 +2057,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet SessionPrefs.setMicAsked(this) } if (wanted.isNotEmpty()) requestPermissions(wanted.toTypedArray(), 1) + com.droiddeck.launcher.session.Onboarding.onFirstRunReady = firstRunReady Thread({ com.droiddeck.launcher.stores.StoreAccounts.encryptAll(this) }, "store-credentials").start() if (!SessionState.running) Thread({ com.droiddeck.launcher.session.LogMigration.run(this) @@ -2104,14 +2149,26 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onWindowFocusChanged(hasFocus: Boolean) { super.onWindowFocusChanged(hasFocus) - if (!hasFocus) triggerKeys.cancel() + if (!hasFocus) { + triggerKeys.cancel() + stopRightStickScroll() + } if (hasFocus) { com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false) applyLauncherFullscreen() } } - private fun applyLauncherFullscreen() { + private fun frostShown(): Boolean = + launcherFrost && frostWallpaper && frost.prepared && frost.available && theme != com.droiddeck.launcher.ui.Themes.TRUE_BLACK + + override fun onConfigurationChanged(newConfig: android.content.res.Configuration) { + super.onConfigurationChanged(newConfig) + applyLauncherFullscreen(newConfig) + } + + private fun applyLauncherFullscreen(config: android.content.res.Configuration = resources.configuration) { + val launcherFullscreen = launcherFullscreenMode.hidesSystemBars(config.orientation) @Suppress("DEPRECATION") window.decorView.systemUiVisibility = if (launcherFullscreen) { (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY @@ -2192,7 +2249,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet return true } return try { - super.dispatchKeyEvent(event) + super.dispatchKeyEvent(event) || com.droiddeck.launcher.ui.PageBumpers.handle(event) } catch (e: IllegalStateException) { if (e.message?.contains("active focus target") != true) throw e android.util.Log.w("MainActivity", "key ${event.keyCode} dropped: ${e.message}") @@ -2202,14 +2259,116 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private val triggerKeys = com.droiddeck.launcher.input.TriggerKeys { dispatchKeyEvent(it) } + internal fun onMenuMotion(event: MotionEvent) = triggerKeys.onMotion(event) + + private val rightStickLayouts = HashMap() + private val rightStickScrollHandler = android.os.Handler(android.os.Looper.getMainLooper()) + private var rightStickScrollDeviceId = -1 + private var rightStickScrollDeflection = 0f + private var rightStickScrollScheduled = false + private var rightStickNextDispatchAt = 0L + private val rightStickScrollTick = object : Runnable { + override fun run() { + val deviceId = rightStickScrollDeviceId + if (!hasWindowFocus() || (compatLaunch != null && !compatLaunch!!.loading.ended) || + deviceId == -1 || + android.view.InputDevice.getDevice(deviceId) == null || + kotlin.math.abs(rightStickScrollDeflection) < 0.55f) { + stopRightStickScroll() + return + } + rightStickScrollScheduled = false + dispatchRightStickScroll(rightStickScrollDeflection, deviceId) + rightStickNextDispatchAt = android.os.SystemClock.uptimeMillis() + 130L + rightStickScrollHandler.postDelayed(this, 130L) + rightStickScrollScheduled = true + } + } + + private fun stopRightStickScroll() { + rightStickScrollHandler.removeCallbacks(rightStickScrollTick) + rightStickScrollDeviceId = -1 + rightStickScrollDeflection = 0f + rightStickScrollScheduled = false + } + + private fun dispatchRightStickScroll(value: Float, deviceId: Int) { + val now = android.os.SystemClock.uptimeMillis() + val root = window.decorView + if (root.width <= 0 || root.height <= 0) return + val properties = android.view.MotionEvent.PointerProperties().apply { + id = 0 + toolType = android.view.MotionEvent.TOOL_TYPE_MOUSE + } + val coordinates = android.view.MotionEvent.PointerCoords().apply { + x = root.width * 0.65f + y = root.height * 0.5f + setAxisValue(android.view.MotionEvent.AXIS_VSCROLL, -value * 3f) + } + val scroll = android.view.MotionEvent.obtain( + now, now, android.view.MotionEvent.ACTION_SCROLL, 1, + arrayOf(properties), arrayOf(coordinates), 0, 0, 1f, 1f, + deviceId, 0, android.view.InputDevice.SOURCE_MOUSE, 0, + ) + try { + super.dispatchGenericMotionEvent(scroll) + } finally { + scroll.recycle() + } + } + + private fun scrollPageWithRightStick(event: android.view.MotionEvent) { + if (event.actionMasked != android.view.MotionEvent.ACTION_MOVE || + !com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) return + val device = event.device ?: return + val rxRy = com.droiddeck.launcher.input.PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts) + ?: run { + if (rightStickScrollDeviceId == event.deviceId) stopRightStickScroll() + return + } + val axis = if (rxRy) android.view.MotionEvent.AXIS_RY else android.view.MotionEvent.AXIS_RZ + val value = event.getAxisValue(axis) + if (kotlin.math.abs(value) < 0.55f) { + if (rightStickScrollDeviceId == event.deviceId) stopRightStickScroll() + return + } + rightStickScrollDeviceId = event.deviceId + rightStickScrollDeflection = value + if (!rightStickScrollScheduled) { + val delay = (rightStickNextDispatchAt - android.os.SystemClock.uptimeMillis()).coerceAtLeast(0L) + rightStickScrollHandler.postDelayed(rightStickScrollTick, delay) + rightStickScrollScheduled = true + } + } + override fun dispatchGenericMotionEvent(event: android.view.MotionEvent): Boolean { if (compatLaunch != null && !compatLaunch!!.loading.ended && - com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) return true + com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) { + stopRightStickScroll() + return true + } triggerKeys.onMotion(event) + scrollPageWithRightStick(event) return super.dispatchGenericMotionEvent(event) } + @Volatile private var inFront = false + private var autoSteamPending = false + + /** Runs on the worker thread that finishes setup, so the foreground state is read as setup completes, not when the UI thread gets to it. */ + private val firstRunReady: () -> Unit = { + val front = inFront + runOnUiThread { if (front) autoStartSteam() } + } + + private fun autoStartSteam() { + if (isFinishing || isDestroyed || SessionState.running || !inFront) return + if (busy) autoSteamPending = true else playSteam() + } + override fun onPause() { + inFront = false + stopRightStickScroll() compatLaunchVisible = false if (android.os.Build.VERSION.SDK_INT >= 29) com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, true) super.onPause() @@ -2217,12 +2376,16 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onResume() { super.onResume() + inFront = true if (!homeChoiceOpen) { HomeApp.releaseUnusedHomeEntry(this) refreshHomeAppState() } if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries() - settingsMode?.let { hdrOn = SessionPrefs.hdr(this, it) } + settingsMode?.let { mode -> + hdrOn = SessionPrefs.hdr(this, mode) + if (mode == SessionService.MODE_STEAM) loadPicturePositions() + } compatLaunchVisible = true com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false) com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, false) @@ -2308,6 +2471,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } private fun saveLauncherState(outState: Bundle) { + outState.putString(STATE_PROCESS, PROCESS) outState.putBoolean(STATE_HOME_CHOICE_OPEN, homeChoiceOpen) outState.putBoolean(STATE_GAME_SPACE_OFFERED, gameSpaceOffered) pendingSessionLogExport?.let { outState.putString(KEY_PENDING_SESSION_LOG_EXPORT, it.absolutePath) } @@ -2351,11 +2515,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet override fun onDestroy() { // The queued launch was saved before this; a restored activity keeps its copy, and this one must not start it too. + if (com.droiddeck.launcher.session.Onboarding.onFirstRunReady === firstRunReady) com.droiddeck.launcher.session.Onboarding.onFirstRunReady = null queuedLaunchRunner.destroy() triggerKeys.cancel() launchCoordinator.cancelAll() cancelCompatLaunch() updates.unregister() + frost.stop() runCatching { unregisterReceiver(shortcutsInstallStatus) } super.onDestroy() } @@ -2760,6 +2926,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet mode = mode, resolution = resolution, resolutionPortrait = resolutionPortrait, panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this), hdr = hdrOn, hdrReason = hdrReason, hdrDisplay = hdrDisplay, zeroCopy = zeroCopyOn, + producerAcquireFences = producerAcquireFences.takeIf { + mode == SessionService.MODE_STEAM && + com.droiddeck.launcher.runtime.FrameAcquireWorkerProbe.available(this) + }, upscaler = upscaler, upscaleSharpness = upscaleSharpness, gpuDrivers = drivers.summary(), touchMode = touchMode, @@ -2774,7 +2944,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet backHold = backHold, backActionsInverted = backActionsInverted, directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null, - picturePosition = if (mode == SessionService.MODE_STEAM) picturePosition else null, + picturePositionLandscape = picturePositionLandscape.takeIf { mode == SessionService.MODE_STEAM }, + picturePositionPortrait = picturePositionPortrait.takeIf { mode == SessionService.MODE_STEAM }, integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null, stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null, avoidNotch = if (mode == SessionService.MODE_STEAM) avoidNotch else null, @@ -2824,6 +2995,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet SessionPrefs.prefMode(SessionState.mode) == SessionPrefs.prefMode(mode)) com.droiddeck.launcher.wayland.WaylandCompositor.nativeSetZeroCopy(on) }, + onProducerAcquireFences = { + SessionPrefs.setProducerAcquireFences(this, it) + producerAcquireFences = it + }, onGpuDrivers = { openComponents(focusContent = true, tab = com.droiddeck.launcher.ui.GPU_TAB) }, onUpscaler = { m -> SessionPrefs.setUpscaler(this, m); upscaler = m }, onUpscaleSharpness = { pct -> SessionPrefs.setUpscaleSharpness(this, pct); upscaleSharpness = pct }, @@ -2847,7 +3022,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet backActionsInverted = inverted }, onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on }, - onPicturePosition = { value -> SessionPrefs.setPicturePosition(this, value); picturePosition = value }, + onPicturePosition = { portrait, value -> + SessionPrefs.setPicturePosition(this, portrait, value) + if (portrait) picturePositionPortrait = value else picturePositionLandscape = value + }, onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on }, onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on }, onAvoidNotch = { on -> SessionPrefs.setAvoidNotch(this, on); avoidNotch = on }, @@ -2934,7 +3112,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } @Composable - private fun PerformanceHost(embedded: Boolean = false) { + private fun PerformanceHost(embedded: Boolean = false, memory: @Composable () -> Unit = {}) { if (embedded) androidx.compose.runtime.LaunchedEffect(Unit) { refreshCores() } PerformancePage( cores = CpuCores.all.map { c -> CoreRow(c, "cpu$c" + (CpuCores.maxGhz(c)?.let { String.format(java.util.Locale.US, " · %.1f GHz", it) } ?: "")) }, @@ -2945,7 +3123,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet fsyncFirst = fsyncFirst, gamescopeRealtime = gamescopeRealtime, gpuClockPin = gpuClockPin, - prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, cursorComposite = cursorComposite, + nativeDesktopAvailable = com.droiddeck.launcher.runtime.NativeGuest.nextSession(this), desktopAsUser = desktopAsUser, cursorComposite = cursorComposite, guestHostname = guestHostname, phantomWarning = phantomWarning, onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on }, onPaceCores = { on -> SessionPrefs.setPaceCores(this, on); paceCores = on }, @@ -2959,9 +3137,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on }, onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on }, onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on }, - onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, - onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on }, - onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on }, + onDesktopAsUser = { on -> SessionPrefs.setDesktopAsUser(this, on); desktopAsUser = on }, onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on }, onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) }, onClientCore = { core, on -> @@ -2974,6 +3150,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet }, onDismiss = { showPerformance = false }, embedded = embedded, + memory = memory, ) } @@ -3096,6 +3273,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet return } val target = com.droiddeck.launcher.frontend.GameRemoval.steamFiles(g) ?: return + if (Library.fromSteamClient(g)) { + com.droiddeck.launcher.stores.steam.SteamStore.uninstall(this, g.appId, target.manifest, fallback = { com.droiddeck.launcher.frontend.GameRemoval.delete(target) }) { refreshAddedGames(); refresh() } + return + } Thread({ com.droiddeck.launcher.frontend.GameRemoval.delete(target) ui.post { refreshAddedGames(); refresh() } @@ -3159,6 +3340,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true) } + private fun loadPicturePositions() { + picturePositionLandscape = SessionPrefs.picturePosition(this, portrait = false) + picturePositionPortrait = SessionPrefs.picturePosition(this, portrait = true) + } + private fun loadModeSettings(mode: String) { pipAutoEnter = SessionPrefs.pipAutoEnter(this) unfoldedControls = SessionPrefs.unfoldedControls(this) @@ -3180,6 +3366,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet loadBootMovie() hdrOn = SessionPrefs.hdr(this, mode) zeroCopyOn = SessionPrefs.zeroCopy(this, mode) + producerAcquireFences = SessionPrefs.producerAcquireFences(this) upscaler = SessionPrefs.upscaler(this) upscaleSharpness = SessionPrefs.upscaleSharpness(this) hdrReason = com.droiddeck.launcher.wayland.HdrSupport.blocked(this) @@ -3193,7 +3380,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet backHold = SessionPrefs.backHold(this) backActionsInverted = SessionPrefs.backActionsInverted(this) directAudio = SessionPrefs.directAudio(this) - picturePosition = SessionPrefs.picturePosition(this) + loadPicturePositions() integerScaling = SessionPrefs.integerScaling(this) stretch16x9 = SessionPrefs.stretch16x9(this) avoidNotch = SessionPrefs.avoidNotch(this) @@ -3273,9 +3460,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet gamescopeRealtime = SessionPrefs.gamescopeRealtime(this) paceCores = SessionPrefs.paceCores(this) gpuClockPin = SessionPrefs.gpuClockPin(this) - prootNoSeccomp = SessionPrefs.prootNoSeccomp(this) - prootFastPath = SessionPrefs.prootFastPath(this) - nativeUserland = SessionPrefs.nativeUserland(this) + desktopAsUser = SessionPrefs.desktopAsUser(this) cursorComposite = SessionPrefs.cursorComposite(this) guestHostname = SessionPrefs.guestHostname(this) refreshPhantomStatus() @@ -3471,6 +3656,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet android.widget.Toast.makeText(this, R.string.storage_cleanup_busy, android.widget.Toast.LENGTH_SHORT).show() return false } + if (!SessionState.running && com.droiddeck.launcher.stores.steam.SteamStore.blocksSession(intent)) { + android.widget.Toast.makeText(this, R.string.steam_store_session_wait, android.widget.Toast.LENGTH_SHORT).show() + return false + } refreshPhantomStatus() if (steamSession && PhantomProcessLimit.blocksSteam(phantomProcessStatus)) { if (queueIfBlocked) queuedLaunch.queue(intent, System.currentTimeMillis()) @@ -3533,9 +3722,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet retryMs = GATE_LAUNCH_RETRY_MS, ) - /** The conditions under which a Steam start waits instead of being refused: setup, a runtime or desktop install, or a storage cleanup. */ + /** The conditions under which a Steam start waits instead of being refused: setup, a runtime or desktop install, a storage cleanup, or a Steam store download. */ private fun steamStartBusy(): Boolean = busy || LinuxRuntimeInstaller.isBusy() || com.droiddeck.launcher.session.Onboarding.settling() || - (SessionState.installing != null && !SessionState.running) || com.droiddeck.launcher.storage.StorageState.cleaning + (SessionState.installing != null && !SessionState.running) || com.droiddeck.launcher.storage.StorageState.cleaning || + (!SessionState.running && com.droiddeck.launcher.stores.steam.SteamStore.downloading()) private fun refreshPhantomStatus() { phantomProcessStatus = PhantomProcessLimit.read(this) @@ -3641,6 +3831,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet refresh() com.droiddeck.launcher.agent.AgentHost.refresh(this) if (ok == true && LinuxRuntime.isInstalled(this)) { protons.checkUpdates(); protons.ensureSteamClient() } + if (autoSteamPending) { autoSteamPending = false; autoStartSteam() } } }, "runtime-operation").start() } @@ -3671,6 +3862,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } companion object { + private val PROCESS = java.util.UUID.randomUUID().toString() + private const val STATE_PROCESS = "process" private const val REQUEST_NOTIFICATIONS = 7103 private const val EXTRA_RESTARTED = "com.droiddeck.launcher.extra.RESTARTED" private const val STATE_HOME_CHOICE_OPEN = "home_choice_open" diff --git a/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt b/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt index f4ebf2f0f7..1906b6aa51 100644 --- a/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt +++ b/app/src/main/java/com/droiddeck/launcher/MaliAutoRoute.kt @@ -26,6 +26,12 @@ internal object MaliAutoRoute { fun userChoice(keyStored: Boolean, owner: String, route: String): Boolean = keyStored && owner != route + fun venusStandsIn(available: Boolean, hostVulkanOk: Boolean, venusOn: Boolean, venusExplicit: Boolean, gpuName: String): Boolean = + available && hostVulkanOk && if (venusExplicit) venusOn else !venusStallsOn(gpuName) + + // Steam's web helper dies on its first window through Venus on these (#2879), so the bridge stands in. + fun venusStallsOn(gpuName: String): Boolean = gpuName.contains("G2-Ultra", ignoreCase = true) + fun shouldEnd(ownsRoute: String, mali: Boolean, installedPair: Boolean): Boolean = mali && installedPair && ownsRoute != NONE } diff --git a/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt b/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt index 385081cc7d..b6799bd315 100644 --- a/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/ProtonMenu.kt @@ -45,6 +45,7 @@ internal class ProtonMenu( var experimentalReleases by Operation.experimentalReleases companion object { const val EXPERIMENTAL = "experimental" + private val REMEMBERED = setOf(ProtonExtras.OWN, ProtonExtras.ANTICHEAT) } @VisibleForTesting internal var latestCheck: (Boolean) -> Boolean = { force -> ProtonExtras.checkLatest(activity, force) } @VisibleForTesting internal var experimentalRefresh: () -> List? = { ExperimentalProtons.refresh(activity) } @@ -66,7 +67,7 @@ internal class ProtonMenu( ui.post { protonStage = label; protonPercent = value } } }.getOrElse { it.message ?: it.javaClass.simpleName } - if (problem == null && !automatic && tool.id == ProtonExtras.OWN) ProtonExtras.setDeclined(activity, false) + if (problem == null && !automatic && tool.id in REMEMBERED) ProtonExtras.setDeclined(activity, false, tool.id) if (tool.id == ProtonExtras.OWN) { if (problem == null) Onboarding.finish(Onboarding.Step.PROTON) else Onboarding.fail(Onboarding.Step.PROTON, problem) Onboarding.recheck(activity) @@ -96,7 +97,7 @@ internal class ProtonMenu( protonPercent = -1 Thread({ if (older) ProtonExtras.removeOlder(activity, tool) else ProtonExtras.remove(activity, tool, dir) - if (tool.id == ProtonExtras.OWN && ProtonExtras.installedAll(activity, tool).isEmpty()) ProtonExtras.setDeclined(activity, true) + if (tool.id in REMEMBERED && ProtonExtras.installedAll(activity, tool).isEmpty()) ProtonExtras.setDeclined(activity, true, tool.id) ui.post { protonBusyId = null protonStage = null @@ -158,7 +159,7 @@ internal class ProtonMenu( refreshExperimental() protonRows = ProtonExtras.offered(activity).map { val all = ProtonExtras.installedAll(activity, it) - ProtonRow(it.id, it.name, all.lastOrNull(), ProtonExtras.queued(activity, it), all, ProtonExtras.update(activity, it)) + ProtonRow(it.id, if (it.label != 0) activity.getString(it.label) else it.name, all.lastOrNull(), ProtonExtras.queued(activity, it), all, ProtonExtras.update(activity, it)) } } diff --git a/app/src/main/java/com/droiddeck/launcher/QuestSteamVrWatch.kt b/app/src/main/java/com/droiddeck/launcher/QuestSteamVrWatch.kt new file mode 100644 index 0000000000..eab1ee2f37 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/QuestSteamVrWatch.kt @@ -0,0 +1,36 @@ +package com.droiddeck.launcher + +import com.droiddeck.launcher.gpu.SteamVr + +internal class QuestSteamVrWatch(start: Long) { + private var startupDeadline = start + STARTUP_MS + private var lastRunning: Long? = null + private var graceUntil = start + private var wasPaused = false + + // A frozen guest cannot answer the status call, so a status read during a freeze, or one that + // started before it, says nothing about SteamVR. + fun stopped(now: Long, status: SteamVr.Status, paused: Boolean): Boolean { + if (paused) { + wasPaused = true + return false + } + if (wasPaused) { + wasPaused = false + graceUntil = now + RESUME_GRACE_MS + } + if (status == SteamVr.Status.RUNNING) { + lastRunning = now + graceUntil = now + return false + } + val deadline = lastRunning?.plus(RUNNING_GRACE_MS) ?: startupDeadline + return now >= maxOf(deadline, graceUntil) + } + + companion object { + const val STARTUP_MS = 30_000L + const val RUNNING_GRACE_MS = 5_000L + const val RESUME_GRACE_MS = 15_000L + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt b/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt index 98e5a0b227..9a6db04cc5 100644 --- a/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/QuestXrActivity.kt @@ -4,25 +4,32 @@ import android.app.NativeActivity import android.os.Bundle import android.os.SystemClock import android.util.Log +import android.view.Surface import android.widget.Toast import com.droiddeck.launcher.gpu.SteamVr import com.droiddeck.launcher.session.SessionService import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.xr.XrLayerSource +import com.droiddeck.launcher.session.xr.XrPanels import com.droiddeck.launcher.wayland.CompositorHost import com.droiddeck.launcher.wayland.WaylandCompositor -class QuestXrActivity : NativeActivity() { +class QuestXrActivity : NativeActivity(), XrLayerSource { private var steamVrStarted = false @Volatile private var closing = false @Volatile private var steamVrStatus = SteamVr.Status.UNAVAILABLE private var sessionId: String? = null override fun onCreate(savedInstanceState: Bundle?) { + // NativeActivity opens the library itself, but the layer host's JNI methods resolve only + // through a System.loadLibrary. + System.loadLibrary("droiddeckxr") sessionId = SessionState.sessionId SessionService.setXrActivityVisible(this, true) super.onCreate(savedInstanceState) } fun onXrActive(active: Boolean) { + XrPanels.setDrawing(active) if (active) { check(CompositorHost.isStarted) { "DroidDeck compositor is not running" } SessionService.resume(this) @@ -52,18 +59,17 @@ class QuestXrActivity : NativeActivity() { if (!closing) leaveXr("SteamVR start failed", sessionAlive()) return@Thread } - val startupDeadline = SystemClock.elapsedRealtime() + 30_000 - var lastRunning: Long? = null + val watch = QuestSteamVrWatch(SystemClock.elapsedRealtime()) while (!closing) { if (!sessionAlive()) { leaveXr("Steam session ended", false) break } - steamVrStatus = SteamVr.status(this) - val now = SystemClock.elapsedRealtime() - if (steamVrStatus == SteamVr.Status.RUNNING) lastRunning = now - val deadline = lastRunning?.plus(5_000) ?: startupDeadline - if (steamVrStatus != SteamVr.Status.RUNNING && now >= deadline) { + val pausedBefore = guestPaused() + val status = SteamVr.status(this) + val paused = pausedBefore || guestPaused() + if (!paused) steamVrStatus = status + if (watch.stopped(SystemClock.elapsedRealtime(), status, paused)) { leaveXr("SteamVR stopped or did not finish starting", true) break } @@ -81,6 +87,8 @@ class QuestXrActivity : NativeActivity() { } } + private fun guestPaused() = SessionState.suspending || SessionState.suspended || SessionState.resuming + private fun sessionAlive() = SessionState.running && !SessionState.stopRequested && sessionId != null && SessionState.sessionId == sessionId @@ -99,8 +107,30 @@ class QuestXrActivity : NativeActivity() { fun onXrStatus(): Int = steamVrStatus.ordinal + fun onXrHostBuffers(state: java.nio.ByteBuffer, control: java.nio.ByteBuffer) { + runOnUiThread { if (!closing) XrPanels.attach(this, state, control) } + } + + fun onXrHostFrame() = XrPanels.frame() + + override val context: android.content.Context get() = this + override fun createLayer(width: Int, height: Int) = nativeCreateLayer(width, height) + override fun layerSurface(id: Int) = nativeLayerSurface(id) + override fun destroyLayer(id: Int) = nativeDestroyLayer(id) + override fun setOrbImage(image: android.graphics.Bitmap) = nativeSetOrbImage(image) + override fun leave() { + closing = true + finish() + } + + private external fun nativeCreateLayer(width: Int, height: Int): Int + private external fun nativeLayerSurface(id: Int): Surface? + private external fun nativeDestroyLayer(id: Int) + private external fun nativeSetOrbImage(image: android.graphics.Bitmap) + override fun onDestroy() { closing = true + XrPanels.detach() SessionService.setXrActivityVisible(this, false) super.onDestroy() } diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index f7468607dd..c9fa757bdc 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -76,6 +76,7 @@ import com.droiddeck.launcher.input.InputSpace import com.droiddeck.launcher.input.KeyboardHost import com.droiddeck.launcher.input.ControllerPrefs import com.droiddeck.launcher.input.SessionClipboard +import com.droiddeck.launcher.input.SessionTextInput import com.droiddeck.launcher.input.OnScreenControls import com.droiddeck.launcher.input.OnScreenLayout import com.droiddeck.launcher.input.InputRouter @@ -99,6 +100,12 @@ import com.droiddeck.launcher.input.SteamControllerBle import com.droiddeck.launcher.input.DirectTouchHold import com.droiddeck.launcher.input.GestureTouchStreamGate import com.droiddeck.launcher.input.PenRouter +import com.droiddeck.launcher.input.AirTrigger +import com.droiddeck.launcher.input.AirTriggerButtons +import com.droiddeck.launcher.input.AirTriggerInput +import com.droiddeck.launcher.input.AirTriggerPrefs +import com.droiddeck.launcher.input.AirTriggerSetup +import com.droiddeck.launcher.input.RedMagicAirTriggers import com.droiddeck.launcher.input.PenStream import com.droiddeck.launcher.input.PointerGestures import com.droiddeck.launcher.input.PointerSpace @@ -121,6 +128,7 @@ import com.droiddeck.launcher.session.GpuClockPin import com.droiddeck.launcher.session.GameProfileFollowState import com.droiddeck.launcher.session.GameProfileInventoryCache import com.droiddeck.launcher.session.GameProfileRefreshState +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionEvents import com.droiddeck.launcher.session.SessionArtifacts @@ -162,7 +170,8 @@ import kotlin.math.abs private const val SCREEN_EFFECTS_TARGET_AUTO = "auto" private const val SCREEN_EFFECTS_TARGET_GLOBAL = "global" -class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droiddeck.launcher.ui.AgentPetHost { +class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droiddeck.launcher.ui.AgentPetHost, + com.droiddeck.launcher.session.xr.XrMenuHost { override fun attachBaseContext(newBase: android.content.Context) { super.attachBaseContext(newBase) com.droiddeck.launcher.core.AppLanguage.applyTo(this, newBase) @@ -176,9 +185,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var unfoldedControls by mutableStateOf(false) private var unfoldedControlsWithController by mutableStateOf(false) private var adaptiveSticks by mutableStateOf(null) + private var directController by mutableStateOf(null) private var quickButtons by mutableStateOf>(emptyMap()) private var picturePosition by mutableStateOf("center") + + private fun picturePortrait(config: android.content.res.Configuration = resources.configuration): Boolean = + config.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT private var integerScaling by mutableStateOf(false) + private var gameZoom by mutableStateOf(SessionState.gameZoom) private var avoidNotch = false private fun applyNotchInset(insets: android.view.WindowInsets? = window.decorView.rootWindowInsets) { @@ -227,6 +241,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private var unfoldedPanel by mutableStateOf(null) private var unfoldedColumn: android.widget.LinearLayout? = null + private var unfoldedKeys: View? = null private var unfoldedDeckSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null private var swappedInputSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null private var unfoldedDeckPanel by mutableStateOf(null) @@ -234,6 +249,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private lateinit var sessionRoot: FrameLayout private var inputRouter: InputRouter? = null private var physicalInputBindings: com.droiddeck.launcher.input.PhysicalInputBindings? = null + private var airTriggerInput: AirTriggerInput? = null + private var airTriggersOpen = false + private var airTriggerMenu by mutableStateOf(null) + private var airTriggerGlow: com.droiddeck.launcher.ui.AirTriggerGlow? = null private var inputSettingsOpen by mutableStateOf(false) @Volatile private var inputUsesLocalActions = false private var inputUsesPointer = false @@ -265,6 +284,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde InputCommand.KEYBOARD -> if (role == InputRole.PRIMARY || secondScreenPresentation?.showKeyboard() != true) togglePcKeyboard() InputCommand.STEAM -> tapSteamButton() InputCommand.QUICK_ACCESS -> tapQam() + InputCommand.GAME_ZOOM_IN -> { + gameZoom = (gameZoom + 0.25f).coerceAtMost(3.0f) + SessionState.gameZoom = gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + } + InputCommand.GAME_ZOOM_OUT -> { + gameZoom = (gameZoom - 0.25f).coerceAtLeast(1.0f) + SessionState.gameZoom = gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + } } } } @@ -337,6 +366,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde window.decorView.hasWindowFocus() || secondScreenPresentation?.window?.decorView?.hasWindowFocus() == true } } + private val sessionTextInput by lazy { + SessionTextInput(this) { + window.decorView.hasWindowFocus() || secondScreenPresentation?.window?.decorView?.hasWindowFocus() == true + } + } private var watching = true private lateinit var touchpad: TouchpadGestures private lateinit var directTouchHold: DirectTouchHold @@ -344,7 +378,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private lateinit var threeFingerTap: com.droiddeck.launcher.input.ThreeFingerTap private lateinit var touchscreenGestures: TouchscreenGestures private var gestureConfig = com.droiddeck.launcher.input.TouchGestureConfig() - private var gestureGame: String? = null + private var gestureGame by mutableStateOf(null) private var gameStarts by mutableIntStateOf(0) private var gestureSettingsOpen by mutableStateOf(false) private var steamImportAsk by mutableStateOf(null) @@ -450,13 +484,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde return true } private val uiHandler = Handler(Looper.getMainLooper()) - private var pendingBackAction: Runnable? = null + private var backTapOpenedDrawer = false + private val backTapsAtOnce: Boolean get() = SessionState.mode != SessionService.MODE_STEAM || !backActionsInverted + private val backTaps = com.droiddeck.launcher.input.BackTaps( + windowMs = { backDoubleTapMs.toLong() }, + atOnce = { backTapsAtOnce }, + onTap = { performBackAction(double = it) }, + sameAction = { SessionState.mode != SessionService.MODE_STEAM }, + ) private val backQamInput = com.droiddeck.launcher.input.BackQamInput( setPressed = { padBridge?.setBackQamPressed(it) }, onTap = { performBackAction(double = it) }, doubleTapMs = { backDoubleTapMs.toLong() }, onCancel = { padBridge?.cancelBackQam() }, holds = { backHold }, + atOnce = { backTapsAtOnce }, + sameAction = { SessionState.mode != SessionService.MODE_STEAM }, ) private val mouseBackInput = com.droiddeck.launcher.input.MouseBackInput( sendRight = { down -> heldButtons.set(32, PointerGestures.BTN_RIGHT, down) }, @@ -526,6 +569,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var drawerOpenState by mutableStateOf(false) private var typingReturnMode: SecondScreenMode? = null private var drawerDocked by mutableStateOf(false) + /** The menu is open as a floating panel in the immersive Quest view instead of over this window. */ + private var drawerXr by mutableStateOf(false) private var drawerPinned by mutableStateOf(false) private var drawerLayerOpen = false private var drawerBackRequests by mutableIntStateOf(0) @@ -542,10 +587,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde drawerLayerOpen = false drawerPinned = false if (value) { + directController = com.droiddeck.launcher.session.DirectControllerSwitch.state(this) releaseHeldKeys() - drawerDocked = dockDrawer() && openDockedMenu() + drawerXr = com.droiddeck.launcher.session.xr.XrPanels.showMenu() + drawerDocked = !drawerXr && dockDrawer() && openDockedMenu() } drawerOpenState = value + if (!value && drawerXr) { + drawerXr = false + com.droiddeck.launcher.session.xr.XrPanels.hideMenu() + } if (!value && drawerDocked) closeDockedMenu() } private val dockedMenuIdle: Boolean get() = com.droiddeck.launcher.input.DualScreen.menuIdleOnBottom(drawerOpen, drawerDocked, drawerPinned, dockedMenuController) @@ -595,6 +646,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var drawerControllerActive by mutableStateOf(false) private var backHold by mutableStateOf(true) private var dockedMenuController by mutableStateOf(false) + private var sessionFullscreenMode by mutableStateOf(FullscreenMode.ALWAYS) private var sessionOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) private var dualScreenSessionMode by mutableStateOf(com.droiddeck.launcher.input.DualScreen.MODE_AUTO) private var backActionsInverted by mutableStateOf(false) @@ -623,6 +675,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var effects by mutableStateOf(ScreenEffects.OFF) private var observedScreenEffectsProfileId by mutableStateOf(null) private var screenEffectsTarget by mutableStateOf(SCREEN_EFFECTS_TARGET_AUTO) + private var screenEffectsProfileRevision by mutableIntStateOf(0) private var cardboard by mutableStateOf(Cardboard.OFF) private var headTracker: HeadTracker? = null private var steamVrStatus by mutableStateOf(null) @@ -683,9 +736,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var drawerTextureAnisotropy by mutableStateOf(null) private var drawerTextureLodBias by mutableStateOf(null) private var lossless by mutableStateOf(Lossless.State.NONE) - private val pickLossless = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r -> - if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let { importLossless(it) } - } private var frameGen by mutableStateOf(FrameGen.Mode.OFF) private var frameGenActiveGameId by mutableStateOf(null) private var frameGenActiveGameName by mutableStateOf(null) @@ -703,6 +753,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde @Volatile private var frameGenInventoryLastAttemptAt = 0L private val frameGenInventoryRetryScheduled = java.util.concurrent.atomic.AtomicBoolean() private val frameGenInventoryRefreshScheduled = java.util.concurrent.atomic.AtomicBoolean() + @Volatile private var frameGenInventoryRefreshDue = false + @Volatile private var frameGenInventoryMissedAppId = 0L @Volatile private var appliedFrameGenMode: FrameGen.Mode? = null @Volatile private var appliedFrameGenHz: Float? = null @@ -785,6 +837,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private var isHomeApp by mutableStateOf(false) private var androidApps by mutableStateOf>(emptyList()) + private var padConnected by mutableStateOf(false) private val deviceListener = object : InputManager.InputDeviceListener { override fun onInputDeviceAdded(deviceId: Int) { @@ -827,6 +880,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + com.droiddeck.launcher.session.xr.XrPanels.setMenuHost(this) AgentGuest.readyListener = agentReadyListener com.droiddeck.launcher.agent.AgentAttachments.gameFrame = gameFrame if (com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isRemoving() || @@ -842,6 +896,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde finish() return } + if (!SessionState.running && com.droiddeck.launcher.stores.steam.SteamStore.blocksSession(intent)) { + runtimeRemovalBlocked = true + android.widget.Toast.makeText(this, R.string.steam_store_session_wait, android.widget.Toast.LENGTH_SHORT).show() + finish() + return + } + if (savedInstanceState == null && !SessionState.running && !com.droiddeck.launcher.stores.steam.SteamStore.downloading()) { + // The Steam client signs in itself; the store's own sign-in must not overlap it. + Thread({ com.droiddeck.launcher.stores.steam.SteamEngine.forget() }, "steam-store-signout").start() + } if (!SessionState.running && SessionState.phase in setOf(SessionPhase.IDLE, SessionPhase.FAILED)) { val mode = intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM SessionState.programArgs = intent.getStringArrayExtra(SessionService.EXTRA_PROGRAM_ARGS)?.toList().orEmpty() @@ -880,7 +944,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } applyFollowChoice() applyFollowOrientation(resources.configuration) - goFullscreen() + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + applySessionFullscreen() volumeControlStream = android.media.AudioManager.STREAM_MUSIC displayManager = getSystemService(DISPLAY_SERVICE) as DisplayManager refreshSecondScreenDisplays() @@ -892,6 +957,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onCapturedPointer(event) || super.dispatchCapturedPointerEvent(event) override fun dispatchPointerCaptureChanged(hasCapture: Boolean) { super.dispatchPointerCaptureChanged(hasCapture) + capturedTouchpad.cancel() + heldButtons.release(64) Log.i(TAG, "pointer capture " + if (hasCapture) "on" else "off") if (hasCapture) { pointerCaptureRefused = false @@ -922,6 +989,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde bridge.setBuiltinPad(SessionState.mode != SessionService.MODE_STEAM || SessionPrefs.builtinPad(this)) padBridge = bridge inputRouter = InputRouter(inputOutput).also { bridge.setInputRouter(it); DeckControls.setRouter(it); physicalInputBindings = com.droiddeck.launcher.input.PhysicalInputBindings(it) } + if (RedMagicAirTriggers.supported(this)) { + airTriggerInput = AirTriggerInput(bridge, ::holdOnScreen, ::airTriggerTouched) + RedMagicAirTriggers.restore(this) + } refreshInputProfile() bridge.setOnChordInput(backQamInput::onChordInput) SessionState.padBridge = bridge @@ -945,6 +1016,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde openDeckRing("activity created") bridge.setOnPlayerInput(::onPadInput) onScreenControls = OnScreenControls(this, bridge).also { controls -> + controls.alpha = onScreenOpacityAlpha() controls.updateLayout(primaryInputLayout) controls.onTouchMiss = miss@{ event -> if (!gestureTouchStreamGate.accepts(GestureTouchStreamGate.Source.ON_SCREEN_CONTROLS, event)) return@miss @@ -953,7 +1025,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } root.addView(controls) } - keyboard = KeyboardHost(this).also { host -> + keyboard = KeyboardHost(this, sendKeyEvent = ::dispatchImeKeyEvent, sendText = WaylandCompositor::textInputCommit).also { host -> host.onImeChanged = ::onPrimaryImeChanged root.addView(host) } @@ -1046,6 +1118,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde override fun onResolvePointerIcon(event: MotionEvent, pointerIndex: Int): android.view.PointerIcon? = if (platformPointerShown == true) super.onResolvePointerIcon(event, pointerIndex) else null }.apply { addView(sessionOverlay) }) + if (airTriggerInput != null) airTriggerGlow = com.droiddeck.launcher.ui.AirTriggerGlow(this).also { root.addView(it) } setContentView(root) glassesScope.launch { Glasses.state.collect { glasses = it @@ -1115,11 +1188,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde when { ::loading.isInitialized && loading.ended -> finish() inputSettingsOpen -> inputSettingsOpen = false - dockedTouchOnly -> routeBackAction() + dockedTouchOnly || backTaps.pending -> backTaps.tap() drawerOpen -> drawerOpen = false achievementsOpen -> closeAchievements() pcKeyboardOpen -> pcKeyboardOpen = false - else -> routeBackAction() + else -> backTaps.tap() } } }) @@ -1131,6 +1204,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde isFocusableInTouchMode = true defaultFocusHighlightEnabled = false setContent { + androidx.compose.runtime.LaunchedEffect(SessionState.running, SessionState.sessionId) { + if (SessionState.running) { + gameZoom = SessionState.gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + } else { + gameZoom = 1.0f + SessionState.gameZoom = 1.0f + runCatching { WaylandCompositor.nativeSetZoom(1.0f) } + } + } + val activeEffectsProfileId = currentScreenEffectsProfileId() val effectsEditorTarget = if (drawerOpen) screenEffectsTarget else null val effectsEditorProfileId = activeEffectsProfileId.takeIf { @@ -1147,7 +1231,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val cursorHidden = cursorHiddenByUi() androidx.compose.runtime.SideEffect { com.droiddeck.launcher.glasses.GlassesMenuMirror.setSessionMenuVisible(this@SessionActivity, - (drawerOpen || achievementsOpen || pcKeyboardOpen) && !pipUi && steamVrStatus != SteamVr.Status.RUNNING) + (drawerOpen || achievementsOpen || pcKeyboardOpen) && !pipUi && !drawerXr && steamVrStatus != SteamVr.Status.RUNNING) } androidx.compose.runtime.SideEffect { applyPlatformPointer(uiPointer) } androidx.compose.runtime.DisposableEffect(Unit) { @@ -1198,6 +1282,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde CursorOverlay({ cursorPos }, cursorVisible && (!cursorHidden || onlyPcKeyboardOpen()) && !bottomOutputActive, resources.displayMetrics.density, cursorImage, cursorHotX, cursorHotY, cursorImageScale) + if (memoryHud.text.isNotEmpty()) HudText(memoryHud.text, hudColor, hudOpacity) if (bottomOutputActive && !loading.visible) SwappedTopPanel() val phonePanel = glassesOutputActive && !loading.visible && !drawerOpen && !pcKeyboardOpen @@ -1216,14 +1301,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde glasses.usesSpatialControllers(glassesSettings) && glassesSettings.joyConTracking) joyConVr?.let { { it.recenter() } } else null, ) { headTracker?.recenter() } - if (!phonePanel && glasses.present && !drawerOpen && !pcKeyboardOpen && !loading.visible) com.droiddeck.launcher.ui.GlassesCornerButton(glassesSlot, + val showGlassesShortcut = com.droiddeck.launcher.ui.rememberShowGlassesShortcut() + if (!phonePanel && glasses.present && showGlassesShortcut && !drawerOpen && !pcKeyboardOpen && !loading.visible) com.droiddeck.launcher.ui.GlassesCornerButton(glassesSlot, controllerSettings?.tint ?: android.graphics.Color.rgb(90, 160, 255), controllerSettings?.opacity ?: 100) { - drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.GLASSES + drawerPage = com.droiddeck.launcher.ui.SessionDrawerPage.VR drawerOpen = true } if (!drawerOpen && !pcKeyboardOpen && !loading.visible) { com.droiddeck.launcher.ui.DrawerEntryHint(SessionState.mode == SessionService.MODE_STEAM, backActionsInverted) { drawerOpen = true } if (cornerTap) com.droiddeck.launcher.ui.DrawerCornerTap { drawerOpen = true } + if (com.droiddeck.launcher.session.QuestExperimental.isSupported()) + com.droiddeck.launcher.ui.DrawerEdgeSwipe { onBackPressedDispatcher.onBackPressed() } } if (loading.visible) LoadingOverlay( loading.step, loading.percent, loading.elapsed, loading.hint, loading.ended, @@ -1301,6 +1389,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (nextGame != null) gameStarts++ gestureGame = nextGame refreshGestureConfig() + restoreGamePanel(nextGame) } if ( SessionState.mode == SessionService.MODE_STEAM && @@ -1314,9 +1403,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } LaunchedEffect(drawerOpen, menuOwnsController, pcKeyboardOpen, achievementsOpen, gestureSettingsOpen, inputSettingsOpen, pipUi, SessionState.suspended, resumed, appTextFocus) { updateOnScreenControls() + refreshAirTriggers() padBridge?.setInputEnabled(resumed && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen && !pipUi && !appTextFocus && !SessionState.suspended) - if (drawerOpen || pcKeyboardOpen || achievementsOpen || gestureSettingsOpen || inputSettingsOpen || pipUi || appTextFocus || SessionState.suspended) { - backQamInput.cancel() + if (!drawerOpen && backTapOpenedDrawer) { + backTaps.cancel() + backQamInput.cancelTap() + backTapOpenedDrawer = false + } + val otherPanel = pcKeyboardOpen || achievementsOpen || gestureSettingsOpen || inputSettingsOpen || pipUi || appTextFocus || SessionState.suspended + if (drawerOpen || otherPanel) { + if (otherPanel || !backTapOpenedDrawer) backTaps.cancel() + backQamInput.cancel(keepTap = backTapOpenedDrawer && !otherPanel) com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this@SessionActivity) cancelTouchGestures() } @@ -1370,7 +1467,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (drawerOpen) { syncLossless() if (menuOwnsController) { - releasePads() + releasePads(keepBackTap = backTapOpenedDrawer) androidx.compose.runtime.withFrameNanos { } val requested = focusDrawer() Log.i(TAG, "drawer root focus requested=$requested docked=$drawerDocked") @@ -1397,7 +1494,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } LaunchedEffect(drawerOpen, achievementsOpen, AgentGuest.focusRevision, StoreAchievements.revision) { - if (!drawerOpen && !achievementsOpen) return@LaunchedEffect + if (!drawerOpen && !achievementsOpen) { + achievementsInFront = null + return@LaunchedEffect + } val found = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { runCatching { resolveAchievementsInFront() } .onFailure { Log.w(TAG, "achievements in front: ${it.javaClass.simpleName}") }.getOrNull() @@ -1409,16 +1509,20 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde LaunchedEffect(pcKeyboardOpen, drawerOpen, achievementsOpen) { if (pcKeyboardOpen || drawerOpen || achievementsOpen) padMouse.reset() } + val panelShown = panelOverGame + LaunchedEffect(panelShown) { boostGpuClock(panelShown && resumed) } if (pcKeyboardOpen) com.droiddeck.launcher.ui.PcKeyboard( sendKey = { code, down -> if (CompositorHost.isStarted) sendGuestKey(code, down, 32) }, onAndroidKeyboard = { pcKeyboardOpen = false; togglePrimaryKeyboard() }, onClose = { pcKeyboardOpen = false }, ) - if (!drawerDocked) SessionMenu( + if (!drawerDocked && !drawerXr) SessionMenu( docked = false, effectsEditorProfileId = effectsEditorProfileId, effectsEditorTarget = effectsEditorTarget, ) + if (drawerOpen && !drawerDocked && !drawerXr && com.droiddeck.launcher.session.QuestExperimental.isSupported()) + com.droiddeck.launcher.ui.DrawerEdgeSwipe { onBackPressedDispatcher.onBackPressed() } LaunchedEffect(achievementsOpen) { if (achievementsOpen) { releasePads() @@ -1467,6 +1571,74 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } + @androidx.compose.runtime.Composable + override fun XrMenuContent() { + val activeEffectsProfileId = currentScreenEffectsProfileId() + val effectsEditorTarget = if (drawerOpen) screenEffectsTarget else null + val effectsEditorProfileId = activeEffectsProfileId.takeIf { effectsEditorTarget == SCREEN_EFFECTS_TARGET_AUTO } + androidx.compose.runtime.LaunchedEffect(effectsEditorTarget, effectsEditorProfileId) { + when (effectsEditorTarget) { + SCREEN_EFFECTS_TARGET_AUTO -> syncActiveScreenEffectsProfile() + null -> Unit + else -> syncScreenEffectsTarget(effectsEditorTarget) + } + } + SessionMenu(docked = true, effectsEditorProfileId = effectsEditorProfileId, effectsEditorTarget = effectsEditorTarget) + } + + override fun xrSetMenuOpen(open: Boolean) { + if (open != drawerOpen) drawerOpen = open + } + + /** + * In the immersive Quest view, Stop takes the user back to this window with the session still + * running, and Stop SteamVR leaves at once instead of after the stop is noticed. + */ + private fun leaveXrMenu() { + if (!drawerXr) return + drawerOpen = false + com.droiddeck.launcher.session.xr.XrPanels.leaveImmersive() + } + + override fun xrMenuBack() { + if (drawerLayerOpen) drawerBackRequests++ else drawerOpen = false + } + + override fun xrSendKey(code: Int, down: Boolean) { + if (CompositorHost.isStarted) sendGuestKey(code, down, 32) + } + + override fun xrTypeText(text: String) = xrKeys.type(text) + + override fun xrImmersiveChanged(active: Boolean) { + if (active) { + if (immersiveFlatSize == null) immersiveFlatSize = SessionState.outputSize + resizeOutputForWindow(surfaceW, surfaceH) + return + } + val flat = immersiveFlatSize + immersiveFlatSize = null + if (windowOutputSize(surfaceW, surfaceH) == null && flat != null) applyOutputSize(flat) + else resizeOutputForWindow(surfaceW, surfaceH) + } + + /** The output's size when the immersive view opened; this window may have no surface while it is up. */ + private var immersiveFlatSize: Pair? = null + + override fun xrTapKey(keyCode: Int) = xrKeys.tap(keyCode) + + /** The VR keyboard's keys go straight to the game, past the menu and pad handling a real key passes through. */ + private val xrKeys by lazy { + KeyboardHost( + this, + sendKeyEvent = { event -> + CompositorHost.isStarted && (event.action != KeyEvent.ACTION_DOWN || event.repeatCount == 0) && + com.droiddeck.launcher.input.GuestKeys.send(event) { code, pressed -> sendGuestKey(code, pressed, 16) } + }, + sendText = { text -> if (CompositorHost.isStarted) WaylandCompositor.textInputCommit(text) }, + ) + } + @androidx.compose.runtime.Composable private fun SessionMenu( docked: Boolean, @@ -1491,8 +1663,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde effects = effects, screenEffectsTarget = screenEffectsTarget, screenEffectsTargets = screenEffectsTargetOptions(), - screenEffectsCanDelete = screenEffectsProfileIdForTarget(screenEffectsTarget)?.let { - SessionPrefs.hasScreenEffectsOverride(this@SessionActivity, it) + screenEffectsCanDelete = screenEffectsProfileRevision.let { + screenEffectsProfileIdForTarget(screenEffectsTarget)?.let { + SessionPrefs.hasScreenEffectsOverride(this@SessionActivity, it) || + SessionPrefs.hasScreenEffectsUpscalerOverride(this@SessionActivity, it) + } } == true, cardboard = cardboard, cardboardSensor = hasRotationSensor, @@ -1563,6 +1738,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() }, onHudOrderReset = { hudConfig = DroidDeckHudConfig.clearOrder(this@SessionActivity); hud.applyConfig() }, onHudExport = { exportHudDiagnostics() }, + gameZoomAvailable = SessionState.running, + gameZoom = gameZoom, + onGameZoom = { value -> + gameZoom = value.coerceIn(1.0f, 3.0f) + SessionState.gameZoom = gameZoom + runCatching { WaylandCompositor.nativeSetZoom(gameZoom) } + }, + picturePosition = picturePosition, + onPicturePosition = { position -> + SessionPrefs.setPicturePosition(this@SessionActivity, picturePortrait(), position) + picturePosition = position + }, integerScaling = integerScaling, onIntegerScaling = { enabled -> SessionPrefs.setIntegerScaling(this@SessionActivity, enabled) @@ -1586,6 +1773,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else { val profileId = screenEffectsProfileIdForTarget(target) SessionPrefs.setScreenEffectsUpscaler(this@SessionActivity, profileId, m) + screenEffectsProfileRevision++ if (target == screenEffectsTarget) { upscaler = m @@ -1621,6 +1809,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else { val profileId = screenEffectsProfileIdForTarget(target) SessionPrefs.setScreenEffectsUpscaler(this@SessionActivity, profileId, m) + screenEffectsProfileRevision++ if (target == screenEffectsTarget) { upscaler = m if (screenEffectsUpscalerTargetAppliesToLiveOutput(target)) { @@ -1667,7 +1856,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val profileId = screenEffectsProfileIdForTarget(editorTarget) SessionPrefs.setScreenEffects(this@SessionActivity, profileId, e) effects = e - if (screenEffectsTargetAppliesToLiveOutput(editorTarget)) e.push(upscaler) + if (screenEffectsTargetAppliesToLiveOutput(editorTarget)) { + val upscalerAppliesToLiveOutput = + screenEffectsUpscalerTargetAppliesToLiveOutput(editorTarget) + val liveUpscaler = if (upscalerAppliesToLiveOutput) { + SessionPrefs.screenEffectsUpscaler( + this@SessionActivity, + screenEffectsProfileIdForTarget(editorTarget) + ) + } else { + SessionPrefs.screenEffectsUpscaler( + this@SessionActivity, + currentScreenEffectsProfileId() + ) + } + e.push(liveUpscaler) + } } } }, @@ -1724,7 +1928,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onBlackFrameInsertion = { on -> SessionPrefs.setBlackFrameInsertion(this@SessionActivity, on) blackFrameInsertion = on - CompositorHost.setBlackFrameInsertion(on, refreshHz(), outputFpsLimit()) + CompositorHost.setBlackFrameInsertion(on, refreshHz(), compositorFpsLimit(), outputFpsLimit()) }, hdr = hdrWanted, hdrAvailable = hdrAvailable, @@ -1747,20 +1951,45 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde readPrefs() applyFrameGen(force = true) }, - onImportLossless = { - pickLossless.launch(InAppFilePicker.buildIntent( - this@SessionActivity, listOf("dll"), getString(R.string.lsfg_pick_title))) - }, onKeyboard = { drawerOpen = false; pcKeyboardOpen = false; togglePrimaryKeyboard() }, onHardwareKeyboard = ::togglePcKeyboard, wowChatShown = com.droiddeck.launcher.ui.WowChat.isWow(AgentGuest.gameProgram), wowChat = wowChat.remembered, onWowChat = wowChat::choose, controller = controllerSettings, + airTriggers = airTriggerMenu, + onAirTriggers = { on -> AirTriggerPrefs.setEnabled(this@SessionActivity, on); refreshAirTriggers() }, + onAirTriggerButton = { trigger, id -> + AirTriggerPrefs.setButton(this@SessionActivity, primaryInputLayout?.id.orEmpty(), trigger, id) + refreshAirTriggers() + }, + onAirTriggerAction = { trigger, action -> + AirTriggerPrefs.setAction(this@SessionActivity, primaryInputLayout?.id.orEmpty(), trigger, action) + refreshAirTriggers() + }, + onAirTriggerRate = { trigger, rate -> + AirTriggerPrefs.setRate(this@SessionActivity, primaryInputLayout?.id.orEmpty(), trigger, rate) + refreshAirTriggers() + }, + onAirTriggerVibration = { on -> AirTriggerPrefs.setVibration(this@SessionActivity, on); refreshAirTriggers() }, + onAirTriggerScreenLight = { on -> AirTriggerPrefs.setScreenLight(this@SessionActivity, on); refreshAirTriggers() }, + onAirTriggerLed = { led -> + AirTriggerPrefs.setLed(this@SessionActivity, led) + if (airTriggersOpen) RedMagicAirTriggers.open(this@SessionActivity) + refreshAirTriggers() + }, + onControllerSize = { percent -> updateControllerPrefs { ControllerPrefs.setSize(this@SessionActivity, percent) } }, + onControllerOpacity = { percent -> + ControllerPrefs.setOnScreenOpacity(this@SessionActivity, percent) + controllerSettings = ControllerPrefs.read(this@SessionActivity) + applyOnScreenOpacity() + }, onRumble = { on -> updateControllerPrefs { ControllerPrefs.setRumble(this@SessionActivity, on) } }, onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null, onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null, - onAchievements = achievementsInFront?.let { { drawerOpen = false; achievementsOpen = true } }, + controllerConnected = padConnected, + achievementsGame = achievementsInFront?.game, + achievementsTitle = achievementsInFront?.title, achievementsProgress = achievementsInFront?.progress, padType = if (SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad) padType else null, onPadType = { id -> @@ -1835,9 +2064,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde SessionService.suspendPolicyChanged(this@SessionActivity) }, onTouch = { v -> SessionPrefs.setTouchMode(this@SessionActivity, v); readPrefs() }, - onInputSettings = { releasePads(); drawerOpen = false; inputSettingsOpen = true }, + onInputSettings = { leaveImmersiveForDialog(); releasePads(); drawerOpen = false; inputSettingsOpen = true }, onInputSelection = { releasePads(); refreshInputProfile() }, - onGestureSettings = { drawerOpen = false; gestureSettingsOpen = true }, + onGestureSettings = { leaveImmersiveForDialog(); drawerOpen = false; gestureSettingsOpen = true }, touchActive = drawerTouchMode(), directHoldBehavior = directHoldBehavior, onDirectHoldBehavior = { value -> @@ -1879,9 +2108,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onPause = ::pauseNow, paused = SessionState.suspended || SessionState.manualPause, onResume = { SessionService.resume(this@SessionActivity) }, + fullscreenMode = sessionFullscreenMode, + onFullscreenMode = { mode -> + SessionPrefs.setSessionFullscreenMode(this@SessionActivity, mode) + sessionFullscreenMode = mode + applySessionFullscreen() + }, orientation = sessionOrientation, onOrientation = { value -> - SessionPrefs.setOrientation(this@SessionActivity, value) + when (SessionState.mode) { + SessionService.MODE_STEAM, SessionService.MODE_RUN -> + SessionPrefs.setOrientation(this@SessionActivity, "steam", value) + SessionService.MODE_DESKTOP -> + SessionPrefs.setOrientation(this@SessionActivity, "desktop", value) + else -> SessionPrefs.setOrientation(this@SessionActivity, value) + } sessionOrientation = value applyFollowOrientation(resources.configuration) }, @@ -1892,6 +2133,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde }, unfoldedControls = unfoldedControls, onUnfoldedControls = ::chooseUnfoldedControls, + deckPanel = unfoldedDeckPanel, + onDeckPanel = ::selectDeckPanel, adaptiveSticks = adaptiveSticks.takeIf { unfoldedPanel != null || oscMode != SessionPrefs.OSC_NEVER && oscMode != SessionPrefs.OSC_STEAM_QAM && !steamTouchInUse }, @@ -1899,6 +2142,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde primaryInputLayout?.let { com.droiddeck.launcher.input.InputLibraries.setAdaptiveSticks(this@SessionActivity, it.id, on) } refreshInputProfile() }, + directController = directController, + onDirectController = { on -> + com.droiddeck.launcher.session.DirectControllerSwitch.set(this@SessionActivity, on) + directController = on + }, showFloatingSteamControls = SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad && unfoldedPanel == null && oscMode != SessionPrefs.OSC_NEVER && oscMode != SessionPrefs.OSC_STEAM_QAM && !steamTouchInUse && OnScreenLayout.supportsFloatingSteamControls(padType, primaryInputLayout), @@ -1928,18 +2176,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onUnfoldedControlsWithController = ::chooseUnfoldedControlsWithController, onBackground = { drawerOpen = false; pip.background(); moveTaskToBack(true) }, onShareLogs = { drawerOpen = false; shareCurrentSessionLogs() }, - onStop = { drawerOpen = false; SessionService.stop(this@SessionActivity); finish() }, + onStop = { + if (drawerXr) leaveXrMenu() else { + drawerOpen = false + SessionService.stop(this@SessionActivity) + finish() + } + }, onStopFrom = { onScreen -> - drawerOpen = false - if (onScreen == null || com.droiddeck.launcher.ui.Motion.scale == 0f || quitFrom != null) { - if (quitFrom == null) { SessionService.stop(this@SessionActivity); finish() } - } else { - val at = IntArray(2).also { sessionOverlay.getLocationOnScreen(it) } - quitFrom = onScreen.translate(-at[0].toFloat(), -at[1].toFloat()) + if (drawerXr) leaveXrMenu() else { + drawerOpen = false + if (onScreen == null || com.droiddeck.launcher.ui.Motion.scale == 0f || quitFrom != null) { + if (quitFrom == null) { SessionService.stop(this@SessionActivity); finish() } + } else { + val at = IntArray(2).also { sessionOverlay.getLocationOnScreen(it) } + quitFrom = onScreen.translate(-at[0].toFloat(), -at[1].toFloat()) + } } }, onClose = { drawerOpen = false }, - onDismissScreen = if (docked) ({ selectSecondScreenMode(SecondScreenMode.NONE) }) else null, + onDismissScreen = if (docked && !drawerXr) ({ selectSecondScreenMode(SecondScreenMode.NONE) }) else null, components = drawerComponents, onComponentsRefresh = { refreshDrawerComponents() @@ -2017,7 +2273,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde }) else null, onKeyboard = { togglePrimaryKeyboard() }, onSessionMenu = { drawerOpen = true }, - onStopSteamVr = if (vr) ({ steamVrAction("stop") }) else null, + onStopSteamVr = if (vr) ({ leaveXrMenu(); steamVrAction("stop") }) else null, brightness = glasses.brightness, brightnessMax = glasses.brightnessMax, onBrightness = if (glasses.canControl && glasses.hardwareControls) Glasses::setBrightness else null, @@ -2056,6 +2312,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun togglePcKeyboard() { drawerOpen = false + if (com.droiddeck.launcher.session.xr.XrPanels.toggleGameKeyboard(pc = true)) return hidePrimaryKeyboard() onScreenControls?.releaseAll() bottomInputControls?.releaseAll() @@ -2065,12 +2322,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun showPrimaryKeyboard() { pendingFieldKeyboard = false fieldKeyboardOnPrimary = false + if (com.droiddeck.launcher.session.xr.XrPanels.showGameKeyboard(pc = false)) return keyboard?.show() } private fun togglePrimaryKeyboard() { pendingFieldKeyboard = false fieldKeyboardOnPrimary = false + if (com.droiddeck.launcher.session.xr.XrPanels.toggleGameKeyboard(pc = false)) return keyboard?.toggle() } @@ -2094,31 +2353,33 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (fieldKeyboardOnPrimary) hidePrimaryKeyboard() } + private fun onScreenOpacityAlpha() = ControllerPrefs.onScreenOpacity(this) / 100f + + private fun applyOnScreenOpacity() { + val alpha = onScreenOpacityAlpha() + onScreenControls?.alpha = alpha + bottomInputControls?.alpha = alpha + unfoldedColumn?.alpha = alpha + swappedInputSurface?.alpha = alpha + secondScreenPresentation?.controlsView?.alpha = alpha + steamTouchControls?.let { it.alpha = if (it.isEditing) 1f else alpha } + } + private fun updateControllerPrefs(change: () -> Unit) { change() controllerSettings = ControllerPrefs.read(this) onScreenControls?.reload() - } - - private fun routeBackAction() { - pendingBackAction?.let { pending -> - uiHandler.removeCallbacks(pending) - pendingBackAction = null - performBackAction(double = true) - return - } - val pending = Runnable { - pendingBackAction = null - performBackAction(double = false) - } - pendingBackAction = pending - uiHandler.postDelayed(pending, backDoubleTapMs.toLong()) + bottomInputControls?.reload() + unfoldedPanel?.reload() } private fun performBackAction(double: Boolean) { val isSteam = SessionState.mode == SessionService.MODE_STEAM val opensQam = isSteam && (double xor backActionsInverted) - if (opensQam) triggerSteamQam() else if (!dockedTouchOnly) drawerOpen = !drawerOpen + if (opensQam) triggerSteamQam() else if (!dockedTouchOnly) { + drawerOpen = !drawerOpen + backTapOpenedDrawer = drawerOpen && !double + } } private fun handleHomeGuideIntent(incoming: Intent?) { @@ -2461,10 +2722,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val targetUpscaler = SessionPrefs.screenEffectsUpscaler(this, profileId) effects = targetEffects upscaler = targetUpscaler + val upscalerAppliesToLiveOutput = screenEffectsUpscalerTargetAppliesToLiveOutput(target) + val liveUpscaler = if (upscalerAppliesToLiveOutput) { + targetUpscaler + } else { + SessionPrefs.screenEffectsUpscaler(this, currentScreenEffectsProfileId()) + } + if (upscalerAppliesToLiveOutput) { + WaylandCompositor.nativeSetUpscaler(liveUpscaler) + } if (screenEffectsTargetAppliesToLiveOutput(target)) { - WaylandCompositor.nativeSetUpscaler(targetUpscaler) - WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(targetEffects, targetUpscaler)?.name) - targetEffects.push(targetUpscaler) + WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(targetEffects, liveUpscaler)?.name) + targetEffects.push(liveUpscaler) + } else if (upscalerAppliesToLiveOutput) { + val liveEffects = SessionPrefs.screenEffects(this, currentScreenEffectsProfileId()) + WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(liveEffects, liveUpscaler)?.name) } } @@ -2477,6 +2749,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun resetScreenEffectsTarget(target: String) { if (target != screenEffectsTarget) return SessionPrefs.resetScreenEffectsProfile(this, screenEffectsProfileIdForTarget(target)) + screenEffectsProfileRevision++ syncScreenEffectsTarget(target) } @@ -2484,6 +2757,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (target != screenEffectsTarget) return val profileId = screenEffectsProfileIdForTarget(target) ?: return SessionPrefs.deleteScreenEffectsProfile(this, profileId) + screenEffectsProfileRevision++ syncScreenEffectsTarget(target) } @@ -2603,11 +2877,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun gpuClockHeld() = SessionPrefs.gpuClockPin(this) && !GpuClockPin.failed + private val panelOverGame: Boolean get() = ((drawerOpen && !drawerDocked) || achievementsOpen || gestureSettingsOpen || inputSettingsOpen) && !pipUi + + private fun boostGpuClock(on: Boolean) { + if (!GpuClockPin.boost(on)) return + Thread { GpuClockPin.sync(applicationContext)?.let { Log.i(TAG, it) } }.start() + } + private fun readPrefs() { pipAutoEnter = SessionPrefs.pipAutoEnter(this) unfoldedControls = SessionPrefs.unfoldedControls(this) unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this) - picturePosition = SessionPrefs.picturePosition(this) + picturePosition = SessionPrefs.picturePosition(this, picturePortrait()) integerScaling = SessionPrefs.integerScaling(this) avoidNotch = SessionPrefs.avoidNotch(this) applyNotchInset() @@ -2663,7 +2944,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde oscTrackpads = SessionPrefs.oscTrackpads(this) backHold = SessionPrefs.backHold(this) dockedMenuController = SessionPrefs.dockedMenuController(this) - sessionOrientation = SessionPrefs.orientation(this) + sessionOrientation = SessionPrefs.orientation(this, SessionState.mode) dualScreenSessionMode = SessionPrefs.dualScreenSessionMode(this) backActionsInverted = SessionPrefs.backActionsInverted(this) physicalShortcuts.bindings = PhysicalShortcuts.read(this) @@ -2834,7 +3115,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun installProton(): String? { uiHandler.post { loading.percent = -1; loading.say(getString(PROTON_LINES.downloading), PROTON_LINES.topic, readable = true) } - if (com.droiddeck.launcher.session.SessionPrefs.ownProtonFirst(this)) return installOwnProton() val catalog = com.droiddeck.launcher.runtime.DesktopCatalog val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested } SessionState.installCancellation = cancellation @@ -2847,24 +3127,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } - private fun installOwnProton(): String? { - val extras = com.droiddeck.launcher.session.ProtonExtras - while ((extras.prefetching || extras.installInProgress) && !SessionState.stopRequested) { - try { Thread.sleep(250) } catch (_: InterruptedException) { Thread.currentThread().interrupt(); return "interrupted" } - } - if (SessionState.stopRequested) return "cancelled" - if (!com.droiddeck.launcher.runtime.DesktopCatalog.ownProtonMissing(this)) return null - val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested } - SessionState.installCancellation = cancellation - return try { - extras.install(this, extras.tools.first { it.id == extras.OWN }, cancellation) { label, percent -> - uiHandler.post { loading.percent = percent; loading.say(label, PROTON_LINES.topic, readable = true) } - }.also { if (it == null) com.droiddeck.launcher.session.Onboarding.recheck(this) } - } finally { - if (SessionState.installCancellation === cancellation) SessionState.installCancellation = null - } - } - override fun surfaceCreated(holder: SurfaceHolder) { if (holder !== outputHolder()) return if (installingRuntime || SessionState.stopRequested || ended) return @@ -2874,6 +3136,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val runtimeDir = File(filesDir, ".wayland-rt").apply { mkdirs() } FileUtils.copyAsset(this, "wayland/keymap.xkb", File(runtimeDir, "keymap.xkb")) com.droiddeck.launcher.input.VrControllers.publish(this) + com.droiddeck.launcher.session.QuestSteamVrLaunch.publish(this) val turnip = TurnipDriver(this) com.droiddeck.launcher.gpu.DriverSetupLog.write(this, "surface.driver-setup") @@ -2940,14 +3203,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val on = SessionState.hdrCapable && SessionPrefs.hdr(this, mode) SessionState.hdr = on WaylandCompositor.nativeSetHdrOutput(on) - WaylandCompositor.nativeSetZeroCopy(on || SessionPrefs.zeroCopy(this, mode)) + WaylandCompositor.nativeSetZeroCopy(on || SessionPrefs.zeroCopy(this, mode) && composedOutputFree()) Log.i(TAG, "hdr: " + (if (on) "on" else "off") + " for this $mode session") } com.droiddeck.launcher.gpu.DriverSetupLog.write(this, "compositor.start driver=$driverId") CompositorHost.startOrAttach( this, holder.surface, runtimeDir.path, driverId?.let { turnip.driverPath(it) }, driverId?.let { turnip.libraryName(it) }, - applicationInfo.nativeLibraryDir, size.first, size.second, refreshHz(holder), outputFpsLimit(), + applicationInfo.nativeLibraryDir, size.first, size.second, refreshHz(holder), compositorFpsLimit(), outputFpsLimit(), ) onOutputAttached(holder) if (SessionState.running && size != previous) { @@ -2965,6 +3228,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde intent.getStringArrayExtra(SessionService.EXTRA_PROGRAM_ARGS), intent.getStringExtra(SessionService.EXTRA_GAME_ID), sessionActivityDisplayId, + frontendSteamGame = intent.getBooleanExtra(SessionService.EXTRA_FRONTEND_STEAM_GAME, false), ) intent.getStringExtra(EXTRA_PLAYED_GAME)?.let { com.droiddeck.launcher.frontend.Library.recordPlayed(this, it) } } @@ -2989,6 +3253,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun windowOutputSize(width: Int, height: Int): Pair? { + if (com.droiddeck.launcher.session.xr.XrPanels.immersiveActive) { + val flat = immersiveFlatSize ?: SessionState.outputSize + return if (steamScreenShown()) vrOutputSize(flat) else flat + } if (width <= 0 || height <= 0 || isInPictureInPictureMode) return null if (bottomGame != null) return when { SessionState.followScreen -> @@ -3002,9 +3270,38 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde else if (glassesScreen == null) outputSize() else null } + /** These editors draw in this window, which the immersive view hides, so they open after leaving it. */ + private fun leaveImmersiveForDialog() { + if (com.droiddeck.launcher.session.xr.XrPanels.immersiveActive) com.droiddeck.launcher.session.xr.XrPanels.leaveImmersive() + } + + /** Steam's own screen is up with no game holding a window; with no focus report, a game may be running. */ + private fun steamScreenShown(): Boolean { + if (SessionState.mode != SessionService.MODE_STEAM) return false + val focus = com.droiddeck.launcher.agent.AgentGuest.focus(this) ?: return false + return com.droiddeck.launcher.session.xr.XrSteamScreen.shown( + focus.takeUnless { it.isNull("focusedApp") }?.optLong("focusedApp"), + focus.optJSONArray("focusableApps")?.let { list -> (0 until list.length()).map { list.optLong(it) } }, + ) + } + + /** + * SteamVR shows Steam's own screen as its floating Steam window, so in the headset that screen is drawn + * tall enough for the window to stay sharp. A flat game keeps the flat size, so the output keeps it + * while one is running. + */ + private fun vrOutputSize(flat: Pair): Pair { + if (flat.second >= VR_OUTPUT_HEIGHT) return flat + val width = (flat.first.toLong() * VR_OUTPUT_HEIGHT / flat.second.coerceAtLeast(1)).toInt() and 1.inv() + return width to VR_OUTPUT_HEIGHT + } + private fun resizeOutputForWindow(width: Int, height: Int) { + applyOutputSize(windowOutputSize(width, height) ?: return) + } + + private fun applyOutputSize(size: Pair) { if (!CompositorHost.isStarted) return - val size = windowOutputSize(width, height) ?: return if (size == SessionState.outputSize) return Log.i(TAG, "output resized: ${SessionState.outputSize.first}x${SessionState.outputSize.second} -> ${size.first}x${size.second}") SessionState.outputSize = size @@ -3013,7 +3310,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde WaylandCompositor.nativeResizeOutput(size.first, size.second) } - private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this) + private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this, SessionState.mode) private fun applyFollowChoice() { val scale = SessionState.followScales.let { if (followPortrait()) it.second else it.first } @@ -3022,12 +3319,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun applyFollowOrientation(config: android.content.res.Configuration) { - val wanted = SessionPrefs.windowOrientation(this, SessionState.followScreen, config.smallestScreenWidthDp) + val wanted = SessionPrefs.windowOrientation(this, SessionState.followScreen, config.smallestScreenWidthDp, SessionState.mode) if (requestedOrientation != wanted) requestedOrientation = wanted } override fun onConfigurationChanged(newConfig: android.content.res.Configuration) { super.onConfigurationChanged(newConfig) + if (!pipUi && !isInPictureInPictureMode) applySessionFullscreen(newConfig) + picturePosition = SessionPrefs.picturePosition(this, picturePortrait(newConfig)) if (refreshActivityDisplayId() && started) { SessionService.setActivityDisplay(this, sessionActivityDisplayId) } @@ -3085,13 +3384,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun displayMode(): String = SessionPrefs.displayMode(this, intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM, intent.getStringExtra(SessionService.EXTRA_PROGRAM)) - private fun portraitOutput(): Boolean = SessionPrefs.portrait(this) && !controlsBelowWanted() + private fun portraitOutput(): Boolean = SessionPrefs.portrait(this, SessionState.mode) && !controlsBelowWanted() private fun outputSize(): Pair = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this), resolutionChoice(), portraitOutput()) - private fun resolutionChoice(portrait: Boolean = SessionPrefs.portrait(this)): String { + private fun resolutionChoice(portrait: Boolean = SessionPrefs.portrait(this, SessionState.mode)): String { val mode = displayMode() val program = intent.getStringExtra(SessionService.EXTRA_PROGRAM) return if (intent.getStringExtra(SessionService.EXTRA_MODE) == SessionService.MODE_RUN && @@ -3138,6 +3437,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun outputFpsLimit(): Int = outputFpsLimit(pipUi) + // Android holds the window to the Game Mode override while the panel runs faster; the guest paces to the panel, + // so without this cap every frame past the override is drawn and dropped. + private fun hostFrameCap(): Int { + if (glassesScreen != null || bottomOutputActive) return 0 + val display = (if (Build.VERSION.SDK_INT >= 30) display else @Suppress("DEPRECATION") windowManager.defaultDisplay) ?: return 0 + return SessionPrefs.hostFrameCap(display.refreshRate, display.mode.refreshRate) + } + + private fun compositorFpsLimit(): Int = SessionPrefs.compositorFpsLimit( + mirrorRefreshLimit(), if (noSteamSession()) SessionState.fpsLimit else 0, pipUi, hostFrameCap(), + ) + private fun outputFpsLimit(pip: Boolean): Int = SessionPrefs.compositorFpsLimit(mirrorRefreshLimit(), if (noSteamSession()) SessionState.fpsLimit else 0, pip) @@ -3175,12 +3486,23 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde ) val hz = refreshHz() val changed = kotlin.math.abs(SessionState.refreshHz - hz) > 0.1f - CompositorHost.updatePacing(hz, outputFpsLimit()) + CompositorHost.updatePacing(hz, compositorFpsLimit(), outputFpsLimit()) pushCardboard(activeCardboard) if (changed && ::surfaceView.isInitialized) applyFrameGen() } } + private fun scheduleFrameGenInventoryRefresh() { + if (!frameGenInventoryRefreshScheduled.compareAndSet(false, true)) return + uiHandler.postDelayed({ + frameGenInventoryRefreshScheduled.set(false) + if (frameGenActivityActive && !isFinishing && !isDestroyed) { + frameGenInventoryRefreshDue = true + applyFrameGen() + } + }, 15_000L) + } + private fun frameGenModeForActiveGame(request: Int): FrameGen.Mode { if (SessionState.mode == SessionService.MODE_RUN) { val activeAppId = ( @@ -3194,7 +3516,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde .mapNotNull { it.profileKey.toLongOrNull() } .toSet() + if (frameGenInventoryRefreshDue) { + val focusedAppId = AgentGuest.focus(this)?.let { snapshot -> + snapshot.optLong("focusedApp").takeIf { snapshot.has("focusedApp") } + } + val stillKnown = synchronized(frameGenInventoryLock) { + frameGenInventoryRefreshDue = false + val known = frameGenInventoryIds + val keep = known != null && focusedAppId != null && + AgentGuest.focusedInstalledSteamAppId(focusedAppId, cachedIds + known) != null + if (!keep) { + frameGenInventoryIds = null + frameGenInventoryLastAttemptAt = 0L + } + keep + } + if (stillKnown) scheduleFrameGenInventoryRefresh() + } + var inventoryRevision = drawerGameInventoryRevision + var scannedNow = false var ids = synchronized(frameGenInventoryLock) { if (frameGenInventoryRevision != inventoryRevision) { frameGenInventoryIds = null @@ -3254,21 +3595,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde ids = cachedIds + currentIds frameGenInventoryIds = ids published = true + scannedNow = true } } if (published) { - if (frameGenInventoryRefreshScheduled.compareAndSet(false, true)) { - uiHandler.postDelayed({ - frameGenInventoryRefreshScheduled.set(false) - if (frameGenActivityActive && !isFinishing && !isDestroyed) { - synchronized(frameGenInventoryLock) { - frameGenInventoryIds = null - frameGenInventoryLastAttemptAt = 0L - } - applyFrameGen() - } - }, 15_000L) - } + scheduleFrameGenInventoryRefresh() if (frameGenRequests.get() != request) { applyFrameGen() } @@ -3286,7 +3617,24 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val activeAppId = AgentGuest.activeSteamAppId( this, cachedIds + (ids ?: emptySet()) ) - if (activeAppId == null) return FrameGen.Mode.OFF + if (activeAppId == null) { + val focusedAppId = AgentGuest.focus(this)?.optLong("focusedApp", 0L) ?: 0L + val rescan = !scannedNow && focusedAppId > 0 && synchronized(frameGenInventoryLock) { + val retained = frameGenInventoryIds + if (retained != null && focusedAppId !in retained && + focusedAppId != frameGenInventoryMissedAppId + ) { + frameGenInventoryMissedAppId = focusedAppId + frameGenInventoryIds = null + frameGenInventoryLastAttemptAt = 0L + true + } else { + false + } + } + if (rescan) uiHandler.post { if (!isFinishing && !isDestroyed) applyFrameGen() } + return FrameGen.Mode.OFF + } return FrameGen.mode(this, activeAppId.toString()) } @@ -3351,19 +3699,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde }, "lossless-sync").start() } - private fun importLossless(dll: File) { - Thread({ - val result = Lossless.import(this, dll) - val message = Lossless.message(this, result) - val state = Lossless.state(this) - runOnUiThread { - lossless = state - Toast.makeText(this, message, Toast.LENGTH_LONG).show() - applyFrameGen(force = result == Lossless.ImportResult.UPDATED) - } - }, "lossless-import").start() - } - private fun watchSession() { val handler = Handler(Looper.getMainLooper()) @@ -3399,6 +3734,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun onSessionEnded(status: Int) { ended = true + runOnUiThread { refreshAirTriggers() } ++steamVrRequestGeneration if (isInPictureInPictureMode) { runOnUiThread { finish() } @@ -3453,11 +3789,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde focusEndedScreen() } - private fun releasePads() { + private fun releasePads(keepBackTap: Boolean = false) { inputMotion.stop() physicalInputBindings?.release() + airTriggerInput?.release() com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this) - backQamInput.cancel() + backQamInput.cancel(keepTap = keepBackTap) padBridge?.releaseAll() joyConVr?.releaseButtons() } @@ -3532,7 +3869,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde presentationFaultHint()?.let { return it } if (log == null || !log.isFile) return null return try { - var enosys = 0 var fexMissing = false val size = log.length() val text = java.io.RandomAccessFile(log, "r").use { f -> @@ -3543,7 +3879,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde String(bytes, Charsets.ISO_8859_1) } text.lineSequence().forEach { line -> - if (line.contains("Function not implemented")) enosys++ if (line.contains(FEX_MISSING)) fexMissing = true } val steamSetup = com.droiddeck.launcher.session.SteamClientSetupFailure.find(text.lineSequence()) @@ -3565,9 +3900,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else if (fexMissing) { val what = com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_end_program) EndHint(getString(R.string.session_end_fex_missing, what), evenOnSuccess = true) - } else if (enosys >= 8) { - EndHint(resources.getQuantityString(R.plurals.session_hint_enosys, enosys, enosys, - getString(R.string.perf_title), getString(R.string.perf_seccomp), getString(R.string.perf_xalia))) } else null } catch (e: Exception) { null @@ -3575,16 +3907,23 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } - override fun dispatchKeyEvent(event: KeyEvent): Boolean { + internal fun dispatchImeKeyEvent(event: KeyEvent): Boolean = dispatchKeyEvent(event, orderedImeKey = true) + + override fun dispatchKeyEvent(event: KeyEvent): Boolean = dispatchKeyEvent(event, orderedImeKey = false) + + private fun dispatchKeyEvent(event: KeyEvent, orderedImeKey: Boolean): Boolean { val normalized = com.droiddeck.launcher.input.GuestKeys.normalizeKeyboardEscape(event) - if (normalized === event) return dispatchSessionKeyEvent(event) + if (normalized === event) return dispatchSessionKeyEvent(event, orderedImeKey) if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) { Log.i(TAG, "hardware Esc normalized from Back device=${event.deviceId} scan=${event.scanCode}") } - return dispatchSessionKeyEvent(normalized) + return dispatchSessionKeyEvent(normalized, orderedImeKey) } - private fun dispatchSessionKeyEvent(event: KeyEvent): Boolean { + private fun physicalInputAccepted() = resumed && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && + !inputSettingsOpen && !gestureSettingsOpen && !SessionState.suspended && !loading.visible + + private fun dispatchSessionKeyEvent(event: KeyEvent, orderedImeKey: Boolean): Boolean { if (com.droiddeck.launcher.ui.AgentPet.handleBack(this, event)) return true when (event.keyCode) { KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_MUTE -> { @@ -3603,10 +3942,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } if (penStream.holdsKey(event) || (penSettings.mode != SessionPrefs.PEN_TOUCH && PenStream.isPenKey(event))) return penStream.onKey(event) + if (airTriggerInput?.onKey(event) { physicalInputAccepted() && !pipUi && !appTextFocus } == true) return true if (appTextFocus) return super.dispatchKeyEvent(event) if (!pipUi) { - if (physicalInputBindings?.onKey(event, resumed && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && - !inputSettingsOpen && !gestureSettingsOpen && !SessionState.suspended && !loading.visible) == true) return true + if (physicalInputBindings?.onKey(event, physicalInputAccepted()) == true) return true if (physicalShortcuts.onKey( event, enabled = resumed && SessionState.running && !SessionState.suspended && @@ -3617,8 +3956,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde !pcKeyboardOpen && !achievementsOpen && !gestureSettingsOpen && !inputSettingsOpen, steam = SessionState.mode == SessionService.MODE_STEAM, ) { action -> - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() if (!dockedMenuIdle) drawerControllerActive = true Log.i(TAG, "physical shortcut ${action.name} device=${event.deviceId} key=${event.keyCode} scan=${event.scanCode}") when (action) { @@ -3650,18 +3988,25 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } if (mouseBackHandled) return true - val backToQam = !pipUi && !appTextFocus && !menuOwnsController && !pcKeyboardOpen && !achievementsOpen && + val backToQam = !pipUi && !appTextFocus && (!menuOwnsController || backQamInput.awaitingTap) && !pcKeyboardOpen && !achievementsOpen && !inputSettingsOpen && !gestureSettingsOpen && SessionState.mode == SessionService.MODE_STEAM && SessionState.running && SessionState.firstFrameSeen && !SessionState.suspended && padBridge?.canHoldQam() == true if (backQamInput.onKeyEvent(event, backToQam)) { - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() return true } if (pipUi) return true + if (event.keyCode == KeyEvent.KEYCODE_BACK && backTapOpenedDrawer && backTaps.pending) { + when { + event.action == KeyEvent.ACTION_DOWN -> backTaps.hold() + event.action == KeyEvent.ACTION_UP && !event.isCanceled -> backTaps.tap() + event.action == KeyEvent.ACTION_UP -> backTaps.cancel() + } + return true + } val pad = com.droiddeck.launcher.input.JoyCon.normalize(event) - if (pad !== event) return dispatchKeyEvent(pad) + if (pad !== event) return dispatchKeyEvent(pad, orderedImeKey) val fromController = PadBridge.isControllerKeyEvent(event) if (fromController && (menuOwnsController || pcKeyboardOpen || achievementsOpen || inputSettingsOpen || gestureSettingsOpen || SessionState.suspended)) { padBridge?.setInputEnabled(false) @@ -3703,7 +4048,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) { if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) { // The bumpers walk the tabs on the strip; a page kept inside More counts as the More tab. - val pages = sessionDrawerPages(glasses.present) + val pages = sessionDrawerPages(achievementsInFront != null) drawerPage = pages.strip().step(pages.tabFor(drawerPage), if (event.keyCode == KeyEvent.KEYCODE_BUTTON_R1) 1 else -1) releaseDrawerDirection() } @@ -3744,7 +4089,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val down = event.action == KeyEvent.ACTION_DOWN if (down && event.repeatCount > 0) return true val owner = if (event.deviceId <= 0) 16 else 8 - if (com.droiddeck.launcher.input.GuestKeys.send(event) { code, pressed -> sendGuestKey(code, pressed, owner) }) return true + if (com.droiddeck.launcher.input.GuestKeys.send(event) { code, pressed -> sendGuestKey(code, pressed, owner, orderedImeKey) }) return true } return super.dispatchKeyEvent(event) } @@ -3802,7 +4147,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else -> return super.dispatchGenericMotionEvent(event) } - if (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) && !drawerOpen) { + if ((event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) || + event.isFromSource(android.view.InputDevice.SOURCE_TOUCHPAD)) && !drawerOpen) { if (appUiOwnsPointer()) { if (super.dispatchGenericMotionEvent(event)) return true if (touchEditorOpen) return false @@ -3830,7 +4176,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde steamTouchControls?.let { takes(it, it::takesTouchAt) } == true || unfoldedPanel?.let { takes(it, it::takesTouchAt) } == true || unfoldedDeckSurface?.let { takes(it, it::takesTouchAt) } == true || - unfoldedColumn?.getChildAt(0)?.let { takes(it) { _, _ -> true } } == true + unfoldedKeys?.let { takes(it) { _, _ -> true } } == true } override fun dispatchTouchEvent(event: MotionEvent): Boolean { @@ -3956,6 +4302,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val presentation = secondScreenPresentation ?: return presentation.showMenu(false) if (secondScreenMode == SecondScreenMode.NONE) closeSecondScreen(reset = false) else updateKeyboardRoute() + if (gamePanelPending) uiHandler.post { restoreGamePanel(gestureGame) } } @@ -3985,7 +4332,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde steamSession = SessionState.mode == SessionService.MODE_STEAM, steamDesktopUi = SessionState.steamUi == "desktop", )) == com.droiddeck.launcher.input.TouchRouter.Route.TOUCHPAD - val mode = com.droiddeck.launcher.input.TouchGestureConfig.gamescopeRelativeMouse(wanted, mouseAttached(), touchpadRoute) + val mode = com.droiddeck.launcher.input.TouchGestureConfig.gamescopeRelativeMouse(wanted, pointerAttached(), touchpadRoute) if (appliedRelativeMouseMode == mode) return if (AgentGuest.setGamescopeConvar(this, "relative_mouse", mode)) appliedRelativeMouseMode = mode else if (relativeMouseRetries++ < RELATIVE_MOUSE_MAX_RETRIES) uiHandler.postDelayed({ requestRelativeMouse() }, 2_000) @@ -4116,6 +4463,27 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } + private val capturedTouchpadListener: PointerGestures.Listener = object : PointerGestures.Listener by pointerListener { + override fun onMove(x: Float, y: Float) { + val rect = drawnRect() ?: return + val scale = sceneScale(rect) + capturedTouchpad.place(CAPTURED_PAD_CENTRE, CAPTURED_PAD_CENTRE) + onRelativeMouse((x - CAPTURED_PAD_CENTRE) * scale, (y - CAPTURED_PAD_CENTRE) * scale) + } + override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) { + heldButtons.set(64, button, pressed) + } + override fun onThreeFingerTap(): Boolean = false + } + + private val capturedTouchpad: TouchpadGestures by lazy { + TouchpadGestures(PointerGestures.slop(this), capturedTouchpadListener, holdDrags = false).apply { + bounds = android.graphics.RectF(0f, 0f, CAPTURED_PAD_CENTRE * 2f, CAPTURED_PAD_CENTRE * 2f) + place(CAPTURED_PAD_CENTRE, CAPTURED_PAD_CENTRE) + } + } + private val capturedPadMatrix = android.graphics.Matrix() + private val scrollListener = object : ScrollTouchGestures.Listener { override fun onMove(x: Float, y: Float) { val rect = pointerSurfaceRect() ?: return @@ -4395,8 +4763,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (secondScreenMode == SecondScreenMode.DECK_CONTROLS && !SessionState.deckPad) selectSecondScreenMode(secondScreenMode) } - private fun openingPanel() = SecondScreenMode.opening(SessionPrefs.secondScreenPanel(this, desktopSession), SessionState.deckPad, - bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available()) + private fun openingPanel(): SecondScreenMode { + val saved = bottomGameKey()?.let { SessionPrefs.gameSecondScreenPanel(this, it) } + // A game's own panel counts as applied, so the next game without one returns to the global choice. + if (saved != null) gamePanelApplied = true + return SecondScreenMode.opening(saved ?: SessionPrefs.secondScreenPanel(this, desktopSession), SessionState.deckPad, + bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available(), SessionState.mode == SessionService.MODE_STEAM) + } private fun openingSurface() = openingPanel().takeIf { it != SecondScreenMode.MENU } ?: SecondScreenMode.KEYBOARD_TRACKPAD @@ -4422,9 +4795,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde typingReturnMode = null automaticPanel = false SessionPrefs.setSecondScreenPanel(this, desktopSession, SecondScreenMode.MENU.id) + bottomGameKey()?.let { SessionPrefs.setGameSecondScreenPanel(this, it, SecondScreenMode.MENU.id) } + gamePanelApplied = bottomGameKey() != null drawerOpen = true } + /** What bottom-screen memory is kept under: the game id in direct-run mode when there is one, else the focused game. */ + private fun bottomGameKey(): String? = + if (SessionState.mode == SessionService.MODE_RUN) SessionState.gameId?.takeIf { it.isNotBlank() }?.let { "game:$it" } ?: gestureGame + else gestureGame + private fun settleDualScreenControls() { if (!dualControlsProvisional || pipUi || !started || (::loading.isInitialized && loading.visible)) return dualControlsProvisional = false @@ -4542,10 +4922,36 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde typingReturnMode = null automaticPanel = false SessionState.bottomMenu = false - if (mode != SecondScreenMode.NONE) SessionPrefs.setSecondScreenPanel(this, desktopSession, mode.id) + if (mode != SecondScreenMode.NONE) { + SessionPrefs.setSecondScreenPanel(this, desktopSession, mode.id) + bottomGameKey()?.let { SessionPrefs.setGameSecondScreenPanel(this, it, mode.id) } + gamePanelApplied = bottomGameKey() != null + } selectSecondScreenMode(mode) } + private var gamePanelApplied = false + private var gamePanelPending = false + + private fun restoreGamePanel(game: String?) { + if (secondScreenMode == SecondScreenMode.NONE || pipUi) return + // The bottom menu or field keyboard is in the way; the panel is restored once it closes. + if (typingReturnMode != null || menuShownOnBottom()) { + gamePanelPending = true + return + } + gamePanelPending = false + val remembered = game?.let { bottomGameKey() }?.let { SessionPrefs.gameSecondScreenPanel(this, it) } + val wanted = when { + remembered != null -> SecondScreenMode.opening(remembered, SessionState.deckPad, bottomPages().isNotEmpty(), + com.droiddeck.launcher.session.BottomDesktop.available(), SessionState.mode == SessionService.MODE_STEAM) + gamePanelApplied -> openingPanel() + else -> return + } + gamePanelApplied = remembered != null + if (wanted != SecondScreenMode.MENU && wanted != secondScreenMode) selectSecondScreenMode(wanted) + } + private fun bottomScreenPicker(mode: SecondScreenMode) = com.droiddeck.launcher.ui.ScreenPicker( com.droiddeck.launcher.ui.secondScreenModes(false, SessionState.deckPad, bottomPages().isNotEmpty(), com.droiddeck.launcher.session.BottomDesktop.available()), @@ -4561,6 +4967,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onKeyboardClosed = ::bottomKeyboardClosed, onMenu = { drawerOpen = true }, picker = ::bottomScreenPicker, + panel = ::bottomPanel, onMenuTouched = { if (drawerPinned) { drawerPinned = false @@ -4597,7 +5004,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde BottomDashboard( bottomPages(), com.droiddeck.launcher.ui.SessionBottomTab.picked(SessionState.sessionId), gameStarts = gameStarts, - onPage = { com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) }, + gamePage = { bottomGameKey()?.let { SessionPrefs.gameBottomPage(this@SessionActivity, it) } }, + onPage = { + com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) + bottomGameKey()?.let { game -> SessionPrefs.setGameBottomPage(this@SessionActivity, game, it) } + }, strip = { pageId -> com.droiddeck.launcher.ui.SessionBottomStrip(pageId) { if (::hud.isInitialized) hud.liveFps else null } }, @@ -4606,11 +5017,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde }), ) - private fun bottomPages(): List = sessionBottomPages(BottomPageActions( + private fun bottomPages(): List = sessionBottomPages(bottomActions()) + + private fun bottomPanel(mode: SecondScreenMode): (@androidx.compose.runtime.Composable () -> Unit)? = + if (!mode.sessionPanel) null else ({ DroidDeckTheme { com.droiddeck.launcher.ui.BottomSessionPanel(mode, bottomActions()) } }) + + private fun bottomActions() = BottomPageActions( takeScreenshot = ::captureScreenshot, fps = { if (::hud.isInitialized) hud.liveFps else null }, runningGame = { gestureGame }, - )) + gameKey = ::bottomGameKey, + copyRegion = ::copyGameRegion, + sourceAspect = { gameSource()?.takeIf { it.width > 0 && it.height > 0 }?.let { it.width.toFloat() / it.height } ?: (16f / 9f) }, + holdComposed = ::holdComposedOutput, + maskRegion = ::maskGameRegion, + ) private fun captureScreenshot(onDone: (Boolean) -> Unit) = copyGameFrame { bitmap -> if (bitmap == null) { @@ -4659,6 +5080,46 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } } + private fun gameSource(): android.view.SurfaceView? = if (glassesOutputActive) glassesScreen?.surfaceView + else if (bottomOutputActive) bottomGame?.surfaceView else if (::surfaceView.isInitialized) surfaceView else null + + private fun copyGameRegion(region: android.graphics.RectF?, outWidth: Int, outHeight: Int, onFrame: (android.graphics.Bitmap?) -> Unit) { + val source = gameSource() + val width = source?.width ?: 0 + val height = source?.height ?: 0 + if (source == null || width <= 0 || height <= 0 || outWidth <= 0 || outHeight <= 0 || source.holder.surface?.isValid != true) { + onFrame(null) + return + } + val r = region ?: android.graphics.RectF(0f, 0f, 1f, 1f) + val src = android.graphics.Rect((r.left * width).toInt(), (r.top * height).toInt(), (r.right * width).toInt(), (r.bottom * height).toInt()) + if (src.width() <= 0 || src.height() <= 0) { + onFrame(null) + return + } + val bitmap = try { + android.graphics.Bitmap.createBitmap(outWidth, outHeight, android.graphics.Bitmap.Config.ARGB_8888) + } catch (_: OutOfMemoryError) { + onFrame(null) + return + } + withPictureFrame { done -> + try { + android.view.PixelCopy.request(source, src, bitmap, { result -> + done() + if (result == android.view.PixelCopy.SUCCESS) onFrame(bitmap) else { + bitmap.recycle() + onFrame(null) + } + }, uiHandler) + } catch (_: IllegalArgumentException) { + done() + bitmap.recycle() + onFrame(null) + } + } + } + /** PixelCopy reads the last queued buffer, which black frame insertion makes black every other refresh. */ private fun withPictureFrame(copy: (done: () -> Unit) -> Unit) { if (!CompositorHost.holdPicture()) return copy {} @@ -4709,6 +5170,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde || inputProfile.keys.any { it.action is InputAction.MouseButton } physicalInputBindings?.configure(inputProfile.keys) padBridge?.setInputProfile(inputProfile) + refreshAirTriggers() DeckControls.refresh() onScreenControls?.updateLayout(primaryInputLayout) bottomInputControls?.updateLayout(primaryInputLayout) @@ -4719,6 +5181,32 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde secondScreenPresentation?.refreshControls() } + private fun refreshAirTriggers() { + val input = airTriggerInput ?: return + val layout = primaryInputLayout + val layoutId = layout?.id.orEmpty() + val enabled = AirTriggerPrefs.enabled(this) + val chosen = AirTrigger.entries.associateWith { + AirTriggerSetup(AirTriggerButtons.resolve(layout, it, AirTriggerPrefs.button(this, layoutId, it)), + AirTriggerPrefs.action(this, layoutId, it), AirTriggerPrefs.rate(this, layoutId, it)) + } + val active = enabled && resumed && !ended && !SessionState.suspended + input.configure(if (active) chosen else emptyMap()) + if (active != airTriggersOpen) { + airTriggersOpen = active + if (active) RedMagicAirTriggers.open(this) else RedMagicAirTriggers.restore(this) + } + airTriggerMenu = com.droiddeck.launcher.ui.AirTriggerMenu(enabled, chosen.mapValues { it.value.element.id }, + AirTriggerButtons.options(layout).map { it.id to it.name }, AirTriggerPrefs.vibration(this), AirTriggerPrefs.screenLight(this), + AirTriggerPrefs.led(this), chosen.mapValues { it.value.action }, chosen.mapValues { it.value.rate }) + } + + private fun airTriggerTouched(trigger: AirTrigger, down: Boolean) { + RedMagicAirTriggers.light(if (down) trigger.pressLight else trigger.releaseLight) + if (down && AirTriggerPrefs.vibration(this)) com.droiddeck.launcher.ui.ControllerHaptics.click(this) + airTriggerGlow?.show(trigger, down && AirTriggerPrefs.screenLight(this)) + } + private fun tapQam() { if (SessionState.mode == SessionService.MODE_STEAM) padBridge?.triggerQam() } @@ -4743,6 +5231,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun refreshControls() { + padConnected = controllerConnected() applyUnfoldedControls() updateOnScreenControls() } @@ -4758,12 +5247,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val width = rootContentWidth() val height = rootContentHeight() val wanted = controlsBelowWanted() - val tabRow = unfoldedColumn?.getChildAt(0)?.height?.let { - it - (com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt() - } ?: 0 val outputAspect = if (!wanted || SessionState.followScreen) 0f else outputSize().let { it.first.toFloat() / it.second.coerceAtLeast(1) } - val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow, outputAspect) + val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, aspect = outputAspect) else FrameLayout.LayoutParams.MATCH_PARENT val params = surfaceView.layoutParams as FrameLayout.LayoutParams if (params.height != gameHeight) { @@ -4780,6 +5266,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (panel != null && (!wanted || panel.dock != dock)) { sessionRoot.removeView(unfoldedColumn) unfoldedColumn = null + unfoldedKeys = null unfoldedDeckSurface = null unfoldedDeckPanel = null unfoldedPanel = null @@ -4790,14 +5277,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (panel == null) { panel = OnScreenControls(this, padBridge, dock).also { it.updateLayout(primaryInputLayout) } val column = android.widget.LinearLayout(this).apply { + alpha = onScreenOpacityAlpha() orientation = android.widget.LinearLayout.VERTICAL - addView(unfoldedBar().apply { - addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom -> - if (bottom - top != oldBottom - oldTop) post { applyUnfoldedControls() } - } - }, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, - android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)) addView(panel, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)) + unfoldedKeys = com.droiddeck.launcher.ui.padKeysView( + this@SessionActivity, SessionState.mode == SessionService.MODE_STEAM, + { releasePads(); drawerOpen = true }, ::tapSteamButton, ::tapQam, + ).also { + addView(it, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, + android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)) + } } sessionRoot.addView(column, sessionRoot.indexOfChild(surfaceView) + 1) unfoldedColumn = column @@ -4808,13 +5297,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde unfoldedColumn?.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, height - gameHeight, Gravity.BOTTOM) } - private fun unfoldedBar(): View = com.droiddeck.launcher.ui.bottomScreenBarView(this) { - val deck = unfoldedDeckPanel - com.droiddeck.launcher.ui.sessionBarModel(getString(if (deck != null) R.string.second_mode_deck_controls else R.string.deck_tab_gamepad), - { chooseUnfoldedControls(false) }, { drawerOpen = true }, ::tapSteamButton, ::tapQam, - tabs = deck?.let { com.droiddeck.launcher.ui.deckPanelTabs(this, it, ::selectDeckPanel) }) - } - private fun showUnfoldedDeckPanel() { val column = unfoldedColumn val panel = unfoldedPanel @@ -4830,7 +5312,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde panel.visibility = View.GONE unfoldedDeckSurface = com.droiddeck.launcher.ui.InputSurfaceView(this, padBridge, layout.elements, InputRole.PRIMARY, layout.style, haptics = true).also { it.tag = layout - column.addView(it, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)) + column.addView(it, column.indexOfChild(panel) + 1, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)) } } @@ -4921,27 +5403,19 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else { endGameField() } - host.type(text) - host.tap(KeyEvent.KEYCODE_ENTER) + if (text.isEmpty()) host.tap(KeyEvent.KEYCODE_ENTER) + else WaylandCompositor.textInputCommitAndSubmit(text) uiHandler.postDelayed({ if (AgentGuest.gameTextField && com.droiddeck.launcher.ui.WowChat.isWow(AgentGuest.gameProgram)) endGameField() }, FIELD_SETTLE_MS) } private fun endGameField() { - WaylandCompositor.nativeSendKey(KEY_END, 1) - WaylandCompositor.nativeSendKey(KEY_END, 0) + orderedImeKeySender(KEY_END, true) + orderedImeKeySender(KEY_END, false) } - private fun selectGameField(vararg then: Int) { - heldKeys.set(256, KEY_LEFTCTRL, true) - try { - for (key in intArrayOf(KEY_A) + then) { - heldKeys.set(256, key, true) - heldKeys.set(256, key, false) - } - } finally { heldKeys.release(256) } - } + private fun selectGameField(copy: Boolean = false) { WaylandCompositor.nativeSelectGameField(copy) } private fun readGameField(done: (String?) -> Unit) { val opened = wowChat.request @@ -4950,7 +5424,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (text != null && stillOpen()) endGameField() done(text) } - selectGameField(KEY_C) + selectGameField(copy = true) } private fun cancelWowChat() { @@ -4961,7 +5435,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde com.droiddeck.launcher.ui.SessionTyping.returnFocus(this, taskId) val mode = typingReturnMode ?: return typingReturnMode = null - uiHandler.post { if (secondScreenMode == SecondScreenMode.KEYBOARD_TRACKPAD) selectSecondScreenMode(mode) } + uiHandler.post { + if (secondScreenMode == SecondScreenMode.KEYBOARD_TRACKPAD) selectSecondScreenMode(mode) + if (gamePanelPending) restoreGamePanel(gestureGame) + } } private fun updateKeyboardRoute() { @@ -5186,17 +5663,28 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var sessionTouchDown = false private var screenTapsClick = true - private fun onScreenLeftMouseButtonShown(): Boolean = listOfNotNull( + private fun inputSurfaces() = listOfNotNull( onScreenControls?.inputSurface, bottomInputControls?.inputSurface, unfoldedPanel?.inputSurface, unfoldedDeckSurface, secondScreenPresentation?.controlsView, swappedInputSurface, - ).any { it.isShown && inputProfile.showsLeftMouseButton(it.inputRole, it.shownElements, stockInputProfile) } + ) + + private fun onScreenLeftMouseButtonShown(): Boolean = + inputSurfaces().any { it.isShown && inputProfile.showsLeftMouseButton(it.inputRole, it.shownElements, stockInputProfile) } + + private fun holdOnScreen(elementId: String, trigger: AirTrigger, held: Boolean, cancelled: Boolean): Boolean { + val surfaces = inputSurfaces().filter { it.inputRole == InputRole.PRIMARY } + if (held) return surfaces.any { it.isShown && it.hold(elementId, trigger.ordinal, true) } + surfaces.forEach { it.hold(elementId, trigger.ordinal, false, cancelled) } + return true + } override fun onTouchEvent(event: MotionEvent): Boolean = inSurfaceSpace(event) { handleTouch(event) } private fun handleTouch(event: MotionEvent): Boolean { val pen = PenStream.penIndex(event) val penRouted = if (pen >= 0) routePen(event, pen).takeIf { it != PenRouter.Route.TOUCH } else null - if (penRouted == null && event.isFromSource(android.view.InputDevice.SOURCE_MOUSE)) return onMouse(event) + if (penRouted == null && (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) || + event.isFromSource(android.view.InputDevice.SOURCE_TOUCHPAD))) return onMouse(event) when (event.actionMasked) { MotionEvent.ACTION_DOWN -> { sessionTouchDown = true @@ -5442,7 +5930,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun isHardwareMouse(d: InputDevice?): Boolean = d != null && !d.isVirtual && !d.supportsSource(InputDevice.SOURCE_STYLUS) && - (d.supportsSource(InputDevice.SOURCE_MOUSE) || d.supportsSource(InputDevice.SOURCE_MOUSE_RELATIVE)) + (d.supportsSource(InputDevice.SOURCE_MOUSE) || d.supportsSource(InputDevice.SOURCE_MOUSE_RELATIVE) || + d.supportsSource(InputDevice.SOURCE_TOUCHPAD)) + + private fun isTouchpad(d: InputDevice?): Boolean = + d?.supportsSource(InputDevice.SOURCE_TOUCHPAD) == true /** Android also sends the Back and Forward buttons as key events, so they are handled as keys. */ private fun guestMouseButton(actionButton: Int): Int? = when (actionButton) { @@ -5452,9 +5944,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde else -> PointerGestures.BTN_LEFT } + private fun pointerAttached(): Boolean = usbMouse.active || InputDevice.getDeviceIds().any { id -> + isHardwareMouse(InputDevice.getDevice(id)) + } + private fun mouseAttached(): Boolean = usbMouse.active || InputDevice.getDeviceIds().any { id -> val d = InputDevice.getDevice(id) - isHardwareMouse(d) && d?.supportsSource(InputDevice.SOURCE_TOUCHPAD) != true + isHardwareMouse(d) && !isTouchpad(d) } private fun externalMouseAttached(): Boolean { @@ -5472,7 +5968,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun updatePointerCapture() { if (!::surfaceView.isInitialized) return val view = window.decorView - val want = (pointerLocked || relativeMouseAttached()) && sessionOwnsInput() && hasWindowFocus() && mouseAttached() + val want = (pointerLocked || relativeMouseAttached()) && sessionOwnsInput() && hasWindowFocus() && pointerAttached() releaseDesktopMouseGrab() updateUsbMouse(want) if (want == view.hasPointerCapture()) return @@ -5525,7 +6021,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun dropMouseCursor() { - if (!mouseOwnsCursor || mouseAttached()) return + if (!mouseOwnsCursor || pointerAttached()) return mouseOwnsCursor = false uiHandler.removeCallbacks(cursorResync) cursorVisible = false @@ -5576,20 +6072,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } private fun onCapturedPointer(event: MotionEvent): Boolean { - if (!event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) return false + if (!com.droiddeck.launcher.input.PointerCapture.accepts(event)) return false notePress(event) + val pad = com.droiddeck.launcher.input.PointerCapture.isTouchpad(event) + when (event.actionMasked) { + MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE -> { + if (pad && event.actionMasked == MotionEvent.ACTION_BUTTON_PRESS) capturedTouchpad.buttonPressed() + guestMouseButton(event.actionButton)?.let { heldButtons.set(8, it, event.actionMasked == MotionEvent.ACTION_BUTTON_PRESS) } + } + else -> if (pad) return onCapturedTouchpad(event) + } when (event.actionMasked) { MotionEvent.ACTION_MOVE -> { - var dx = event.x - var dy = event.y - for (i in 0 until event.historySize) { - dx += event.getHistoricalX(i) - dy += event.getHistoricalY(i) - } - onRelativeMouse(dx, dy) + val delta = com.droiddeck.launcher.input.PointerCapture.delta(event) + onRelativeMouse(delta[0], delta[1]) } - MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE -> - guestMouseButton(event.actionButton)?.let { heldButtons.set(8, it, event.actionMasked == MotionEvent.ACTION_BUTTON_PRESS) } + MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE -> {} MotionEvent.ACTION_SCROLL -> { val v = event.getAxisValue(MotionEvent.AXIS_VSCROLL) if (v != 0f) sendSceneWheel(-Math.round(v)) @@ -5600,6 +6098,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde return true } + private fun onCapturedTouchpad(event: MotionEvent): Boolean { + if (event.actionMasked == MotionEvent.ACTION_DOWN) { + val metrics = resources.displayMetrics + val scale = com.droiddeck.launcher.input.PointerCapture.touchpadScale(event, metrics.xdpi / 25.4f, metrics.widthPixels) + capturedPadMatrix.setScale(scale, scale) + capturedTouchpad.desktop = SessionState.mode == SessionService.MODE_DESKTOP + if (::touchpad.isInitialized) capturedTouchpad.sensitivity = touchpad.sensitivity + } + val scaled = MotionEvent.obtain(event) + scaled.transform(capturedPadMatrix) + val handled = capturedTouchpad.onTouch(scaled) + scaled.recycle() + return handled + } + private fun logInputDevice(what: String, deviceId: Int) { val d = InputDevice.getDevice(deviceId) ?: return if (!PadBridge.isFromController(d)) return @@ -5620,7 +6133,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde val view = com.droiddeck.launcher.input.SteamTouchControls(this, device, onMenu = { drawerOpen = true }, onKeyboard = ::togglePcKeyboard) view.visibility = View.GONE - view.onEditingChanged = { touchEditorChanged() } + view.alpha = onScreenOpacityAlpha() + view.onEditingChanged = { editing -> + view.alpha = if (editing) 1f else onScreenOpacityAlpha() + touchEditorChanged() + } view.onOptions = { options -> steamTouchOptions = options applyTouchRouting() @@ -5725,6 +6242,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (bottom?.parent !== bottomRoot) { (bottom?.parent as? android.view.ViewGroup)?.removeView(bottom) bottom = OnScreenControls(bottomRoot.context, padBridge).also { view -> + view.alpha = onScreenOpacityAlpha() view.onTouchMiss = { event -> onBottomGameTouch(event) } bottomRoot.addView(view, android.view.ViewGroup.LayoutParams(-1, -1)) } @@ -5824,11 +6342,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde releaseHeldKeys() } - private fun sendGuestKey(key: Int, down: Boolean, owner: Int = 1) { + private fun sendGuestKey(key: Int, down: Boolean, owner: Int = 1, orderedImeKey: Boolean = false) { if (down && pipUi) return val code = if (key == KEY_RIGHTCTRL && SessionState.mode == SessionService.MODE_DESKTOP) KEY_LEFTCTRL else key if (owner == 1) { if (down) guestKeysDown.add(code) else guestKeysDown.remove(code) } - heldKeys.set(owner, code, down) + val orderedSender = if (orderedImeKey) orderedImeKeySender else null + heldKeys.set(owner, code, down, orderedSender) + } + + private val orderedImeKeySender: (Int, Boolean) -> Unit = { code, down -> + WaylandCompositor.nativeSendKeyOrdered(code, if (down) 1 else 0) } private fun capturePausedFrame(manual: Boolean = false, onDone: () -> Unit = {}) { @@ -5892,7 +6415,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (zeroCopyActive()) { WaylandCompositor.nativeSetZeroCopy(false) val restore = java.util.concurrent.atomic.AtomicBoolean(false) - val back = { if (restore.compareAndSet(false, true)) WaylandCompositor.nativeSetZeroCopy(true) } + pauseCaptures++ + val back = { + if (restore.compareAndSet(false, true)) { + pauseCaptures-- + if (!isDestroyed && zeroCopyActive()) WaylandCompositor.nativeSetZeroCopy(composedOutputFree()) + } + } uiHandler.postDelayed({ capturePausedFrame(manual = true, onDone = back) }, ZERO_COPY_SETTLE_MS) uiHandler.postDelayed({ back() }, ZERO_COPY_RESTORE_MS) } else { @@ -5901,6 +6430,58 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde SessionService.pause(this) } + private var composedHolds = 0 + private var pauseCaptures = 0 + + private fun composedOutputFree() = composedHolds == 0 && pauseCaptures == 0 + private var mirrorMask: android.view.View? = null + private var maskedRegion: android.graphics.RectF? = null + private var maskDim = false + private val maskLayout = android.view.View.OnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> placeMirrorMask() } + + private fun maskGameRegion(region: android.graphics.RectF?, dim: Boolean) { + maskedRegion = region + maskDim = dim + if (region != null && mirrorMask == null && ::sessionRoot.isInitialized && ::surfaceView.isInitialized) { + val mask = android.view.View(this).apply { + isClickable = false + isFocusable = false + importantForAccessibility = android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO + } + sessionRoot.addView(mask, sessionRoot.indexOfChild(surfaceView) + 1, FrameLayout.LayoutParams(0, 0)) + surfaceView.addOnLayoutChangeListener(maskLayout) + mirrorMask = mask + } + placeMirrorMask() + } + + private fun placeMirrorMask() { + val mask = mirrorMask ?: return + val r = maskedRegion + if (r == null || glassesOutputActive || bottomOutputActive || surfaceView.width <= 0) { + mask.visibility = android.view.View.GONE + return + } + mask.setBackgroundColor(if (maskDim) 0xB3000000.toInt() else android.graphics.Color.BLACK) + val w = surfaceView.width + val h = surfaceView.height + mask.layoutParams = FrameLayout.LayoutParams(((r.right - r.left) * w).toInt(), ((r.bottom - r.top) * h).toInt(), Gravity.TOP or Gravity.START).apply { + leftMargin = surfaceView.left - sessionRoot.paddingLeft + (r.left * w).toInt() + topMargin = surfaceView.top - sessionRoot.paddingTop + (r.top * h).toInt() + } + mask.visibility = android.view.View.VISIBLE + } + + private fun holdComposedOutput(hold: Boolean) { + val wasHeld = composedHolds > 0 + composedHolds = (composedHolds + if (hold) 1 else -1).coerceAtLeast(0) + val held = composedHolds > 0 + if (held == wasHeld) return + WaylandCompositor.nativeSetMirrorCapture(held) + // Importable HDR is redirected by the compositor hold. Keep its layer-only fallback available. + if (zeroCopyActive()) WaylandCompositor.nativeSetZeroCopy(composedOutputFree()) + } + private fun zeroCopyActive(): Boolean = CompositorHost.isStarted && !SessionState.hdr && SessionPrefs.zeroCopy(this, SessionState.mode) @@ -5943,8 +6524,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde drawerOpen = false pcKeyboardOpen = false achievementsOpen = false - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() releaseDrawerDirection() onScreenControls?.releaseAll() bottomInputControls?.releaseAll() @@ -5959,6 +6539,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde heldButtons.clear() hidePrimaryKeyboard() sessionClipboard.stop() + sessionTextInput.stop() padMotion?.stop() cursorVisible = false closeSecondScreen(reset = false) @@ -5974,7 +6555,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else if (!isFinishing && !isDestroyed) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) updateOnScreenControls() - if (resumed) { sessionClipboard.start(); updatePadMotion() } + if (resumed) { sessionClipboard.start(); sessionTextInput.start(); updatePadMotion() } if (started) { settleDualScreenControls() refreshSecondScreenDisplays() @@ -6044,7 +6625,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde displayManager.unregisterDisplayListener(displayListener) com.droiddeck.launcher.input.DualScreen.unwatchTaken(bottomScreenListener) contentResolver.unregisterContentObserver(refreshSettingObserver) - if (!screenIsOff()) closeSecondScreen(reset = false) + // Closing the presentation removes the docked Agent page and unregisters its picker. + if (com.droiddeck.launcher.session.SessionVisibilityPolicy.shouldCloseSecondScreenOnStop( + screenOff = screenIsOff(), + dockedDrawerOpen = menuShownOnBottom(), + attachmentPickerOpen = com.droiddeck.launcher.agent.AgentAttachments.picking, + ) + ) closeSecondScreen(reset = false) + sessionTextInput.stop() startedScreens = (startedScreens - 1).coerceAtLeast(0) updateGlassesScreen() updateBottomGame() @@ -6080,6 +6668,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde override fun onResume() { super.onResume() + com.droiddeck.launcher.agent.AgentAttachments.picking = false drawerGameInventoryRevision++ com.droiddeck.launcher.input.SystemKeyCapture.attach(this, { hasWindowFocus() && !appUiOwnsPointer() && CompositorHost.isStarted }) { event -> com.droiddeck.launcher.input.GuestKeys.send(event) { code, down -> sendGuestKey(code, down, 8) } @@ -6089,7 +6678,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } if (CompositorHost.isStarted) applyFrameGen(force = true) applyFollowOrientation(resources.configuration) + uiHandler.removeCallbacks(questSteamVrRequest) + if (com.droiddeck.launcher.session.QuestExperimental.isSupported()) uiHandler.post(questSteamVrRequest) if (runtimeRemovalBlocked) return + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + if (!pipUi && !isInPictureInPictureMode) applySessionFullscreen() if (!SessionState.suspended) pausedFrame = null com.droiddeck.launcher.ui.Motion.refresh(this) refreshHomeApp() @@ -6100,13 +6693,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } (getSystemService(INPUT_SERVICE) as? InputManager) ?.registerInputDeviceListener(deviceListener, Handler(Looper.getMainLooper())) + padConnected = controllerConnected() padBridge?.setStickDeadZone(ControllerPrefs.deadZone(this)) refreshSecondScreenDisplays() if (SessionState.guestPid > 1) padBridge?.syncConnectedControllers() joyConVr?.refresh() onScreenControls?.reload() controllerSettings = ControllerPrefs.read(this) + applyOnScreenOpacity() resumed = true + boostGpuClock(panelOverGame) updateKeyboardRoute() retryFieldKeyboard(hasWindowFocus()) updateDesktopKeyboardButton() @@ -6120,7 +6716,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onCancel = { padBridge?.cancelHomeGuide() }, ) updatePointerCapture() - if (!pipUi) sessionClipboard.start() + if (!pipUi) { sessionClipboard.start(); sessionTextInput.start() } updatePadMotion() ControllerPrefs.prefs(this).registerOnSharedPreferenceChangeListener(shortcutPrefListener) SessionPrefs.sessionPrefs(this).registerOnSharedPreferenceChangeListener(screenEffectsProfilePrefListener) @@ -6147,16 +6743,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } override fun onPause() { + uiHandler.removeCallbacks(questSteamVrRequest) departureCleanup() super.onPause() } + private val questSteamVrRequest = object : Runnable { + override fun run() { + if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) && + SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start") + uiHandler.postDelayed(this, 1000) + } + } + private fun departureCleanup() { com.droiddeck.launcher.input.SystemKeyCapture.detach(this) com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this) if (runtimeRemovalBlocked) return physicalShortcuts.clear() backQamInput.cancel() + backTaps.cancel() mouseBackInput.cancel() capturePausedFrame() padBridge?.setInputEnabled(false) @@ -6178,7 +6784,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde heldButtons.clear() if (!screenOff) { val menuUp = menuShownOnBottom() - drawerOpen = false + if (!com.droiddeck.launcher.agent.AgentAttachments.picking) drawerOpen = false if (menuUp) SessionState.bottomMenu = true pcKeyboardOpen = false achievementsOpen = false @@ -6190,6 +6796,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (::scrollTouch.isInitialized) scrollTouch.cancel() if (::padMouse.isInitialized) padMouse.reset() resumed = false + refreshAirTriggers() + boostGpuClock(false) updateKeyboardRoute() updatePointerCapture() updatePadMotion() @@ -6602,7 +7210,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde androidx.compose.runtime.key(profileLayout) { androidx.compose.ui.viewinterop.AndroidView( factory = { context -> com.droiddeck.launcher.ui.InputSurfaceView(context, padBridge, profileLayout?.elements.orEmpty(), - surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()).also { swappedInputSurface = it } }, + surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()).also { + it.alpha = onScreenOpacityAlpha() + swappedInputSurface = it + } }, modifier = Modifier.fillMaxWidth().weight(1f), onRelease = { if (swappedInputSurface === it) swappedInputSurface = null }, ) @@ -6618,11 +7229,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde modifier = Modifier.fillMaxWidth().weight(1f), ) } + secondScreenMode.sessionPanel -> androidx.compose.foundation.layout.Column(Modifier.fillMaxSize()) { + com.droiddeck.launcher.ui.BottomScreenBar(bar(getString(secondScreenMode.label))) + androidx.compose.foundation.layout.Box(Modifier.fillMaxWidth().weight(1f)) { + com.droiddeck.launcher.ui.BottomSessionPanel(secondScreenMode, bottomActions()) + } + } pages.isEmpty() -> com.droiddeck.launcher.ui.BottomScreenBar(bar(null)) else -> BottomDashboard( pages, com.droiddeck.launcher.ui.SessionBottomTab.picked(SessionState.sessionId), gameStarts = gameStarts, - onPage = { com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) }, + gamePage = { bottomGameKey()?.let { SessionPrefs.gameBottomPage(this@SessionActivity, it) } }, + onPage = { + com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) + bottomGameKey()?.let { game -> SessionPrefs.setGameBottomPage(this@SessionActivity, game, it) } + }, bar = bar(getString(R.string.second_mode_dashboard)), strip = { pageId -> com.droiddeck.launcher.ui.SessionBottomStrip(pageId) { if (::hud.isInitialized) hud.liveFps else null } @@ -6762,18 +7383,20 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde super.onWindowFocusChanged(hasFocus) if (!hasFocus) com.droiddeck.launcher.input.HomeButtonShortcuts.cancel(this) if (!hasFocus) backQamInput.cancel() + if (!hasFocus) backTaps.cancel() if (!hasFocus) mouseBackInput.cancel() if (!hasFocus && ::padMouse.isInitialized) padMouse.reset() if (runtimeRemovalBlocked) return if (!hasFocus) { - if (::touchscreenGestures.isInitialized) touchscreenGestures.cancel() - if (::touchpad.isInitialized) touchpad.cancel() - if (::scrollTouch.isInitialized) scrollTouch.cancel() + cancelTouchGestures() releaseHeldGuestInput() + airTriggerInput?.release() } + // Game Space clears the distribute state when the launcher or Game Space itself comes to the front. + if (hasFocus && airTriggersOpen) RedMagicAirTriggers.open(this) if (hasFocus && !pipUi) { retryFieldKeyboard(true) - goFullscreen() + applySessionFullscreen() refreshClipboard() } updatePointerCapture() @@ -6783,19 +7406,24 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (resumed) sessionClipboard.refresh() } - private fun goFullscreen() { + private fun applySessionFullscreen(config: android.content.res.Configuration = resources.configuration) { + val fullscreen = sessionFullscreenMode.hidesSystemBars(config.orientation) + if (fullscreen) window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) + else window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) @Suppress("DEPRECATION") - window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + window.decorView.systemUiVisibility = if (fullscreen) (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) else View.SYSTEM_UI_FLAG_LAYOUT_STABLE if (Build.VERSION.SDK_INT >= 28) { window.attributes = window.attributes.apply { - layoutInDisplayCutoutMode = if (Build.VERSION.SDK_INT >= 30) - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS - else WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + layoutInDisplayCutoutMode = when { + !fullscreen -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT + Build.VERSION.SDK_INT >= 30 -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS + else -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + } } } } @@ -6817,6 +7445,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } override fun onDestroy() { + com.droiddeck.launcher.session.xr.XrPanels.clearMenuHost(this) + if (drawerXr) com.droiddeck.launcher.session.xr.XrPanels.hideMenu() uiHandler.removeCallbacks(panelHeldCheck) uiHandler.removeCallbacks(panelHeldRetry) synchronized(frameGenGlobalLock) { @@ -6829,6 +7459,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde gamescopeConvarRequests.shutdownNow() backQamInput.cancel() steamVrRecovery.close() + sessionTextInput.stop() uiHandler.removeCallbacks(steamTouchRetry) uiHandler.removeCallbacks(cursorResync) uiHandler.removeCallbacks(usbMouseFallback) @@ -6837,8 +7468,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (runtimeRemovalBlocked) { super.onDestroy(); return } watching = false releaseDrawerDirection() - pendingBackAction?.let(uiHandler::removeCallbacks) - pendingBackAction = null + backTaps.cancel() if (::pip.isInitialized) pip.destroyed() closeSecondScreen(reset = false) glassesScope.cancel() @@ -6856,6 +7486,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde inputMotion.stop() padBridge?.setInputEnabled(false) physicalInputBindings?.close() + airTriggerInput?.close() + airTriggerInput = null + if (airTriggersOpen) RedMagicAirTriggers.restore(this) padBridge?.stop() DeckControls.clearRouter(inputRouter) inputRouter = null @@ -6942,6 +7575,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde const val EXTRA_RETURN_HOME = "returnHome" private const val BLUETOOTH_CONNECT = "android.permission.BLUETOOTH_CONNECT" private const val REQUEST_BLUETOOTH = 31 + private const val VR_OUTPUT_HEIGHT = 1080 const val EXTRA_LINK_TASK = "linkTask" const val EXTRA_STEAMVR = "steamVr" const val EXTRA_PLAYED_GAME = "com.droiddeck.launcher.PLAYED_GAME" @@ -6970,6 +7604,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private const val PAD_SCROLL_POINTER_X = 0.985f private const val PAD_SCROLL_HEIGHTS_PER_S = 3f private const val AXIS_UNITS_PER_PIXEL = 3f + private const val CAPTURED_PAD_CENTRE = 1_000_000f private const val KEY_LEFTCTRL = 29 private const val KEY_RIGHTCTRL = 97 private const val KEY_A = 30 diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt index 2113161467..9c4659a550 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt @@ -23,7 +23,7 @@ object AgentAccess { fun requireCommands(context: Context) { if (!commandsAllowed(context)) throw AgentException( "AGENT_COMMANDS_DISABLED", - "Debugging tools are off: turn on Setup > Developer > Debugging tools on the device", + "droiddeckctl is off: turn on Setup > Developer > droiddeckctl on the device", ) } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentAttachments.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentAttachments.kt index b4f9a09dff..9c9dd5c150 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentAttachments.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentAttachments.kt @@ -19,6 +19,15 @@ object AgentAttachments { /** Guest paths waiting to go with the next message. */ val pending = mutableStateListOf() + /** True while the file picker is open over a session: it answers the drawer's agent page, so the drawer must stay. */ + @Volatile var picking = false + + /** Launches a system screen that answers the agent page, keeping the drawer for it; the result callback clears [picking]. */ + fun pick(launch: () -> Unit) { + picking = true + if (runCatching(launch).isFailure) picking = false + } + private const val NEW = "new" private const val GUEST_DIR = "/root/.cache/droiddeck/attachments" private val IMAGE = setOf("png", "jpg", "jpeg", "webp", "gif", "bmp") @@ -35,14 +44,17 @@ object AgentAttachments { val folder = chat ?: NEW val dir = File(hostDir(app), folder).apply { mkdirs() } return uris.mapNotNull { uri -> + var target: File? = null runCatching { val name = displayName(app, uri).replace(Regex("[^A-Za-z0-9._-]"), "_").ifEmpty { "file" } - var target = File(dir, name) + var candidate = File(dir, name) var n = 1 - while (target.exists()) target = File(dir, "${name.substringBeforeLast('.')}-${n++}${name.substringAfterLast('.', "").let { if (it.isEmpty()) "" else ".$it" }}") - app.contentResolver.openInputStream(uri)!!.use { input -> target.outputStream().use { input.copyTo(it) } } - "$GUEST_DIR/$folder/${target.name}" - }.getOrNull() + // Created atomically, so copies running side by side never pick the same name. + while (!candidate.createNewFile()) candidate = File(dir, "${name.substringBeforeLast('.')}-${n++}${name.substringAfterLast('.', "").let { if (it.isEmpty()) "" else ".$it" }}") + target = candidate + app.contentResolver.openInputStream(uri)!!.use { input -> candidate.outputStream().use { input.copyTo(it) } } + "$GUEST_DIR/$folder/${candidate.name}" + }.onFailure { target?.delete() }.getOrNull() } } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentChatActivity.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentChatActivity.kt new file mode 100644 index 0000000000..02f1a84e86 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentChatActivity.kt @@ -0,0 +1,48 @@ +package com.droiddeck.launcher.agent + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.core.AppUiPrefs +import com.droiddeck.launcher.ui.AgentPage +import com.droiddeck.launcher.ui.DroidDeckTheme + +/** + * The agent's chat in a window of its own, for Quest's flat mode: opened in its own task, it is a + * separate Horizon panel the user can move, resize and close like any other. + */ +class AgentChatActivity : ComponentActivity() { + override fun attachBaseContext(newBase: Context) { + super.attachBaseContext(newBase) + com.droiddeck.launcher.core.AppLanguage.applyTo(this, newBase) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + DroidDeckTheme(appScale = AppUiPrefs.scale(this)) { + AgentPage( + Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background).padding(horizontal = 12.dp, vertical = 6.dp), + visible = true, startTyping = AgentHost.entries.isEmpty(), + ) + } + } + } + + companion object { + fun open(context: Context) { + context.startActivity( + Intent(context, AgentChatActivity::class.java) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT), + ) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentGuest.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentGuest.kt index abe8abb3a3..c1ad86bfc3 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentGuest.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentGuest.kt @@ -19,7 +19,7 @@ import java.util.UUID object AgentGuest { private val main by lazy { Handler(Looper.getMainLooper()) } var focusRevision by mutableIntStateOf(0) - private set + @androidx.annotation.VisibleForTesting internal set var steamKeyboard by mutableStateOf(false) private set var desktopTextField by mutableStateOf(false) diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt index 80667afef0..22c30a994e 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.agent import android.content.Context -import android.os.Environment import android.os.Handler import android.os.Looper import android.os.SystemClock @@ -76,7 +75,9 @@ object AgentHost { "Never kill by a command-line pattern (pkill -f, pgrep -f piped to kill): your own command line holds the user's message, so the pattern matches you. " + "Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments. " + "To have the user pick between options, end your reply with a fenced code block whose language is choices, one short option per line, " + - "and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message." + "and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message. " + + "To show the user an image (a screenshot, a mockup, a chart), put ![what it shows](/absolute/path.png) on a line of its own: " + + "DroidDeck draws the file in the chat." val entries = mutableStateListOf() val queue = mutableStateListOf() @@ -564,13 +565,12 @@ object AgentHost { (if (connectAdb) "adb start-server >/dev/null 2>&1; adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " else "") + "cd \"$1\" 2>/dev/null; shift; exec \"$@\"", "sh", workdir, ) - val proot = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), null, env + shell + command, fakeRoot) + val proot = LinuxRuntime.command(app, null, null, LinuxRuntime.sharedStorage(app), null, env + shell + command, fakeRoot) return ProcessBuilder(proot).redirectErrorStream(true).apply { environment().apply { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) - if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt index 613cbe2c39..0d2fffc73e 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt @@ -14,8 +14,6 @@ object AgentNative { fun run(context: Context, request: JSONObject, timeoutMs: Long): JSONObject { val root = LinuxRuntime.rootDir(context) com.droiddeck.launcher.session.SessionFiles.stage(context, root) - // with the setting off, staging leaves the rootfs as proot wants it - if (!com.droiddeck.launcher.session.SessionPrefs.nativeUserland(context)) NativeGuest.prepare(context, root) if (!NativeGuest.available(root)) throw AgentException("NATIVE_UNAVAILABLE", "The rootfs has no native hook or glibc loader yet; start a session once") val argvJson = request.optJSONArray("argv") ?: throw AgentException("INVALID_REQUEST", "argv is required") val argv = (0 until argvJson.length()).map { argvJson.getString(it) } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt index 573814f00c..ad78dd3d44 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentSetup.kt @@ -8,8 +8,11 @@ import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import com.droiddeck.launcher.R +import com.droiddeck.launcher.core.WirelessAdbFix import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.OrphanReaper +import com.droiddeck.launcher.session.QuestExperimental import java.io.File import java.util.concurrent.TimeUnit @@ -88,6 +91,8 @@ object AgentSetup { private fun completedKey(harness: AgentHarness) = "setup_completed_${harness.id}" private val main = Handler(Looper.getMainLooper()) + /** Advanced by every Allow, so a connection check started before it cannot overwrite what it found. */ + private var connectionGeneration = 0 private const val REPO = "https://github.com/Droid-Deck/DroidDeck.git" private const val CHECKOUT = "/root/DroidDeck" private val HELPERS = listOf("android-open", "dd-gh-login", "droiddeckctl", "droiddeck-scenario") @@ -104,6 +109,7 @@ object AgentSetup { val harness = AgentHost.harness keys = harness.keys(LinuxRuntime.rootDir(app)) val probes = mutableListOf>>() + val generation = connectionGeneration for (step in Step.entries) if (status[step] != Status.WORKING) { when (step) { Step.INSTALL -> set(step, if (harness.files.all { AgentHost.guestFileExists(app, it) }) Status.DONE else Status.TODO) @@ -114,7 +120,9 @@ object AgentSetup { detail.remove(step) Thread({ val live = com.droiddeck.launcher.core.WirelessAdbFix.liveConnectAddress(app) != null - set(step, if (live) Status.DONE else Status.TODO) + main.post { + if (generation == connectionGeneration && status[step] != Status.WORKING) status[step] = if (live) Status.DONE else Status.TODO + } }, "agent-connection").start() } else probes += step to listOf("sh", "-c", "for i in 1 2 3; do adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " + @@ -123,14 +131,40 @@ object AgentSetup { Step.GITHUB -> probes += step to listOf("gh", "auth", "status") } } - Thread({ for ((step, command) in probes) probe(app, harness, step, command) }, "agent-checks").start() + Thread({ for ((step, command) in probes) probe(app, harness, step, command, generation) }, "agent-checks").start() } + /** The last failed refresh ends the script: the installs after it would run from stale indexes and could report success. */ + internal fun installScript(harnessInstall: String) = "set -e; export DEBIAN_FRONTEND=noninteractive; " + + "apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " + + "dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " + + "for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; " + + "[ \$i = 3 ] && { echo 'Some package sources could not be refreshed'; exit 1; }; " + + "echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " + + "apt -f install -y --fix-missing; " + + "apt install -y --no-install-recommends git gh adb curl ca-certificates python3; $harnessInstall" + fun runsAsRoot(step: Step) = step == Step.INSTALL /** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */ fun run(context: Context, step: Step) = run(context, step, null) + /** The [Step.CONNECTION] action on a Quest, which has no pairing screen; see [WirelessAdbFix.trustOnDevice]. */ + fun trustOnDevice(context: Context) { + val app = context.applicationContext + connectionGeneration++ + status[Step.CONNECTION] = Status.WORKING + detail[Step.CONNECTION] = app.getString(R.string.agent_connection_quest_waiting) + Thread({ + val ok = runCatching { WirelessAdbFix.trustOnDevice(app) }.isSuccess + main.post { + status[Step.CONNECTION] = if (ok) Status.DONE else Status.FAILED + if (ok) detail.remove(Step.CONNECTION) else detail[Step.CONNECTION] = app.getString(R.string.agent_connection_quest_failed) + if (ok) check(app) + } + }, "agent-quest-trust").start() + } + /** Opens the page where a provider's key is made, as the sign-in of a harness that takes pasted keys. */ fun openKeyPage(context: Context, page: String) = run(context, Step.SIGN_IN, listOf("/root/.local/bin/android-open", page)) @@ -140,12 +174,7 @@ object AgentSetup { val command = override ?: when (step) { Step.CONNECTION -> return Step.INSTALL -> { - listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " + - "apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " + - "dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " + - "for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " + - "apt -f install -y --fix-missing; " + - "apt install -y --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}") + listOf("sh", "-c", installScript(harness.install)) } Step.SIGN_IN -> harness.signIn Step.GITHUB -> listOf("dd-gh-login") @@ -197,7 +226,18 @@ object AgentSetup { /** The whole output of a step's last run; the card shows only its last line. */ fun logFile(app: Context, step: Step) = File(app.filesDir, "agent/setup-${step.name.lowercase()}.log") - fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git") + /** + * An install set up before setup wrote the Gradle init script gets the step again, but only + * once the checkout's setup writes it: the step runs that script, and an older one never would. + */ + fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git") && + (AgentHost.guestFileExists(app, GRADLE_INIT) || !setupWritesGradleInit(app)) + + private const val GRADLE_INIT = "/root/.gradle/init.d/droiddeck-device.gradle" + + private fun setupWritesGradleInit(app: Context) = runCatching { + File(LinuxRuntime.rootDir(app), "$CHECKOUT/tools/agent/setup".removePrefix("/")).readText().contains(GRADLE_INIT.substringAfterLast('/')) + }.getOrDefault(false) /** dd-lab-build compiled this install's commit, so a Lab build compiles only what changed. */ private fun prepared(app: Context) = runCatching { @@ -211,7 +251,7 @@ object AgentSetup { detail.clear() } - private fun probe(app: Context, harness: AgentHarness, step: Step, command: List) { + private fun probe(app: Context, harness: AgentHarness, step: Step, command: List, generation: Int) { var output = "" val ok = runCatching { val child = AgentHost.guest(app, command, connectAdb = step == Step.CONNECTION).start() @@ -227,11 +267,14 @@ object AgentSetup { }.onFailure { output = it.message.orEmpty() }.getOrDefault(false) main.post { if (AgentHost.harness != harness) return@post + // A running or newer Allow owns the row, including the instructions it shows while it waits. + if (step == Step.CONNECTION && (generation != connectionGeneration || status[step] == Status.WORKING)) return@post if (status[step] != Status.WORKING) status[step] = if (ok) Status.DONE else Status.TODO val last = output.lines().lastOrNull { it.isNotBlank() && !noise(it.trim()) }?.trim()?.take(160) when { ok -> detail.remove(step) - step == Step.CONNECTION -> detail[step] = app.getString(com.droiddeck.launcher.R.string.agent_connection_off) + step == Step.CONNECTION -> detail[step] = app.getString( + if (QuestExperimental.isSupported()) R.string.agent_connection_quest_off else R.string.agent_connection_off) step.required && last != null -> detail[step] = last } if (ready) AgentHost.prefs(app).edit().putBoolean(completedKey(harness), true).apply() diff --git a/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java b/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java index 8d9ddcb1f0..f87aefaa14 100644 --- a/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java +++ b/app/src/main/java/com/droiddeck/launcher/audio/DirectAudioRelayComponent.java @@ -89,7 +89,7 @@ public class DirectAudioRelayComponent extends SessionPart { } } final java.io.PrintWriter log = out; - pid = HostProcess.start(command.toString(), env.toArray(new String[0]), + pid = HostProcess.startUncounted(command.toString(), env.toArray(new String[0]), app().getFilesDir(), null, line -> { Log.i(TAG, line); diff --git a/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java b/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java index 53a0a6aacf..300a08b5f3 100644 --- a/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java +++ b/app/src/main/java/com/droiddeck/launcher/audio/PulseAudioComponent.java @@ -12,6 +12,7 @@ import com.droiddeck.launcher.core.TarZst; import java.io.File; import java.io.InputStream; import java.net.URL; +import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.ArrayList; @@ -36,9 +37,15 @@ public class PulseAudioComponent extends SessionPart { private final HostLifecycle host = new HostLifecycle(Process::killProcess); static final class HostLifecycle { + static final int MAX_STARTUP_CRASH_RESTARTS = 4; + private static final long[] STARTUP_RESTART_DELAYS_MS = {250L, 1000L, 2000L, 4000L}; + volatile int pid = -1; private long generation; private long launches; + private boolean preferStandardPerformanceMode; + private boolean sinkReady; + private int startupCrashRestarts; private final IntConsumer terminate; final ReentrantReadWriteLock commands = new ReentrantReadWriteLock(); @@ -48,6 +55,9 @@ public class PulseAudioComponent extends SessionPart { synchronized long begin() { stop(); + preferStandardPerformanceMode = false; + sinkReady = false; + startupCrashRestarts = 0; return generation; } @@ -55,6 +65,7 @@ public class PulseAudioComponent extends SessionPart { generation++; if (pid > 1) terminate.accept(pid); pid = -1; + sinkReady = false; } boolean launch(long expected, IntSupplier launch) { @@ -63,6 +74,7 @@ public class PulseAudioComponent extends SessionPart { synchronized (this) { if (expected != generation) return false; launches++; + sinkReady = false; pid = launch.getAsInt(); return true; } @@ -93,11 +105,45 @@ public class PulseAudioComponent extends SessionPart { return token == launches && pid > 1; } + synchronized boolean preferStandardPerformanceMode() { + return preferStandardPerformanceMode; + } + + synchronized void markLowLatencyFailed(long token) { + if (token == launches && pid > 1) preferStandardPerformanceMode = true; + } + + synchronized void markSinkReady(long token) { + if (token == launches && pid > 1) { + sinkReady = true; + startupCrashRestarts = 0; + } + } + synchronized boolean exited(long expected) { if (expected != generation || pid <= 1) return false; pid = -1; return true; } + + /** + * Decides whether a dead host should be restarted and after how many milliseconds. + * Returns 0 for immediate recovery of a host that had a working sink, a positive backoff + * while falling back to standard AAudio mode after a startup crash, or -1 to stop retrying. + */ + synchronized long nextRestartDelayMs(long expected) { + if (expected != generation) return -1L; + if (sinkReady) { + sinkReady = false; + startupCrashRestarts = 0; + return 0L; + } + preferStandardPerformanceMode = true; + if (startupCrashRestarts >= MAX_STARTUP_CRASH_RESTARTS) return -1L; + long delay = STARTUP_RESTART_DELAYS_MS[Math.min(startupCrashRestarts, STARTUP_RESTART_DELAYS_MS.length - 1)]; + startupCrashRestarts++; + return delay; + } } public PulseAudioComponent(Context context) { @@ -167,11 +213,14 @@ public class PulseAudioComponent extends SessionPart { if (micFifoPath != null && !micFifoPath.isEmpty()) { new File(micFifoPath).delete(); } + boolean standardMode = host.preferStandardPerformanceMode(); + String initialPerformanceMode = standardMode ? "0" : "1"; ArrayList config = new ArrayList<>(); config.add("load-module module-native-protocol-unix auth-anonymous=1 auth-cookie-enabled=0 socket=\"" + socket().getAbsolutePath() + "\""); config.add(".nofail"); - config.add("load-module module-directaudio-native-sink sink_name=DirectAudio performance_mode=1 adaptive=1 decay=0 limiter=1 watchdog=1 volume=1.0 control_dir=" + deviceControls); + config.add("load-module module-directaudio-native-sink sink_name=DirectAudio performance_mode=" + + initialPerformanceMode + " adaptive=1 decay=0 limiter=1 watchdog=1 volume=1.0 control_dir=" + deviceControls); config.add("set-default-sink DirectAudio"); config.add(".fail"); if (micFifoPath != null && !micFifoPath.isEmpty()) { @@ -186,15 +235,36 @@ public class PulseAudioComponent extends SessionPart { env.add("LD_LIBRARY_PATH=/system/lib64:" + modules + ":" + workingDir.getAbsolutePath()); env.add("HOME=" + workingDir); env.add("TMPDIR=" + workingDir); + // The daemon closes every fd at start but this one; in a worker process it is the binder + // fd whose closing Android takes for the process's death. + env.add("PULSE_PASSED_FD=" + com.droiddeck.launcher.runtime.GuestWorker.BINDER_FD_TOKEN); String command = String.join(" ", HostProcess.dataExecutable(workingDir.getAbsolutePath() + "/libpulseaudio.so")) + " --system=false --disable-shm=true --fail=false" + " -n --file=default.pa --daemonize=false --use-pid-file=false --exit-idle-time=-1" + " --log-level=info"; final java.io.PrintWriter out = openLog(); - if (!host.launch(generation, () -> HostProcess.start(command, env.toArray(new String[0]), workingDir, status -> { + if (!host.launch(generation, () -> HostProcess.startUncounted(command, env.toArray(new String[0]), workingDir, status -> { if (host.exited(generation)) { - Log.w(TAG, "audio host exited with status " + status + "; restarting"); + long delayMs = host.nextRestartDelayMs(generation); + if (delayMs < 0) { + String msg = "audio host exited with status " + status + + " before a client sink came up too many times; not restarting again in this session"; + Log.w(TAG, msg); + note(out, msg); + return; + } + Log.w(TAG, "audio host exited with status " + status + "; restarting" + + (host.preferStandardPerformanceMode() ? " with standard AAudio mode" : "") + + (delayMs > 0 ? " in " + delayMs + " ms" : "")); + if (delayMs > 0) { + try { + Thread.sleep(delayMs); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return; + } + } start(generation); } }, @@ -208,6 +278,24 @@ public class PulseAudioComponent extends SessionPart { guard.start(); } + private boolean loadDirectAudioSink(long token, String performanceMode) { + if ("0".equals(performanceMode)) pactlOk(token, "unload-module", "module-directaudio-native-sink"); + String loaded = pactlFor(token, "load-module", "module-directaudio-native-sink", "sink_name=DirectAudio", + "performance_mode=" + performanceMode, + "adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls); + if (loaded == null) return false; + if (pactlOk(token, "set-default-sink", "DirectAudio")) return true; + String moduleId = loaded.trim(); + pactlOk(token, "unload-module", moduleId.matches("\\d+") ? moduleId : "module-directaudio-native-sink"); + return false; + } + + private boolean loadPlainAAudioSink(long token, String performanceMode) { + return pactlOk(token, "load-module", "module-aaudio-sink", "sink_name=AAudioSink", + "performance_mode=" + performanceMode, "adaptive=1", "volume=1.0", "control_dir=" + deviceControls) + && pactlOk(token, "set-default-sink", "AAudioSink"); + } + private void ensureClientSink(java.io.PrintWriter out, long token) { try { // Nothing that may block (a sink whose AAudio open hangs: a Galaxy S24 FE (US) hung the @@ -229,27 +317,42 @@ public class PulseAudioComponent extends SessionPart { if (sinks == null) { line = "== client sink: the daemon did not answer in 30 s; no fallback attempted"; } else if (sinks.contains("\tDirectAudio\t") || sinks.startsWith("DirectAudio\t") || sinks.contains("\tDirectAudio\n") || sinks.matches("(?s).*\\bDirectAudio\\b.*")) { - line = "== client sink: DirectAudio (module-directaudio-native-sink)"; + host.markSinkReady(token); + line = "== client sink: DirectAudio (module-directaudio-native-sink" + + (host.preferStandardPerformanceMode() ? ", standard mode" : "") + ")"; } else { // AAudio can refuse the first open with AAUDIO_ERROR_DISCONNECTED while Android is - // still switching the output route as the session starts (seen on a Galaxy S24 FE): - // try DirectAudio again, then the plain sink, a few times over ten seconds. + // still switching the output route (Galaxy S24 FE) or when low-latency MMAP output + // is rejected by the HAL (Samsung One UI). Retry low-latency once if it hasn't been + // disqualified yet, then fall back to performance_mode=0 (non-MMAP) on DirectAudio + // before trying the plain AAudio sink. String loadedAs = null; for (int attempt = 1; attempt <= 5 && loadedAs == null && host.live(token); attempt++) { try { Thread.sleep(2000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } - if (pactlOk(token, "load-module", "module-directaudio-native-sink", "sink_name=DirectAudio", "performance_mode=1", - "adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls) - && pactlOk(token, "set-default-sink", "DirectAudio")) { - loadedAs = "DirectAudio on attempt " + attempt; - } else if (pactlOk(token, "load-module", "module-aaudio-sink", "sink_name=AAudioSink", - "performance_mode=" + (attempt == 1 ? "1" : "0"), "adaptive=1", "volume=1.0", "control_dir=" + deviceControls) - && pactlOk(token, "set-default-sink", "AAudioSink")) { - loadedAs = "the plain AAudio sink (AAudioSink) on attempt " + attempt; + if (!host.live(token)) break; + if (attempt == 1 && !host.preferStandardPerformanceMode()) { + if (loadDirectAudioSink(token, "1")) { + loadedAs = "DirectAudio on attempt " + attempt; + break; + } + if (!host.live(token)) break; + host.markLowLatencyFailed(token); + } + if (loadDirectAudioSink(token, "0")) { + loadedAs = "DirectAudio (standard mode) on attempt " + attempt; + } else if (host.live(token) && loadPlainAAudioSink(token, "0")) { + loadedAs = "the plain AAudio sink (AAudioSink, standard mode) on attempt " + attempt; } } - line = loadedAs != null ? "== client sink: DirectAudio did not come up at start; retried and got " + loadedAs - : "== client sink: DirectAudio did not come up and the AAudio fallback failed too after 5 retries - no client sound." - + " If audio.log shows AAUDIO_ERROR_DISCONNECTED, Android refused the audio output: rebooting the phone usually fixes this"; + if (loadedAs != null) { + host.markSinkReady(token); + line = "== client sink: DirectAudio did not come up at start; retried and got " + loadedAs; + } else if (!host.live(token)) { + line = "== client sink: audio host exited during sink recovery"; + } else { + line = "== client sink: DirectAudio did not come up and the AAudio fallback failed too after 5 retries - no client sound." + + " If audio.log shows AAUDIO_ERROR_DISCONNECTED, Android refused the audio output: rebooting the phone usually fixes this"; + } Log.w(TAG, line); } Log.i(TAG, line); @@ -404,11 +507,22 @@ public class PulseAudioComponent extends SessionPart { continue; } File destination = new File(workingDir, lib); + File temp = null; try (InputStream in = resource.openStream()) { - Files.copy(in, destination.toPath(), StandardCopyOption.REPLACE_EXISTING); - FileUtils.chmod(destination, 0771); + temp = File.createTempFile(lib + ".", ".tmp", workingDir); + Files.copy(in, temp.toPath(), StandardCopyOption.REPLACE_EXISTING); + FileUtils.chmod(temp, 0771); + try { + Files.move(temp.toPath(), destination.toPath(), + StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); + } catch (AtomicMoveNotSupportedException e) { + Files.move(temp.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + temp = null; } catch (Exception e) { Log.w(TAG, "copy " + lib, e); + } finally { + if (temp != null) temp.delete(); } } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/CpuFeatures.kt b/app/src/main/java/com/droiddeck/launcher/core/CpuFeatures.kt new file mode 100644 index 0000000000..e8cd318bc2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/CpuFeatures.kt @@ -0,0 +1,17 @@ +package com.droiddeck.launcher.core + +import java.io.File + +object CpuFeatures { + internal fun lacksAtomics(cpuInfo: String): Boolean { + val cores = cpuInfo.lineSequence() + .filter { it.substringBefore(':').trim() == "Features" } + .map { it.substringAfter(':').trim().split(Regex("\\s+")) } + .toList() + return cores.isNotEmpty() && cores.any { "atomics" !in it } + } + + val lacksAtomics: Boolean by lazy { + runCatching { lacksAtomics(File("/proc/cpuinfo").readText()) }.getOrDefault(false) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 9cf1871e10..46b74fbafa 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -27,6 +27,7 @@ import java.io.File import java.text.SimpleDateFormat import java.util.Date import java.util.Locale +import java.util.TimeZone object DeviceReport { private const val TAG = "DeviceReport" @@ -36,6 +37,10 @@ object DeviceReport { .map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") } .filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" } + internal fun buildDate(millis: Long): String? = millis.takeIf { it > 0 }?.let { + SimpleDateFormat("yyyy-MM-dd HH:mm 'UTC'", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }.format(Date(it)) + } + fun write(context: Context, target: File, mode: String) { try { target.writeText(build(context, mode)) @@ -62,6 +67,7 @@ object DeviceReport { 14 -> "FREEZER" 15 -> "PACKAGE_STATE_CHANGE" 16 -> "PACKAGE_UPDATED" + 17 -> "MEMORY_LIMITER" else -> "REASON_$reason" } @@ -128,6 +134,7 @@ object DeviceReport { k("Android", "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})") k("Security patch", Build.VERSION.SECURITY_PATCH) k("Build", Build.DISPLAY) + k("Build date", buildDate(Build.TIME)) k("Fingerprint", Build.FINGERPRINT) k("Kernel", System.getProperty("os.version")) k("ABIs", Build.SUPPORTED_ABIS.joinToString(", ")) @@ -185,6 +192,7 @@ object DeviceReport { val fs = StatFs(Environment.getExternalStorageDirectory().path) k("Shared storage free", FileUtils.sizeToString(fs.availableBlocksLong * fs.blockSizeLong)) } + k("All files access", runCatching { com.droiddeck.launcher.files.AllFilesAccess.state() }.getOrNull()) h("GPU") k("KGSL gpu_model", readSys("/sys/class/kgsl/kgsl-3d0/gpu_model")) @@ -283,9 +291,12 @@ object DeviceReport { k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up") k("gamescope realtime", SessionPrefs.gamescopeRealtime(context)) k("pace cores", SessionPrefs.paceCores(context)) - k("proot without seccomp", SessionPrefs.prootNoSeccomp(context)) - k("native userland (no proot)", SessionPrefs.nativeUserland(context)) - k("proot fast path", SessionPrefs.prootFastPath(context)) + k("guest runtime policy", "native preferred with PRoot fallback") + k("guest runtime", when (com.droiddeck.launcher.runtime.NativeGuest.sessionMode) { + true -> "native" + false -> "PRoot" + null -> if (com.droiddeck.launcher.runtime.NativeGuest.enabled(context)) "native available" else "native unavailable" + }) k("proot binary", LinuxRuntime.prootSource(context) + " " + LinuxRuntime.prootBinary(context).path) k("proot fast path (eligible)", com.droiddeck.launcher.runtime.ProotFastPath.enabled(context)) k("Guest host name", SessionPrefs.guestHostname(context)) diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt index 55e7e61284..fc848b167e 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt @@ -50,6 +50,17 @@ object GameEnvironment { return withScopeValue(config, scope, NO_STEAM, if (on) "1" else null) } + /** dd-directcontroller on DroidDeck-Bionic: "0" starts the game in pass-through (Wine's own xinput); unset = the pad state. */ + const val DIRECT_CONTROLLER = "DD_DIRECTCONTROLLER" + + fun gameDirectController(config: Config, scope: String): Boolean = + scope.isEmpty() || config.games[scope]?.get(DIRECT_CONTROLLER) != "0" + + fun withGameDirectController(config: Config, scope: String, on: Boolean): Config { + require(scope.isNotEmpty() && validScope(scope)) + return withScopeValue(config, scope, DIRECT_CONTROLLER, if (on) null else "0") + } + const val GAME_RESOLUTION = "DROIDDECK_GAME_RESOLUTION" fun gameResolution(config: Config, scope: String): GameResolution.Choice? = @@ -61,7 +72,19 @@ object GameEnvironment { } fun effective(config: Config, preset: String, scope: String, forceSsbs: Boolean = false): Map = - defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else config.games[scope].orEmpty() + defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else knownGames[scope].orEmpty() + config.games[scope].orEmpty() + + /** + * What some Steam games need here whatever the shared settings say; the game's own settings still win. + * GTA III dies at 0042A703 when a new game starts with FEX's reduced x87 precision, as the Rockstar store copy does. + */ + val knownGames: Map> = mapOf( + "12100" to mapOf("FEX_X87REDUCEDPRECISION" to "0"), + ) + + /** [config] with [knownGames] folded under each game's own settings, for the guest to read. */ + fun withKnownGames(config: Config): Config = + config.copy(games = config.games + knownGames.mapValues { (scope, known) -> known + config.games[scope].orEmpty() }) fun hasOverride(config: Config, scope: String, name: String): Boolean = scope.isNotEmpty() && config.entries(scope).containsKey(name) @@ -78,7 +101,7 @@ object GameEnvironment { val entries = config.games[scope].orEmpty() if (FexPreset.environmentKeys.none(entries::containsKey)) return null return FexPreset.all.firstOrNull { preset -> - val expected = FexPreset.environment(preset.id) + val expected = presetFor(scope, preset.id) FexPreset.environmentKeys.all { key -> entries.containsKey(key) && entries[key] == expected[key] } }?.id ?: CUSTOM_FEX_PRESET } @@ -88,12 +111,16 @@ object GameEnvironment { require(preset == null || FexPreset.all.any { it.id == preset }) val entries = config.entries(scope).filterKeys { it !in FexPreset.environmentKeys }.toMutableMap() if (preset != null) { - val values = FexPreset.environment(preset) + val values = presetFor(scope, preset) FexPreset.environmentKeys.forEach { key -> entries[key] = values[key] } } return config.withEntries(scope, entries) } + /** A FEX preset as a game gets it: picking one never undoes a fix the game is known to need. */ + private fun presetFor(scope: String, preset: String): Map = + FexPreset.environment(preset) + knownGames[scope].orEmpty().filterKeys { it in FexPreset.environmentKeys } + const val CUSTOM_FEX_PRESET = "__custom__" val syncBackends = listOf(SessionPrefs.SYNC_NTSYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_WINESERVER) diff --git a/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt b/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt index 3e4bb53051..1daf377fb7 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GlobalSettings.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.core import android.content.Context +import android.content.pm.PackageManager import android.net.Uri import android.provider.Settings @@ -19,4 +20,14 @@ object GlobalSettings { fun developerOptionsOn(context: Context): Boolean = isOn(context, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED) fun wirelessDebuggingOn(context: Context): Boolean = isOn(context, "adb_wifi_enabled") + + /** + * True when it was off and is now on. Quest only, where Settings has no switch for it; it needs + * WRITE_SECURE_SETTINGS granted over adb. + */ + fun turnOnWirelessDebugging(context: Context): Boolean { + if (!com.droiddeck.launcher.session.QuestExperimental.isSupported() || wirelessDebuggingOn(context)) return false + if (context.checkSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED) return false + return runCatching { Settings.Global.putInt(context.contentResolver, "adb_wifi_enabled", 1) }.getOrDefault(false) + } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/HostProcess.kt b/app/src/main/java/com/droiddeck/launcher/core/HostProcess.kt index d4a2cdc66d..d3a03036a3 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/HostProcess.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/HostProcess.kt @@ -1,5 +1,6 @@ package com.droiddeck.launcher.core +import android.os.ParcelFileDescriptor import android.util.Log import java.io.File import java.util.function.Consumer @@ -7,6 +8,9 @@ import java.util.function.Consumer object HostProcess { private const val TAG = "HostProcess" private const val LINKER = "/system/bin/linker64" + // sh -c WORKER_CD sh DIR NAME=VALUE... -- PROGRAM ARGS... + private const val WORKER_CD = "cd \"\$1\" || exit 126; shift; " + + "while [ \$# -gt 0 ] && [ \"\$1\" != -- ]; do export \"\$1\"; shift; done; shift; exec \"\$@\"" /** Android 10+ refuses to execute app data files for targetSdk 29+; its linker still loads them. */ @JvmStatic @@ -65,6 +69,77 @@ object HostProcess { } } + /** + * As [start], but the program runs as the main process of one of the app's worker processes, + * which Android does not count against the app's child processes (docs/phantom-processes.md). + * Falls back to [start] when no worker is available. The exit status is the program's exit + * code, or 128 plus the signal that ended it, as Process.waitFor() reports it. + */ + @JvmStatic + @JvmOverloads + fun startUncounted(command: String, env: Array?, dir: File?, onExit: Consumer?, onLine: Consumer?, + outputFile: File? = null, onOutputComplete: Runnable? = null): Int { + val context = com.droiddeck.launcher.runtime.GuestWorkers.context + val argv = split(command) + // A missing working directory fails the launch (start() returns -1 for it), not the program + if (context == null || argv.isEmpty() || !com.droiddeck.launcher.runtime.GuestWorkers.enabled(context) || + (dir != null && !dir.isDirectory)) { + return start(command, env, dir, onExit, onLine, outputFile, onOutputComplete) + } + val environment = LinkedHashMap(System.getenv()) + env?.forEach { line -> + val eq = line.indexOf('=') + if (eq > 0) environment[line.substring(0, eq)] = line.substring(eq + 1) + } + val assignments = environment.map { (k, v) -> "$k=$v" } + // A worker cannot chdir before its exec, so Android's shell does it. The shell starts with an + // environment of its own (the program's LD_PRELOAD of glibc libraries would stop it loading) + // and exports the program's before the exec. + val launch = if (dir != null) { + listOf("/system/bin/sh", "-c", WORKER_CD, "sh", dir.path) + assignments + listOf("--") + argv + } else argv + val workerEnv = if (dir != null) listOf("PATH=/system/bin") else assignments + var input: ParcelFileDescriptor? = null + var reader: ParcelFileDescriptor? = null + var output: ParcelFileDescriptor? = null + val pid = try { + input = ParcelFileDescriptor.open(File("/dev/null"), ParcelFileDescriptor.MODE_READ_ONLY) + output = when { + onLine != null -> ParcelFileDescriptor.createPipe().let { reader = it[0]; it[1] } + outputFile != null -> ParcelFileDescriptor.open(outputFile, + ParcelFileDescriptor.MODE_WRITE_ONLY or ParcelFileDescriptor.MODE_CREATE or ParcelFileDescriptor.MODE_APPEND) + else -> ParcelFileDescriptor.open(File("/dev/null"), ParcelFileDescriptor.MODE_WRITE_ONLY) + } + com.droiddeck.launcher.runtime.GuestWorkers.start(context, launch, workerEnv, listOf(input, output, output)) { status -> + onExit?.accept(if (status < 0) -1 else if (status and 0x7f == 0) (status shr 8) and 0xff else 128 + (status and 0x7f)) + } + } catch (e: Exception) { + Log.w(TAG, "no worker for ${argv.first()}", e) + -1 + } finally { + runCatching { input?.close() } + runCatching { output?.close() } + } + if (pid <= 0) { + reader?.close() + return start(command, env, dir, onExit, onLine, outputFile, onOutputComplete) + } + Log.i(TAG, "started pid $pid outside the child-process count: ${argv.first()} (${argv.size - 1} arguments)") + reader?.let { pipe -> + Thread({ + try { + ParcelFileDescriptor.AutoCloseInputStream(pipe).bufferedReader().useLines { lines -> + lines.forEach { onLine?.accept(it) } + } + } catch (e: Exception) { + } finally { + onOutputComplete?.run() + } + }, "proc-out-$pid").apply { priority = Thread.NORM_PRIORITY - 1; isDaemon = true; start() } + } + return pid + } + @JvmStatic fun pidOf(process: Process): Int = try { val field = process.javaClass.getDeclaredField("pid") diff --git a/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt b/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt index 6e67ff495d..5bcc716d1e 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/PhantomProcessLimit.kt @@ -7,6 +7,8 @@ import com.droiddeck.launcher.R enum class PhantomProcessStatus { NOT_APPLICABLE, + /** The limit is on, but the session keeps its programs out of Android's count (GuestWorkers). */ + UNCOUNTED, DISABLED, ENABLED, UNSET, @@ -57,6 +59,12 @@ object PhantomProcessLimit { fun read(context: Context, sdk: Int = Build.VERSION.SDK_INT): PhantomProcessStatus { if (sdk < Build.VERSION_CODES.S) return PhantomProcessStatus.NOT_APPLICABLE + val status = readSetting(context, sdk) + return if (status != PhantomProcessStatus.DISABLED && com.droiddeck.launcher.runtime.GuestWorkers.limitHandled(context)) + PhantomProcessStatus.UNCOUNTED else status + } + + private fun readSetting(context: Context, sdk: Int): PhantomProcessStatus { if (usesDeviceConfig(sdk)) { val off = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean(PREF_ANDROID_12_OFF, false) val global = try { @@ -101,7 +109,8 @@ object PhantomProcessLimit { fun hasDeveloperToggle(sdk: Int = Build.VERSION.SDK_INT): Boolean = sdk >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE fun blocksSteam(status: PhantomProcessStatus): Boolean = - status != PhantomProcessStatus.NOT_APPLICABLE && status != PhantomProcessStatus.DISABLED + status != PhantomProcessStatus.NOT_APPLICABLE && status != PhantomProcessStatus.DISABLED && + status != PhantomProcessStatus.UNCOUNTED fun title(context: Context, status: PhantomProcessStatus): String = context.getString(when (status) { PhantomProcessStatus.ENABLED -> R.string.phantom_title_on @@ -109,6 +118,7 @@ object PhantomProcessLimit { PhantomProcessStatus.UNREADABLE -> R.string.phantom_title_unreadable PhantomProcessStatus.DISABLED -> R.string.phantom_title_off PhantomProcessStatus.NOT_APPLICABLE -> R.string.phantom_title_not_required + PhantomProcessStatus.UNCOUNTED -> R.string.phantom_title_uncounted }) fun instructions(context: Context, status: PhantomProcessStatus): String = when (status) { @@ -116,6 +126,7 @@ object PhantomProcessLimit { context.getString(R.string.phantom_instructions_fix, fixSentence(context)) PhantomProcessStatus.DISABLED -> context.getString(R.string.phantom_instructions_off) PhantomProcessStatus.NOT_APPLICABLE -> context.getString(R.string.phantom_instructions_not_applicable) + PhantomProcessStatus.UNCOUNTED -> context.getString(R.string.phantom_instructions_uncounted) } fun gateInstructions(context: Context, status: PhantomProcessStatus): String = when (status) { @@ -132,5 +143,6 @@ object PhantomProcessLimit { PhantomProcessStatus.UNSET -> "not set (ROM default applies; DroidDeck requires an explicit disabled value)" PhantomProcessStatus.UNREADABLE -> "unreadable (DroidDeck could not verify the setting)" PhantomProcessStatus.NOT_APPLICABLE -> "not applicable before Android 12" + PhantomProcessStatus.UNCOUNTED -> "on, not needed (most of the session's programs run in uncounted worker processes)" } } diff --git a/app/src/main/java/com/droiddeck/launcher/core/SessionLogCapture.kt b/app/src/main/java/com/droiddeck/launcher/core/SessionLogCapture.kt index 650a6b8d4d..42524b5dcb 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/SessionLogCapture.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/SessionLogCapture.kt @@ -28,17 +28,18 @@ object SessionLogCapture { out.flush() writer = out this.target = target - pid = HostProcess.start( + pid = HostProcess.startUncounted( command(Process.myPid(), sinceMillis), null, target.parentFile, null, - ) { line -> - synchronized(this) { - try { - writer?.apply { write(line); newLine(); flush() } - } catch (e: Exception) { + onLine = { line -> + synchronized(this) { + try { + writer?.apply { write(line); newLine(); flush() } + } catch (e: Exception) { + } } - } - } + }, + ) if (pid == -1) { out.write("logcat could not be started; this ROM may not hand an app its own entries.\n") out.flush() diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt index 5c8b32f7ba..e9f8bbdfaa 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt @@ -22,6 +22,9 @@ object WirelessAdbFix { private const val HOST_FILE = "wireless-adb-host.txt" private const val CONNECTION_FILE = "wireless-adb-connection.txt" const val LOOPBACK = "127.0.0.1" + private const val TCP_PORT = 5555 + private const val WIRELESS_START_MS = 2_000L + private const val NETWORK_PROMPT_MS = 30_000L private data class SavedConnection(val host: String, val port: Int?) @@ -55,6 +58,23 @@ object WirelessAdbFix { writeAtomically(context, File(context.noBackupFilesDir, CONNECTION_FILE), ByteArray(0)) } + /** + * Quest has no pairing screen. adbd in TCP mode (`adb tcpip 5555`) asks "Allow debugging?" for an + * unknown key, and Wireless debugging accepts a key allowed there, so this stands in for pairing. + * Blocks until the prompt is answered or times out. + */ + fun trustOnDevice(context: Context) { + val app = context.applicationContext + // Already trusted, as after a reboot: Wireless debugging takes the key, and port 5555 is closed by then. + val live = if (savedConnection(app) != null) liveConnectAddress(app) else null + if (live != null && acceptsKey(app, live.substringBeforeLast(':').trim('[', ']'), live.substringAfterLast(':').toInt())) return + GlobalSettings.turnOnWirelessDebugging(app) + loadOrCreateIdentity(app) + Kadb.create(LOOPBACK, TCP_PORT, 2_000, 120_000).use { check(it.shell("true").exitCode == 0) } + writeAtomically(app, File(app.noBackupFilesDir, HOST_FILE), LOOPBACK.toByteArray()) + writeAtomically(app, File(app.noBackupFilesDir, CONNECTION_FILE), ByteArray(0)) + } + private fun savedConnection(context: Context): SavedConnection? { val directory = context.applicationContext.noBackupFilesDir if (!File(directory, CERT_FILE).isFile || !File(directory, KEY_FILE).isFile) return null @@ -78,10 +98,17 @@ object WirelessAdbFix { fun liveConnectAddress(context: Context): String? { val app = context.applicationContext val saved = savedConnection(app) ?: return null + val turnedOn = GlobalSettings.turnOnWirelessDebugging(app) val host = if (':' in saved.host) "[${saved.host}]" else saved.host - saved.port?.takeIf { answers(saved.host, it) }?.let { return "$host:$it" } + if (!turnedOn) saved.port?.takeIf { answers(saved.host, it) }?.let { return "$host:$it" } val loopback = runCatching { InetAddress.getByName(saved.host).isLoopbackAddress }.getOrDefault(false) - val port = if (loopback) loopbackAdbPort(app) else findConnectPort(app, saved.host, accept = { answers(saved.host, it) }) + // Turning it on can first ask "Allow wireless debugging on this network?", so keep looking while that is answered. + val deadline = android.os.SystemClock.elapsedRealtime() + if (turnedOn) NETWORK_PROMPT_MS else 0L + var port: Int? + do { + if (turnedOn) Thread.sleep(WIRELESS_START_MS) + port = if (loopback) loopbackAdbPort(app) else findConnectPort(app, saved.host, accept = { answers(saved.host, it) }) + } while (port == null && android.os.SystemClock.elapsedRealtime() < deadline) port ?: return null saveConnection(app, saved.host, port) return "$host:$port" @@ -92,7 +119,7 @@ object WirelessAdbFix { * socket table, and mDNS often advertises nothing, so the ephemeral range Linux gives adbd is * scanned on loopback (closed ports refuse at once) and the open ports are tried with our key. */ - private fun loopbackAdbPort(app: Context): Int? { + private fun loopbackAdbPort(app: Context, exclude: Int? = null): Int? { val open = java.util.concurrent.ConcurrentLinkedQueue() val workers = 32 val range = EPHEMERAL_PORTS @@ -100,15 +127,17 @@ object WirelessAdbFix { Thread { var port = range.first + worker while (port <= range.last) { - if (answers(LOOPBACK, port, 150)) open += port + if (port != exclude && answers(LOOPBACK, port, 150)) open += port port += workers } }.apply { start() } }.forEach { it.join() } + return open.sorted().firstOrNull { port -> acceptsKey(app, LOOPBACK, port) } + } + + private fun acceptsKey(app: Context, host: String, port: Int): Boolean { loadOrCreateIdentity(app) - return open.sorted().firstOrNull { port -> - runCatching { Kadb.create(LOOPBACK, port, 1_000, 3_000).use { it.shell("true").exitCode == 0 } }.getOrDefault(false) - } + return runCatching { Kadb.create(host, port, 1_000, 3_000).use { it.shell("true").exitCode == 0 } }.getOrDefault(false) } private val EPHEMERAL_PORTS = 32768..60999 @@ -133,8 +162,28 @@ object WirelessAdbFix { }.getOrDefault(address is Inet4Address) fun localConnectPort(context: Context): Int? = - tlsPortProperty() - ?: findConnectPort(context, LOOPBACK) + discoverConnectPort(context, LOOPBACK) + + private fun discoverConnectPort(context: Context, host: String, exclude: Int? = null): Int? = + chooseConnectPort(host, exclude, + property = ::tlsPortProperty, + advertised = { acceptable -> findConnectPort(context, host, accept = acceptable) }, + answers = { port -> answers(host, port) }, + // Some local devices never advertise their connect port. Try only + // loopback and require the app's existing paired key to authenticate. + authenticatedLocal = { loopbackAdbPort(context.applicationContext, exclude) }, + ) + + internal fun chooseConnectPort( + host: String, exclude: Int?, + property: () -> Int?, advertised: ((Int) -> Boolean) -> Int?, + answers: (Int) -> Boolean, authenticatedLocal: () -> Int?, + ): Int? { + val local = host == LOOPBACK + val acceptable: (Int) -> Boolean = { port -> port != exclude && (!local || answers(port)) } + val propertyPort = if (local) property()?.takeIf(acceptable) else null + return propertyPort ?: advertised(acceptable) ?: if (local) authenticatedLocal() else null + } private fun tlsPortProperty(): Int? = runCatching { Class.forName("android.os.SystemProperties").getMethod("get", String::class.java) @@ -272,14 +321,14 @@ object WirelessAdbFix { if (cachedPort != null) { val cachedResult = runCatching { action(appContext, saved.host, cachedPort) } if (cachedResult.isSuccess) return - val discoveredPort = findConnectPort(appContext, saved.host) + val discoveredPort = discoverConnectPort(appContext, saved.host, exclude = cachedPort) if (discoveredPort != null && discoveredPort != cachedPort) { action(appContext, saved.host, discoveredPort) } else { cachedResult.getOrThrow() } } else { - val discoveredPort = findConnectPort(appContext, saved.host) + val discoveredPort = discoverConnectPort(appContext, saved.host) ?: error(appContext.getString(R.string.adbfix_enter_address)) action(appContext, saved.host, discoveredPort) } diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt index f7097dce7c..d1e2d911e8 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt @@ -4,20 +4,23 @@ import android.app.Notification import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent -import android.app.RemoteInput import android.app.Service import android.content.Context import android.content.Intent +import android.net.Uri import android.net.nsd.NsdManager import android.net.nsd.NsdServiceInfo import android.os.Build import android.os.Handler import android.os.IBinder import android.os.Looper +import android.util.TypedValue +import android.widget.RemoteViews import com.droiddeck.launcher.FrontEndActivity import com.droiddeck.launcher.R import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import java.util.UUID class WirelessAdbPairingService : Service() { override fun attachBaseContext(newBase: android.content.Context) = @@ -37,6 +40,8 @@ class WirelessAdbPairingService : Service() { private var discovery: NsdManager.DiscoveryListener? = null private var pairingHost: String? = null private var pairingPort: Int? = null + private val keypad = WirelessPairingKeypad() + private var keypadToken = UUID.randomUUID().toString() @Volatile private var working = false @Volatile private var limitEnabled = false @Volatile private var session = 0 @@ -46,13 +51,21 @@ class WirelessAdbPairingService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { when (intent?.action) { - ACTION_CODE -> { - val code = RemoteInput.getResultsFromIntent(intent)?.getCharSequence(KEY_CODE) - ?.filter(Char::isDigit)?.toString().orEmpty() - onCode(code) + ACTION_KEYPAD -> { + if (intent.data?.host == keypadToken && current.value is Stage.CodeNeeded && !working) { + val key = intent.data?.lastPathSegment?.toIntOrNull() + if (key == WirelessPairingKeypad.SUBMIT) { + if (keypad.ready && pairingPort != null) onCode(keypad.digits) + } else if (key != null && keypad.press(key)) { + show(current.value, quietUpdate = true) + } + } else if (current.value == Stage.Idle) { + stopSelf(startId) + } } ACTION_CANCEL -> finish(Stage.Idle) - else -> begin(intent?.getBooleanExtra(EXTRA_ENABLE_LIMIT, false) == true) + null -> begin(intent?.getBooleanExtra(EXTRA_ENABLE_LIMIT, false) == true) + else -> if (discovery == null && !working) stopSelf(startId) } return START_NOT_STICKY } @@ -60,11 +73,13 @@ class WirelessAdbPairingService : Service() { private fun begin(enableLimit: Boolean) { if (working) return session++ + resetKeypad() limitEnabled = enableLimit pairingHost = null pairingPort = null working = false publish(Stage.Waiting) + getSystemService(NotificationManager::class.java)?.cancel(KEYPAD_NOTIFICATION_ID) startForeground(NOTIFICATION_ID, notification(Stage.Waiting)) startDiscovery() main.removeCallbacks(timeout) @@ -101,9 +116,13 @@ class WirelessAdbPairingService : Service() { if (!WirelessAdbFix.isLocalAddress(address)) return main.post { if (owner != session || working || current.value == Stage.Done) return@post + val endpointChanged = pairingHost != address.hostAddress || pairingPort != serviceInfo.port pairingHost = address.hostAddress pairingPort = serviceInfo.port - if (current.value !is Stage.CodeNeeded) show(Stage.CodeNeeded()) + if (endpointChanged) { + resetKeypad() + show(Stage.CodeNeeded()) + } } } } @@ -117,11 +136,12 @@ class WirelessAdbPairingService : Service() { show(Stage.Waiting) return } - if (code.length != 6) { + if (code.length != WirelessPairingKeypad.LENGTH) { show(Stage.CodeNeeded(getString(R.string.adbpair_six_digits))) return } working = true + resetKeypad() val owner = session val enable = limitEnabled show(Stage.Working(getString(R.string.adbpair_pairing))) @@ -155,17 +175,34 @@ class WirelessAdbPairingService : Service() { }, "wireless-adb-pairing").start() } - private fun show(stage: Stage) { + private fun show(stage: Stage, quietUpdate: Boolean = false) { publish(stage) - getSystemService(NotificationManager::class.java)?.notify(NOTIFICATION_ID, notification(stage)) + val manager = getSystemService(NotificationManager::class.java) ?: return + if (stage is Stage.CodeNeeded) { + // A new high-priority notification can pop over Settings. Updating the + // quiet foreground-service notification can leave the keypad in the shade. + // End any previous indeterminate progress even if this is a code retry. + if (!quietUpdate) manager.notify(NOTIFICATION_ID, notification(stage, foregroundCodeEntry = true)) + manager.notify(KEYPAD_NOTIFICATION_ID, notification(stage, quietUpdate)) + } else { + manager.cancel(KEYPAD_NOTIFICATION_ID) + manager.notify(NOTIFICATION_ID, notification(stage, quietUpdate)) + } + } + + private fun resetKeypad() { + keypad.clear() + keypadToken = UUID.randomUUID().toString() } private fun finish(stage: Stage) { session++ + resetKeypad() main.removeCallbacks(timeout) stopDiscovery() publish(stage) val manager = getSystemService(NotificationManager::class.java) + manager?.cancel(KEYPAD_NOTIFICATION_ID) if (stage is Stage.Done || stage is Stage.Failed) { manager?.notify(NOTIFICATION_ID, notification(stage)) stopForeground(STOP_FOREGROUND_DETACH) @@ -183,13 +220,16 @@ class WirelessAdbPairingService : Service() { } override fun onDestroy() { + getSystemService(NotificationManager::class.java)?.cancel(KEYPAD_NOTIFICATION_ID) main.removeCallbacks(timeout) stopDiscovery() if (current.value.let { it is Stage.Waiting || it is Stage.CodeNeeded || it is Stage.Working }) publish(Stage.Idle) super.onDestroy() } - private fun notification(stage: Stage): Notification { + private fun notification( + stage: Stage, quietUpdate: Boolean = false, foregroundCodeEntry: Boolean = false, + ): Notification { val manager = getSystemService(NotificationManager::class.java) manager?.createNotificationChannel(NotificationChannel(CHANNEL_ID, getString(R.string.adbpair_channel_name), NotificationManager.IMPORTANCE_HIGH).apply { @@ -205,7 +245,7 @@ class WirelessAdbPairingService : Service() { PendingIntent.FLAG_IMMUTABLE) val cancel = PendingIntent.getService(this, 1, Intent(this, WirelessAdbPairingService::class.java).setAction(ACTION_CANCEL), PendingIntent.FLAG_IMMUTABLE) - val quiet = stage == Stage.Waiting || stage == Stage.Idle || stage is Stage.Working + val quiet = foregroundCodeEntry || stage == Stage.Waiting || stage == Stage.Idle || stage is Stage.Working val builder = Notification.Builder(this, if (quiet) PROGRESS_CHANNEL_ID else CHANNEL_ID) .setSmallIcon(R.drawable.ic_stat_session) .setContentIntent(open) @@ -220,19 +260,31 @@ class WirelessAdbPairingService : Service() { .setOnlyAlertOnce(true) .addAction(Notification.Action.Builder(null, getString(R.string.common_cancel), cancel).build()) is Stage.CodeNeeded -> { - val reply = PendingIntent.getService(this, 2, - Intent(this, WirelessAdbPairingService::class.java).setAction(ACTION_CODE), - if (Build.VERSION.SDK_INT >= 31) PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT - else PendingIntent.FLAG_UPDATE_CURRENT) - val input = RemoteInput.Builder(KEY_CODE).setLabel(getString(R.string.adbpair_code_label)).build() - val text = stage.error ?: getString(R.string.adbpair_code_hint) builder - .setContentTitle(getString(if (stage.error == null) R.string.adbpair_title_code else R.string.adbpair_title_retry)) - .setContentText(text) - .setStyle(Notification.BigTextStyle().bigText(text)) + .setContentTitle(getString(if (foregroundCodeEntry) R.string.adbpair_title_pair + else if (stage.error == null) R.string.adbpair_title_code else R.string.adbpair_title_retry)) + .setContentIntent(null) + .setVisibility(Notification.VISIBILITY_SECRET) + .setLocalOnly(true) .setOngoing(true) - .addAction(Notification.Action.Builder(null, getString(R.string.adbpair_enter_code), reply).addRemoteInput(input).build()) - .addAction(Notification.Action.Builder(null, getString(R.string.common_cancel), cancel).build()) + .setOnlyAlertOnce(foregroundCodeEntry || quietUpdate) + if (!foregroundCodeEntry) { + // Keep the keypad separate from status/install notifications. Android owns + // the heads-up timeout; the drawer remains usable without expanding a group. + builder.setGroup(KEYPAD_GROUP) + .addAction(Notification.Action.Builder(null, getString(R.string.common_cancel), cancel).build()) + if (stage.error != null && pairingPort == null) { + builder.setContentText(stage.error) + .setStyle(Notification.BigTextStyle().bigText(stage.error)) + } else { + builder.setStyle(Notification.DecoratedCustomViewStyle()) + .setCustomBigContentView(pairingKeypad()) + .setCustomHeadsUpContentView(pairingKeypad(keyHeightDp = 24)) + if (Build.VERSION.SDK_INT >= 31) { + builder.setCustomContentView(pairingKeypad(keyHeightDp = 21)) + } + } + } } is Stage.Working -> builder .setContentTitle(getString(R.string.adbpair_title_working)) @@ -254,14 +306,39 @@ class WirelessAdbPairingService : Service() { return builder.build() } + private fun pairingKeypad(keyHeightDp: Int? = null): RemoteViews = RemoteViews(packageName, R.layout.wireless_pairing_keypad).apply { + val ids = intArrayOf(R.id.pair_key_0, R.id.pair_key_1, R.id.pair_key_2, R.id.pair_key_3, R.id.pair_key_4, + R.id.pair_key_5, R.id.pair_key_6, R.id.pair_key_7, R.id.pair_key_8, R.id.pair_key_9, + R.id.pair_key_delete, R.id.pair_key_submit) + ids.forEachIndexed { key, id -> + if (keyHeightDp != null && Build.VERSION.SDK_INT >= 31) { + // Fit both rows inside the system template's heads-up or collapsed height. + setViewLayoutHeight(id, keyHeightDp.toFloat(), TypedValue.COMPLEX_UNIT_DIP) + setViewLayoutMargin(id, RemoteViews.MARGIN_TOP, 1f, TypedValue.COMPLEX_UNIT_DIP) + setViewLayoutMargin(id, RemoteViews.MARGIN_BOTTOM, 1f, TypedValue.COMPLEX_UNIT_DIP) + setTextViewTextSize(id, TypedValue.COMPLEX_UNIT_SP, if (keyHeightDp < 24) 14f else 15f) + } + val intent = Intent(this@WirelessAdbPairingService, WirelessAdbPairingService::class.java) + .setAction(ACTION_KEYPAD) + .setData(Uri.Builder().scheme("droiddeck-pairing").authority(keypadToken).appendPath(key.toString()).build()) + val press = PendingIntent.getService(this@WirelessAdbPairingService, key, intent, PendingIntent.FLAG_IMMUTABLE) + setOnClickPendingIntent(id, press) + } + setTextViewText(R.id.pair_key_code, keypad.display) + setContentDescription(R.id.pair_key_code, getString(R.string.adbpair_keypad_entered, keypad.digits.length)) + setBoolean(R.id.pair_key_delete, "setEnabled", keypad.digits.isNotEmpty()) + setBoolean(R.id.pair_key_submit, "setEnabled", keypad.ready && pairingPort != null) + } + companion object { private const val CHANNEL_ID = "wireless-adb-pairing" private const val PROGRESS_CHANNEL_ID = "wireless-adb-pairing-progress" private const val NOTIFICATION_ID = 3 + private const val KEYPAD_NOTIFICATION_ID = 3403 + private const val KEYPAD_GROUP = "wireless-adb-keypad" private const val PAIRING_TYPE = "_adb-tls-pairing._tcp" - private const val ACTION_CODE = "com.droiddeck.launcher.action.WIRELESS_ADB_CODE" + private const val ACTION_KEYPAD = "com.droiddeck.launcher.action.WIRELESS_ADB_KEYPAD" private const val ACTION_CANCEL = "com.droiddeck.launcher.action.WIRELESS_ADB_CANCEL" - private const val KEY_CODE = "code" private const val EXTRA_ENABLE_LIMIT = "enable_limit" private const val TIMEOUT_MS = 5 * 60_000L @@ -288,7 +365,7 @@ class WirelessAdbPairingService : Service() { fun notificationsEnabled(context: Context): Boolean = context.getSystemService(NotificationManager::class.java)?.areNotificationsEnabled() != false && !channelBlocked(context) - /** The code is typed into a notification on this channel; a channel the user switched off leaves pairing with nothing to type into. */ + /** Pairing needs this notification channel to show the keypad over Android Settings. */ fun channelBlocked(context: Context): Boolean = context.getSystemService(NotificationManager::class.java)?.getNotificationChannel(CHANNEL_ID)?.importance == NotificationManager.IMPORTANCE_NONE diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessPairingKeypad.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessPairingKeypad.kt new file mode 100644 index 0000000000..942911a78d --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessPairingKeypad.kt @@ -0,0 +1,29 @@ +package com.droiddeck.launcher.core + +internal class WirelessPairingKeypad { + var digits = "" + private set + val ready: Boolean get() = digits.length == LENGTH + val display: String get() = digits.padEnd(LENGTH, '–') + + fun press(key: Int): Boolean { + val next = when { + key == DELETE -> digits.dropLast(1) + key in 0..9 && !ready -> digits + key + else -> digits + } + if (next == digits) return false + digits = next + return true + } + + fun clear() { + digits = "" + } + + companion object { + const val LENGTH = 6 + const val DELETE = 10 + const val SUBMIT = 11 + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt b/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt index de95eea354..94ea2e33f9 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt @@ -8,9 +8,27 @@ import android.os.Environment import android.provider.Settings object AllFilesAccess { + private val VOLUME = Regex("^(/storage/emulated/\\d+|/storage/[^/]+|/sdcard)(/.*)?$") + private val APP_FOLDERS = listOf("/Android/data", "/Android/obb") + fun missing(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean = sdk >= Build.VERSION_CODES.R && !granted() + fun state(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): String = when { + sdk < Build.VERSION_CODES.R -> "not needed" + granted() -> "granted" + else -> "missing" + } + + fun mayHideFilesIn(path: String, sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean = + covers(path) && missing(sdk, granted) + + /** Whether reading [path] takes all-files access: shared storage, outside the per-app folders directly under a volume's root, which Android always lets the app use. */ + fun covers(path: String): Boolean { + val inside = VOLUME.matchEntire(path)?.groupValues?.get(2) ?: return false + return APP_FOLDERS.none { inside == it || inside.startsWith("$it/") } + } + fun open(context: Context) { val app = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:" + context.packageName)) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) diff --git a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt index 7025769d87..c872096533 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/FileManagerScreen.kt @@ -504,13 +504,15 @@ fun FileManagerScreen( } val drives = remember(storageTick) { StorageRoots.list(context) } var accessDrive by remember { mutableStateOf(null) } + var accessWasMissing by remember { mutableStateOf(AllFilesAccess.missing()) } + var accessDeclined by remember { mutableStateOf(false) } fun unreadable(drive: StorageRoot) { if (AllFilesAccess.missing()) accessDrive = drive.label else Toast.makeText(context, context.getString(R.string.fm_drive_not_readable, drive.label), Toast.LENGTH_SHORT).show() } accessDrive?.let { label -> OutlinedAlertDialog( - onDismissRequest = { accessDrive = null }, + onDismissRequest = { accessDrive = null; accessDeclined = true }, title = { Text(stringResource(R.string.fm_drive_access_title, label)) }, text = { Text(stringResource(R.string.fm_drive_access_text)) }, confirmButton = { @@ -519,9 +521,17 @@ fun FileManagerScreen( AllFilesAccess.open(context) }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.upd_open_settings)) } }, - dismissButton = { TextButton(onClick = { accessDrive = null }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } }, + dismissButton = { TextButton(onClick = { accessDrive = null; accessDeclined = true }, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } }, ) } + LaunchedEffect(currentDir, storageTick) { + if (!AllFilesAccess.missing()) { + if (accessWasMissing) { accessWasMissing = false; loadDirectory(currentDir, resetScroll = false, record = false) } + } else { + accessWasMissing = true + if (!accessDeclined && accessDrive == null && AllFilesAccess.covers(currentDir.path)) accessDrive = drives.firstOrNull { currentDir.path.startsWith(it.dir.path) }?.label ?: context.getString(R.string.fm_drive_internal) + } + } val linuxRoot = remember(storageTick) { com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context).takeIf { File(it, "usr").isDirectory } } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt index 7009e0e68f..b26c2536cc 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt @@ -233,14 +233,14 @@ object AddedGames { if (folder.name.lowercase() in steamInstalls || isSteamLibraryFolder(folder.name)) continue if (folder.path in removed) continue if (folder.name == "Games" && StoreInstallRoot.roots(context).any { it.absolutePath == folder.absolutePath }) continue - for (game in expand(folder, entries, reuse = true)) if (game.path !in removed) scanGame(context, game, out, reuse = true) + timed(folder) { for (game in expand(folder, entries, reuse = true)) if (game.path !in removed) scanGame(context, game, out, reuse = true) } } } for (entry in AddedExes.list(context)) { val folder = File(entry.folder) if (folder.path in removed || !folder.isDirectory) continue if (StoreGameSidecar.read(folder)?.isInstalled == false) continue - scanGame(context, folder, out, single = entry, reuse = true) + timed(folder) { scanGame(context, folder, out, single = entry, reuse = true) } } for (folder in libraryDepotInstalls(context)) if (folder.path !in removed) scanGame(context, folder, out, reuse = true) for (folder in StoreInstallRoot.gameFolders(context)) if (StoreInstallRoot.isFinished(folder)) scanGame(context, folder, out, reuse = true) @@ -250,6 +250,15 @@ object AddedGames { return out.distinctBy { it.folder.canonicalPath } } + private const val SLOW_FOLDER_MS = 1_000L + + private inline fun timed(folder: File, block: () -> Unit) { + val began = android.os.SystemClock.elapsedRealtime() + block() + val took = android.os.SystemClock.elapsedRealtime() - began + if (took >= SLOW_FOLDER_MS) Log.i(TAG, "games: scanning ${folder.path} took ${took}ms") + } + fun single(context: Context, folderPath: String, reuse: Boolean = false): Game? { val folder = File(folderPath) if (!folder.isDirectory || folderPath in SessionPrefs.removedAddedGames(context)) return null @@ -490,6 +499,7 @@ object AddedGames { launchOptions = when { sidecar == null -> SessionPrefs.addedGameLaunch(context, folder.path) sidecar.store == Store.UBISOFT -> com.droiddeck.launcher.stores.ubisoft.UbisoftConnect.launchOptions(context) + sidecar.store == Store.EA -> SessionPrefs.addedGameLaunch(context, folder.path) else -> "" }, single = single != null, steamProgram = steamProgram)) @@ -564,8 +574,10 @@ object AddedGames { class Listed(val appId: Long, val name: String, val launchOptions: String) + fun listingFile(context: Context): File = File(context.filesDir, "session/added-games.json") + fun listed(context: Context): List? = runCatching { - val file = File(context.filesDir, "session/added-games.json") + val file = listingFile(context) if (!file.isFile) return null val entries = org.json.JSONArray(file.readText()) (0 until entries.length()).mapNotNull { i -> @@ -575,7 +587,7 @@ object AddedGames { fun writeListing(context: Context, games: List, extra: List = listOfNotNull(com.droiddeck.launcher.stores.epic.EpicClient.steamListing(context))): File { - val file = File(context.filesDir, "session/added-games.json").apply { parentFile?.mkdirs() } + val file = listingFile(context).apply { parentFile?.mkdirs() } val json = StringBuilder("[") games.forEachIndexed { i, g -> if (i > 0) json.append(',') @@ -596,10 +608,24 @@ object AddedGames { if (games.isNotEmpty() || i > 0) json.append(',') json.append(entry.toString()) } - file.writeText(json.append(']').toString()) + val text = json.append(']').toString() + synchronized(listing) { + val partial = File(file.parentFile, file.name + ".part") + try { + partial.writeText(text) + java.nio.file.Files.move(partial.toPath(), file.toPath(), + java.nio.file.StandardCopyOption.ATOMIC_MOVE, java.nio.file.StandardCopyOption.REPLACE_EXISTING) + } catch (e: java.io.IOException) { + Log.w(TAG, "games: listing not replaced: ${e.message}") + partial.delete() + if (!file.isFile) file.writeText(text) + } + } return file } + private val listing = Any() + private fun artGuestPath(context: Context, file: File): String? { val files = context.filesDir.absolutePath if (file.absolutePath.startsWith("$files/")) return file.absolutePath diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt index c70b2a895a..f2a4ef27e3 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGamesPublisher.kt @@ -1,17 +1,31 @@ package com.droiddeck.launcher.frontend import android.content.Context +import android.os.SystemClock import android.util.Log import androidx.annotation.VisibleForTesting +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.stores.SteamLiveShortcuts +import java.io.File +import java.util.concurrent.Callable import java.util.concurrent.Executors object AddedGamesPublisher { private const val TAG = "AddedGamesPublisher" + private const val CLIENT_WAIT_MS = 600_000L + private const val POLL_MS = 1_000L + private const val RETRY_MS = 5_000L @VisibleForTesting @Volatile internal var now = false + @VisibleForTesting + @Volatile + internal var live: (Context, List, (AddedGames.Game) -> Boolean) -> Boolean = SteamLiveShortcuts::sync + private val worker = Executors.newSingleThreadExecutor { r -> Thread(r, "added-games-publish") } fun later(context: Context, live: () -> Unit = {}) { @@ -23,10 +37,56 @@ object AddedGamesPublisher { if (now) work.run() else worker.execute(work) } - fun republish(context: Context) { + fun republish(context: Context): List { val games = AddedGames.scan(context) AddedGames.writeListing(context, games) - val arch = com.droiddeck.launcher.session.SessionPrefs.activeSteamClientArch(context) + val arch = SessionPrefs.activeSteamClientArch(context) LibraryCache.save(context, Library.launchableGames(context, added = games, arch = arch), arch == "x86_64") + return games } + + fun sessionListing(context: Context): File { + val app = context.applicationContext + val started = AddedGames.listed(app)?.map { it.appId }?.toSet() + ?: return AddedGames.writeListing(app, AddedGames.scan(app).also { log(it) }) + val session = SessionState.sessionId + val work = Runnable { + try { + val began = SystemClock.elapsedRealtime() + val games = serial { republish(app) } + Log.i(TAG, "session refresh: ${games.size} game(s) in ${SystemClock.elapsedRealtime() - began} ms") + log(games) + val fresh = games.filter { (it.appId and 0xFFFFFFFFL) !in started } + if (fresh.isNotEmpty()) deliver(app, session, fresh) + } catch (e: Exception) { + Log.w(TAG, "session refresh: ${e.message}") + } + } + if (now) work.run() else Thread(work, "added-games-refresh").apply { priority = Thread.MIN_PRIORITY }.start() + return AddedGames.listingFile(app) + } + + internal fun log(games: List) { + if (games.isNotEmpty()) Log.i(TAG, "added games: " + games.joinToString { "${it.name} (${it.exe.name})" }) + } + + private fun deliver(app: Context, session: String?, games: List) { + val until = SystemClock.uptimeMillis() + CLIENT_WAIT_MS + while (current(session)) { + val ready = SessionState.phase == SessionPhase.READY + if (ready && serial { !current(session) || (SessionState.phase == SessionPhase.READY && syncUnremoved(app, games)) }) return + if (now || SystemClock.uptimeMillis() >= until) return + Thread.sleep(if (ready) RETRY_MS else POLL_MS) + } + } + + private fun current(session: String?): Boolean = + SessionState.running && !SessionState.stopRequested && SessionState.sessionId == session + + private fun syncUnremoved(app: Context, games: List): Boolean { + val removed = SessionPrefs.removedAddedGames(app).toSet() + return live(app, games) { it.folder.path !in removed } + } + + private fun serial(block: () -> T): T = if (now) block() else worker.submit(Callable { block() }).get() } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AutoComponents.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AutoComponents.kt index 4da77ee6d7..d54995703e 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AutoComponents.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AutoComponents.kt @@ -28,7 +28,8 @@ object AutoComponents { else -> game.appId.takeIf { it > 0 }?.toString() } - fun autoPicks(findings: List, catalog: Map): Map { + fun autoPicks(findings: List, catalog: Map, + user: Map = emptyMap()): Map { val out = LinkedHashMap() for (f in findings) { if (!f.auto || f.component == null) continue @@ -37,6 +38,13 @@ object AutoComponents { if (WinComponents.support(c, catalog) != WinComponents.Support.READY) continue if (id !in out) out[id] = WinComponents.AutoReason(f.origin.name, listOf(f.original) + f.args) } + if (user["d3dx9"] != false && (user["d3dx9"] == true || "d3dx9" in out)) { + val reason = out["d3dx9"] ?: WinComponents.AutoReason(WinCompSources.Origin.FOLDER.name, listOf("d3dx9")) + for (id in listOf("d3dcompiler_42", "d3dcompiler_43")) { + val c = catalog[id] ?: continue + if (WinComponents.support(c, catalog) == WinComponents.Support.READY) out.putIfAbsent(id, reason) + } + } return out } @@ -228,8 +236,8 @@ object AutoComponents { val findings = findings(context, game) val refreshed = if (knownCatalog == null && asked && online(context)) catalogOf(context, true) else null val catalog = knownCatalog ?: (refreshed ?: catalogOf(context, false) ?: catalogOf(context, true))?.associateBy { it.name } ?: return - val wanted = autoPicks(findings, catalog) val user = WinComponents.selection(context, key).user + val wanted = autoPicks(findings, catalog, user) val before = WinComponents.selection(context, key).auto val installed = installedOf(context) val kept = LinkedHashMap() @@ -373,7 +381,7 @@ object AutoComponents { private const val FINDINGS = "wincomp-findings.json" - private const val DETECTORS = "d3" + private const val DETECTORS = "d4" internal fun signature(context: Context, game: Library.SteamGame): String { val folder = game.gameFiles @@ -452,9 +460,9 @@ object AutoComponents { } return pendingSaved && pending.isEmpty() } - val wanted = autoPicks(findings, catalog) val selection = WinComponents.selection(context, key) val user = selection.user + val wanted = autoPicks(findings, catalog, user) val installed = installedOf(context) val roots = selection.effective + wanted.keys.filter { user[it] != false } val required = withParts(roots.filter { WinComponents.validId(it) }, catalog) diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/DependencyDetector.kt b/app/src/main/java/com/droiddeck/launcher/frontend/DependencyDetector.kt index 0983a29975..a9b0e16d4d 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/DependencyDetector.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/DependencyDetector.kt @@ -42,6 +42,7 @@ object DependencyDetector { "dotnet45" to ".NET Framework 4.5", "dotnet452" to ".NET Framework 4.5.2", "dotnet46" to ".NET Framework 4.6", "dotnet472" to ".NET Framework 4.7.2", "dotnet48" to ".NET Framework 4.8", "dotnet35" to ".NET Framework 3.5", + "dotnetcoredesktop3" to ".NET Desktop 3", "dotnet50" to ".NET 5", "dotnetcoredesktop6" to ".NET Desktop 6", "dotnetcoredesktop7" to ".NET Desktop 7", "dotnetcoredesktop8" to ".NET Desktop 8", ) @@ -50,7 +51,7 @@ object DependencyDetector { "vcredist2005", "vcredist2008", "vcredist2010", "vcredist2012", "vcredist2013", "vcredist2015", "vcredist2019", "vcredist2022", "dotnet35", "dotnet40", "dotnet45", "dotnet452", "dotnet46", "dotnet472", "dotnet48", - "dotnetcoredesktop6", "dotnetcoredesktop7", "dotnetcoredesktop8", + "dotnetcoredesktop3", "dotnet50", "dotnetcoredesktop6", "dotnetcoredesktop7", "dotnetcoredesktop8", "d3dx9", "d3dx11", "xact", "xact_x64", "xna31", "xna40", "physx", "oalinst", "XLiveRedist", ) @@ -148,7 +149,7 @@ object DependencyDetector { val comp = dotnetComponent("$path $name") return when { comp != null -> listOf(comp) - isDir -> emptyList() + isDir || CORE_RUNTIME.containsMatchIn(path) -> emptyList() else -> listOf("dotnet48") } } @@ -172,10 +173,20 @@ object DependencyDetector { private val D3DX11_RE = Regex("""d3dx11_\d+\.dll""") private val D3DCOMPILER_RE = Regex("""d3dcompiler_\d+\.dll""") - private fun dotnetComponent(s: String): String? = when { - s.contains("desktop-runtime-8") || Regex("""\b8\.\d""").containsMatchIn(s) -> "dotnetcoredesktop8" - s.contains("desktop-runtime-7") || Regex("""\b7\.\d""").containsMatchIn(s) -> "dotnetcoredesktop7" - s.contains("desktop-runtime-6") || Regex("""\b6\.\d""").containsMatchIn(s) -> "dotnetcoredesktop6" + private val CORE_RUNTIME = Regex("""(?:windowsdesktop|dotnet)-runtime-(\d+)\.""") + private val CORE_RUNTIMES = mapOf( + "3" to "dotnetcoredesktop3", "5" to "dotnet50", "6" to "dotnetcoredesktop6", "7" to "dotnetcoredesktop7", "8" to "dotnetcoredesktop8", + ) + + private fun dotnetComponent(s: String): String? { + CORE_RUNTIME.find(s)?.let { return CORE_RUNTIMES[it.groupValues[1]] } + return byVersion(s) + } + + private fun byVersion(s: String): String? = when { + s.contains("desktop-runtime-8") || Regex("""(? "dotnetcoredesktop8" + s.contains("desktop-runtime-7") || Regex("""(? "dotnetcoredesktop7" + s.contains("desktop-runtime-6") || Regex("""(? "dotnetcoredesktop6" s.contains("ndp48") || s.contains("fx48") || s.contains("4.8") -> "dotnet48" s.contains("ndp472") || s.contains("4.7.2") -> "dotnet472" s.contains("ndp46") || s.contains("4.6") -> "dotnet46" diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt index 2466c8df8b..2b1356b069 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameExePicker.kt @@ -51,11 +51,12 @@ object GameExePicker { val entries = dir.listFiles()?.sortedBy { it.name.lowercase() } ?: continue for (f in entries) { if (visited >= WALK_BUDGET) break@walk - if (isLink(f)) continue - if (f.isDirectory) { + val attrs = attributes(f) ?: continue + if (attrs.isSymbolicLink) continue + if (attrs.isDirectory) { visited++ if (depth < MAX_DEPTH && !skipDir(f, f.relativeTo(folder).invariantSeparatorsPath)) next.add(f) - } else if (f.isFile && f.name.endsWith(".exe", ignoreCase = true)) { + } else if (attrs.isRegularFile && f.name.endsWith(".exe", ignoreCase = true)) { visited++ if (!JUNK_EXE_RE.matches(f.nameWithoutExtension)) found.add(f to depth) } @@ -98,7 +99,9 @@ object GameExePicker { return SKIP_PATHS.any { rel == it || rel.endsWith("/$it") } } - private fun isLink(f: File): Boolean = runCatching { java.nio.file.Files.isSymbolicLink(f.toPath()) }.getOrDefault(false) + private fun attributes(f: File): java.nio.file.attribute.BasicFileAttributes? = runCatching { + java.nio.file.Files.readAttributes(f.toPath(), java.nio.file.attribute.BasicFileAttributes::class.java, java.nio.file.LinkOption.NOFOLLOW_LINKS) + }.getOrNull() private fun key(s: String) = s.lowercase().filter { it.isLetterOrDigit() } } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt b/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt index 3e5d4ae0dd..91349aa6f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/GameLaunchIntent.kt @@ -11,6 +11,10 @@ object GameLaunchIntent { fun accepts(action: String?): Boolean = action == Intent.ACTION_VIEW || action == ACTION || action == GAMENATIVE_ACTION + fun replayed(intent: Intent, restored: Boolean, savedProcess: String?, process: String): Boolean = + !(intent.data?.scheme == "droiddeck" && intent.data?.host == "settings") && + (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0 || restored && savedProcess != process) + fun read(context: Context, intent: Intent): GameRequest? = when (intent.action) { Intent.ACTION_VIEW -> GameFiles.readIntent(context, intent) ACTION, GAMENATIVE_ACTION -> readExtras(intent) diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt b/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt index 25124a6a52..2ae97cfc4f 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt @@ -10,11 +10,13 @@ object FrameGen { const val ENGINE_DDFG = "ddfg" private const val LEGACY_ENGINE_WINFG = "winfg" const val ENGINE_LSFG = "lsfg" + const val ENGINE_ZEROFG = "zerofg" private const val DDFG_PERF_PRESET = 2 private const val DDFG_MODEL = 4 private const val FLOW_SCALE_DDFG = 0.60f private const val FLOW_SCALE_LSFG = 0.80f + private const val FLOW_SCALE_ZEROFG = 1.0f val ADAPTIVE_TARGETS = listOf(120, 90, 60) @@ -69,6 +71,14 @@ object FrameGen { .putString("engine", mode.engine).putInt("multiplier", mode.multiplier).putInt("target", mode.target).apply() } + fun pacerEnabled(context: Context): Boolean = + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean("pacer", false) + + fun setPacer(context: Context, enabled: Boolean) { + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("pacer", enabled).apply() + WaylandCompositor.nativeSetFrameGenPacer(enabled) + } + fun clearGlobal(context: Context) { context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit() .remove("engine").remove("multiplier").remove("target").apply() @@ -80,6 +90,7 @@ object FrameGen { mode.engine == ENGINE_DDFG -> context.getString(R.string.frame_gen_ddfg, mode.multiplier) mode.engine == ENGINE_LSFG && mode.target > 0 -> context.getString(R.string.frame_gen_lsfg_adaptive, mode.target) mode.engine == ENGINE_LSFG -> context.getString(R.string.frame_gen_lsfg, mode.multiplier) + mode.engine == ENGINE_ZEROFG -> context.getString(R.string.frame_gen_zerofg, mode.multiplier) else -> context.getString(R.string.frame_gen_off) } @@ -104,6 +115,7 @@ object FrameGen { fun applyPrepared(context: Context, prepared: PreparedApply, refreshHz: Float): String? { val mode = prepared.mode + WaylandCompositor.nativeSetFrameGenPacer(pacerEnabled(context)) when (mode.engine) { ENGINE_LSFG -> { val status = prepared.lsfgStatus ?: LsfgNative.STATUS_NOT_INSTALLED @@ -111,7 +123,7 @@ object FrameGen { if (status != LsfgNative.STATUS_OK || cachePath == null) { WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0) val problem = context.getString( - if (status == LsfgNative.STATUS_NOT_INSTALLED) R.string.lsfg_problem_missing else R.string.lsfg_problem_failed, + if (status == LsfgNative.STATUS_NOT_INSTALLED) R.string.lsfg_needs_steam else R.string.lsfg_problem_failed, ) Log.w(TAG, "$problem (status $status)") return problem @@ -127,6 +139,11 @@ object FrameGen { WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_DDFG, refreshHz) WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0) } + ENGINE_ZEROFG -> { + WaylandCompositor.nativeSetFrameGenEngine(WaylandCompositor.FG_ENGINE_ZEROFG) + WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_ZEROFG, refreshHz) + WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0) + } else -> WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0) } Log.i(TAG, "frame generation: $mode at ${refreshHz}Hz") diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/Lossless.kt b/app/src/main/java/com/droiddeck/launcher/gpu/Lossless.kt index f78cb629ee..352885f558 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/Lossless.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/Lossless.kt @@ -2,22 +2,16 @@ package com.droiddeck.launcher.gpu import android.content.Context import android.util.Log -import com.droiddeck.launcher.R import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.GameStorage -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.security.DigestOutputStream import java.security.MessageDigest object Lossless { - enum class Source { NONE, STEAM, IMPORT } - - enum class ImportResult { UPDATED, UNCHANGED, NOT_OWNED, INVALID, FAILED } - - data class State(val owned: Boolean, val ready: Boolean, val source: Source) { + data class State(val owned: Boolean, val ready: Boolean) { companion object { - val NONE = State(owned = false, ready = false, source = Source.NONE) + val NONE = State(owned = false, ready = false) } } @@ -26,15 +20,13 @@ object Lossless { private const val KEY_OWNED = "owned" private const val KEY_ID = "id" private const val KEY_SOURCE = "source" + private const val SOURCE_STEAM = "STEAM" private const val KEY_STEAM_STAMP = "steamStamp" + private const val STEAM_MANIFEST = "steamapps/appmanifest_993090.acf" private const val STEAM_DLL = "steamapps/common/Lossless Scaling/Lossless.dll" private const val UNCHANGED = -1 - fun state(context: Context): State { - val source = prefs(context).getString(KEY_SOURCE, null) - ?.let { name -> Source.entries.firstOrNull { it.name == name } } ?: Source.NONE - return State(owned(context), cacheFile(context)?.isFile == true, source) - } + fun state(context: Context) = State(owned(context), cacheFile(context)?.isFile == true) fun owned(context: Context): Boolean { if (prefs(context).getBoolean(KEY_OWNED, false)) return true @@ -43,61 +35,46 @@ object Lossless { return true } - fun cacheFile(context: Context): File? = prefs(context).getString(KEY_ID, null)?.let { cacheFor(context, it) } + fun cacheFile(context: Context): File? = steamCacheId(context)?.let { cacheFor(context, it) } + + private fun steamCacheId(context: Context): String? = prefs(context).let { + if (it.getString(KEY_SOURCE, null) == SOURCE_STEAM) it.getString(KEY_ID, null) else null + } @Synchronized fun sync(context: Context): Int { + val settings = prefs(context) + if (steamCacheId(context) == null && settings.contains(KEY_ID)) { + settings.edit().remove(KEY_ID).remove(KEY_SOURCE).remove(KEY_STEAM_STAMP).apply() + } val steam = steamDll(context) if (steam != null) { markOwned(context) val stamp = "${steam.length()}:${steam.lastModified()}" - if (stamp != prefs(context).getString(KEY_STEAM_STAMP, null)) { - val status = adopt(context, steam, Source.STEAM) + if (stamp != settings.getString(KEY_STEAM_STAMP, null)) { + val status = adoptSteamDll(context, steam) if (status != LsfgNative.STATUS_OK && status != UNCHANGED) { Log.w(TAG, "Steam copy $steam not taken: ${statusName(status)}") } - prefs(context).edit().putString(KEY_STEAM_STAMP, stamp).apply() + settings.edit().putString(KEY_STEAM_STAMP, stamp).apply() } } return ensureBuilt(context) } - @Synchronized - fun import(context: Context, dll: File): ImportResult { - if (!owned(context)) return ImportResult.NOT_OWNED - return when (adopt(context, dll, Source.IMPORT)) { - UNCHANGED -> ImportResult.UNCHANGED - LsfgNative.STATUS_OK -> ImportResult.UPDATED - LsfgNative.STATUS_UNREADABLE_FILE, LsfgNative.STATUS_NOT_PORTABLE_EXECUTABLE, - LsfgNative.STATUS_MISSING_SHADERS -> ImportResult.INVALID - else -> ImportResult.FAILED - } - } - - fun message(context: Context, result: ImportResult): String = context.getString( - when (result) { - ImportResult.UPDATED -> R.string.lsfg_imported - ImportResult.UNCHANGED -> R.string.lsfg_import_unchanged - ImportResult.NOT_OWNED -> R.string.lsfg_import_not_owned - ImportResult.INVALID -> R.string.lsfg_import_invalid - ImportResult.FAILED -> R.string.lsfg_import_failed - }, - ) - private fun ensureBuilt(context: Context): Int { - val id = prefs(context).getString(KEY_ID, null) ?: return LsfgNative.STATUS_NOT_INSTALLED - val cache = cacheFor(context, id) + val cache = cacheFile(context) ?: return LsfgNative.STATUS_NOT_INSTALLED if (usable(cache)) return LsfgNative.STATUS_OK val dll = storedDll(context) if (!dll.isFile) return LsfgNative.STATUS_NOT_INSTALLED return build(dll, cache) } - private fun adopt(context: Context, source: File, from: Source): Int { + private fun adoptSteamDll(context: Context, source: File): Int { val staged = File(dir(context).apply { mkdirs() }, "Lossless.dll.staged") try { val id = copyHashing(source, staged) - if (id == prefs(context).getString(KEY_ID, null) && usable(cacheFor(context, id))) return UNCHANGED + if (id == steamCacheId(context) && usable(cacheFor(context, id))) return UNCHANGED val cache = cacheFor(context, id) var status = LsfgNative.nativeValidateDll(staged.path) if (status == LsfgNative.STATUS_OK) status = build(staged, cache) @@ -109,9 +86,9 @@ object Lossless { cache.delete() return LsfgNative.STATUS_CACHE_UNUSABLE } - prefs(context).edit().putString(KEY_ID, id).putString(KEY_SOURCE, from.name).apply() + prefs(context).edit().putString(KEY_ID, id).putString(KEY_SOURCE, SOURCE_STEAM).apply() removeStale(context, id) - Log.i(TAG, "Lossless.dll from $source ($from) ready as $id") + Log.i(TAG, "Steam Lossless.dll from $source ready as $id") return LsfgNative.STATUS_OK } catch (e: java.io.IOException) { Log.w(TAG, "could not copy $source", e) @@ -158,9 +135,13 @@ object Lossless { GameStorage.effective(context)?.path?.let(::File), GameStorage.x64CardLibrary(context), ) + com.droiddeck.launcher.frontend.AddedGames.roots(context).map { it.host } - return libraries.map { File(it, STEAM_DLL) }.filter { it.isFile }.maxByOrNull { it.lastModified() } + return installedSteamDll(libraries) } + internal fun installedSteamDll(libraries: List): File? = + libraries.asSequence().filter { File(it, STEAM_MANIFEST).isFile } + .map { File(it, STEAM_DLL) }.filter { it.isFile }.maxByOrNull { it.lastModified() } + private fun markOwned(context: Context) { if (!prefs(context).getBoolean(KEY_OWNED, false)) prefs(context).edit().putBoolean(KEY_OWNED, true).apply() } diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt b/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt index 25682ca064..7916c01467 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/SocNames.kt @@ -7,17 +7,21 @@ object SocNames { "SM8150" to "Snapdragon 855", "SM8250" to "Snapdragon 865", "SM8250-AC" to "Snapdragon 870", "SM8350" to "Snapdragon 888", "SM8450" to "Snapdragon 8 Gen 1", "SM8475" to "Snapdragon 8+ Gen 1", "SM8550" to "Snapdragon 8 Gen 2", "QCS8550" to "Snapdragon 8 Gen 2", "SM8650" to "Snapdragon 8 Gen 3", + "SM8635" to "Snapdragon 8s Gen 3", "SM8735" to "Snapdragon 8s Gen 4", "SM8750" to "Snapdragon 8 Elite", "SM8750P" to "Snapdragon 8 Elite", "SM8850" to "Snapdragon 8 Elite Gen 5", "SM8975" to "Snapdragon 8 Elite Extreme Gen 6", "SM7325" to "Snapdragon 778G", "SM7450" to "Snapdragon 7 Gen 1", "SM7550" to "Snapdragon 7 Gen 3", + "SM7675" to "Snapdragon 7+ Gen 3", "SM6375" to "Snapdragon 695", + // Handheld parts: AYANEO Pocket FIT (SG8350P), Retroid Pocket Duo (CQ7790S). + "SG8350P" to "Snapdragon G3 Gen 3", "CQ7790S" to "Dragonwing Q-7790", ) private val PLATFORMS = mapOf( "msmnile" to "Snapdragon 855/860", "kona" to "Snapdragon 865/870", "lahaina" to "Snapdragon 888", "taro" to "Snapdragon 8 Gen 1", "cape" to "Snapdragon 8+ Gen 1", "kalama" to "Snapdragon 8 Gen 2", - "pineapple" to "Snapdragon 8 Gen 3", "sun" to "Snapdragon 8 Elite", + "pineapple" to "Snapdragon 8 Gen 3", "sun" to "Snapdragon 8 Elite", "canoe" to "Snapdragon 8 Elite Gen 5", ) fun model(prop: (String) -> String = GpuInfo::systemProperty): String { @@ -30,8 +34,16 @@ object SocNames { internal fun normalizedModel(model: String): String = model.trim().uppercase().removePrefix("QTI ").trim() - fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? = - MODELS[normalizedModel(model)] ?: PLATFORMS[platform.lowercase()]?.let { "$it family" } + /** + * The exact model's name; the board platform's family only for an empty model or a phone "SM" part, since + * different chips share a platform (the Retroid Pocket Duo's CQ7790S and the Snapdragon 8 Elite are both "sun"). + */ + fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? { + val m = normalizedModel(model) + MODELS[m]?.let { return it } + if (m.isNotEmpty() && !m.startsWith("SM")) return null + return PLATFORMS[platform.lowercase()]?.let { "$it family" } + } // Without label's platform-family guess: a rebadged chip such as the Duo's CQ7790S reports a platform it is not. fun plainName(model: String = model(), maker: String = manufacturer()): String = diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt index 719aae8d7f..b7d95c4872 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudConfig.kt @@ -5,13 +5,13 @@ import com.droiddeck.launcher.session.SessionPrefs internal object DroidDeckHudConfig { val DEFAULTS: Map = linkedMapOf( - "hudSize" to "minimal", "hudLocked" to "1", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid", + "hudSize" to "minimal", "hudLocked" to "0", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid", "hudOutline" to "40", "hudOutlineAccent" to "1", "showGpuModel" to "1", "showGPULoad" to "1", "showCPUUsage" to "1", "showCPULoad" to "1", "showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0", "showVram" to "1", "showRAM" to "1", "showSwap" to "1", "showBattery" to "0", "showBatteryTime" to "0", "showPower" to "1", "showFPS" to "1", "showFPSGraph" to "1", "fpsDecimal" to "1", - "showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "1", "showLow001" to "1", + "showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "0", "showLow001" to "0", "showEngine" to "1", "showRenderer" to "1", "showDisplay" to "1", "showHdr" to "1", "showNet" to "1", "showResolution" to "1", "showProton" to "1", "showSession" to "1", "showClock" to "1", "hudOrder" to "", diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt index 94bcb2920f..91ee9877f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudModels.kt @@ -40,7 +40,8 @@ enum class DroidDeckHudSize(val token: String, val label: String) { PILL("pill", "Pill"), MINIMAL("minimal", "Minimal"), MEGA("mega", "Mega"), - STRIP("strip", "Strip"); + STRIP("strip", "Strip"), + SIDE_STRIP("side_strip", "Side strip"); fun next(): DroidDeckHudSize { val all = values() @@ -96,6 +97,11 @@ enum class DroidDeckHudSize(val token: String, val label: String) { "showCPUUsage", "showTemp", "showVram", "showRAM", "showBattery", "showBatteryTemp", "showBatteryTime", "showPower", "showDisplay", "showHdr", "showGpuModel", ), + SIDE_STRIP to listOf( + "showFPS", "showFPSGraph", "showAvg", "showLow1", + "showGPULoad", "showGpuTemp", "showCPUUsage", "showTemp", "showRAM", "showVram", + "showPower", "showBattery", "showBatteryTemp", "showBatteryTime", + ), ) @@ -110,6 +116,7 @@ enum class DroidDeckHudSize(val token: String, val label: String) { MEGA to DroidDeckHudStyle(row = 11.5f, unit = 11.5f * 0.62f, pad = 10f, lineGap = 3.5f, labelGap = 7f, band = 9.5f, gutter = 16f), STRIP to DroidDeckHudStyle(row = 11.5f, unit = 11.5f * 0.8f, pad = 10f, lineGap = 0f, labelGap = 13f), + SIDE_STRIP to DroidDeckHudStyle(row = 11.5f, unit = 9f, pad = 8f, lineGap = 4f, labelGap = 4f, key = 9f), ) fun rowsFor(size: DroidDeckHudSize, values: Map): List = diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt index bd04d149a2..c49ec88cdb 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudView.kt @@ -92,8 +92,8 @@ class DroidDeckHudView(context: Context) : View(context) { private var showBatteryTemp = false private var showGraph = false private var showLow1 = true - private var showLow01 = true - private var showLow001 = true + private var showLow01 = false + private var showLow001 = false private var fpsDecimal = true private var showClockTime = true private var showLatency = true @@ -187,6 +187,12 @@ class DroidDeckHudView(context: Context) : View(context) { private var graphRect: RectF? = null private var contentW = 0f private var contentH = 0f + private var viewportW = Float.POSITIVE_INFINITY + private var viewportH = Float.POSITIVE_INFINITY + + private val panelFit: Float + get() = if (dPanel == null || contentW <= 0f || contentH <= 0f) 1f + else minOf(1f, viewportW / contentW, viewportH / contentH) private var onMovedListener: BiConsumer? = null private var onSizeCycledListener: Consumer? = null @@ -349,7 +355,7 @@ class DroidDeckHudView(context: Context) : View(context) { showProton = switchOn("showProton") showSession = switchOn("showSession") tempDisplay = HudMetrics.TempDisplay.from(cfg) - lockController.setLocked(cfg.get("hudLocked", "1") == "1") + lockController.setLocked(cfg.get("hudLocked", "0") == "1") lockController.setHoldLocks(cfg.get("hudHold", "collapse") == DroidDeckHudConfig.HOLD_LOCKS) dock = DroidDeckHudDock.from(cfg.get("hudDock", "none")) @@ -567,6 +573,7 @@ class DroidDeckHudView(context: Context) : View(context) { if (s == null) { contentW = 0f; contentH = 0f; return } if (dock != DroidDeckHudDock.NONE) { buildDockTab(); return } if (size == DroidDeckHudSize.STRIP) { buildStrip(s); return } + if (size == DroidDeckHudSize.SIDE_STRIP) { buildSideStrip(s); return } buildRows(s) if (contentW <= 0f || contentH <= 0f) return if (size == DroidDeckHudSize.PILL) addSubtleClock(sp(10f), leftAligned = true) @@ -678,8 +685,8 @@ class DroidDeckHudView(context: Context) : View(context) { finishPanel(panel, halfRound = halfRound) } - private fun finishPanel(panel: RectF, halfRound: Boolean) { - val r = if (halfRound) panel.height() / 2f else min(panel.height() / 2f, sp(56f)) + private fun finishPanel(panel: RectF, halfRound: Boolean, maxRadius: Float = sp(56f), inset: Float = panelInset()) { + val r = if (halfRound) panel.height() / 2f else min(panel.height() / 2f, maxRadius) val margin = outlineWidth() + sp(4f) fun curveIn(top: Float, bottom: Float): Float { val d = max(max(panel.top + r - top, bottom - (panel.bottom - r)), 0f) @@ -697,8 +704,8 @@ class DroidDeckHudView(context: Context) : View(context) { for (t in tileRects) right = max(right, t.right + curveIn(t.top, t.bottom) + margin) panel.right = max(right, panel.left + sp(6f) + r) dPanel = panel; dRadius = r - contentW = panel.right + panelInset() - contentH = panel.bottom + panelInset() + contentW = panel.right + inset + contentH = panel.bottom + inset } private fun clockTimeString(): String = DateFormat.getTimeFormat(context).format(Date()) @@ -930,6 +937,58 @@ class DroidDeckHudView(context: Context) : View(context) { } } + private fun buildSideStrip(s: HudMetrics.Snapshot) { + val style = size.style + val inset = sp(5f) + val panelWidth = sp(86f) + val pad = sp(style.pad) + val left = inset + pad + val right = inset + panelWidth - pad + val markHeight = sp(12f) + val markTop = inset + sp(6f) + val markLeft = left - DroidDeckMark.inkLeftFor(markHeight) + headerMark = RectF(markLeft, markTop, markLeft + DroidDeckMark.widthFor(markHeight), markTop + markHeight) + dDividerTop = markTop + markHeight + sp(6f) + + if (showClockTime) { + val clock = clockTimeString() + val clockPx = sp(8.5f) + val clockWidth = measure(clock, clockPx) + if (right - clockWidth >= markLeft + DroidDeckMark.inkRightFor(markHeight) + sp(4f)) { + val baseline = markTop + (markHeight + capHeight(clockPx)) / 2f + glyphs.add(Glyph(right - clockWidth, baseline, clock, blend(colDim), clockPx)) + } + } + + val labelPx = sp(style.key) + val rowPx = sp(style.row) + val unitPx = sp(style.unit) + val lineGap = sp(style.lineGap) + var y = dDividerTop + sp(6f) + for (key in size.rowsIn(storedOrder)) { + if (!switchOn(key)) continue + if (key == "showFPSGraph") { + val height = sp(15f) + graphRect = RectF(left, y, right, y + height) + y += height + lineGap + continue + } + + val valuePx = if (key == "showFPS") sp(16f) else rowPx + val row = reading(key, s, labelPx, valuePx, unitPx) + val available = right - left - measure(row.label.text, labelPx) - sp(style.labelGap) + val fit = (available / runWidth(row.vals)).coerceIn(0f, 1f) + val values = row.vals.map { Span(it.text, it.color, it.sizePx * fit, it.glow) } + val baseline = y - ascent(valuePx) + placeRun(left, baseline, listOf(row.label)) + placeRun(right - runWidth(values), baseline, values) + y += lineH(valuePx) + lineGap + } + + val panel = RectF(inset, inset, inset + panelWidth, y + sp(7f)) + finishPanel(panel, halfRound = false, maxRadius = sp(11f), inset = inset) + } + private fun buildStrip(s: HudMetrics.Snapshot) { val rowPx = sp(11.5f); val unitPx = rowPx * 0.8f; val fpsPx = sp(15f) val padX = sp(10f); val groupGap = sp(13f) @@ -993,13 +1052,20 @@ class DroidDeckHudView(context: Context) : View(context) { } override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + viewportW = viewportLimit(widthMeasureSpec) + viewportH = viewportLimit(heightMeasureSpec) if (stripRect != null) { setMeasuredDimension(contentW.roundToInt(), resolveSize(contentH.roundToInt(), heightMeasureSpec)); return } + val fit = panelFit setMeasuredDimension( - resolveSize(contentW.roundToInt(), widthMeasureSpec), - resolveSize(contentH.roundToInt(), heightMeasureSpec), + resolveSize((contentW * fit).roundToInt(), widthMeasureSpec), + resolveSize((contentH * fit).roundToInt(), heightMeasureSpec), ) } + private fun viewportLimit(spec: Int): Float = + if (MeasureSpec.getMode(spec) == MeasureSpec.UNSPECIFIED) Float.POSITIVE_INFINITY + else MeasureSpec.getSize(spec).toFloat() + override fun onDraw(canvas: Canvas) { if (contentW <= 0f || contentH <= 0f) { lockController.drawBadge(canvas); return } val blend = if (dock == DroidDeckHudDock.NONE && previewEdge != DroidDeckHudDock.NONE) previewBlend else 0f @@ -1034,8 +1100,10 @@ class DroidDeckHudView(context: Context) : View(context) { } private fun drawContent(canvas: Canvas) { - - dPanel?.let { panel -> panelFrame(panel)?.let { canvas.drawBitmap(it, 0f, 0f, null) } } + val fit = panelFit + dPanel?.let { panel -> panelFrame(panel, fit)?.let { canvas.drawBitmap(it, 0f, 0f, null) } } + val saved = canvas.save() + if (fit != 1f) canvas.scale(fit, fit) if (tileRects.isNotEmpty()) { tilePaint.color = Color.argb((14 * bgOpacity).roundToInt().coerceIn(8, 40), 255, 255, 255) @@ -1065,6 +1133,7 @@ class DroidDeckHudView(context: Context) : View(context) { if (stripRect != null && layerType != LAYER_TYPE_SOFTWARE) drawCachedGraph(canvas, it) else drawGraph(canvas, it) } + canvas.restoreToCount(saved) lockController.drawBadge(canvas) } @@ -1177,13 +1246,14 @@ class DroidDeckHudView(context: Context) : View(context) { return if (dy <= 0f) p.right - stroke else if (dy >= r) cx else cx + sqrt(r * r - dy * dy) } - private fun panelFrame(panel: RectF): Bitmap? { + private fun panelFrame(panel: RectF, fit: Float): Bitmap? { if (width <= 0 || height <= 0) return null val stroke = outlineWidth() - val key = "$width,$height,$panel,$dRadius,$dDividerTop,$stroke,$accent,$surfaceRgb,$bgOpacity,${outlineColor()}" + val key = "$width,$height,$fit,$panel,$dRadius,$dDividerTop,$stroke,$accent,$surfaceRgb,$bgOpacity,${outlineColor()}" if (key == dFrameKey) dFrame?.let { return it } val bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) val c = Canvas(bmp) + c.scale(fit, fit) val corner = sp(6f) val body = dShape(panel.left, panel.top, panel.right, panel.bottom, dRadius, corner) bgPaint.color = panelColor() @@ -1256,8 +1326,8 @@ class DroidDeckHudView(context: Context) : View(context) { internal val isStrip: Boolean get() = stripRect != null - internal val contentWidth: Float get() = contentW - internal val contentHeight: Float get() = contentH + internal val contentWidth: Float get() = contentW * panelFit + internal val contentHeight: Float get() = contentH * panelFit internal val isDragging: Boolean get() = lockController.isDragging() || tabDragging diff --git a/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt b/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt index 54ae373ae2..3925109a28 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/BackQamInput.kt @@ -6,18 +6,15 @@ import android.os.Looper class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: (Boolean) -> Unit, private val doubleTapMs: () -> Long = { 500 }, private val onCancel: () -> Unit = {}, - private val holds: () -> Boolean = { true }) { + private val holds: () -> Boolean = { true }, atOnce: () -> Boolean = { false }, sameAction: () -> Boolean = { false }) { private class Press(val hold: Runnable, var held: Boolean = false, var used: Boolean = false) private val handler = Handler(Looper.getMainLooper()) private val presses = mutableMapOf() private val cancelled = mutableSetOf() - private var tapPending = false - private val singleTap = Runnable { tapPending = false; onTap(false) } + private val taps = BackTaps(doubleTapMs, atOnce, onTap, sameAction) + val awaitingTap: Boolean get() = taps.pending - private fun cancelTap() { - handler.removeCallbacks(singleTap) - tapPending = false - } + fun cancelTap() = taps.cancel() fun onChordInput() { if (presses.isEmpty()) return @@ -46,7 +43,7 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: cancelled.remove(device) if (!enabled || event.isCanceled) return false if (device in presses) return true - handler.removeCallbacks(singleTap) + taps.hold() val hold = Runnable { val press = presses[device] ?: return@Runnable if (!holds()) { press.used = true; cancelTap(); return@Runnable } @@ -66,10 +63,8 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: if (press != null) { handler.removeCallbacks(press.hold) if (press.held && presses.values.none { it.held }) setPressed(false) - if (!press.used && !event.isCanceled) { - if (tapPending) { cancelTap(); onTap(true) } - else { tapPending = true; handler.postDelayed(singleTap, doubleTapMs()) } - } else if (event.isCanceled) cancelTap() + if (!press.used && !event.isCanceled) taps.tap() + else if (event.isCanceled) cancelTap() } press != null || wasCancelled || enabled } @@ -77,8 +72,8 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap: } } - fun cancel() { - cancelTap() + fun cancel(keepTap: Boolean = false) { + if (!keepTap) cancelTap() val wasHeld = presses.values.any { it.held } presses.values.forEach { handler.removeCallbacks(it.hold) } cancelled.addAll(presses.keys) diff --git a/app/src/main/java/com/droiddeck/launcher/input/BackTaps.kt b/app/src/main/java/com/droiddeck/launcher/input/BackTaps.kt new file mode 100644 index 0000000000..4328148bea --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/BackTaps.kt @@ -0,0 +1,39 @@ +package com.droiddeck.launcher.input + +import android.os.Handler +import android.os.Looper + +class BackTaps( + private val windowMs: () -> Long, + private val atOnce: () -> Boolean, + private val onTap: (Boolean) -> Unit, + private val sameAction: () -> Boolean = { false }, +) { + private val handler = Handler(Looper.getMainLooper()) + private var deferred = false + var pending = false + private set + private val expire = Runnable { + pending = false + if (deferred) onTap(false) + } + + fun tap() { + if (pending) { + cancel() + if (deferred || !sameAction()) onTap(true) + return + } + pending = true + deferred = !atOnce() + handler.postDelayed(expire, windowMs()) + if (!deferred) onTap(false) + } + + fun hold() = handler.removeCallbacks(expire) + + fun cancel() { + handler.removeCallbacks(expire) + pending = false + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/input/ControllerPortraitGeometry.kt b/app/src/main/java/com/droiddeck/launcher/input/ControllerPortraitGeometry.kt index 907d71c70d..d6958f7b17 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/ControllerPortraitGeometry.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/ControllerPortraitGeometry.kt @@ -46,7 +46,14 @@ internal class ControllerPortraitGeometry( } row(shoulders, top + pad + buttonHeight / 2f, buttonHeight, 4f * unit) var bodyTop = top + pad + buttonHeight + gap - if (presented.any { it.control in REAR && isStock(it) }) { + if (presented.any { it.control in REAR && isStock(it) } && docked) { + val chipHeight = 36f * unit + val cell = (w - 2f * pad - 5f * gap) / 6f + listOf(0, 1, 4, 5).zip(REAR).forEach { (index, control) -> + put(control, Box(safe.left + pad + cell / 2f + index * (cell + gap), bodyTop + chipHeight / 2f, cell, chipHeight)) + } + bodyTop += chipHeight + gap + } else if (presented.any { it.control in REAR && isStock(it) }) { val rearHeight = min(56f * unit, (panel - bodyTop + top) * .12f).coerceAtLeast(buttonHeight) row(REAR, bodyTop + rearHeight / 2f, rearHeight, gap) bodyTop += rearHeight + gap diff --git a/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt b/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt index 5231a753ac..73782d7e63 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/ControllerPrefs.kt @@ -19,8 +19,9 @@ object ControllerPrefs { ) val opacities = listOf(40, 60, 80, 100) + val onScreenOpacityRange = 10..100 - val sizes = listOf(80, 90, 100, 110, 125) + val sizes = listOf(80, 85, 90, 95, 100, 105, 110, 115, 120, 125) val deadZones = listOf(0, 5, 8, 12, 15, 20, 25) const val DEFAULT_DEAD_ZONE_PERCENT = 12 @@ -45,6 +46,7 @@ object ControllerPrefs { val size: Int, val stickClick: Boolean, val adaptiveSticks: Boolean, + val onScreenOpacity: Int, val rumble: Boolean, val steamButton: Boolean, val qamButton: Boolean, @@ -66,7 +68,8 @@ object ControllerPrefs { opacity = p.getInt("opacity", 100).takeIf { it in opacities } ?: 100, size = p.getInt("size", 100).takeIf { it in sizes } ?: 100, stickClick = p.getBoolean("stickClick", true), - adaptiveSticks = p.getBoolean("adaptiveSticks", true), + adaptiveSticks = p.getBoolean("adaptiveSticks", false), + onScreenOpacity = onScreenOpacity(context), rumble = rumbleEnabled(context), steamButton = p.getBoolean("steamButton", true), qamButton = p.getBoolean("qamButton", true), @@ -103,6 +106,13 @@ object ControllerPrefs { prefs(context).edit().putBoolean("stickClick", on).apply() } + fun onScreenOpacity(context: Context): Int = + prefs(context).getInt("onScreenOpacity", 100).coerceIn(onScreenOpacityRange) + + fun setOnScreenOpacity(context: Context, percent: Int) { + prefs(context).edit().putInt("onScreenOpacity", percent.coerceIn(onScreenOpacityRange)).apply() + } + fun setAdaptiveSticks(context: Context, on: Boolean) { prefs(context).edit().putBoolean("adaptiveSticks", on).apply() } diff --git a/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt b/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt index 7a64caaac6..db78da807f 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/DirectTouchHold.kt @@ -2,6 +2,7 @@ package com.droiddeck.launcher.input import android.os.Handler import android.os.Looper +import android.os.SystemClock import android.view.MotionEvent import kotlin.math.abs @@ -24,6 +25,7 @@ class DirectTouchHold( private var delayMs = 0L private var holdBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK private var forwarded = false + private var forwardedAt = 0L private var held = false private var pressing = false private var upX = 0f @@ -125,8 +127,11 @@ class DirectTouchHold( upX = event.x upY = event.y liftId = event.getPointerId(event.actionIndex) - liftPending = true - handler.postDelayed(lift, LIFT_MS) + val wait = MIN_PRESS_MS - (SystemClock.uptimeMillis() - forwardedAt) + if (wait > 0L) { + liftPending = true + handler.postDelayed(lift, wait) + } else lift.run() } MotionEvent.ACTION_CANCEL -> cancel() } @@ -136,9 +141,10 @@ class DirectTouchHold( private fun forwardDown() { touch.down(downId, downX, downY) forwarded = true + forwardedAt = SystemClock.uptimeMillis() } private companion object { - const val LIFT_MS = 50L + const val MIN_PRESS_MS = 50L } } diff --git a/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java b/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java index dc847e90ad..8d4cde566b 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java +++ b/app/src/main/java/com/droiddeck/launcher/input/FakeInputWriter.java @@ -149,6 +149,8 @@ public class FakeInputWriter { private static native void nativeStoreFence(); + private static native void nativeWake(ByteBuffer ring, int offset); + public static void storeFence() { nativeStoreFence(); } @@ -455,6 +457,7 @@ public class FakeInputWriter { writeSnapshotLocked(ring); nativeStoreFence(); ring.putLong(RING_WRITE_SEQ_OFFSET, writeSeq); + nativeWake(ring, RING_WRITE_SEQ_OFFSET); } return true; } diff --git a/app/src/main/java/com/droiddeck/launcher/input/HeldInput.kt b/app/src/main/java/com/droiddeck/launcher/input/HeldInput.kt index 1fdb6121fc..41cf641275 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/HeldInput.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/HeldInput.kt @@ -2,14 +2,24 @@ package com.droiddeck.launcher.input class HeldInput(private val emit: (Int, Boolean) -> Unit) { private val owners = IntArray(768) + private val ordered = arrayOfNulls<(Int, Boolean) -> Unit>(768) @Synchronized - fun set(source: Int, code: Int, down: Boolean) { + fun set(source: Int, code: Int, down: Boolean, orderedEmit: ((Int, Boolean) -> Unit)? = null) { if (code !in owners.indices) return val before = owners[code] val after = if (down) before or source else before and source.inv() owners[code] = after - if ((before == 0) != (after == 0)) emit(code, after != 0) + if ((before == 0) != (after == 0)) { + if (after != 0) { + ordered[code] = orderedEmit + orderedEmit?.invoke(code, true) ?: emit(code, true) + } else { + val fn = ordered[code] + ordered[code] = null + fn?.invoke(code, false) ?: emit(code, false) + } + } } @Synchronized @@ -21,7 +31,9 @@ class HeldInput(private val emit: (Int, Boolean) -> Unit) { fun clear() { for (code in owners.indices) if (owners[code] != 0) { owners[code] = 0 - emit(code, false) + val fn = ordered[code] + ordered[code] = null + fn?.invoke(code, false) ?: emit(code, false) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/input/InputLibraries.kt b/app/src/main/java/com/droiddeck/launcher/input/InputLibraries.kt index 4683aece97..8bb6470edb 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/InputLibraries.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/InputLibraries.kt @@ -156,7 +156,13 @@ object InputLibraries { update(context) { library -> library.copy(layouts = library.layouts.map { layout -> if (layout.id != layoutId || !layout.editable) layout - else layout.copy(elements = layout.elements.map { if (it.kind == InputElementKind.STICK) it.copy(floating = on, hideWhenIdle = on) else it }) + else { + fun updateSticks(elements: List) = elements.map { + if (it.kind == InputElementKind.STICK) it.copy(floating = on, hideWhenIdle = it.hideStickAtRest, adaptiveCapture = on) + else it + } + layout.copy(elements = updateSticks(layout.elements), rotated = updateSticks(layout.rotated)) + } }) } }.onSuccess { ControllerPrefs.setAdaptiveSticks(context, on) }.isSuccess @@ -328,7 +334,8 @@ object InputLibraries { for (e in list) elements.put(JSONObject().put("id", e.id).put("kind", e.kind.name) .put("control", e.control.id).put("name", e.name).put("x", e.x.toDouble()).put("y", e.y.toDouble()) .put("width", e.width.toDouble()).put("height", e.height.toDouble()).put("floating", e.floating).put("hideWhenIdle", e.hideWhenIdle).put("mouseGestures", e.mouseGestures).put("toggle", e.toggle).put("icon", e.icon).put("image", e.image) - .put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown)) + .put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown) + .put("adaptiveCapture", e.adaptiveCapture)) } private fun decodeElements(array: JSONArray) = array.objects(64).map { e -> @@ -336,7 +343,8 @@ object InputLibraries { e.getDouble("y").toFloat(), e.getDouble("width").toFloat(), e.getDouble("height").toFloat(), e.getString("id"), InputElementKind.valueOf(e.getString("kind")), e.getString("name"), e.optBoolean("floating", true), e.optBoolean("hideWhenIdle", false), e.optBoolean("mouseGestures", false), e.optBoolean("toggle", false), e.optInt("icon", 0), e.optString("image", ""), - e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false)) + e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false), + if (e.isNull("adaptiveCapture")) null else e.optBoolean("adaptiveCapture", false)) } internal fun encode(library: InputLibrary): String { diff --git a/app/src/main/java/com/droiddeck/launcher/input/InputLibrary.kt b/app/src/main/java/com/droiddeck/launcher/input/InputLibrary.kt index 9532f51778..54b394a31c 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/InputLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/InputLibrary.kt @@ -32,7 +32,7 @@ data class SavedInputLayout( fun withQuickButton(button: InputCommand, shown: Boolean) = copy(style = style.copy(hidden = if (shown) style.hidden - button else style.hidden + button)) fun derived(id: String, name: String) = copy(id = id, name = name, origin = origin ?: this.id) - val adaptiveSticks get() = elements.filter { it.kind == InputElementKind.STICK }.takeIf { editable && it.isNotEmpty() }?.all { it.floating && it.hideWhenIdle } + val adaptiveSticks get() = elements.filter { it.kind == InputElementKind.STICK }.takeIf { editable && it.isNotEmpty() }?.all { it.adaptiveStick } fun supports(role: InputRole) = screen.supports(role) && when (template) { InputLayoutTemplate.OVERLAY -> role == InputRole.PRIMARY InputLayoutTemplate.DECK, InputLayoutTemplate.TRACKPAD -> role == InputRole.SECONDARY diff --git a/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt b/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt index f17076e7ca..e988c39d92 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/InputProfile.kt @@ -21,7 +21,7 @@ enum class InputControl(val id: String, val label: String, val dimensions: Int = } } -enum class InputCommand { MENU, KEYBOARD, STEAM, QUICK_ACCESS } +enum class InputCommand { MENU, KEYBOARD, STEAM, QUICK_ACCESS, GAME_ZOOM_IN, GAME_ZOOM_OUT } sealed interface InputAction { data class Native(val target: InputControl? = null) : InputAction diff --git a/app/src/main/java/com/droiddeck/launcher/input/InputSurfaceLayout.kt b/app/src/main/java/com/droiddeck/launcher/input/InputSurfaceLayout.kt index 888e9bc260..e85c51ee2c 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/InputSurfaceLayout.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/InputSurfaceLayout.kt @@ -37,7 +37,12 @@ data class InputSurfaceElement( val buttonShape: InputButtonShape = InputButtonShape.ROUNDED, val showLabel: Boolean = true, val alwaysShown: Boolean = false, + val adaptiveCapture: Boolean? = null, ) { + // Old layouts encoded Adaptive sticks as Floating + Hide when idle. + val adaptiveStick get() = kind == InputElementKind.STICK && floating && (adaptiveCapture ?: hideWhenIdle) + val hideStickAtRest get() = hideWhenIdle && (adaptiveCapture != null || !adaptiveStick) + val hasClick get() = kind == InputElementKind.STICK || kind == InputElementKind.TRACKPAD fun bounded() = copy(x = x.coerceIn(0f, 0.97f), y = y.coerceIn(0f, 0.97f), diff --git a/app/src/main/java/com/droiddeck/launcher/input/KeyboardHost.kt b/app/src/main/java/com/droiddeck/launcher/input/KeyboardHost.kt index 5372be6db5..a9549c9918 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/KeyboardHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/KeyboardHost.kt @@ -4,7 +4,6 @@ import android.app.Activity import android.content.Context import android.os.Build import android.text.InputType -import android.view.KeyCharacterMap import android.view.KeyEvent import android.view.View import android.view.WindowInsets @@ -12,15 +11,17 @@ import android.view.inputmethod.BaseInputConnection import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputConnection import android.view.inputmethod.InputMethodManager +import com.droiddeck.launcher.wayland.WaylandCompositor class KeyboardHost( context: Context, private val sendKeyEvent: (KeyEvent) -> Boolean, + private val sendText: (String) -> Unit, ) : View(context) { - constructor(activity: Activity) : this(activity, { activity.dispatchKeyEvent(it) }) + constructor(activity: Activity) : + this(activity, { activity.dispatchKeyEvent(it) }, { WaylandCompositor.textInputCommit(it) }) private val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - private val map: KeyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD) var shown = false private set var imeShowing = false @@ -40,8 +41,7 @@ class KeyboardHost( override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? { if (!shown) return null - outAttrs.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS or - InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD + outAttrs.inputType = InputType.TYPE_CLASS_TEXT outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE or EditorInfo.IME_FLAG_NO_FULLSCREEN or EditorInfo.IME_FLAG_NO_EXTRACT_UI return KeyConnection() @@ -93,45 +93,153 @@ class KeyboardHost( fun type(text: CharSequence?) { if (text.isNullOrEmpty()) return - val events = map.getEvents(text.toString().toCharArray()) - if (events != null) { - for (event in events) sendKeyEvent(event) - } else { - for (ch in text) { - val t = System.currentTimeMillis() - val down = KeyEvent(t, t, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_UNKNOWN, 0, 0, - KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, 0) - sendKeyEvent(CharKeyEvent(down, ch)) - sendKeyEvent(CharKeyEvent(KeyEvent.changeAction(down, KeyEvent.ACTION_UP), ch)) - } - } + // Text and soft editing actions share this queue to preserve IME ordering. + sendText(text.toString()) } fun tap(keyCode: Int) { + val control = softControl(keyCode) + if (control != null) { + sendText(control.toString()) + return + } val t = System.currentTimeMillis() sendKeyEvent(KeyEvent(t, t, KeyEvent.ACTION_DOWN, keyCode, 0)) sendKeyEvent(KeyEvent(t, t, KeyEvent.ACTION_UP, keyCode, 0)) } private inner class KeyConnection : BaseInputConnection(this, false) { + // A press keeps the route chosen on its first down across repeats and the matching up. + private val controlRoutes = HashMap() + + private var composingText = "" + private var composingCursor = 0 + override fun commitText(text: CharSequence?, newCursorPosition: Int): Boolean { + composingText = "" + composingCursor = 0 type(text) return true } - override fun setComposingText(text: CharSequence?, newCursorPosition: Int): Boolean = true - override fun finishComposingText(): Boolean = true - - override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean { - repeat(beforeLength) { tap(KeyEvent.KEYCODE_DEL) } - repeat(afterLength) { tap(KeyEvent.KEYCODE_FORWARD_DEL) } + override fun setComposingText(text: CharSequence?, newCursorPosition: Int): Boolean { + composingText = text?.toString().orEmpty() + val rawCursor = if (newCursorPosition > 0) { + composingText.length.toLong() + newCursorPosition - 1L + } else { + newCursorPosition.toLong() + } + composingCursor = rawCursor.coerceIn(0L, composingText.length.toLong()).toInt() return true } - override fun sendKeyEvent(event: KeyEvent): Boolean = this@KeyboardHost.sendKeyEvent(event) + override fun finishComposingText(): Boolean { + val text = composingText + composingText = "" + composingCursor = 0 + type(text) + return true + } + + override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean { + val before = beforeLength.coerceAtLeast(0) + val after = afterLength.coerceAtLeast(0) + if (before == 0 && after == 0) return true + val consumedBefore = minOf(before, composingCursor) + val consumedAfter = minOf(after, composingText.length - composingCursor) + val guestBefore = before - consumedBefore + val guestAfter = after - consumedAfter + if (guestBefore > 1 || guestAfter > 1) return false + return applyDeletion( + composingCursor - consumedBefore, + composingCursor + consumedAfter, + guestBefore, + guestAfter, + ) + } + + override fun deleteSurroundingTextInCodePoints(beforeLength: Int, afterLength: Int): Boolean { + val before = beforeLength.coerceAtLeast(0) + val after = afterLength.coerceAtLeast(0) + if (before == 0 && after == 0) return true + if (splitsPair(composingCursor)) return false + val text = composingText + val beforePoints = Character.codePointCount(text, 0, composingCursor) + val afterPoints = Character.codePointCount(text, composingCursor, text.length) + val consumedBefore = minOf(before, beforePoints) + val consumedAfter = minOf(after, afterPoints) + val start = Character.offsetByCodePoints(text, composingCursor, -consumedBefore) + val end = Character.offsetByCodePoints(text, composingCursor, consumedAfter) + if (hasUnpairedSurrogate(text, start, end)) return false + return applyDeletion( + start, + end, + before - consumedBefore, + after - consumedAfter, + ) + } + + private fun applyDeletion(start: Int, end: Int, guestBefore: Int, guestAfter: Int): Boolean { + if (guestBefore > 64 || guestAfter > 64) return false + if (splitsPair(start) || splitsPair(end)) return false + if (start < end) { + composingText = composingText.removeRange(start, end) + composingCursor = start + } + val controls = StringBuilder() + repeat(guestBefore) { controls.append(BACKSPACE) } + repeat(guestAfter) { controls.append(FORWARD_DELETE) } + if (controls.isNotEmpty()) sendText(controls.toString()) + return true + } + + private fun splitsPair(index: Int): Boolean = + index > 0 && index < composingText.length && + composingText[index - 1].isHighSurrogate() && composingText[index].isLowSurrogate() + + private fun hasUnpairedSurrogate(text: CharSequence, start: Int, end: Int): Boolean { + var i = start + while (i < end) { + val c = text[i] + if (c.isHighSurrogate()) { + if (i + 1 >= end || !text[i + 1].isLowSurrogate()) return true + i += 2 + } else if (c.isLowSurrogate()) { + return true + } else { + i++ + } + } + return false + } + + override fun sendKeyEvent(event: KeyEvent): Boolean { + val control = softControl(event.keyCode) + if (control == null) return this@KeyboardHost.sendKeyEvent(event) + if (event.action == KeyEvent.ACTION_DOWN) { + val soft = if (event.repeatCount == 0) { + val route = !event.isModified() + controlRoutes[event.keyCode] = route + route + } else { + controlRoutes[event.keyCode] ?: !event.isModified() + } + if (!soft) return this@KeyboardHost.sendKeyEvent(event) + if (control == ENTER) finishComposingText() + sendText(control.toString()) + return true + } + if (event.action == KeyEvent.ACTION_UP) { + val soft = controlRoutes.remove(event.keyCode) ?: !event.isModified() + if (soft) return true + return this@KeyboardHost.sendKeyEvent(event) + } + return this@KeyboardHost.sendKeyEvent(event) + } override fun performEditorAction(actionCode: Int): Boolean { - tap(KeyEvent.KEYCODE_ENTER) + finishComposingText() + sendText(ENTER.toString()) return true } @@ -140,8 +248,22 @@ class KeyboardHost( override fun getSelectedText(flags: Int): CharSequence? = null } - private class CharKeyEvent(origin: KeyEvent, private val ch: Char) : KeyEvent(origin) { - override fun getUnicodeChar(): Int = ch.code - override fun getUnicodeChar(metaState: Int): Int = ch.code + private fun softControl(keyCode: Int): Char? = when (keyCode) { + KeyEvent.KEYCODE_DEL -> BACKSPACE + KeyEvent.KEYCODE_FORWARD_DEL -> FORWARD_DELETE + KeyEvent.KEYCODE_ENTER -> ENTER + KeyEvent.KEYCODE_TAB -> TAB + else -> null + } + + private fun KeyEvent.isModified(): Boolean = + isCtrlPressed || isShiftPressed || isAltPressed || isMetaPressed + + private companion object { + // Control characters represent editing keys on the guest text channel. + const val ENTER = '\r' + const val BACKSPACE = '\b' + const val FORWARD_DELETE = '\u007f' + const val TAB = '\t' } } diff --git a/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt b/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt index a944ec28ef..003357cb75 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/LegacyGamepadLayout.kt @@ -5,7 +5,7 @@ import android.graphics.Rect import kotlin.math.* internal class LegacyGamepadLayout(private val context: Context, private val width: Int, private val height: Int, private val safe: Rect = Rect(), - private val scale: Float = 1f) { + private val scale: Float = 1f, private val sizeOverride: Int? = null) { private val resources get() = context.resources private val settings = ControllerPrefs.read(context) private var fit = 1f @@ -41,7 +41,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid private fun dp(value: Float) = value * resources.displayMetrics.density - private fun scaled(value: Float) = dp(value) * settings.size / 100f * scale * fit + private fun scaled(value: Float) = dp(value) * (sizeOverride ?: settings.size) / 100f * scale * fit private fun fitScale(): Float { val metrics = resources.displayMetrics @@ -188,7 +188,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid settings.mapping[it.id] != ControllerPrefs.OFF && (it.id != "guide" || settings.steamButton) && (it.id != "qam" || settings.qamButton) }.map { c -> InputSurfaceElement(requireNotNull(InputControl.fromId(c.id)), (c.cx - c.halfW) / width, (c.cy - c.halfH) / height, - 2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, hideWhenIdle = c.stick >= 0 && settings.adaptiveSticks, + 2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, adaptiveCapture = if (c.stick >= 0) settings.adaptiveSticks else null, buttonShape = if (c.id in shoulderIds) InputButtonShape.PILL else InputButtonShape.CIRCLE).let { if (previousStickGeometry) widenStickPreviously(it) else widenStick(it) }.bounded() }.toMutableList() if (settings.keyboardButton) result += keyboard() diff --git a/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt b/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt index ad5d8e2701..6cef661a5f 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/OnScreenLayout.kt @@ -36,6 +36,15 @@ object OnScreenLayout { fun elements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect, buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null, trackpads: Boolean? = null): List { + val placed = placeElements(context, saved, width, height, safe, buttonsOnly, dock, rearButtons, trackpads) + // Docked sticks stay visible and only pick up touches inside their own bounds. + return if (dock == null) placed else placed.map { + if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false, adaptiveCapture = false) else it + } + } + + private fun placeElements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect, + buttonsOnly: Boolean, dock: Dock?, rearButtons: Boolean?, trackpads: Boolean?): List { if (saved == null) return emptyList() if (width <= 0 || height <= 0) return saved.elements val layout = oriented(saved, dock?.portrait ?: (height > width)) @@ -44,7 +53,7 @@ object OnScreenLayout { val (reference, matched) = reference(context, layout, width, height) if (buttonsOnly && dock == null) return generator.buttonsOnly(stored) + fit(stored.filter { it.alwaysShown }, reference.first, reference.second, width, height, safe) if (dock?.portrait == true && !dock.grips && !matched && layout.aspect > 0f && layout.aspect < 1f && stored.any(::isGamepad)) - return cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe) + return scaleDocked(context, cluster(stored.filterNot { it.alwaysShown || isGamepad(it) && (it.id == KEYBOARD_ID || it.control in BAR) }, layout.aspect, width, height, safe), ControllerPrefs.read(context).size / 100f, width, height, safe) val generated = matched || PadKit.forOverlay(context, layout) != null && stored.any(::isGamepad) && (dock != null || height > width && layout.aspect >= 1f || height <= width && layout.aspect > 0f && layout.aspect < 1f) val gamepad = if (generated) stored.filter(::isGamepad) else emptyList() @@ -57,22 +66,144 @@ object OnScreenLayout { val placed = regenerated + gamepad.filter { g -> dock == null && optional(g) && regenerated.none { it.id == g.id } } val byId = (placed + others).associateBy { it.id } val ordered = stored.mapNotNull { byId[it.id] } + placed.filter { p -> stored.none { it.id == p.id } } - val kit = PadKit.forOverlay(context, layout) ?: return ordered + val kit = PadKit.forOverlay(context, layout) ?: return if (dock == null) ordered else scaleDocked(context, ordered, ControllerPrefs.read(context).size / 100f, width, height, safe) + val controllerScale = layout.scale * ControllerPrefs.read(context).size / 100f if (generated && ControllerPrefs.layout(context, reference.first.toInt(), reference.second.toInt()).isEmpty() && ControllerPrefs.layout(context, width, height).isEmpty()) { if (dock != null || height > width) { - return ControllerPortraitGeometry(width.toFloat(), height.toFloat(), safe, context.resources.displayMetrics.density) - .place(ordered, kit, dock != null, layout.scale, rearButtons == true, trackpads == true) + val placed = ControllerPortraitGeometry(width.toFloat(), height.toFloat(), safe, context.resources.displayMetrics.density) + .place(ordered, kit, dock != null, controllerScale, rearButtons == true, trackpads == true) + return if (dock != null) { + scaleDocked(context, placed, ControllerPrefs.read(context).size / 100f, width, height, safe) + } else placed } - return ControllerOverlayGeometry(width, height, safe, context.resources.displayMetrics, layout.scale) + return ControllerOverlayGeometry(width, height, safe, context.resources.displayMetrics, controllerScale) .place(ordered, kit, rearButtons == true, trackpads == true) } - if (dock != null || !kit.steam) return ordered + if (dock != null || !kit.steam) { + if (dock == null) return ordered + return scaleDocked(context, ordered, ControllerPrefs.read(context).size / 100f, width, height, safe) + } return FloatingSteamOverlay(width, height, safe, context.resources.displayMetrics.density) .place(ordered, lowerShortcuts = generated, rearButtons = rearButtons, trackpads = trackpads) } + private fun scaleDocked(context: Context, elements: List, scale: Float, width: Int, height: Int, safe: Rect): List { + val usableWidth = (width - safe.left - safe.right).coerceAtLeast(1).toFloat() / width + val usableHeight = (height - safe.top - safe.bottom).coerceAtLeast(1).toFloat() / height + val leftBound = safe.left.toFloat() / width + val rightBound = (width - safe.right).toFloat() / width + val topBound = safe.top.toFloat() / height + val bottomBound = (height - safe.bottom).toFloat() / height + val scaled = elements.map { element -> + if (!isGamepad(element)) return@map element + val w = (element.width * scale).coerceIn(min(.001f, usableWidth), usableWidth) + val h = (element.height * scale).coerceIn(min(.001f, usableHeight), usableHeight) + val x = (element.x + element.width / 2f - w / 2f) + .coerceIn(leftBound, (rightBound - w).coerceAtLeast(leftBound)) + val y = (element.y + element.height / 2f - h / 2f) + .coerceIn(topBound, (bottomBound - h).coerceAtLeast(topBound)) + element.copy(x = x, y = y, width = w, height = h) + }.toMutableList() + if (scale > 1f) { + val gap = 4f / width + fun spacePair(leftControl: InputControl, rightControl: InputControl) { + val li = scaled.indexOfFirst { isGamepad(it) && it.control == leftControl } + val ri = scaled.indexOfFirst { isGamepad(it) && it.control == rightControl } + if (li < 0 || ri < 0) return + var left = scaled[li] + var right = scaled[ri] + val available = (rightBound - leftBound).coerceAtLeast(.001f) + var gapSize = gap.coerceAtMost(available / 4f) + if (left.width + right.width + gapSize > available) { + val factor = ((available - gapSize).coerceAtLeast(0f) / (left.width + right.width)).coerceAtMost(1f) + left = left.copy(width = left.width * factor) + right = right.copy(width = right.width * factor) + } + val total = left.width + gapSize + right.width + val center = ((left.x + left.width / 2f) + (right.x + right.width / 2f)) / 2f + val start = (center - total / 2f).coerceIn(leftBound, (rightBound - total).coerceAtLeast(leftBound)) + scaled[li] = left.copy(x = start) + scaled[ri] = right.copy(x = start + left.width + gapSize) + } + spacePair(InputControl.LT, InputControl.LB) + spacePair(InputControl.RB, InputControl.RT) + } + if (scale > 1f && ControllerPrefs.layout(context, width, height).isEmpty()) { + repeat(scaled.size) { + for (i in scaled.indices) { + if (!isGamepad(scaled[i])) continue + for (j in i + 1 until scaled.size) { + if (!isGamepad(scaled[j])) continue + val a = scaled[i] + val b = scaled[j] + val overlapX = min(a.x + a.width, b.x + b.width) - max(a.x, b.x) + val overlapY = min(a.y + a.height, b.y + b.height) - max(a.y, b.y) + if (overlapX <= 0f || overlapY <= 0f) continue + + val centerAX = a.x + a.width / 2f + val centerBX = b.x + b.width / 2f + val centerAY = a.y + a.height / 2f + val centerBY = b.y + b.height / 2f + if (overlapX / min(a.width, b.width) <= overlapY / min(a.height, b.height)) { + val gapX = 2f / width + val available = (rightBound - leftBound).coerceAtLeast(.001f) + val leftFirst = centerAX <= centerBX + val factor = ((available - gapX).coerceAtLeast(0f) / (a.width + b.width)).coerceIn(0f, 1f) + val aw = a.width * factor + val ah = a.height * factor + val bw = b.width * factor + val bh = b.height * factor + val total = aw + gapX + bw + val center = ((centerAX + centerBX) / 2f).coerceIn( + leftBound + total / 2f, + (rightBound - total / 2f).coerceAtLeast(leftBound + total / 2f)) + val firstX = center - total / 2f + val secondX = firstX + (if (leftFirst) aw else bw) + gapX + scaled[i] = if (leftFirst) { + a.copy(x = firstX, y = centerAY - ah / 2f, width = aw, height = ah) + } else { + a.copy(x = secondX, y = centerAY - ah / 2f, width = aw, height = ah) + } + scaled[j] = if (leftFirst) { + b.copy(x = secondX, y = centerBY - bh / 2f, width = bw, height = bh) + } else { + b.copy(x = firstX, y = centerBY - bh / 2f, width = bw, height = bh) + } + } else { + val gapY = 2f / height + val available = (bottomBound - topBound).coerceAtLeast(.001f) + val topFirst = centerAY <= centerBY + val factor = ((available - gapY).coerceAtLeast(0f) / (a.height + b.height)).coerceIn(0f, 1f) + val aw = a.width * factor + val ah = a.height * factor + val bw = b.width * factor + val bh = b.height * factor + val total = ah + gapY + bh + val center = ((centerAY + centerBY) / 2f).coerceIn( + topBound + total / 2f, + (bottomBound - total / 2f).coerceAtLeast(topBound + total / 2f)) + val firstY = center - total / 2f + val secondY = firstY + (if (topFirst) ah else bh) + gapY + scaled[i] = if (topFirst) { + a.copy(x = centerAX - aw / 2f, y = firstY, width = aw, height = ah) + } else { + a.copy(x = centerAX - aw / 2f, y = secondY, width = aw, height = ah) + } + scaled[j] = if (topFirst) { + b.copy(x = centerBX - bw / 2f, y = secondY, width = bw, height = bh) + } else { + b.copy(x = centerBX - bw / 2f, y = firstY, width = bw, height = bh) + } + } + } + } + } + } + return scaled + } + fun oriented(layout: SavedInputLayout, width: Int, height: Int): SavedInputLayout = oriented(layout, height > width) private fun oriented(layout: SavedInputLayout, portrait: Boolean): SavedInputLayout { @@ -181,7 +312,14 @@ object OnScreenLayout { ?.let { (it * height).roundToInt().coerceAtLeast(1) to height } for ((w, h) in listOfNotNull(named, width to height, aspectSize, long to short, short to long).distinct()) { val generator = LegacyGamepadLayout(display, w, h, scale = layout.scale) - if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true))) return (w.toFloat() to h.toFloat()) to true + val sizedGenerator = LegacyGamepadLayout( + display, w, h, scale = layout.scale, + sizeOverride = ControllerPrefs.read(context).size + ) + if (matches(gamepad, generator.elements()) || matches(gamepad, generator.elements(previousStickGeometry = true)) || + matches(gamepad, sizedGenerator.elements()) || matches(gamepad, sizedGenerator.elements(previousStickGeometry = true))) { + return (w.toFloat() to h.toFloat()) to true + } } } val aspect = layout.aspect.takeIf { it > 0f } ?: (long.toFloat() / short) diff --git a/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java b/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java index 666a9d1ceb..81a84fcdba 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java +++ b/app/src/main/java/com/droiddeck/launcher/input/PadBridge.java @@ -59,7 +59,7 @@ public final class PadBridge { private final PadState[] playerStates = new PadState[SLOTS]; private final float[][] rawSticks = new float[SLOTS][4]; private final Map rightStickLayouts = new HashMap<>(); - private final boolean[][] keyTriggers = new boolean[SLOTS][2]; + private final TriggerKey[][] keyTriggers = TriggerKey.slots(SLOTS); private final int[] retainedSticks = new int[SLOTS]; private final PadState effectiveState = new PadState(); private final PadState homeGuideReport = new PadState(); @@ -273,7 +273,8 @@ public final class PadBridge { static boolean isSystemVirtualInputName(String name) { if (name == null) return false; String lower = name.trim().toLowerCase(java.util.Locale.ROOT); - return lower.startsWith("uinput-") || lower.startsWith("uinput_"); + // Xiaomi's "ui-input-xiaomi" is a system uinput device that also reports gamepad sources. + return lower.startsWith("uinput-") || lower.startsWith("uinput_") || lower.equals("ui-input-xiaomi"); } public static boolean isFromController(InputDevice device) { @@ -483,7 +484,7 @@ public final class PadBridge { stateFor(slot).clear(); retainedSticks[slot] = 0; Arrays.fill(rawSticks[slot], 0f); - Arrays.fill(keyTriggers[slot], false); + for (TriggerKey key : keyTriggers[slot]) key.reset(); } private void mutateState(java.util.function.Consumer mutation) { @@ -529,7 +530,7 @@ public final class PadBridge { float lx = event.getAxisValue(MotionEvent.AXIS_X); float ly = event.getAxisValue(MotionEvent.AXIS_Y); boolean wired = wiredXboxLayout(device, event.getSource()); - boolean rxRyStick = rightStickUsesRxRy(event, device, rightStickLayouts); + boolean rxRyStick = Boolean.TRUE.equals(rightStickUsesRxRy(event, device, rightStickLayouts)); float rx = event.getAxisValue(rxRyStick ? MotionEvent.AXIS_RX : MotionEvent.AXIS_Z); float ry = event.getAxisValue(rxRyStick ? MotionEvent.AXIS_RY : MotionEvent.AXIS_RZ); retainStick(slot, JoyCon.LEFT, lx, ly); @@ -569,26 +570,76 @@ public final class PadBridge { return true; } - static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, boolean[] held, int side) { + static final class TriggerKey { + static final float RELEASE_FROM_PEAK = 0.05f; + boolean held; + boolean handoff; + boolean axisLive; + boolean axisMovedWhilePressed; + float peak; + float axis; + + static TriggerKey[][] slots(int count) { + TriggerKey[][] keys = new TriggerKey[count][2]; + for (TriggerKey[] pair : keys) { + pair[0] = new TriggerKey(); + pair[1] = new TriggerKey(); + } + return keys; + } + + void reset() { + held = false; + handoff = false; + axisLive = false; + axisMovedWhilePressed = false; + peak = 0f; + axis = 0f; + } + } + + static float keyTrigger(float current, boolean pressed, int repeatCount, boolean analog, TriggerKey[] keys, int side) { + TriggerKey key = keys[side]; if (repeatCount > 0) return current; if (!analog) { - held[side] = pressed; + key.held = pressed; return pressed ? 1f : 0f; } if (pressed) { - if (current != 0f) return current; - held[side] = true; + key.axisMovedWhilePressed = false; + if (key.axisLive || current != 0f) return current; + key.held = true; return 1f; } - if (!held[side]) return current; - held[side] = false; + if (!key.axisMovedWhilePressed) key.axisLive = false; + if (key.handoff) { + key.handoff = false; + return key.axis; + } + if (!key.held) return current; + key.held = false; return 0f; } - static float axisTrigger(float value, boolean[] held, int side) { - if (!held[side]) return value; - if (value == 0f) return 1f; - held[side] = false; + static float axisTrigger(float value, TriggerKey[] keys, int side) { + TriggerKey key = keys[side]; + key.axis = value; + if (value != 0f) { + key.axisLive = true; + key.axisMovedWhilePressed = true; + } + if (key.held) { + if (value == 0f) return 1f; + key.held = false; + key.handoff = true; + key.peak = value; + return 1f; + } + if (key.handoff) { + key.peak = Math.max(key.peak, value); + if (value > key.peak - TriggerKey.RELEASE_FROM_PEAK) return 1f; + key.handoff = false; + } return value; } @@ -603,14 +654,14 @@ public final class PadBridge { return false; } - static boolean rightStickUsesRxRy(MotionEvent event, InputDevice device, Map layouts) { + public static Boolean rightStickUsesRxRy(MotionEvent event, InputDevice device, Map layouts) { int source = event.getSource(); if (wiredXboxLayout(device, source)) return true; boolean hasRxRy = hasAxis(device, source, MotionEvent.AXIS_RX) && hasAxis(device, source, MotionEvent.AXIS_RY); boolean hasZRz = hasAxis(device, source, MotionEvent.AXIS_Z) && hasAxis(device, source, MotionEvent.AXIS_RZ); - if (!hasRxRy) return false; + if (!hasRxRy) return hasZRz ? false : null; if (!hasZRz) return true; Boolean cached = layouts.get(event.getDeviceId()); if (cached != null) return cached; @@ -618,7 +669,7 @@ public final class PadBridge { && nearCentre(device, source, event, MotionEvent.AXIS_RX, MotionEvent.AXIS_RY); boolean zRzEvidence = atMinimum(device, source, event, MotionEvent.AXIS_RX, MotionEvent.AXIS_RY) && nearCentre(device, source, event, MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ); - if (rxRyEvidence == zRzEvidence) return false; + if (rxRyEvidence == zRzEvidence) return null; boolean useRxRy = rxRyEvidence; layouts.put(event.getDeviceId(), useRxRy); return useRxRy; diff --git a/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt b/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt index dccba8a1b6..8f21ad67de 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/PadMouse.kt @@ -90,7 +90,7 @@ class PadMouse(private val listener: Listener, private val clock: () -> Long = S val sticks = physical.getOrPut(event.deviceId) { Sticks() } val device = event.device val wired = wiredLayout.getOrPut(event.deviceId) { PadBridge.wiredXboxLayout(device, event.source) } - val rxRyStick = PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts) + val rxRyStick = PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts) ?: false sticks.leftX = event.getAxisValue(MotionEvent.AXIS_X) sticks.leftY = event.getAxisValue(MotionEvent.AXIS_Y) sticks.rightX = scrollAxis(event, if (rxRyStick) MotionEvent.AXIS_RX else MotionEvent.AXIS_Z) diff --git a/app/src/main/java/com/droiddeck/launcher/input/PointerCapture.kt b/app/src/main/java/com/droiddeck/launcher/input/PointerCapture.kt new file mode 100644 index 0000000000..d598a1bc05 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/PointerCapture.kt @@ -0,0 +1,33 @@ +package com.droiddeck.launcher.input + +import android.view.InputDevice +import android.view.MotionEvent + +object PointerCapture { + fun accepts(event: MotionEvent): Boolean = + event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE) || + event.isFromSource(InputDevice.SOURCE_TOUCHPAD) + + fun isTouchpad(event: MotionEvent): Boolean = event.isFromSource(InputDevice.SOURCE_TOUCHPAD) + + fun delta(event: MotionEvent): FloatArray { + var dx = event.x + var dy = event.y + for (i in 0 until event.historySize) { + dx += event.getHistoricalX(i) + dy += event.getHistoricalY(i) + } + return floatArrayOf(dx, dy) + } + + fun touchpadScale(unitsPerMm: Float, padWidth: Float, pixelsPerMm: Float, screenWidth: Int): Float = when { + unitsPerMm > 0f && pixelsPerMm > 0f -> pixelsPerMm / unitsPerMm + padWidth > 0f && screenWidth > 0 -> screenWidth / padWidth + else -> 1f + } + + fun touchpadScale(event: MotionEvent, pixelsPerMm: Float, screenWidth: Int): Float { + val range = event.device?.getMotionRange(MotionEvent.AXIS_X, InputDevice.SOURCE_TOUCHPAD) + return touchpadScale(range?.resolution ?: 0f, range?.range ?: 0f, pixelsPerMm, screenWidth) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/input/RedMagicAirTriggers.kt b/app/src/main/java/com/droiddeck/launcher/input/RedMagicAirTriggers.kt new file mode 100644 index 0000000000..051e745945 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/RedMagicAirTriggers.kt @@ -0,0 +1,324 @@ +package com.droiddeck.launcher.input + +import android.content.Context +import android.content.SharedPreferences +import android.net.Uri +import android.os.Build +import android.os.Handler +import android.os.IBinder +import android.os.Looper +import android.os.Parcel +import android.provider.Settings +import android.util.Log +import android.view.InputDevice +import android.view.KeyEvent +import java.util.EnumMap +import java.util.EnumSet +import java.util.concurrent.Executor +import java.util.concurrent.LinkedBlockingQueue +import java.util.concurrent.ThreadPoolExecutor +import java.util.concurrent.TimeUnit +import org.json.JSONObject + +enum class AirTrigger(val keyCode: Int, val control: InputControl, val pressLight: Int, val releaseLight: Int) { + LEFT(KeyEvent.KEYCODE_F7, InputControl.LT, 106, 107), RIGHT(KeyEvent.KEYCODE_F8, InputControl.RT, 108, 109); + + companion object { + private const val DEVICE_PREFIX = "nubia_tgk" + + internal fun isTriggerDevice(device: InputDevice?): Boolean { + if (device == null) return false + if (device.name.startsWith(DEVICE_PREFIX)) return true + // Some RedMagic firmware merges the trigger sensors with an unnamed built-in keyboard. + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && + device.name.isEmpty() && !device.isVirtual && !device.isExternal && + device.supportsSource(InputDevice.SOURCE_KEYBOARD) && + device.hasKeys(LEFT.keyCode, RIGHT.keyCode).all { it } + } + + internal fun of(keyCode: Int, device: InputDevice?): AirTrigger? = + entries.firstOrNull { it.keyCode == keyCode }?.takeIf { isTriggerDevice(device) } + } +} + +/** Game Space's single tap holds the button while the trigger is touched; its long press latches it until the next touch. */ +enum class AirTriggerAction { TAP, LATCH, RAPID } + +/** Game Space's rapid fire counts for its low, normal and high click frequency. */ +enum class RapidFireRate(val clicksPerSecond: Int) { LOW(2), NORMAL(5), HIGH(10) } + +/** Game Space's touch atmosphere lamp cases, by their name in RedMagic's shoulder light settings. */ +enum class AirTriggerLed(val effect: String, val fallback: String) { + OFF("close", "02000000"), STEADY("steady", "02101000"), PULSE("pulse", "02102000") +} + +data class AirTriggerSetup( + val element: InputSurfaceElement, + val action: AirTriggerAction = AirTriggerAction.TAP, + val rate: RapidFireRate = RapidFireRate.NORMAL, +) { + /** Long press and rapid fire decide when the button is let go, so they press a toggle button as a plain one. */ + internal val target get() = if (action != AirTriggerAction.TAP && element.toggle) element.copy(toggle = false) else element +} + +object AirTriggerButtons { + fun options(layout: SavedInputLayout?): List { + val placed = layout?.let { (it.elements + it.rotated).distinctBy { element -> element.id } }.orEmpty() + .filter { it.kind == InputElementKind.BUTTON || it.kind == InputElementKind.TRIGGER } + return placed + AirTrigger.entries.filter { trigger -> placed.none { it.control == trigger.control } } + .map { InputSurfaceElement(it.control, 0f, 0f, 0f, 0f) } + } + + fun resolve(layout: SavedInputLayout?, trigger: AirTrigger, chosen: String?): InputSurfaceElement { + val options = options(layout) + return chosen?.let { id -> options.firstOrNull { it.id == id } } ?: options.first { it.control == trigger.control } + } +} + +object AirTriggerPrefs { + private const val FILE = "redmagic-air-triggers" + private const val ENABLED = "enabled" + private const val VIBRATION = "vibration" + private const val SCREEN_LIGHT = "screen-light" + private const val LED = "led" + internal const val OWNED = "distribute-owned" + + fun prefs(context: Context): SharedPreferences = context.getSharedPreferences(FILE, Context.MODE_PRIVATE) + fun enabled(context: Context) = prefs(context).getBoolean(ENABLED, false) + fun setEnabled(context: Context, on: Boolean) = prefs(context).edit().putBoolean(ENABLED, on).apply() + fun button(context: Context, layoutId: String, trigger: AirTrigger): String? = prefs(context).getString(key(layoutId, trigger), null) + fun setButton(context: Context, layoutId: String, trigger: AirTrigger, elementId: String) = + prefs(context).edit().putString(key(layoutId, trigger), elementId).apply() + fun action(context: Context, layoutId: String, trigger: AirTrigger) = read(context, key(layoutId, trigger, "action"), AirTriggerAction.TAP) + fun setAction(context: Context, layoutId: String, trigger: AirTrigger, action: AirTriggerAction) = + prefs(context).edit().putString(key(layoutId, trigger, "action"), action.name).apply() + fun rate(context: Context, layoutId: String, trigger: AirTrigger) = read(context, key(layoutId, trigger, "rate"), RapidFireRate.NORMAL) + fun setRate(context: Context, layoutId: String, trigger: AirTrigger, rate: RapidFireRate) = + prefs(context).edit().putString(key(layoutId, trigger, "rate"), rate.name).apply() + fun vibration(context: Context) = prefs(context).getBoolean(VIBRATION, false) + fun setVibration(context: Context, on: Boolean) = prefs(context).edit().putBoolean(VIBRATION, on).apply() + fun screenLight(context: Context) = prefs(context).getBoolean(SCREEN_LIGHT, false) + fun setScreenLight(context: Context, on: Boolean) = prefs(context).edit().putBoolean(SCREEN_LIGHT, on).apply() + fun led(context: Context) = read(context, LED, AirTriggerLed.STEADY) + fun setLed(context: Context, led: AirTriggerLed) = prefs(context).edit().putString(LED, led.name).apply() + + private inline fun > read(context: Context, key: String, default: E): E = + prefs(context).getString(key, null)?.let { name -> enumValues().firstOrNull { it.name == name } } ?: default + + private fun key(layoutId: String, trigger: AirTrigger, setting: String? = null) = + listOfNotNull(trigger.name.lowercase(), setting).joinToString("-") + ".$layoutId" +} + +/** Game Space's exported provider switches the triggers to plain F7/F8 keys without its panel, and needs no permission. */ +object RedMagicAirTriggers { + private const val TAG = "AirTriggers" + private const val AUTHORITY = "cn.nubia.tgk.data.TgkDataProvider" + private val URI = Uri.parse("content://$AUTHORITY") + private const val OPEN = "openTouchGameKeyDistribute" + private const val CLOSE = "closeTouchGameKeyDistribute" + private const val SHOULDER_LIGHT_ON = 110 + private const val SHOULDER_LIGHT_OFF = 111 + private const val SHOULDER_SETTINGS = "lighting_shoulder_config_json" + private val REAPPLY_MS = longArrayOf(1_000, 5_000) + internal var worker: Executor = ThreadPoolExecutor(0, 1, 10, TimeUnit.SECONDS, LinkedBlockingQueue()) { Thread(it, "air-triggers") } + internal var lights: TriggerLights = ColorfulLights + private val main = Handler(Looper.getMainLooper()) + private var reapply: Runnable? = null + + @Suppress("DEPRECATION") + fun supported(context: Context) = context.packageManager.resolveContentProvider(AUTHORITY, 0) != null && + InputDevice.getDeviceIds().any { AirTrigger.isTriggerDevice(InputDevice.getDevice(it)) } + + /** Call on the main thread. */ + fun open(context: Context) { + val app = context.applicationContext + cancelReapply() + worker.execute { apply(app) } + // Game Space runs its own trigger setup for the app that comes to the front, which switches the trigger keys and lights off again. + val again = Runnable { worker.execute { apply(app) } } + reapply = again + REAPPLY_MS.forEach { main.postDelayed(again, it) } + } + + private fun apply(app: Context) { + val prefs = AirTriggerPrefs.prefs(app) + if (!prefs.getBoolean(AirTriggerPrefs.OWNED, false) && Settings.Global.getInt(app.contentResolver, OPEN, 0) != 1) + prefs.edit().putBoolean(AirTriggerPrefs.OWNED, true).commit() + call(app, OPEN) + if (!prefs.getBoolean(AirTriggerPrefs.OWNED, false)) return + lights.request(SHOULDER_LIGHT_ON) + // The light service drops every trigger light until an effect is set, which Game Space only does from its own view. + lights.setEffect(shoulderEffect(Settings.Global.getString(app.contentResolver, SHOULDER_SETTINGS), AirTriggerPrefs.led(app))) + // Entering the scene turns the lights off; the release actions show the idle light picked in RedMagic's lighting settings. + AirTrigger.entries.forEach { lights.request(it.releaseLight) } + } + + /** The code RedMagic's shoulder light settings give the effect, such as "02101000" for steady. */ + internal fun shoulderEffect(settings: String?, led: AirTriggerLed): String = settings + ?.let { runCatching { JSONObject(it).optJSONObject("shoulder_effects")?.optString(led.effect) }.getOrNull() } + ?.takeIf { it.length == 8 } ?: led.fallback + + /** Closes only what this app opened, so a distribute another app turned on stays on. Call on the main thread. */ + fun restore(context: Context) { + val app = context.applicationContext + cancelReapply() + worker.execute { + val prefs = AirTriggerPrefs.prefs(app) + if (!prefs.getBoolean(AirTriggerPrefs.OWNED, false)) return@execute + lights.request(SHOULDER_LIGHT_OFF) + if (call(app, CLOSE)) prefs.edit().remove(AirTriggerPrefs.OWNED).commit() + } + } + + fun light(code: Int) = worker.execute { lights.request(code) } + + private fun cancelReapply() { + reapply?.let(main::removeCallbacks) + reapply = null + } + + private fun call(context: Context, method: String) = runCatching { context.contentResolver.call(URI, method, null, null) != null } + .onFailure { Log.w(TAG, "$method failed", it) }.getOrDefault(false) +} + +internal interface TriggerLights { + fun request(action: Int) + fun setEffect(effect: String) +} + +private object ColorfulLights : TriggerLights { + private const val TAG = "AirTriggers" + private const val SERVICE = "ColorfulLightService" + private const val INTERFACE = "com.zte.hardware.IColorfulLightManager" + // IColorfulLightManager transaction codes; its ColorfulLightManager wrapper is a blocked hidden API. + private const val REQUEST_LIGHT = IBinder.FIRST_CALL_TRANSACTION + private const val SET_SHOULDER_EFFECT = IBinder.FIRST_CALL_TRANSACTION + 2 + private val binder: IBinder? by lazy { + runCatching { Class.forName("android.os.ServiceManager").getMethod("getService", String::class.java).invoke(null, SERVICE) as IBinder? } + .getOrNull()?.takeIf { runCatching { it.interfaceDescriptor }.getOrNull() == INTERFACE } + } + + override fun request(action: Int) = transact(REQUEST_LIGHT) { writeInt(action) } + override fun setEffect(effect: String) = transact(SET_SHOULDER_EFFECT) { writeString(effect) } + + private fun transact(code: Int, write: Parcel.() -> Unit) { + val binder = binder ?: return + val data = Parcel.obtain() + val reply = Parcel.obtain() + try { + data.writeInterfaceToken(INTERFACE) + data.write() + binder.transact(code, data, reply, 0) + reply.readException() + } catch (e: Exception) { + Log.w(TAG, "light call $code failed", e) + } finally { + data.recycle() + reply.recycle() + } + } +} + +/** Presses the chosen button on screen when it is shown, so it animates and keeps one toggle state; otherwise uses a source of its own. */ +class AirTriggerInput( + private val pad: PadBridge, + private val onScreen: (elementId: String, trigger: AirTrigger, held: Boolean, cancelled: Boolean) -> Boolean = { _, _, _, _ -> false }, + private val touched: (AirTrigger, Boolean) -> Unit = { _, _ -> }, + private val handler: Handler = Handler(Looper.getMainLooper()), +) { + private val sources = EnumMap(AirTrigger::class.java) + private val setups = EnumMap(AirTrigger::class.java) + private val held = EnumSet.noneOf(AirTrigger::class.java) + private val pressed = EnumSet.noneOf(AirTrigger::class.java) + private val heldOnScreen = EnumMap(AirTrigger::class.java) + private val timers = EnumMap(AirTrigger::class.java) + + fun configure(setups: Map) { + for (trigger in AirTrigger.entries) { + val setup = setups[trigger] + if (this.setups[trigger] == setup) continue + stop(trigger) + if (sources[trigger]?.element != setup?.target) { + pressed.remove(trigger) + heldOnScreen.remove(trigger)?.let { onScreen(it, trigger, false, true) } + sources.remove(trigger)?.close() + if (setup != null) sources[trigger] = InputSurfaceSource(pad, InputRole.PRIMARY, setup.target) + } else if (trigger in pressed) unpress(trigger, cancelled = true) + if (setup != null) this.setups[trigger] = setup else this.setups.remove(trigger) + } + } + + fun onKey(event: KeyEvent, enabled: () -> Boolean): Boolean { + if (event.keyCode != AirTrigger.LEFT.keyCode && event.keyCode != AirTrigger.RIGHT.keyCode) return false + val trigger = AirTrigger.of(event.keyCode, event.device) ?: return false + return onKey(trigger, event.action, event.repeatCount, event.action == KeyEvent.ACTION_DOWN && enabled()) + } + + fun onKey(trigger: AirTrigger, action: Int, repeatCount: Int, enabled: Boolean): Boolean { + val source = sources[trigger] + when (action) { + KeyEvent.ACTION_DOWN -> if (source != null && enabled && repeatCount == 0 && held.add(trigger)) { + touched(trigger, true) + val setup = setups[trigger] + if (setup?.action == AirTriggerAction.LATCH && trigger in pressed) unpress(trigger, cancelled = false) + else if (trigger !in pressed) { + press(trigger, source) + if (setup?.action == AirTriggerAction.RAPID) rapid(trigger, 500L / setup.rate.clicksPerSecond) + } + } + KeyEvent.ACTION_UP -> if (held.remove(trigger)) { + touched(trigger, false) + if (setups[trigger]?.action != AirTriggerAction.LATCH) { + stop(trigger) + if (trigger in pressed) unpress(trigger, cancelled = false) + } + return true + } + } + return source != null + } + + private fun rapid(trigger: AirTrigger, halfPeriod: Long) { + val tick = object : Runnable { + override fun run() { + if (trigger in pressed) unpress(trigger, cancelled = false) else sources[trigger]?.let { press(trigger, it) } + handler.postDelayed(this, halfPeriod) + } + } + timers[trigger] = tick + handler.postDelayed(tick, halfPeriod) + } + + private fun stop(trigger: AirTrigger) { + timers.remove(trigger)?.let(handler::removeCallbacks) + } + + private fun press(trigger: AirTrigger, source: InputSurfaceSource) { + pressed += trigger + if (source.element == setups[trigger]?.element && onScreen(source.element.id, trigger, true, false)) { + heldOnScreen[trigger] = source.element.id + // The router counts held keys, so a toggle latched while its button was hidden is released before the button takes over. + if (source.latched) source.release() + } else source.update(1f) + } + + private fun unpress(trigger: AirTrigger, cancelled: Boolean) { + pressed -= trigger + heldOnScreen.remove(trigger)?.let { onScreen(it, trigger, false, cancelled) } + ?: sources[trigger]?.let { if (cancelled) it.cancel() else it.update(0f) } + } + + fun release() { + AirTrigger.entries.forEach(::stop) + held.toList().forEach { held.remove(it); touched(it, false) } + pressed.toList().forEach { unpress(it, cancelled = true) } + sources.values.forEach { it.release() } + } + + fun close() { + release() + sources.values.forEach { it.close() } + sources.clear() + setups.clear() + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt b/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt index 476ac443ac..536493572e 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/SecondScreenMode.kt @@ -15,17 +15,24 @@ enum class SecondScreenMode(val id: String, @StringRes val label: Int, val bindi DECK_CONTROLS("deck-controls", R.string.second_mode_deck_controls, InputStockLayouts.DECK), CUSTOM_CONTROLS("custom-controls", R.string.input_profile_controls_mode), DASHBOARD("dashboard", R.string.second_mode_dashboard), + GUIDES("guides", R.string.bottom_page_guides), + MIRROR("mirror", R.string.bottom_page_mirror), + STEAM_QAM("steam-qam", R.string.bottom_qam_title), + ART("art", R.string.bottom_art_title), DESKTOP("desktop", R.string.second_mode_desktop); + val sessionPanel: Boolean get() = this == GUIDES || this == MIRROR || this == STEAM_QAM || this == ART + val controls: Boolean get() = this == CUSTOM_CONTROLS || bindings != null fun panel(context: Context): String? = if (this == DECK_CONTROLS) SessionPrefs.deckPanel(context).bindings else bindings companion object { /** The mode the bottom screen opens in: the one picked last if it is still available, else the DroidDeck menu. */ - fun opening(remembered: String?, deckPad: Boolean, dashboard: Boolean = false, bottomDesktop: Boolean = false): SecondScreenMode = + fun opening(remembered: String?, deckPad: Boolean, dashboard: Boolean = false, bottomDesktop: Boolean = false, + steam: Boolean = false): SecondScreenMode = entries.firstOrNull { - it != NONE && it.id == remembered && (it != DECK_CONTROLS || deckPad) && (it != DASHBOARD || dashboard) && + it != NONE && it.id == remembered && (it != DECK_CONTROLS || deckPad) && (it != DASHBOARD && !it.sessionPanel || dashboard) && (it != STEAM_QAM && it != ART || steam) && (it != DESKTOP || bottomDesktop) } ?: MENU } diff --git a/app/src/main/java/com/droiddeck/launcher/input/SessionTextInput.kt b/app/src/main/java/com/droiddeck/launcher/input/SessionTextInput.kt new file mode 100644 index 0000000000..387351def2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/input/SessionTextInput.kt @@ -0,0 +1,327 @@ +package com.droiddeck.launcher.input + +import android.content.Context +import android.net.LocalSocket +import android.net.LocalSocketAddress +import android.os.Handler +import android.os.Looper +import android.util.Log +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.wayland.WaylandCompositor +import java.io.File +import java.io.IOException +import java.util.concurrent.RejectedExecutionException +import java.util.concurrent.ScheduledThreadPoolExecutor +import java.util.concurrent.TimeUnit + +private enum class TextDelivery(val result: Int) { + NOT_DELIVERED(WaylandCompositor.TEXT_NOT_DELIVERED), + DELIVERED(WaylandCompositor.TEXT_DELIVERED), + UNRESOLVED(WaylandCompositor.TEXT_UNRESOLVED), +} + +class SessionTextInput(context: Context, private val hasFocus: () -> Boolean) { + private val delivery = deliveryFor(context) + private val owner = Any() + + fun start() = delivery.start(owner, hasFocus) + fun stop() = delivery.stop(owner) + + private companion object { + private var instance: SessionTextDelivery? = null + + @Synchronized private fun deliveryFor(context: Context): SessionTextDelivery = + instance ?: SessionTextDelivery(context.applicationContext).also { instance = it } + } +} + +private class SessionTextDelivery(private val appContext: Context) { + private val handler = Handler(Looper.getMainLooper()) + private val lock = Any() + private var generation = 0L + @Volatile private var active = false + private var owner: Any? = null + private var focusCheck: (() -> Boolean)? = null + private var executor: ScheduledThreadPoolExecutor? = null + private var socket: LocalSocket? = null + private var pendingToken = 0 + private var runningToken = 0 + private var failedToken = 0 + private val guestListener = object : WaylandCompositor.TextInputFallbackListener { + override fun onTextInputFallback(text: String, token: Int): Boolean { + synchronized(lock) { + if (!active || pendingToken != 0 || failedToken != 0 || token <= 0) return false + val received = generation + pendingToken = token + val posted = try { + handler.post { enqueue(text, received, token) } + } catch (e: RuntimeException) { + false + } + if (!posted) pendingToken = 0 + return posted + } + } + } + + fun start(nextOwner: Any, hasFocus: () -> Boolean) { + val previous = synchronized(lock) { + if (owner === nextOwner) return + owner + } + if (previous != null) stop(previous) + val queue = ScheduledThreadPoolExecutor(1) { runnable -> + Thread(runnable, "session-text-input").apply { isDaemon = true } + } + queue.executeExistingDelayedTasksAfterShutdownPolicy = false + synchronized(lock) { + this.owner = nextOwner + focusCheck = hasFocus + active = true + executor = queue + if (failedToken != 0) scheduleRetryLocked(failedToken, INITIAL_DELAY_MS) + } + WaylandCompositor.setTextInputFallbackListener(guestListener) + } + + fun stop(oldOwner: Any) { + val detached = synchronized(lock) { + if (owner !== oldOwner) return + owner = null + focusCheck = null + active = false + generation += 1 + val queue = executor + val open = socket + val token = if (runningToken == 0 && failedToken == 0) pendingToken else 0 + executor = null + socket = null + Triple(queue, open, token) + } + WaylandCompositor.clearTextInputFallbackListener(guestListener) + handler.removeCallbacksAndMessages(null) + detached.second?.let { requestCancel(it) } + detached.first?.shutdown() + if (detached.third != 0) complete(detached.third) + } + + private fun enqueue(text: String, received: Long, token: Int) { + val currentFocus = synchronized(lock) { if (active && generation == received) focusCheck else null } + if (currentFocus == null || !currentFocus() || !WaylandCompositor.isTextInputFallbackListener(guestListener)) { + Log.d(TAG, "guest text fallback skipped outside the active focused session") + complete(token) + return + } + val bytes = text.toByteArray(Charsets.UTF_8) + if (bytes.isEmpty() || bytes.size > MAX_BYTES) { + complete(token) + return + } + val queue = synchronized(lock) { + if (active && generation == received) executor else null + } + if (queue == null) { + complete(token) + return + } + try { + queue.execute { + try { + val delivery = send(bytes, received, token) + if (delivery == TextDelivery.UNRESOLVED) recover(token) + else complete(token, delivery) + } finally { + releaseRunning(token) + } + } + } catch (e: RejectedExecutionException) { + complete(token) + } + } + + private fun recover(token: Int) { + if (probe()) { + complete(token) + return + } + val marked = synchronized(lock) { + if (pendingToken == token && failedToken == 0) { + failedToken = token + WaylandCompositor.completeTextInputFallback(token, TextDelivery.UNRESOLVED.result) + scheduleRetryLocked(token, INITIAL_DELAY_MS) + true + } else { + false + } + } + if (marked) Log.w(TAG, "text injection could not be confirmed") + } + + private fun scheduleRetryLocked(token: Int, delayMs: Long) { + if (!active || failedToken != token || pendingToken != token) return + val queue = executor ?: return + val current = generation + try { + queue.schedule({ retryProbe(current, token, delayMs) }, delayMs, TimeUnit.MILLISECONDS) + } catch (e: RejectedExecutionException) { + } + } + + private fun retryProbe(received: Long, token: Int, delayMs: Long) { + val ready = synchronized(lock) { + active && generation == received && failedToken == token && pendingToken == token + } + if (!ready) return + val proven = probe() + val owned = synchronized(lock) { + if (proven) { + if (active && generation == received && failedToken == token && pendingToken == token) { + pendingToken = 0 + runningToken = 0 + failedToken = 0 + true + } else { + false + } + } else { + if (active && generation == received && failedToken == token && pendingToken == token) { + val next = (delayMs * 2).coerceAtMost(MAX_DELAY_MS) + scheduleRetryLocked(token, next) + } + false + } + } + if (owned) WaylandCompositor.completeTextInputFallback(token, TextDelivery.NOT_DELIVERED.result) + } + + private fun probe(): Boolean { + val live = LocalSocket() + return try { + live.connect(LocalSocketAddress(endpoint().path, LocalSocketAddress.Namespace.FILESYSTEM)) + live.soTimeout = TIMEOUT_MS + val out = live.outputStream + out.write(lengthPrefix(0)) + out.flush() + live.inputStream.read() == 0 + } catch (e: IOException) { + Log.w(TAG, "could not probe guest text input state", e) + false + } finally { + close(live) + } + } + + private fun complete(token: Int, delivery: TextDelivery = TextDelivery.NOT_DELIVERED) { + val owned = synchronized(lock) { + if (pendingToken == token) { + pendingToken = 0 + runningToken = 0 + failedToken = 0 + true + } else { + false + } + } + if (owned) WaylandCompositor.completeTextInputFallback(token, delivery.result) + } + + private fun releaseRunning(token: Int) { + synchronized(lock) { + if (runningToken == token) runningToken = 0 + } + } + + private fun send(bytes: ByteArray, received: Long, token: Int): TextDelivery { + val live = LocalSocket() + if (!claim(live, received, token)) { + close(live) + return TextDelivery.NOT_DELIVERED + } + var requested = false + try { + live.connect(LocalSocketAddress(endpoint().path, LocalSocketAddress.Namespace.FILESYSTEM)) + live.soTimeout = TIMEOUT_MS + if (!isCurrent(received)) return TextDelivery.NOT_DELIVERED + val out = live.outputStream + out.write(lengthPrefix(bytes.size)) + requested = true + out.write(bytes) + out.flush() + val input = live.inputStream + val ack = try { + input.read() + } catch (e: IOException) { + // Android may report a socket read timeout as a plain IOException. + requestCancel(live) + input.read() + } + if (ack == 0) Log.d(TAG, "guest did not complete text delivery") + if (ack != 0 && ack != 1 && isCurrent(received)) Log.w(TAG, "guest did not acknowledge text delivery") + return when (ack) { + 1 -> TextDelivery.DELIVERED + 0 -> TextDelivery.NOT_DELIVERED + else -> TextDelivery.UNRESOLVED + } + } catch (e: IOException) { + if (isCurrent(received)) Log.w(TAG, "could not hand text to the guest", e) + if (!requested) return TextDelivery.NOT_DELIVERED + return TextDelivery.UNRESOLVED + } finally { + release(live) + close(live) + } + } + + private fun requestCancel(live: LocalSocket) { + try { + live.shutdownOutput() + } catch (e: IOException) { + Log.w(TAG, "could not request guest text input cancellation", e) + } + } + + private fun isCurrent(received: Long) = synchronized(lock) { active && generation == received } + + private fun claim(live: LocalSocket, received: Long, token: Int) = synchronized(lock) { + if (!active || generation != received || pendingToken != token || runningToken != 0 || failedToken != 0) { + false + } else { + runningToken = token + socket = live + true + } + } + + private fun release(live: LocalSocket) { + synchronized(lock) { + if (socket === live) socket = null + } + } + + private fun endpoint(): File = File(LinuxRuntime.sessionRoot(appContext), "text-input.sock") + + private fun lengthPrefix(size: Int): ByteArray { + val flagged = if (size == 0) size else size or Int.MIN_VALUE + return byteArrayOf( + (flagged ushr 24).toByte(), + (flagged ushr 16).toByte(), + (flagged ushr 8).toByte(), + flagged.toByte(), + ) + } + + private fun close(sock: LocalSocket) { + try { + sock.close() + } catch (e: IOException) { + } + } + + private companion object { + const val TAG = "SessionTextInput" + const val MAX_BYTES = 65536 + const val TIMEOUT_MS = 3000 + const val INITIAL_DELAY_MS = 500L + const val MAX_DELAY_MS = 5000L + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt b/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt index 659b99c0ce..a044469f3b 100644 --- a/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt +++ b/app/src/main/java/com/droiddeck/launcher/input/TouchpadGestures.kt @@ -9,6 +9,7 @@ import kotlin.math.hypot class TouchpadGestures( private val slopPx: Float, private val listener: PointerGestures.Listener, + private val holdDrags: Boolean = true, ) { var x = 0f private set @@ -33,6 +34,7 @@ class TouchpadGestures( private var held = false private var secondDownAt = 0L private var secondWasTap = false + private var pressed = false private var twoFingers = false private var scrollAnchorX = 0f private var scrollAnchorY = 0f @@ -90,6 +92,15 @@ class TouchpadGestures( lastTapAt = 0L } + fun buttonPressed() { + pressed = true + handler.removeCallbacks(longPress) + releaseClick() + travelled = slopPx + 1f + secondWasTap = false + lastTapAt = 0L + } + fun place(px: Float, py: Float) { x = px.coerceIn(bounds.left, bounds.right) y = py.coerceIn(bounds.top, bounds.bottom) @@ -115,7 +126,7 @@ class TouchpadGestures( releaseClick() lastX = event.x; lastY = event.y downAt = event.eventTime - travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false + travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false; pressed = false fingers = 1; pinching = false anchorId = event.getPointerId(0); moverId = -1; holdDrag = false; scrollLocked = false if (clicks && event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) { @@ -123,7 +134,7 @@ class TouchpadGestures( press(PointerGestures.BTN_LEFT) } else { dragging = false - if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS) + if (clicks && holdDrags) handler.postDelayed(longPress, TouchTiming.HOLD_MS) } return true } @@ -142,7 +153,7 @@ class TouchpadGestures( if (holdDrag) return true twoFingers = true secondDownAt = event.eventTime - secondWasTap = true + secondWasTap = !pressed scrollAnchorX = (event.getX(0) + event.getX(1)) / 2f scrollAnchorY = (event.getY(0) + event.getY(1)) / 2f pinchSpan = span(event) @@ -153,7 +164,7 @@ class TouchpadGestures( val mi = if (moverId == -1) -1 else event.findPointerIndex(moverId) if (ai >= 0 && mi >= 0) { val mx = event.getX(mi); val my = event.getY(mi) - if (!holdDrag && !scrolled && !scrollLocked) { + if (holdDrags && !holdDrag && !scrolled && !scrollLocked) { val anchorMoved = abs(event.getX(ai) - anchorStartX) + abs(event.getY(ai) - anchorStartY) val moverMoved = abs(mx - moverStartX) + abs(my - moverStartY) if (anchorMoved >= slopPx) { diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt index 0e42e770e3..d72274443b 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt @@ -288,12 +288,26 @@ object BwrapSpawner { } private fun preload(session: List, rootfs: String, env: MutableMap): List { - val libs = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines() - ?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: return emptyList() - if (libs.isEmpty()) return emptyList() + val configured = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines() + ?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: emptyList() + val lseDisabled = env["LSE_EMU"] == "0" + val libs = configured.filterNot { lseDisabled && it.endsWith("/liblse_emu.so") } + val inherited = env["LD_PRELOAD"]?.split(Regex("[\\s:]+")) + ?.filter { it.isNotEmpty() && !(lseDisabled && it.substringAfterLast('/') == "liblse_emu.so") } + ?: emptyList() + if (libs.isEmpty()) { + if (lseDisabled) { + if (inherited.isEmpty()) env.remove("LD_PRELOAD") + else env["LD_PRELOAD"] = inherited.joinToString(":") + } + return emptyList() + } val binds = ArrayList() val paths = libs.map { lib -> "$PRELOAD_DIR/${lib.substringAfterLast('/')}".also { binds.add(Bind(rootfs + lib, it)) } } - env["LD_PRELOAD"] = (paths + listOfNotNull(env["LD_PRELOAD"]?.takeIf { it.isNotBlank() })).joinToString(":") + env["LD_PRELOAD"] = (paths + inherited).joinToString(":") + if (libs.any { it.endsWith("/liblse_emu.so") }) { + env.putIfAbsent("LSE_EMU", "1") + } File(rootfs, NET_LINK).takeIf { it.isFile }?.let { binds.add(Bind(it.path, "/$NET_LINK")) } env["FAKE_EVDEV_DIR"]?.let { File(it).parent }?.let { dev -> binds.addAll(bindsFor(session, rootfs, dev, dev)) @@ -563,12 +577,15 @@ object BwrapSpawner { private fun run(context: Context, plan: Plan, client: LocalSocket, out: DataOutputStream, id: Int) { val verbose = plan.env["DROIDDECK_PROOT_VERBOSE"]?.toIntOrNull() - val native = if (NativeGuest.forSession(context)) nativeLaunch(context, plan) else null + val nativeSession = NativeGuest.forSession(context) + val native = if (nativeSession) nativeLaunch(context, plan) else null val builder = if (native != null) { ProcessBuilder(native.first).redirectErrorStream(true) .directory(File(hostPath(plan.binds, plan.root.path, plan.cwd)).takeIf { it.isDirectory } ?: plan.root) .also { b -> b.environment().apply { clear(); putAll(native.second) } } } else { + val reason = if (nativeSession) "sandbox native launch unavailable" else "parent guest uses PRoot" + Log.i(TAG, "Flatpak: using PRoot ($reason)") val cmd = LinuxRuntime.prootPrefix(context, plan.root, plan.cwd) if (verbose != null) { cmd.add("-v"); cmd.add(verbose.toString()) } plan.binds.forEach { cmd.add("-b"); cmd.add(it.spec) } @@ -585,7 +602,6 @@ object BwrapSpawner { putAll(prootEnvironment(plan, envTool)) put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/ElfSeccompPatch.kt b/app/src/main/java/com/droiddeck/launcher/runtime/ElfSeccompPatch.kt index 817cbc9757..8ebf839fd7 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/ElfSeccompPatch.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/ElfSeccompPatch.kt @@ -38,6 +38,11 @@ object ElfSeccompPatch { val end = minOf(data.size, buffer.getLong(at + 8).toInt() + buffer.getLong(at + 32).toInt()) and 3.inv() var pos = start while (pos + 4 <= end) { + if (patchTermiosRequest(buffer, pos, end)) { + patched++ + pos += 4 + continue + } val replacement = when (buffer.getInt(pos)) { MOV_X8_SET_ROBUST_LIST -> NOP MOV_X8_CLONE3, MOV_X8_RSEQ -> MOV_X0_ENOSYS @@ -65,6 +70,40 @@ object ElfSeccompPatch { return patched } + /** + * glibc 2.42 and later read and set a terminal with TCGETS2 and TCSETS2/W2/F2, which Android's + * SELinux policy refuses on an app's pseudo-terminal slaves (EACCES): isatty() was false in every + * Konsole, ssh and tmux session, so bash had no prompt or job control and stdout was not line + * buffered. TCGETS and TCSETS* carry the same struct without its two speed fields, which glibc + * then takes from c_cflag. A site is `movz xN, #lo` then `movk xN, #hi, lsl #16`; the movz gets + * the old request and the movk becomes a no-op. + */ + private fun patchTermiosRequest(buffer: ByteBuffer, pos: Int, end: Int): Boolean { + val movz = buffer.getInt(pos) + if ((movz and 0x7fe00000) != 0x52800000) return false + val low = (movz ushr 5) and 0xffff + if (low !in 0x542a..0x542d) return false + val register = movz and 0x1f + var next = pos + 4 + while (next < minOf(end, pos + 4 + 4 * 4)) { + val movk = buffer.getInt(next) + if ((movk and 0x7fe00000) == 0x72a00000 && (movk and 0x1f) == register) { + val request = when ((movk ushr 5) and 0xffff) { + 0x802c -> if (low == 0x542a) 0x5401 else return false + 0x402c -> if (low != 0x542a) 0x5402 + (low - 0x542b) else return false + else -> return false + } + buffer.putInt(pos, (movz and 0x1f.inv() and (0xffff shl 5).inv()) or (request shl 5) or register) + buffer.putInt(next, NOP) + return true + } + // Anything between that might read or write the register would see the old low half + if (intArrayOf(0, 5, 10, 16).any { (movk ushr it) and 0x1f == register }) return false + next += 4 + } + return false + } + /** Patches the file behind [path] (symlinks followed) if it still has unpatched call sites. */ fun patchFile(path: File): Int { val target = path.canonicalFile diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/FrameAcquireWorkerProbe.kt b/app/src/main/java/com/droiddeck/launcher/runtime/FrameAcquireWorkerProbe.kt new file mode 100644 index 0000000000..403a8c59cc --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/runtime/FrameAcquireWorkerProbe.kt @@ -0,0 +1,271 @@ +package com.droiddeck.launcher.runtime + +import android.content.Context +import android.os.SystemClock +import android.system.Os +import android.system.OsConstants +import android.util.Log +import com.droiddeck.launcher.wayland.WaylandCompositor +import java.io.File +import java.io.InputStream +import java.nio.file.Files +import java.nio.file.LinkOption.NOFOLLOW_LINKS +import java.security.MessageDigest + +/** One app-issued Steam session and one attested Gamescope worker. This is not an + * isolation boundary against arbitrary code already running as the Android app UID. */ +internal object FrameAcquireWorkerProbe { + private const val SESSION_SCRIPT = "/usr/local/bin/droiddeck-session" + private const val PATH = "/usr/local/bin/gamescope" + private const val CAPABILITY = "linuxfs/usr/local/share/droiddeck/gamescope-producer-acquire-v1" + internal const val GAMESCOPE_ENABLE = "GAMESCOPE_DROIDDECK_PRODUCER_ACQUIRE=1" + internal const val GAME_ENABLE = "DROIDDECK_GAME_DROIDDECK_GAME_FRAME_ACQUIRE=1" + private const val MAX_BINARY_BYTES = 32L * 1024L * 1024L + internal const val RECEIPT_TAG = 0x44445046 + internal const val RECEIPT_BYTES = Int.SIZE_BYTES + Long.SIZE_BYTES + private const val TTL_MS = 90_000L + + internal data class Ticket( + val owner: Int, val root: File, val configuredRoot: File, val binary: File, + val expected: ByteArray, val expires: Long, val steamGameUrl: String?, + ) + internal data class Qualified(val ticket: Ticket, val dev: Long, val ino: Long, val mtime: Long, val ctime: Long) + private var intent: Ticket? = null + private var nativeOwner = 0 + private var nativePid = 0 + + private enum class Stage { ARM, MATCH, PUBLISH } + private enum class Reason { + ENABLED, MATCH_ACK, MATCH_OWNER, MATCH_EXPIRED, MATCH_PATH, MATCH_ROOT, + MATCH_ARGV, MATCH_FILE, MATCH_DIGEST, QUALIFIED, PUBLISH_TICKET, PUBLISH_RESTAT, + PUBLISH_NATIVE, PUBLISH_RECEIPT, RESERVED + } + private val reported = mutableSetOf() + @Synchronized private fun breadcrumb(stage: Stage, reason: Reason) { + if (reported.add(stage)) Log.i("FrameAcquireWorkerProbe", "worker_admission=" + reason.name) + } + + internal fun validEnvironment(agentEnvironment: List, customEnvironment: List): Boolean { + // AgentEnv supplies a replacement PATH whenever any executable override is staged. + // Custom env is user-editable, including names not known to this build; it is not a trust root. + return agentEnvironment.isEmpty() && customEnvironment.isEmpty() + } + + fun available(context: Context): Boolean = + android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.core.DeviceSupport.adreno() && + runCatching { context.assets.open(CAPABILITY).use { it.readBytes().decodeToString() } } + .getOrNull() == "droiddeck-producer-acquire-v1\n" + + private fun digest(input: InputStream, maxBytes: Long): ByteArray { + val out = MessageDigest.getInstance("SHA-256") + val buffer = ByteArray(64 * 1024) + var size = 0L + while (true) { + val n = input.read(buffer) + if (n == -1) break + require(n > 0) + size += n + require(size <= maxBytes) + out.update(buffer, 0, n) + } + require(size > 0) + return out.digest() + } + + // Compute asset identity outside SessionService's stop lock and before a worker + // exists. The resulting ticket still has to be assigned to that exact owner. + private const val STEAM_RUN_PREFIX = "steam://rungameid/" + + internal fun permittedLaunch(url: String?, frontendGame: Boolean): Boolean = + if (url == null) !frontendGame else frontendGame && url.startsWith(STEAM_RUN_PREFIX) && + com.droiddeck.launcher.frontend.GameLaunchLink.validId(url.removePrefix(STEAM_RUN_PREFIX)) + + internal fun prepare(context: Context, steamGameUrl: String?, frontendGame: Boolean): Ticket? { + if (!permittedLaunch(steamGameUrl, frontendGame) || + !available(context) || !WaylandCompositor.frameWorkerProbeEnabled()) return null + return runCatching { + val configuredRoot = LinuxRuntime.rootDir(context).absoluteFile + val root = configuredRoot.canonicalFile + val file = File(root.path + PATH) + require(file.canonicalFile == file && Files.isRegularFile(file.toPath(), NOFOLLOW_LINKS)) + val script = File(root.path + SESSION_SCRIPT) + require(exactSteamScript(SESSION_SCRIPT, root, configuredRoot)) + val stagedScript = script.inputStream().use { digest(it, 1024L * 1024L) } + val signedScript = context.assets.open("linuxfs" + SESSION_SCRIPT).use { digest(it, 1024L * 1024L) } + require(MessageDigest.isEqual(stagedScript, signedScript)) + val expected = context.assets.open("linuxfs" + PATH).use { digest(it, MAX_BINARY_BYTES) } + Ticket(0, root, configuredRoot, file, expected, SystemClock.elapsedRealtime() + TTL_MS, steamGameUrl) + }.getOrNull() + } + + @Synchronized fun arm(owner: Int, prepared: Ticket): Boolean { + if (owner <= 0 || SystemClock.elapsedRealtime() >= prepared.expires) return false + reported.clear() + intent = prepared.copy(owner = owner) + breadcrumb(Stage.ARM, Reason.ENABLED) + return true + } + + /** Native shebang handling can give Bash the staged host filename as its $0. */ + internal fun exactSteamScript(token: String, root: File, configuredRoot: File): Boolean { + if (token != SESSION_SCRIPT && token != root.path + SESSION_SCRIPT && + token != configuredRoot.path + SESSION_SCRIPT) return false + return runCatching { + val expected = File(root.path + SESSION_SCRIPT) + val supplied = if (token == SESSION_SCRIPT) expected else File(token) + // Reject symlinks within the authorized root, including a symlink replacing the script. + // Android's configured root itself may be an alias of its app-issued canonical root. + require(configuredRoot.canonicalFile == root && expected.canonicalFile == expected && + supplied.canonicalFile == expected && + Files.isRegularFile(expected.toPath(), NOFOLLOW_LINKS) && + Files.isRegularFile(supplied.toPath(), NOFOLLOW_LINKS)) + Files.isSameFile(supplied.toPath(), expected.toPath()) + }.getOrDefault(false) + } + + internal fun exactGamescopeArgs( + argv: List, steamGameUrl: String? = null, script: (String) -> Boolean, + ): Boolean { + if (argv.firstOrNull() !in listOf("gamescope", PATH)) return false + val delimiter = argv.indexOf("--") + val tailSize = if (steamGameUrl == null) 3 else 4 + if (delimiter < 4 || argv.size != delimiter + tailSize || argv[delimiter + 2] != "steam" || + !script(argv[delimiter + 1]) || + (steamGameUrl != null && (!permittedLaunch(steamGameUrl, true) || argv.last() != steamGameUrl))) return false + val opts = argv.subList(1, delimiter) + if (opts.take(4) != listOf("--backend", "wayland", "--expose-wayland", "-f")) return false + val dimensions = setOf("-W", "-H", "-w", "-h") + val seen = mutableSetOf() + var i = 4 + while (i < opts.size) { + val option = opts[i++] + if (!seen.add(option)) return false + when (option) { + "-e", "--hdr-enabled", "--mangoapp" -> Unit + "-S" -> if (opts.getOrNull(i++) != "stretch") return false + "--default-touch-mode" -> if (opts.getOrNull(i++) != "4") return false + "-W", "-H", "-w", "-h", "-r", "--xwayland-count" -> { + val value = opts.getOrNull(i++) ?: return false + if (value.length !in 1..6 || value.any { it !in '0'..'9' } || + value.toIntOrNull()?.let { it > 0 } != true) return false + } + else -> return false + } + } + return seen.containsAll(dimensions) + } + + fun match(owner: Int, root: File, file: String, argv: List, ack: Boolean): Qualified? { + val t = synchronized(this) { intent } ?: return null + // Startup's --version worker and unrelated workers must not consume the one diagnostic. + val candidate = "--version" !in argv && (file.substringAfterLast('/') == "gamescope" || + argv.firstOrNull()?.substringAfterLast('/') == "gamescope") + val rejection = when { + !ack -> Reason.MATCH_ACK + t.owner != owner -> Reason.MATCH_OWNER + SystemClock.elapsedRealtime() >= t.expires -> Reason.MATCH_EXPIRED + file != PATH -> Reason.MATCH_PATH + runCatching { root.canonicalFile }.getOrNull() != t.root -> Reason.MATCH_ROOT + !exactGamescopeArgs(argv, t.steamGameUrl) { exactSteamScript(it, t.root, t.configuredRoot) } -> Reason.MATCH_ARGV + else -> null + } + if (rejection != null) { + if (candidate) breadcrumb(Stage.MATCH, rejection) + return null + } + // Hash an actual descriptor rather than two pathname opens. Check both the + // descriptor and pathname identity; a race or substituted executable denies the grant. + val qualified = runCatching { + require(t.binary.canonicalFile == t.binary) + val before = Os.lstat(t.binary.path) + require(OsConstants.S_ISREG(before.st_mode) && before.st_size in 1..MAX_BINARY_BYTES) + val fd = Os.open(t.binary.path, OsConstants.O_RDONLY or OsConstants.O_NOFOLLOW or OsConstants.O_CLOEXEC, 0) + val sum = try { + require(stillSame(before, Os.fstat(fd))) + android.os.ParcelFileDescriptor.AutoCloseInputStream(android.os.ParcelFileDescriptor.dup(fd)).use { + digest(it, MAX_BINARY_BYTES) + }.also { require(stillSame(before, Os.fstat(fd))) } + } finally { + Os.close(fd) + } + val after = Os.lstat(t.binary.path) + require(stillSame(before, after)) + if (!MessageDigest.isEqual(sum, t.expected)) { + breadcrumb(Stage.MATCH, Reason.MATCH_DIGEST) + return null + } + Qualified(t, after.st_dev, after.st_ino, after.st_mtime, after.st_ctime) + }.getOrNull() + breadcrumb(Stage.MATCH, if (qualified == null) Reason.MATCH_FILE else Reason.QUALIFIED) + return qualified + } + + private fun stillSame(a: android.system.StructStat, b: android.system.StructStat): Boolean = + a.st_dev == b.st_dev && a.st_ino == b.st_ino && a.st_size == b.st_size && + a.st_mtime == b.st_mtime && a.st_ctime == b.st_ctime && + OsConstants.S_ISREG(b.st_mode) + + internal fun validReceipt(pid: Int, workerPid: Int, ticks: Long, bytes: Int): Long = + if (pid > 1 && pid == workerPid && ticks > 0 && bytes == RECEIPT_BYTES) ticks else 0L + + internal fun parseSelfStat(stat: String, pid: Int): Long { + if (pid <= 1 || !stat.startsWith("$pid (")) return 0L + val comm = stat.lastIndexOf(')') + if (comm < 3 || stat.getOrNull(comm + 1) != ' ') return 0L + val fields = stat.substring(comm + 2).split(' ').filter { it.isNotEmpty() } + if (fields.firstOrNull()?.length != 1 || fields.size < 21) return 0L + val value = fields[19] // field 22 from field 3 (the single-character task state). + return value.takeIf { it.isNotEmpty() && it.all { ch -> ch in '0'..'9' } } + ?.toLongOrNull()?.takeIf { it > 0 } ?: 0L + } + + internal fun selfStartTicks(pid: Int): Long = runCatching { + File("/proc/self/stat").inputStream().use { input -> + val bytes = ByteArray(4096) + var used = 0 + while (used < bytes.size) { + val n = input.read(bytes, used, bytes.size - used) + if (n < 0) break + if (n == 0) return@runCatching 0L + used += n + } + if (used == bytes.size || used == 0 || bytes[used-1] != '\n'.code.toByte()) 0L + else parseSelfStat(String(bytes, 0, used, Charsets.US_ASCII), pid) + } + }.getOrDefault(0L) + + /** Runs just before the final GO byte. Failure never changes ordinary launch. */ + @Synchronized fun publish(q: Qualified, pid: Int, startTicks: Long) { + val t = q.ticket + if (intent !== t || pid <= 1 || SystemClock.elapsedRealtime() >= t.expires) { + if (intent === t) breadcrumb(Stage.PUBLISH, Reason.PUBLISH_TICKET) + return + } + intent = null // At most one candidate per explicitly armed session. + if (startTicks <= 0L) { + breadcrumb(Stage.PUBLISH, Reason.PUBLISH_RECEIPT) + return + } + val status = runCatching { + val st = Os.lstat(t.binary.path) + require(OsConstants.S_ISREG(st.st_mode) && st.st_dev == q.dev && st.st_ino == q.ino && + st.st_mtime == q.mtime && st.st_ctime == q.ctime) + if (WaylandCompositor.frameWorkerProbeGrant(t.owner, pid, t.expires, t.binary.path, st.st_dev, st.st_ino, startTicks)) { + nativeOwner = t.owner + nativePid = pid + Reason.RESERVED + } else Reason.PUBLISH_NATIVE + }.getOrDefault(Reason.PUBLISH_RESTAT) + breadcrumb(Stage.PUBLISH, status) + } + + @Synchronized fun revoke(owner: Int, pid: Int = 0) { + if (owner <= 0) return + if (pid == 0 && intent?.owner == owner) intent = null + if (nativeOwner == owner && (pid == 0 || pid == nativePid)) { + WaylandCompositor.frameWorkerProbeRevoke(owner, pid) + nativeOwner = 0 + nativePid = 0 + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 2c5fbad51e..50a190c1ba 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -1,13 +1,11 @@ package com.droiddeck.launcher.runtime import android.content.Context -import android.os.Environment import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper import com.droiddeck.launcher.session.SessionFiles import com.droiddeck.launcher.session.SessionPaths -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.util.concurrent.atomic.AtomicBoolean @@ -37,7 +35,7 @@ object GuestCommand { SessionFiles.stage(context, root) LinuxNetworkLinkComponent(context, root).publish() val runtimeDir = File(context.filesDir, ".flatpak-rt").apply { mkdirs() } - val binds = LinuxRuntime.binds(context, null, runtimeDir, Environment.getExternalStorageDirectory(), extraBinds) + val binds = LinuxRuntime.binds(context, null, runtimeDir, LinuxRuntime.sharedStorage(context), extraBinds) val native = NativeGuest.forSession(context) val fastPathKey = if (!native && fastPath && !fakeRoot && linkDir == null && ProotFastPath.enabled(context)) ProotFastPath.key(root, binds) else null val guest = mutableListOf( @@ -68,7 +66,6 @@ object GuestCommand { put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) if (linkDir != null) put("PROOT_L2S_DIR", linkDir.path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> put(k, v) } } LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt new file mode 100644 index 0000000000..e3f7d0ba01 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt @@ -0,0 +1,1008 @@ +package com.droiddeck.launcher.runtime + +import android.app.ActivityManager +import android.app.Service +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.content.ServiceConnection +import android.net.LocalServerSocket +import android.net.LocalSocket +import android.os.Binder +import android.os.Handler +import android.os.IBinder +import android.os.Looper +import android.os.Parcel +import android.os.ParcelFileDescriptor +import android.os.Process +import android.system.ErrnoException +import android.system.Os +import android.system.OsConstants +import android.system.StructPollfd +import android.util.Log +import org.json.JSONObject +import java.io.DataInputStream +import java.io.File +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit + +/** + * A guest program run as the main process of its own Android process. + * + * Android counts the processes in an app process's cgroup against its child-process limit, but not + * the app processes themselves. The worker execs the program in place; its binder fd stays open + * across the exec, so the system keeps the process as a live service process. The program's own + * children are still counted. See docs/phantom-processes.md. + */ +open class GuestWorker : Service() { + private val binder = object : Binder() { + override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean { + if (code != RUN) return super.onTransact(code, data, reply, flags) + val argv = data.createStringArray() ?: return false + val env = data.createStringArray() ?: return false + val fds = List(data.readInt()) { data.readFileDescriptor() } + val targets = data.createIntArray() ?: IntArray(fds.size) { it } + val fillBinderFd = data.readInt() != 0 + val go = data.readFileDescriptor() + val nice = data.readInt() + val pid = Process.myPid() + reply?.writeInt(pid) + // Optional fixed-size receipt, on the exact local, non-exported worker's Binder. + // Nothing in the guest socket request populates these fields. + if (reply != null && + Binder.getCallingUid() == Process.myUid() && + data.dataAvail() == Int.SIZE_BYTES && data.readInt() == FrameAcquireWorkerProbe.RECEIPT_TAG) { + reply.writeInt(pid) + reply.writeLong(FrameAcquireWorkerProbe.selfStartTicks(pid)) + } + Handler(Looper.getMainLooper()).post { + // The app writes a byte once it has the reply and has taken the launch on: an exec + // before then would end this process with the reply undelivered, and with none (the + // app gave up and starts the program another way) the program must not run here. + var why = "" + // poll() with a timeout counts as network I/O to StrictMode on the main thread + android.os.StrictMode.setThreadPolicy(android.os.StrictMode.ThreadPolicy.LAX) + val committed = runCatching { + fun byte(timeout: Int): Int { + val poll = StructPollfd().apply { fd = go.fileDescriptor; events = OsConstants.POLLIN.toShort() } + val ready = Os.poll(arrayOf(poll), timeout) + return (if (ready > 0) Os.read(go.fileDescriptor, ByteArray(1), 0, 1) else -1) + .also { why = "poll $ready revents ${poll.revents} read $it" } + } + // The commit, an answer, and the app's word that it has the answer: the app may + // have stopped waiting for it (and started the program another way) meanwhile. + // That last word comes, or the app closes its end (a byte or EOF): no timeout, + // which could drop a launch the app has already reported as started. + byte(GO_TIMEOUT_MS) == 1 && Os.write(go.fileDescriptor, byteArrayOf(1), 0, 1) == 1 && byte(-1) == 1 + }.getOrElse { why = it.toString(); false } + go.close() + if (committed) exec(argv, env, fds, targets, fillBinderFd, nice) + else { + Log.w(TAG, "launch not committed ($why): not running ${argv.firstOrNull()}") + Process.killProcess(Process.myPid()) + } + } + return true + } + } + + override fun onBind(intent: Intent): IBinder = binder + + private fun exec(argv: Array, env: Array, fds: List, targets: IntArray, fillBinderFd: Boolean, + nice: Int) { + try { + val top = targets.maxOrNull() ?: 2 + val (binderTop, binderFd) = keepBinderOpen(maxOf(BINDER_FDS, top + 1)) + // Out of the way first, so that placing one fd cannot overwrite another not yet placed. + val above = maxOf(MOVED_FDS, top + 1, binderTop + 1) + val moved = fds.map { pfd -> pfd?.let { Os.fcntlInt(it.fileDescriptor, OsConstants.F_DUPFD, above) } } + moved.forEachIndexed { i, fd -> + if (fd == null || i >= targets.size) return@forEachIndexed + val source = ParcelFileDescriptor.adoptFd(fd).also { kept.add(it) }.fileDescriptor + Os.dup2(source, targets[i]) + Os.fcntlInt(source, OsConstants.F_SETFD, OsConstants.FD_CLOEXEC) + } + // A session of its own: in zygote's process group, a program signalling its group + // (kill(0, sig)) would reach every process of the app. + runCatching { Os.setsid() } + // The native hook closes the binder fds in every other process (hook/handoff.c). Only an + // app launch asks for the number (a whole argument or variable value), never a guest's. + val fill = { arg: String -> + if (!fillBinderFd) arg + else if (arg == BINDER_FD_TOKEN) binderFd.toString() + else if (arg.endsWith("=$BINDER_FD_TOKEN")) arg.removeSuffix(BINDER_FD_TOKEN) + binderFd + else arg + } + // This thread blocks SIGQUIT, SIGUSR1 and SIGPIPE (Android's runtime), and an exec keeps + // that: the program's hook sets DDH_SIGMASK instead (none blocked, unless the request says). + val mask = if (env.any { it.startsWith("DDH_SIGMASK=") }) emptyList() else listOf("DDH_SIGMASK=0") + // Android raised this thread to THREAD_PRIORITY_TOP_APP_BOOST (a service the top app binds with + // BIND_IMPORTANT is scheduled as the top app); the program and its threads would keep it and + // run ahead of the game. They get the asker's priority instead, as a forked child would. + runCatching { Process.setThreadPriority(nice) } + Os.execve(argv[0], argv.map(fill).toTypedArray(), + env.filterNot { it.startsWith("DDH_WORKER_PID=") }.map(fill).toTypedArray() + mask + + "DDH_WORKER_PID=${Process.myPid()}") + } catch (e: ErrnoException) { + Log.e(TAG, "could not exec ${argv.firstOrNull()}", e) + } + Process.killProcess(Process.myPid()) + } + + /** + * Binder fds stay open across the exec, at [from] or above, where no fd of the program goes. + * Returns the highest fd used and the one on /dev/binder, whose closing Android takes for + * the death of this process. + */ + private fun keepBinderOpen(from: Int): Pair { + var highest = from - 1 + var binder = -1 + File("/proc/self/fd").listFiles()?.forEach { link -> + val target = runCatching { Os.readlink(link.path) }.getOrNull() ?: return@forEach + if (target !in BINDER_DEVICES && !target.startsWith("/dev/binderfs/")) return@forEach + // A copy, not adoptFd(): some of these fds are owned (fdsan) by a ParcelFileDescriptor. + val copy = runCatching { ParcelFileDescriptor.fromFd(link.name.toIntOrNull() ?: return@forEach) }.getOrNull() + ?: return@forEach + val kept = Os.fcntlInt(copy.fileDescriptor, OsConstants.F_DUPFD, from) + highest = maxOf(highest, kept) + if (target.substringAfterLast('/') == "binder") binder = kept + copy.close() + } + return highest to binder + } + + companion object { + const val RUN = IBinder.FIRST_CALL_TRANSACTION + /** An argument, or a variable's whole value, in an app launch: replaced by the number of its kept binder fd. */ + const val BINDER_FD_TOKEN = "@DDH_WORKER_BINDER_FD@" + // Longer than the app may wait for the hook's "go" (GuestWorkers.ACK_TIMEOUT_MS) before it commits + private const val GO_TIMEOUT_MS = 15000 + private val BINDER_DEVICES = setOf("/dev/binder", "/dev/hwbinder", "/dev/vndbinder") + private const val BINDER_FDS = 900 + private const val MOVED_FDS = 1200 + private const val TAG = "GuestWorker" + private val kept = ArrayList() + + fun isWorkerProcess(context: Context, process: String?): Boolean = + process != null && process.startsWith(context.packageName + ":g") && + process.substring(context.packageName.length + 2).all { it.isDigit() } + } +} + +class GuestWorker0 : GuestWorker() +class GuestWorker1 : GuestWorker() +class GuestWorker2 : GuestWorker() +class GuestWorker3 : GuestWorker() +class GuestWorker4 : GuestWorker() +class GuestWorker5 : GuestWorker() +class GuestWorker6 : GuestWorker() +class GuestWorker7 : GuestWorker() +class GuestWorker8 : GuestWorker() +class GuestWorker9 : GuestWorker() +class GuestWorker10 : GuestWorker() +class GuestWorker11 : GuestWorker() +class GuestWorker12 : GuestWorker() +class GuestWorker13 : GuestWorker() +class GuestWorker14 : GuestWorker() +class GuestWorker15 : GuestWorker() +class GuestWorker16 : GuestWorker() +class GuestWorker17 : GuestWorker() +class GuestWorker18 : GuestWorker() +class GuestWorker19 : GuestWorker() +class GuestWorker20 : GuestWorker() +class GuestWorker21 : GuestWorker() +class GuestWorker22 : GuestWorker() +class GuestWorker23 : GuestWorker() +class GuestWorker24 : GuestWorker() +class GuestWorker25 : GuestWorker() +class GuestWorker26 : GuestWorker() +class GuestWorker27 : GuestWorker() +class GuestWorker28 : GuestWorker() +class GuestWorker29 : GuestWorker() +class GuestWorker30 : GuestWorker() +class GuestWorker31 : GuestWorker() +class GuestWorker32 : GuestWorker() +class GuestWorker33 : GuestWorker() +class GuestWorker34 : GuestWorker() +class GuestWorker35 : GuestWorker() +class GuestWorker36 : GuestWorker() +class GuestWorker37 : GuestWorker() +class GuestWorker38 : GuestWorker() +class GuestWorker39 : GuestWorker() +class GuestWorker40 : GuestWorker() +class GuestWorker41 : GuestWorker() +class GuestWorker42 : GuestWorker() +class GuestWorker43 : GuestWorker() +class GuestWorker44 : GuestWorker() +class GuestWorker45 : GuestWorker() +class GuestWorker46 : GuestWorker() +class GuestWorker47 : GuestWorker() +class GuestWorker48 : GuestWorker() +class GuestWorker49 : GuestWorker() +class GuestWorker50 : GuestWorker() +class GuestWorker51 : GuestWorker() +class GuestWorker52 : GuestWorker() +class GuestWorker53 : GuestWorker() +class GuestWorker54 : GuestWorker() +class GuestWorker55 : GuestWorker() +class GuestWorker56 : GuestWorker() +class GuestWorker57 : GuestWorker() +class GuestWorker58 : GuestWorker() +class GuestWorker59 : GuestWorker() +class GuestWorker60 : GuestWorker() +class GuestWorker61 : GuestWorker() +class GuestWorker62 : GuestWorker() +class GuestWorker63 : GuestWorker() +class GuestWorker64 : GuestWorker() +class GuestWorker65 : GuestWorker() +class GuestWorker66 : GuestWorker() +class GuestWorker67 : GuestWorker() +class GuestWorker68 : GuestWorker() +class GuestWorker69 : GuestWorker() +class GuestWorker70 : GuestWorker() +class GuestWorker71 : GuestWorker() +class GuestWorker72 : GuestWorker() +class GuestWorker73 : GuestWorker() +class GuestWorker74 : GuestWorker() +class GuestWorker75 : GuestWorker() +class GuestWorker76 : GuestWorker() +class GuestWorker77 : GuestWorker() +class GuestWorker78 : GuestWorker() +class GuestWorker79 : GuestWorker() +class GuestWorker80 : GuestWorker() +class GuestWorker81 : GuestWorker() +class GuestWorker82 : GuestWorker() +class GuestWorker83 : GuestWorker() +class GuestWorker84 : GuestWorker() +class GuestWorker85 : GuestWorker() +class GuestWorker86 : GuestWorker() +class GuestWorker87 : GuestWorker() +class GuestWorker88 : GuestWorker() +class GuestWorker89 : GuestWorker() +class GuestWorker90 : GuestWorker() +class GuestWorker91 : GuestWorker() +class GuestWorker92 : GuestWorker() +class GuestWorker93 : GuestWorker() +class GuestWorker94 : GuestWorker() +class GuestWorker95 : GuestWorker() +class GuestWorker96 : GuestWorker() +class GuestWorker97 : GuestWorker() +class GuestWorker98 : GuestWorker() +class GuestWorker99 : GuestWorker() +class GuestWorker100 : GuestWorker() +class GuestWorker101 : GuestWorker() +class GuestWorker102 : GuestWorker() +class GuestWorker103 : GuestWorker() +class GuestWorker104 : GuestWorker() +class GuestWorker105 : GuestWorker() +class GuestWorker106 : GuestWorker() +class GuestWorker107 : GuestWorker() +class GuestWorker108 : GuestWorker() +class GuestWorker109 : GuestWorker() +class GuestWorker110 : GuestWorker() +class GuestWorker111 : GuestWorker() +class GuestWorker112 : GuestWorker() +class GuestWorker113 : GuestWorker() +class GuestWorker114 : GuestWorker() +class GuestWorker115 : GuestWorker() +class GuestWorker116 : GuestWorker() +class GuestWorker117 : GuestWorker() +class GuestWorker118 : GuestWorker() +class GuestWorker119 : GuestWorker() +class GuestWorker120 : GuestWorker() +class GuestWorker121 : GuestWorker() +class GuestWorker122 : GuestWorker() +class GuestWorker123 : GuestWorker() +class GuestWorker124 : GuestWorker() +class GuestWorker125 : GuestWorker() +class GuestWorker126 : GuestWorker() +class GuestWorker127 : GuestWorker() + +/** The pool of [GuestWorker] processes, and the socket guests ask it through (`droiddeck-spawn`). */ +object GuestWorkers { + private const val TAG = "GuestWorkers" + private val classes: List> = listOf( + GuestWorker0::class.java, GuestWorker1::class.java, GuestWorker2::class.java, + GuestWorker3::class.java, GuestWorker4::class.java, GuestWorker5::class.java, + GuestWorker6::class.java, GuestWorker7::class.java, GuestWorker8::class.java, + GuestWorker9::class.java, GuestWorker10::class.java, GuestWorker11::class.java, + GuestWorker12::class.java, GuestWorker13::class.java, GuestWorker14::class.java, + GuestWorker15::class.java, GuestWorker16::class.java, GuestWorker17::class.java, + GuestWorker18::class.java, GuestWorker19::class.java, GuestWorker20::class.java, + GuestWorker21::class.java, GuestWorker22::class.java, GuestWorker23::class.java, + GuestWorker24::class.java, GuestWorker25::class.java, GuestWorker26::class.java, + GuestWorker27::class.java, GuestWorker28::class.java, GuestWorker29::class.java, + GuestWorker30::class.java, GuestWorker31::class.java, GuestWorker32::class.java, + GuestWorker33::class.java, GuestWorker34::class.java, GuestWorker35::class.java, + GuestWorker36::class.java, GuestWorker37::class.java, GuestWorker38::class.java, + GuestWorker39::class.java, GuestWorker40::class.java, GuestWorker41::class.java, + GuestWorker42::class.java, GuestWorker43::class.java, GuestWorker44::class.java, + GuestWorker45::class.java, GuestWorker46::class.java, GuestWorker47::class.java, + GuestWorker48::class.java, GuestWorker49::class.java, GuestWorker50::class.java, + GuestWorker51::class.java, GuestWorker52::class.java, GuestWorker53::class.java, + GuestWorker54::class.java, GuestWorker55::class.java, GuestWorker56::class.java, + GuestWorker57::class.java, GuestWorker58::class.java, GuestWorker59::class.java, + GuestWorker60::class.java, GuestWorker61::class.java, GuestWorker62::class.java, + GuestWorker63::class.java, GuestWorker64::class.java, GuestWorker65::class.java, + GuestWorker66::class.java, GuestWorker67::class.java, GuestWorker68::class.java, + GuestWorker69::class.java, GuestWorker70::class.java, GuestWorker71::class.java, + GuestWorker72::class.java, GuestWorker73::class.java, GuestWorker74::class.java, + GuestWorker75::class.java, GuestWorker76::class.java, GuestWorker77::class.java, + GuestWorker78::class.java, GuestWorker79::class.java, GuestWorker80::class.java, + GuestWorker81::class.java, GuestWorker82::class.java, GuestWorker83::class.java, + GuestWorker84::class.java, GuestWorker85::class.java, GuestWorker86::class.java, + GuestWorker87::class.java, GuestWorker88::class.java, GuestWorker89::class.java, + GuestWorker90::class.java, GuestWorker91::class.java, GuestWorker92::class.java, + GuestWorker93::class.java, GuestWorker94::class.java, GuestWorker95::class.java, + GuestWorker96::class.java, GuestWorker97::class.java, GuestWorker98::class.java, + GuestWorker99::class.java, GuestWorker100::class.java, GuestWorker101::class.java, + GuestWorker102::class.java, GuestWorker103::class.java, GuestWorker104::class.java, + GuestWorker105::class.java, GuestWorker106::class.java, GuestWorker107::class.java, + GuestWorker108::class.java, GuestWorker109::class.java, GuestWorker110::class.java, + GuestWorker111::class.java, GuestWorker112::class.java, GuestWorker113::class.java, + GuestWorker114::class.java, GuestWorker115::class.java, GuestWorker116::class.java, + GuestWorker117::class.java, GuestWorker118::class.java, GuestWorker119::class.java, + GuestWorker120::class.java, GuestWorker121::class.java, GuestWorker122::class.java, + GuestWorker123::class.java, GuestWorker124::class.java, GuestWorker125::class.java, + GuestWorker126::class.java, GuestWorker127::class.java, + ) + + private class Slot(val index: Int) { + lateinit var connection: ServiceConnection + val connected = CountDownLatch(1) + @Volatile var service: IBinder? = null + @Volatile var pid = -1 + @Volatile var guest = false + /** The session it runs a program for ([serve]'s number). */ + @Volatile var session = 0 + @Volatile var onExit: ((Int) -> Unit)? = null + /** The priority it runs its program at: the asker's (a guest, or the app thread that started it). */ + @Volatile var nice = 0 + /** Set once its program was handed over: only then does its end count as the program's. */ + @Volatile var started = false + /** Between the pid and the last word of a launch (under the slots lock): its end is held back. */ + var launching = false + /** It ended while launching: reported once the launch turns out to have run, never otherwise. */ + var endedLaunching = false + } + + private val slots = arrayOfNulls(classes.size) + // Workers bound ahead of need while a session runs: a zygote fork and the bind take about + // 60-100 ms, which every program the session starts would otherwise wait for. + private val warm = ArrayDeque() + @Volatile private var warmTarget = 0 + // Numbers the sessions: an old session's teardown can still be running when the next one starts. + @Volatile private var session = 0 + // The latest session whose teardown has begun + @Volatile private var stopped = 0 + // Held for a launch's last word and for marking a session stopped + private val authorizing = Any() + private val warming = java.util.concurrent.atomic.AtomicBoolean(false) + private const val WARM_WORKERS = 2 + // A game's start hands off a burst of programs (Wine's services, the agent's checks) within a few + // seconds: bound ahead while the client starts it, not forked while the game draws its first frames. + private const val LAUNCH_WORKERS = 16 + private const val LAUNCH_MS = 20_000L + @Volatile private var launchUntil = 0L + private val launches = java.util.concurrent.atomic.AtomicInteger() + private const val ACK_TIMEOUT_MS = 5000 + private const val ANSWER_TIMEOUT_MS = 5000 + private const val RECEIVE_TIMEOUT_MS = 10000 + // argv and the environment of one exec, with room: Linux caps them at a quarter of the stack + private const val MAX_REQUEST_BYTES = 8 shl 20 + private const val MAX_RECEIVING = 32 + private val receiving = java.util.concurrent.atomic.AtomicInteger() + private val connections = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "guest-worker-binder").apply { isDaemon = true } } + @Volatile private var server: Thread? = null + // Android sets a worker's main thread to THREAD_PRIORITY_TOP_APP_BOOST again each time the app returns to the top + private const val TOP_APP_BOOST = -10 + private const val PRIORITY_CHECK_MS = 2000L + @Volatile private var keeper: Thread? = null + + /** The app, once [attach] or [serve] ran in its main process; null before. */ + @Volatile var context: Context? = null + private set + + /** Whether the session runs its programs in workers: the native userland, and not turned off. */ + fun enabled(context: Context): Boolean = handoffAllowed(context) && NativeGuest.enabled(context) + + private fun handoffAllowed(context: Context): Boolean = + android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context) + + /** How the running session's root was started: in a worker (true) or counted (false); null with none running. */ + @Volatile var sessionRootUncounted: Boolean? = null + + /** + * Whether Android's child-process limit is out of the session's way: as the running session + * started (a proot session, or one whose root fell back to a counted start, is not), else as + * the next one would start. + */ + fun limitHandled(context: Context): Boolean = + sessionRootUncounted ?: (NativeGuest.sessionMode != false && handoffAllowed(context) && NativeGuest.nextSession(context)) + + /** Whether pid is a program running in one of the workers. */ + fun runsInWorker(pid: Int): Boolean = pid > 0 && synchronized(slots) { slots.any { it != null && it.started && it.pid == pid } } + + fun socketName(context: Context): String = "droiddeck-spawn." + context.packageName + "." + Process.myUid() + + /** + * Runs [argv] (a host command line) as the main process of a free worker with [env] and the + * fds in [stdio] as its 0, 1 and 2. Returns its pid, or -1. Blocks: not for the main thread. + * [onExit] runs once the process is gone. + */ + fun start(context: Context, argv: List, env: List, stdio: List, onExit: (Int) -> Unit): Int = + start(context, argv, env, stdio, IntArray(stdio.size) { it }, onExit) + + /** As [start], with the fds in [fds] placed at the numbers in [targets]. */ + fun start(context: Context, argv: List, env: List, fds: List, targets: IntArray, + onExit: (Int) -> Unit): Int = start(context, argv, env, fds, targets, false, onExit) + + /** + * [guest]: one of the session's guest programs, which [guestPids] lists and [stopGuests] ends. + * [commit] runs with the pid before the worker may run the program; false, and it does not. + * [confirmed] runs once the worker has taken it on, just before it is told to run it; false, and it does not. + * [owner]: the session asking (the one a guest's request names), else the latest. + */ + private fun start(context: Context, argv: List, env: List, fds: List, targets: IntArray, + guest: Boolean, onExit: (Int) -> Unit, commit: (Int) -> Boolean = { true }, + confirmed: () -> Boolean = { true }, owner: Int = session, + nice: Int = Process.getThreadPriority(Process.myTid()), + testWorker: FrameAcquireWorkerProbe.Qualified? = null): Int { + val app = context.applicationContext + if (guest && owner <= stopped) { + Log.w(TAG, (if (owner == 0) "a request naming no session" else "session $owner is stopping") + + ": not starting ${argv.firstOrNull()}") + return -1 + } + val slot = takeWarm() ?: bind(app)?.takeIf { fresh -> + fresh.connected.await(10, TimeUnit.SECONDS).also { if (!it) release(app, fresh) } + } ?: run { + Log.w(TAG, "no worker started for ${argv.firstOrNull()}") + return -1 + } + slot.guest = guest + slot.session = owner + slot.onExit = onExit + slot.nice = nice + // during a game's start the pool drains instead: its refill would fork while the game starts + if (android.os.SystemClock.elapsedRealtime() >= launchUntil) refill(app) + // The worker execs once a byte comes through this socket: after the reply has reached us, so + // that its exec does not cut the reply off, and after the slot is marked started. Closed + // without one, the worker ends without running the program (the caller starts it another way). + // It answers with a byte of its own: without that it gave up waiting, and nothing runs. + var go: Array? = null + var data: Parcel? = Parcel.obtain() + val reply = Parcel.obtain() + try { + go = ParcelFileDescriptor.createSocketPair() + data!!.writeStringArray(argv.toTypedArray()) + data.writeStringArray(env.toTypedArray()) + data.writeInt(fds.size) + fds.forEach { data.writeFileDescriptor(it.fileDescriptor) } + data.writeIntArray(targets) + data.writeInt(if (guest) 0 else 1) + data.writeFileDescriptor(go[0].fileDescriptor) + data.writeInt(nice) + val service = checkNotNull(slot.service) + if (testWorker != null) data.writeInt(FrameAcquireWorkerProbe.RECEIPT_TAG) + check(service.transact(GuestWorker.RUN, data, reply, 0)) + // The worker has its own copy: with ours closed (and the request's, which holds one too), + // a worker that gave up leaves no reader + data.recycle() + data = null + go[0].close() + val pid = reply.readInt() + val startTicks = if (testWorker != null) { + val size = reply.dataAvail() + if (size == FrameAcquireWorkerProbe.RECEIPT_BYTES) + FrameAcquireWorkerProbe.validReceipt(pid, reply.readInt(), reply.readLong(), size) + else 0L + } else 0L + // Once a session's teardown has begun (stopGuests), none of its programs may start: it + // would not find them. + val stopping = { guest && owner <= stopped } + if (stopping() || !commit(pid)) { + Log.w(TAG, "worker ${slot.index}: ${argv.firstOrNull()} was not taken on") + release(app, slot) + return -1 + } + // launching, not started yet: an end before the last word is reported only if the launch ran + val live = synchronized(slots) { + (slots[slot.index] === slot && !stopping()).also { if (it) { slot.pid = pid; slot.launching = true } } + } + if (!live) { + Log.w(TAG, "worker ${slot.index} ended, or its session is stopping, before running ${argv.firstOrNull()}") + release(app, slot) + return -1 + } + Os.write(go[1].fileDescriptor, byteArrayOf(1), 0, 1) + val answer = StructPollfd().apply { fd = go[1].fileDescriptor; events = OsConstants.POLLIN.toShort() } + // then the word to run it: given only here, once its answer is in, so that a worker whose + // answer came too late never runs a program this call reports as not started. [confirmed] + // goes first: a caller that hears nothing runs the program itself, so it must have heard + // before the worker may run it (an app dying in between loses the program, not doubles it). + // The word and a teardown's start exclude each other: a launch is authorized before stopGuests() + // marks the session stopped, and is then stopped with the pids it takes (guestPids lists a + // launching slot), or never. + val answered = Os.poll(arrayOf(answer), ANSWER_TIMEOUT_MS) > 0 && Os.read(go[1].fileDescriptor, ByteArray(1), 0, 1) == 1 + val accepted = answered && synchronized(authorizing) { + if (stopping() || !confirmed()) false + else { + if (testWorker != null) FrameAcquireWorkerProbe.publish(testWorker, pid, + if (slot.service === service) startTicks else 0L) + Os.write(go[1].fileDescriptor, byteArrayOf(1), 0, 1) == 1 + } + } + val endedRunning = synchronized(slots) { + slot.launching = false + if (accepted && !slot.endedLaunching) slot.started = true + accepted && slot.endedLaunching + } + if (!accepted) { + Log.w(TAG, "worker ${slot.index} did not take ${argv.firstOrNull()} on") + release(app, slot) + return -1 + } + // it ran and was already gone by now: its end, once + if (endedRunning) reportEnd(app, slot) + } catch (e: Exception) { + Log.w(TAG, "worker ${slot.index} refused ${argv.firstOrNull()}", e) + synchronized(slots) { slot.launching = false } + release(app, slot) + return -1 + } finally { + data?.recycle() + reply.recycle() + go?.forEach { runCatching { it.close() } } + } + Log.i(TAG, "worker ${slot.index} (pid ${slot.pid}) runs ${argv.lastOrNull { !it.startsWith("-") }}") + return slot.pid + } + + /** Binds a free worker; its [Slot.connected] opens once it is up. Null when all are in use. */ + private fun bind(app: Context): Slot? { + val slot = synchronized(slots) { + val index = slots.indexOfFirst { it == null } + if (index < 0) { + Log.w(TAG, "all ${slots.size} workers are busy") + return null + } + Slot(index).also { slots[index] = it } + } + slot.connection = object : ServiceConnection { + override fun onServiceConnected(name: ComponentName, binder: IBinder) { + slot.service = binder + slot.connected.countDown() + } + + override fun onServiceDisconnected(name: ComponentName) = release(app, slot) + + override fun onBindingDied(name: ComponentName) = release(app, slot) + } + // Callbacks off the main thread: start() waits for onServiceConnected, and a caller holding a + // lock the main thread is waiting for (PulseAudio's launch) would otherwise wait out the timeout. + val bound = runCatching { + app.bindService(Intent(app, classes[slot.index]), Context.BIND_AUTO_CREATE or Context.BIND_IMPORTANT, + connections, slot.connection) + }.onFailure { Log.w(TAG, "worker ${slot.index} could not be bound", it) }.getOrDefault(false) + if (!bound) { + release(app, slot) + return null + } + return slot + } + + private fun takeWarm(): Slot? = synchronized(slots) { + while (warm.isNotEmpty()) { + val slot = warm.removeFirst() + if (slots[slot.index] === slot && slot.service?.isBinderAlive == true) return slot + } + null + } + + /** Brings the warm workers back up to [warmTarget], one at a time, off the caller's thread. */ + private fun refill(app: Context) { + if (warmTarget == 0 || !warming.compareAndSet(false, true)) return + Thread({ + try { + while (true) { + val missing = warmTarget - synchronized(slots) { warm.size } + if (missing <= 0) break + // all at once: the zygote forks them in parallel + val fresh = (1..missing).mapNotNull { bind(app) } + if (fresh.isEmpty()) break + for (slot in fresh) { + if (!slot.connected.await(10, TimeUnit.SECONDS)) { + release(app, slot) + continue + } + // decided once, under the lock: kept warm, or released + val kept = synchronized(slots) { + (slots[slot.index] === slot && warmTarget > 0).also { if (it) warm.addLast(slot) } + } + if (!kept) release(app, slot) + } + } + } finally { + warming.set(false) + } + }, "guest-worker-warm").apply { isDaemon = true; start() } + } + + /** A game is about to start: [LAUNCH_WORKERS] bound ahead, back to [WARM_WORKERS] once it is up. */ + fun expectLaunch(context: Context) { + val app = context.applicationContext + val raised = synchronized(slots) { (warmTarget > 0).also { if (it) warmTarget = LAUNCH_WORKERS } } + if (!raised) return + launchUntil = android.os.SystemClock.elapsedRealtime() + LAUNCH_MS + val launch = launches.incrementAndGet() + refill(app) + Thread({ + try { + Thread.sleep(LAUNCH_MS) + } catch (_: InterruptedException) { + return@Thread + } + if (launches.get() != launch) return@Thread + val extra = synchronized(slots) { + if (warmTarget != LAUNCH_WORKERS) emptyList() + else { + warmTarget = WARM_WORKERS + List((warm.size - WARM_WORKERS).coerceAtLeast(0)) { warm.removeLast() } + } + } + extra.forEach { release(app, it) } + refill(app) + }, "guest-worker-launch").apply { isDaemon = true; start() } + } + + private fun release(app: Context, slot: Slot) { + var report = false + val removed = synchronized(slots) { + warm.remove(slot) + if (slot.launching) slot.endedLaunching = true else report = slot.started + (slots[slot.index] === slot).also { if (it) slots[slot.index] = null } + } + if (!removed) return + runCatching { app.unbindService(slot.connection) } + if (report) reportEnd(app, slot) + } + + private fun reportEnd(app: Context, slot: Slot) { + val onExit = slot.onExit ?: return + Thread({ onExit(exitStatus(app, slot.pid)) }, "guest-worker-exit").start() + } + + /** The worker's exit as a wait status (exit code << 8, or the signal), -1 when unknown. */ + private fun exitStatus(app: Context, pid: Int): Int { + if (pid <= 0 || android.os.Build.VERSION.SDK_INT < 30) return -1 + val am = app.getSystemService(ActivityManager::class.java) + var recorded = false + repeat(20) { + am.getHistoricalProcessExitReasons(app.packageName, pid, 1).firstOrNull()?.let { + recorded = true + // an exit code only when the process exited itself; a signal number otherwise (a native crash) + if (it.reason == android.app.ApplicationExitInfo.REASON_EXIT_SELF) return (it.status and 0xff) shl 8 + if (it.status in 1..64) return it.status and 0x7f + // Android records the death first and the zygote's status later (as UNKNOWN, 0, then + // EXIT_SELF): a reason without a status may still be completed + if (it.reason != android.app.ApplicationExitInfo.REASON_UNKNOWN) return OsConstants.SIGKILL + } + Thread.sleep(50) + } + // killed by Android with no signal recorded, not a clean exit + return if (recorded) OsConstants.SIGKILL else -1 + } + + /** The pids of session [of]'s guest programs running in workers. */ + fun guestPids(of: Int = session): List = + synchronized(slots) { slots.mapNotNull { s -> s?.takeIf { it.guest && it.session == of }?.pid?.takeIf { it > 0 } } } + + /** Ends session [of]'s guest programs that are still running, and, for the latest session, the warm workers. */ + fun stopGuests(of: Int = session) { + // the check and the reset together: a new session's serve() may be under way + val drained = synchronized(authorizing) { + synchronized(slots) { + stopped = maxOf(stopped, of) + if (of != session) emptyList() else { warmTarget = 0; warm.toList().also { warm.clear() } } + } + } + context?.let { app -> drained.forEach { release(app, it) } } + FrameAcquireWorkerProbe.revoke(of) + val pids = guestPids(of) + if (pids.isEmpty()) return + pids.forEach { Process.sendSignal(it, OsConstants.SIGTERM) } + Thread.sleep(500) + pids.forEach { Process.killProcess(it) } + } + + /** Listens for `droiddeck-spawn` requests from the session's guests. */ + fun attach(context: Context) { + this.context = context.applicationContext + } + + /** Puts a running program's main thread back to its asker's priority after Android boosted it (once started, never stops). */ + private fun keepPriorities() { + synchronized(this) { + if (keeper != null) return + keeper = Thread({ + while (true) { + try { + Thread.sleep(PRIORITY_CHECK_MS) + } catch (_: InterruptedException) { + return@Thread + } + val running = synchronized(slots) { + slots.filterNotNull().filter { it.started && it.pid > 0 && it.nice != TOP_APP_BOOST } + } + for (s in running) runCatching { + if (Process.getThreadPriority(s.pid) == TOP_APP_BOOST) Process.setThreadPriority(s.pid, s.nice) + } + } + }, "guest-worker-priority").apply { isDaemon = true; start() } + } + } + + /** Starts a session's use of the workers (and the spawn socket, once); returns its number. */ + fun serve(context: Context): Int { + val app = context.applicationContext + this.context = app + val number = synchronized(slots) { warmTarget = WARM_WORKERS; ++session } + refill(app) + keepPriorities() + synchronized(this) { + if (server != null) return number + server = Thread({ + val socket = try { + LocalServerSocket(socketName(app)) + } catch (e: Exception) { + Log.e(TAG, "no spawn socket", e) + synchronized(this) { server = null } + return@Thread + } + while (true) { + val client = runCatching { socket.accept() }.getOrNull() + if (client == null) { + Thread.sleep(100) // out of fds, for one: do not spin + continue + } + // A bounded number of requests still coming in: a stalled sender holds a thread + if (receiving.incrementAndGet() > MAX_RECEIVING) { + receiving.decrementAndGet() + Log.w(TAG, "$MAX_RECEIVING spawn requests are still coming in: refusing another") + runCatching { client.close() } + continue + } + Thread({ + try { + handle(app, client) { receiving.decrementAndGet() } + } catch (e: Throwable) { + Log.w(TAG, "spawn request failed", e) + } + }, "guest-spawn").start() + } + }, "guest-spawn-server").apply { isDaemon = true; start() } + } + return number + } + + private fun handle(app: Context, client: LocalSocket, received: () -> Unit) { + var receiving = true + val done = { if (receiving) { receiving = false; received() } } + try { + handleRequest(app, client, done) + } finally { + done() + } + } + + private fun handleRequest(app: Context, client: LocalSocket, received: () -> Unit) { + client.use { + if (client.peerCredentials.uid != Process.myUid()) return + // The whole request and its fds within this, however slowly they come (the wait for a + // program's exit is not): each read gets what is left of it + val deadline = android.os.SystemClock.elapsedRealtime() + RECEIVE_TIMEOUT_MS + fun left() { + val ms = deadline - android.os.SystemClock.elapsedRealtime() + if (ms <= 0) throw java.net.SocketTimeoutException("spawn request not received in time") + client.soTimeout = ms.toInt() + } + val input = DataInputStream(client.inputStream) + val fds = ArrayList() + fun take() { + val received = client.ancillaryFileDescriptors.orEmpty() + try { + received.forEach { fds.add(ParcelFileDescriptor.dup(it)) } + } finally { + received.forEach { runCatching { Os.close(it) } } + } + } + // fds can come with any read, the request's own bytes too: each read's are taken at once + fun fill(bytes: ByteArray) { + var got = 0 + while (got < bytes.size) { + left() + val n = input.read(bytes, got, bytes.size - got) + take() + if (n < 0) throw java.io.EOFException("spawn request ended at $got of ${bytes.size} bytes") + got += n + } + } + // Until start() has them: closed on every way out before that, from the first byte on + var handedOver = false + try { + val length = ByteArray(4).also { fill(it) }.let { java.nio.ByteBuffer.wrap(it).int } + if (length !in 1..MAX_REQUEST_BYTES) { + Log.w(TAG, "spawn request of $length bytes refused") + return + } + val payload = ByteArray(length).also { fill(it) } + val request = JSONObject(String(payload)) + if (request.has("fdchunks")) { + // The hook sends its fds after the request, a chunk with each byte (hook/handoff.c) + val total = (request.optJSONArray("fds")?.length() ?: 0) + (if (request.has("table")) 1 else 0) + while (fds.size < total) { + left() + if (input.read() < 0) throw java.io.EOFException("fds ended at ${fds.size} of $total") + take() + } + } else { + take() + } + received() + val argv = request.getJSONArray("argv").let { a -> List(a.length()) { a.getString(it) } } + val env = LinkedHashMap() + request.optJSONObject("env")?.let { o -> o.keys().forEach { env[it] = o.getString(it) } } + request.optJSONArray("envlist")?.let { a -> + for (i in 0 until a.length()) a.getString(i).split('=', limit = 2).let { if (it.size == 2) env[it[0]] = it[1] } + } + // What the hook told the program that asked (it may run in a worker itself) is not this one's + env.keys.removeAll { it.startsWith("DDH_") } + val cwd = request.optString("cwd", "/") + val wait = request.optBoolean("wait", false) + // A path without a slash names a file in the cwd, as execve() takes it, not one on PATH + val file = request.optString("file", "").let { if (it.isNotEmpty() && '/' !in it) "./$it" else it } + // The handoff table (the hook's) comes last among the fds; the rest go to these numbers. + val tableIndex = request.optInt("table", -1) + val numbers = request.optJSONArray("fds")?.let { a -> IntArray(a.length()) { a.getInt(it) } } ?: IntArray(3) { it } + val table = fds.getOrNull(tableIndex)?.takeIf { pfd -> + runCatching { Os.readlink("/proc/self/fd/${pfd.fd}") }.getOrNull()?.contains("ddnatv-handoff") == true + } + val slot = request.optInt("slot", -1) + val parent = request.optInt("parent", -1) + var programFds = fds.filterIndexed { i, _ -> i != tableIndex } + var targets = numbers + if (table != null && slot >= 0) { + // The program reports its own exit status into the table (hook/handoff.c) + val tableFd = (numbers.maxOrNull() ?: 2) + 1 + programFds = programFds + table + targets = numbers + tableFd + env["DDH_TABLE"] = "$tableFd:$slot:$parent:${request.optInt("child", -1)}" + } + val root = env["DDNATV_ROOT"]?.let(::File) + val out = client.outputStream + if (root == null || argv.isEmpty()) { + out.write("error no guest root or program\n".toByteArray()) + return + } + val shell = listOf("/usr/bin/bash", "/bin/bash").first { File(root, it.removePrefix("/")).isFile } + val args = if (file.isNotEmpty()) { + listOf("-c", "unset DDH_WRAPPER; cd -- \"\$1\" 2>/dev/null; a=\$2; f=\$3; shift 3; exec -a \"\$a\" \"\$f\" \"\$@\"", + "droiddeck-spawn", cwd, argv[0], file) + argv.drop(1) + } else { + listOf("-c", "unset DDH_WRAPPER; cd -- \"\$1\" 2>/dev/null; shift; exec \"\$@\"", "droiddeck-spawn", cwd) + argv + } + val command = NativeGuest.command(root, shell, args) + env["DDNATV_REAL_EXE"] = File(root, shell.removePrefix("/")).path + // The hook restores these in the program (tools/nativeguest/hook/handoff.c). + if (request.has("sigign")) env["DDH_SIGIGN"] = request.getLong("sigign").toString() + if (request.has("nofile")) { + env["DDH_NOFILE"] = request.getLong("nofile").toString() + + (if (request.has("nofilemax")) ":" + request.getLong("nofilemax") else "") + } + if (request.has("umask")) env["DDH_UMASK"] = request.getLong("umask").toString() + if (request.has("pgid")) env["DDH_PGID"] = request.getLong("pgid").toString() + if (request.has("anchor")) env["DDH_ANCHOR"] = request.getLong("anchor").toString() + if (request.has("pstart")) env["DDH_PSTART"] = request.getLong("pstart").toString() + if (request.has("astart")) env["DDH_ASTART"] = request.getLong("astart").toString() + env["DDH_SIGMASK"] = request.optLong("sigmask", 0L).toString() + // The shell above: the hook restores nothing there (bash changes its own signal mask), + // only in the program it execs, which no longer has this. + env["DDH_WRAPPER"] = "1" + val child = request.optInt("child", -1) + val exited = CountDownLatch(1) + var status = -1 + var worker = -1 + // The hook answers the pid with "go" (ack): without it (it died, or gave up and runs the + // program itself) the worker must not run it too. + val ack = request.optBoolean("ack", false) + var answered = false + // the hook's last word, sent once the worker has taken the program on and before it runs it + var confirmedToHook = false + // The session whose guest asks, not the latest: a new session can start (serve()) while an + // older one's guests are still sending, and that older one's teardown must find its programs. + // A request that names none is refused (start() runs nothing for session 0): the hook and + // droiddeck-spawn always name it, and which session's it is cannot be told otherwise. + val owner = request.optInt("session", 0).coerceAtLeast(0) + // The sender is the forked child (or droiddeck-spawn): its priority is the one the program would inherit + val nice = runCatching { Process.getThreadPriority(client.peerCredentials.pid) }.getOrDefault(Process.THREAD_PRIORITY_DEFAULT) + val testWorker = FrameAcquireWorkerProbe.match(owner, root, file, argv, ack) + val pid = start(app, command, env.map { (k, v) -> "$k=$v" }, programFds, targets, true, owner = owner, nice = nice, onExit = { code -> + if (testWorker != null && worker > 1) FrameAcquireWorkerProbe.revoke(owner, worker) + status = code + if (table != null && slot >= 0) reportExit(table, slot, code, parent, child, worker) + exited.countDown() + }, confirmed = { + val confirmed = !ack || runCatching { + out.write("ok\n".toByteArray()) + out.flush() + confirmedToHook = true + }.isSuccess + confirmed + }, commit = { started -> + worker = started + if (!ack) return@start true + runCatching { + out.write("pid $started\n".toByteArray()) + out.flush() + answered = true + client.soTimeout = ACK_TIMEOUT_MS + // the whole line: a hook whose write stopped short treats it as failed and runs the program itself + val line = StringBuilder() + var ended = false + while (!ended) { + val c = input.read() + if (c < 0) break + if (c == '\n'.code) ended = true else line.append(c.toChar()) + } + ended && line.toString() == "go" + }.getOrDefault(false) + }, testWorker = testWorker) + if (pid <= 0 && testWorker != null && worker > 1) FrameAcquireWorkerProbe.revoke(owner, worker) + handedOver = true + programFds.filter { it !== table }.forEach { runCatching { it.close() } } + if (pid <= 0) table?.let { runCatching { it.close() } } + if (!answered) { + out.write(if (pid > 0) "pid $pid\n".toByteArray() else "error no worker\n".toByteArray()) + out.flush() + } else if (!confirmedToHook) { + // nothing runs it in a worker: the hook runs it itself + runCatching { out.write("error not started\n".toByteArray()); out.flush() } + } + if (pid > 0 && wait) { + exited.await() + // droiddeck-spawn exits with this: an exit code, or 128 plus the signal + val code = if (status < 0) 1 else if (status and 0x7f == 0) (status shr 8) and 0xff else 128 + (status and 0x7f) + out.write("exit $code\n".toByteArray()) + out.flush() + } + } finally { + if (!handedOver) fds.forEach { runCatching { it.close() } } + } + } + } + + // Layout of the hook's table (tools/nativeguest/hook/handoff.c): a 64-byte header, then 64-byte + // entries of int32 child, real, parent, state, ..., and at 32 the app's report: int32 status, child. + // The report is one 8-byte write tagged with the child it is for; only the hook changes an + // entry's state, so a report that lands after the entry went to another child is ignored there. + private fun reportExit(table: ParcelFileDescriptor, slot: Int, status: Int, parent: Int, child: Int, worker: Int) { + runCatching { + val entry = 64L + slot * 64L + val head = java.nio.ByteBuffer.allocate(16).order(java.nio.ByteOrder.nativeOrder()) + Os.pread(table.fileDescriptor, head, entry) + val real = head.getInt(4) + val state = head.getInt(12) + // Also while the hook holds the entry (TAKEN) or has already guessed its end (EXITED): + // the report is for this child only, and wins over the timeout's guess (ddh_status) + if (head.getInt(0) != child || head.getInt(8) != parent || (real != 0 && real != worker) || state !in 1..4) + return@runCatching + // An exit Android has no record of is reported as a failure, not as a signal. + val report = java.nio.ByteBuffer.allocate(8).order(java.nio.ByteOrder.nativeOrder()) + .putInt(0, if (status < 0) 1 shl 8 else status).putInt(4, child) + Os.pwrite(table.fileDescriptor, report, entry + 32) + if (parent > 0) Process.sendSignal(parent, OsConstants.SIGCHLD) + }.onFailure { Log.w(TAG, "could not report an exit to the guest's parent", it) } + runCatching { table.close() } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LegacyNames.kt b/app/src/main/java/com/droiddeck/launcher/runtime/LegacyNames.kt index 3f4589ae13..8008cf82ed 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LegacyNames.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LegacyNames.kt @@ -35,9 +35,40 @@ object LegacyNames { @Synchronized fun migrateEtc(root: File) { for ((old, new) in LINKED_DIRS) moveAndLink(File(root, old), File(root, new)) - File(root, "etc/droiddeck/empty").mkdirs() + clearEmptyStandIn(root) + File(root, NO_THERMAL).mkdirs() } + /** + * It stands in for /sys/bus/pci/devices, and libpci exits the whole process on an entry it cannot + * parse; older builds let thermal bind mount points leak into it. The guest can write here, so a + * link is never followed: one in place of the folder is removed, and one above it stops the cleanup. + */ + private fun clearEmptyStandIn(root: File) { + val linkedAbove = listOf("etc", "etc/droiddeck").firstOrNull { Files.isSymbolicLink(File(root, it).toPath()) } + if (linkedAbove != null) { + Log.w(TAG, "not clearing the empty stand-in: $linkedAbove is a link") + return + } + val empty = File(root, "etc/droiddeck/empty") + if (Files.isSymbolicLink(empty.toPath())) runCatching { Files.delete(empty.toPath()) } + .onFailure { Log.w(TAG, "could not remove the link at $empty", it); return } + empty.mkdirs() + empty.listFiles()?.forEach { entry -> + runCatching { deleteWithoutFollowing(entry.toPath()) }.onFailure { Log.w(TAG, "could not clear $entry", it) } + } + } + + private fun deleteWithoutFollowing(path: java.nio.file.Path) { + if (Files.isDirectory(path, java.nio.file.LinkOption.NOFOLLOW_LINKS)) { + Files.newDirectoryStream(path).use { entries -> entries.forEach(::deleteWithoutFollowing) } + } + Files.deleteIfExists(path) + } + + /** Stands in for a /sys/class/thermal the kernel won't list; proot adds the bound zones' mount points to it. */ + const val NO_THERMAL = "etc/droiddeck/no-thermal" + @Synchronized fun migrateRootfs(root: File) { migrateEtc(root) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt index b76172edb1..1f5d1a4d56 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt @@ -302,9 +302,9 @@ class LinuxNetworkLinkComponent( val etc = File(rootDir, "etc") replace(File(etc, "resolv.conf"), text) val hosts = File(etc, "hosts") - if (!hosts.isFile || !hosts.readText().contains("localhost")) { - hosts.writeText("127.0.0.1 localhost\n::1 localhost\n") - } + val existing = if (hosts.isFile) hosts.readText() else null + val wanted = hostsText(existing) + if (wanted != existing) replace(hosts, wanted) Log.i(TAG, "resolver: " + servers.joinToString(" ")) } catch (e: IOException) { Log.w(TAG, "Could not write the resolver", e) @@ -338,6 +338,42 @@ class LinuxNetworkLinkComponent( companion object { private val WRITES = Any() + private const val HOSTS_BLOCK_START = "# DroidDeck: Unity telemetry is refused (start)" + private const val HOSTS_BLOCK_END = "# DroidDeck: Unity telemetry is refused (end)" + + // Unity 5's player seeds its bundled OpenSSL before its first HTTPS request, and that code jumps + // to a bad address under FEX (Windlands, 428370). Refusing these telemetry hosts makes the request + // fail before TLS starts; the games run without them. + internal val UNITY_TELEMETRY_HOSTS = listOf( + "config.uca.cloud.unity3d.com", "api.uca.cloud.unity3d.com", "cdp.cloud.unity3d.com", + "stats.unity3d.com", "perf-events.cloud.unity3d.com", + ) + + internal fun hostsText(existing: String?): String { + val kept = mutableListOf() + var block: MutableList? = null + for (line in existing.orEmpty().lines()) { + when { + line == HOSTS_BLOCK_START -> { + block?.let(kept::addAll) + block = mutableListOf() + } + line == HOSTS_BLOCK_END -> block = null + block != null -> block!!.add(line) + else -> kept.add(line) + } + } + block?.let(kept::addAll) + kept.removeAll { it.isBlank() } + return buildString { + if (kept.none { it.substringBefore('#').contains("localhost") }) append("127.0.0.1 localhost\n::1 localhost\n") + kept.forEach { append(it).append('\n') } + append(HOSTS_BLOCK_START).append('\n') + append("0.0.0.0 ").append(UNITY_TELEMETRY_HOSTS.joinToString(" ")).append('\n') + append(HOSTS_BLOCK_END).append('\n') + } + } + internal fun gateways(properties: LinkProperties?, capabilities: NetworkCapabilities?): List = listOf(Inet4Address::class.java, Inet6Address::class.java).mapNotNull { family -> properties?.routes.orEmpty() diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java index f0e959d0c7..327e7fc1ea 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java @@ -185,7 +185,12 @@ public final class LinuxRuntime { public static List lastBinds(Context context) { List binds = lastBinds; if (binds != null) return binds; - return binds(context, null, null, android.os.Environment.getExternalStorageDirectory(), null); + return binds(context, null, null, sharedStorage(context), null); + } + + /** The phone's shared storage, or null when it should stay out of the container. */ + public static File sharedStorage(Context context) { + return SessionPrefs.mountSharedStorage(context) ? android.os.Environment.getExternalStorageDirectory() : null; } public static List prootPrefix(Context context, File root, String cwd) { @@ -199,6 +204,7 @@ public final class LinuxRuntime { } public static List prootPrefix(Context context, File root, String cwd, boolean fakeRoot) { + NativeGuest.relinkAfterProot(root); List cmd = new ArrayList<>(); cmd.addAll(com.droiddeck.launcher.core.HostProcess.dataExecutable(prootBinary(context).getPath())); cmd.add("--kill-on-exit"); @@ -242,7 +248,7 @@ public final class LinuxRuntime { // A kernel that refuses to list /sys/class/thermal (Pixel 10, Android 17) made mangoapp abort // at start ("filesystem_error ... Permission denied: '/sys/class/thermal/'") until its // wrapper gave up: it lists the directory for CPU temperatures. Empty there instead. - if (new File("/sys/class/thermal").list() == null) bind(cmd, new File(root, "etc/droiddeck/empty").getPath() + ":/sys/class/thermal"); + if (new File("/sys/class/thermal").list() == null) bind(cmd, new File(root, LegacyNames.NO_THERMAL).getPath() + ":/sys/class/thermal"); bind(cmd, context.getFilesDir().getPath()); bind(cmd, context.getCacheDir().getPath()); bind(cmd, liveDir(context).getPath()); @@ -511,7 +517,7 @@ public final class LinuxRuntime { public static List cpuTempZones() { java.util.Map replaced = replacedZoneTypes(); List zones = new ArrayList<>(); - for (java.util.Map.Entry zone : new java.util.TreeMap<>(thermalZones()).entrySet()) { + for (java.util.Map.Entry zone : thermalZones().entrySet()) { String type = zone.getKey(); if (type.contains("cpu") && !type.contains("gpu") && !replaced.containsKey(zone.getValue().getName())) { zones.add(zone.getValue()); @@ -554,23 +560,31 @@ public final class LinuxRuntime { private static String thermalZone(String sensor) { java.util.Map zones = thermalZones(); File zone = zones.get(sensor); - for (java.util.Map.Entry e : new java.util.TreeMap<>(zones).entrySet()) { + for (java.util.Map.Entry e : zones.entrySet()) { if (zone == null && e.getKey().contains(sensor)) zone = e.getValue(); } return zone != null ? new File(zone, "temp").getPath() : null; } - private static java.util.Map thermalZones() { + private static volatile java.util.SortedMap thermalZoneTypes; + + private static java.util.SortedMap thermalZones() { + java.util.SortedMap known = thermalZoneTypes; + if (known != null) return known; java.util.Map byType = new java.util.HashMap<>(); File[] zones = new File("/sys/class/thermal").listFiles((dir, n) -> n.startsWith("thermal_zone")); - if (zones == null) return byType; + if (zones == null) return java.util.Collections.emptySortedMap(); + boolean complete = true; for (File zone : zones) { try (java.io.BufferedReader r = new java.io.BufferedReader(new java.io.FileReader(new File(zone, "type")))) { byType.putIfAbsent(String.valueOf(r.readLine()).trim().toLowerCase(java.util.Locale.ROOT), zone); - } catch (IOException ignored) { + } catch (IOException e) { + complete = false; } } - return byType; + java.util.SortedMap sorted = java.util.Collections.unmodifiableSortedMap(new java.util.TreeMap<>(byType)); + if (complete && !sorted.isEmpty()) thermalZoneTypes = sorted; + return sorted; } private static void bindSystemFonts(List cmd, File root) { diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt index 61f91598d5..6e69ffe376 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt @@ -22,14 +22,24 @@ object NativeGuest { } fun enabled(context: Context): Boolean = - SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context)) + available(LinuxRuntime.rootDir(context)) + + /** + * Whether the next session will start natively. The session stages the hook from the APK before + * it starts, so the rootfs's loader decides, and a runtime still to be + * installed will have one. + */ + fun nextSession(context: Context): Boolean = + willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context)) + + internal fun willRun(root: File, installed: Boolean): Boolean = !installed || loader(root) != null /** The mode the running session started in; null between sessions. */ @Volatile var sessionMode: Boolean? = null /** * Whether a session's helpers (root commands, Flatpak sandboxes, installers) run natively: the - * session's own mode while one runs, as the setting can change under it and the rootfs is only + * session's own mode while one runs, as the rootfs is only * prepared for native programs at a session's start. */ fun forSession(context: Context): Boolean = sessionMode ?: enabled(context) @@ -94,8 +104,11 @@ object NativeGuest { private fun hostProgram(root: File, program: String): File = File(root, program.removePrefix("/")) /** The environment of the session process: the hook's root, the mounts proot used to make, the preload list. */ - fun sessionEnvironment(root: File, binds: List, program: String, hostname: String? = null): Map { - val preload = preloadList(root) + fun sessionEnvironment( + root: File, binds: List, program: String, hostname: String? = null, lseEmu: String? = null, + ): Map { + val preload = preloadList(root).filterNot { lseEmu == "0" && it.substringAfterLast('/') == "liblse_emu.so" } + val lse = lseEmu ?: "1".takeIf { preload.any { it.substringAfterLast('/') == "liblse_emu.so" } } return linkedMapOf( "DDNATV_ROOT" to root.path, "DDNATV_EXEC" to execLoader.orEmpty(), @@ -103,6 +116,7 @@ object NativeGuest { "DDNATV_HOSTNAME" to hostname.orEmpty(), "DDNATV_BINDS" to binds.joinToString("|") { if (it.contains(':')) it else "$it:$it" }, "DDNATV_PRELOAD" to preload.joinToString(":"), + "LSE_EMU" to lse.orEmpty(), "LD_PRELOAD" to (preload.map { File(root, it.removePrefix("/")).path } + hook(root).path).joinToString(":"), ).filterValues { it.isNotEmpty() } } @@ -112,8 +126,9 @@ object NativeGuest { File(BwrapSpawner.hostPath(binds.map { BwrapSpawner.Bind.parse(it) }, root.path, cwd)).takeIf { it.isDirectory } ?: root /** A process for [guest] (argv) started as proot would with [binds], in guest directory [cwd]. */ - fun processBuilder(context: Context, root: File, binds: List, guest: List, cwd: String = "/root"): ProcessBuilder = - ProcessBuilder(command(root, guest.first(), guest.drop(1))) + fun processBuilder(context: Context, root: File, binds: List, guest: List, cwd: String = "/root"): ProcessBuilder { + if (sessionMode == null) prepare(context, root) + return ProcessBuilder(command(root, guest.first(), guest.drop(1))) .directory(workingDirectory(root, binds, cwd)) .also { builder -> builder.environment().apply { @@ -121,6 +136,7 @@ object NativeGuest { putAll(sessionEnvironment(root, binds, guest.first(), SessionPrefs.guestHostname(context))) } } + } private const val RUNPATH_CONF = "etc/ld.so.conf.d/zz-droiddeck-native.conf" private val SCAN_DIRS = listOf("usr/lib", "usr/local/lib", "opt") @@ -149,6 +165,7 @@ object NativeGuest { } /** What a rootfs needs before anything runs in it natively; cheap once done. */ + @Synchronized fun prepare(context: Context, root: File) { val relinked = relinkAbsoluteSymlinks(context, root) if (relinked > 0) android.util.Log.i(TAG, "native userland: $relinked absolute symlinks made relative") @@ -169,8 +186,15 @@ object NativeGuest { } } + private const val RELINK_STAMP = "etc/droiddeck/native-symlinks" + + @JvmStatic + fun relinkAfterProot(root: File) { + File(root, RELINK_STAMP).delete() + } + private val HOST_LINK_TARGETS = listOf("/proc", "/dev", "/sys", "/sdcard", "/storage", "/data", "/system", "/vendor", "/apex", - "/system_ext", "/product", "/odm", "/linkerconfig", "/mnt") + "/system_ext", "/product", "/odm", "/linkerconfig", "/mnt", "/root/Storage") /** * Symbolic links the kernel follows by itself (ld.so, Steam, anything that skips the hook) read @@ -178,9 +202,9 @@ object NativeGuest { * which reads the target inside the rootfs, so each is rewritten as a relative link, which * resolves the same way under proot and without it. Rerun when the runtime changes. */ - fun relinkAbsoluteSymlinks(context: Context, root: File): Int { - val stamp = File(root, "etc/droiddeck/native-symlinks") - val version = com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(context).orEmpty() + "/2" + fun relinkAbsoluteSymlinks(context: Context, root: File, commands: () -> Sequence> = ::procCommands): Int { + val stamp = File(root, RELINK_STAMP) + val version = com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(context).orEmpty() + "/3" if (stamp.isFile && stamp.readText() == version) return 0 val rootPath = root.toPath() var rewritten = 0 @@ -206,11 +230,20 @@ object NativeGuest { override fun visitFileFailed(file: java.nio.file.Path, exc: java.io.IOException) = java.nio.file.FileVisitResult.CONTINUE }) - stamp.parentFile?.mkdirs() - stamp.writeText(version) + if (!prootRunning(LinuxRuntime.prootBinary(context).path, commands())) { + stamp.parentFile?.mkdirs() + stamp.writeText(version) + } return rewritten } + internal fun prootRunning(proot: String, commands: Sequence>): Boolean = + commands.any { args -> args.take(2).any { it == proot } } + + private fun procCommands(): Sequence> = (File("/proc").listFiles() ?: emptyArray()).asSequence() + .filter { it.name.all(Char::isDigit) } + .mapNotNull { runCatching { File(it, "cmdline").readText().split('\u0000') }.getOrNull() } + /** * The guest path that host path [target] stands for in a session with [binds] ("src:dst"), or null * when it is a guest path already: the rootfs, or the longest mount source holding it (the first diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt b/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt index 27ef86f086..33fa897237 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt @@ -3,7 +3,6 @@ package com.droiddeck.launcher.runtime import android.content.Context import android.os.Build import android.util.Log -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.security.MessageDigest @@ -12,17 +11,14 @@ object ProotFastPath { const val LIBRARY = "/usr/local/lib/libddfastpath.so" const val MAX_BINDS = 256 - fun allows(preference: Boolean, noSeccomp: Boolean, source: String, nativeUserland: Boolean = false): Boolean = - preference && !noSeccomp && !nativeUserland && source == LinuxRuntime.PROOT_PACK + internal fun allows(source: String, native: Boolean): Boolean = + !native && source == LinuxRuntime.PROOT_PACK - fun enabled(context: Context): Boolean { - val preference = SessionPrefs.prootFastPath(context) - val noSeccomp = SessionPrefs.prootNoSeccomp(context) - val nativeUserland = SessionPrefs.nativeUserland(context) + fun enabled(context: Context, native: Boolean = NativeGuest.forSession(context)): Boolean { + if (native) return false val source = LinuxRuntime.prootSource(context) - val on = allows(preference, noSeccomp, source, nativeUserland) - if (preference && !noSeccomp && !nativeUserland && !on) - Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot") + val on = allows(source, native) + if (!on) Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot") return on } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt index 16228be728..1791df54b0 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt @@ -8,7 +8,6 @@ import android.os.Process import android.util.Log import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper -import com.droiddeck.launcher.session.SessionPrefs import org.json.JSONObject import java.io.DataInputStream import java.io.DataOutputStream @@ -128,7 +127,6 @@ object RootSpawner { clear() put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt b/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt index efc460ee04..ea9b0ba699 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/UserApps.kt @@ -14,6 +14,7 @@ import com.droiddeck.launcher.R import com.droiddeck.launcher.core.Downloader import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.core.Hashes +import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.store.FlathubApi import org.json.JSONArray import org.json.JSONObject @@ -184,9 +185,10 @@ object UserApps { fun binds(context: Context): List { val internal = Environment.getExternalStorageDirectory().canonicalPath + val mounted = SessionPrefs.mountSharedStorage(context) return root(context).listFiles().orEmpty().mapNotNull { dir -> val target = runCatching { Os.readlink(File(dir, "files").path) }.getOrNull() ?: return@mapNotNull null - target.takeIf { !it.startsWith("$internal/") && File(it).isDirectory } + target.takeIf { !(mounted && it.startsWith("$internal/")) && File(it).isDirectory } }.distinct() } @@ -475,7 +477,8 @@ object UserApps { if (!file.isFile) return context.getString(R.string.user_apps_file_gone) if (!FlatpakManager.ready(context)) FlatpakManager.setup(context, onProgress)?.let { return it } val shared = Environment.getExternalStorageDirectory().canonicalPath - val copy = File(LinuxRuntime.rootDir(context), "tmp/droiddeck-bundle.flatpak").takeIf { !file.canonicalPath.startsWith("$shared/") } + val copy = File(LinuxRuntime.rootDir(context), "tmp/droiddeck-bundle.flatpak") + .takeIf { !SessionPrefs.mountSharedStorage(context) || !file.canonicalPath.startsWith("$shared/") } try { if (copy != null) { onProgress(context.getString(R.string.user_apps_copying, file.name), -1) diff --git a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt index b25ed487a2..b815d29fdd 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt @@ -40,6 +40,7 @@ object BottomDesktop { val generation: Int, val installed: Boolean, val nativeUserland: Boolean, + val sharedStorage: File?, ) @Volatile private var launch: Launch? = null @@ -91,10 +92,11 @@ object BottomDesktop { sessionDir: File, generation: Int, nativeUserland: Boolean, + sharedStorage: File?, stillCurrent: () -> Boolean, ) { val prepared = Launch(ArrayList(guest), ArrayList(binds), sessionRoot, hostEnvironment.copyOf(), root, sessionDir, generation, - DesktopCatalog.desktopInstalled(root), nativeUserland) + DesktopCatalog.desktopInstalled(root), nativeUserland, sharedStorage) synchronized(launchLock) { if (stillCurrent()) launch = prepared } } @@ -217,6 +219,19 @@ object BottomDesktop { fun sendText(text: String) { val target = service ?: return + if (text.isNotEmpty() && text.all { it == '\r' || it == '\n' || it == '\b' || it == '\u007f' || it == '\t' }) { + for (c in text) { + val evdev = when (c) { + '\r', '\n' -> 28 + '\b' -> 14 + '\u007f' -> 111 + else -> 15 + } + sendKey(evdev, true) + sendKey(evdev, false) + } + return + } send(target, Message.obtain(null, Comp.MSG_TEXT).apply { data = Bundle().apply { putString(Comp.KEY_TEXT, text) } }) } @@ -313,7 +328,7 @@ object BottomDesktop { val runtime = runtimeDir(context).apply { mkdirs() } val imeDir = File(current.sessionRoot, "bottom-desktop-ime") main.post { if (generation == guestGeneration) watchIme(imeDir) } - val binds = LinuxRuntime.binds(context, current.sessionRoot, runtime, Environment.getExternalStorageDirectory(), current.binds) + val binds = LinuxRuntime.binds(context, current.sessionRoot, runtime, current.sharedStorage, current.binds) val guest = ArrayList(current.guest).apply { add("DD_WIDTH=$width") add("DD_HEIGHT=$height") @@ -328,7 +343,8 @@ object BottomDesktop { LinuxRuntime.commandWithBinds(context, current.root, binds, guest) } val environment = if (current.nativeUserland) { - com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, guest.first(), SessionPrefs.guestHostname(context)) + val lseEmu = current.guest.lastOrNull { it.startsWith("LSE_EMU=") }?.substringAfter('=') + com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, guest.first(), SessionPrefs.guestHostname(context), lseEmu) .map { (k, v) -> "$k=$v" }.toTypedArray() } else current.hostEnvironment val line = command.joinToString(" ") { it.replace("\\", "\\\\").replace(" ", "\\ ") } diff --git a/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt b/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt index 98239f8eb0..cf31b02404 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BuildWatermarkSetting.kt @@ -39,6 +39,10 @@ internal object BuildWatermarkSetting { throw error } } + notifyChanged(context) + } + + fun notifyChanged(context: Context) { context.sendBroadcast(Intent(CHANGED).setPackage(context.packageName)) } } diff --git a/app/src/main/java/com/droiddeck/launcher/session/CdpPage.kt b/app/src/main/java/com/droiddeck/launcher/session/CdpPage.kt new file mode 100644 index 0000000000..3d460f24a2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/CdpPage.kt @@ -0,0 +1,63 @@ +package com.droiddeck.launcher.session + +import org.json.JSONObject +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicInteger +import java.util.concurrent.CompletableFuture +import kotlin.concurrent.thread + +class CdpPage(port: Int, path: String, private val onEvent: (String, JSONObject) -> Unit) : AutoCloseable { + private val ws = LoopbackWebSocket(port, path, connectTimeoutMs = 2_000) + private val ids = AtomicInteger() + private val pending = ConcurrentHashMap>() + private val sender = Executors.newSingleThreadExecutor { r -> Thread(r, "cdp-send").apply { isDaemon = true } } + @Volatile var closed = false + private set + private val tornDown = java.util.concurrent.atomic.AtomicBoolean(false) + + init { + thread(name = "cdp-read", isDaemon = true) { + try { + while (true) { + val m = JSONObject(ws.receive() ?: break) + if (m.has("id")) pending.remove(m.optInt("id"))?.complete(m) + else onEvent(m.optString("method"), m.optJSONObject("params") ?: JSONObject()) + } + } catch (_: Exception) { + } + close() + } + } + + fun send(method: String, params: JSONObject = JSONObject()) { + if (closed) return + val id = ids.incrementAndGet() + val text = JSONObject().put("id", id).put("method", method).put("params", params).toString() + runCatching { sender.execute { runCatching { ws.send(text) } } } + } + + fun call(method: String, params: JSONObject = JSONObject(), timeoutMs: Long = 3_000): JSONObject? { + if (closed) return null + val id = ids.incrementAndGet() + val future = CompletableFuture() + pending[id] = future + val text = JSONObject().put("id", id).put("method", method).put("params", params).toString() + runCatching { sender.execute { runCatching { ws.send(text) }.onFailure { future.complete(JSONObject()) } } } + .onFailure { future.complete(JSONObject()) } + return runCatching { future.get(timeoutMs, TimeUnit.MILLISECONDS) }.getOrNull().also { pending.remove(id) } + } + + fun evaluate(expression: String): Any? = + call("Runtime.evaluate", JSONObject().put("expression", expression).put("returnByValue", true)) + ?.optJSONObject("result")?.optJSONObject("result")?.opt("value") + + override fun close() { + closed = true + if (!tornDown.compareAndSet(false, true)) return + pending.values.forEach { it.complete(JSONObject()) } + sender.shutdown() + runCatching { ws.close() } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt index 146509bba7..b9be461b01 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt @@ -30,6 +30,8 @@ object ComponentsManager { private const val DD_COMPONENTS = "Droid-Deck/DroidDeck-Components" internal const val DD_NIGHTLY = "linux-nightly" internal const val DD_BIONIC = "bionic-stable" + /** FEX for original Xbox games on DroidDeck-Bionic: kept apart from [DD_BIONIC] so automatic FEX updates never pick it. */ + internal const val DD_XBOX = "bionic-xbox" private val RELEASES = linkedMapOf( "FexCore-Linux" to "fex", "Dxvk-Linux" to "dxvk", @@ -38,7 +40,8 @@ object ComponentsManager { "Vkd3d-proton-Linux" to "vkd3d", ) private val NIGHTLY_PREFIXES = linkedMapOf("DD-dxvk-" to "dxvk", "DD-vkd3d-proton-" to "vkd3d", "DD-FEXCore-" to "fex") - private val SOURCES = RELEASES.keys.map { NIGHTLIES to it } + (DD_COMPONENTS to DD_NIGHTLY) + (DD_COMPONENTS to DD_BIONIC) + private val SOURCES = RELEASES.keys.map { NIGHTLIES to it } + (DD_COMPONENTS to DD_NIGHTLY) + (DD_COMPONENTS to DD_BIONIC) + + (DD_COMPONENTS to DD_XBOX) private val DOWNLOAD_REPOS = listOf(NIGHTLIES, DD_COMPONENTS) private val TYPES = mapOf("FEXCore-Linux" to "fex", "FEXCore-Bionic" to "fex", "DXVK-Linux" to "dxvk", "VKD3D-Linux" to "vkd3d") private val TYPE_OF = mapOf("fex" to "FEXCore-Linux", "dxvk" to "DXVK-Linux", "vkd3d" to "VKD3D-Linux") @@ -253,6 +256,28 @@ object ComponentsManager { saveState(context, state) } + internal enum class Assigned { SET, NOT_LISTED, CHANGED } + + /** + * Sets a game's component to a listed package, fetching it first when it is not stored. [expected] is the component + * the caller read when it decided: if the game's component is something else once the package is ready (the player + * chose one during the download), nothing is written. [onSet] runs under the same lock as the write. + */ + internal fun assignGameComponent(context: Context, scope: String, comp: String, file: String, release: String, + expected: String?, onSet: () -> Unit = {}): Assigned { + val wcp = File(packagesDir(context), safeName(file)) + if (!wcp.isFile || runCatching { packageInfo(context, wcp) }.isFailure) { + wcp.delete() + download(context, catalogItem(context, file, release) ?: return Assigned.NOT_LISTED) {} + } + synchronized(lock) { + if (gameComponents(context, scope)[comp] != expected) return Assigned.CHANGED + setGameComponent(context, scope, comp, file) { runtimeManaged(context, it) } + onSet() + } + return Assigned.SET + } + fun clearGameComponents(context: Context, scope: String) = synchronized(lock) { require(GameEnvironment.validScope(scope)) val state = loadState(context) @@ -1124,7 +1149,7 @@ object ComponentsManager { internal fun assetComp(release: String, name: String): String? = RELEASES[release] ?: when (release) { DD_NIGHTLY -> NIGHTLY_PREFIXES.entries.firstOrNull { name.startsWith(it.key) }?.value - DD_BIONIC -> "fex" + DD_BIONIC, DD_XBOX -> "fex" else -> null } diff --git a/app/src/main/java/com/droiddeck/launcher/session/DirectControllerSwitch.kt b/app/src/main/java/com/droiddeck/launcher/session/DirectControllerSwitch.kt new file mode 100644 index 0000000000..790ff1122e --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/DirectControllerSwitch.kt @@ -0,0 +1,46 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import com.droiddeck.launcher.core.GameEnvironment +import com.droiddeck.launcher.runtime.LinuxRuntime +import java.io.File + +/** + * dd-directcontroller's mode file. DroidDeck-Bionic's launch.sh writes it beside the controller folder when a game set to start + * without Steam reads XInput through dd-directcontroller; the game's DLLs read it while it runs ('1' the pad state, '0' Wine's own + * xinput). No file = the session's game does not use dd-directcontroller. + */ +object DirectControllerSwitch { + const val FILE = "dd-directcontroller.mode" + + fun file(context: Context): File = File(LinuxRuntime.sessionRoot(context), "dev/$FILE") + + /** The running game's mode, or null when it does not use dd-directcontroller. */ + fun state(context: Context): Boolean? = runCatching { + when (file(context).takeIf { it.isFile }?.readText()?.trim()) { + "1" -> true + "0" -> false + else -> null + } + }.getOrNull() + + /** One request after another, in call order: the last switch sets both the live mode and the saved choice. */ + private val queue = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "dd-directcontroller") } + + /** Switches the running game now and remembers the choice for its next start. */ + fun set(context: Context, on: Boolean) { + val app = context.applicationContext + queue.execute { + runCatching { file(app).takeIf { it.isFile }?.writeText(if (on) "1\n" else "0\n") } + val scope = NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { NoSteamLaunch.battleNetTitleScope(app, it) } + if (!scope.isNullOrEmpty() && GameEnvironment.validScope(scope)) runCatching { + GameEnvironmentStore.setGameDirectController(app, scope, on) + } + } + } + + /** A session starts without the file: only a launch that uses dd-directcontroller writes it again. */ + fun clear(context: Context) { + file(context).delete() + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt b/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt index c9c55f9c27..9490279fa8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/EnhancedSessionLogShare.kt @@ -5,6 +5,7 @@ import android.os.ParcelFileDescriptor import android.system.Os import android.system.OsConstants import com.droiddeck.launcher.core.LogRedactor +import com.droiddeck.launcher.frontend.Library import com.droiddeck.launcher.runtime.BattleNet import com.droiddeck.launcher.runtime.LinuxRuntime import org.json.JSONArray @@ -25,6 +26,7 @@ import java.nio.channels.SeekableByteChannel import java.nio.file.FileVisitResult import java.nio.file.Files import java.nio.file.LinkOption +import java.nio.file.NoSuchFileException import java.nio.file.Path import java.nio.file.SimpleFileVisitor import java.nio.file.StandardOpenOption @@ -221,7 +223,7 @@ internal object EnhancedSessionLogShare { Category.values().map { category -> val budget = budgets.getValue(category) val records = ArrayList() - val selected = candidates.filter { it.category == category } + val selected = candidates.filter { it.category == category }.sortedBy(::sharePriority) val zip = File(out, "DroidDeck-${folder.name}-${category.suffix}.zip") ZipOutputStream(zip.outputStream().buffered()).use { archive -> val names = HashSet() @@ -268,7 +270,7 @@ internal object EnhancedSessionLogShare { val out = outputDirectory.apply { deleteRecursively(); mkdirs() } val redactionLearningComplete = LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context)) val discovery = collect(context, folder, limits.maxDiscoveredFiles, legacy = true) - val candidates = discovery.candidates.filter { it.linePrefix == null } + val candidates = discovery.candidates.filter { it.linePrefix == null }.sortedBy(::sharePriority) if (candidates.isEmpty()) { out.deleteRecursively() return null @@ -616,7 +618,8 @@ internal object EnhancedSessionLogShare { redactionLearningComplete: Boolean, ) { val entries = JSONArray() - records.take(MAX_MANIFEST_RECORDS).forEach { record -> + val (discovery, rest) = records.partition { it.origin == "discovery" } + (discovery + rest).take(MAX_MANIFEST_RECORDS).forEach { record -> entries.put(JSONObject().apply { put("entry", record.entry) put("origin", record.origin) @@ -680,6 +683,15 @@ internal object EnhancedSessionLogShare { categoryCounts[category] = (categoryCounts[category] ?: 0) + 1 } } + fun addRecentLogs(root: File, entryPrefix: String, origin: String) { + val scan = walk(root, remaining(maxFiles, out.size)) + truncated = truncated || scan.truncated + partial = partial || scan.partial + val base = root.toPath().toAbsolutePath().normalize() + scan.files.asSequence().filter { recent(it) && it.name.endsWith(".log", true) }.forEach { file -> + add(file, root, "$entryPrefix/${base.relativize(file.toPath().toAbsolutePath().normalize()).joinToString("/")}", origin) + } + } CRITICAL_SESSION_FILES.forEach { name -> File(folder, name).takeIf { it.exists() }?.let { add(it, folder, "${folder.name}/$name", "session-critical") } } @@ -697,15 +709,6 @@ internal object EnhancedSessionLogShare { Category.GAMES, "DROIDDECK_DIAGNOSTICS event=game_", ) } - if (SessionPaths.current()?.canonicalFile == folder.canonicalFile && !File(folder, "steam").exists()) { - val steam = File(SessionPrefs.activeSteamRoot(context), "logs") - val scan = directFiles(steam, remaining(maxFiles, out.size)) - truncated = truncated || scan.truncated - partial = partial || scan.partial - scan.files.forEach { - add(it, steam, "${folder.name}/steam/${it.name}", "live-steam") - } - } val logs = LinuxRuntime.logDir(context) for ((name, root) in listOf(SessionLogShare.STORES_DIR to File(logs, SessionLogShare.STORES_DIR), SessionPaths.TOOLS_DIR to File(logs, SessionPaths.TOOLS_DIR))) { val scan = directFiles(root, STORE_LOG_SCAN) @@ -722,16 +725,7 @@ internal object EnhancedSessionLogShare { add(source.file, source.root, source.entry, "battlenet") } } else { - battleNetRoots(context).forEach { (prefix, root) -> - val scan = walk(root, remaining(maxFiles, out.size)) - truncated = truncated || scan.truncated - partial = partial || scan.partial - scan.files.asSequence().filter { recent(it) && it.name.endsWith(".log", true) } - .forEach { file -> - val relative = root.toPath().toAbsolutePath().normalize().relativize(file.toPath().toAbsolutePath().normalize()).joinToString("/") - add(file, root, "battlenet/$prefix/$relative", "battlenet") - } - } + battleNetRoots(context).forEach { (prefix, root) -> addRecentLogs(root, "battlenet/$prefix", "battlenet") } } val sessionScan = walk(folder, remaining(maxFiles, out.size)) truncated = truncated || sessionScan.truncated @@ -742,9 +736,28 @@ internal object EnhancedSessionLogShare { if (relative == EnhancedDiagnostics.MANIFEST_FILE) return@forEach add(file, folder, "${folder.name}/$relative", "session") } + val antiCheat = antiCheatRoots(context) + partial = partial || antiCheat.partial + antiCheat.roots.forEach { (appId, root) -> addRecentLogs(root, "anticheat/$appId", "anticheat") } + if (SessionPaths.current()?.canonicalFile == folder.canonicalFile && !File(folder, "steam").exists()) { + val steam = File(SessionPrefs.activeSteamRoot(context), "logs") + val scan = directFiles(steam, remaining(maxFiles, out.size)) + truncated = truncated || scan.truncated + partial = partial || scan.partial + scan.files.forEach { + add(it, steam, "${folder.name}/steam/${it.name}", "live-steam") + } + } return CollectionResult(out.values.toList(), truncated, partial) } + private fun sharePriority(candidate: Candidate): Int = when { + candidate.origin == "session-critical" -> 0 + candidate.origin == "session" && candidate.category == Category.GAMES -> 1 + candidate.origin == "anticheat" -> 2 + else -> 3 + } + private fun remaining(maxFiles: Int, found: Int): Int = (maxFiles - found + 1).coerceAtLeast(0) private fun walk(root: File, limit: Int): ScanResult { @@ -816,6 +829,39 @@ internal object EnhancedSessionLogShare { return ScanResult(files, truncated, partial) } + private class AntiCheatRoots(val roots: List>, val partial: Boolean) + + private fun antiCheatRoots(context: Context): AntiCheatRoots { + var partial = false + val seen = HashSet() + val dirs = runCatching { Library.compatdataDirs(context) }.getOrElse { partial = true; emptyList() } + val roots = dirs.flatMapIndexed { library, compatdata -> + val prefixes = compatdata.listFiles() ?: run { partial = true; emptyArray() } + prefixes.filter { !Files.isSymbolicLink(it.toPath()) }.mapNotNull { prefix -> + val appId = steamAppId(prefix.name) ?: return@mapNotNull null + val root = File(prefix, EAC_LOG_DIR) + val directory = try { + Files.readAttributes(root.toPath(), BasicFileAttributes::class.java, LinkOption.NOFOLLOW_LINKS).isDirectory + } catch (_: NoSuchFileException) { + false + } catch (_: Exception) { + partial = true + false + } + if (!directory) return@mapNotNull null + val base = "$appId/library${library + 1}" + val key = base.takeIf { seen.add(it) } ?: "$base-${prefix.name}".takeIf { seen.add(it) } + if (key != null) key to root else { partial = true; null } + } + } + return AntiCheatRoots(roots, partial) + } + + private fun steamAppId(name: String): String? = + name.takeIf { SIGNED_APP_ID.matches(it) }?.toLongOrNull() + ?.takeIf { it in Int.MIN_VALUE.toLong()..0xffffffffL } + ?.let { (it and 0xffffffffL).toString() } + private fun battleNetRoots(context: Context): List> { val drive = File(BattleNet.prefix(context), "pfx/drive_c") val data = File(drive, "ProgramData/Battle.net") @@ -922,7 +968,9 @@ internal object EnhancedSessionLogShare { val normalized = name.replace('\\', '/').trimStart('/') val parts = normalized.split('/') if (normalized.isEmpty() || parts.any { it.isEmpty() || it == "." || it == ".." }) return null - return parts.joinToString("/") { safeComponent(it) } + return parts.mapIndexed { index, part -> + if (index == 1 && parts[0] == "anticheat" && APP_ID.matches(part)) part else safeComponent(part) + }.joinToString("/") } private fun safeComponent(value: String): String { @@ -935,7 +983,7 @@ internal object EnhancedSessionLogShare { private fun category(entry: String): Category { val value = entry.lowercase(Locale.US) - if (value.startsWith("battlenet/") || value.startsWith("stores/") || value.startsWith("tools/") || value.startsWith("rpcs3/") || + if (value.startsWith("battlenet/") || value.startsWith("anticheat/") || value.startsWith("stores/") || value.startsWith("tools/") || value.startsWith("rpcs3/") || value.contains("droiddeck-esync/") || GAME_LOG.matches(value.substringAfterLast('/')) || listOf("proton", "wine", "dxvk", "vkd3d", "battle.net", "game-debug", "bionic").any(value::contains)) return Category.GAMES if (listOf("wayland", "gamescope", "xwayland", "vulkan", "gpu", "mesa", "egl", "glx", "drm", "compositor", "frame-trace").any(value::contains)) return Category.GRAPHICS @@ -944,7 +992,7 @@ internal object EnhancedSessionLogShare { private val GAME_LOG = Regex("steam-[0-9]+\\.(log|txt)") private val KNOWN_COMPONENTS = setOf( - "steam", "graphics", "games", "battlenet", "client", "agent", "setup", "stores", "tools", + "steam", "graphics", "games", "battlenet", "anticheat", "anticheatlauncher.log", "client", "agent", "setup", "stores", "tools", "droiddeck", "droiddeck-esync", "session.log", "app.log", "wayland.log", "audio.log", "device.txt", "network.txt", "events.jsonl", "memory.csv", "capture.json", "crash.log", "frame-trace.log", "process-trace.log", "game-lifecycle.log", "launches.log", "tools.tsv", "wanted.tsv", "prefixes.json", @@ -955,11 +1003,15 @@ internal object EnhancedSessionLogShare { private val KNOWN_COMPONENT_PATTERNS = listOf( Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"), Regex("steam-[0-9]+\\.(?:log|txt)"), + Regex("library[0-9]+(?:--?[0-9]{1,10})?"), Regex("(?:battle\\.net-[0-9]+|battle\\.net-setup-[0-9]+|Agent-[0-9]+)\\.log"), Regex("(?:Agent\\.[0-9]+|bna_[0-9]+)"), Regex("stores-[0-9]{4}-[0-9]{2}-[0-9]{2}\\.log"), + Regex("library[0-9]{1,3}"), Regex("entry-[0-9a-f]{16}(?:\\.[a-z0-9]{1,8})?"), ) + private val APP_ID = Regex("[0-9]{1,10}") + private val SIGNED_APP_ID = Regex("-?[0-9]{1,10}") private val SAFE_SUFFIX = Regex("\\.[A-Za-z0-9]{1,8}$") private val CRITICAL_SESSION_FILES = listOf( "session.log", "app.log", "wayland.log", "audio.log", "device.txt", "network.txt", @@ -967,6 +1019,7 @@ internal object EnhancedSessionLogShare { ) private const val RECENT_MILLIS = 7L * 24 * 60 * 60 * 1000 private const val STORE_LOG_SCAN = 512 + private const val EAC_LOG_DIR = "pfx/drive_c/users/steamuser/AppData/Roaming/EasyAntiCheat" private const val COPY_BUFFER_BYTES = 64 * 1024 private const val TRACE_SCAN_BYTES = 16L * 1024 * 1024 private const val LEGACY_LOG_MAX_BYTES = 8L * 1024 * 1024 diff --git a/app/src/main/java/com/droiddeck/launcher/session/FullscreenMode.kt b/app/src/main/java/com/droiddeck/launcher/session/FullscreenMode.kt new file mode 100644 index 0000000000..9d3cdd2e21 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/FullscreenMode.kt @@ -0,0 +1,18 @@ +package com.droiddeck.launcher.session + +import android.content.res.Configuration +import androidx.annotation.StringRes +import com.droiddeck.launcher.R + +enum class FullscreenMode(@StringRes val label: Int) { + ALWAYS(R.string.widgets_on), + LANDSCAPE_ONLY(R.string.setup_fullscreen_landscape_only), + OFF(R.string.widgets_off); + + fun hidesSystemBars(orientation: Int): Boolean = + this == ALWAYS || (this == LANDSCAPE_ONLY && orientation == Configuration.ORIENTATION_LANDSCAPE) + + companion object { + fun fromStored(value: String?): FullscreenMode? = entries.firstOrNull { it.name == value } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt b/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt index d4bdce833e..d3689c120d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameEnvironmentStore.kt @@ -13,6 +13,7 @@ object GameEnvironmentStore { private const val TAG = "GameEnvironmentStore" private const val SETTINGS = "game-environment.json" private const val GUEST_FILE = "root/.config/droiddeck/game-environment.json" + private const val GAME_CORES_FILE = "root/.config/droiddeck/game-cores" const val DXVK_CONFIG = "dxvkConfig" const val DXVK_CONFIG_GAMES = "dxvkConfigGames" const val GAME_DEBUG_LOGS = "gameDebugLogs" @@ -90,6 +91,13 @@ object GameEnvironmentStore { return config } + @Synchronized + fun setGameDirectController(context: Context, scope: String, on: Boolean): GameEnvironment.Config { + val config = GameEnvironment.withGameDirectController(read(context), scope, on) + save(context, config) + return config + } + @Synchronized fun setGameResolution(context: Context, scope: String, choice: com.droiddeck.launcher.core.GameResolution.Choice?): GameEnvironment.Config { val config = GameEnvironment.withGameResolution(read(context), scope, choice) @@ -108,10 +116,12 @@ object GameEnvironmentStore { @Synchronized fun publish( context: Context, - config: GameEnvironment.Config = read(context), + config: GameEnvironment.Config? = null, gameDebugLogsOverride: Boolean? = null, ) { - val resolved = config.copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + config.shared) + publishGameCores(context) + val stored = config ?: read(context) + val resolved = GameEnvironment.withKnownGames(stored).copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + stored.shared) val json = encode(resolved) val dxvk = TextureFiltering.dxvkOptions( SessionPrefs.textureAnisotropy(context), SessionPrefs.textureLodBias(context), @@ -140,6 +150,26 @@ object GameEnvironmentStore { write(File(LinuxRuntime.rootDir(context), GUEST_FILE), json.toString()) } + @Synchronized + fun publishGameCores(context: Context) { + val file = File(LinuxRuntime.rootDir(context), GAME_CORES_FILE) + val pending = File(file.path + ".new") + try { + check(file.parentFile!!.isDirectory || file.parentFile!!.mkdirs()) + java.io.FileOutputStream(pending).use { + it.write((com.droiddeck.launcher.core.CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(context)) + "\n").toByteArray(Charsets.UTF_8)) + it.fd.sync() + } + java.nio.file.Files.move( + pending.toPath(), file.toPath(), + java.nio.file.StandardCopyOption.ATOMIC_MOVE, java.nio.file.StandardCopyOption.REPLACE_EXISTING, + ) + } catch (error: Exception) { + Log.e(TAG, "Could not update game cores", error) + if (!file.delete() && file.exists()) Log.e(TAG, "Could not remove outdated game cores") + } + } + private fun write(file: File, text: String) { check(file.parentFile!!.isDirectory || file.parentFile!!.mkdirs()) val atomic = AtomicFile(file) diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt b/app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt new file mode 100644 index 0000000000..0115819cb3 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/GameLinks.kt @@ -0,0 +1,284 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import org.json.JSONArray +import org.json.JSONObject +import java.io.File +import java.net.HttpURLConnection +import java.net.URL +import java.net.URLEncoder + +object GameLinks { + enum class Kind { WIKI, STRATEGYWIKI, PCGAMINGWIKI, GAMEFAQS, IGN, HOWLONGTOBEAT, MAPGENIE } + + data class Link(val kind: Kind, val url: String) + + data class Search(val id: String, val url: String) + + internal fun sparql(appId: Long): String = """ + SELECT ?fandom ?pcgw ?gamefaqs ?ign ?hltb ?sw WHERE { + ?g wdt:P1733 "$appId". + OPTIONAL { ?g wdt:P4073 ?fandom } + OPTIONAL { ?g wdt:P6337 ?pcgw } + OPTIONAL { ?g wdt:P4769 ?gamefaqs } + OPTIONAL { ?g wdt:P5385 ?ign } + OPTIONAL { ?g wdt:P2816 ?hltb } + OPTIONAL { ?g wdt:P9075 ?sw } + } LIMIT 50 + """.trimIndent() + + internal fun parse(json: String): List { + val rows = JSONObject(json).optJSONObject("results")?.optJSONArray("bindings") ?: return emptyList() + val values = HashMap>() + for (i in 0 until rows.length()) { + val row = rows.optJSONObject(i) ?: continue + for (key in row.keys()) { + val v = row.optJSONObject(key)?.optString("value").orEmpty() + if (v.isNotEmpty() && v !in values.getOrPut(key) { mutableListOf() }) values.getValue(key) += v + } + } + fun first(key: String) = values[key]?.firstOrNull() + // Wikidata is editable by anyone, and this id becomes a URL host. + val fandomId = Regex("[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)?") + val fandom = values["fandom"]?.filter(fandomId::matches)?.let { all -> all.firstOrNull { '.' !in it } ?: all.firstOrNull() } + return listOfNotNull( + fandom?.let { id -> if ('.' in id) id.split('.', limit = 2).let { (lang, wiki) -> "https://$wiki.fandom.com/$lang/" } else "https://$id.fandom.com/" } + ?.let { Link(Kind.WIKI, it) }, + first("sw")?.let { Link(Kind.STRATEGYWIKI, "https://strategywiki.org/wiki/" + path(it)) }, + first("pcgw")?.let { Link(Kind.PCGAMINGWIKI, "https://www.pcgamingwiki.com/wiki/" + path(it)) }, + first("gamefaqs")?.takeIf { it.all(Char::isDigit) }?.let { Link(Kind.GAMEFAQS, "https://gamefaqs.gamespot.com/-/$it-") }, + first("ign")?.let { Link(Kind.IGN, "https://www.ign.com/games/" + path(it)) }, + first("hltb")?.takeIf { it.all(Char::isDigit) }?.let { Link(Kind.HOWLONGTOBEAT, "https://howlongtobeat.com/game/$it") }, + ) + } + + /** Site slugs to try for a game name, longest first: "Bully: Scholarship Edition" gives bully-scholarship-edition, then bully. */ + internal fun slugs(name: String): List { + fun slug(s: String) = s.lowercase().replace("&", "and").replace(Regex("['’™®©]"), "") + .replace(Regex("[^a-z0-9]+"), "-").trim('-') + val short = name.split(Regex(":| - | – |\\("), limit = 2).first() + return listOf(slug(name), slug(short)).filter { it.isNotEmpty() }.distinct() + } + + /** Direct pages for what Wikidata has no ID for, found from each site's own routes rather than a web search. */ + internal fun direct(name: String, found: List, exists: (String) -> Boolean, strategyWiki: (String) -> String?): List = + merge(found, discover(name, found, exists, strategyWiki)) + + /** Wikidata's links with the discovered ones; a discovered IGN wiki replaces Wikidata's IGN game page. */ + internal fun merge(found: List, extra: List): List = + found.filterNot { it.kind == Kind.IGN && extra.any { e -> e.kind == Kind.IGN } } + + extra.filterNot { e -> e.kind != Kind.IGN && found.any { it.kind == e.kind } } + + internal fun discover(name: String, found: List, exists: (String) -> Boolean, strategyWiki: (String) -> String?): List { + val have = found.map { it.kind }.toSet() + val slugs = slugs(name) + fun first(urls: List) = urls.firstOrNull(exists) + val ignWiki = found.firstOrNull { it.kind == Kind.IGN }?.url?.substringAfter("/games/", "")?.takeIf { it.isNotEmpty() } + val extra = listOfNotNull( + first(slugs.map { "https://mapgenie.io/$it" })?.let { Link(Kind.MAPGENIE, it) }, + first((listOfNotNull(ignWiki) + slugs).distinct().map { "https://www.ign.com/wikis/$it" })?.let { Link(Kind.IGN, it) }, + // Fandom answers pages with a bot check, but its API with 200 for a wiki that exists and 404 for one that does not. + if (Kind.WIKI in have) null else slugs.map { it.replace("-", "") }.distinct() + .firstOrNull { exists("https://$it.fandom.com/api.php?action=query&meta=siteinfo&format=json") } + ?.let { Link(Kind.WIKI, "https://$it.fandom.com/") }, + if (Kind.STRATEGYWIKI in have) null else strategyWiki(name.split(":").first().trim())?.let { Link(Kind.STRATEGYWIKI, it) }, + ) + return extra + } + + internal fun parseOpenSearch(json: String, title: String): String? = runCatching { + val a = JSONArray(json) + val titles = a.getJSONArray(1) + val urls = a.getJSONArray(3) + (0 until titles.length()).firstOrNull { titles.getString(it).equals(title, ignoreCase = true) }?.let { urls.getString(it) } + }.getOrNull() + + /** Whether the page exists, or null when the site could not be asked. */ + private fun exists(url: String): Boolean? = runCatching { + val c = URL(url).openConnection() as HttpURLConnection + c.instanceFollowRedirects = false + c.connectTimeout = 6_000 + c.readTimeout = 6_000 + c.setRequestProperty("User-Agent", BROWSER) + try { c.responseCode.takeIf { it < 500 }?.let { it in 200..399 } } finally { c.disconnect() } + }.getOrNull() + + private fun strategyWiki(title: String): Result = runCatching { + parseOpenSearch(get("https://strategywiki.org/w/api.php?action=opensearch&namespace=0&limit=5&format=json&search=" + + URLEncoder.encode(title, "UTF-8")), title) + } + + fun links(context: Context, appId: Long, name: String? = null): List { + val cache = File(context.cacheDir, "game-links/$appId.json") + val fresh = cache.isFile && System.currentTimeMillis() - cache.lastModified() < CACHE_MS + val text = if (fresh) runCatching { cache.readText() }.getOrNull() else null + val fetched = text ?: runCatching { + get("https://query.wikidata.org/sparql?format=json&query=" + URLEncoder.encode(sparql(appId), "UTF-8")) + }.getOrNull()?.also { runCatching { cache.parentFile?.mkdirs(); cache.writeText(it) } } + val json = fetched ?: runCatching { cache.readText() }.getOrNull() + val wikidata = json?.let { runCatching { parse(it) }.getOrNull() }.orEmpty() + val withFixes = if (wikidata.any { it.kind == Kind.PCGAMINGWIKI }) wikidata + else wikidata + Link(Kind.PCGAMINGWIKI, "https://www.pcgamingwiki.com/api/appid.php?appid=$appId") + if (name.isNullOrBlank()) return withFixes + // Only the discovered pages are cached, and only when every site answered, so an offline lookup is retried. + val directCache = File(context.cacheDir, "game-links/$appId-direct-v3.json") + val cached = directCache.takeIf { it.isFile && System.currentTimeMillis() - it.lastModified() < CACHE_MS } + ?.let { runCatching { readLinks(it.readText()) }.getOrNull() } + if (cached != null) return merge(withFixes, cached) + var complete = fetched != null + val extra = discover(name, withFixes, { url -> exists(url).also { if (it == null) complete = false } == true }) { title -> + strategyWiki(title).onFailure { complete = false }.getOrNull() + } + if (complete) runCatching { directCache.parentFile?.mkdirs(); directCache.writeText(writeLinks(extra)) } + return merge(withFixes, extra) + } + + internal fun writeLinks(links: List): String = + JSONArray(links.map { JSONObject().put("kind", it.kind.name).put("url", it.url) }).toString() + + internal fun readLinks(json: String): List = JSONArray(json).let { a -> + (0 until a.length()).map { a.getJSONObject(it) }.map { Link(Kind.valueOf(it.getString("kind")), it.getString("url")) } + } + + fun protonTier(appId: Long): String? = runCatching { + parseTier(get("https://www.protondb.com/api/v1/reports/summaries/$appId.json")) + }.getOrNull() + + internal fun parseTier(json: String): String? = + JSONObject(json).optString("tier").takeIf { it in TIERS } + + /** Searches on the sites themselves, for what has no direct page. */ + fun searches(name: String, found: List): List { + val q = URLEncoder.encode(name, "UTF-8") + return listOfNotNull( + Search("youtube", "https://m.youtube.com/results?search_query=$q+walkthrough"), + Search("gamefaqs", "https://gamefaqs.gamespot.com/search?game=$q").takeIf { found.none { it.kind == Kind.GAMEFAQS } }, + ) + } + + private fun path(id: String) = id.replace(' ', '_') + + private fun get(url: String): String { + val c = URL(url).openConnection() as HttpURLConnection + c.connectTimeout = 10_000 + c.readTimeout = 15_000 + c.setRequestProperty("User-Agent", "DroidDeck (bottom screen guides)") + c.setRequestProperty("Accept", "application/sparql-results+json, application/json") + try { + if (c.responseCode != 200) throw java.io.IOException("HTTP ${c.responseCode}") + return c.inputStream.bufferedReader().use { it.readText() } + } finally { + c.disconnect() + } + } + + val TIERS = listOf("platinum", "gold", "silver", "bronze", "borked") + private const val CACHE_MS = 7L * 24 * 3600 * 1000 + private const val BROWSER = "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Mobile Safari/537.36" +} + +object GuideLibrary { + data class Saved(val file: File, val title: String, val url: String) + + data class PinnedMap(val file: File, val markers: List>) + + private fun dir(context: Context, game: String, kind: String) = + File(context.filesDir, "guides/${game.replace(Regex("[^A-Za-z0-9._-]"), "_")}/$kind") + + fun savedFile(context: Context, game: String): File = dir(context, game, "saved").apply { mkdirs() }.let { File(it, "${System.currentTimeMillis()}.mht") } + + fun recordSaved(file: File, title: String, url: String) { + runCatching { File(file.path.removeSuffix(".mht") + ".json").writeText(JSONObject().put("title", title).put("url", url).toString()) } + } + + fun saved(context: Context, game: String): List = dir(context, game, "saved").listFiles { f -> f.name.endsWith(".mht") && f.length() > 0 } + .orEmpty().sortedByDescending { it.lastModified() }.map { f -> + val meta = runCatching { JSONObject(File(f.path.removeSuffix(".mht") + ".json").readText()) }.getOrNull() + Saved(f, meta?.optString("title").orEmpty().ifEmpty { f.nameWithoutExtension }, meta?.optString("url").orEmpty()) + } + + fun isSaved(context: Context, file: File): Boolean = + file.canonicalPath.startsWith(File(context.filesDir, "guides").canonicalPath + File.separator) && file.name.endsWith(".mht") + + fun delete(file: File) { + file.delete() + File(file.path.removeSuffix(".mht") + ".json").delete() + File(file.path + ".markers.json").delete() + } + + fun maps(context: Context, game: String): List = dir(context, game, "maps") + .listFiles { f -> f.extension in IMAGE_TYPES.values }.orEmpty().sortedByDescending { it.lastModified() } + .map { PinnedMap(it, markers(it)) } + + fun markers(map: File): List> = runCatching { + val arr = JSONArray(File(map.path + ".markers.json").readText()) + List(arr.length()) { i -> arr.getJSONArray(i).let { it.getDouble(0).toFloat() to it.getDouble(1).toFloat() } } + }.getOrDefault(emptyList()) + + fun saveMarkers(map: File, markers: List>) { + runCatching { File(map.path + ".markers.json").writeText(JSONArray(markers.map { JSONArray(listOf(it.first.toDouble(), it.second.toDouble())) }).toString()) } + } + + /** Follows redirects itself so the page's cookies reach only the host they were read for. */ + private const val MAX_REDIRECTS = 5 + + private fun openMap(url: String, cookies: String?): HttpURLConnection? { + val home = URL(url).host + var target = URL(url) + repeat(MAX_REDIRECTS + 1) { + val c = target.openConnection() as HttpURLConnection + c.instanceFollowRedirects = false + c.connectTimeout = 10_000 + c.readTimeout = 30_000 + c.setRequestProperty("User-Agent", "Mozilla/5.0 (Linux; Android) DroidDeck") + if (target.host.equals(home, ignoreCase = true)) cookies?.takeIf { it.isNotEmpty() }?.let { c.setRequestProperty("Cookie", it) } + if (c.responseCode !in 300..399) return c + val next = c.getHeaderField("Location")?.let { runCatching { URL(target, it) }.getOrNull() } + c.disconnect() + if (next == null || (next.protocol != "https" && next.protocol != "http")) return null + target = next + } + return null + } + + fun pin(context: Context, game: String, url: String, cookies: String?): File? = runCatching { + if (!url.startsWith("https://") && !url.startsWith("http://")) return null + val c = openMap(url, cookies) ?: return null + try { + if (c.responseCode != 200) return null + val ext = IMAGE_TYPES[c.contentType?.substringBefore(';')?.trim()?.lowercase()] ?: return null + if (c.contentLengthLong > MAX_MAP_BYTES) return null + val out = File(dir(context, game, "maps").apply { mkdirs() }, "${System.currentTimeMillis()}.$ext") + // Written beside the map and renamed when complete, so the Maps list never shows a partial image. + val part = File(out.path + ".part") + try { + c.inputStream.use { input -> + part.outputStream().use { output -> + val buf = ByteArray(64 * 1024) + var total = 0L + while (true) { + val n = input.read(buf) + if (n < 0) break + total += n + if (total > MAX_MAP_BYTES) return null + output.write(buf, 0, n) + } + } + } + if (!part.renameTo(out)) return null + } finally { + part.delete() + } + out + } finally { + c.disconnect() + } + }.getOrNull() + + fun clear(context: Context, game: String) { + File(context.filesDir, "guides/${game.replace(Regex("[^A-Za-z0-9._-]"), "_")}").deleteRecursively() + } + + private val IMAGE_TYPES = mapOf("image/png" to "png", "image/jpeg" to "jpg", "image/webp" to "webp", "image/gif" to "gif") + private const val MAX_MAP_BYTES = 40L * 1024 * 1024 +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt b/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt index ed1d357b32..7784f1f9f9 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameProfileManager.kt @@ -22,6 +22,11 @@ object GameProfileManager { clear("component packages") { ComponentsManager.clearGameComponents(context, scope) } clear("texture filtering") { SessionPrefs.clearGameTextureFiltering(context, scope) } clear("Windows components") { WinComponents.setPicks(context, scope, emptyList()) } + clear("bottom screen") { SessionPrefs.clearGameBottomScreen(context, scope) } + clear("guides") { + SteamGuides.clear(context, scope) + GuideLibrary.clear(context, scope) + } if (failures.isNotEmpty()) { val names = failures.joinToString { it.first } diff --git a/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt b/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt index 263860334c..3c2d722c06 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GameStorage.kt @@ -59,13 +59,18 @@ object GameStorage { return when { pref == SessionPrefs.GAME_STORAGE_OFF -> null pref.isEmpty() -> options(context).firstOrNull()?.let { Option(it.name, it.path) } - else -> Option(SessionPrefs.gameStorageLabel(context), pref).takeIf { attached(File(pref)) } + else -> reachable(pref).let { path -> Option(SessionPrefs.gameStorageLabel(context), path).takeIf { attached(File(path)) } } } } fun disconnected(context: Context): Boolean { val pref = SessionPrefs.gameStorage(context) - return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(pref)) + return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(reachable(pref))) + } + + internal fun reachable(path: String, usable: (File) -> Boolean = { it.isDirectory && it.canWrite() }): String { + val alias = UsbLink.storagePath(path) + return if (alias != path && !usable(File(path)) && usable(File(alias))) alias else path } internal fun attached( diff --git a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt index e02b3e7bfa..1e0d30828e 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt @@ -18,10 +18,24 @@ object GpuClockPin { var failed = false private set - val supported: Boolean by lazy { File(KGSL_NODE).exists() } + var supported: Boolean = File(KGSL_NODE).exists() + internal set + + internal var turbo: (Boolean) -> Unit = { WaylandCompositor.nativeSetGpuTurbo(it) } private var live = false + @Volatile + private var boosted = false + + private fun wanted(context: Context) = boosted || SessionPrefs.gpuClockPin(context) + + fun boost(on: Boolean): Boolean { + if (boosted == on) return false + boosted = on + return true + } + @Synchronized fun start(context: Context): String { live = true @@ -30,11 +44,11 @@ object GpuClockPin { private fun hold(context: Context): String { failed = false - if (!SessionPrefs.gpuClockPin(context)) return "gpu clock: governed" + if (!wanted(context)) return "gpu clock: governed" if (!supported) return "gpu clock: no $KGSL_NODE, left governed" return try { File(context.filesDir, MARKER).createNewFile() - WaylandCompositor.nativeSetGpuTurbo(true) + turbo(true) pinned = true "gpu clock: held at its top" } catch (t: Throwable) { @@ -48,13 +62,14 @@ object GpuClockPin { @Synchronized fun sync(context: Context): String? { if (!live) return null - if (!SessionPrefs.gpuClockPin(context) && pinned) clear(context) + if (!wanted(context) && pinned) clear(context) return hold(context) } @Synchronized fun stop(context: Context) { live = false + boosted = false if (pinned) clear(context) } @@ -66,7 +81,7 @@ object GpuClockPin { private fun clear(context: Context) { if (supported) { try { - WaylandCompositor.nativeSetGpuTurbo(false) + turbo(false) } catch (t: Throwable) { Log.w(TAG, "clear", t) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/GuestLeftovers.kt b/app/src/main/java/com/droiddeck/launcher/session/GuestLeftovers.kt new file mode 100644 index 0000000000..f1e7454e7e --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/GuestLeftovers.kt @@ -0,0 +1,54 @@ +package com.droiddeck.launcher.session + +import java.io.File + +/** Finds the processes a session left running, also once proot is gone and they belong to init. */ +object GuestLeftovers { + private const val MARKER = "DD_DEBUG_DIR=" + + fun find(rootfs: String, ended: File?, skip: Set): Set { + val marker = ended?.let { MARKER + it.path } + val parents = HashMap() + val matched = HashSet() + File("/proc").listFiles { f -> f.name.all { it.isDigit() } }?.forEach { proc -> + val pid = proc.name.toIntOrNull() ?: return@forEach + parentOf(proc)?.let { parents[pid] = it } + if (pid in skip) return@forEach + val exe = runCatching { File(proc, "exe").canonicalPath }.getOrNull() + // proot runs a guest through its loader, which is then the process's executable + if (exe?.startsWith(rootfs) == true || + marker != null && carries(runCatching { File(proc, "environ").readBytes() }.getOrNull(), marker)) { + matched.add(pid) + } + } + return withDescendants(matched, parents) - skip + } + + internal fun carries(environ: ByteArray?, marker: String): Boolean { + if (environ == null) return false + val wanted = marker.toByteArray() + var start = 0 + while (start < environ.size) { + var end = start + while (end < environ.size && environ[end] != 0.toByte()) end++ + if (end - start == wanted.size && (0 until wanted.size).all { environ[start + it] == wanted[it] }) return true + start = end + 1 + } + return false + } + + internal fun withDescendants(roots: Set, parents: Map): Set { + val out = HashSet(roots) + var grew = true + while (grew) { + grew = false + for ((pid, ppid) in parents) if (pid > 1 && ppid in out && out.add(pid)) grew = true + } + return out + } + + private fun parentOf(proc: File): Int? { + val stat = runCatching { File(proc, "stat").readText() }.getOrNull() ?: return null + return stat.substringAfterLast(") ").split(' ').getOrNull(1)?.toIntOrNull() + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoopbackWebSocket.kt b/app/src/main/java/com/droiddeck/launcher/session/LoopbackWebSocket.kt new file mode 100644 index 0000000000..0a789b21ca --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/LoopbackWebSocket.kt @@ -0,0 +1,135 @@ +package com.droiddeck.launcher.session + +import java.io.ByteArrayOutputStream +import java.io.DataInputStream +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream +import java.net.InetSocketAddress +import java.net.Socket +import java.security.MessageDigest +import java.security.SecureRandom +import java.util.Base64 + +class LoopbackWebSocket(port: Int, path: String = "/", connectTimeoutMs: Int = 1_000, readTimeoutMs: Int = 0) : AutoCloseable { + private val socket = Socket() + private val out: OutputStream + private val input: DataInputStream + private val random = SecureRandom() + + init { + try { + socket.connect(InetSocketAddress("127.0.0.1", port), connectTimeoutMs) + socket.soTimeout = UPGRADE_TIMEOUT_MS + socket.tcpNoDelay = true + out = socket.getOutputStream() + input = DataInputStream(socket.getInputStream().buffered()) + val key = Base64.getEncoder().encodeToString(ByteArray(16).also(random::nextBytes)) + out.write(("GET $path HTTP/1.1\r\nHost: 127.0.0.1:$port\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n" + + "Sec-WebSocket-Key: $key\r\nSec-WebSocket-Version: 13\r\n\r\n").toByteArray()) + out.flush() + val status = line(input) ?: throw IOException("no upgrade response") + if (status.split(' ').getOrNull(1) != "101") throw IOException("upgrade refused: $status") + val headers = HashMap() + while (true) { + val header = line(input) ?: throw IOException("upgrade cut short") + if (header.isEmpty()) break + val colon = header.indexOf(':') + if (colon > 0) headers[header.substring(0, colon).trim().lowercase()] = header.substring(colon + 1).trim() + } + if (!headers["upgrade"].equals("websocket", ignoreCase = true) || + headers["connection"]?.split(',')?.none { it.trim().equals("upgrade", ignoreCase = true) } != false || + headers["sec-websocket-accept"] != accept(key) + ) throw IOException("bad upgrade headers") + socket.soTimeout = readTimeoutMs + } catch (e: Exception) { + runCatching { socket.close() } + throw e + } + } + + @Synchronized + fun send(text: String) = frame(0x1, text.toByteArray()) + + fun receive(): String? { + val message = ByteArrayOutputStream() + while (true) { + val b0 = input.read().takeIf { it >= 0 } ?: return null + val b1 = input.read().takeIf { it >= 0 } ?: return null + var length = (b1 and 0x7F).toLong() + if (length == 126L) length = input.readUnsignedShort().toLong() else if (length == 127L) length = input.readLong() + if (length < 0 || length > MAX_FRAME) throw IOException("frame too large") + val mask = if (b1 and 0x80 != 0) ByteArray(4).also(input::readFully) else null + val data = ByteArray(length.toInt()).also(input::readFully) + if (mask != null) for (i in data.indices) data[i] = (data[i].toInt() xor mask[i % 4].toInt()).toByte() + when (b0 and 0x0F) { + 0x8 -> { + sendClose(data.copyOf(minOf(2, data.size))) + return null + } + 0x9 -> synchronized(this) { frame(0xA, data) } + 0x0, 0x1, 0x2 -> { + message.write(data) + if (message.size() > MAX_FRAME) throw IOException("message too large") + if (b0 and 0x80 != 0) return message.toString(Charsets.UTF_8.name()) + } + } + } + } + + private fun frame(opcode: Int, payload: ByteArray) { + val mask = ByteArray(4).also(random::nextBytes) + val frame = ByteArrayOutputStream(payload.size + 14) + frame.write(0x80 or opcode) + when { + payload.size < 126 -> frame.write(0x80 or payload.size) + payload.size < 65536 -> { + frame.write(0x80 or 126) + frame.write(payload.size ushr 8) + frame.write(payload.size and 0xFF) + } + else -> { + frame.write(0x80 or 127) + for (k in 7 downTo 0) frame.write(((payload.size.toLong() ushr (8 * k)) and 0xFF).toInt()) + } + } + frame.write(mask) + for (i in payload.indices) frame.write((payload[i].toInt() xor mask[i % 4].toInt()) and 0xFF) + out.write(frame.toByteArray()) + out.flush() + } + + private fun line(s: InputStream): String? { + val buf = ByteArrayOutputStream() + while (true) { + val b = s.read() + if (b < 0) return if (buf.size() == 0) null else buf.toString(Charsets.UTF_8.name()) + if (b == '\n'.code) return buf.toString(Charsets.UTF_8.name()).trimEnd('\r') + if (buf.size() > 8192) throw IOException("header line too long") + buf.write(b) + } + } + + private var closeSent = false + + private fun sendClose(payload: ByteArray) { + synchronized(this) { + if (closeSent) return + closeSent = true + runCatching { frame(0x8, payload) } + } + } + + override fun close() { + sendClose(ByteArray(0)) + runCatching { socket.close() } + } + + internal companion object { + const val MAX_FRAME = 16L * 1024 * 1024 + const val UPGRADE_TIMEOUT_MS = 3_000 + + fun accept(key: String): String = Base64.getEncoder().encodeToString( + MessageDigest.getInstance("SHA-1").digest((key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").toByteArray())) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt b/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt index 2d18a84a30..bbfa7bfc29 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/Onboarding.kt @@ -29,6 +29,10 @@ object Onboarding { /** The setup screens belong to the first run; later runtime, Proton and Steam client updates keep the usual Play button. */ val firstRun = MutableStateFlow(true) + /** Called once, when this process finishes the first-run downloads itself; not when everything was already in place. */ + @Volatile var onFirstRunReady: (() -> Unit)? = null + @Volatile private var worked = false + fun attach(context: Context) { appContext = context.applicationContext val prefs = context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE) @@ -52,8 +56,10 @@ object Onboarding { private fun markFirstRunDone() { val context = appContext ?: return + val live = firstRun.value && worked context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(KEY_FIRST_RUN_DONE, true).apply() firstRun.value = false + if (live) onFirstRunReady?.invoke() } /** Keeps the process in the foreground, with one notification, while a step downloads and the runtime installer is not already doing so. */ @@ -90,6 +96,7 @@ object Onboarding { } fun report(step: Step, label: String, percent: Int) { + worked = true failed.value = failed.value - step active.value = active.value + (step to Progress(label, percent)) keepAlive() diff --git a/app/src/main/java/com/droiddeck/launcher/session/PageCacheTrim.kt b/app/src/main/java/com/droiddeck/launcher/session/PageCacheTrim.kt new file mode 100644 index 0000000000..da6a118c91 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/PageCacheTrim.kt @@ -0,0 +1,104 @@ +package com.droiddeck.launcher.session + +import android.util.Log +import java.io.File +import java.io.IOException +import java.nio.file.FileVisitResult +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.SimpleFileVisitor +import java.nio.file.attribute.BasicFileAttributes + +internal object PageCacheTrim { + private const val TAG = "PageCacheTrim" + internal const val MIN_FILE_BYTES = 8L shl 20 + private const val POLL_MS = 3000L + private const val RESCAN_MS = 120_000L + + data class Mem(val freeKb: Long, val fileKb: Long) + + fun parse(meminfo: String): Mem? { + fun field(name: String) = Regex("""(?m)^$name:\s+(\d+) kB""").find(meminfo)?.groupValues?.get(1)?.toLongOrNull() + val free = field("MemFree") ?: return null + val file = (field("Active\\(file\\)") ?: return null) + (field("Inactive\\(file\\)") ?: return null) + return Mem(free, file) + } + + fun shouldTrim(mem: Mem, baselineFileKb: Long): Boolean { + val built = mem.fileKb - baselineFileKb + return (mem.freeKb < 2560 * 1024 && built >= 768 * 1024) || + (mem.freeKb < 1024 * 1024 && built >= 128 * 1024) + } + + fun start(roots: () -> List, alive: () -> Boolean) { + Thread({ + var baseline = 0L + var files = emptyList() + var scanned = 0L + var trims = 0 + var failureLogged = false + while (alive()) { + runCatching { + val mem = parse(File("/proc/meminfo").readText()) + if (mem != null && shouldTrim(mem, baseline)) { + val now = System.currentTimeMillis() + if (now - scanned > RESCAN_MS) { + files = roots().flatMap { root -> bigFiles(root) } + scanned = now + } + val began = System.nanoTime() + files.forEach(::drop) + val after = parse(File("/proc/meminfo").readText()) + baseline = after?.fileKb ?: mem.fileKb + trims++ + Log.i(TAG, "trim #$trims: free ${mem.freeKb / 1024} -> ${after?.freeKb?.div(1024)} MB, file cache ${mem.fileKb / 1024} -> ${after?.fileKb?.div(1024)} MB, ${files.size} files, ${(System.nanoTime() - began) / 1_000_000} ms") + } + }.onFailure { + if (!failureLogged) Log.w(TAG, "trim failed: $it") + failureLogged = true + } + Thread.sleep(POLL_MS) + } + }, "page-cache-trim").apply { isDaemon = true }.start() + } + + // java.io's directory listing hands raw entry names to JNI NewStringUTF, which aborts the + // process on names that are not valid UTF-8; NIO decodes them with replacement instead. + // Without FOLLOW_LINKS, symlinked directories are never descended into, like the old onEnter, + // except that a starting directory that is itself a link has to be resolved first; a link + // whose target has vanished yields an empty result instead of an error. + internal fun bigFiles(root: File): List { + val out = ArrayList() + val start = root.toPath() + val real = if (Files.isSymbolicLink(start)) { + try { + start.toRealPath() + } catch (_: IOException) { + return out + } + } else start + Files.walkFileTree(real, object : SimpleFileVisitor() { + override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult { + if (attrs.isRegularFile && attrs.size() >= MIN_FILE_BYTES) out.add(file.toFile()) + return FileVisitResult.CONTINUE + } + + override fun visitFileFailed(file: Path, error: IOException): FileVisitResult = FileVisitResult.CONTINUE + + override fun postVisitDirectory(dir: Path, error: IOException?): FileVisitResult = FileVisitResult.CONTINUE + }) + return out + } + + private fun drop(file: File) { + PageCacheNative.fadviseDontNeed(file.path) + } +} + +internal object PageCacheNative { + init { + System.loadLibrary("sdnative") + } + + @JvmStatic external fun fadviseDontNeed(path: String): Int +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt b/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt index 412fc79627..756a721a7a 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ProtonExtras.kt @@ -9,6 +9,8 @@ import com.droiddeck.launcher.core.Downloader import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.runtime.NativeGuest +import com.droiddeck.launcher.storage.SteamStorage +import com.droiddeck.launcher.stores.steam.SteamClient import java.io.File import java.util.Locale import org.json.JSONArray @@ -34,7 +36,9 @@ object ProtonExtras { private var replacing = false class Tool(val id: String, val name: String, val prefix: String, val repo: String, val assetPattern: Regex, - val prereleases: Boolean = false) + val prereleases: Boolean = false, val x86_64: Boolean = false, val label: Int = 0) { + val arch: String get() = if (x86_64) "x86-64" else "ARM64" + } internal data class Asset(val tag: String, val name: String, val url: String, val sha512: String?, val size: Long, val sha256: String? = null, val releaseName: String = tag) @@ -42,11 +46,13 @@ object ProtonExtras { const val OWN = "droiddeck" const val BIONIC = "bionic" + const val ANTICHEAT = "anticheat" val tools = listOf( Tool("ge", "GE-Proton", "GE-Proton", "GloriousEggroll/proton-ge-custom", Regex("aarch64\\.tar\\.(gz|xz)$")), Tool("cachyos", "proton-cachyos", "proton-cachyos", "CachyOS/proton-cachyos", Regex("arm64\\.tar\\.(gz|xz)$")), Tool("droiddeck", "DroidDeck-Proton", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Proton-.*aarch64\\.tar\\.(gz|xz)$")), + Tool(ANTICHEAT, "DroidDeck-Proton x86-64", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Proton-.*x86_64\\.tar\\.(gz|xz)$"), x86_64 = true, label = R.string.pextra_anticheat), // Bionic (Android libc) Proton started outside the Linux userland; test builds are prereleases. No-proot only. Tool(BIONIC, "DroidDeck-Bionic", "DroidDeck-Bionic", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Bionic-.*aarch64\\.tar\\.(gz|xz)$"), prereleases = true), ) @@ -66,11 +72,14 @@ object ProtonExtras { internal fun installedIn(dir: File, tool: Tool): List = dir.listFiles() - ?.filter { it.isDirectory && it.name.startsWith(tool.prefix) && usable(it) } + ?.filter { it.isDirectory && it.name.startsWith(tool.prefix) && x86_64Build(it) == tool.x86_64 && usable(it) } ?.map { it.name } ?.sortedWith { a, b -> compareVersions(a, b) } ?: emptyList() + internal fun x86_64Build(dir: File): Boolean = + File(dir, "files/lib/wine/x86_64-unix").isDirectory && !File(dir, "files/bin-arm64").isDirectory + private fun usable(dir: File): Boolean { val manifest = runCatching { File(dir, "toolmanifest.vdf").readText() }.getOrNull() ?: return false val command = Regex("\\\"commandline\\\"\\s+\\\"/?([^\\\" ]+)").find(manifest)?.groupValues?.getOrNull(1) ?: return false @@ -108,15 +117,31 @@ object ProtonExtras { fun update(context: Context, tool: Tool): String? = updateFor(installedTags(context, tool), cachedLatest(context, tool)) - fun missing(context: Context, tool: Tool): String? = - if (tool.id == OWN && !declined(context) && installedAll(context, tool).isEmpty()) cachedLatest(context, tool) else null + fun missing(context: Context, tool: Tool): String? = missing(context, tool) { antiCheatRuntimeInstalled(context) } + + internal fun missing(context: Context, tool: Tool, antiCheat: () -> Boolean): String? = when { + declined(context, tool.id) || installedAll(context, tool).isNotEmpty() -> null + tool.id == OWN || tool.id == ANTICHEAT && antiCheat() -> cachedLatest(context, tool) + else -> null + } + + private fun antiCheatRuntimeInstalled(context: Context): Boolean = + antiCheatRuntimeIn(listOf("arm64", SteamClient.X86_64).flatMap { arch -> + runCatching { SteamClient.libraries(context, arch).map { it.host } }.getOrDefault(emptyList()) + } + listOfNotNull(GameStorage.effective(context)?.let { File(it.path) }, GameStorage.x64CardLibrary(context))) + + internal fun antiCheatRuntimeIn(libraries: List): Boolean = libraries.any { library -> + ANTICHEAT_RUNTIMES.any { File(library, "steamapps/appmanifest_$it.acf").isFile } + } + + private val ANTICHEAT_RUNTIMES = listOf(SteamStorage.EAC_RUNTIME, SteamStorage.BATTLEYE_RUNTIME) private fun choices(context: Context) = context.getSharedPreferences("proton-auto-updates", Context.MODE_PRIVATE) - fun declined(context: Context): Boolean = choices(context).getBoolean("$OWN.declined", false) + fun declined(context: Context, id: String = OWN): Boolean = choices(context).getBoolean("$id.declined", false) - fun setDeclined(context: Context, declined: Boolean) { - choices(context).edit().putBoolean("$OWN.declined", declined).apply() + fun setDeclined(context: Context, declined: Boolean, id: String = OWN) { + choices(context).edit().putBoolean("$id.declined", declined).apply() } fun cachedLatest(context: Context, tool: Tool): String? = @@ -220,8 +245,8 @@ object ProtonExtras { if (runCatching { ComponentsManager.carryOver(context, old, newest) }.onFailure { Log.w(TAG, "components of $old", it) }.isFailure) continue if (runCatching { keepUserSettings(context, old, newest) }.onFailure { Log.w(TAG, "user settings of $old", it) }.isFailure) continue if (runCatching { ProtonDefault.moveGames(context, setOf(old), newest) }.onFailure { Log.w(TAG, "per-game picks of $old", it) }.isFailure) continue - // DroidDeck-Bionic only: the guest finds no default for a deleted Bionic build and falls back to DroidDeck-Proton - if (tool.id == BIONIC && runCatching { ProtonDefault.moveDefault(context, setOf(old), newest) }.onFailure { Log.w(TAG, "default pick of $old", it) }.isFailure) continue + // DroidDeck-Bionic and the x86-64 build: the guest finds no default for a deleted build and falls back to DroidDeck-Proton + if ((tool.id == BIONIC || tool.id == ANTICHEAT) && runCatching { ProtonDefault.moveDefault(context, setOf(old), newest) }.onFailure { Log.w(TAG, "default pick of $old", it) }.isFailure) continue if (deleteTool(context, old)) ComponentsManager.forgetProton(context, old) else Log.w(TAG, "could not remove $old") } @@ -288,7 +313,7 @@ object ProtonExtras { } private fun prefetchNow(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? { - val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name) + val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name, tool.arch) val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() } val archive = File(downloads, "${tool.id}-${asset.name}") if (asset.size > 0 && archive.length() > asset.size) archive.delete() @@ -305,7 +330,7 @@ object ProtonExtras { if (SessionState.running) return context.getString(R.string.pextra_stop_session) if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required) - val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name) + val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name, tool.arch) val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() } val archive = File(downloads, "${tool.id}-${asset.name}") if (asset.size > 0 && archive.length() > asset.size) archive.delete() @@ -374,7 +399,7 @@ object ProtonExtras { archive.delete() unqueue(context, tool) record(context, tool, placed, asset.tag) - if (tool.id == OWN || tool.id == BIONIC) replaceOlder(context, tool) + if (tool.id == OWN || tool.id == BIONIC || tool.id == ANTICHEAT) replaceOlder(context, tool) if (EsyncPacks.enabled(context)) { onProgress(context.getString(R.string.esync_fetching), -1) try { diff --git a/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt b/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt new file mode 100644 index 0000000000..8f619b86b3 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/QuestSteamVrLaunch.kt @@ -0,0 +1,35 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import java.io.File + +/** + * On a Quest, SteamVR has to run inside the immersive activity. A launch from Steam's library happens in the + * guest, so the guest's SteamVR helper leaves a request in the shared runtime directory for the session to act on. + */ +object QuestSteamVrLaunch { + private const val DIR = ".wayland-rt/droiddeck-steamvr" + private const val MARKER = "quest-immersive" + private const val REQUEST = "xr-request" + + fun publish(context: Context) { + val dir = File(context.filesDir, DIR) + val marker = File(dir, MARKER) + if (!QuestExperimental.isSupported()) { + marker.delete() + return + } + runCatching { + dir.mkdirs() + marker.writeText("") + } + } + + /** A request left by an earlier session must not open the immersive view in this one. */ + fun clearRequest(context: Context) { + File(context.filesDir, "$DIR/$REQUEST").delete() + } + + fun takeRequest(context: Context): Boolean = + QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete() +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt b/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt index 53fc319c26..08fa86f608 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SecondaryLibrary.kt @@ -46,7 +46,16 @@ object SecondaryLibrary { } fun privateRoot(files: File, library: File): File { - val digest = MessageDigest.getInstance("SHA-256").digest(library.canonicalPath.toByteArray()) + val own = privateDir(files, library.canonicalPath) + if (own.exists()) return own + val raw = UsbLink.rawPath(library.absolutePath) + val alias = if (raw != library.absolutePath) raw else UsbLink.storagePath(library.absolutePath) + if (alias == library.absolutePath) return own + return privateDir(files, runCatching { File(alias).canonicalPath }.getOrDefault(alias)).takeIf { it.exists() } ?: own + } + + private fun privateDir(files: File, path: String): File { + val digest = MessageDigest.getInstance("SHA-256").digest(path.toByteArray()) .joinToString("") { "%02x".format(it.toInt() and 255) } return File(files, "steam-libraries/$digest") } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt index 03c9fddcae..68cb9b4976 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionArtifacts.kt @@ -667,10 +667,18 @@ object SessionArtifacts { val am = context.getSystemService(android.app.ActivityManager::class.java) ?: return false am.getHistoricalProcessExitReasons(context.packageName, 0, 3) .firstOrNull { it.processName == context.packageName } - ?.reason == android.app.ApplicationExitInfo.REASON_LOW_MEMORY + ?.let { memoryKill(it.reason, it.description) } == true }.getOrDefault(false) } + // ApplicationExitInfo.REASON_MEMORY_LIMITER (API 37.2), newer than compileSdk. + private const val REASON_MEMORY_LIMITER = 17 + + // The Android 17 behavior changes page instead documents REASON_OTHER with the limiter named in the description. + internal fun memoryKill(reason: Int, description: String?): Boolean = + reason == android.app.ApplicationExitInfo.REASON_LOW_MEMORY || reason == REASON_MEMORY_LIMITER || + reason == android.app.ApplicationExitInfo.REASON_OTHER && description?.contains("MemoryLimiter") == true + private fun exitReasons(context: Context): String { if (android.os.Build.VERSION.SDK_INT < 30) return "" return runCatching { @@ -691,6 +699,7 @@ object SessionArtifacts { private fun reasonName(reason: Int): String = when (reason) { android.app.ApplicationExitInfo.REASON_LOW_MEMORY -> "LOW_MEMORY (killed for memory)" + REASON_MEMORY_LIMITER -> "MEMORY_LIMITER (over the app memory limit)" android.app.ApplicationExitInfo.REASON_SIGNALED -> "SIGNALED" android.app.ApplicationExitInfo.REASON_CRASH -> "CRASH" android.app.ApplicationExitInfo.REASON_CRASH_NATIVE -> "CRASH_NATIVE" diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt index 919891fa45..10a20f9fcc 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt @@ -16,6 +16,7 @@ object SessionDisplay { const val LINK_PORTRAIT = "link/portrait" const val DEFAULT_RESOLUTION = "720p" + const val DEFAULT_STEAM_PORTRAIT_RESOLUTION = "1280x800" private val PRESET_HEIGHTS = listOf(720, 900, 1080) fun presetHeight(choice: String): Int? = diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index a3b368632e..dc708cb51d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -5,12 +5,14 @@ import android.content.Context import android.os.Environment import android.util.Log import com.droiddeck.launcher.R +import com.droiddeck.launcher.core.CpuFeatures import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.runtime.BwrapSpawner import com.droiddeck.launcher.runtime.DesktopCatalog import com.droiddeck.launcher.runtime.LegacyNames import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.runtime.ProotFastPath +import org.json.JSONObject import java.io.File object SessionFiles { @@ -21,6 +23,12 @@ object SessionFiles { private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad" const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio" private const val STAGED_LEDGER = "usr/local/.droiddeck-staged" + internal const val LSE_EMU = "usr/local/lib/droiddeck-lse/liblse_emu.so" + + internal fun lsePreload(lacksAtomics: Boolean, staged: Boolean, lseEmu: String? = null): String = + if (lacksAtomics && staged && lseEmu != "0") "/$LSE_EMU\n" else "" + private const val IME_MANIFEST = "usr/local/share/droiddeck/ime-files.json" + private const val IME_DEFAULT_MODE = 420 val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread") internal val DESKTOP_FILES = arrayOf( @@ -35,6 +43,7 @@ object SessionFiles { "usr/local/bin/kwin_wayland_wrapper" to "usr/local/bin/kwin_wayland_wrapper", "usr/lib/firefox/defaults/pref/droiddeck.js" to "usr/lib/firefox/defaults/pref/droiddeck.js", "etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop", + "usr/share/applications/droiddeck-return-gaming.desktop" to "usr/share/applications/droiddeck-return-gaming.desktop", "etc/xdg/fastfetch/config.jsonc" to "etc/xdg/fastfetch/config.jsonc", ) @@ -98,10 +107,23 @@ object SessionFiles { } private val STAGE_LOCK = Any() + @Volatile private var activeSessionLseEmu: String? = null - fun stage(context: Context, root: File, startsSession: Boolean = false) = synchronized(STAGE_LOCK) { stageNow(context, root, startsSession) } + fun stage(context: Context, root: File, startsSession: Boolean = false) = + stage(context, root, startsSession, lseEmu = null) - private fun stageNow(context: Context, root: File, startsSession: Boolean) { + fun stage(context: Context, root: File, startsSession: Boolean, lseEmu: String?) = + synchronized(STAGE_LOCK) { + val selection = if (startsSession) { + activeSessionLseEmu = lseEmu + lseEmu + } else { + lseEmu ?: activeSessionLseEmu + } + stageNow(context, root, startsSession, selection) + } + + private fun stageNow(context: Context, root: File, startsSession: Boolean, lseEmu: String?) { if (DesktopCatalog.desktopInstalled(root) && !DesktopCatalog.desktopFromPack(root)) try { DesktopCatalog.cleanLegacy(context) } catch (e: Exception) { Log.w(TAG, "LXQt cleanup will retry next session", e) } GameEnvironmentStore.publish(context) @@ -129,7 +151,11 @@ object SessionFiles { "usr/local/bin/droiddeck-agent" to "usr/local/bin/droiddeck-agent", "usr/local/bin/steam-compatibility" to "usr/local/bin/steam-compatibility", "usr/local/bin/droiddeck-clipboard" to "usr/local/bin/droiddeck-clipboard", + "usr/local/bin/droiddeck-spawn" to "usr/local/bin/droiddeck-spawn", + "usr/local/bin/droiddeck-log-writer" to "usr/local/bin/droiddeck-log-writer", "usr/local/bin/droiddeck-desktop-clipboard" to "usr/local/bin/droiddeck-desktop-clipboard", + "usr/local/bin/droiddeck-text-input" to "usr/local/bin/droiddeck-text-input", + "usr/local/bin/droiddeck-steam-ime" to "usr/local/bin/droiddeck-steam-ime", "usr/local/bin/droiddeck-gpu-window" to "usr/local/bin/droiddeck-gpu-window", "usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install", "usr/local/bin/droiddeck-steam-preapply" to "usr/local/bin/droiddeck-steam-preapply", @@ -147,11 +173,13 @@ object SessionFiles { "usr/local/bin/droiddeck-login1" to "usr/local/bin/droiddeck-login1", "usr/local/bin/droiddeck-documents" to "usr/local/bin/droiddeck-documents", "usr/local/bin/droiddeck-steam-launch" to "usr/local/bin/droiddeck-steam-launch", + "usr/local/bin/droiddeck-qam-relay" to "usr/local/bin/droiddeck-qam-relay", "usr/local/bin/droiddeck-desktop-games" to "usr/local/bin/droiddeck-desktop-games", "usr/local/bin/droiddeck-desktop-programs" to "usr/local/bin/droiddeck-desktop-programs", "usr/local/bin/droiddeck-desktop-bookmarks" to "usr/local/bin/droiddeck-desktop-bookmarks", "usr/local/bin/droiddeck-downloads" to "usr/local/bin/droiddeck-downloads", "usr/local/bin/droiddeck-root" to "usr/local/bin/droiddeck-root", + "usr/local/bin/droiddeck-user" to "usr/local/bin/droiddeck-user", "usr/local/bin/droiddeck-text" to "usr/local/bin/droiddeck-text", "usr/local/bin/droiddeck-snapd" to "usr/local/bin/droiddeck-snapd", "usr/local/bin/droiddeck-emulators" to "usr/local/bin/droiddeck-emulators", @@ -271,6 +299,7 @@ object SessionFiles { "usr/local/lib/droiddeck-pipewire.tzst" to "usr/local/lib/droiddeck-pipewire.tzst", "usr/local/share/licenses/dwarfs/LICENSE" to "usr/local/share/licenses/dwarfs/LICENSE", "usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE", + LSE_EMU to LSE_EMU, ) + mangoapp + xclipse.map { it to it } + maliCompat + msitools.map { it to it } + vr + gpuLoad + fexPreloads).filter { (asset, _) -> val dir = asset.substringBeforeLast('/') runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false) @@ -330,22 +359,25 @@ object SessionFiles { if (installed) ledger.staged(key, target) else Log.e(TAG, "DirectAudio $set/$relative NOT staged") } for (pack in SERVICE_PACKS.keys) stageStoreService(context, root, pack, ledger) + stageImeFiles(context, root, ledger) ledger.save() for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively() - val preload = StringBuilder("/usr/local/lib/libddsession.so\n") + val preload = StringBuilder(lsePreload(CpuFeatures.lacksAtomics, File(root, LSE_EMU).isFile, lseEmu)) + preload.append("/usr/local/lib/libddsession.so\n") if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) { preload.append("/usr/local/lib/libfakeinput.so\n") } - val nativeUserland = SessionPrefs.nativeUserland(context) - if (nativeUserland) com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root) - if (ProotFastPath.enabled(context)) { + com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root) + val native = com.droiddeck.launcher.runtime.NativeGuest.available(root) + val nativePreload = preload.toString() + if (ProotFastPath.enabled(context, native)) { val library = com.droiddeck.launcher.agent.AgentEnv.fastPathLibrary(context) preload.append(library + "\n") if (startsSession && library != ProotFastPath.LIBRARY) Log.i(TAG, "fast path preload: $library (debugging override)") } val etc = File(root, "etc").apply { mkdirs() } File(etc, "droiddeck").mkdirs() - FileUtils.writeString(File(etc, "droiddeck/native-preload"), preload.toString()) + FileUtils.writeString(File(etc, "droiddeck/native-preload"), nativePreload) val staged = File(etc, "ld.so.preload.staged") if (!FileUtils.writeString(staged, preload.toString()) || !staged.renameTo(File(etc, "ld.so.preload"))) { @@ -356,6 +388,7 @@ object SessionFiles { Log.e(TAG, "could not write steam-compatibility-label") } writeCjkFontConfig(root, etc) + writeSessionBusPolicy(etc) writeDesktopStrings(context, File(etc, "droiddeck").apply { mkdirs() }) val droiddeckEtc = File(etc, "droiddeck").apply { mkdirs() } val stagedSocket = File(droiddeckEtc, "bwrap-socket.staged") @@ -415,6 +448,42 @@ object SessionFiles { seen?.let { SessionPrefs.setBootMovieSteamSeen(context, it) } } + private fun stageImeFiles(context: Context, root: File, ledger: StageLedger) { + val entries = LinkedHashMap() + try { + val text = context.assets.open("linuxfs/$IME_MANIFEST").bufferedReader().use { it.readText() } + val files = JSONObject(text).getJSONObject("files") + for (name in files.keys()) { + entries[name] = files.optJSONObject(name)?.optString("mode").orEmpty().toIntOrNull(8) ?: IME_DEFAULT_MODE + } + entries[IME_MANIFEST] = IME_DEFAULT_MODE + } catch (e: Exception) { + Log.w(TAG, "the Chinese input payload is not bundled; Steam sessions start without it", e) + return + } + for ((relative, mode) in entries) { + val target = File(root, relative) + if (ledger.current(relative, target)) continue + val staged = File(target.parentFile, target.name + ".staged") + var installed = false + try { + target.parentFile?.mkdirs() + context.assets.open("linuxfs/$relative").use { input -> + staged.outputStream().use { output -> FileUtils.copy(input, output) } + } + installed = staged.setReadable(true, false) && + staged.setWritable((mode and 0x80) != 0, true) && + staged.setExecutable((mode and 0x49) != 0, false) && + staged.renameTo(target) + } catch (e: Exception) { + Log.w(TAG, "could not stage $relative", e) + } finally { + if (!installed) staged.delete() + } + if (installed) ledger.staged(relative, target) else Log.e(TAG, "$relative NOT staged") + } + } + internal fun resetMissingStartupMovie(config: File, force: Boolean): Boolean { synchronized(STEAM_CONFIG) { if (!config.isFile) return true @@ -878,6 +947,24 @@ object SessionFiles { } } + /** + * A session bus admits only its owner, and with droiddeck-user (the native hook's ordinary + * user) a root process and a user's share the bus while the kernel sees one Android uid. + */ + private fun writeSessionBusPolicy(etc: File) { + val xml = """ + + + + + +""" + val conf = File(etc, "dbus-1/session.d/droiddeck-users.conf") + conf.parentFile?.mkdirs() + if (!FileUtils.writeString(conf, xml)) Log.e(TAG, "could not write the session bus policy") + } + private fun writeCjkFontConfig(root: File, etc: File) { try { val confDir = File(etc, "fonts/conf.d").apply { mkdirs() } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt index 69cb7d4fae..d8117ae714 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPaths.kt @@ -26,6 +26,9 @@ object SessionPaths { @Volatile private var startedAt = 0L + @Volatile + private var debugLogsContext: Context? = null + @Synchronized fun beginOrCurrent(context: Context, label: String? = null): File { dir?.let { if (it.isDirectory) return it } @@ -44,6 +47,7 @@ object SessionPaths { startedAt = System.currentTimeMillis() if (!made.isDirectory && !made.mkdirs()) Log.e(TAG, "could not create $made") dir = made + debugLogsContext = if (SessionPrefs.gameDebugLogsEnabled(context)) context.applicationContext else null if (enhanced && !EnhancedDiagnostics.consumeInto(context, made)) { Log.e(TAG, "could not activate enhanced diagnostics for $made") } @@ -65,6 +69,9 @@ object SessionPaths { val taken = dir dir = null if (taken != null) ended = taken + val expiring = debugLogsContext + debugLogsContext = null + if (taken != null && expiring != null) SessionPrefs.expireGameDebugLogs(expiring) return taken } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index b5794eff94..d63b67872c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -10,6 +10,7 @@ import com.droiddeck.launcher.gpu.Cardboard import com.droiddeck.launcher.gpu.ScreenEffects import com.droiddeck.launcher.gpu.SystemVulkanDriver import com.droiddeck.launcher.gpu.TurnipDriver +import org.json.JSONArray import org.json.JSONObject import java.io.File @@ -63,6 +64,24 @@ object SessionPrefs { .takeIf { value -> orientationOptions.any { it.first == value } } ?: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE + fun orientation(context: Context, mode: String?): Int { + val key = when (mode) { + "steam", SessionService.MODE_STEAM, SessionService.MODE_RUN -> "orientation.steam" + "desktop", SessionService.MODE_DESKTOP -> "orientation.desktop" + else -> null + } ?: return orientation(context) + val stored = prefs(context).getInt(key, Int.MIN_VALUE) + return if (stored == Int.MIN_VALUE) orientation(context) + else stored.takeIf { value -> orientationOptions.any { it.first == value } } ?: orientation(context) + } + + fun setOrientation(context: Context, mode: String, orientation: Int) { + require(mode == "steam" || mode == "desktop") + require(orientationOptions.any { it.first == orientation }) + val key = if (mode == "steam") "orientation.steam" else "orientation.desktop" + prefs(context).edit().putInt(key, orientation).apply() + } + /** The session menu's width in dp the user dragged it to; null keeps the default. */ fun drawerWidthDp(context: Context): Int? = prefs(context).getInt("drawerWidthDp", 0).takeIf { it > 0 } @@ -75,21 +94,73 @@ object SessionPrefs { prefs(context).edit().putInt("orientation", orientation).apply() } - fun windowOrientation(context: Context, followScreen: Boolean, smallestWidthDp: Int): Int = - if (followScreen && smallestWidthDp >= SessionDisplay.UNFOLDED_MIN_DP && !prefs(context).contains("orientation")) + fun windowOrientation(context: Context, followScreen: Boolean, smallestWidthDp: Int, mode: String? = null): Int { + val modeKey = when (mode) { + "steam", SessionService.MODE_STEAM, SessionService.MODE_RUN -> "orientation.steam" + "desktop", SessionService.MODE_DESKTOP -> "orientation.desktop" + else -> null + } + val preferences = prefs(context) + if (modeKey != null && preferences.contains(modeKey)) return orientation(context, mode) + return if (followScreen && smallestWidthDp >= SessionDisplay.UNFOLDED_MIN_DP && !preferences.contains("orientation")) ActivityInfo.SCREEN_ORIENTATION_USER else orientation(context) + } - fun portrait(context: Context): Boolean = when (orientation(context)) { + fun portrait(context: Context, mode: String? = null): Boolean = when (orientation(context, mode)) { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> true ActivityInfo.SCREEN_ORIENTATION_USER -> context.resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT else -> false } - fun launcherFullscreen(context: Context): Boolean = prefs(context).getBoolean("launcherFullscreen", true) + fun launcherFullscreenMode(context: Context): FullscreenMode { + val preferences = prefs(context) + return FullscreenMode.fromStored(preferences.getString("launcherFullscreenMode", null)) + ?: if (preferences.getBoolean("launcherFullscreen", true)) FullscreenMode.ALWAYS else FullscreenMode.OFF + } - fun setLauncherFullscreen(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("launcherFullscreen", on).apply() + fun setLauncherFullscreenMode(context: Context, mode: FullscreenMode) { + prefs(context).edit().putString("launcherFullscreenMode", mode.name).apply() + } + + fun sessionFullscreenMode(context: Context): FullscreenMode = + FullscreenMode.fromStored(prefs(context).getString("sessionFullscreenMode", null)) ?: FullscreenMode.ALWAYS + + fun setSessionFullscreenMode(context: Context, mode: FullscreenMode) { + prefs(context).edit().putString("sessionFullscreenMode", mode.name).apply() + } + + fun launcherFrost(context: Context): Boolean = prefs(context).getBoolean("launcherFrost", false) + + fun setLauncherFrost(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("launcherFrost", on).apply() + } + + fun frostWallpaper(context: Context): Boolean = prefs(context).getBoolean("frostWallpaper", true) + + fun setFrostWallpaper(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("frostWallpaper", on).apply() + } + + fun frostCards(context: Context): Boolean = prefs(context).getBoolean("frostCards", true) + + fun setFrostCards(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("frostCards", on).apply() + } + + fun frostTransparency(context: Context): Int = frostPercent(context, "frostTransparency", com.droiddeck.launcher.ui.FROST_WALLPAPER_DEFAULT) + + fun setFrostTransparency(context: Context, percent: Int) = setFrostPercent(context, "frostTransparency", percent) + + fun frostCardTransparency(context: Context): Int = frostPercent(context, "frostCardTransparency", com.droiddeck.launcher.ui.FROST_DEFAULT) + + fun setFrostCardTransparency(context: Context, percent: Int) = setFrostPercent(context, "frostCardTransparency", percent) + + private fun frostPercent(context: Context, key: String, default: Int): Int = + prefs(context).getInt(key, default).coerceIn(0, com.droiddeck.launcher.ui.FROST_MAX) + + private fun setFrostPercent(context: Context, key: String, percent: Int) { + prefs(context).edit().putInt(key, percent.coerceIn(0, com.droiddeck.launcher.ui.FROST_MAX)).apply() } fun controllerHaptics(context: Context): Boolean = prefs(context).getBoolean("controllerHaptics", true) @@ -142,6 +213,55 @@ object SessionPrefs { private fun secondScreenPanelKey(desktop: Boolean) = if (desktop) "secondScreenPanel.desktop" else "secondScreenPanel.game" + fun gameSecondScreenPanel(context: Context, game: String): String? = prefs(context).getString("secondScreenPanel.app.$game", null) + + fun setGameSecondScreenPanel(context: Context, game: String, mode: String) { + prefs(context).edit().putString("secondScreenPanel.app.$game", mode).apply() + } + + fun gameBottomPage(context: Context, game: String): String? = prefs(context).getString("bottomPage.app.$game", null) + + fun setGameBottomPage(context: Context, game: String, page: String) { + prefs(context).edit().putString("bottomPage.app.$game", page).apply() + } + + /** The bottom screen's brightness in percent, or null to follow the system. */ + fun bottomBrightness(context: Context): Int? = prefs(context).getInt("bottomBrightness", -1).takeIf { it >= 0 } + + fun setBottomBrightness(context: Context, percent: Int) { + prefs(context).edit().putInt("bottomBrightness", percent).apply() + } + + fun bottomAutoDim(context: Context): Boolean = prefs(context).getBoolean("bottomAutoDim", true) + + fun setBottomAutoDim(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("bottomAutoDim", on).apply() + } + + fun mirrorRegion(context: Context, game: String): String? = prefs(context).getString("mirrorRegion.app.$game", null) + + fun setMirrorRegion(context: Context, game: String, region: String) { + prefs(context).edit().putString("mirrorRegion.app.$game", region).apply() + } + + fun mirrorHide(context: Context, game: String): String = prefs(context).getString("mirrorHide.app.$game", null) ?: "off" + + fun setMirrorHide(context: Context, game: String, mode: String) { + prefs(context).edit().putString("mirrorHide.app.$game", mode).apply() + } + + /** How Steam's Quick Access menu sits on the bottom screen: full, left, center or right. */ + fun quickAccessLayout(context: Context): String? = prefs(context).getString("bottomQamLayout", null) + + fun setQuickAccessLayout(context: Context, id: String) { + prefs(context).edit().putString("bottomQamLayout", id).apply() + } + + fun clearGameBottomScreen(context: Context, game: String) { + prefs(context).edit().remove("secondScreenPanel.app.$game").remove("bottomPage.app.$game").remove("mirrorRegion.app.$game") + .remove("mirrorHide.app.$game").apply() + } + /** The bottom-screen desktop takes touch as a trackpad unless the user switched it to direct touch. */ fun bottomDesktopDirectTouch(context: Context): Boolean = prefs(context).getBoolean("bottomDesktopDirectTouch", false) @@ -198,6 +318,14 @@ object SessionPrefs { prefs(context).edit().putBoolean("telemetryAuto", on).apply() } + fun settingsSearches(context: Context): List = runCatching { + JSONArray(prefs(context).getString("settingsSearches", null) ?: "[]").let { a -> List(a.length()) { a.getString(it) } } + }.getOrDefault(emptyList()) + + fun setSettingsSearches(context: Context, searches: List) { + prefs(context).edit().putString("settingsSearches", JSONArray(searches).toString()).apply() + } + fun telemetryOff(context: Context): Set = prefs(context).getStringSet("telemetryOff", null)?.toSet().orEmpty() fun setTelemetryOff(context: Context, keys: Set) { @@ -256,13 +384,13 @@ object SessionPrefs { prefs(context).edit().putInt("libraryCardLevel", level).apply() } - fun libraryShowTitle(context: Context): Boolean = prefs(context).getBoolean("libraryShowTitle", true) + fun libraryShowTitle(context: Context): Boolean = prefs(context).getBoolean("libraryShowTitle", false) fun setLibraryShowTitle(context: Context, show: Boolean) { prefs(context).edit().putBoolean("libraryShowTitle", show).apply() } - fun libraryShowSize(context: Context): Boolean = prefs(context).getBoolean("libraryShowSize", true) + fun libraryShowSize(context: Context): Boolean = prefs(context).getBoolean("libraryShowSize", false) fun setLibraryShowSize(context: Context, show: Boolean) { prefs(context).edit().putBoolean("libraryShowSize", show).apply() @@ -444,6 +572,17 @@ object SessionPrefs { prefs(context).edit().putString("drawerPageHidden", keys.joinToString(",")).apply() } + fun drawerSections(context: Context): Map = + idList(prefs(context).getString("drawerSections", null)).mapNotNull { entry -> + val at = entry.lastIndexOf('=').takeIf { it > 0 } ?: return@mapNotNull null + entry.substring(0, at) to (entry.substring(at + 1) == "1") + }.toMap() + + fun setDrawerSections(context: Context, sections: Map) { + prefs(context).edit().putString("drawerSections", sections.entries.filter { ',' !in it.key } + .joinToString(",") { "${it.key}=${if (it.value) 1 else 0}" }).apply() + } + fun setNavTabHidden(context: Context, keys: Set) { prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply() } @@ -827,13 +966,21 @@ object SessionPrefs { } - fun picturePosition(context: Context): String = - prefs(context).getString("picturePosition", "center") - ?.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center" + private val picturePositions = setOf("center", "top", "bottom", "left", "right") - fun setPicturePosition(context: Context, position: String) { - prefs(context).edit().putString("picturePosition", - position.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center").apply() + private fun picturePositionKey(portrait: Boolean) = + if (portrait) "picturePosition.portrait" else "picturePosition.landscape" + + fun picturePosition(context: Context, portrait: Boolean): String { + val preferences = prefs(context) + return preferences.getString(picturePositionKey(portrait), null)?.takeIf { it in picturePositions } + ?: preferences.getString("picturePosition", null)?.takeIf { it in picturePositions } + ?: if (portrait) "top" else "center" + } + + fun setPicturePosition(context: Context, portrait: Boolean, position: String) { + require(position in picturePositions) + prefs(context).edit().putString(picturePositionKey(portrait), position).apply() } fun integerScaling(context: Context): Boolean = @@ -911,12 +1058,6 @@ object SessionPrefs { fun micAsked(context: Context): Boolean = prefs(context).getBoolean("micAsked", false) - fun allFilesAsked(context: Context): Boolean = prefs(context).getBoolean("allFilesAsked", false) - - fun setAllFilesAsked(context: Context) { - prefs(context).edit().putBoolean("allFilesAsked", true).apply() - } - fun bluetoothAsked(context: Context): Boolean = prefs(context).getBoolean("bluetoothAsked", false) fun setBluetoothAsked(context: Context) { @@ -959,6 +1100,7 @@ object SessionPrefs { fun setGameCpus(context: Context, list: String) { prefs(context).edit().putString("gameCpus", list).apply() + GameEnvironmentStore.publishGameCores(context) } fun noXalia(context: Context): Boolean = prefs(context).getBoolean("noXalia", true) @@ -1040,22 +1182,22 @@ object SessionPrefs { fun gameThreadHints(context: Context): Boolean = prefs(context).getBoolean("gameThreadHints", true) - fun prootNoSeccomp(context: Context): Boolean = prefs(context).getBoolean("prootNoSeccomp", false) + /** Whether the phone's shared storage (/sdcard) is mounted into the Linux container. */ + @JvmStatic + fun mountSharedStorage(context: Context): Boolean = prefs(context).getBoolean("mountSharedStorage", true) - fun setProotNoSeccomp(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("prootNoSeccomp", on).apply() + fun setMountSharedStorage(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("mountSharedStorage", on).apply() } - fun nativeUserland(context: Context): Boolean = prefs(context).getBoolean("nativeUserland", true) + /** The session's long-lived programs run in worker processes Android does not count (GuestWorkers). */ + fun childProcessHandoff(context: Context): Boolean = prefs(context).getBoolean("childProcessHandoff", true) - fun setNativeUserland(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("nativeUserland", on).apply() - } + /** Whether the Plasma desktop, and so its apps and shells, runs as an ordinary user instead of root (native userland only). */ + fun desktopAsUser(context: Context): Boolean = prefs(context).getBoolean("desktopAsUser", false) - fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true) - - fun setProotFastPath(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("prootFastPath", on).apply() + fun setDesktopAsUser(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("desktopAsUser", on).apply() } fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", true) @@ -1177,6 +1319,11 @@ object SessionPrefs { prefs(context).edit().putBoolean("venus", on).apply() } + /** Venus off with no choice stored, so that Auto turning it off does not read as the user's own choice. */ + fun clearVenus(context: Context) { + prefs(context).edit().remove("venus").apply() + } + fun setVkBridge(context: Context, on: Boolean) { prefs(context).edit().putBoolean("vkBridge", on).putBoolean("bridgeFellBack", false).apply() } @@ -1228,7 +1375,7 @@ object SessionPrefs { oldValue = logsEnabled(context), newValue = on, newEffective = gameDebugLogsEffective(context, on, gameDebugLogsEnabled(context)), - ) + ).also { if (it) BuildWatermarkSetting.notifyChanged(context) } } fun gameDebugLogsEnabled(context: Context): Boolean = @@ -1241,7 +1388,13 @@ object SessionPrefs { oldValue = gameDebugLogsEnabled(context), newValue = on, newEffective = gameDebugLogsEffective(context, logsEnabled(context), on), - ) + ).also { if (it) BuildWatermarkSetting.notifyChanged(context) } + } + + /** The setting lasts for the session that started with it on; the next session's start republishes the environment. */ + internal fun expireGameDebugLogs(context: Context) { + prefs(context).edit().putBoolean("gameDebugLogsEnabled", false).apply() + runCatching { BuildWatermarkSetting.notifyChanged(context) } } private fun setLogPreference( @@ -1370,10 +1523,12 @@ object SessionPrefs { fun resolutionStored(context: Context, mode: String, panel: Pair, portrait: Boolean): String { if (!portrait) return landscapeResolutionStored(context, mode, panel) - val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE + val fallback = if (mode == SessionService.MODE_STEAM) SessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION + else SessionDisplay.LINK_LANDSCAPE + val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return fallback if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) || SessionDisplay.presetHeight(value) != null) return value - return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE + return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: fallback } fun parseOrientedResolution(text: String): Pair? = @@ -1635,6 +1790,9 @@ object SessionPrefs { name.removeSuffix(from) + to to moved } + fun storedAddedGameAppId(context: Context, folderPath: String): Long? = + prefs(context).getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L } + fun addedGameAppId(context: Context, folderPath: String, first: Long): Long = synchronized(addedGameLock) { val p = prefs(context) p.getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L } @@ -1679,6 +1837,7 @@ object SessionPrefs { signal = p.getInt("customThemeSignal", defaults.signal), good = p.getInt("customThemeGood", defaults.good), error = p.getInt("customThemeError", defaults.error), + warning = p.getInt("customThemeWarning", defaults.warning), ) } @@ -1699,6 +1858,7 @@ object SessionPrefs { .putInt("customThemeSignal", colors.signal) .putInt("customThemeGood", colors.good) .putInt("customThemeError", colors.error) + .putInt("customThemeWarning", colors.warning) .apply() } @@ -1729,10 +1889,17 @@ object SessionPrefs { prefs(context).edit().putBoolean(hdrKey(mode), on).apply() } - fun zeroCopy(context: Context, mode: String): Boolean = prefs(context).getBoolean("zeroCopy.$mode", true) + /** Restart-scoped opt-in; not inferred from Zero-copy (which defaults on). */ + fun producerAcquireFences(context: Context): Boolean = prefs(context).getBoolean("producerAcquireFences", false) + + fun setProducerAcquireFences(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("producerAcquireFences", on).apply() + } + + fun zeroCopy(context: Context, mode: String): Boolean = prefs(context).getBoolean("zeroCopy.${prefMode(mode)}", true) fun setZeroCopy(context: Context, mode: String, on: Boolean) { - prefs(context).edit().putBoolean("zeroCopy.$mode", on).apply() + prefs(context).edit().putBoolean("zeroCopy.${prefMode(mode)}", on).apply() } const val FPS_UNPACED = -1 @@ -1742,16 +1909,18 @@ object SessionPrefs { const val PIP_FPS = 30 - fun compositorFpsLimit(mirrorRefreshLimit: Int, sessionLimit: Int = 0, pip: Boolean = false): Int { - val limit = when { - mirrorRefreshLimit <= 0 && sessionLimit <= 0 -> FPS_UNPACED - mirrorRefreshLimit <= 0 -> sessionLimit - sessionLimit <= 0 -> mirrorRefreshLimit - else -> minOf(mirrorRefreshLimit, sessionLimit) - } + fun compositorFpsLimit(mirrorRefreshLimit: Int, sessionLimit: Int = 0, pip: Boolean = false, hostCap: Int = 0): Int { + val limit = listOf(mirrorRefreshLimit, sessionLimit, hostCap).filter { it > 0 }.minOrNull() ?: FPS_UNPACED return if (pip && mirrorRefreshLimit <= 0 && (limit <= 0 || limit > PIP_FPS)) PIP_FPS else limit } + fun layerFrameRate(ownLimit: Int, refreshHz: Float, blackFrameInsertion: Boolean): Float = + if (ownLimit > 0 && !blackFrameInsertion) ownLimit.toFloat() else refreshHz + + /** The per-app rate Android holds this window to (Game Mode's FPS override), or 0 when the panel's rate applies. */ + fun hostFrameCap(overrideHz: Float, panelHz: Float): Int = + if (overrideHz > 1f && panelHz - overrideHz > 1f) Math.round(overrideHz) else 0 + val upscalerChoices = listOf( 2 to "Nearest", 0 to "Linear", 4 to "AMD FSR 1", 3 to "Snapdragon GSR", 8 to "Snapdragon GSR (quality)", 7 to "NVIDIA NIS", 6 to "Sharpen only", @@ -1847,24 +2016,84 @@ object SessionPrefs { sessionPrefs.edit().putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString()).apply() } + private const val GAME_UPSCALER_OVERRIDES_KEY = "upscaler.gameOverrides" + + private fun gameUpscalerOverrides(context: Context): JSONObject = runCatching { + JSONObject(prefs(context).getString(GAME_UPSCALER_OVERRIDES_KEY, null) ?: "{}") + }.getOrDefault(JSONObject()) + + private fun legacyScreenEffectsUpscaler(context: Context, profileId: String): Int? = + runCatching { + val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}") + val profile = profiles.optJSONObject(profileId) + if (profile?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true) { + profile.optInt(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY, -1).takeIf { it >= 0 } + } else null + }.getOrNull()?.let(::canonicalUpscaler) + + private fun clearLegacyScreenEffectsUpscaler(context: Context, profileId: String) { + val sessionPrefs = prefs(context) + val profiles = runCatching { + JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}") + }.getOrNull() ?: return + val profile = profiles.optJSONObject(profileId) ?: return + if (!profile.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY)) return + profile.remove(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) + if (profile.length() == 0) profiles.remove(profileId) + sessionPrefs.edit().apply { + if (profiles.length() == 0) remove(SCREEN_EFFECTS_PROFILES_KEY) + else putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString()) + }.apply() + } + + fun hasGameUpscalerOverride(context: Context, gameId: String): Boolean { + if (gameId.isBlank()) return false + val stored = gameUpscalerOverrides(context) + return (stored.has(gameId) && stored.optInt(gameId, -1) >= 0) || + legacyScreenEffectsUpscaler(context, "game:$gameId") != null + } + + fun setGameUpscaler(context: Context, gameId: String, mode: Int) { + if (gameId.isBlank()) return + val overrides = gameUpscalerOverrides(context) + overrides.put(gameId, canonicalUpscaler(mode)) + prefs(context).edit().putString(GAME_UPSCALER_OVERRIDES_KEY, overrides.toString()).apply() + clearLegacyScreenEffectsUpscaler(context, "game:$gameId") + } + + fun clearGameUpscaler(context: Context, gameId: String) { + if (gameId.isBlank()) return + val sessionPrefs = prefs(context) + val overrides = gameUpscalerOverrides(context) + if (overrides.has(gameId)) { + overrides.remove(gameId) + sessionPrefs.edit().apply { + if (overrides.length() == 0) remove(GAME_UPSCALER_OVERRIDES_KEY) + else putString(GAME_UPSCALER_OVERRIDES_KEY, overrides.toString()) + }.apply() + } + clearLegacyScreenEffectsUpscaler(context, "game:$gameId") + } + fun hasScreenEffectsUpscalerOverride(context: Context, profileId: String?): Boolean { if (profileId.isNullOrBlank()) return false - return runCatching { - val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}") - profiles.optJSONObject(profileId)?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true - }.getOrDefault(false) + if (profileId.startsWith("game:")) { + return hasGameUpscalerOverride(context, profileId.removePrefix("game:")) + } + return legacyScreenEffectsUpscaler(context, profileId) != null } fun screenEffectsUpscaler(context: Context, profileId: String?): Int { if (profileId.isNullOrBlank()) return upscaler(context) - val stored = runCatching { - val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}") - val profile = profiles.optJSONObject(profileId) - if (profile?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true) { - profile.optInt(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY, -1) - } else -1 - }.getOrDefault(-1) - return if (stored >= 0) canonicalUpscaler(stored) else upscaler(context) + if (profileId.startsWith("game:")) { + val gameId = profileId.removePrefix("game:") + val overrides = gameUpscalerOverrides(context) + if (overrides.has(gameId)) { + val stored = overrides.optInt(gameId, -1) + if (stored >= 0) return canonicalUpscaler(stored) + } + } + return legacyScreenEffectsUpscaler(context, profileId) ?: upscaler(context) } fun setScreenEffectsUpscaler(context: Context, profileId: String?, mode: Int) { @@ -1872,6 +2101,10 @@ object SessionPrefs { setUpscaler(context, mode) return } + if (profileId.startsWith("game:")) { + setGameUpscaler(context, profileId.removePrefix("game:"), mode) + return + } val sessionPrefs = prefs(context) val profiles = runCatching { JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}") @@ -1908,6 +2141,7 @@ object SessionPrefs { val profiles = runCatching { JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}") }.getOrElse { JSONObject() } + if (profileId.startsWith("game:")) clearGameUpscaler(context, profileId.removePrefix("game:")) if (!profiles.has(profileId)) return profiles.remove(profileId) sessionPrefs.edit().apply { @@ -2052,6 +2286,12 @@ object SessionPrefs { (resolutionChosen(context, SessionService.MODE_DESKTOP) || resolutionChosen(context, SessionService.MODE_DESKTOP, true))) SessionService.MODE_DESKTOP else prefMode(mode) + fun showGlassesShortcut(context: Context): Boolean = prefs(context).getBoolean("showGlassesShortcut", true) + + fun setShowGlassesShortcut(context: Context, show: Boolean) { + prefs(context).edit().putBoolean("showGlassesShortcut", show).apply() + } + fun pipAutoEnter(context: Context): Boolean = prefs(context).getBoolean("pipAutoEnter", true) fun setPipAutoEnter(context: Context, enabled: Boolean) { diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 283a4e2d58..502f32142c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -47,6 +47,7 @@ import com.droiddeck.launcher.input.SteamControllerBle import com.droiddeck.launcher.runtime.BwrapSpawner import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.runtime.NativeGuest import com.droiddeck.launcher.runtime.ProotFastPath import com.droiddeck.launcher.runtime.UserApps import com.droiddeck.launcher.wayland.WaylandCompositor @@ -394,8 +395,10 @@ class SessionService : Service() { SessionState.program = intent?.getStringExtra(EXTRA_PROGRAM) SessionState.programArgs = intent?.getStringArrayExtra(EXTRA_PROGRAM_ARGS)?.toList().orEmpty() SessionState.steamUi = intent?.getStringExtra(EXTRA_STEAM_UI) - SessionState.steamUrl = intent?.getStringExtra(EXTRA_STEAM_URL) - val steamUrlGameId = SessionState.steamUrl + val launchSteamUrl = intent?.getStringExtra(EXTRA_STEAM_URL) + val frontendSteamGame = intent?.getBooleanExtra(EXTRA_FRONTEND_STEAM_GAME, false) == true + SessionState.steamUrl = launchSteamUrl + val steamUrlGameId = launchSteamUrl ?.let { url -> when { url.startsWith(GAME_URL_PREFIX) -> @@ -417,13 +420,20 @@ class SessionService : Service() { SessionPrefs.screenEffectsProfileId(SessionState.mode, resolvedGameId, SessionState.program), ) com.droiddeck.launcher.stores.battlenet.BattleNetClient.clearRequests(LinuxRuntime.sessionRoot(this)) + QuestSteamVrLaunch.clearRequest(this) val gen = synchronized(SessionState.startLock) { synchronized(stopLock) { SessionState.steamClientArch = null + SessionState.gameZoom = 1.0f SessionState.running = true ++sessionGen } } + val trimGen = gen + PageCacheTrim.start( + roots = { listOfNotNull(File(filesDir, "linuxfs"), GameStorage.effective(applicationContext)?.let { File(it.path) }).filter(File::isDirectory) }, + alive = { SessionState.running && sessionGen == trimGen }, + ) if (SessionState.stopRequested) { stopSession(0) return START_NOT_STICKY @@ -445,7 +455,7 @@ class SessionService : Service() { Thread({ OrphanReaper.reap("session starting") ProtonExtras.awaitReplacement(120_000) - runSession(gen) + runSession(gen, launchSteamUrl, frontendSteamGame) }, "session-start").start() return START_NOT_STICKY } @@ -498,7 +508,7 @@ class SessionService : Service() { } - private fun runSession(gen: Int) { + private fun runSession(gen: Int, launchSteamUrl: String?, frontendSteamGame: Boolean) { SessionPrefs.ensurePowerVrAutoDriversAfterGpuQuery(this) if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) { com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) } @@ -553,9 +563,11 @@ class SessionService : Service() { return } } - val agentEnvironment = runCatching { com.droiddeck.launcher.agent.AgentEnv.beginSession(this) } + val nextAgentEnvironment = runCatching { com.droiddeck.launcher.agent.AgentEnv.beginSession(this) } .onFailure { Log.w(TAG, "agent environment skipped", it) } - .getOrDefault(emptyList()) + val agentEnvironment = nextAgentEnvironment.getOrDefault(emptyList()) + val customEnvironment = extraEnv() + val lseEmu = (customEnvironment + agentEnvironment).lastOrNull { it.startsWith("LSE_EMU=") }?.substringAfter('=') try { if (systemVulkan) { SystemVulkanDriver.prepare(this) @@ -565,7 +577,7 @@ class SessionService : Service() { } pruneSystemVulkanRuntime() } - SessionFiles.stage(this, root, startsSession = true) + SessionFiles.stage(this, root, startsSession = true, lseEmu = lseEmu) } catch (error: Exception) { Log.e(TAG, "Could not prepare the session graphics runtime", error) failSession(gen, "GRAPHICS_RUNTIME_FAILED", getString(R.string.session_graphics_runtime_failed), -1) @@ -612,6 +624,9 @@ class SessionService : Service() { val size = SessionState.outputSize val guest = ArrayList() val steamHere = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP + runCatching { SessionEvents.step("components-xbox") { XboxBackCompatComponents.ensure(this) } } + .onSuccess { if (it != null) Log.i(TAG, it) } + .onFailure { Log.w(TAG, "original Xbox components", it) } runCatching { SessionEvents.step("components-republish") { ComponentsManager.republish(this) } } .onSuccess { if (it) Log.i(TAG, "component selections published for the installed Proton builds") } .onFailure { Log.w(TAG, "component selections", it) } @@ -621,7 +636,7 @@ class SessionService : Service() { .onFailure { Log.w(TAG, "forced components", it) } } try { - SessionEvents.step("client-environment") { addClientEnvironment(guest, steamHere, agentEnvironment) } + SessionEvents.step("client-environment") { addClientEnvironment(guest, steamHere, agentEnvironment, customEnvironment) } } catch (e: IllegalStateException) { Log.e(TAG, "Could not resolve the selected Linux Vulkan driver", e) failSession(gen, "VULKAN_DRIVER_UNAVAILABLE", e.message ?: "Selected Linux Vulkan driver is unavailable", -1) @@ -659,7 +674,7 @@ class SessionService : Service() { Log.i(TAG, "game resolution: ${w}x$h on a ${size.first}x${size.second} output") } if (SessionState.followScreen || size.first < size.second || - SessionPrefs.orientation(this) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER) + SessionPrefs.orientation(this, SessionState.mode) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER) guest.add("DD_FOLLOW_OUTPUT=1") if (SessionState.hdr) { guest.add("DD_HDR=1") @@ -693,18 +708,48 @@ class SessionService : Service() { .onFailure { Log.w(TAG, "Epic install directory setup failed", it) } } if (steamHere || noSteamGame) { - val added = SessionEvents.step("added-games-scan") { com.droiddeck.launcher.frontend.AddedGames.scan(this) } - val listing = SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) } + val listing = if (steamHere) SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGamesPublisher.sessionListing(this) } else { + val added = SessionEvents.step("added-games-scan") { com.droiddeck.launcher.frontend.AddedGames.scan(this) } + com.droiddeck.launcher.frontend.AddedGamesPublisher.log(added) + SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) } + } guest.add("DD_ADDED_GAMES=" + listing.path) if (OfflineMode.active(this)) guest.add("DD_STEAM_OFFLINE=1") if (com.droiddeck.launcher.gpu.Lossless.owned(this)) guest.add("DD_LOSSLESS_OWNED=1") - if (added.isNotEmpty()) Log.i(TAG, "added games: " + added.joinToString { "${it.name} (${it.exe.name})" }) } guest.add("DD_LAUNCH_DIR=" + sessionRoot.path) + // this session's worker number: the shared field may be a newer session's by the time it is used + var ownWorkers = 0 + if (com.droiddeck.launcher.runtime.GuestWorkers.enabled(this)) { + val fenceWorker = com.droiddeck.launcher.runtime.FrameAcquireWorkerProbe + val preparedFence = if (steamHere && !systemVulkan && !VenusComponent.wanted(this) && + SessionPrefs.zeroCopy(this, MODE_STEAM) && SessionPrefs.producerAcquireFences(this) && + nextAgentEnvironment.isSuccess && fenceWorker.validEnvironment(agentEnvironment, customEnvironment) + ) fenceWorker.prepare(this, launchSteamUrl, frontendSteamGame) else null + var fenceArmed = false + // Under the lock a stop takes its number with: a stop either comes first (and this session + // starts no workers) or owns them + ownWorkers = synchronized(stopLock) { + if (gen != sessionGen || !SessionState.running) 0 + else com.droiddeck.launcher.runtime.GuestWorkers.serve(this).also { + guestWorkerSession = it + if (preparedFence != null) fenceArmed = fenceWorker.arm(it, preparedFence) + } + } + if (ownWorkers > 0) { + guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this)) + guest.add("DD_SPAWN_SESSION=$ownWorkers") + if (fenceArmed) { + guest.add(fenceWorker.GAMESCOPE_ENABLE) + guest.add(fenceWorker.GAME_ENABLE) + } + } + } // Proton builds up to 11.12 report X11 text fields under this name. guest.add("BL_LAUNCH_DIR=" + sessionRoot.path) GameStorage.effective(this)?.let { guest.add("DD_LIBRARY_LABEL=" + it.label.replace('"', ' ')) } if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("DD_STEAM_UI=desktop") + if (SessionPrefs.desktopAsUser(this)) guest.add("DD_DESKTOP_USER=1") // Detailed graphics logs: per-game logs and the guest's Vulkan summary (a GPU that is not // an Adreno, or Setup's switch), and graphics-report.txt for every session. if (GraphicsReport.detailed(this)) guest.add("DD_GAME_LOGS=1") @@ -719,7 +764,7 @@ class SessionService : Service() { val desktopGuest = ArrayList(guest) guest.add(LinuxRuntime.SESSION_SCRIPT) guest.add(SessionState.mode) - if (SessionState.mode == MODE_STEAM) SessionState.steamUrl?.takeIf { it.startsWith("steam://") }?.let { + if (SessionState.mode == MODE_STEAM) launchSteamUrl?.takeIf { it.startsWith("steam://") }?.let { guest.add(it) Log.i(TAG, "steam: handing the client $it") } @@ -739,14 +784,16 @@ class SessionService : Service() { SessionEvents.step("shm-clear") { FileUtils.clear(File(LinuxRuntime.liveDir(this), "shm")) } - val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir) - val nativeUserland = com.droiddeck.launcher.runtime.NativeGuest.enabled(this) + val sharedStorage = LinuxRuntime.sharedStorage(this) + val nativeUserland = NativeGuest.enabled(this) + val fastPath = ProotFastPath.enabled(this, nativeUserland) + val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage, fastPath) synchronized(stopLock) { if (gen == sessionGen && SessionState.running) com.droiddeck.launcher.runtime.NativeGuest.sessionMode = nativeUserland } - val fastPathKey = if (ProotFastPath.enabled(this)) { + val fastPathKey = if (fastPath) { val prootBinds = LinuxRuntime.binds( - this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, + this, sessionRoot, runtimeDir, sharedStorage, binds, ) val root = LinuxRuntime.rootDir(this) ProotFastPath.key(root, prootBinds)?.also { key -> @@ -760,21 +807,19 @@ class SessionService : Service() { } } else null - val sessionBindSpecs = LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds) + val sessionBindSpecs = LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds) val command = if (nativeUserland) { LinuxRuntime.rememberSessionBinds(sessionBindSpecs) com.droiddeck.launcher.runtime.NativeGuest.command(root, guest.first(), guest.drop(1)) } else { - LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, guest) + val reason = if (NativeGuest.loader(root) == null) "missing glibc loader" else "missing native hook" + Log.i(TAG, "guest runtime: using PRoot ($reason)") + LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, guest) } val prootEnv = HostEnvironment() prootEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(this).path prootEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(this).path - if (SessionPrefs.prootNoSeccomp(this)) { - prootEnv["PROOT_NO_SECCOMP"] = "1" - if (!nativeUserland) Log.i(TAG, "proot: seccomp acceleration off by request") - } fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> prootEnv[k] = v } } for (key in listOf("PROOT_PROFILE", "PROOT_PROFILE_SLOW_US")) { guest.lastOrNull { it.startsWith("$key=") }?.substringAfter('=')?.let { prootEnv[key] = it } @@ -786,7 +831,7 @@ class SessionService : Service() { if (drives > 0) Log.i(TAG, "$drives Wine drive links given their guest paths back") val hostEnv = if (nativeUserland) HostEnvironment().also { env -> Log.i(TAG, "native userland: no proot (${sessionBindSpecs.size} mounts)") - com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, guest.first(), SessionPrefs.guestHostname(this)) + com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, guest.first(), SessionPrefs.guestHostname(this), lseEmu) .forEach { (k, v) -> env[k] = v } } else prootEnv @@ -794,7 +839,7 @@ class SessionService : Service() { val terminalCommand = if (nativeUserland) { com.droiddeck.launcher.runtime.NativeGuest.command(root, shellGuest.first(), shellGuest.drop(1)) } else { - LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, shellGuest) + LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, shellGuest) } val terminalHostEnvironment = LinkedHashMap(System.getenv()) hostEnv.asArray().forEach { entry -> @@ -805,7 +850,7 @@ class SessionService : Service() { SessionTerminal.prepare(terminalCommand, terminalHostEnvironment.map { (key, value) -> "$key=$value" }.toTypedArray(), root, gen) val (fastPathName, _) = ProotFastPath.hostEnv("") BottomDesktop.prepare(desktopGuest, binds, sessionRoot, - prootEnv.asArray().filterNot { it.startsWith("$fastPathName=") }.toTypedArray(), root, sessionDir, gen, nativeUserland, + prootEnv.asArray().filterNot { it.startsWith("$fastPathName=") }.toTypedArray(), root, sessionDir, gen, nativeUserland, sharedStorage, ) { gen == sessionGen && SessionState.running } } @@ -858,10 +903,10 @@ class SessionService : Service() { watchLaunchRequests(sessionRoot) watchSyncWanted(root) EsyncPacks.fetchInBackground(this, root) - val pid = SessionEvents.step("guest-launch") { HostProcess.start(line, hostEnv.asArray(), root, { status -> + val pid = SessionEvents.step("guest-launch") { HostProcess.startUncounted(line, hostEnv.asArray(), root, { status -> if (gen != sessionGen) { Log.i(TAG, "an earlier session's process ended ($status); the current one carries on") - return@start + return@startUncounted } val program = programStatus(sessionRoot) Log.i(TAG, "session ended: $status" + if (program != null) " (program $program)" else "") @@ -877,10 +922,19 @@ class SessionService : Service() { syncWatcher = null } abandonStart(gen, sessionDir, started) - if (pid > 1) Thread({ teardown(pid) }, "session-teardown").start() + val workers = ownWorkers + if (pid > 1) Thread({ teardown(pid, workerSession = workers) }, "session-teardown").start() + else com.droiddeck.launcher.runtime.GuestWorkers.stopGuests(workers) return } sessionPid = pid + // Under the lock Stop clears it with, and only while this session still runs: a Stop since the + // check above has cleared it already, and this would set it again for no running session. + val uncounted = com.droiddeck.launcher.runtime.GuestWorkers.runsInWorker(pid) + synchronized(stopLock) { + if (gen == sessionGen && SessionState.running) + com.droiddeck.launcher.runtime.GuestWorkers.sessionRootUncounted = uncounted + } if (pid > 1) { raiseTracer(pid, gen) SessionEvents.guestStarted(pid) @@ -892,11 +946,15 @@ class SessionService : Service() { return } if (gen == sessionGen && SessionState.running) { + val workers = ownWorkers suspendController = SessionSuspendController( sessionRoot = { sessionPid }, + // Programs handed off to worker processes are not descendants of the session root, and + // the clock shift applied at resume would move their monotonic time backwards. helperRoots = { components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } + - listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 }) + listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 }) + + (if (workers > 0) com.droiddeck.launcher.runtime.GuestWorkers.guestPids(workers) else emptyList()) }, suspendAudio = { if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink") @@ -988,7 +1046,8 @@ class SessionService : Service() { return com.droiddeck.launcher.input.GesturePrefs.read(this, game).relativeMouseMode } - private fun addClientEnvironment(guest: MutableList, steamHere: Boolean, agentEnvironment: List) { + private fun addClientEnvironment(guest: MutableList, steamHere: Boolean, + agentEnvironment: List, customEnvironment: List) { guest.add("/usr/bin/env") guest.add("-i") guest.add("DROIDDECK_BWRAP_SOCKET=" + com.droiddeck.launcher.runtime.BwrapSpawner.socket(this)) @@ -1108,7 +1167,7 @@ class SessionService : Service() { guest.add("DD_ZRAM=1") } guest.add("AUDIO_DIRECT_DECAY=0") - val extra = extraEnv() + agentEnvironment + val extra = customEnvironment + agentEnvironment guest.addAll(TurnipEnvironment.gameEnvironment(tuOverride, tuDriver, SessionPrefs.tuSysmem(this), extra)) if (extra.none { it.startsWith("MESA_NO_ERROR=") }) guest.add("${GAME_PREFIX}MESA_NO_ERROR=") extra.forEach { guest.add(it) } @@ -1192,6 +1251,7 @@ class SessionService : Service() { } private fun addControllerEnvironment(guest: MutableList, fakeInputDir: File, sessionDir: File) { + DirectControllerSwitch.clear(this) FakeInputWriter.prepareRingSlots(fakeInputDir, 5) val builtinPad = SessionPrefs.builtinPad(this) val hiddenPad = SessionState.mode == MODE_STEAM && !builtinPad && @@ -1255,6 +1315,8 @@ class SessionService : Service() { guest: MutableList, sessionRoot: File, runtimeDir: File, + sharedStorage: File?, + fastPath: Boolean, ): ArrayList { val binds = ArrayList() if (controllersOn) binds.add(fakeInputDir.path + ":/dev/input") @@ -1298,7 +1360,24 @@ class SessionService : Service() { if (controllersOn) components.add(RumbleComponent().also { it.attach(this) }) val home = File(LinuxRuntime.rootDir(this), "root") File(home, "Storage").mkdirs() - binds.add(Environment.getExternalStorageDirectory().path + ":/root/Storage") + val addedExeFolders = com.droiddeck.launcher.frontend.AddedExes.list(this).map { File(it.folder) }.distinctBy { it.path } + val addedGameRoots = com.droiddeck.launcher.frontend.AddedGames.roots(this) + val addedFolders = (addedExeFolders + addedGameRoots.map { it.host }).distinctBy { it.path } + for (folder in addedFolders) { + if (com.droiddeck.launcher.files.AllFilesAccess.mayHideFilesIn(folder.path)) + Log.w(TAG, "added games: Android may hide .exe files in $folder because All files access is missing") + } + if (sharedStorage != null) { + binds.add(sharedStorage.path + ":/root/Storage") + } else { + for (folder in addedExeFolders) { + val guest = com.droiddeck.launcher.frontend.AddedGames.guestPath(this, folder) ?: continue + if (!guest.startsWith("/root/Storage/") || !folder.isDirectory) continue + File(LinuxRuntime.rootDir(this), guest.removePrefix("/")).mkdirs() + binds.add(folder.path + ":" + guest) + Log.i(TAG, "added game: $folder -> $guest (shared storage not mounted)") + } + } val library = GameStorage.effective(this) steamLibraryMounts = emptyMap() var storageDiagnosticLibrary: File? = null @@ -1342,7 +1421,7 @@ class SessionService : Service() { Log.w(TAG, "storage diagnostics: selected library could not be identified; metadata snapshot only") } } - for (root in com.droiddeck.launcher.frontend.AddedGames.roots(this)) { + for (root in addedGameRoots) { if (root.host.isDirectory && root.host.canRead()) { File(LinuxRuntime.rootDir(this), root.guest.removePrefix("/")).mkdirs() binds.add(root.host.path + ":" + root.guest) @@ -1371,8 +1450,8 @@ class SessionService : Service() { if (storageDiagnosticLibrary != null && library != null) libraries.add(SecondaryLibrary.CARD_GUESTS[0] to library.label) val gamesLibraries = GameStorage.gamesFolderLibraries(this) if (gamesLibraries.isNotEmpty()) { - var room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + var room = if (fastPath) { + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (games in gamesLibraries) { if (games.host.path + ":" + games.guest !in binds) continue @@ -1413,8 +1492,8 @@ class SessionService : Service() { continue } try { - val room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + val room = if (fastPath) { + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val content = SecondaryLibrary.contentPath(entry.host) val extra = SecondaryLibrary.binds(filesDir, entry.host, listOf(entry.guest), content = content) @@ -1442,8 +1521,8 @@ class SessionService : Service() { if (problem != null) { Log.w(TAG, "x86-64 steam library: $problem") } else try { - val room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + val room = if (fastPath) { + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, x64, listOf(GameStorage.X64_CARD_GUEST)).drop(1) if (extra.size > room) { @@ -1464,8 +1543,8 @@ class SessionService : Service() { continue } try { - val room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + val room = if (fastPath) { + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, entry.x64Host, listOf(entry.x64Guest)).drop(1) if (extra.size > room) { @@ -1500,8 +1579,8 @@ class SessionService : Service() { try { val listing = File(filesDir, "session/desktop-volumes.json").apply { parentFile?.mkdirs() } val volumes = org.json.JSONArray() - var room = if (ProotFastPath.enabled(this)) { - ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds).size + var room = if (fastPath) { + ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (root in com.droiddeck.launcher.files.StorageRoots.list(this)) { if (!root.removable || !root.readable) continue @@ -1521,10 +1600,15 @@ class SessionService : Service() { return binds } - private fun teardown(prootPid: Int, expectedStartTime: Long? = null) { + // The workers' session number of the session running now (GuestWorkers.serve) + @Volatile private var guestWorkerSession = 0 + + private fun teardown(prootPid: Int, expectedStartTime: Long? = null, workerSession: Int = guestWorkerSession) { fun stillSameProcess(): Boolean = expectedStartTime == null || readStat(prootPid)?.second == expectedStartTime if (!stillSameProcess()) return - val tree = descendants(prootPid) + // The session's programs that run in worker processes are not descendants of its root. + val workers = if (expectedStartTime == null) com.droiddeck.launcher.runtime.GuestWorkers.guestPids(workerSession) else emptyList() + val tree = descendants(prootPid) + workers.flatMap { pid -> listOfNotNull(readStat(pid)?.let { Pair(pid, it.second) }) + descendants(pid) } if (!stillSameProcess()) return saveWineRegistries(tree) android.os.Process.sendSignal(prootPid, 15) @@ -1541,6 +1625,7 @@ class SessionService : Service() { killed++ } if (killed > 0) Log.i(TAG, "swept $killed process(es) proot left behind") + if (expectedStartTime == null) com.droiddeck.launcher.runtime.GuestWorkers.stopGuests(workerSession) } private fun clearCachedApps() { @@ -1715,6 +1800,7 @@ class SessionService : Service() { SessionEvents.record("steam.game_launch_requested", mapOf("gameId" to gameId, "generation" to gen)) watchGameExit(gameId, gen, exitWatchToken, pendingSteamPreviousGameId) Log.i(TAG, "queued Steam game $gameId for the running client") + com.droiddeck.launcher.runtime.GuestWorkers.expectLaunch(this) } private fun watchGameExit( @@ -1729,6 +1815,7 @@ class SessionService : Service() { var startupWasSuspended = false var seen = false var goneSince = 0L + var gamePid: String? = null while (token == gameExitWatchToken && gen == sessionGen && SessionState.running && !SessionState.stopRequested) { val now = android.os.SystemClock.elapsedRealtime() val startupSuspended = SessionState.suspended || SessionState.suspending || SessionState.phase != SessionPhase.READY @@ -1744,7 +1831,8 @@ class SessionService : Service() { lastStartupCheck = now } } - if (steamGameRunning(gameId)) { + gamePid = SteamGameProcess.runningPid(gameId, gamePid) + if (gamePid != null) { if (!seen) { Log.i(TAG, "game $gameId started; tracking its exit") mainHandler.post { @@ -1886,21 +1974,11 @@ class SessionService : Service() { File(directory, STEAM_GAME_REQUEST + ".tmp").delete() } - private fun killGuestLeftovers() { - val me = android.os.Process.myPid() + private fun killGuestLeftovers(ended: File?) { val rootfs = try { File(filesDir, "linuxfs").canonicalPath } catch (e: Exception) { return } + "/" - val procs = File("/proc").listFiles { f -> f.name.all { it.isDigit() } } ?: return - val spared = OrphanReaper.spared() - var killed = 0 - for (proc in procs) { - val pid = proc.name.toIntOrNull() ?: continue - if (pid == me || pid in spared) continue - val exe = try { File(proc, "exe").canonicalPath } catch (e: Exception) { continue } - if (!exe.startsWith(rootfs)) continue - android.os.Process.killProcess(pid) - killed++ - } - if (killed > 0) Log.w(TAG, "killed $killed guest process(es) proot no longer tracked") + val leftovers = GuestLeftovers.find(rootfs, ended, OrphanReaper.spared() + android.os.Process.myPid()) + leftovers.forEach { android.os.Process.killProcess(it) } + if (leftovers.isNotEmpty()) Log.w(TAG, "killed ${leftovers.size} guest process(es) proot no longer tracked") } private fun killStragglers() { @@ -2319,12 +2397,16 @@ class SessionService : Service() { return } completeNativeSleep() + var workers = 0 val (ended, endedArch) = synchronized(stopLock) { if (gen != null && gen != sessionGen) return + // as it is when running is cleared: startup registers its workers under this lock too + workers = guestWorkerSession cancelQueuedSteamGame() gameExitWatchToken++ // also when startup stopped before the guest ran com.droiddeck.launcher.runtime.NativeGuest.sessionMode = null + com.droiddeck.launcher.runtime.GuestWorkers.sessionRootUncounted = null if (!SessionState.running) return if (relaunch) SessionState.confirmRelaunchStop() SessionEvents.record("guest.exited", mapOf("status" to status)) @@ -2385,8 +2467,9 @@ class SessionService : Service() { if (prootPid > 1 && steamClientMayRun) askSteamToExit(prootPid) com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession) auxiliary.forEach { (pid, started) -> teardown(pid, started) } - if (prootPid > 1) teardown(prootPid) - killGuestLeftovers() + if (prootPid > 1) teardown(prootPid, workerSession = workers) + else com.droiddeck.launcher.runtime.GuestWorkers.stopGuests(workers) + killGuestLeftovers(ended) pruneSystemVulkanRuntime() finishSessionStop(status, stoppedGen, collectEnded) if (launcherEnded) importLauncherGames() @@ -2394,6 +2477,7 @@ class SessionService : Service() { } else { Thread({ pruneSystemVulkanRuntime() }, "system-vulkan-prune").start() Thread({ + com.droiddeck.launcher.runtime.GuestWorkers.stopGuests(workers) com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession) finishSessionStop(status, stoppedGen, collectEnded) if (launcherEnded) importLauncherGames() @@ -2712,6 +2796,9 @@ class SessionService : Service() { const val EXTRA_PROGRAM_ARGS = "programArgs" const val EXTRA_STEAM_UI = "steamUi" const val EXTRA_STEAM_URL = "steamUrl" + // Set by the first-party Library play action on the private SessionActivity/Service path. + // Never copied from an exported intent or Agent command. + internal const val EXTRA_FRONTEND_STEAM_GAME = "com.droiddeck.launcher.FRONTEND_STEAM_GAME" const val EXTRA_GAME_ID = "gameId" fun start( @@ -2719,6 +2806,7 @@ class SessionService : Service() { steamUi: String? = null, steamUrl: String? = null, programArgs: Array? = null, gameId: String? = null, displayId: Int = Display.DEFAULT_DISPLAY, + frontendSteamGame: Boolean = false, ) { SteamClientPrefetch.cancel() SessionState.activityDisplayId = displayId @@ -2729,6 +2817,7 @@ class SessionService : Service() { if (programArgs != null) intent.putExtra(EXTRA_PROGRAM_ARGS, programArgs) if (steamUi != null) intent.putExtra(EXTRA_STEAM_UI, steamUi) if (steamUrl != null) intent.putExtra(EXTRA_STEAM_URL, steamUrl) + if (frontendSteamGame) intent.putExtra(EXTRA_FRONTEND_STEAM_GAME, true) if (gameId != null) intent.putExtra(EXTRA_GAME_ID, gameId) if (Build.VERSION.SDK_INT >= 26) context.startForegroundService(intent) else context.startService(intent) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt index 92255febec..ac62bde46c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt @@ -47,6 +47,9 @@ object SessionState { @Volatile var running = false + /** Zoom level retained across activity recreation for the active session. */ + @Volatile + var gameZoom = 1.0f @Volatile var activityDisplayId = 0 @Volatile diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionVisibilityPolicy.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionVisibilityPolicy.kt index 90630ebbcd..79cc595af9 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionVisibilityPolicy.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionVisibilityPolicy.kt @@ -1,6 +1,12 @@ package com.droiddeck.launcher.session internal object SessionVisibilityPolicy { + fun shouldCloseSecondScreenOnStop( + screenOff: Boolean, + dockedDrawerOpen: Boolean, + attachmentPickerOpen: Boolean, + ): Boolean = !screenOff && !(dockedDrawerOpen && attachmentPickerOpen) + fun isHidden( activityStarted: Boolean, defaultDisplayOn: Boolean, diff --git a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt index 0c1d8ddb1b..c9852d4b8b 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt @@ -12,17 +12,17 @@ object SettingsReset { private const val TAG = "SettingsReset" internal val SESSION_KEYS = setOf( - "orientation", "launcherFullscreen", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt", + "orientation", "launcherFullscreen", "launcherFullscreenMode", "sessionFullscreenMode", "launcherFrost", "frostWallpaper", "frostCards", "frostTransparency", "frostCardTransparency", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt", "drawerWidthDp", "dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard", "soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature", "storesInstallLanguage", "hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController", "gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController", - "stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys", + "stretch16x9", "avoidNotch", "picturePosition", "picturePosition.portrait", "picturePosition.landscape", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys", "gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop", - "tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores", + "tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "producerAcquireFences", "paceCores", "directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus", - "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite", + "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite", "mountSharedStorage", "guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics", "buildWatermark", "upscaler", "upscaleSharpness", "screenEffects", "blackFrameInsertion", "textureAnisotropy", "textureLodBias", "steamDownloadsInBackground", "steam_offline", "steam_offline_auto", "steam_offline_by_network", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds", "skipBootMovie", diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt index 6b7ecda60c..5aa20cb693 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamGameProcess.kt @@ -55,12 +55,15 @@ object SteamGameProcess { return false } - fun running(gameId: String, proc: File = File("/proc")): Boolean = - proc.listFiles()?.any { p -> - p.name.all(Char::isDigit) && - runCatching { File(p, "cmdline").readBytes() } - .getOrNull()?.let { matches(it, gameId) } == true - } == true + fun running(gameId: String, proc: File = File("/proc")): Boolean = runningPid(gameId, null, proc) != null + + fun runningPid(gameId: String, known: String?, proc: File = File("/proc")): String? { + if (known != null && runs(File(proc, known), gameId)) return known + return proc.listFiles()?.firstOrNull { p -> p.name.all(Char::isDigit) && runs(p, gameId) }?.name + } + + private fun runs(process: File, gameId: String): Boolean = + runCatching { File(process, "cmdline").readBytes() }.getOrNull()?.let { matches(it, gameId) } == true // A front end that resumes a player by launching the same game again would otherwise have Steam // start it a second time, which Steam answers with "Game already running". diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt new file mode 100644 index 0000000000..90905abe80 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamGuides.kt @@ -0,0 +1,98 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import android.text.Html +import java.net.HttpURLConnection +import java.net.URL + +object SteamGuides { + class Guide(val id: String, val title: String, val author: String, val summary: String, val preview: String?, val stars: Int) { + val url: String get() = "https://steamcommunity.com/sharedfiles/filedetails/?id=$id" + } + + class Place(val url: String, val scroll: Float) + + val TAGS = listOf("Walkthroughs", "Achievements", "Secrets", "Maps or Levels") + + internal fun listUrl(appId: Long, tag: String?, language: String? = null): String = + "https://steamcommunity.com/app/$appId/guides/?browsefilter=toprated&browsesort=toprated" + + listOfNotNull(tag, language).joinToString("") { "&requiredtags%5B%5D=" + java.net.URLEncoder.encode(it, "UTF-8") } + + internal fun language(locale: java.util.Locale): String { + val tag = locale.toLanguageTag() + return when { + tag.startsWith("zh-Hant") || locale.country in setOf("TW", "HK", "MO") && locale.language == "zh" -> "tchinese" + locale.language == "zh" -> "schinese" + locale.language == "pt" && locale.country == "BR" -> "brazilian" + locale.language == "es" && locale.country.isNotEmpty() && locale.country != "ES" -> "latam" + else -> LANGUAGES[locale.language] ?: "english" + } + } + + fun list(appId: Long, cookies: String?, tag: String? = null, language: String? = language(java.util.Locale.getDefault())): List? { + val found = fetch(appId, cookies, tag, language) + return if (language != null && found != null && found.isEmpty()) fetch(appId, cookies, tag, null) else found + } + + private fun fetch(appId: Long, cookies: String?, tag: String?, language: String?): List? = runCatching { + val connection = URL(listUrl(appId, tag, language)).openConnection() as HttpURLConnection + connection.connectTimeout = 10_000 + connection.readTimeout = 15_000 + connection.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) DroidDeck") + cookies?.takeIf { it.isNotEmpty() }?.let { connection.setRequestProperty("Cookie", it) } + try { + if (connection.responseCode != 200) return null + parse(connection.inputStream.bufferedReader().use { it.readText() }) + } finally { + connection.disconnect() + } + }.getOrNull() + + internal fun parse(html: String): List = html.split("class=\"workshopItemCollectionContainer\"").drop(1).mapNotNull { card -> + val id = ID.find(card)?.groupValues?.get(1) ?: return@mapNotNull null + val title = TITLE.find(card)?.groupValues?.get(1)?.let(::text)?.takeIf { it.isNotEmpty() } ?: return@mapNotNull null + Guide( + id, title, + AUTHOR.find(card)?.groupValues?.get(1)?.let(::text).orEmpty(), + SUMMARY.find(card)?.groupValues?.get(1)?.let(::text).orEmpty(), + PREVIEW.find(card)?.groupValues?.get(1)?.let { Html.fromHtml(it, Html.FROM_HTML_MODE_LEGACY).toString() }, + STARS.find(card)?.groupValues?.get(1)?.toIntOrNull() ?: 0, + ) + }.distinctBy { it.id } + + fun place(context: Context, game: String): Place? { + val prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE) + val url = prefs.getString("$game.url", null)?.takeIf(::isGuide) ?: return null + return Place(url, prefs.getFloat("$game.scroll", 0f)) + } + + fun savePlace(context: Context, game: String, url: String, scroll: Float) { + if (!isGuide(url)) return + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit() + .putString("$game.url", url).putFloat("$game.scroll", scroll.coerceIn(0f, 1f)).apply() + } + + fun clear(context: Context, game: String) { + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().remove("$game.url").remove("$game.scroll").apply() + } + + internal fun isGuide(url: String): Boolean = GUIDE_URL.matches(url) + + private fun text(html: String): String = Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY).toString().trim().replace(Regex("\\s+"), " ") + + private val LANGUAGES = mapOf( + "en" to "english", "de" to "german", "fr" to "french", "it" to "italian", "es" to "spanish", "pt" to "portuguese", + "ru" to "russian", "pl" to "polish", "ja" to "japanese", "ko" to "koreana", "tr" to "turkish", "uk" to "ukrainian", + "nl" to "dutch", "sv" to "swedish", "da" to "danish", "fi" to "finnish", "nb" to "norwegian", "no" to "norwegian", + "cs" to "czech", "hu" to "hungarian", "ro" to "romanian", "bg" to "bulgarian", "el" to "greek", "th" to "thai", + "vi" to "vietnamese", "id" to "indonesian", "in" to "indonesian", "ar" to "arabic", + ) + private const val PREFS = "steam_guides" + private val GUIDE_URL = Regex("https://steamcommunity\\.com/sharedfiles/filedetails/\\?id=\\d+(#[\\w-]*)?") + private val ID = Regex("""filedetails/\?id=(\d+)""") + private val TITLE = Regex("""class="workshopItemTitle">(.*?)""", RegexOption.DOT_MATCHES_ALL) + private val AUTHOR = Regex("""class="workshopItemAuthorName">(.*?)""", RegexOption.DOT_MATCHES_ALL) + private val SUMMARY = Regex("""class="workshopItemShortDesc">(.*?)""", RegexOption.DOT_MATCHES_ALL) + private val PREVIEW = Regex("""class="workshopItemPreviewImage" src="([^"]+)"""") + private val STARS = Regex("""/(\d)-star\.png""") +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamLocalConfig.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamLocalConfig.kt new file mode 100644 index 0000000000..ad6196d2ab --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamLocalConfig.kt @@ -0,0 +1,70 @@ +package com.droiddeck.launcher.session + +import com.droiddeck.launcher.frontend.AddedGames +import java.io.File + +object SteamLocalConfig { + class AppStats(val playtimeMinutes: Long, val lastPlayed: Long) + + fun appStats(steamRoot: File, appId: Int): AppStats? { + val config = AddedGames.accountConfig(steamRoot) ?: return null + val text = runCatching { File(config, "localconfig.vdf").readText() }.getOrNull() ?: return null + return appStats(text, appId) + } + + internal fun appStats(text: String, appId: Int): AppStats? { + val apps = blocks(text, "apps").firstNotNullOfOrNull { blocks(it, appId.toString(), topLevel = true).firstOrNull() } ?: return null + val minutes = PLAYTIME.find(apps)?.groupValues?.get(1)?.toLongOrNull() ?: 0L + val last = LAST_PLAYED.find(apps)?.groupValues?.get(1)?.toLongOrNull() ?: 0L + return AppStats(minutes, last) + } + + private fun blocks(text: String, key: String, topLevel: Boolean = false): List { + val out = mutableListOf() + val quoted = "\"$key\"" + var depth = 0 + var i = 0 + while (i < text.length) { + when (val c = text[i]) { + '{' -> depth++ + '}' -> depth-- + '"' -> { + val end = text.indexOf('"', i + 1).takeIf { it > 0 } ?: return out + if ((!topLevel || depth == 0) && text.regionMatches(i, quoted, 0, quoted.length) && end == i + quoted.length - 1) { + val open = text.indexOfFirst(end + 1) { !it.isWhitespace() } + if (open >= 0 && text[open] == '{') { + val close = matching(text, open) + if (close > open) out += text.substring(open + 1, close) + } + } + i = end + } + else -> if (c == '/' && text.startsWith("//", i)) i = text.indexOf('\n', i).takeIf { it > 0 } ?: text.length + } + i++ + } + return out + } + + private fun matching(text: String, open: Int): Int { + var depth = 0 + var i = open + while (i < text.length) { + when (text[i]) { + '{' -> depth++ + '}' -> if (--depth == 0) return i + '"' -> i = text.indexOf('"', i + 1).takeIf { it > 0 } ?: return -1 + } + i++ + } + return -1 + } + + private inline fun String.indexOfFirst(from: Int, predicate: (Char) -> Boolean): Int { + for (i in from until length) if (predicate(this[i])) return i + return -1 + } + + private val PLAYTIME = Regex(""""Playtime"\s*"(\d+)"""") + private val LAST_PLAYED = Regex(""""LastPlayed"\s*"(\d+)"""") +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt new file mode 100644 index 0000000000..4b08d0a3da --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt @@ -0,0 +1,385 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import com.droiddeck.launcher.agent.AgentGuest +import org.json.JSONArray +import org.json.JSONObject +import java.io.File + +// Steam renders the quick access menu only while it is open. While the app holds it, the menu is kept open with its +// browser view placed outside the Big Picture window, composition capped at "notification" so gamescope keeps the game +// focused, and gamepad focus on the main UI. The hold is a lease the app renews, so Steam recovers if the app goes away. +object SteamQam { + /** [mainPath] is Steam's main menu page, shown beside the quick access menu in the split layout. */ + data class Target(val port: Int, val path: String, val mainPath: String? = null) + + const val MAIN_MENU = 1 + const val QUICK_ACCESS = 2 + + /** Height in CSS pixels both menus are laid out at in the split layout, so they show at one scale. */ + const val SPLIT_CSS_HEIGHT = 480 + + /** Steam's own width for the main menu; quick access takes the rest of the panel. */ + const val MAIN_CSS_WIDTH = 240 + + /** Holds the parked main menu in place and spreads its item rows (not dividers) over the full height, at most 80 px each. */ + private const val MAIN_PARKED_CSS = + ".BasicUI > .Panel { transform: none !important; width: 100% !important; height: 100% !important; margin: 0 !important; } " + + ".BasicUI > .Panel > :has(> .Focusable) { flex: 1 1 0 !important; height: auto !important; max-height: 80px; } " + + ".BasicUI > .Panel > :has(> .Focusable) > .Panel { height: 100% !important; }" + const val LEASE_MS = 5_000 + private const val TAG = "SteamQam" + private const val EVAL_MS = 6_000L + + private val owners = java.util.concurrent.atomic.AtomicLong(0) + + /** A new panel's lease owner: later panels get larger numbers, also across app restarts. */ + fun newOwner(): Long = owners.updateAndGet { maxOf(it + 1, System.currentTimeMillis()) } + + /** + * Takes or renews the lease for [owner], or releases it. A live lease held by a newer panel is never taken back by an + * older one, so a late request from a panel being torn down cannot end its replacement's lease or change its layout. + */ + internal fun leaseScript(on: Boolean, owner: Long, aspect: Float = 0f, split: Boolean = false): String = + if (on) "if (!(g.__ddQamUntil > Date.now()) || !(g.__ddQamOwner > $owner)) { g.__ddQamOwner = $owner; g.__ddQamUntil = Date.now() + $LEASE_MS;" + + (if (aspect > 0f) " g.__ddQamAspect = $aspect;" else "") + " g.__ddQamSplit = $split; }" + else "if (g.__ddQamOwner === $owner) g.__ddQamUntil = 0;" + + /** + * [aspect] is the panel's width over height: the menu is laid out at that shape so every tab shows at one scale. With + * [split], Steam's main menu is kept rendered at its own width beside the quick access menu, which gets the rest. + */ + internal fun script(on: Boolean, aspect: Float = 0f, owner: Long = 0, split: Boolean = false): String = """(() => { + const g = globalThis, QAM = 2, MAIN = 1; + const W = SteamUIStore.WindowStore.SteamUIWindows[0]; + const m = W.MenuStore, c = W.m_CompositionStateStore; + const nav = W.m_FocusNavContext; + const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0"); + const held = () => g.__ddQamUntil > Date.now(); + const split = () => held() && g.__ddQamSplit === true; + // Steam's views carry no names: the main menu's is the one Steam focuses while the main menu is open. Until Steam + // has shown it, the main menu is opened once with its view parked like the quick access menu's. + const probing = () => g.__ddMainProbe > Date.now(); + const ours = () => held() && !g.__ddQamTop && (m.m_eOpenSideMenu === QAM || (probing() && m.m_eOpenSideMenu === MAIN)); + const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0; + const parkX = () => popup.m_popup.innerWidth + 64; + const mainSize = () => [$MAIN_CSS_WIDTH, $SPLIT_CSS_HEIGHT]; + const qamSplitSize = () => [Math.max(Math.round($SPLIT_CSS_HEIGHT * (g.__ddQamAspect > 0 ? g.__ddQamAspect : 1)) - $MAIN_CSS_WIDTH, 320), $SPLIT_CSS_HEIGHT]; + const size = (w, h) => split() ? qamSplitSize() : [width(h) || w, h]; + const mainView = () => views().find(v => v.__ddMain); + // Only the quick access view is parked: the one Steam focuses while quick access is open. Before Steam has + // focused it, any view but the main menu's and the header's web page (Store and other pages) may be it. + const headerView = () => W.m_HeaderStore?.m_currentBrowserAndBackstack?.m_browserView; + const isQam = (v) => !v.__ddMain && v !== headerView() && + (!!v.__ddQamView || !views().some(o => o.__ddQamView) || (probing() && m.m_eOpenSideMenu === MAIN)); + const mainParked = () => split() && (m.m_eOpenSideMenu !== MAIN || probing()); + const mainDoc = () => { + for (const s of SteamUIStore.m_GamepadNavigationManager?.m_rgGamepadInputSources || []) { + try { const d = s.m_targetWindow?.document; if (d?.title?.startsWith("MainMenu")) return d; } catch (e) {} + } + return null; + }; + // Steam slides the main menu out whenever it is not the open side menu; parked, it stays in place and fills its view. + const mainStyle = (on) => { + const d = mainDoc(); + let s = d?.getElementById("dd-main-split"); + if (!on) { s?.remove(); return; } + if (!d?.head) return; + if (!s) { s = d.createElement("style"); s.id = "dd-main-split"; d.head.appendChild(s); } + if (s.textContent !== "$MAIN_PARKED_CSS") s.textContent = "$MAIN_PARKED_CSS"; + }; + if (!c.__ddQam) { + c.__ddQam = c.ComputeOverallMinimumRequestedComposition; + m.__ddQam = m.OnMenuDeactivated; + m.OnMenuDeactivated = function (d) { if (d === QAM && held() && !g.__ddQamTop) return; return m.__ddQam.call(this, d); }; + } + if (c.__ddQamV !== 2) { + c.__ddQamV = 2; + // Only the menu's own overlay request is lowered: a dialog over the game still needs Steam to take input. + c.ComputeOverallMinimumRequestedComposition = function (...a) { + const v = c.__ddQam.apply(this, a); + if (v !== 2 || !ours()) return v; + m.IsSideMenuVisible = () => false; + m.IsSideMenuInteractable = () => false; + let without; + try { without = c.__ddQam.apply(this, a); } finally { delete m.IsSideMenuVisible; delete m.IsSideMenuInteractable; } + return without >= 2 ? v : 1; + }; + } + // Steam frosts its Store page while a side menu is open; a parked menu is not over it. + const inst = m.m_Instance; + if (inst?.SetStoreBrowserGlass && !inst.__ddQamGlass) { + inst.__ddQamGlass = inst.SetStoreBrowserGlass; + inst.SetStoreBrowserGlass = function (e) { return inst.__ddQamGlass.call(this, ours() ? 0 : e); }; + } + const glass = () => { + const on = !ours() && m.m_eOpenSideMenu !== 0; + if (g.__ddQamGlassOn === on) return; + g.__ddQamGlassOn = on; + inst?.SetStoreBrowserGlass?.(m.m_eOpenSideMenu); + }; + const views = () => popup?.m_rgChildBrowserViews || []; + const backdrop = (hide) => { + const doc = popup?.m_popup?.document; + if (!doc) return; + for (const e of doc.querySelectorAll("div")) { + if (e.dataset.ddQam) { if (!hide) { e.style.removeProperty("visibility"); delete e.dataset.ddQam; } continue; } + if (!hide) continue; + const s = getComputedStyle(e), r = e.getBoundingClientRect(), v = doc.defaultView; + if (s.backdropFilter && s.backdropFilter !== "none" && r.width >= v.innerWidth - 2 && r.height >= v.innerHeight - 2) { + e.dataset.ddQam = "1"; + e.style.setProperty("visibility", "hidden", "important"); + } + } + }; + const keep = () => { + for (const v of views()) { + if (!v.__ddQam) v.__ddQam = v.SetBounds; + if (v.__ddQamW === 4) continue; + v.__ddQamW = 4; + v.__ddQamVis = v.__ddQamVis || v.SetVisible; + v.__ddQamFocus = v.__ddQamFocus || v.SetFocus; + v.SetBounds = function (x, y, w, h, ...r) { + if (v.__ddMain && mainParked()) { + if (w > 0) v.__ddMainAsked = [x, y, w, h]; + [w, h] = mainSize(); + v.__ddMainOn = true; v.__ddMainW = w; v.__ddMainH = h; + return v.__ddQam.call(this, parkX(), 0, w, h, ...r); + } + if (v.__ddMain && w > 0) mainStyle(false); + v.__ddAsked = [x, y, w, h]; + if (w > 0 && ours() && isQam(v)) { x = parkX(); [w, h] = size(w, h); } + v.__ddAt = x; + v.__ddW = w; + v.__ddH = h; + return v.__ddQam.call(this, x, y, w, h, ...r); + }; + v.SetVisible = function (on, ...r) { + return v.__ddQamVis.call(this, on || (!!v.__ddMain && mainParked()), ...r); + }; + v.SetFocus = function (on, ...r) { + if (on && m.m_eOpenSideMenu === MAIN && v !== headerView()) { + for (const o of views()) if (o !== v) delete o.__ddMain; + v.__ddMain = true; + delete v.__ddQamView; + } + if (on && m.m_eOpenSideMenu === QAM && !v.__ddMain && v !== headerView()) { + for (const o of views()) if (o !== v) delete o.__ddQamView; + v.__ddQamView = true; + } + return v.__ddQamFocus.call(this, on, ...r); + }; + } + if (g.__ddMainProbe && !probing()) { g.__ddMainProbe = 0; g.__ddMainProbed = true; } + if (probing() && mainView()) { g.__ddMainProbe = 0; g.__ddMainProbed = true; } + const mv = mainView(); + if (mv && !probing()) { + if (mainParked()) { + const [w, h] = mainSize(); + if (!mv.__ddMainOn || mv.__ddMainW !== w || mv.__ddMainH !== h) { + mv.__ddQam.call(mv, parkX(), 0, w, h); + mv.__ddQamVis.call(mv, true); + mv.__ddMainOn = true; mv.__ddMainW = w; mv.__ddMainH = h; + } + } else if (mv.__ddMainOn) { + mv.__ddMainOn = false; + if (m.m_eOpenSideMenu !== MAIN) { mv.__ddQamVis.call(mv, false); mv.__ddQam.call(mv, 0, 0, 0, 0); } + else if (mv.__ddMainAsked) mv.__ddQam.call(mv, ...mv.__ddMainAsked); + } + } + mainStyle(!!mv && mainParked() && !probing()); + glass(); + if (!held()) { + const parked = !g.__ddQamTop; + g.__ddQamTop = false; + g.__ddQamPress = undefined; + if (!g.__ddQamOn) return; + g.__ddQamOn = false; + backdrop(false); + if (parked && m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); + c.EnsureCorrectComposition?.(); + return; + } + // Steam sends the pad to an open side menu, so a dialog over the game would get no input: step aside until it closes. + const dialog = nav?.m_rgGamepadNavigationTrees?.some(t => t.m_ID?.startsWith("ModalDialogOverlay") && t.m_Root?.m_element?.isConnected); + if (dialog && !g.__ddQamTop) { + g.__ddQamPress = W.m_flLastQuickAccessPressMS || 0; + if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); + if (g.__ddQamOn) { g.__ddQamOn = false; backdrop(false); c.EnsureCorrectComposition?.(); } + return; + } + // The Quick Access button shows the menu on the top screen as usual; closing it there parks it again. + const press = W.m_flLastQuickAccessPressMS || 0; + if (g.__ddQamPress === undefined) g.__ddQamPress = press; + if (press !== g.__ddQamPress) { + g.__ddQamPress = press; + g.__ddQamTop = !g.__ddQamTop; + if (!g.__ddQamTop) { if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); return; } + backdrop(false); + if (m.m_eOpenSideMenu !== QAM) m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined); + for (const v of views()) if (v.__ddAsked?.[2] > 0) { v.__ddAt = v.__ddAsked[0]; v.__ddW = v.__ddAsked[2]; v.__ddQam.call(v, ...v.__ddAsked); } + c.EnsureCorrectComposition?.(); + return; + } + if (g.__ddQamTop) { + if (m.m_eOpenSideMenu === QAM) { + if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab; + return; + } + g.__ddQamTop = false; + } + // Each Split activation gets a fresh probe budget, and a spent one refills after a backoff, so a Steam that was + // still loading does not leave the main menu undiscovered for good. + if (split() !== !!g.__ddQamSplitOn) { g.__ddQamSplitOn = split(); if (split()) g.__ddMainProbes = 0; } + if (split() && !mv) { + if (probing()) return; + if ((g.__ddMainProbes || 0) >= 3 && Date.now() - (g.__ddMainProbeLast || 0) > 30000) g.__ddMainProbes = 0; + if ((g.__ddMainProbes || 0) < 3 && m.m_eOpenSideMenu !== MAIN) { + g.__ddMainProbes = (g.__ddMainProbes || 0) + 1; + g.__ddMainProbeLast = Date.now(); + g.__ddMainProbe = Date.now() + 1500; + m.OpenMainMenu(); + c.EnsureCorrectComposition?.(); + return; + } + } + if (g.__ddMainProbed) { + g.__ddMainProbed = false; + if (m.m_eOpenSideMenu === MAIN) m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined); + } + const decky = !!g.DeckyPluginLoader?.tabsHook?.qamBrowserViewPatch; + // Decky hooks the menu after Steam starts; the menu has to unmount for its tab to appear, so reopen on the next tick. + if (m.m_eOpenSideMenu === QAM && decky && !g.__ddQamDecky) { g.__ddQamDecky = true; m.CloseSideMenus(); return; } + if (m.m_eOpenSideMenu === 0) { + m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined); + g.__ddQamDecky = decky; + c.EnsureCorrectComposition?.(); + } + if (m.m_eOpenSideMenu !== QAM) return; + if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab; + if (!g.__ddQamOn) { g.__ddQamOn = true; c.EnsureCorrectComposition?.(); } + for (const v of views()) { + if (v.__ddMain) continue; + if (!isQam(v)) { + // A view parked before the quick access view was known goes back where Steam asked for it. + const a = v.__ddAsked; + if (a?.[2] > 0 && v.__ddAt >= popup.m_popup.innerWidth) { v.__ddQam.call(v, ...a); v.__ddAt = a[0]; v.__ddW = a[2]; v.__ddH = a[3]; } + continue; + } + if (!v.__ddAsked) { + const b = v.GetBounds?.(); + if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; v.__ddW = b.width; v.__ddH = b.height; } + } + const a = v.__ddAsked; + const [w, h] = a?.[2] > 0 ? size(a[2], a[3]) : [0, 0]; + if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || v.__ddW !== w || v.__ddH !== h)) v.SetBounds(...a); + } + const main = nav?.m_rgGamepadNavigationTrees?.find(t => t.m_ID === "GamepadUI_Full_Root"); + if (main && /^(QuickAccess|MainMenu)/.test(nav.m_LastActiveNavTree?.m_ID ?? "")) nav.SetActiveNavTree(main); + backdrop(true); + }; + ${leaseScript(on, owner, aspect, split)} + keep(); + if (held() && !g.__ddQamTimer) { + g.__ddQamTimer = setInterval(() => { + keep(); + if (!held() && !g.__ddQamOn) { clearInterval(g.__ddQamTimer); g.__ddQamTimer = 0; } + }, 250); + } + return JSON.stringify([m.m_eOpenSideMenu, g.__ddQamTop ? 1 : 0]); + })()""" + + /** [open] is Steam's open side menu; [top] is true while the menu is shown on the top screen. */ + data class Hold(val open: Int, val top: Boolean) + + fun hold(context: Context, aspect: Float, owner: Long, split: Boolean = false): Hold? = + eval(context, script(true, aspect, owner, split))?.let(::parseHold) + + internal fun parseHold(text: String): Hold? = runCatching { + val a = JSONArray(text) + Hold(a.getInt(0), a.getInt(1) == 1) + }.getOrNull() + + fun release(context: Context, relayPort: Int, owner: Long) { + eval(context, script(false, owner = owner)) + stopRelay(context, relayPort) + } + + fun stopRelay(context: Context, relayPort: Int) { + if (relayPort > 0) helper(context, "stop", relayPort.toString()) + } + + /** Starts the guest relay to Steam's DevTools and finds the menu's page; the relay is stopped again when there is none. */ + fun target(context: Context): Target? = runCatching { + val devtools = File(AgentGuest.dir(context), "cdp-port").readText().trim().toInt() + val (relay, secret) = parseRelay(helper(context, "start", devtools.toString())) ?: return null + val found = runCatching { + parseTarget(relay, get(relay, "/$secret/json"))?.let { t -> t.copy(path = "/$secret${t.path}", mainPath = t.mainPath?.let { "/$secret$it" }) } + } + if (found.getOrNull() == null) helper(context, "stop", relay.toString()) + found.getOrThrow() + }.onFailure { android.util.Log.e(TAG, "no quick access target: $it") }.getOrNull() + + internal fun parseRelay(text: String?): Pair? { + val parts = text?.trim()?.split(' ') ?: return null + val port = parts.getOrNull(0)?.toIntOrNull() ?: return null + val secret = parts.getOrNull(1)?.takeIf { it.matches(Regex("[0-9a-f]{16,64}")) } ?: return null + return port to secret + } + + private fun helper(context: Context, vararg args: String): String? = runCatching { + val request = JSONObject().put("kind", "exec").put("argv", JSONArray(listOf("droiddeck-qam-relay") + args)).put("timeout", 5.0) + val answer = AgentGuest.call(context, request, 8_000, trusted = true) + if (answer.optInt("exitCode", -1) == 0) answer.optJSONObject("stdout")?.optString("text") ?: answer.optString("stdout") else null + }.getOrNull() + + private fun get(port: Int, path: String): String = java.net.Socket().use { s -> + s.connect(java.net.InetSocketAddress("127.0.0.1", port), 2_000) + s.soTimeout = 3_000 + s.getOutputStream().apply { + write("GET $path HTTP/1.1\r\nHost: 127.0.0.1:$port\r\nAccept: */*\r\nConnection: close\r\n\r\n".toByteArray()) + flush() + } + httpBody(s.getInputStream()) + } + + /** Reads one response, by its Content-Length when it has one: DevTools does not always close the connection. */ + internal fun httpBody(input: java.io.InputStream): String { + val head = StringBuilder() + while (!head.endsWith("\r\n\r\n")) { + val b = input.read() + check(b >= 0 && head.length < 16_384) { "devtools answered ${head.take(80)}" } + head.append(b.toChar()) + } + check(head.startsWith("HTTP/1.1 200")) { "devtools answered ${head.take(80)}" } + val length = Regex("(?im)^content-length:\\s*(\\d+)").find(head)?.groupValues?.get(1)?.toInt() + val body = if (length == null) input.readBytes() else ByteArray(length).also { buf -> + var read = 0 + while (read < length) { + val n = input.read(buf, read, length - read) + check(n > 0) { "devtools closed after $read of $length bytes" } + read += n + } + } + return body.toString(Charsets.UTF_8) + } + + internal fun parseTarget(port: Int, json: String): Target? { + val list = JSONArray(json) + fun page(prefix: String): String? { + for (i in 0 until list.length()) { + val t = list.optJSONObject(i) ?: continue + if (!t.optString("title").startsWith(prefix)) continue + val ws = t.optString("webSocketDebuggerUrl") + Regex("^ws://[^/]+(/devtools/page/[A-Za-z0-9-]+)$").find(ws)?.groupValues?.get(1)?.let { return it } + } + return null + } + return page("QuickAccess")?.let { Target(port, it, page("MainMenu")) } + } + + private fun eval(context: Context, expression: String): String? = runCatching { + val answer = AgentGuest.steamEval(context, expression, EVAL_MS) + if (answer.optBoolean("ok")) answer.opt("value")?.takeIf { it != JSONObject.NULL }?.toString() else null + }.getOrNull() +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt index b309bca43b..207a9921e6 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/WinComponents.kt @@ -105,14 +105,9 @@ object WinComponents { const val VCREDIST_ARM64 = "vcredist2022_arm64" internal fun builtInArm64Runtime(): Component { - fun value(view: String, name: String, type: String, data: String) = Step("set_register_key", JSONObject() - .put("action", "set_register_key").put("key", "HKLM\\Software\\${view}Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\arm64") - .put("value", name).put("type", type).put("data", data)) - val steps = listOf("", "Wow6432Node\\").flatMap { view -> - listOf(value(view, "Installed", "REG_DWORD", "1"), value(view, "Major", "REG_DWORD", "14"), value(view, "Minor", "REG_DWORD", "44"), - value(view, "Bld", "REG_DWORD", "35211"), value(view, "Rbld", "REG_DWORD", "0"), value(view, "Version", "REG_SZ", "v14.44.35211.00")) - } - return Component(VCREDIST_ARM64, "Microsoft Visual C++ 2015-2022 ARM64 runtime 14.44.35211 (registry entries only)", "Microsoft", "ready", emptyList(), steps) + val install = Step("install_exe", JSONObject().put("action", "install_exe").put("file_name", "VC_redist.arm64.exe") + .put("url", "https://aka.ms/vs/17/release/vc_redist.arm64.exe")) + return Component(VCREDIST_ARM64, "Microsoft Visual C++ 2015-2022 Redistributable (arm64)", "Microsoft", "ready", emptyList(), listOf(install), revision = 2) } private fun parse(body: String): List? { diff --git a/app/src/main/java/com/droiddeck/launcher/session/XboxBackCompatComponents.kt b/app/src/main/java/com/droiddeck/launcher/session/XboxBackCompatComponents.kt new file mode 100644 index 0000000000..e547cd8963 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/XboxBackCompatComponents.kt @@ -0,0 +1,78 @@ +package com.droiddeck.launcher.session + +import android.content.Context +import android.util.Log +import com.droiddeck.launcher.gpu.GpuInfo +import com.droiddeck.launcher.stores.Store +import com.droiddeck.launcher.stores.StoreGameSidecar +import com.droiddeck.launcher.stores.StoreInstallRoot +import com.droiddeck.launcher.stores.xbox.XboxManifest + +/** + * Microsoft's original Xbox releases for PC run its emulator, which needs FEX and VKD3D-Proton builds with fixes of + * their own (each off unless droiddeck-game-env turns it on for these games) and a newer DXVK than some Protons carry. + * Each installed one gets them as its game components. A component the player chose for the game is never replaced; + * one set here follows this list, so a newer build replaces it, and one the player cleared stays cleared. + */ +internal object XboxBackCompatComponents { + private const val TAG = "XboxBackCompat" + private const val PREFS = "xbox-backcompat-components" + + internal data class Wanted(val comp: String, val file: String, val release: String) + + internal fun wanted(family: GpuInfo.Family?): List = listOf( + Wanted("fex", "FEXCore-2611.1-xbox-bionic.wcp", ComponentsManager.DD_XBOX), + Wanted("vkd3d", "vkd3d-proton-arm64ec-3.1-xbox-linux.wcp", "Vkd3d-proton-Linux"), + Wanted("dxvk", if (family == GpuInfo.Family.A6XX) "dxvk-gplasync-3.2-a6xx-1-linux.wcp" else "dxvk-gplasync-3.2-1-linux.wcp", + "Dxvk-gplasync-Linux"), + ) + + /** The file to set for one component of a game, or null to leave it as it is. */ + internal fun decide(current: String?, assigned: String?, wanted: String): String? = when { + current == null && assigned == null -> wanted + current != null && current == assigned && current != wanted -> wanted + else -> null + } + + internal class Game(val scope: String, val title: String) + + internal fun installed(context: Context): List = StoreInstallRoot.gameFolders(context).mapNotNull { folder -> + val sidecar = StoreGameSidecar.read(folder)?.takeIf { it.store == Store.XBOX && it.isInstalled } ?: return@mapNotNull null + if (!XboxManifest.backCompat(folder)) return@mapNotNull null + val appId = SessionPrefs.storedAddedGameAppId(context, folder.path) ?: return@mapNotNull null + Game(appId.toString(), sidecar.title) + } + + fun ensure(context: Context): String? { + val games = installed(context) + if (games.isEmpty()) return null + val marks = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE) + val wanted = wanted(runCatching { GpuInfo.detect().family }.getOrNull()) + val lines = mutableListOf() + for (game in games) { + val current = ComponentsManager.gameComponents(context, game.scope) + for (w in wanted) { + val key = "${game.scope}/${w.comp}" + val file = decide(current[w.comp], marks.getString(key, null), w.file) ?: continue + val label = ComponentsManager.LABEL[w.comp] + runCatching { + ComponentsManager.assignGameComponent(context, game.scope, w.comp, file, w.release, expected = current[w.comp]) { + marks.edit().putString(key, file).apply() + } + } + .onSuccess { result -> + lines += when (result) { + ComponentsManager.Assigned.SET -> "${game.title}: $label ${file.removeSuffix(".wcp")}" + ComponentsManager.Assigned.NOT_LISTED -> "${game.title}: $file is not listed; $label unchanged" + ComponentsManager.Assigned.CHANGED -> "${game.title}: $label was chosen during the download; kept" + } + } + .onFailure { e -> + Log.w(TAG, "${game.title}: $file", e) + lines += "${game.title}: $label unchanged (${e.message ?: e.javaClass.simpleName})" + } + } + } + return lines.joinToString("; ").ifEmpty { null } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrGesture.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrGesture.kt new file mode 100644 index 0000000000..cbd66f1964 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrGesture.kt @@ -0,0 +1,68 @@ +package com.droiddeck.launcher.session.xr + +/** + * The menu gesture: both controllers held together. It arms when the two aim points come within + * [ARM_METRES], cancels once they part beyond [CANCEL_METRES], and fires after [HOLD_MS] held. + * It needs both controllers apart again before it can arm a second time. + */ +internal class XrGesture { + enum class Phase { IDLE, ARMING, FIRED } + + var phase = Phase.IDLE + private set + var progress = 0f + private set + var midpoint = Vec3.ZERO + private set + private var startedMs = 0L + private var needsRelease = false + + /** Returns true on the frame the gesture completes. */ + fun update(left: XrHand, right: XrHand, nowMs: Long): Boolean { + if (!left.active || !right.active) { + reset(release = false) + return false + } + val a = left.aim.position + val b = right.aim.position + val distance = (a - b).length + midpoint = Vec3.lerp(a, b, 0.5f) + if (needsRelease) { + if (distance > CANCEL_METRES) needsRelease = false + phase = Phase.IDLE + progress = 0f + return false + } + when (phase) { + Phase.IDLE, Phase.FIRED -> if (distance < ARM_METRES) { + phase = Phase.ARMING + startedMs = nowMs + progress = 0f + } + Phase.ARMING -> if (distance > CANCEL_METRES) { + phase = Phase.IDLE + progress = 0f + } else { + progress = ((nowMs - startedMs).toFloat() / HOLD_MS).coerceIn(0f, 1f) + if (progress >= 1f) { + phase = Phase.FIRED + needsRelease = true + return true + } + } + } + return false + } + + fun reset(release: Boolean) { + phase = Phase.IDLE + progress = 0f + if (release) needsRelease = true + } + + companion object { + const val ARM_METRES = 0.09f + const val CANCEL_METRES = 0.14f + const val HOLD_MS = 1500L + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrHost.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrHost.kt new file mode 100644 index 0000000000..48424cccbf --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrHost.kt @@ -0,0 +1,160 @@ +package com.droiddeck.launcher.session.xr + +import java.nio.ByteBuffer +import java.nio.ByteOrder + +/** + * Typed access to the two buffers quest_xr.cpp shares each frame (app/src/main/cpp/questxr/xr_host.h). + * The offsets here must match that header. + */ +internal object XrHostLayout { + const val VERSION = 1 + const val LAYERS = 6 + const val STATE_SIZE = 288 + const val CONTROL_SIZE = 552 + const val POSE_SIZE = 32 + const val HAND_SIZE = 96 + const val STATE_HEAD = 32 + const val STATE_HANDS = 64 + const val HAND_GRIP = 0 + const val HAND_AIM = 32 + const val HAND_TRIGGER = 64 + const val HAND_SQUEEZE = 68 + const val HAND_STICK = 72 + const val HAND_BUTTONS = 80 + const val HAND_ACTIVE = 84 + const val CONTROL_HANDS = 8 + const val HAND_CONTROL_SIZE = 40 + const val HAND_CONTROL_MASK = 0 + const val HAND_CONTROL_LASER = 4 + const val HAND_CONTROL_HAPTIC = 8 + const val CONTROL_ORB = 88 + const val CONTROL_LAYERS = 136 + const val LAYER_SIZE = 64 + + const val FLAG_SURFACE_SWAPCHAIN = 1 + const val FLAG_FOCUSED = 2 + const val MASK_INPUT = 1 + const val LAYER_ALPHA = 1 + const val LAYER_HEAD_LOCKED = 2 + + const val SECONDARY_CLICK = 1 shl 2 +} + +internal class XrHand( + val grip: Pose, + val aim: Pose, + val trigger: Float, + val squeeze: Float, + val stickX: Float, + val stickY: Float, + val buttons: Int, + val active: Boolean, +) { + val secondary: Boolean get() = buttons and XrHostLayout.SECONDARY_CLICK != 0 + + companion object { + val IDLE = XrHand(Pose(), Pose(), 0f, 0f, 0f, 0f, 0, false) + } +} + +internal class XrFrame(val flags: Int, val frame: Long, val displayTimeNs: Long, val head: Pose, val hands: List) { + val focused: Boolean get() = flags and XrHostLayout.FLAG_FOCUSED != 0 + val surfaces: Boolean get() = flags and XrHostLayout.FLAG_SURFACE_SWAPCHAIN != 0 +} + +internal class XrHaptic(val durationMs: Int, val amplitude: Float, val frequency: Float = 0f) + +internal class XrLayerOut( + val id: Int, + val pose: Pose, + val width: Float, + val height: Float, + val order: Int, + val alpha: Boolean = true, +) + +internal class XrControlOut { + val masks = BooleanArray(2) + val lasers = FloatArray(2) + val haptics = arrayOfNulls(2) + var orb: Orb? = null + val layers = mutableListOf() + + class Orb(val position: Vec3, val radius: Float, val progress: Float, val burst: Float) +} + +internal class XrHost(state: ByteBuffer, control: ByteBuffer) { + private val state = state.order(ByteOrder.nativeOrder()) + private val control = control.order(ByteOrder.nativeOrder()) + private val hapticIds = LongArray(2) + + init { + require(state.capacity() >= XrHostLayout.STATE_SIZE && control.capacity() >= XrHostLayout.CONTROL_SIZE) { "XR host buffers too small" } + } + + fun read(): XrFrame = readFrame(state) + + fun write(out: XrControlOut) = writeControl(control, out, hapticIds) + + companion object { + fun readPose(b: ByteBuffer, at: Int) = Pose( + Quat(b.getFloat(at), b.getFloat(at + 4), b.getFloat(at + 8), b.getFloat(at + 12)), + Vec3(b.getFloat(at + 16), b.getFloat(at + 20), b.getFloat(at + 24)), + ) + + fun writePose(b: ByteBuffer, at: Int, pose: Pose) { + b.putFloat(at, pose.orientation.x); b.putFloat(at + 4, pose.orientation.y) + b.putFloat(at + 8, pose.orientation.z); b.putFloat(at + 12, pose.orientation.w) + b.putFloat(at + 16, pose.position.x); b.putFloat(at + 20, pose.position.y); b.putFloat(at + 24, pose.position.z) + b.putInt(at + 28, 0) + } + + fun readFrame(b: ByteBuffer): XrFrame { + val hands = (0 until 2).map { hand -> + val at = XrHostLayout.STATE_HANDS + hand * XrHostLayout.HAND_SIZE + XrHand( + readPose(b, at + XrHostLayout.HAND_GRIP), readPose(b, at + XrHostLayout.HAND_AIM), + b.getFloat(at + XrHostLayout.HAND_TRIGGER), b.getFloat(at + XrHostLayout.HAND_SQUEEZE), + b.getFloat(at + XrHostLayout.HAND_STICK), b.getFloat(at + XrHostLayout.HAND_STICK + 4), + b.getInt(at + XrHostLayout.HAND_BUTTONS), b.getInt(at + XrHostLayout.HAND_ACTIVE) != 0, + ) + } + return XrFrame(b.getInt(8), b.getLong(16), b.getLong(24), readPose(b, XrHostLayout.STATE_HEAD), hands) + } + + fun writeControl(b: ByteBuffer, out: XrControlOut, hapticIds: LongArray) { + for (i in 0 until XrHostLayout.CONTROL_SIZE step 4) b.putInt(i, 0) + b.putInt(0, XrHostLayout.VERSION) + for (hand in 0 until 2) { + val at = XrHostLayout.CONTROL_HANDS + hand * XrHostLayout.HAND_CONTROL_SIZE + b.putInt(at + XrHostLayout.HAND_CONTROL_MASK, if (out.masks[hand]) XrHostLayout.MASK_INPUT else 0) + b.putFloat(at + XrHostLayout.HAND_CONTROL_LASER, out.lasers[hand]) + out.haptics[hand]?.let { hapticIds[hand]++ } + val haptic = at + XrHostLayout.HAND_CONTROL_HAPTIC + b.putLong(haptic, hapticIds[hand]) + out.haptics[hand]?.let { + b.putLong(haptic + 8, it.durationMs * 1_000_000L) + b.putFloat(haptic + 16, it.amplitude) + b.putFloat(haptic + 20, it.frequency) + } + } + out.orb?.let { orb -> + val at = XrHostLayout.CONTROL_ORB + b.putInt(at, 1) + b.putFloat(at + 4, orb.progress); b.putFloat(at + 8, orb.burst); b.putFloat(at + 12, orb.radius) + writePose(b, at + 16, Pose(position = orb.position)) + } + out.layers.take(XrHostLayout.LAYERS).forEachIndexed { index, layer -> + val at = XrHostLayout.CONTROL_LAYERS + index * XrHostLayout.LAYER_SIZE + b.putInt(at, layer.id) + b.putInt(at + 4, 1) + b.putInt(at + 8, if (layer.alpha) XrHostLayout.LAYER_ALPHA else 0) + b.putInt(at + 12, layer.order) + writePose(b, at + 16, layer.pose) + b.putFloat(at + 48, layer.width); b.putFloat(at + 52, layer.height) + } + for (index in out.layers.size until XrHostLayout.LAYERS) b.putInt(XrHostLayout.CONTROL_LAYERS + index * XrHostLayout.LAYER_SIZE, -1) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrInteraction.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrInteraction.kt new file mode 100644 index 0000000000..d045a87663 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrInteraction.kt @@ -0,0 +1,303 @@ +package com.droiddeck.launcher.session.xr + +import kotlin.math.PI +import kotlin.math.abs + +/** + * [barButton]: the grab bar has a button at its left end; the menu has its own close button instead. + * [tilt]: how far the panel leans back from upright, in radians, as a keyboard lies on a desk. + */ +internal enum class XrPanelKind( + val key: String, val resizable: Boolean, val chrome: Boolean, val barButton: Boolean = false, val tilt: Float = 0f, +) { + MENU("menu", resizable = true, chrome = true), + PET_HEAD("pet_head", resizable = false, chrome = false), + PET_CHAT("pet_chat", resizable = true, chrome = true, barButton = true), + KEYBOARD("keyboard_desk", resizable = true, chrome = true, barButton = true, tilt = (PI / 4).toFloat()); + + /** Turned towards [head] about the vertical axis, then leant back by [tilt]. */ + fun orient(position: Vec3, head: Vec3): Quat = facing(position, head) * Quat.pitch(-tilt) +} + +/** Where a panel is and how big, in metres; [pixelWidth] and [pixelHeight] are its surface's size. */ +internal class XrPanelState(val kind: XrPanelKind, var pose: Pose, var width: Float, var height: Float) { + var pixelWidth = XrUnits.pixels(width) + var pixelHeight = XrUnits.pixels(height) + /** 0 while it opens or closes from [animationFrom], 1 when it is in place and takes input. */ + var scale = 1f + var animationFrom: Vec3? = null + + val shownPose: Pose get() = animationFrom?.let { Pose(pose.orientation, Vec3.lerp(it, pose.position, scale)) } ?: pose + val interactive: Boolean get() = scale >= 1f + + fun hit(ray: Pose): XrHit? = hitPlane(ray, bounded = true) + + /** Where [ray] meets this panel's plane; [bounded] limits it to the panel itself. */ + fun hitPlane(ray: Pose, bounded: Boolean, plane: Pose = pose, w: Float = width, h: Float = height): XrHit? { + val normal = plane.orientation.rotate(Vec3(0f, 0f, 1f)) + val direction = ray.forward + val denominator = direction dot normal + if (denominator > -1e-4f) return null + val distance = ((plane.position - ray.position) dot normal) / denominator + if (distance <= 0f) return null + val local = plane.toLocal(ray.position + direction * distance) + if (bounded && (abs(local.x) > w / 2f || abs(local.y) > h / 2f)) return null + return XrHit(this, local.x, local.y, distance) + } + + fun u(localX: Float) = (localX / width + 0.5f).coerceIn(0f, 1f) + fun v(localY: Float) = (0.5f - localY / height).coerceIn(0f, 1f) + fun pixelX(localX: Float) = u(localX) * pixelWidth + fun pixelY(localY: Float) = v(localY) * pixelHeight + + /** The grab bar runs along the bottom, as under Quest's own windows, with its button at the left end. */ + fun inBar(hit: XrHit) = kind.chrome && hit.y + 0.5f * height <= XrUnits.BAR_METRES + fun inBarButtons(hit: XrHit) = kind.barButton && inBar(hit) && hit.x + 0.5f * width <= XrUnits.BAR_BUTTONS_METRES + fun inResizeGrip(hit: XrHit) = kind.resizable && + 0.5f * width - hit.x <= XrUnits.GRIP_METRES && hit.y + 0.5f * height <= XrUnits.GRIP_METRES +} + +internal class XrHit(val panel: XrPanelState, val x: Float, val y: Float, val distance: Float) + +internal object XrUnits { + const val DP_PER_METRE = 900f + const val DENSITY = 2f + const val DPI = 320 + const val BAR_METRES = 52f / DP_PER_METRE + const val BAR_BUTTONS_DP = 150f + const val BAR_BUTTONS_METRES = BAR_BUTTONS_DP / DP_PER_METRE + const val GRIP_METRES = 0.05f + const val MIN_METRES = 0.3f + const val MAX_METRES = 1.6f + const val MIN_DISTANCE = 0.4f + const val MAX_DISTANCE = 3f + fun pixels(metres: Float) = (metres * DP_PER_METRE * DENSITY).toInt().coerceAtLeast(16) +} + +internal sealed class XrPointerEvent(val panel: XrPanelState) { + class Down(panel: XrPanelState, val x: Float, val y: Float, val hand: Int = 0) : XrPointerEvent(panel) + class Move(panel: XrPanelState, val x: Float, val y: Float, val hand: Int = 0) : XrPointerEvent(panel) + class Up(panel: XrPanelState, val x: Float, val y: Float, val hand: Int = 0) : XrPointerEvent(panel) + class Cancel(panel: XrPanelState, val hand: Int = 0) : XrPointerEvent(panel) + class Scroll(panel: XrPanelState, val x: Float, val y: Float, val amount: Float) : XrPointerEvent(panel) + class Back(panel: XrPanelState) : XrPointerEvent(panel) + class Click(panel: XrPanelState) : XrPointerEvent(panel) + class Resized(panel: XrPanelState) : XrPointerEvent(panel) + class Moved(panel: XrPanelState) : XrPointerEvent(panel) +} + +internal class XrInteractionOut { + val events = mutableListOf() + val masks = BooleanArray(2) + val lasers = FloatArray(2) + val ticks = BooleanArray(2) + /** Where each controller points on each panel, in its pixels, left hand first; panels with no entry show none. */ + val cursors = mutableMapOf>>() + + fun point(panel: XrPanelState, x: Float, y: Float) { + cursors.getOrPut(panel) { mutableListOf() } += x to y + } +} + +/** + * What the two controllers do to the panels each frame. A controller acts on a panel only while it + * points at one, or while it holds one it picked up, pressed or is resizing; only then is its input + * taken from the game. + */ +internal class XrInteraction { + private sealed class Hold { + object None : Hold() + class Press(val panel: XrPanelState, var x: Float, var y: Float) : Hold() + class Move(val panel: XrPanelState, var offset: Vec3, val byGrip: Boolean) : Hold() + class Resize(val panel: XrPanelState, val plane: Pose, val width: Float, val height: Float, val startX: Float, val startY: Float) : Hold() + class HeadPress(val panel: XrPanelState, val startX: Float, val startY: Float, val offset: Vec3) : Hold() + } + + private val holds = arrayOf(Hold.None, Hold.None) + private val trigger = BooleanArray(2) + private val grip = BooleanArray(2) + private val secondary = BooleanArray(2) + + fun holding(panel: XrPanelState) = holds.any { held(it) === panel } + + private fun held(hold: Hold): XrPanelState? = when (hold) { + is Hold.Press -> hold.panel + is Hold.Move -> hold.panel + is Hold.Resize -> hold.panel + is Hold.HeadPress -> hold.panel + Hold.None -> null + } + + /** Lets go of everything, as when the immersive view goes. A button still held counts only once let go and pressed again. */ + fun reset() { + holds.fill(Hold.None) + trigger.fill(true) + grip.fill(true) + secondary.fill(true) + } + + /** Cancels a press and ends a move or resize where it is, as when the headset loses focus; then [reset]. */ + fun cancel(out: XrInteractionOut) { + for ((hand, hold) in holds.withIndex()) when (hold) { + is Hold.Press -> out.events += XrPointerEvent.Cancel(hold.panel, hand) + is Hold.Move -> out.events += XrPointerEvent.Moved(hold.panel) + is Hold.Resize -> out.events += XrPointerEvent.Resized(hold.panel) + else -> Unit + } + reset() + } + + /** Lets go of [panel], as when it closes. */ + fun release(panel: XrPanelState, out: XrInteractionOut) { + for (hand in 0..1) if (held(holds[hand]) === panel) { + if (holds[hand] is Hold.Press) out.events += XrPointerEvent.Cancel(panel, hand) + holds[hand] = Hold.None + } + } + + fun update(head: Pose, hands: List, panels: List, dtSeconds: Float): XrInteractionOut { + val out = XrInteractionOut() + for (hand in 0..1) handFrame(hand, head, hands[hand], panels.filter { it.interactive }, dtSeconds, out) + return out + } + + private fun handFrame(index: Int, head: Pose, hand: XrHand, panels: List, dt: Float, out: XrInteractionOut) { + val wasTrigger = trigger[index] + val wasGrip = grip[index] + val wasSecondary = secondary[index] + trigger[index] = if (wasTrigger) hand.trigger > 0.4f else hand.trigger > 0.6f + grip[index] = if (wasGrip) hand.squeeze > 0.5f else hand.squeeze > 0.7f + secondary[index] = hand.secondary + val triggerDown = trigger[index] && !wasTrigger + val triggerUp = !trigger[index] && wasTrigger + val gripDown = grip[index] && !wasGrip + val secondaryDown = secondary[index] && !wasSecondary + val hold = holds[index] + if (!hand.active) { + if (hold is Hold.Press) out.events += XrPointerEvent.Cancel(hold.panel, index) + if (hold is Hold.Move) out.events += XrPointerEvent.Moved(hold.panel) + if (hold is Hold.Resize) out.events += XrPointerEvent.Resized(hold.panel) + holds[index] = Hold.None + return + } + val ray = hand.aim + when (hold) { + is Hold.Move -> { + val panel = hold.panel + if (abs(hand.stickY) > 0.2f) { + val length = hold.offset.length + val wanted = (length * (1f + hand.stickY * 1.2f * dt)).coerceIn(XrUnits.MIN_DISTANCE, XrUnits.MAX_DISTANCE) + hold.offset = hold.offset.normalized() * wanted + } + val position = ray.toWorld(hold.offset) + panel.pose = Pose(panel.kind.orient(position, head.position), position) + out.masks[index] = true + out.lasers[index] = hold.offset.length + val released = if (hold.byGrip) !grip[index] else !trigger[index] + if (released) { + holds[index] = Hold.None + out.events += XrPointerEvent.Moved(panel) + } + return + } + is Hold.Resize -> { + val panel = hold.panel + out.masks[index] = true + hold.panel.hitPlane(ray, bounded = false, plane = hold.plane, w = hold.width, h = hold.height)?.let { hit -> + val left = -hold.width / 2f + val top = hold.height / 2f + val width = (hold.width + hit.x - hold.startX).coerceIn(XrUnits.MIN_METRES, XrUnits.MAX_METRES) + val height = (hold.height + hold.startY - hit.y).coerceIn(XrUnits.MIN_METRES, XrUnits.MAX_METRES) + panel.width = width + panel.height = height + panel.pose = Pose(hold.plane.orientation, hold.plane.toWorld(Vec3(left + width / 2f, top - height / 2f, 0f))) + out.lasers[index] = hit.distance + } + if (!trigger[index]) { + holds[index] = Hold.None + out.events += XrPointerEvent.Resized(panel) + } + return + } + is Hold.Press -> { + val panel = hold.panel + out.masks[index] = true + val hit = panel.hitPlane(ray, bounded = false) + if (hit != null) { + val x = panel.pixelX(hit.x) + val y = panel.pixelY(hit.y) + if (x != hold.x || y != hold.y) out.events += XrPointerEvent.Move(panel, x, y, index) + hold.x = x; hold.y = y + out.lasers[index] = hit.distance + out.point(panel, x, y) + } + if (secondaryDown) out.events += XrPointerEvent.Back(panel) + if (triggerUp || !trigger[index]) { + out.events += if (hit != null) XrPointerEvent.Up(panel, hold.x, hold.y, index) else XrPointerEvent.Cancel(panel, index) + holds[index] = Hold.None + } + return + } + is Hold.HeadPress -> { + val panel = hold.panel + out.masks[index] = true + val hit = panel.hitPlane(ray, bounded = false) + if (hit != null) { + out.lasers[index] = hit.distance + val moved = Vec3(hit.x - hold.startX, hit.y - hold.startY, 0f).length + if (moved > HEAD_DRAG_METRES) { + holds[index] = Hold.Move(panel, hold.offset, byGrip = false) + val position = ray.toWorld(hold.offset) + panel.pose = Pose(panel.kind.orient(position, head.position), position) + return + } + } + if (!trigger[index]) { + holds[index] = Hold.None + if (panel.hit(ray) != null) out.events += XrPointerEvent.Click(panel) + } + return + } + Hold.None -> Unit + } + val hit = panels.mapNotNull { it.hit(ray) }.minByOrNull { it.distance } ?: return + val panel = hit.panel + out.masks[index] = true + out.lasers[index] = hit.distance + val x = panel.pixelX(hit.x) + val y = panel.pixelY(hit.y) + out.point(panel, x, y) + val other = holds[1 - index] + val heldByOther = held(other) === panel && other !is Hold.Press + when { + heldByOther -> Unit + gripDown -> { + holds[index] = Hold.Move(panel, ray.toLocal(panel.pose.position), byGrip = true) + out.ticks[index] = true + } + triggerDown && panel.kind == XrPanelKind.PET_HEAD -> + holds[index] = Hold.HeadPress(panel, hit.x, hit.y, ray.toLocal(panel.pose.position)) + triggerDown && panel.inResizeGrip(hit) -> { + holds[index] = Hold.Resize(panel, panel.pose, panel.width, panel.height, hit.x, hit.y) + out.ticks[index] = true + } + triggerDown && panel.inBar(hit) && !panel.inBarButtons(hit) -> { + holds[index] = Hold.Move(panel, ray.toLocal(panel.pose.position), byGrip = false) + out.ticks[index] = true + } + triggerDown -> { + holds[index] = Hold.Press(panel, x, y) + out.events += XrPointerEvent.Down(panel, x, y, index) + } + } + if (holds[index] === Hold.None) { + if (abs(hand.stickY) > 0.25f) out.events += XrPointerEvent.Scroll(panel, x, y, hand.stickY * SCROLL_PER_SECOND * dt) + if (secondaryDown) out.events += XrPointerEvent.Back(panel) + } + } + + companion object { + const val HEAD_DRAG_METRES = 0.02f + const val SCROLL_PER_SECOND = 12f + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrKeyboard.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrKeyboard.kt new file mode 100644 index 0000000000..275322d745 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrKeyboard.kt @@ -0,0 +1,283 @@ +package com.droiddeck.launcher.session.xr + +import android.view.KeyEvent +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.tween +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsPressedAsState +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.outlined.Backspace +import androidx.compose.material.icons.automirrored.outlined.KeyboardReturn +import androidx.compose.material.icons.outlined.KeyboardArrowUp +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.compositeOver +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.text.TextRange +import androidx.compose.ui.text.input.EditCommand +import androidx.compose.ui.text.input.ImeAction +import androidx.compose.ui.text.input.ImeOptions +import androidx.compose.ui.text.input.PlatformTextInputService +import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.input.PC_KEY_ROWS +import kotlinx.coroutines.delay +import com.droiddeck.launcher.ui.TypingRequest + +/** Sends text fields in the floating panels to [XrKeyboard], since the system keyboard cannot show in the immersive view. */ +internal class XrTextInput : PlatformTextInputService { + private var request: TypingRequest? = null + + override fun startInput( + value: TextFieldValue, imeOptions: ImeOptions, + onEditCommand: (List) -> Unit, onImeActionPerformed: (ImeAction) -> Unit, + ) { + val next = TypingRequest(value, imeOptions, { onEditCommand(TypingRequest.editsFor(it)) }, onImeActionPerformed) + request = next + XrPanels.startTyping(next) + } + + override fun stopInput() { + request?.let { XrPanels.stopTyping(it) } + request = null + } + + override fun showSoftwareKeyboard() { + request?.let { XrPanels.startTyping(it) } + } + + override fun hideSoftwareKeyboard() { + request?.let { XrPanels.stopTyping(it) } + } + + override fun updateState(oldValue: TextFieldValue?, newValue: TextFieldValue) { + request?.value = newValue + } +} + +internal object XrKeys { + private val letters = listOf("qwertyuiop", "asdfghjkl", "zxcvbnm") + private val symbols = listOf("1234567890", "@#&*-+=()", "!?:;'\"/,") + + fun rows(numbers: Boolean, shift: Boolean): List = + (if (numbers) symbols else letters).map { if (shift && !numbers) it.uppercase() else it } + + fun insert(value: TextFieldValue, text: String): TextFieldValue { + val start = minOf(value.selection.start, value.selection.end) + val end = maxOf(value.selection.start, value.selection.end) + val next = value.text.substring(0, start) + text + value.text.substring(end) + return TextFieldValue(next, TextRange(start + text.length)) + } + + fun backspace(value: TextFieldValue): TextFieldValue { + val start = minOf(value.selection.start, value.selection.end) + val end = maxOf(value.selection.start, value.selection.end) + if (start != end) return TextFieldValue(value.text.substring(0, start) + value.text.substring(end), TextRange(start)) + if (start == 0) return value + val cut = value.text.offsetByCodePoints(start, -1) + return TextFieldValue(value.text.substring(0, cut) + value.text.substring(start), TextRange(cut)) + } + + const val REPEAT_DELAY_MS = 450L + const val REPEAT_MS = 50L + + /** Return sends when the field asks for an action, and starts a new line otherwise. */ + fun returnSends(options: ImeOptions) = options.imeAction != ImeAction.Default && options.imeAction != ImeAction.None && + options.singleLine +} + +/** Where the laser keyboard's keys go: a text field in a panel, or the game. */ +internal interface XrKeyTarget { + fun type(text: String) + fun backspace() + fun enter() +} + +internal class XrFieldTarget(private val request: TypingRequest) : XrKeyTarget { + override fun type(text: String) = request.send(XrKeys.insert(request.value, text)) + override fun backspace() = request.send(XrKeys.backspace(request.value)) + override fun enter() = if (XrKeys.returnSends(request.imeOptions)) request.action() else type("\n") +} + +internal class XrGameTarget(private val host: XrMenuHost) : XrKeyTarget { + override fun type(text: String) = host.xrTypeText(text) + override fun backspace() = host.xrTapKey(KeyEvent.KEYCODE_DEL) + override fun enter() = host.xrTapKey(KeyEvent.KEYCODE_ENTER) +} + +/** + * DroidDeck's PC keyboard typing into a panel's text field: the keys that make a character type it, + * Backspace, Enter and Space edit, and Shift and Caps Lock pick the case. The rest have nothing to do there. + */ +internal class XrPcText(private val target: XrKeyTarget, private val timer: XrTimer = XrTimer.Main) { + private val keys = PC_KEY_ROWS.flatten() + .filter { it.labelRes == 0 && it.label.length == 1 && it.code !in ARROWS } + .associateBy { it.code } + private val shifts = mutableSetOf() + private var caps = false + private var stopRepeat: (() -> Unit)? = null + + fun key(code: Int, down: Boolean) { + if (code == LEFT_SHIFT || code == RIGHT_SHIFT) { + if (down) shifts += code else shifts -= code + return + } + if (!down && code != BACKSPACE) return + stopRepeat?.invoke() + stopRepeat = null + if (!down) return + val shifted = shifts.isNotEmpty() + when (code) { + BACKSPACE -> { + target.backspace() + stopRepeat = timer.after(XrKeys.REPEAT_DELAY_MS, ::repeatBackspace) + } + ENTER -> target.enter() + SPACE -> target.type(" ") + CAPS -> caps = !caps + else -> keys[code]?.let { key -> + target.type(when { + shifted && key.shifted != null -> key.shifted + key.label[0].isLetter() && (shifted xor caps) -> key.label.uppercase() + else -> key.label + }) + } + } + } + + private fun repeatBackspace() { + target.backspace() + stopRepeat = timer.after(XrKeys.REPEAT_MS, ::repeatBackspace) + } + + private companion object { + const val LEFT_SHIFT = 42 + const val RIGHT_SHIFT = 54 + const val BACKSPACE = 14 + const val ENTER = 28 + const val SPACE = 57 + const val CAPS = 58 + val ARROWS = setOf(103, 105, 106, 108) + } +} + +/** Runs an action later on the main thread; the function it returns cancels it. */ +internal fun interface XrTimer { + fun after(ms: Long, action: () -> Unit): () -> Unit + + companion object { + private val handler by lazy { android.os.Handler(android.os.Looper.getMainLooper()) } + val Main = XrTimer { ms, action -> + val runnable = Runnable(action) + handler.postDelayed(runnable, ms) + ({ handler.removeCallbacks(runnable) }) + } + } +} + +/** The Android-style text keyboard. */ +@Composable +internal fun XrKeyboard(target: XrKeyTarget) { + var shift by remember { mutableStateOf(false) } + var numbers by remember { mutableStateOf(false) } + fun type(text: String) { + target.type(text) + if (shift) shift = false + } + Column(Modifier.fillMaxSize().padding(8.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + XrKeys.rows(numbers, shift).forEachIndexed { index, row -> + Row(Modifier.fillMaxWidth().weight(1f), horizontalArrangement = Arrangement.spacedBy(6.dp)) { + if (index == 2) KeyIcon(Icons.Outlined.KeyboardArrowUp, stringResource(R.string.pckb_key_shift), active = shift, weight = 1.5f) { shift = !shift } + row.forEach { key -> Key(key.toString()) { type(key.toString()) } } + if (index == 2) KeyIcon(Icons.AutoMirrored.Outlined.Backspace, stringResource(R.string.pckb_key_backspace), weight = 1.5f, repeats = true) { target.backspace() } + } + } + Row(Modifier.fillMaxWidth().weight(1f), horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Key(if (numbers) "abc" else "?123", weight = 1.5f) { numbers = !numbers } + Key(",") { type(",") } + Key(" ", weight = 5f) { type(" ") } + Key(".") { type(".") } + KeyIcon(Icons.AutoMirrored.Outlined.KeyboardReturn, stringResource(R.string.pckb_key_enter), weight = 1.5f) { target.enter() } + } + } +} + +/** A key that lights while the laser is over it and dips while it is pressed; [repeats] keeps acting while held. */ +@Composable +private fun RowScope.KeyBox( + weight: Float, active: Boolean, onClick: () -> Unit, repeats: Boolean = false, content: @Composable (Color) -> Unit, +) { + val colors = MaterialTheme.colorScheme + val source = remember { MutableInteractionSource() } + val (pointedAt, pointed) = rememberXrPointed() + val hovered = pointed.value + val pressed by source.collectIsPressedAsState() + val action by rememberUpdatedState(onClick) + var repeated by remember { mutableStateOf(false) } + if (repeats) LaunchedEffect(pressed) { + if (!pressed) return@LaunchedEffect + repeated = false + delay(XrKeys.REPEAT_DELAY_MS) + repeated = true + while (true) { + action() + delay(XrKeys.REPEAT_MS) + } + } + val fill by animateColorAsState( + when { + pressed -> colors.primary + active -> colors.primary.copy(alpha = 0.8f) + hovered -> colors.onSurface.copy(alpha = 0.22f).compositeOver(colors.surfaceVariant) + else -> colors.surfaceVariant + }, tween(if (pressed) 40 else 140), label = "keyFill", + ) + val scale by animateFloatAsState(if (pressed) 0.9f else if (hovered) 1.05f else 1f, tween(if (pressed) 40 else 140), label = "keyScale") + Box( + Modifier.weight(weight).fillMaxHeight() + .then(pointedAt) + .graphicsLayer { scaleX = 1f + (scale - 1f) * size.height / size.width; scaleY = scale } + .clip(RoundedCornerShape(8.dp)).background(fill) + .border(if (hovered) 2.dp else 0.dp, if (hovered) colors.primary else Color.Transparent, RoundedCornerShape(8.dp)) + .clickable(interactionSource = source, indication = null) { if (repeated) repeated = false else onClick() }, + contentAlignment = Alignment.Center, + ) { content(if (pressed || active) colors.onPrimary else colors.onSurface) } +} + +@Composable +private fun RowScope.Key(label: String, weight: Float = 1f, onClick: () -> Unit) = + KeyBox(weight, active = false, onClick) { tint -> Text(label, color = tint, fontSize = 22.sp, maxLines = 1) } + +@Composable +private fun RowScope.KeyIcon(icon: ImageVector, label: String, active: Boolean = false, weight: Float = 1f, repeats: Boolean = false, onClick: () -> Unit) = + KeyBox(weight, active, onClick, repeats) { tint -> Icon(icon, label, tint = tint) } diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrMath.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrMath.kt new file mode 100644 index 0000000000..4f5072f142 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrMath.kt @@ -0,0 +1,61 @@ +package com.droiddeck.launcher.session.xr + +import kotlin.math.atan2 +import kotlin.math.cos +import kotlin.math.sin +import kotlin.math.sqrt + +internal data class Vec3(val x: Float, val y: Float, val z: Float) { + operator fun plus(o: Vec3) = Vec3(x + o.x, y + o.y, z + o.z) + operator fun minus(o: Vec3) = Vec3(x - o.x, y - o.y, z - o.z) + operator fun times(s: Float) = Vec3(x * s, y * s, z * s) + infix fun dot(o: Vec3) = x * o.x + y * o.y + z * o.z + infix fun cross(o: Vec3) = Vec3(y * o.z - z * o.y, z * o.x - x * o.z, x * o.y - y * o.x) + val length: Float get() = sqrt(this dot this) + fun normalized(): Vec3 = length.let { if (it > 1e-6f) this * (1f / it) else ZERO } + + companion object { + val ZERO = Vec3(0f, 0f, 0f) + val FORWARD = Vec3(0f, 0f, -1f) + val UP = Vec3(0f, 1f, 0f) + fun lerp(a: Vec3, b: Vec3, t: Float) = a + (b - a) * t + } +} + +internal data class Quat(val x: Float, val y: Float, val z: Float, val w: Float) { + fun rotate(v: Vec3): Vec3 { + val u = Vec3(x, y, z) + return u * (2f * (u dot v)) + v * (w * w - (u dot u)) + (u cross v) * (2f * w) + } + + fun conjugate() = Quat(-x, -y, -z, w) + + operator fun times(o: Quat) = Quat( + w * o.x + x * o.w + y * o.z - z * o.y, + w * o.y - x * o.z + y * o.w + z * o.x, + w * o.z + x * o.y - y * o.x + z * o.w, + w * o.w - x * o.x - y * o.y - z * o.z, + ) + + companion object { + val IDENTITY = Quat(0f, 0f, 0f, 1f) + fun yaw(radians: Float) = Quat(0f, sin(radians / 2f), 0f, cos(radians / 2f)) + fun pitch(radians: Float) = Quat(sin(radians / 2f), 0f, 0f, cos(radians / 2f)) + } +} + +internal data class Pose(val orientation: Quat = Quat.IDENTITY, val position: Vec3 = Vec3.ZERO) { + val forward: Vec3 get() = orientation.rotate(Vec3.FORWARD) + fun toLocal(world: Vec3): Vec3 = orientation.conjugate().rotate(world - position) + fun toWorld(local: Vec3): Vec3 = position + orientation.rotate(local) +} + +/** Yaw of a direction in the horizontal plane, 0 along -Z, matching [Quat.yaw] applied to -Z. */ +internal fun yawOf(direction: Vec3): Float = atan2(-direction.x, -direction.z) + +/** An orientation that turns +Z, the side of a quad that shows, from [position] towards [target] about the vertical axis only. */ +internal fun facing(position: Vec3, target: Vec3): Quat { + val d = target - position + if (d.x * d.x + d.z * d.z < 1e-8f) return Quat.IDENTITY + return Quat.yaw(atan2(d.x, d.z)) +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanelChrome.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanelChrome.kt new file mode 100644 index 0000000000..00540563a1 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanelChrome.kt @@ -0,0 +1,126 @@ +package com.droiddeck.launcher.session.xr + +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Remove +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.State +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.setValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.layout.boundsInWindow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +/** + * The frame of a floating panel: the content, a bar under it to grab it by with up to two buttons at + * its left end, a corner grip to resize it, and the dot where a controller points. Its sizes match [XrUnits]. + */ +@Composable +internal fun XrPanelChrome( + cursor: State>>, + buttons: List, + resizable: Boolean, + content: @Composable () -> Unit, +) { + val colors = MaterialTheme.colorScheme + val shape = RoundedCornerShape(18.dp) + Box(Modifier.fillMaxSize().clip(shape).background(colors.background).border(1.dp, Color(0x33FFFFFF), shape)) { + Column(Modifier.fillMaxSize()) { + Box(Modifier.weight(1f).fillMaxWidth().padding(start = 10.dp, top = 10.dp, end = 10.dp)) { + CompositionLocalProvider(LocalXrPointers provides cursor) { content() } + } + Box( + Modifier.fillMaxWidth().height(52.dp).background(colors.surfaceVariant.copy(alpha = 0.6f)), + contentAlignment = Alignment.Center, + ) { + Box(Modifier.width(72.dp).height(6.dp).clip(CircleShape).background(colors.onSurface.copy(alpha = 0.35f))) + if (buttons.isNotEmpty()) Row( + Modifier.align(Alignment.CenterStart).width(XrUnits.BAR_BUTTONS_DP.dp).padding(start = 8.dp), + horizontalArrangement = Arrangement.spacedBy(4.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + buttons.take(2).forEach { button -> + if (button.icon != null) IconButton(onClick = button.onClick, modifier = Modifier.size(44.dp)) { + Icon(button.icon, button.label, tint = colors.onSurface) + } else TextButton(onClick = button.onClick, modifier = Modifier.height(40.dp), contentPadding = PaddingValues(horizontal = 10.dp)) { + Text(button.label, color = colors.onSurface, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, maxLines = 1) + } + } + } + } + } + if (resizable) Canvas(Modifier.align(Alignment.BottomEnd).padding(6.dp).size(28.dp)) { + val stroke = Stroke(width = 3.dp.toPx()) + for (step in 1..3) { + val inset = size.width * step / 4f + drawLine(Color(0x99FFFFFF), Offset(size.width, inset), Offset(inset, size.height), stroke.width) + } + } + val density = LocalDensity.current + Canvas(Modifier.fillMaxSize()) { + val radius = with(density) { 7.dp.toPx() } + for ((x, y) in cursor.value) { + drawCircle(Color(0xCC1E9EFF), radius, Offset(x, y)) + drawCircle(Color.White, radius, Offset(x, y), style = Stroke(with(density) { 2.dp.toPx() })) + } + } + } +} + +/** Where each laser meets the panel, in the panel's pixels; null off a floating panel. */ +internal val LocalXrPointers = staticCompositionLocalOf>>?> { null } + +/** + * Whether a laser rests on the element the returned [Modifier] is put on, for both controllers at + * once, where a mouse hover has room for one. False off a floating panel. + */ +@Composable +internal fun rememberXrPointed(): Pair> { + val pointers = LocalXrPointers.current + var bounds by remember { mutableStateOf(Rect.Zero) } + val pointed = remember(pointers) { + derivedStateOf { pointers != null && pointers.value.any { (x, y) -> bounds.contains(Offset(x, y)) } } + } + return Modifier.onGloballyPositioned { bounds = it.boundsInWindow() } to pointed +} + +/** With no [icon] the button shows [label] itself, for a short word such as a keyboard mode. */ +internal class XrPanelButton(val icon: ImageVector?, val label: String, val onClick: () -> Unit) + +internal val XrCollapseIcon get() = Icons.Outlined.Remove diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanelWindow.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanelWindow.kt new file mode 100644 index 0000000000..0d54d8cafe --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanelWindow.kt @@ -0,0 +1,271 @@ +package com.droiddeck.launcher.session.xr + +import android.app.Presentation +import android.content.Context +import android.hardware.display.DisplayManager +import android.hardware.display.VirtualDisplay +import android.os.Bundle +import android.os.SystemClock +import android.view.InputDevice +import android.view.MotionEvent +import android.view.Surface +import android.view.View +import android.view.ViewGroup +import android.view.WindowManager +import android.view.inspector.WindowInspector +import android.widget.FrameLayout +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.LocalTextInputService +import androidx.compose.ui.text.input.TextInputService +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.LifecycleRegistry +import androidx.activity.OnBackPressedDispatcher +import androidx.activity.OnBackPressedDispatcherOwner +import androidx.activity.setViewTreeOnBackPressedDispatcherOwner +import androidx.lifecycle.ViewModelStore +import androidx.lifecycle.ViewModelStoreOwner +import androidx.lifecycle.setViewTreeLifecycleOwner +import androidx.lifecycle.setViewTreeViewModelStoreOwner +import androidx.savedstate.SavedStateRegistry +import androidx.savedstate.SavedStateRegistryController +import androidx.savedstate.SavedStateRegistryOwner +import androidx.savedstate.setViewTreeSavedStateRegistryOwner +import com.droiddeck.launcher.ui.LocalPresentationWindow + +/** Keeps a panel's Compose content running while the activity that made it is stopped behind the XR view. */ +private class PanelOwner : LifecycleOwner, SavedStateRegistryOwner, ViewModelStoreOwner, OnBackPressedDispatcherOwner { + private val registry = LifecycleRegistry(this) + private val saved = SavedStateRegistryController.create(this) + override val lifecycle: Lifecycle get() = registry + override val savedStateRegistry: SavedStateRegistry get() = saved.savedStateRegistry + override val viewModelStore = ViewModelStore() + override val onBackPressedDispatcher = OnBackPressedDispatcher() + + fun own(view: View) { + view.setViewTreeLifecycleOwner(this) + view.setViewTreeSavedStateRegistryOwner(this) + view.setViewTreeViewModelStoreOwner(this) + view.setViewTreeOnBackPressedDispatcherOwner(this) + } + + init { + saved.performRestore(null) + registry.currentState = Lifecycle.State.RESUMED + } + + fun destroy() { + registry.currentState = Lifecycle.State.DESTROYED + viewModelStore.clear() + } +} + +/** + * One floating panel's Android side: a private virtual display drawing into the panel's OpenXR + * surface, and a presentation on it holding the Compose content. Main thread only. + */ +internal class XrPanelWindow( + private val context: Context, + private var surface: Surface, + width: Int, + height: Int, + startPaused: Boolean, + private val content: @Composable () -> Unit, +) { + private var paused = startPaused + private val owner = PanelOwner() + private val textInput = TextInputService(XrTextInput()) + private val display: VirtualDisplay = context.getSystemService(DisplayManager::class.java).createVirtualDisplay( + "DroidDeck XR panel", width, height, XrUnits.DPI, surface.takeUnless { paused }, DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY, + ) + private val presentation = PanelPresentation(context, display.display) + private var downTime = 0L + private var target: View? = null + /** The controllers pressing the panel, by hand, as fingers of one touch. */ + private val touches = linkedMapOf>() + private var hovering: View? = null + private var hoverAt = 0f to 0f + private var cursor: Pair? = null + + init { + try { + presentation.show() + } catch (failure: RuntimeException) { + release() + throw failure + } + } + + val displayId: Int get() = display.display.displayId + + fun resize(surface: Surface, width: Int, height: Int) { + this.surface = surface + if (!paused) display.surface = surface + display.resize(width, height, XrUnits.DPI) + } + + /** Stops drawing into the panel's layer, or starts again. */ + fun pause(pause: Boolean) { + if (pause == paused) return + paused = pause + display.surface = if (pause) null else surface + } + + fun release() { + runCatching { presentation.dismiss() } + owner.destroy() + display.release() + } + + private inner class PanelPresentation(outer: Context, display: android.view.Display) : Presentation(outer, display) { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + window?.setBackgroundDrawableResource(android.R.color.transparent) + window?.addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) + val compose = ComposeView(context).apply { + owner.own(this) + setContent { + CompositionLocalProvider( + LocalPresentationWindow provides true, + LocalTextInputService provides textInput, + ) { content() } + } + } + val frame = FrameLayout(context).apply { + addView(compose, FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)) + } + setContentView(frame) + window?.decorView?.let(owner::own) + } + } + + /** + * The topmost window on this panel's display under the point, so popups and dialogs get the input. + * A focusable popup or dialog on top takes a press outside it too, as on a touchscreen, where it + * dismisses itself rather than letting the press act on what is behind it. + */ + private fun rootAt(x: Float, y: Float): View? { + val roots = WindowInspector.getGlobalWindowViews().filter { it.isAttachedToWindow && it.display?.displayId == displayId && it.isShown } + val location = IntArray(2) + fun contains(root: View): Boolean { + root.getLocationOnScreen(location) + return x >= location[0] && y >= location[1] && x < location[0] + root.width && y < location[1] + root.height + } + val top = roots.lastOrNull() ?: return null + val focusable = (top.layoutParams as? WindowManager.LayoutParams) + ?.let { it.flags and WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE == 0 } ?: false + if (roots.size > 1 && focusable && !contains(top)) return top + return roots.lastOrNull(::contains) ?: top + } + + /** Sends every finger in [touches] to [target]; [action] is already shifted by its pointer index where it needs one. */ + private fun sendTouches(action: Int, time: Long) { + val view = target ?: return + val location = IntArray(2) + view.getLocationOnScreen(location) + val properties = touches.keys.map { hand -> + MotionEvent.PointerProperties().apply { id = hand; toolType = MotionEvent.TOOL_TYPE_FINGER } + }.toTypedArray() + val coords = touches.values.map { (x, y) -> + MotionEvent.PointerCoords().apply { this.x = x - location[0]; this.y = y - location[1]; pressure = 1f; size = 1f } + }.toTypedArray() + val event = MotionEvent.obtain(downTime, time, action, touches.size, properties, coords, 0, 0, 1f, 1f, 0, 0, + InputDevice.SOURCE_TOUCHSCREEN, 0) + try { + view.dispatchTouchEvent(event) + } finally { + event.recycle() + } + } + + private fun indexed(action: Int, hand: Int) = + action or (touches.keys.indexOf(hand) shl MotionEvent.ACTION_POINTER_INDEX_SHIFT) + + private fun send(view: View, action: Int, x: Float, y: Float, time: Long, generic: Boolean, scroll: Float = 0f): Boolean { + val location = IntArray(2) + view.getLocationOnScreen(location) + val properties = arrayOf(MotionEvent.PointerProperties().apply { + id = 0 + toolType = if (generic) MotionEvent.TOOL_TYPE_MOUSE else MotionEvent.TOOL_TYPE_FINGER + }) + val coords = arrayOf(MotionEvent.PointerCoords().apply { + this.x = x - location[0] + this.y = y - location[1] + pressure = 1f + size = 1f + if (scroll != 0f) setAxisValue(MotionEvent.AXIS_VSCROLL, scroll) + }) + val source = if (generic) InputDevice.SOURCE_MOUSE else InputDevice.SOURCE_TOUCHSCREEN + val event = MotionEvent.obtain(if (generic) time else downTime, time, action, 1, properties, coords, 0, 0, 1f, 1f, 0, 0, source, 0) + return try { + if (generic) view.dispatchGenericMotionEvent(event) else view.dispatchTouchEvent(event) + } finally { + event.recycle() + } + } + + /** The laser resting on the panel, as a mouse hovering, so keys and buttons light under it. Null: it left. */ + fun hover(at: Pair?) { + cursor = at + if (target != null) return + val now = SystemClock.uptimeMillis() + val root = at?.let { (x, y) -> rootAt(x, y) } + if (root !== hovering) endHover(now) + if (root == null || at == null) return + if (hovering == null) send(root, MotionEvent.ACTION_HOVER_ENTER, at.first, at.second, now, generic = true) + send(root, MotionEvent.ACTION_HOVER_MOVE, at.first, at.second, now, generic = true) + hovering = root + hoverAt = at + } + + private fun endHover(now: Long) { + hovering?.let { send(it, MotionEvent.ACTION_HOVER_EXIT, hoverAt.first, hoverAt.second, now, generic = true) } + hovering = null + } + + fun pointer(event: XrPointerEvent) { + val now = SystemClock.uptimeMillis() + when (event) { + is XrPointerEvent.Down -> { + if (event.hand in touches) return + touches[event.hand] = event.x to event.y + if (touches.size == 1) { + endHover(now) + downTime = now + target = rootAt(event.x, event.y) + sendTouches(MotionEvent.ACTION_DOWN, now) + } else sendTouches(indexed(MotionEvent.ACTION_POINTER_DOWN, event.hand), now) + } + is XrPointerEvent.Move -> { + if (event.hand !in touches) return + touches[event.hand] = event.x to event.y + sendTouches(MotionEvent.ACTION_MOVE, now) + } + is XrPointerEvent.Up -> { + if (event.hand !in touches) return + touches[event.hand] = event.x to event.y + if (touches.size > 1) { + sendTouches(indexed(MotionEvent.ACTION_POINTER_UP, event.hand), now) + touches -= event.hand + } else { + sendTouches(MotionEvent.ACTION_UP, now) + touches.clear() + target = null + hover(cursor) + } + } + is XrPointerEvent.Cancel -> { + if (event.hand !in touches) return + sendTouches(MotionEvent.ACTION_CANCEL, now) + touches.clear() + target = null + } + is XrPointerEvent.Scroll -> rootAt(event.x, event.y)?.let { + send(it, MotionEvent.ACTION_SCROLL, event.x, event.y, now, generic = true, scroll = event.amount) + } + else -> Unit + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanels.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanels.kt new file mode 100644 index 0000000000..17431f1458 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrPanels.kt @@ -0,0 +1,611 @@ +package com.droiddeck.launcher.session.xr + +import android.content.Context +import android.os.Handler +import android.os.Looper +import android.os.SystemClock +import android.util.Log +import android.view.Surface +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.KeyboardHide +import androidx.compose.runtime.Composable +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.agent.AgentHost +import com.droiddeck.launcher.session.QuestExperimental +import com.droiddeck.launcher.ui.AgentPage +import com.droiddeck.launcher.ui.AgentPet +import com.droiddeck.launcher.ui.DroidDeckTheme +import com.droiddeck.launcher.ui.PcKeyboard +import com.droiddeck.launcher.ui.PetFigure +import com.droiddeck.launcher.ui.TypingRequest +import com.droiddeck.launcher.ui.petStateNow +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch +import java.lang.ref.WeakReference +import java.nio.ByteBuffer +import java.util.concurrent.ConcurrentLinkedQueue +import kotlin.math.PI + +/** The 2D session window, which hands its menu to the immersive view while that is open. */ +internal interface XrMenuHost { + @Composable + fun XrMenuContent() + fun xrSetMenuOpen(open: Boolean) + fun xrMenuBack() + /** A key of DroidDeck's PC keyboard, by Linux key code, to the game. */ + fun xrSendKey(code: Int, down: Boolean) + /** Text from the laser keyboard to the game, as the Android keyboard sends it. */ + fun xrTypeText(text: String) + fun xrTapKey(keyCode: Int) + /** The immersive view opened or closed; Steam's screen, which SteamVR mirrors as its Steam window, sizes for it. */ + fun xrImmersiveChanged(active: Boolean) +} + +/** What the immersive view's native loop offers: surface-backed layers it composites in front of the game. */ +internal interface XrLayerSource { + val context: Context + fun createLayer(width: Int, height: Int): Int + fun layerSurface(id: Int): Surface? + fun destroyLayer(id: Int) + fun setOrbImage(image: android.graphics.Bitmap) + fun leave() +} + +/** + * DroidDeck's own windows inside the immersive Quest view: the session menu, opened by holding the + * controllers together, and the agent pet with its chat. Quest only. [frame] runs on the XR thread + * each frame; the rest runs on the main thread. + */ +internal object XrPanels { + private const val TAG = "XrPanels" + private const val OPEN_MS = 350f + private const val CLOSE_MS = 250f + private const val BURST_MS = 400f + + /** The immersive view is up, so the menu and pet belong in it. Always false off Quest. */ + @Volatile + var immersiveActive = false + + /** Counts attachments, so work posted from one immersive view is dropped once a later one, or none, is up. */ + @Volatile + private var attachment = 0 + private set + + private val main = Handler(Looper.getMainLooper()) + + /** Whether the headset shows the session; panels draw into their layers only then. */ + @Volatile + private var drawing = false + private val lock = Any() + private val ops = ConcurrentLinkedQueue<() -> Unit>() + private var source: XrLayerSource? = null + private var host: XrHost? = null + private var menuHost: WeakReference? = null + private var scope: CoroutineScope? = null + + private class Panel(val state: XrPanelState, val content: @Composable (State>>) -> Unit) { + val cursorState = mutableStateOf>>(emptyList()) + var layerId = -1 + var window: XrPanelWindow? = null + var openedMs = 0L + var closingMs = 0L + var resizing = false + var cursor: List> = emptyList() + } + + private val panels = mutableListOf() + private val gesture = XrGesture() + private val interaction = XrInteraction() + private var lastFrameMs = 0L + private var orbImageSent = false + private var lastHead = Pose() + private var burstMs = 0L + private var burstAt = Vec3.ZERO + private var lastTick = 0 + private var menuFrom: Vec3? = null + private val typing = mutableStateOf(null) + /** The keyboard was opened for the game, from the session menu; a panel's text field takes it over while it types. */ + private val gameKeyboard = mutableStateOf(false) + private val pcKeyboard = mutableStateOf(false) + + fun gateOpen(model: String, device: String, manufacturer: String, immersive: Boolean) = + immersive && QuestExperimental.supported(model, device, manufacturer) + + fun setMenuHost(menu: XrMenuHost?) { + menuHost = menu?.let { WeakReference(it) } + if (immersiveActive) menu?.xrImmersiveChanged(true) + } + + fun clearMenuHost(menu: XrMenuHost) { + if (menuHost?.get() === menu) menuHost = null + } + + /** Main thread: the immersive view handed over its buffers. */ + fun attach(layers: XrLayerSource, state: ByteBuffer, control: ByteBuffer) { + if (!QuestExperimental.isSupported()) return + synchronized(lock) { + source = layers + host = XrHost(state, control) + orbImageSent = false + } + attachment++ + immersiveActive = true + menuHost?.get()?.xrImmersiveChanged(true) + scope?.cancel() + scope = MainScope().also { scope -> + scope.launch { + snapshotFlow { com.droiddeck.launcher.agent.AgentGuest.focusRevision }.collect { + menuHost?.get()?.xrImmersiveChanged(true) + } + } + scope.launch { + snapshotFlow { AgentPet.enabled && AgentHost.installed }.collect { on -> + if (on) { if (!shown(XrPanelKind.PET_CHAT)) open(XrPanelKind.PET_HEAD) } + else { close(XrPanelKind.PET_HEAD); close(XrPanelKind.PET_CHAT) } + } + } + } + } + + /** + * XR thread, as the session becomes visible or stops being so. OpenXR allows writing into a surface + * swapchain only while the session is visible or focused, and requires the writes to have stopped + * before xrEndSession, so this returns once the panels have stopped or started drawing. + */ + fun setDrawing(visible: Boolean) { + val done = java.util.concurrent.CountDownLatch(1) + val apply = Runnable { + try { + drawing = visible + synchronized(lock) { panels.mapNotNull { it.window } }.forEach { it.pause(!visible) } + } finally { + done.countDown() + } + } + if (Looper.myLooper() == Looper.getMainLooper()) apply.run() + else if (main.post(apply) && !done.await(1, java.util.concurrent.TimeUnit.SECONDS)) + Log.w(TAG, "panels did not ${if (visible) "start" else "stop"} drawing within a second") + } + + /** Main thread: the immersive view is going; every panel goes with it. */ + fun detach() { + if (!immersiveActive) return + immersiveActive = false + scope?.cancel() + scope = null + val windows = synchronized(lock) { + source = null + host = null + ops.clear() + interaction.reset() + panels.mapNotNull { it.window }.also { panels.clear() } + } + windows.forEach { it.release() } + typing.value = null + gameKeyboard.value = false + gesture.reset(release = false) + menuHost?.get()?.xrSetMenuOpen(false) + menuHost?.get()?.xrImmersiveChanged(false) + } + + /** Main thread, from the session window's menu state. */ + fun showMenu(): Boolean { + if (!immersiveActive) return false + open(XrPanelKind.MENU, menuFrom) + menuFrom = null + return true + } + + fun hideMenu() = close(XrPanelKind.MENU) + + /** Main thread: closes the immersive view, as a stop chosen in its menu asks. */ + fun leaveImmersive() { + synchronized(lock) { source }?.leave() + } + + /** Main thread: a text field in a panel wants typing, so the laser keyboard opens. */ + fun startTyping(request: TypingRequest) { + if (!immersiveActive) return + typing.value = request + open(XrPanelKind.KEYBOARD) + } + + fun stopTyping(request: TypingRequest) { + if (typing.value !== request) return + typing.value = null + if (!gameKeyboard.value) close(XrPanelKind.KEYBOARD) + } + + /** + * Main thread: the session menu's keyboards. [pc] picks DroidDeck's PC keyboard over the Android-style one; + * asking again for the one already open closes it. False off the immersive view, where the 2D keyboards stay. + */ + fun toggleGameKeyboard(pc: Boolean): Boolean { + if (!immersiveActive) return false + if (gameKeyboard.value && pcKeyboard.value == pc && shown(XrPanelKind.KEYBOARD)) hideKeyboard() + else showGameKeyboard(pc) + return true + } + + fun showGameKeyboard(pc: Boolean): Boolean { + if (!immersiveActive) return false + gameKeyboard.value = true + pcKeyboard.value = pc + open(XrPanelKind.KEYBOARD) + return true + } + + private fun hideKeyboard() { + typing.value = null + gameKeyboard.value = false + close(XrPanelKind.KEYBOARD) + } + + private fun shown(kind: XrPanelKind) = synchronized(lock) { panels.any { it.state.kind == kind && it.closingMs == 0L } } + + private fun open(kind: XrPanelKind, from: Vec3? = null) { + ops += { create(kind, from) } + } + + private fun close(kind: XrPanelKind) { + ops += { + panels.filter { it.state.kind == kind && it.closingMs == 0L }.forEach { panel -> + panel.closingMs = SystemClock.uptimeMillis() + val out = XrInteractionOut() + interaction.release(panel.state, out) + dispatch(out) + } + } + } + + /** XR thread. */ + private fun create(kind: XrPanelKind, from: Vec3?) { + val layers = source ?: return + panels.firstOrNull { it.state.kind == kind }?.let { existing -> + if (existing.closingMs != 0L) { + existing.closingMs = 0L + val elapsed = 1f - Math.cbrt((1.0 - existing.state.scale).coerceIn(0.0, 1.0)).toFloat() + existing.openedMs = SystemClock.uptimeMillis() - (elapsed * OPEN_MS).toLong() + } + return + } + val placed = XrPlacement.load(layers.context, kind, lastHead) + val state = XrPanelState(kind, placed.pose, placed.width, placed.height) + state.scale = 0f + state.animationFrom = from ?: placed.pose.position + val id = layers.createLayer(state.pixelWidth, state.pixelHeight) + val surface = if (id >= 0) layers.layerSurface(id) else null + if (surface == null) { + Log.w(TAG, "no layer for the ${kind.key} panel") + if (id >= 0) layers.destroyLayer(id) + if (kind == XrPanelKind.MENU) main.post { menuHost?.get()?.xrSetMenuOpen(false) } + return + } + val panel = Panel(state, contentFor(kind)) + panel.layerId = id + panel.openedMs = SystemClock.uptimeMillis() + panels += panel + val context = layers.context + main.post { + synchronized(lock) { + if (panel !in panels) return@post + panel.window = runCatching { + XrPanelWindow(context, surface, state.pixelWidth, state.pixelHeight, startPaused = !drawing) { + panel.content(panel.cursorState) + } + }.onFailure { + Log.w(TAG, "could not show the ${kind.key} panel", it) + panels -= panel + ops += { if (source === layers) layers.destroyLayer(id) } + if (kind == XrPanelKind.MENU) menuHost?.get()?.xrSetMenuOpen(false) + }.getOrNull() + } + } + } + + private fun contentFor(kind: XrPanelKind): @Composable (State>>) -> Unit = when (kind) { + XrPanelKind.MENU -> { cursor -> + DroidDeckTheme { + XrPanelChrome(cursor, buttons = emptyList(), resizable = true) { + menuHost?.get()?.XrMenuContent() + } + } + } + XrPanelKind.PET_HEAD -> { _ -> + DroidDeckTheme { Box(Modifier.fillMaxSize()) { PetFigure(petStateNow(), Modifier.fillMaxSize()) } } + } + XrPanelKind.KEYBOARD -> { cursor -> + DroidDeckTheme { + val buttons = listOf( + XrPanelButton(Icons.Outlined.KeyboardHide, stringResource(R.string.pckb_hide), ::hideKeyboard), + XrPanelButton(null, if (pcKeyboard.value) "Android" else "PC") { pcKeyboard.value = !pcKeyboard.value }, + ) + XrPanelChrome(cursor, buttons, resizable = true) { KeyboardContent() } + } + } + XrPanelKind.PET_CHAT -> { cursor -> + DroidDeckTheme { + XrPanelChrome(cursor, listOf(XrPanelButton(XrCollapseIcon, stringResource(R.string.bottom_chat_close), ::collapseChat)), resizable = true) { + AgentPage(Modifier.fillMaxSize().padding(horizontal = 12.dp), visible = true, startTyping = false, hidesPet = false) + } + } + } + } + + /** A panel's text field takes the keyboard while it types; otherwise its keys go to the game. */ + @Composable + private fun KeyboardContent() { + val request = typing.value + val host = menuHost?.get()?.takeIf { gameKeyboard.value } + val target = request?.let(::XrFieldTarget) ?: host?.let(::XrGameTarget) ?: return + if (pcKeyboard.value) { + val pcText = remember(request) { request?.let { XrPcText(XrFieldTarget(it)) } } + PcKeyboard( + sendKey = { code, down -> pcText?.key(code, down) ?: host?.xrSendKey(code, down) }, + onAndroidKeyboard = { pcKeyboard.value = false }, + onClose = ::hideKeyboard, + heightFraction = 1f, + showButtons = false, + hoverFeedback = true, + ) + } else XrKeyboard(target) + } + + private fun collapseChat() { + close(XrPanelKind.PET_CHAT) + open(XrPanelKind.PET_HEAD) + } + + private fun expandChat(from: Vec3) { + close(XrPanelKind.PET_HEAD) + open(XrPanelKind.PET_CHAT, from) + } + + /** XR thread, once per frame, from QuestXrActivity.onXrHostFrame. */ + fun frame() = synchronized(lock) { + val host = host ?: return + val layers = source ?: return + val frame = host.read() + lastHead = frame.head + while (true) (ops.poll() ?: break).invoke() + if (!orbImageSent) { + orbImageSent = true + runCatching { + android.graphics.BitmapFactory.decodeResource(layers.context.resources, R.drawable.logo) + }.getOrNull()?.let { layers.setOrbImage(it); it.recycle() } + } + val now = SystemClock.uptimeMillis() + val dt = if (lastFrameMs == 0L) 0f else ((now - lastFrameMs) / 1000f).coerceIn(0f, 0.1f) + lastFrameMs = now + val control = XrControlOut() + animate(now, layers) + val active = panels.filter { it.closingMs == 0L && it.window != null } + if (frame.focused) { + if (gesture.update(frame.hands[0], frame.hands[1], now)) { + burstMs = now + burstAt = gesture.midpoint + lastTick = 0 + for (hand in 0..1) control.haptics[hand] = XrHaptic(60, 0.9f) + val from = gesture.midpoint + val posted = attachment + main.post { if (immersiveActive && posted == attachment) toggleMenu(from) } + } else if (gesture.phase == XrGesture.Phase.ARMING) { + val step = (gesture.progress * 4).toInt() + if (step > lastTick) for (hand in 0..1) control.haptics[hand] = XrHaptic(18, 0.2f + 0.15f * step) + lastTick = step + } else lastTick = 0 + val out = interaction.update(frame.head, frame.hands, active.map { it.state }, dt) + for (hand in 0..1) { + control.masks[hand] = out.masks[hand] + control.lasers[hand] = out.lasers[hand] + if (out.ticks[hand] && control.haptics[hand] == null) control.haptics[hand] = XrHaptic(12, 0.35f) + } + dispatch(out) + } else { + gesture.reset(release = false) + val out = XrInteractionOut() + interaction.cancel(out) + dispatch(out) + } + control.orb = orb(now) + panels.forEachIndexed { index, panel -> + if (panel.layerId < 0 || panel.window == null) return@forEachIndexed + val state = panel.state + control.layers += XrLayerOut(panel.layerId, state.shownPose, state.width * state.scale, state.height * state.scale, + order = if (state.kind == XrPanelKind.PET_HEAD) 100 else index) + } + host.write(control) + } + + private fun orb(now: Long): XrControlOut.Orb? { + if (gesture.phase == XrGesture.Phase.ARMING) + return XrControlOut.Orb(gesture.midpoint, 0.02f + 0.01f * gesture.progress, gesture.progress, 0f) + val burst = (now - burstMs) / BURST_MS + if (burstMs != 0L && burst < 1f) return XrControlOut.Orb(burstAt, 0.03f, 1f, burst.coerceAtLeast(0.01f)) + return null + } + + private fun animate(now: Long, layers: XrLayerSource) { + val gone = mutableListOf() + for (panel in panels) { + val state = panel.state + if (panel.closingMs != 0L) { + val t = ((now - panel.closingMs) / CLOSE_MS).coerceIn(0f, 1f) + state.scale = minOf(state.scale, 1f - easeOut(t)) + if (state.animationFrom == null) state.animationFrom = state.pose.position + if (t >= 1f) gone += panel + } else if (state.scale < 1f) { + state.scale = easeOut(((now - panel.openedMs) / OPEN_MS).coerceIn(0f, 1f)) + if (state.scale >= 1f) state.animationFrom = null + } + } + for (panel in gone) { + panels -= panel + if (panel.layerId >= 0) layers.destroyLayer(panel.layerId) + val window = panel.window + val context = layers.context + val state = panel.state + val head = lastHead + main.post { + window?.release() + XrPlacement.save(context, state.kind, head, state.pose, state.width, state.height) + } + } + } + + private fun easeOut(t: Float) = 1f - (1f - t) * (1f - t) * (1f - t) + + /** XR thread: hands each panel its input on the main thread and follows up on moves and resizes. */ + private fun dispatch(out: XrInteractionOut) { + val layers = source ?: return + for (panel in panels) { + val cursor = out.cursors[panel.state]?.toList().orEmpty() + if (cursor != panel.cursor) { + panel.cursor = cursor + val target = panel.cursorState + val window = panel.window + main.post { + target.value = cursor + window?.hover(cursor.firstOrNull()) + } + } + } + for (event in out.events) { + val panel = panels.firstOrNull { it.state === event.panel } ?: continue + when (event) { + is XrPointerEvent.Back -> main.post { back(panel.state.kind) } + is XrPointerEvent.Click -> { + val from = panel.state.pose.position + main.post { expandChat(from) } + } + is XrPointerEvent.Resized -> { + savePlacement(panel, layers) + resize(panel, layers) + } + is XrPointerEvent.Moved -> savePlacement(panel, layers) + else -> { + val window = panel.window + main.post { window?.pointer(event) } + } + } + } + } + + /** XR thread: the place a move or resize ended at, read together now and saved on the main thread. */ + private fun savePlacement(panel: Panel, layers: XrLayerSource) { + val state = panel.state + val kind = state.kind + val head = lastHead + val pose = state.pose + val width = state.width + val height = state.height + val context = layers.context + main.post { XrPlacement.save(context, kind, head, pose, width, height) } + } + + /** XR thread: gives a resized panel a surface of its new size once its content has moved over to it. */ + private fun resize(panel: Panel, layers: XrLayerSource) { + val state = panel.state + val width = XrUnits.pixels(state.width) + val height = XrUnits.pixels(state.height) + if (width == state.pixelWidth && height == state.pixelHeight) return + val id = layers.createLayer(width, height) + val surface = if (id >= 0) layers.layerSurface(id) else null + if (surface == null) { + if (id >= 0) layers.destroyLayer(id) + return + } + val window = panel.window + main.post { + window?.resize(surface, width, height) + ops += { + if (panel in panels) { + val old = panel.layerId + panel.layerId = id + state.pixelWidth = width + state.pixelHeight = height + if (old >= 0) layers.destroyLayer(old) + } else if (source === layers) layers.destroyLayer(id) + } + } + } + + /** Main thread. */ + private fun toggleMenu(from: Vec3) { + val menu = menuHost?.get() ?: return + if (shown(XrPanelKind.MENU)) menu.xrSetMenuOpen(false) + else { + menuFrom = from + menu.xrSetMenuOpen(true) + } + } + + /** Main thread: B on a panel goes back a step, as Back does in the 2D window. */ + private fun back(kind: XrPanelKind) { + when (kind) { + XrPanelKind.MENU -> menuHost?.get()?.xrMenuBack() + XrPanelKind.PET_CHAT -> collapseChat() + XrPanelKind.PET_HEAD -> Unit + XrPanelKind.KEYBOARD -> hideKeyboard() + } + } +} + +/** Where each panel kind was left, relative to where the user faced, so it comes back there. */ +internal object XrPlacement { + class Placed(val pose: Pose, val width: Float, val height: Float) + + private class Default(val yaw: Float, val distance: Float, val dy: Float, val width: Float, val height: Float) + + private val defaults = mapOf( + XrPanelKind.MENU to Default(0f, 0.95f, -0.12f, 0.9f, 0.6f), + XrPanelKind.PET_CHAT to Default(0.6f, 0.95f, -0.12f, 0.6f, 0.7f), + XrPanelKind.PET_HEAD to Default(0.7f, 0.75f, -0.45f, 0.12f, 0.12f), + XrPanelKind.KEYBOARD to Default(0f, 0.5f, -0.5f, 0.8f, 0.36f), + ) + + private fun prefs(context: Context) = context.getSharedPreferences("quest_xr_panels", Context.MODE_PRIVATE) + + fun place(kind: XrPanelKind, head: Pose, yaw: Float, distance: Float, dy: Float): Pose { + val angle = yawOf(head.forward) + yaw + val direction = Quat.yaw(angle).rotate(Vec3.FORWARD) + val position = head.position + direction * distance + Vec3(0f, dy, 0f) + return Pose(kind.orient(position, head.position), position) + } + + fun relative(head: Pose, position: Vec3): Triple { + val offset = position - head.position + val distance = Vec3(offset.x, 0f, offset.z).length + var yaw = yawOf(offset) - yawOf(head.forward) + while (yaw > PI) yaw -= (2 * PI).toFloat() + while (yaw < -PI) yaw += (2 * PI).toFloat() + return Triple(yaw, distance, offset.y) + } + + fun load(context: Context, kind: XrPanelKind, head: Pose): Placed { + val fallback = defaults.getValue(kind) + val saved = prefs(context).getString(kind.key, null)?.split(',')?.mapNotNull { it.toFloatOrNull() } + val values = saved?.takeIf { it.size == 5 } ?: listOf(fallback.yaw, fallback.distance, fallback.dy, fallback.width, fallback.height) + val distance = values[1].coerceIn(XrUnits.MIN_DISTANCE, XrUnits.MAX_DISTANCE) + val width = if (kind.resizable) values[3].coerceIn(XrUnits.MIN_METRES, XrUnits.MAX_METRES) else fallback.width + val height = if (kind.resizable) values[4].coerceIn(XrUnits.MIN_METRES, XrUnits.MAX_METRES) else fallback.height + return Placed(place(kind, head, values[0], distance, values[2].coerceIn(-1.5f, 1.5f)), width, height) + } + + fun save(context: Context, kind: XrPanelKind, head: Pose, pose: Pose, width: Float, height: Float) { + val (yaw, distance, dy) = relative(head, pose.position) + prefs(context).edit().putString(kind.key, listOf(yaw, distance, dy, width, height).joinToString(",")).apply() + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/xr/XrSteamScreen.kt b/app/src/main/java/com/droiddeck/launcher/session/xr/XrSteamScreen.kt new file mode 100644 index 0000000000..d797f5be9b --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/xr/XrSteamScreen.kt @@ -0,0 +1,16 @@ +package com.droiddeck.launcher.session.xr + +/** Whether the guest's focus report shows Steam's own screen, with no game holding a window. */ +internal object XrSteamScreen { + /** Steam's own UI and SteamVR, which have windows of their own but are not games. */ + private val STEAM_APPS = setOf(769L, 250820L) + + /** + * Gamescope lists Steam itself while its screen is up, so a report naming no app at all, as the guest + * writes when it could not collect focus or gamescope has not published it, says nothing. + */ + fun shown(focusedApp: Long?, focusableApps: List?): Boolean { + val apps = (listOfNotNull(focusedApp) + focusableApps.orEmpty()).filter { it > 0 } + return apps.isNotEmpty() && apps.all { it in STEAM_APPS } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt b/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt index 5923cd6e44..ef3c2d3482 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/CloudSaves.kt @@ -113,7 +113,7 @@ object CloudSaves { } Store.UBISOFT -> UBISOFT_TEMPLATE Store.EA -> eaRules(context, id) ?: return null - Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR -> "" + Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR, Store.STEAM -> "" } ?: return null p.edit() .putString("cloud_template_$id", fetched.ifEmpty { TEMPLATE_NONE }) @@ -181,7 +181,7 @@ object CloudSaves { Store.EPIC -> CloudSavePaths.epic(template, pfx, folder, EpicCredentialStore.load(context)?.accountId.orEmpty(), id) Store.EA -> if (sidecar.extra["masterTitleId"].isNullOrEmpty()) null else EaSaveRules.parse(template)?.base()?.let(EaSaveRules::template)?.let { CloudSavePaths.gog(it, pfx, folder) } - Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> null + Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR, Store.STEAM -> null } return dir to (if (dir == null) "unresolved" else "ok") } @@ -221,7 +221,7 @@ object CloudSaves { if (rules == null || base == null || token == null || uid.isEmpty() || master.isEmpty()) null else EaCloud(token, uid, EaCloud.keys(master, sidecar?.extra?.get("multiplayerId").orEmpty()), base, rules, saveFolder(context, store, id).first) } - Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR -> null + Store.AMAZON, Store.ITCH, Store.GAMEJOLT, Store.XBOX, Store.BATTLENET, Store.ROCKSTAR, Store.STEAM -> null } private fun signedIn(context: Context, store: Store): Boolean = when (store) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt b/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt index a1b54088eb..99870f032c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/LoginFlows.kt @@ -16,7 +16,7 @@ internal object LoginFlows { Store.UBISOFT -> ubisoftFlow(browserUserAgent) Store.EA -> eaFlow(browserUserAgent) Store.ROCKSTAR -> rockstarFlow(browserUserAgent) - Store.ITCH, Store.XBOX, Store.BATTLENET -> null + Store.ITCH, Store.XBOX, Store.BATTLENET, Store.STEAM -> null } @Volatile var epicFlow: () -> StoreLoginActivity.Flow? = { null } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/SteamAchievements.kt b/app/src/main/java/com/droiddeck/launcher/stores/SteamAchievements.kt new file mode 100644 index 0000000000..a1b270a8ae --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/SteamAchievements.kt @@ -0,0 +1,58 @@ +package com.droiddeck.launcher.stores + +import android.content.Context +import com.droiddeck.launcher.agent.AgentGuest +import com.droiddeck.launcher.session.SessionService +import com.droiddeck.launcher.session.SessionState +import org.json.JSONObject + +object SteamAchievements : StoreAchievements("steam", "Steam") { + fun game(appId: Long) = Game(source, appId.toString()) + + override fun request(context: Context, game: Game): Result { + val appId = game.id.toLongOrNull()?.takeIf { it in 1..4_294_967_295L } ?: return Result.Failed(Reason.NO_SERVICE) + if (!SessionState.running || SessionState.mode != SessionService.MODE_STEAM) return Result.Failed(Reason.UNREACHABLE) + val answer = AgentGuest.steamEval(context, expression(appId), EVAL_TIMEOUT_MS) + if (!answer.optBoolean("ok")) return Result.Failed(Reason.UNREACHABLE) + val value = answer.opt("value")?.takeIf { it != JSONObject.NULL }?.toString() ?: return Result.Failed(Reason.UNREACHABLE) + return parse(appId, value) + } + + internal fun expression(appId: Long) = """(async () => { + const r = await SteamClient.Apps.GetMyAchievementsForApp('$appId'); + return typeof r === 'string' ? r : JSON.stringify(r); + })()""" + + internal fun parse(appId: Long, json: String): Result { + val root = runCatching { JSONObject(json) }.getOrNull() ?: return Result.Failed(Reason.UNREACHABLE) + if (root.optInt("result", 1) != 1) return Result.Found(emptyList()) + val items = root.optJSONObject("data")?.optJSONArray("rgAchievements") ?: return Result.Found(emptyList()) + val out = ArrayList(items.length()) + for (i in 0 until items.length()) { + val a = items.optJSONObject(i) ?: continue + val id = a.optString("strID") + if (id.isEmpty()) continue + val unlocked = a.optBoolean("bAchieved") + out += Achievement( + id = id, + name = a.optString("strName").ifEmpty { id }, + description = a.optString("strDescription"), + hidden = a.optBoolean("bHidden"), + unlocked = unlocked, + unlockedAt = if (unlocked) a.optLong("rtUnlocked") else 0, + icon = image(appId, a.optString("strImage")), + iconLocked = null, + ) + } + return Result.Found(out) + } + + private fun image(appId: Long, value: String): String? = when { + value.isEmpty() -> null + value.startsWith("https://") -> value + value.startsWith("http://") -> "https://" + value.removePrefix("http://") + else -> "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/$appId/${value.substringAfterLast('/')}" + } + + private const val EVAL_TIMEOUT_MS = 8_000L +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt b/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt index ced9ae8fb2..c4601cb907 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/SteamLiveShortcuts.kt @@ -19,25 +19,33 @@ object SteamLiveShortcuts { private const val EVAL_TIMEOUT_MS = 20_000L private const val THAW_WAIT_MS = 15_000L - fun sync(context: Context, games: List, include: (AddedGames.Game) -> Boolean = { it.source != Library.ADDED }) { + fun sync(context: Context, games: List, include: (AddedGames.Game) -> Boolean = { it.source != Library.ADDED }): Boolean { val wanted = games.filter(include) - if (wanted.isEmpty() || !clientRunning()) return + if (wanted.isEmpty()) return true + if (!clientRunning()) return false val list = JSONArray() for (g in wanted) list.put(JSONObject().put("name", g.name).put("exe", g.guestExe).put("dir", g.guestDir).put("appid", g.appId and 0xFFFFFFFFL).put("launch", g.launchOptions)) val js = """ (async () => { const want = ${list}; - let added = 0; + let added = 0, missed = 0; for (const w of want) { if (await ${KNOWN}(w.appid, w.name, w.exe)) continue; - if (await ${ADD}(w.name, w.exe, w.dir, true, ${JSONObject.quote(compatTool(context))}, w.launch)) added++; + if (await ${ADD}(w.name, w.exe, w.dir, true, ${JSONObject.quote(compatTool(context))}, w.launch)) added++; else missed++; } - return added; + return JSON.stringify({ added, missed }); })() """.trimIndent() - val result = evaluate(context, js) ?: return - Log.i(TAG, "live shortcuts: $result added") - if (result != "0") StoresState.logLine("Steam: $result shortcut(s) added to the running client") + return synced(evaluate(context, js)) + } + + internal fun synced(result: String?): Boolean { + val counts = result?.let { runCatching { JSONObject(it) }.getOrNull() } ?: return false + val added = counts.optInt("added") + val missed = counts.optInt("missed") + Log.i(TAG, "live shortcuts: $added added" + if (missed > 0) ", $missed not added" else "") + if (added > 0) StoresState.logLine("Steam: $added shortcut(s) added to the running client") + return missed == 0 } fun ensure(context: Context, name: String, exe: String, dir: String, compat: Boolean, appId: Long? = null): Long? { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/Store.kt b/app/src/main/java/com/droiddeck/launcher/stores/Store.kt index 67b439943d..765ae7a5ce 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/Store.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/Store.kt @@ -10,11 +10,18 @@ enum class Store(val id: String, val label: String, val shortLabel: String) { UBISOFT("ubisoft", "Ubisoft Connect", "Ubisoft"), AMAZON("amazon", "Amazon Games", "Amazon"), BATTLENET("battlenet", "Battle.net", "Battle.net"), - GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt"); + GAMEJOLT("gamejolt", "Game Jolt", "Game Jolt"), + STEAM("steamstore", "Steam", "Steam"); val folder: String get() = if (this == ITCH) "itch" else shortLabel + /** The Library tab its games list under: Steam's are the Steam client's own tab. */ + val librarySource: String get() = if (this == STEAM) com.droiddeck.launcher.frontend.Library.SOURCE_STEAM else id + companion object { fun byId(id: String?): Store? = entries.firstOrNull { it.id == id } + + /** The stores with a tab of their own; Steam's games list in the Library's Steam tab. */ + val tabbed: List get() = entries - STEAM } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt index 5e30fb7a5d..5bf88fb1b0 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreAccounts.kt @@ -90,7 +90,7 @@ object StoreAccounts { fun signedInAs(context: Context, store: Store): String? { val json = read(context, store) ?: return if (isUnavailable(store)) store.label else null if (store == Store.XBOX) return json.optString("username").takeIf { it.isNotBlank() } - if (store == Store.BATTLENET) return json.optString("display_name").takeIf { it.isNotBlank() } + if (store == Store.BATTLENET || store == Store.STEAM) return json.optString("display_name").takeIf { it.isNotBlank() } if (json.optString("access_token", "").isEmpty()) return null return json.optString("display_name", "").ifEmpty { json.optString("username", "") }.ifEmpty { store.label } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt index 67ae6bae61..d248caf502 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreAchievements.kt @@ -95,7 +95,7 @@ abstract class StoreAchievements(val source: String, val label: String) { private set fun invalidate() { revision++ } - private val all: List by lazy { listOf(GogAchievements, EpicAchievements) } + private val all: List by lazy { listOf(GogAchievements, EpicAchievements, SteamAchievements) } fun forSource(source: String?): StoreAchievements? = all.firstOrNull { it.source == source } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt index 040969b840..e9e4f9f631 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt @@ -247,7 +247,7 @@ object StoreInstallRoot { fun storeDir(root: File, store: Store): File = File(root, store.folder) fun gameFolders(context: Context): List = roots(context).flatMap { root -> - Store.entries.flatMap { store -> + Store.entries.filter { it != Store.STEAM }.flatMap { store -> storeDir(root, store).listFiles { f -> f.isDirectory }?.sortedBy { it.name.lowercase() } ?: emptyList() } } @@ -267,7 +267,7 @@ object StoreInstallRoot { fun isFinished(folder: File): Boolean = StoreGameSidecar.read(folder)?.isInstalled == true fun unfinished(context: Context): List = roots(context).flatMap { root -> - Store.entries.filter { it != Store.BATTLENET }.flatMap { store -> + Store.entries.filter { it != Store.BATTLENET && it != Store.STEAM }.flatMap { store -> storeDir(root, store).listFiles { f -> f.isDirectory }.orEmpty().mapNotNull { folder -> val sidecar = StoreGameSidecar.read(folder) when { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt index e792b67a94..4aca4ca028 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt @@ -122,10 +122,16 @@ object StoreInstalls { fun discard(context: Context, folder: File, caches: List) { val app = context.applicationContext + inBackground(folder) { discardNow(app, folder, caches) } + } + + fun deleteLater(dir: File) = inBackground(dir) { deleteTree(dir) } + + private fun inBackground(folder: File, work: () -> Unit) { beginDiscard(folder) val worker = Thread({ try { - discardNow(app, folder, caches) + work() } finally { endDiscard(folder) } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt index 8dfa21a725..e76e5279e1 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunch.kt @@ -97,7 +97,7 @@ object StoreLaunch { lines += "del \"%~dp0$EA_ENV\"" lines += ":run" lines += "if exist \"$EA_ORIGIN\" start \"\" \"$EA_ORIGIN\"" - lines += run + lines += "$run %*" lines += "taskkill /f /im Origin.exe >nul 2>&1" } else { lines += run diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt index cc231dfcb8..41f76ce30c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreLaunchRequests.kt @@ -189,7 +189,7 @@ object StoreLaunchRequests { /// /// The message is the only thing that separates a stale sign-in from a title /// that is not installed, so it is kept, minus anything that could carry a - /// device path or a token: segments lookng like a path are dropped and the + /// device path or a token: segments looking like a path are dropped and the /// rest is folded to plain text. internal fun reasonFor(error: Throwable): String { val text = error.message.orEmpty() diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt index 8a47c06806..af8e09bc57 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreSizes.kt @@ -63,7 +63,7 @@ object StoreSizes { Store.AMAZON -> AmazonPrefs.get(app).edit().putLong("size_${item.id}", it).apply() Store.ITCH, Store.GAMEJOLT -> {} Store.EA -> com.droiddeck.launcher.stores.ea.EaPrefs.get(app).edit().putLong("size_${item.id}", it).apply() - Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> {} + Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR, Store.STEAM -> {} } } }, pool).exceptionally { error -> @@ -142,5 +142,6 @@ object StoreSizes { Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR -> 0L Store.ITCH -> com.droiddeck.launcher.stores.itch.ItchLibrary.size(context, item) Store.GAMEJOLT -> com.droiddeck.launcher.stores.gamejolt.GameJoltBuilds.size(context, item) + Store.STEAM -> com.droiddeck.launcher.stores.steam.SteamStore.plannedBytes(context, item) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt index 975626168d..e73d1e6801 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreTabs.kt @@ -3,7 +3,7 @@ package com.droiddeck.launcher.stores data class StoreTab(val store: Store, val shown: Boolean) fun arrangeStoreTabs(order: List, hidden: Set): List { - val known = Store.entries.associateBy { it.id } + val known = Store.tabbed.associateBy { it.id } val listed = order.mapNotNull { known[it] }.distinct() - return (listed + Store.entries.filterNot { it in listed }).map { StoreTab(it, it.id !in hidden) } + return (listed + Store.tabbed.filterNot { it in listed }).map { StoreTab(it, it.id !in hidden) } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt index 8cd6ea13a2..8c0d4198f1 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoresState.kt @@ -85,6 +85,7 @@ object StoresState { do { seen = refreshRequests.get() runCatching { com.droiddeck.launcher.stores.battlenet.BattleNetClient.syncAccount(app) } + runCatching { com.droiddeck.launcher.stores.steam.SteamStore.syncAccount(app) } val found = Store.entries.mapNotNull { store -> StoreAccounts.displayName(app, store)?.let { store to it } } val onDisk = StoreInstallRoot.gameFolders(app).mapNotNull { folder -> StoreGameSidecar.read(folder)?.takeIf { it.isInstalled || it.state == StoreGameSidecar.STATE_UPDATING }?.let { InstalledStoreGame(it, folder) } @@ -120,6 +121,8 @@ object StoresState { var unfinished by mutableStateOf>(emptyList()) internal set + var steamPicking by mutableStateOf(null) + fun isUnfinished(item: CatalogItem): Boolean = unfinished.any { it.store == item.store && (it.id == item.id || (it.id == null && it.folder.name == StoreInstallRoot.folderName(item.title, item.id))) } @@ -260,6 +263,7 @@ object StoresState { fun requestInstall(context: Context, item: CatalogItem) { askForNotifications(context) + if (item.store == Store.STEAM) { com.droiddeck.launcher.stores.steam.SteamStore.requestInstall(context, item); return } if (item.store == Store.ITCH && item.extra["uploadId"].isNullOrEmpty()) { itchPicking = item; return } if (item.store == Store.GAMEJOLT && item.extra["buildId"].isNullOrEmpty()) { gameJoltPicking = item; return } if (isUnfinished(item)) { install(context, item); return } @@ -278,6 +282,7 @@ object StoresState { fun install(context: Context, item: CatalogItem, root: java.io.File? = null, language: String? = null) { val app = context.applicationContext + if (item.store == Store.STEAM) { com.droiddeck.launcher.stores.steam.SteamStore.restore(app, item); return } val targetRoot = root ?: StoreInstallRoot.defaultTarget(app)?.root ?: StoreInstallRoot.installRoot(app) if (item.store == Store.BATTLENET && !com.droiddeck.launcher.stores.battlenet.BattleNetInstall.headless(item)) { backends[item.store]?.install(app, item, targetRoot) @@ -315,7 +320,7 @@ object StoresState { val key = "${game.sidecar.store.id}:${game.sidecar.id}" uninstalling[key] = 0f background("stores-uninstall", onFailure = { main.post { uninstalling.remove(key); onDone() } }) { - if (!com.droiddeck.launcher.stores.download.DownloadQueue.holdForRemovalWhenFree(key)) { + if (!com.droiddeck.launcher.stores.download.DownloadQueue.stopForRemoval(app, key)) { logLine("kept \"${game.sidecar.title}\": its download or update is still running") main.post { uninstalling.remove(key); onDone() } return@background diff --git a/app/src/main/java/com/droiddeck/launcher/stores/WebCookies.kt b/app/src/main/java/com/droiddeck/launcher/stores/WebCookies.kt index b44a274c50..6077ebe327 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/WebCookies.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/WebCookies.kt @@ -14,9 +14,14 @@ internal object WebCookies { } } + fun scopes(url: String, paths: List): List { + val segments = runCatching { java.net.URI(url).path }.getOrNull().orEmpty().split('/').filter { it.isNotEmpty() } + return (paths + segments.indices.map { i -> "/" + segments.take(i + 1).joinToString("/") }).distinct() + } + fun expire(urls: List, domain: String, paths: List, done: (Int) -> Unit) { val cookies = CookieManager.getInstance() - val lines = urls.flatMap { url -> expired(cookies.getCookie(url), domain, paths, Uri.parse(url).host).map { url to it } } + val lines = urls.flatMap { url -> expired(cookies.getCookie(url), domain, scopes(url, paths), Uri.parse(url).host).map { url to it } } if (lines.isEmpty()) { done(0) return diff --git a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt index 426d3616a9..6ee2f1b16d 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/battlenet/BattleNetStore.kt @@ -7,6 +7,7 @@ import com.droiddeck.launcher.R import com.droiddeck.launcher.frontend.AddedGames import com.droiddeck.launcher.runtime.BattleNet import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameStorage import com.droiddeck.launcher.stores.CatalogItem import com.droiddeck.launcher.stores.InstalledStoreGame import com.droiddeck.launcher.stores.Store @@ -130,13 +131,13 @@ object BattleNetClient { StoresState.post { opener?.invoke(args) } } - fun library(context: Context, root: File = preferred(context)): List = - AddedGames.guestPath(context, StoreInstallRoot.storeDir(root, Store.BATTLENET))?.let { listOf("--library", it) }.orEmpty() + fun library(context: Context, root: File? = preferred(context)): List = + root?.let { AddedGames.guestPath(context, StoreInstallRoot.storeDir(it, Store.BATTLENET)) }?.let { listOf("--library", it) }.orEmpty() - internal fun preferred(context: Context): File { + internal fun preferred(context: Context): File? { val second = StoreInstallRoot.libraryRoot(context)?.absolutePath return StoreInstallRoot.targets(context).firstOrNull { it.root.absolutePath == second && (it.root.isDirectory || it.root.mkdirs()) }?.root - ?: StoreInstallRoot.internalRoot(context) + ?: StoreInstallRoot.internalRoot(context).takeIf { second == null && !GameStorage.disconnected(context) } } fun installGame(context: Context, uid: String, root: File) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt index 4ceb4278bf..8d5d1e6586 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/download/DownloadQueue.kt @@ -9,6 +9,7 @@ import java.util.concurrent.atomic.AtomicBoolean object DownloadQueue { private const val TAG = "StoreDownloads" + private const val REMOVAL_WAIT_MS = 30_000L interface DownloadJob { fun run(handle: JobHandle): String? @@ -120,17 +121,24 @@ object DownloadQueue { fun releaseRemoval(key: String) { synchronized(lock) { removing.remove(key); (lock as Object).notifyAll() } } - fun holdForRemovalWhenFree(key: String): Boolean = synchronized(lock) { - while (true) { - val item = items[key] - if (item?.entry?.isActive == true || item?.job != null) return@synchronized false - if (key !in cleaningUp && key !in removing) break - (lock as Object).wait() + fun stopForRemoval(context: Context, key: String): Boolean { + if (synchronized(lock) { busyLocked(key) }) cancel(context, key) + val deadline = android.os.SystemClock.uptimeMillis() + REMOVAL_WAIT_MS + return synchronized(lock) { + while (true) { + val busy = busyLocked(key) + if (!busy && key !in cleaningUp && key !in removing) break + val left = deadline - android.os.SystemClock.uptimeMillis() + if (busy && left <= 0) return@synchronized false + (lock as Object).wait(if (busy) left else 0L) + } + removing.add(key) + true } - removing.add(key) - true } + private fun busyLocked(key: String): Boolean = items[key].let { it?.entry?.isActive == true || it?.job != null } + private fun beginCleanup(key: String): Boolean = synchronized(lock) { if (key in removing) return@synchronized false cleaningUp.merge(key, 1, Int::plus) @@ -159,6 +167,7 @@ object DownloadQueue { } fun holdPaused(key: String) = synchronized(lock) { heldPaused.add(key) } + fun dropHeld(key: String) = synchronized(lock) { heldPaused.remove(key) } private var running = 0 fun parallel(context: Context): Int = SessionPrefs.gameStoresParallel(context) @@ -411,6 +420,7 @@ object DownloadQueue { } item.job = null publishLocked() + (lock as Object).notifyAll() } when (item.entry.state) { DownloadState.INSTALLED -> { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaBackend.kt index bd8d5c1212..3da83576bb 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaBackend.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaBackend.kt @@ -44,7 +44,7 @@ object EaBackend : StoreBackend { signOuts.incrementAndGet() StoresState.post { StoresState.shelves.remove(store) } EaUpdates.available.clear() - runCatching { WebCookies.expire(EaLogin.SIGN_IN_URLS, ".ea.com", listOf("/")) {} } + EaLogin.forget {} } override fun syncLibrary(context: Context, force: Boolean) { @@ -100,9 +100,7 @@ internal class EaLogin(private val pending: EaAuth.Pending, override val userAge override fun isRedirect(url: String): Boolean = url.startsWith("qrc:", ignoreCase = true) - override fun forgetSignIn(done: () -> Unit) { - runCatching { WebCookies.expire(SIGN_IN_URLS, ".ea.com", listOf("/")) { done() } }.onFailure { done() } - } + override fun forgetSignIn(done: () -> Unit) = forget(done) override fun finish(activity: StoreLoginActivity, view: WebView, url: String): String? { val code = EaAuth.redirectValue(url, "code") ?: return activity.getString(R.string.stores_login_error_verification) @@ -116,7 +114,11 @@ internal class EaLogin(private val pending: EaAuth.Pending, override val userAge } companion object { - val SIGN_IN_URLS = listOf("https://accounts.ea.com", "https://signin.ea.com", "https://www.ea.com") + val SIGN_IN_URLS = listOf(EaAuth.AUTH_URL, "https://signin.ea.com/p/juno/login", "https://www.ea.com") + + fun forget(done: () -> Unit) { + runCatching { WebCookies.expire(SIGN_IN_URLS, ".ea.com", listOf("/")) { done() } }.onFailure { done() } + } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt index a9b623a2d6..7869d2d2bb 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLaunch.kt @@ -73,35 +73,72 @@ object EaLaunch { /** Answers the guest's request right before an EA game starts: session, licence and the LSX endpoint. */ fun prepare(context: Context, request: JSONObject): JSONObject { val app = context.applicationContext + request.optJSONObject("steam")?.let { return prepareSteam(app, request, it) } val id = request.optString("id") - val reply = JSONObject().put("ok", false) - val (folder, recorded) = installed(app, id) ?: return reply.put("reason", "not-installed") + val (folder, recorded) = installed(app, id) ?: return JSONObject().put("ok", false).put("reason", "not-installed") val sidecar = backfill(folder, recorded) runCatching { com.droiddeck.launcher.stores.StoreLaunch.refreshLauncher(folder, sidecar) } File(folder, ENV_FILE).delete() - val account = EaAuth.load(app) ?: return reply.put("reason", "signed-out") - val access = EaAuth.accessToken(app) ?: return reply.put("reason", "sign-in-expired") - val contentId = sidecar.extra["contentId"].orEmpty() - val locale = sidecar.extra["locale"].orEmpty().ifEmpty { "en_US" } - val core = EaOoa.coreDir(folder, sidecar.exe) + val known = (sidecar.extra["contentIds"].orEmpty().split(',') + sidecar.extra["multiplayerId"].orEmpty()).map { it.trim() }.filter { it.isNotEmpty() }.toSet() + val game = Started(folder, id, sidecar.extra["contentId"].orEmpty(), known, sidecar.extra["contentIds"].orEmpty().split(','), + sidecar.title, sidecar.installVersion, sidecar.extra["locale"].orEmpty().ifEmpty { "en_US" }, sidecar.exe) + val (reply, env) = start(app, game, request) + if (env != null) { + val tmp = File(folder, "$ENV_FILE.tmp") + tmp.writeText(env.entries.joinToString("\r\n", postfix = "\r\n") { "${it.key}=${it.value}" }) + tmp.renameTo(File(folder, ENV_FILE)) + } + return reply + } + + private val OFFER = Regex("Origin\\.OFR\\.[0-9]+\\.[0-9]+") + private val CONTENT = Regex("[A-Za-z0-9._-]{1,64}") + + /** Steam's copy of an EA game, which Steam would hand to the EA app; the env comes back in the reply. */ + private fun prepareSteam(app: Context, request: JSONObject, steam: JSONObject): JSONObject { + val failed = JSONObject().put("ok", false) + val root = com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app).canonicalFile + val folder = File(root, steam.optString("folder").removePrefix("/")).canonicalFile + if (!folder.path.startsWith(root.path + File.separator) || !folder.isDirectory) return failed.put("reason", "no-folder") + fun strings(name: String, pattern: Regex) = steam.optJSONArray(name)?.let { a -> (0 until a.length()).map { a.optString(it) } } + .orEmpty().filter { pattern.matches(it) }.distinct() + val offers = strings("offers", OFFER) + val contents = strings("contentIds", CONTENT) + if (offers.isEmpty() || contents.isEmpty()) return failed.put("reason", "no-offer") + val game = Started(folder, offers.first(), contents.first(), contents.toSet(), contents, steam.optString("title").ifEmpty { folder.name }, + steam.optString("version"), steam.optString("locale").ifEmpty { "en_US" }, steam.optString("exe")) + val (reply, env) = start(app, game, request) + if (env != null) reply.put("id", game.offerId).put("env", JSONObject(env.toMap())) + return reply + } + + private class Started( + val folder: File, val offerId: String, val contentId: String, val contentIds: Set, val licenceIds: List, + val title: String, val version: String, val locale: String, val exe: String, + ) + + private fun start(app: Context, game: Started, request: JSONObject): Pair?> { + val reply = JSONObject().put("ok", false) + val id = game.offerId + val account = EaAuth.load(app) ?: return reply.put("reason", "signed-out") to null + val access = EaAuth.accessToken(app) ?: return reply.put("reason", "sign-in-expired") to null + val contentId = game.contentId + val locale = game.locale + val core = EaOoa.coreDir(game.folder, game.exe) val hashVersion = core?.let(EaOoa::activationVersion) ?: 1 val hardware = request.optJSONObject("hardware")?.let(EaOoa.Hardware::fromJson)?.takeIf { it.complete(hashVersion) } val legacy = EaOoa.legacyCore(core) val lifetime = if (legacy) 14400 else 550 val opaque = EaAuth.mint(app, EaAuth.CLIENT_ID, "token", EaAuth.OPAQUE_SCOPES, "OPAQUE", lifetime).orEmpty() - val known = (sidecar.extra["contentIds"].orEmpty().split(',') + sidecar.extra["multiplayerId"].orEmpty()).map { it.trim() }.filter { it.isNotEmpty() }.toSet() - val lsx = EaLsx.start(app, EaLsx.Game(id, contentId, sidecar.title, sidecar.installVersion, locale, hardware, hashVersion, opaque, - System.currentTimeMillis() + (lifetime - 30) * 1000L, known)) + val lsx = EaLsx.start(app, EaLsx.Game(id, contentId, game.title, game.version, locale, hardware, hashVersion, opaque, + System.currentTimeMillis() + (lifetime - 30) * 1000L, game.contentIds)) val env = environment(id, contentId, locale, if (legacy && opaque.isNotEmpty()) opaque else access, access, opaque, EaAuth.load(app) ?: account) - val tmp = File(folder, "$ENV_FILE.tmp") - tmp.writeText(env.entries.joinToString("\r\n", postfix = "\r\n") { "${it.key}=${it.value}" }) - tmp.renameTo(File(folder, ENV_FILE)) val licenses = JSONArray() val notes = ArrayList() if (core != null) { - val ids = (listOf(contentId) + sidecar.extra["contentIds"].orEmpty().split(',')).map { it.trim() }.filter { it.isNotEmpty() }.distinct() + val ids = (listOf(contentId) + game.licenceIds).map { it.trim() }.filter { it.isNotEmpty() }.distinct() if (hardware == null) notes += "no-hardware" else { val hash = EaOoa.machineHash(hardware, hashVersion) for (content in ids) { @@ -125,7 +162,7 @@ object EaLaunch { } val licenseNote = if (core == null) "none-needed" else "v$hashVersion " + notes.joinToString(",") Log.i(TAG, "prepared $id lsx=$lsx legacy=$legacy opaque=${opaque.isNotEmpty()} licence=$licenseNote") - return reply.put("ok", true).put("lsx", lsx).put("license", licenseNote).put("licenses", licenses) + return reply.put("ok", true).put("lsx", lsx).put("license", licenseNote).put("licenses", licenses) to env } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLsx.kt b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLsx.kt index f9e6b286a0..35e9bdb343 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLsx.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/ea/EaLsx.kt @@ -67,7 +67,7 @@ object EaLsx { } @Volatile var game: Game? = null - @Volatile private var account: Account? = null + @Volatile internal var account: Account? = null /** The one session of the current launch that may act for the account. */ /** Bumped whenever the launch changes; a connection accepted under an older one is not admitted. */ @Volatile internal var generation = 0 @@ -333,10 +333,11 @@ object EaLsx { private fun now() = LocalDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")) - private fun answer(session: Session, m: Message): String? { + internal fun answer(session: Session, m: Message): String? { val g = game val who = account val person = who?.takeIf { session.trusted } + val profile = who?.takeIf { session.trusted || session.claimed } val locale = g?.locale ?: "en_US" return when (m.name) { "ChallengeResponse" -> { @@ -355,15 +356,16 @@ object EaLsx { "GetConfig" -> tag("GetConfigResponse", body = SERVICES.joinToString("") { tag("Service", "Name" to it.first, "Facility" to it.second) }) "GetProfile" -> tag( "GetProfileResponse", - "Persona" to person?.persona.orEmpty(), "SubscriberLevel" to 0, "CommerceCurrency" to "USD", "IsTrialSubscriber" to false, - "Country" to "US", "UserId" to person?.userId.orEmpty(), "GeoCountry" to "US", "AvatarId" to "", "IsSubscriber" to false, - "IsSteamSubscriber" to false, "PersonaId" to person?.personaId.orEmpty(), "IsUnderAge" to false, "UserIndex" to 0, + "Persona" to profile?.persona.orEmpty(), "SubscriberLevel" to 0, "CommerceCurrency" to "USD", "IsTrialSubscriber" to false, + "Country" to "US", "UserId" to profile?.userId.orEmpty(), "GeoCountry" to "US", "AvatarId" to "", "IsSubscriber" to false, + "IsSteamSubscriber" to false, "PersonaId" to profile?.personaId.orEmpty(), "IsUnderAge" to false, "UserIndex" to 0, ) "GetSetting" -> tag("GetSettingResponse", "Setting" to when (m.attrs["SettingId"]) { "ENVIRONMENT" -> "production" "LANGUAGE" -> locale else -> "false" }) + "GetSettings" -> tag("GetSettingsResponse", "IsIGOAvailable" to false, "IsIGOEnabled" to false, "IsTelemetryEnabled" to false, "IsManualOffline" to false) "GetGameInfo" -> tag("GetGameInfoResponse", "GameInfo" to when (m.attrs["GameInfoId"]) { "FREETRIAL" -> "false" "LANGUAGES" -> LANGUAGES @@ -403,7 +405,7 @@ object EaLsx { ) }) } - "GetPresence" -> tag("GetPresenceResponse", "UserId" to person?.userId.orEmpty(), "Presence" to "INGAME") + "GetPresence" -> tag("GetPresenceResponse", "UserId" to profile?.userId.orEmpty(), "Presence" to "INGAME") "QueryPresence" -> tag("QueryPresenceResponse", body = "") "QueryFriends" -> tag("QueryFriendsResponse", body = "") "GetBlockList" -> tag("GetBlockListResponse", "Return" to "Success", body = "") diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt index d620388c82..cf6e484f49 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientInstaller.kt @@ -5,6 +5,7 @@ import com.droiddeck.launcher.R import com.droiddeck.launcher.runtime.GuestCommand import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.stores.StoreInstallRoot +import com.droiddeck.launcher.stores.StoreInstalls import com.droiddeck.launcher.stores.download.DownloadQueue import com.droiddeck.launcher.stores.download.DownloadStage import com.droiddeck.launcher.stores.formatBytes @@ -215,7 +216,7 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow val before = EpicClient.read(app) val needApp = !(before.version == launcher.version && File(state, "app/${launcher.version}/.droiddeck-ready").isFile) val needRuntime = !(before.runtimeVersion == runtime.version && File(state, "runtime/${runtime.version}/.droiddeck-ready").isFile) - val dir = EpicClient.downloadsDir(app).apply { mkdirs() } + val dir = EpicClient.downloadsDir(app).also { StoreInstalls.awaitDiscard(it) }.apply { mkdirs() } val gles = EpicClientSources.gles() val appPart = if (needApp) Part(listOf(launcher.url), File(dir, "${launcher.version}-${EpicClientSources.LAUNCHER_FILE}"), null, true) else null val desktopParts = if (needApp) EpicClientSources.DESKTOP.map { Part(it.urls, File(dir, it.file), it.sha256, false, it.size) } else emptyList() @@ -265,7 +266,7 @@ internal class EpicClientInstaller(private val app: Context) : DownloadQueue.Dow override fun cancel(deleteFiles: Boolean) { cancelled.set(true) runCatching { connection?.disconnect() } - if (deleteFiles) EpicClient.downloadsDir(app).deleteRecursively() + if (deleteFiles) StoreInstalls.deleteLater(EpicClient.downloadsDir(app)) } private fun length(url: String): Long { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt index 8ad240e651..56e8d6e128 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.stores.gog import android.content.Context -import android.os.Environment import android.util.Log import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -9,7 +8,6 @@ import androidx.compose.runtime.setValue import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.SessionEvents -import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionState import com.droiddeck.launcher.stores.Store import com.droiddeck.launcher.stores.AchievementNotifications @@ -143,14 +141,13 @@ object GogComet { val pb = if (com.droiddeck.launcher.runtime.NativeGuest.forSession(context)) { val root = LinuxRuntime.rootDir(context) com.droiddeck.launcher.runtime.NativeGuest.processBuilder(context, root, - LinuxRuntime.binds(context, null, null, Environment.getExternalStorageDirectory(), null), guest).redirectErrorStream(true) + LinuxRuntime.binds(context, null, null, LinuxRuntime.sharedStorage(context), null), guest).redirectErrorStream(true) } else { - ProcessBuilder(LinuxRuntime.command(context, null, null, Environment.getExternalStorageDirectory(), guest)).redirectErrorStream(true).also { + ProcessBuilder(LinuxRuntime.command(context, null, null, LinuxRuntime.sharedStorage(context), guest)).redirectErrorStream(true).also { it.environment().apply { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamClient.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamClient.kt new file mode 100644 index 0000000000..6574a31380 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamClient.kt @@ -0,0 +1,130 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import android.os.Environment +import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.AddedGames +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameStorage +import com.droiddeck.launcher.session.SecondaryLibrary +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionService +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.SteamLibraries +import com.droiddeck.launcher.stores.StoreInstallRoot +import org.json.JSONArray +import org.json.JSONObject +import java.io.File + +/** The active Steam client's folders as the app sees them. Reads storage; call off the main thread. */ +internal object SteamClient { + const val X86_64 = "x86_64" + + class Target( + val library: SteamLibraryFolders.Library, val engineHost: File, val label: String, + val freeBytes: Long, val removable: Boolean, val folder: Boolean, + ) + + fun activeArch(context: Context): String = SessionPrefs.activeSteamClientArch(context) + + private fun guestHome(arch: String) = if (arch == X86_64) "/root/.droiddeck-x64" else "/root" + + fun guestRoot(arch: String) = "${guestHome(arch)}/.local/share/Steam" + + private fun aliases(arch: String) = listOf(guestRoot(arch), "${guestHome(arch)}/.steam/steam", "${guestHome(arch)}/.steam/root") + + /** [guest] names [library]; the main library also answers to the client's other spellings of its root. */ + fun sameLibrary(context: Context, library: SteamLibraryFolders.Library, guest: String): Boolean { + if (library.guest == guest) return true + if (!library.main) return false + val arch = activeArch(context) + val wanted = SteamLibraryFolders.normalize(guest) ?: return false + return (aliases(arch) + guestRoot(arch)).mapNotNull(SteamLibraryFolders::normalize).contains(wanted) + } + + fun root(context: Context, arch: String = activeArch(context)): File = SessionPrefs.steamRoot(context, arch) + + fun registry(context: Context, arch: String = activeArch(context)): File = + File(LinuxRuntime.rootDir(context), guestHome(arch).removePrefix("/") + "/.steam/registry.vdf") + + fun loginUsers(context: Context, arch: String = activeArch(context)): File = File(root(context, arch), "config/loginusers.vdf") + + fun language(context: Context): String = + runCatching { SteamLibraryFolders.language(registry(context).readText()) }.getOrNull() ?: "english" + + fun mounts(context: Context): List { + val out = ArrayList() + GameStorage.effective(context)?.let { card -> SecondaryLibrary.CARD_GUESTS.forEach { out += SteamLibraryFolders.Mount(it, File(card.path)) } } + SteamLibraries.list(context).forEach { out += SteamLibraryFolders.Mount(it.guest, it.host) } + AddedGames.roots(context).forEach { out += SteamLibraryFolders.Mount(it.guest, it.host) } + StoreInstallRoot.externalRoots(context).forEach { (host, guest) -> out += SteamLibraryFolders.Mount(guest, host) } + out += SteamLibraryFolders.Mount("/root/Storage", Environment.getExternalStorageDirectory()) + return out + } + + /** Every library the client lists in libraryfolders.vdf that maps to a folder of the app. */ + fun libraries(context: Context, arch: String = activeArch(context)): List { + val root = root(context, arch) + val text = runCatching { File(root, "steamapps/libraryfolders.vdf").readText() }.getOrNull().orEmpty() + return SteamLibraryFolders.resolve( + SteamLibraryFolders.parse(text), guestRoot(arch), aliases(arch), root, mounts(context), LinuxRuntime.rootDir(context), + ) + } + + private fun canonical(file: File): String = runCatching { file.canonicalPath }.getOrDefault(file.absolutePath) + + /** The card and added libraries are written through the raw card view when Android allows it, as the session binds them. */ + private fun engineView(context: Context): (File) -> File { + val bases = listOfNotNull(GameStorage.effective(context)?.let { File(it.path) }) + SteamLibraries.list(context).map { it.host } + val seen = HashMap() + return { host -> + val path = host.absolutePath + val base = bases.filter { path == it.absolutePath || path.startsWith(it.absolutePath + "/") }.maxByOrNull { it.absolutePath.length } + if (base == null) host else { + val content = seen.getOrPut(base.absolutePath) { SecondaryLibrary.contentPath(base) } + if (content.absolutePath == base.absolutePath) host + else path.removePrefix(base.absolutePath).trimStart('/').let { if (it.isEmpty()) content else File(content, it) } + } + } + } + + class EngineLibraries(val libraries: List>) { + val json: String get() = JSONArray().apply { + for ((library, host) in libraries) put(JSONObject().put("host", host.absolutePath).put("guest", library.guest)) + }.toString() + + fun hostOf(library: SteamLibraryFolders.Library): File = + libraries.firstOrNull { it.first.guest == library.guest }?.second ?: library.host + } + + fun engineLibraries(context: Context, arch: String = activeArch(context)): EngineLibraries { + val view = engineView(context) + return EngineLibraries(libraries(context, arch).filter { it.host.isDirectory }.map { it to view(it.host) }) + } + + fun targets(context: Context): List { + val arch = activeArch(context) + val card = GameStorage.effective(context)?.let { canonical(File(it.path)) } + val known = Library.steamLibraries(context, arch).associate { (host, label) -> + canonical(host) to if (label == "internal") context.getString(R.string.games_internal) else label + } + val engine = engineLibraries(context) + return engine.libraries.mapNotNull { (library, host) -> + if (!library.host.isDirectory || !library.host.canWrite()) return@mapNotNull null + val path = canonical(library.host) + val onCard = card != null && (path == card || path.startsWith("$card/")) + val label = library.label.ifBlank { + if (library.main) context.getString(R.string.stores_target_internal) else known[path] ?: File(library.guest).name + } + Target(library, host, label, StoreInstallRoot.availableBytes(host), removable = onCard, folder = !library.main && !onCard) + } + } + + /** True while a session that can run the Steam client is up or starting. */ + fun clientMayRun(): Boolean { + val up = SessionState.running || (SessionState.phase != SessionPhase.IDLE && SessionState.phase != SessionPhase.FAILED) + return up && SessionState.mode != SessionService.MODE_RUN + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamEngine.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamEngine.kt new file mode 100644 index 0000000000..826d7ab0c5 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamEngine.kt @@ -0,0 +1,102 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import android.os.SystemClock +import android.util.Log +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.stores.StoresNative +import org.json.JSONArray +import org.json.JSONObject + +/** Blocking calls into the Rust engine; they reach the network, so never on the main thread. */ +internal object SteamEngine { + private const val TAG = "SteamEngine" + const val MISSING = "engine_missing" + const val MISSING_TEXT = "Steam: the store engine is not available" + + private const val RETRY_MS = 60_000L + /** After Steam refuses sign-ins for coming too often, wait well past its limit. */ + private const val THROTTLED_MS = 30 * 60_000L + + private val lock = Any() + @Volatile private var signedIn = false + /** The saved login the last sign-in attempt read, so a refusal rejects that login and not one saved since. */ + @Volatile var attempted: String? = null + private set + private var failed: JSONObject? = null + private var failedAt = 0L + + fun failure(error: String): JSONObject = JSONObject().put("ok", false).put("error", error) + + private fun call(op: String, block: () -> String): JSONObject { + if (!StoresNative.ensureLoaded()) return failure(MISSING) + val text = try { + block() + } catch (e: UnsatisfiedLinkError) { + Log.w(TAG, "$op: not in this engine build") + return failure(MISSING) + } catch (t: Throwable) { + Log.w(TAG, "$op: ${t.javaClass.simpleName}") + return failure(t.javaClass.simpleName) + } + return runCatching { JSONObject(text) }.getOrElse { failure("$op: unreadable answer") } + } + + fun signIn(context: Context): JSONObject { + synchronized(lock) { + if (signedIn) return JSONObject().put("ok", true) + failed?.takeIf { SystemClock.elapsedRealtime() - failedAt < waitAfter(it) }?.let { return it } + val roots = JSONArray() + .put(SessionPrefs.steamRoot(context, "arm64").absolutePath) + .put(SessionPrefs.steamRoot(context, SteamClient.X86_64).absolutePath) + val registry = SteamClient.registry(context).absolutePath + attempted = SteamStore.fingerprint(context) + val answer = call("signIn") { SteamNative.nativeSignIn(roots.toString(), registry, "") } + signedIn = answer.optBoolean("ok") + failed = if (signedIn) null else answer + failedAt = SystemClock.elapsedRealtime() + if (!signedIn) Log.w(TAG, "sign-in: ${answer.optString("error")}") + return answer + } + } + + private fun waitAfter(failure: JSONObject): Long { + val error = failure.optString("error") + return if ("RateLimitExceeded" in error || "Throttle" in error) THROTTLED_MS else RETRY_MS + } + + fun forget() { + synchronized(lock) { + failed = null + if (!signedIn) return + signedIn = false + try { + SteamNative.nativeSignOut() + } catch (t: Throwable) { + Log.w(TAG, "sign-out: ${t.javaClass.simpleName}") + } + } + } + + private fun signedCall(context: Context, op: String, block: () -> String): JSONObject { + synchronized(lock) { + val signIn = signIn(context) + if (!signIn.optBoolean("ok")) return signIn + val answer = call(op, block) + val error = answer.optString("error").lowercase() + if (!answer.optBoolean("ok") && listOf("logon", "sign", "session", "connect").any { it in error }) signedIn = false + return answer + } + } + + fun library(context: Context): JSONObject = signedCall(context, "library") { SteamNative.nativeLibrary() } + + fun plan(context: Context, appId: Int, language: String): JSONObject = + signedCall(context, "plan") { SteamNative.nativePlan(appId, language) } + + fun uninstall(appId: Int, steamRoot: String, host: String, guest: String, roots: String): JSONObject { + synchronized(lock) { + return call("uninstall") { SteamNative.nativeUninstall(appId, steamRoot, host, guest, roots) } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamInstallJob.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamInstallJob.kt new file mode 100644 index 0000000000..dac4beb222 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamInstallJob.kt @@ -0,0 +1,144 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import com.droiddeck.launcher.R +import com.droiddeck.launcher.stores.download.DownloadQueue +import com.droiddeck.launcher.stores.download.DownloadStage +import com.droiddeck.launcher.stores.download.StoreDownloadTier +import org.json.JSONObject +import java.io.File +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicReference + +/** Called by the engine on its own threads. */ +interface SteamInstallListener { + fun onProgress(doneBytes: Long, totalBytes: Long, phase: String?) + fun onComplete(ok: Boolean, result: String?) +} + +internal class SteamInstallJob( + private val app: Context, + private val appId: Int, + private val libraryGuest: String, +) : DownloadQueue.DownloadJob { + private val cancelled = AtomicBoolean(false) + private val started = AtomicBoolean(false) + @Volatile private var discard = false + @Volatile private var installDir: String? = null + @Volatile private var createdDir = false + + override fun run(handle: DownloadQueue.JobHandle): String? { + started.set(true) + try { + return install(handle) + } finally { + if (discard) SteamStore.discardPartial(app, appId, libraryGuest, installDir, createdDir) + } + } + + private fun install(handle: DownloadQueue.JobHandle): String? { + handle.stage(DownloadStage.MANIFEST) + if (SteamClient.clientMayRun()) throw IllegalStateException(app.getString(R.string.steam_store_close_steam)) + val engine = SteamClient.engineLibraries(app) + val target = engine.libraries.firstOrNull { SteamClient.sameLibrary(app, it.first, libraryGuest) } + ?: throw IllegalStateException(app.getString(R.string.game_sync_err_steam_library)) + val signIn = SteamEngine.signIn(app) + if (!signIn.optBoolean("ok")) { + SteamStore.signInFailed(app, signIn.optString("error")) + throw IllegalStateException(SteamStore.errorText(app, signIn)) + } + val language = SteamClient.language(app) + val (plan, planned) = SteamStore.plan(app, appId, language) + if (plan == null) throw IllegalStateException(SteamStore.errorText(app, planned)) + installDir = plan.installDir + createdDir = SteamStore.claimFolder(app, appId, libraryGuest, File(target.second, "steamapps/common/${plan.installDir}")) + if (plan.installBytes > 0) handle.diskSize(plan.installBytes) + if (cancelled.get()) return null + + val tier = StoreDownloadTier.current(app) + val journal = File(app.filesDir, "${SteamStore.JOURNAL}/$appId").apply { mkdirs() } + handle.log("steam: $appId tier=${tier.id} window=${tier.networkWindow} process_workers=${tier.processWorkers}") + val done = CountDownLatch(1) + val succeeded = AtomicBoolean(false) + val answer = AtomicReference("") + val listener = object : SteamInstallListener { + private var stage: DownloadStage? = null + private var shown = -1L + + override fun onProgress(doneBytes: Long, totalBytes: Long, phase: String?) { + synchronized(this) { + val now = SteamLibraryFolders.stageOf(phase.orEmpty()) + if (now != stage) { + stage = now + shown = -1L + } + if (doneBytes < shown) return + shown = doneBytes + if (now == DownloadStage.DOWNLOAD) handle.progress(doneBytes, totalBytes) + else { + handle.stage(now) + if (totalBytes > 0) handle.stageProgress(doneBytes, totalBytes, bytes = true) + } + } + } + + override fun onComplete(ok: Boolean, result: String?) { + answer.set(result.orEmpty()) + succeeded.set(ok) + done.countDown() + } + } + val native = try { + SteamNative.nativeStart( + appId, language, SteamClient.root(app).absolutePath, target.second.absolutePath, target.first.guest, engine.json, + journal.absolutePath, "", tier.networkWindow.coerceIn(1, 128), tier.processWorkers, listener, + ) + } catch (e: UnsatisfiedLinkError) { + throw IllegalStateException(SteamEngine.MISSING_TEXT) + } + if (native == 0L && done.count > 0L) throw IllegalStateException(SteamStore.errorText(app, parse(answer.get()))) + if (native != 0L) { + try { + var forwarded = false + while (true) { + val finished = try { + done.await(CANCEL_POLL_MS, TimeUnit.MILLISECONDS) + } catch (e: InterruptedException) { + cancelled.set(true) + false + } + if (finished) break + if (!forwarded && cancelled.get()) { + runCatching { SteamNative.nativeCancel(native) } + forwarded = true + } + } + } finally { + runCatching { SteamNative.nativeRelease(native) } + } + } + val result = parse(answer.get()) + if (succeeded.get() && result.optBoolean("ok", true)) { + SteamStore.forgetJournal(app, appId, libraryGuest, target.first.guest) + return File(target.first.host, "steamapps/common/${plan.installDir}").path + } + if (cancelled.get() || result.optString("error") == "cancelled") return null + throw IllegalStateException(SteamStore.errorText(app, result)) + } + + private fun parse(text: String): JSONObject = + runCatching { JSONObject(text) }.getOrElse { SteamEngine.failure(text.ifBlank { "install failed" }) } + + override fun cancel(deleteFiles: Boolean) { + cancelled.set(true) + if (!deleteFiles) return + discard = true + if (!started.get()) SteamStore.discardPartial(app, appId, libraryGuest, null, SteamStore.createdFolder(app, appId, libraryGuest)) + } + + private companion object { + const val CANCEL_POLL_MS = 250L + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamLibraryFolders.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamLibraryFolders.kt new file mode 100644 index 0000000000..c22f365acc --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamLibraryFolders.kt @@ -0,0 +1,170 @@ +package com.droiddeck.launcher.stores.steam + +import com.droiddeck.launcher.storage.SteamStorage +import com.droiddeck.launcher.stores.download.DownloadStage +import java.io.File + +internal object SteamLibraryFolders { + data class Folder(val path: String, val label: String) + + class Mount(guest: String, val host: File) { + val guest: String = guest.trimEnd('/') + } + + data class Library(val guest: String, val host: File, val label: String, val main: Boolean) + + data class Installed(val appId: Int, val name: String, val installDir: String?, val library: Library, val sizeOnDisk: Long) + + /** Guest folders that exist only as binds of the session; without their bind they are empty mount points in the rootfs. */ + val BIND_ONLY = listOf("/mnt", "/media", "/storage", "/sdcard", "/root/Storage", "/root/ROMs", "/root/Games") + + private val TOKEN = Regex("\"((?:\\\\.|[^\"\\\\])*)\"|[{}]|//[^\n]*") + private val ACF = Regex("appmanifest_\\d+\\.acf") + private val SIZE_ON_DISK = Regex("^\\s*\"SizeOnDisk\"\\s*\"(\\d+)\"", setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE)) + + private fun walk(text: String, pair: (blocks: List, key: String, value: String) -> Unit, closed: (blocks: List) -> Unit = {}) { + val blocks = ArrayList() + var key: String? = null + for (m in TOKEN.findAll(text)) { + val token = m.value + when { + token.startsWith("//") -> {} + token == "{" -> { blocks.add(key.orEmpty()); key = null } + token == "}" -> { if (blocks.isNotEmpty()) { closed(blocks); blocks.removeAt(blocks.lastIndex) }; key = null } + key == null -> key = unescape(m.groupValues[1]) + else -> { pair(blocks, key, unescape(m.groupValues[1])); key = null } + } + } + } + + private fun unescape(s: String): String { + if ('\\' !in s) return s + val out = StringBuilder(s.length) + var i = 0 + while (i < s.length) { + if (s[i] == '\\' && i + 1 < s.length) { out.append(s[i + 1]); i += 2 } else { out.append(s[i]); i++ } + } + return out.toString() + } + + private fun inRoot(blocks: List) = blocks.firstOrNull()?.equals("libraryfolders", ignoreCase = true) == true + + fun parse(text: String): List { + val out = ArrayList() + var path: String? = null + var label = "" + walk(text, pair = { blocks, key, value -> + if (!inRoot(blocks)) return@walk + if (blocks.size == 1 && key.isNotEmpty() && key.all(Char::isDigit)) out += Folder(value, "") + if (blocks.size == 2) when (key.lowercase()) { + "path" -> path = value + "label" -> label = value + } + }, closed = { blocks -> + if (blocks.size == 2 && inRoot(blocks)) path?.let { out += Folder(it, label) } + if (blocks.size == 2) { path = null; label = "" } + }) + return out + } + + fun normalize(path: String): String? { + val p = path.trim().replace(Regex("/+"), "/").trimEnd('/') + if (!p.startsWith("/") || p.split('/').any { it == ".." || it == "." }) return null + return p + } + + private fun under(path: String, prefix: String) = path == prefix || path.startsWith("$prefix/") + + fun hostFor(guest: String, mounts: List, rootfs: File): File? { + val path = normalize(guest) ?: return null + mounts.filter { it.guest.isNotEmpty() && under(path, it.guest) }.maxByOrNull { it.guest.length }?.let { m -> + val rest = path.removePrefix(m.guest).trimStart('/') + return if (rest.isEmpty()) m.host else File(m.host, rest) + } + if (BIND_ONLY.any { under(path, it) } || !under(path, "/root")) return null + return File(rootfs, path.removePrefix("/")) + } + + fun resolve(folders: List, mainGuest: String, aliases: Collection, mainHost: File, mounts: List, rootfs: File): List { + val mains = (aliases + mainGuest).mapNotNull(::normalize).toSet() + val listed = if (folders.any { normalize(it.path) in mains }) folders else listOf(Folder(mainGuest, "")) + folders + val out = ArrayList() + // The main library first, so an entry reaching the same folder under another path cannot take its place. + for (f in listed.sortedByDescending { normalize(it.path) in mains }) { + val guest = normalize(f.path) ?: continue + val main = guest in mains + val host = if (main) mainHost else hostFor(guest, mounts, rootfs) ?: continue + if (out.any { it.host.path == host.path || (main && it.main) }) continue + out += Library(guest, host, f.label.trim(), main) + } + return out.sortedByDescending { it.main } + } + + fun installed(libraries: List, read: (File) -> String? = { runCatching { it.readText() }.getOrNull() }): Map { + val out = LinkedHashMap() + for (library in libraries) { + val apps = File(library.host, "steamapps") + val names = apps.list() ?: continue + for (name in names.sorted()) { + if (!ACF.matches(name)) continue + val file = File(apps, name) + val text = read(file) ?: continue + val manifest = SteamStorage.parseManifest(file, text) ?: continue + if (!manifest.installed || SteamStorage.isTool(manifest) || manifest.appId in out) continue + val size = SIZE_ON_DISK.find(text)?.groupValues?.get(1)?.toLongOrNull() ?: 0L + out[manifest.appId] = Installed(manifest.appId, manifest.name, manifest.installDir, library, size) + } + } + return out + } + + data class SavedAccount(val id: String, val name: String) + + fun savedAccount(loginUsers: String): String? = savedLogin(loginUsers)?.name + + /** + * The account the client signs in with by itself, chosen as the engine does: `AutoLoginUser`, else the most recent, else the newest; + * none when that account opted out of Remember me. [SavedAccount.id] is its SteamID64. + */ + fun savedLogin(loginUsers: String, registry: String = ""): SavedAccount? { + val users = LinkedHashMap>() + walk(loginUsers, pair = { blocks, key, value -> + if (blocks.size == 2 && blocks[0].equals("users", ignoreCase = true)) users.getOrPut(blocks[1]) { HashMap() }[key.lowercase()] = value + }) + val accounts = users.entries.filter { it.key.all(Char::isDigit) && !it.value["accountname"].isNullOrBlank() } + val auto = autoLoginUser(registry) + val (id, user) = auto?.let { name -> accounts.firstOrNull { it.value["accountname"].equals(name, ignoreCase = true) } } + ?: accounts.firstOrNull { it.value["mostrecent"] == "1" } + ?: accounts.maxByOrNull { it.value["timestamp"]?.toLongOrNull() ?: 0L } + ?: return null + if (user["rememberpassword"] == "0") return null + val name = user["personaname"]?.takeIf { it.isNotBlank() } ?: user["accountname"]?.takeIf { it.isNotBlank() } ?: return null + return SavedAccount(id, name) + } + + fun autoLoginUser(registry: String): String? { + var found: String? = null + walk(registry, pair = { blocks, key, value -> + if (found == null && key.equals("AutoLoginUser", ignoreCase = true) && blocks.lastOrNull().equals("Steam", ignoreCase = true) && value.isNotBlank()) found = value + }) + return found + } + + fun language(registry: String): String? { + var found: String? = null + walk(registry, pair = { blocks, key, value -> + if (found == null && key.equals("language", ignoreCase = true) && blocks.lastOrNull().equals("Steam", ignoreCase = true) && value.isNotBlank()) found = value + }) + return found + } + + fun stageOf(phase: String): DownloadStage { + val p = phase.lowercase() + return when { + "verif" in p || "validat" in p -> DownloadStage.VERIFY + listOf("install", "regist", "final", "commit", "acf", "apply").any { it in p } -> DownloadStage.INSTALL + listOf("manifest", "plan", "prepar", "check", "scan", "clean", "alloc", "connect", "logon", "login", "sign").any { it in p } -> DownloadStage.MANIFEST + else -> DownloadStage.DOWNLOAD + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamNative.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamNative.kt new file mode 100644 index 0000000000..bce35d4500 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamNative.kt @@ -0,0 +1,12 @@ +package com.droiddeck.launcher.stores.steam + +object SteamNative { + @JvmStatic external fun nativeSignIn(steamRootsJson: String, registryVdfPath: String, caBundlePath: String): String + @JvmStatic external fun nativeSignOut() + @JvmStatic external fun nativeLibrary(): String + @JvmStatic external fun nativePlan(appId: Int, language: String): String + @JvmStatic external fun nativeStart(appId: Int, language: String, steamRoot: String, gameLibraryHost: String, gameLibraryGuest: String, libraryRootsJson: String, journalDir: String, caBundlePath: String, maxWorkers: Int, processWorkers: Int, listener: Any): Long + @JvmStatic external fun nativeCancel(handle: Long) + @JvmStatic external fun nativeRelease(handle: Long) + @JvmStatic external fun nativeUninstall(appId: Int, steamRoot: String, gameLibraryHost: String, gameLibraryGuest: String, libraryRootsJson: String): String +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamStore.kt b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamStore.kt new file mode 100644 index 0000000000..bbcd1f425d --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/steam/SteamStore.kt @@ -0,0 +1,394 @@ +package com.droiddeck.launcher.stores.steam + +import android.content.Context +import android.content.Intent +import android.net.Uri +import android.util.Log +import android.widget.Toast +import androidx.annotation.StringRes +import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.session.SessionService +import com.droiddeck.launcher.storage.SteamStorage +import com.droiddeck.launcher.stores.CatalogItem +import com.droiddeck.launcher.stores.InstalledStoreGame +import com.droiddeck.launcher.stores.Store +import com.droiddeck.launcher.stores.StoreAccounts +import com.droiddeck.launcher.stores.StoreBackend +import com.droiddeck.launcher.stores.StoreInstallRoot +import com.droiddeck.launcher.stores.StoreInstalls +import com.droiddeck.launcher.stores.StoreSizes +import com.droiddeck.launcher.stores.StoresState +import com.droiddeck.launcher.stores.download.DownloadEntry +import com.droiddeck.launcher.stores.download.DownloadQueue +import com.droiddeck.launcher.stores.download.DownloadState +import com.droiddeck.launcher.stores.download.SavedQueue +import com.droiddeck.launcher.stores.formatBytes +import org.json.JSONArray +import org.json.JSONObject +import java.io.File +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.Executors + +/** Games land in the active client's own libraries, registered as the client does, and only while no session can run the client. */ +internal object SteamStore { + private const val TAG = "SteamStore" + private const val PREFS = "steam-store" + internal const val JOURNAL = "steam-store/journal" + private const val CDN = "https://cdn.cloudflare.steamstatic.com/steam/apps/" + private const val LIBRARY = "library" + private const val LIBRARY_LABEL = "libraryLabel" + private val SIGNED_OUT = setOf("no_saved_login", "remember_me_off", "decrypt_failed") + private val REFUSED = Regex("logon_failed: eresult=(-?\\d+).*") + /** InvalidPassword, AccessDenied, AccountNotFound, Revoked, Expired, AccountLogonDenied. */ + private val REFUSALS = setOf(5, 15, 18, 26, 27, 63) + + class Plan(val installDir: String, val downloadBytes: Long, val installBytes: Long, val buildId: String, val linuxBuild: Boolean) { + companion object { + fun of(json: JSONObject): Plan? { + if (!json.optBoolean("ok")) return null + val dir = json.optString("installDir").takeIf { SteamStore.validDir(it) } ?: return null + return Plan(dir, json.optLong("downloadBytes"), json.optLong("installBytes"), json.optString("buildId"), json.optBoolean("linuxBuild")) + } + } + } + + internal const val LINUX_BUILD = "linux_build" + + /** Each plan with the language it was made for. */ + private val plans = ConcurrentHashMap>() + private val work = Executors.newSingleThreadExecutor { r -> Thread(r, "steam-store") } + @Volatile private var rejectedThisRun: String? = null + + fun key(appId: Int): String = "${Store.STEAM.id}:$appId" + + private fun validDir(dir: String) = dir.isNotBlank() && dir != "." && dir != ".." && '/' !in dir && '\\' !in dir + + private fun prefs(context: Context) = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE) + + private fun toast(context: Context, @StringRes text: Int) { + val app = context.applicationContext + StoresState.post { Toast.makeText(app, text, Toast.LENGTH_LONG).show() } + } + + /** Steam refusing the saved login; a connection failure or a throttled logon leaves the account as it is. */ + internal fun isSignInError(error: String) = + error in SIGNED_OUT || REFUSED.matchEntire(error)?.groupValues?.get(1)?.toIntOrNull() in REFUSALS + + internal fun errorText(context: Context, answer: JSONObject): String { + val error = answer.optString("error") + return when { + error == SteamEngine.MISSING -> SteamEngine.MISSING_TEXT + error == LINUX_BUILD -> context.getString(R.string.steam_store_linux_build) + isSignInError(error) -> context.getString(R.string.stores_login_title, Store.STEAM.label) + error.isBlank() -> "Steam: install failed" + else -> error + } + } + + internal fun fingerprint(context: Context): String { + val users = SteamClient.loginUsers(context) + val registry = SteamClient.registry(context) + return "${SteamClient.activeArch(context)}:${users.lastModified()}:${users.length()}:${registry.lastModified()}:${registry.length()}" + } + + private fun savedAccount(context: Context): SteamLibraryFolders.SavedAccount? { + val print = fingerprint(context) + if (print == rejectedThisRun || print == prefs(context).getString("rejected", null)) return null + val registry = runCatching { SteamClient.registry(context).readText() }.getOrDefault("") + return runCatching { SteamLibraryFolders.savedLogin(SteamClient.loginUsers(context).readText(), registry) }.getOrNull() + } + + /** Mirrors the client's saved sign-in into the store account; reads storage. A new name for the same account only relabels it. */ + fun syncAccount(context: Context): Boolean { + val saved = savedAccount(context) + val stored = StoreAccounts.read(context, Store.STEAM) + val storedId = stored?.optString("steam_id").orEmpty() + if (saved != null && saved.id == storedId) { + if (saved.name != stored?.optString("display_name")) { + StoreAccounts.write(context, Store.STEAM, JSONObject().put("display_name", saved.name).put("steam_id", saved.id)) + } + return false + } + if (saved == null && stored == null) return false + if (saved == null) StoreAccounts.clear(context, Store.STEAM) + else StoreAccounts.write(context, Store.STEAM, JSONObject().put("display_name", saved.name).put("steam_id", saved.id)) + plans.clear() + SteamEngine.forget() + StoresState.post { + StoresState.library.remove(Store.STEAM) + StoresState.problems.remove(Store.STEAM) + } + Log.i(TAG, if (saved == null) "no saved Steam sign-in" else "Steam sign-in found") + return true + } + + internal fun signInFailed(context: Context, error: String) { + if (!isSignInError(error)) return + val print = fingerprint(context) + if (SteamEngine.attempted?.let { it != print } == true) return + rejectedThisRun = print + if (error in SIGNED_OUT) prefs(context).edit().putString("rejected", print).apply() + StoreAccounts.clear(context, Store.STEAM) + StoresState.logLine("Steam: the saved sign-in was not accepted ($error)") + StoresState.post { + StoresState.accounts.remove(Store.STEAM) + StoresState.library.remove(Store.STEAM) + } + } + + fun downloading(): Boolean = StoresState.latestDownloads.any { + it.store == Store.STEAM && (it.state == DownloadState.RUNNING || it.state == DownloadState.QUEUED) + } + + /** A Steam store download holds every session that could start the Steam client. */ + fun blocksSession(intent: Intent?): Boolean { + val mode = intent?.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM + return mode != SessionService.MODE_RUN && (downloading() || StoresState.uninstalling.keys.any { it.startsWith("${Store.STEAM.id}:") }) + } + + internal fun syncLibrary(context: Context, force: Boolean) { + val app = context.applicationContext + if (force) plans.clear() + work.execute { + val answer = SteamEngine.library(app) + if (!answer.optBoolean("ok")) { + val error = answer.optString("error") + if (isSignInError(error)) signInFailed(app, error) + else StoresState.post { + StoresState.problems[Store.STEAM] = errorText(app, answer) + StoresState.library[Store.STEAM] = emptyList() + } + return@execute + } + val art = runCatching { Library.steamLibraryArt(app).toMap() }.getOrDefault(emptyMap()) + val items = items(answer.optJSONArray("games"), art) + StoresState.logLine("Steam: library has ${items.size} games") + StoresState.post { + StoresState.problems.remove(Store.STEAM) + StoresState.library[Store.STEAM] = items + } + } + } + + private fun items(games: JSONArray?, art: Map): List { + val out = ArrayList() + for (i in 0 until (games?.length() ?: 0)) { + val game = games?.optJSONObject(i) ?: continue + val id = game.optInt("appId").takeIf { it > 0 } ?: continue + val type = game.optString("type").lowercase() + if (type.isNotEmpty() && type != "game") continue + val name = game.optString("name").takeIf { it.isNotBlank() } ?: continue + out += CatalogItem( + Store.STEAM, id.toString(), name, + imageUrl = "$CDN$id/header.jpg", + tallImageUrl = art[id]?.let { Uri.fromFile(it).toString() } ?: "$CDN$id/library_600x900.jpg", + isFree = game.optBoolean("free"), + storeUrl = "https://store.steampowered.com/app/$id/", + owned = true, + ) + } + return out.distinctBy { it.id }.sortedBy { it.title.lowercase() } + } + + /** Reaches the network; call off the main thread. */ + internal fun plan(context: Context, appId: Int, language: String = SteamClient.language(context)): Pair { + val plan = plans[appId]?.takeIf { it.first == language }?.second ?: run { + val answer = SteamEngine.plan(context, appId, language) + val error = answer.optString("error") + if (isSignInError(error)) signInFailed(context, error) + Plan.of(answer)?.also { plans[appId] = language to it } ?: return null to answer + } + if (plan.linuxBuild && !protonMapped(context, appId)) return null to SteamEngine.failure(LINUX_BUILD) + return plan to JSONObject().put("ok", true) + } + + /** The engine installs the Windows depots; a game with a Linux build gets those from the client only when it is mapped to a Proton. */ + private fun protonMapped(context: Context, appId: Int): Boolean { + val config = runCatching { File(SteamClient.root(context), "config/config.vdf").readText() }.getOrNull() ?: return false + return SteamStorage.compatMappings(config)[appId.toString()]?.contains("proton", ignoreCase = true) == true + } + + internal fun plannedBytes(context: Context, item: CatalogItem): Long = + item.id.toIntOrNull()?.let { plan(context, it).first?.installBytes } ?: 0L + + fun requestInstall(context: Context, item: CatalogItem) { + if (SteamClient.clientMayRun()) { + toast(context, R.string.steam_store_close_steam) + return + } + StoresState.steamPicking = item + } + + fun install(context: Context, item: CatalogItem, target: SteamClient.Target) { + val app = context.applicationContext + val appId = item.id.toIntOrNull() ?: return + if (SteamClient.clientMayRun()) { + toast(app, R.string.steam_store_close_steam) + return + } + val plan = plans[appId]?.second + val needed = plan?.installBytes ?: 0L + val tagged = item.copy(extra = item.extra + mapOf(LIBRARY to target.library.guest, LIBRARY_LABEL to target.label)) + val entry = DownloadEntry( + Store.STEAM, item.id, item.title, cover = item.imageUrl, + bytesTotal = plan?.downloadBytes ?: 0L, location = target.label, + ) + SavedQueue.remember(app, tagged, target.library.host) + if (StoreInstallRoot.insufficientSpace(needed, target.freeBytes)) { + val error = app.getString(R.string.stores_storage_insufficient, formatBytes(needed), formatBytes(target.freeBytes)) + DownloadQueue.recordFailed(app, entry, error) { requestInstall(app, item) } + return + } + DownloadQueue.enqueue(app, entry) { SteamInstallJob(app, appId, target.library.guest) } + } + + internal fun restore(context: Context, item: CatalogItem) { + val app = context.applicationContext + val appId = item.id.toIntOrNull() ?: return + val guest = item.extra[LIBRARY] ?: return + work.execute { + // Either client may have finished the install from where this download was paused. + if (installedByAClient(app, appId)) { + DownloadQueue.dropHeld(key(appId)) + StoresState.logLine("Steam: \"${item.title}\" was finished by Steam; its saved download is dropped") + return@execute + } + StoresState.post { + SavedQueue.remember(app, item, null) + val entry = DownloadEntry(Store.STEAM, item.id, item.title, cover = item.imageUrl, location = item.extra[LIBRARY_LABEL].orEmpty()) + DownloadQueue.enqueue(app, entry) { SteamInstallJob(app, appId, guest) } + } + } + } + + private fun installedByAClient(context: Context, appId: Int): Boolean = listOf("arm64", SteamClient.X86_64).any { arch -> + runCatching { appId in SteamLibraryFolders.installed(SteamClient.libraries(context, arch)) }.getOrDefault(false) + } + + /** Removes a game like the client does; [fallback] deletes it when the engine cannot (no engine, or a library it does not map). */ + fun uninstall(context: Context, appId: Int, manifest: File?, fallback: () -> Boolean, onDone: () -> Unit = {}) { + val app = context.applicationContext + if (SteamClient.clientMayRun()) { + toast(app, R.string.steam_store_close_steam) + return + } + val key = key(appId) + if (key in StoresState.uninstalling) return + StoresState.uninstalling[key] = 0f + Thread({ + if (!DownloadQueue.stopForRemoval(app, key)) { + StoresState.logLine("Steam: kept $appId, its download is still running") + StoresState.post { StoresState.uninstalling.remove(key); onDone() } + return@Thread + } + val answer = try { runCatching { + val apps = manifest?.parentFile?.let(::canonical) + // The game may sit in the other client's library; that client's files are the ones to update. + val active = SteamClient.activeArch(app) + val found = listOf(active, if (active == SteamClient.X86_64) "arm64" else SteamClient.X86_64).firstNotNullOfOrNull { arch -> + val libraries = SteamClient.libraries(app, arch) + val chosen = if (apps == null) libraries else libraries.filter { canonical(File(it.host, "steamapps")) == apps } + SteamLibraryFolders.installed(chosen)[appId]?.let { arch to it } + } + val answer = if (found == null) SteamEngine.failure(SteamEngine.MISSING) else { + val (arch, game) = found + val engine = SteamClient.engineLibraries(app, arch) + SteamEngine.uninstall(appId, SteamClient.root(app, arch).absolutePath, engine.hostOf(game.library).absolutePath, game.library.guest, engine.json) + } + when { + answer.optString("error") != SteamEngine.MISSING -> answer + fallback() -> JSONObject().put("ok", true) + else -> SteamEngine.failure("remove_failed") + } + }.getOrElse { SteamEngine.failure(it.javaClass.simpleName) } } finally { DownloadQueue.releaseRemoval(key) } + val ok = answer.optBoolean("ok") + StoresState.logLine(if (ok) "Steam: uninstalled $appId" else "Steam: uninstall of $appId failed: ${answer.optString("error")}") + StoresState.post { + StoresState.uninstalling.remove(key) + if (ok) StoreSizes.onDisk.remove(key) + else Toast.makeText(app, errorText(app, answer), Toast.LENGTH_LONG).show() + onDone() + } + }, "steam-uninstall").start() + } + + private fun canonical(file: File): String = runCatching { file.canonicalPath }.getOrDefault(file.absolutePath) + + /** The engine keys an app's resume journal by library as `///`. */ + private fun libraryKey(guest: String): String = + "%08x".format(java.util.zip.CRC32().apply { update(guest.trimEnd('/').toByteArray()) }.value) + + private fun createdMarker(context: Context, appId: Int, guest: String) = + File(context.filesDir, "$JOURNAL/$appId/created-${libraryKey(guest)}") + + /** Drops the resume state of one app in one library; other libraries' downloads of the app keep theirs. */ + internal fun forgetJournal(context: Context, appId: Int, guest: String, engineGuest: String? = null) { + val app = File(context.filesDir, "$JOURNAL/$appId") + val spelled = engineGuest ?: runCatching { + SteamClient.engineLibraries(context).libraries.firstOrNull { SteamClient.sameLibrary(context, it.first, guest) }?.first?.guest + }.getOrNull() ?: guest + File(app, "$appId/${libraryKey(spelled)}").deleteRecursively() + createdMarker(context, appId, guest).delete() + File(app, "$appId").delete() + app.delete() + } + + /** Whether this install made the game folder in that library: decided by its first attempt and kept for every resume. */ + internal fun claimFolder(context: Context, appId: Int, guest: String, folder: File): Boolean { + val marker = createdMarker(context, appId, guest) + if (marker.isFile) return true + if (folder.exists()) return false + marker.parentFile?.mkdirs() + return runCatching { marker.writeText(folder.name); true }.getOrDefault(false) + } + + internal fun createdFolder(context: Context, appId: Int, guest: String): Boolean = createdMarker(context, appId, guest).isFile + + /** + * Removes what a cancelled download left; a finished install stays. The game folder goes only when this download made it + * ([createdDir]) and no other installed game uses it. + */ + internal fun discardPartial(context: Context, appId: Int, guest: String, installDir: String?, createdDir: Boolean) { + // An unmounted library keeps its journal and ownership record, so a later cancel can still clean it up. + val library = runCatching { + SteamClient.engineLibraries(context).libraries.firstOrNull { SteamClient.sameLibrary(context, it.first, guest) }?.second + }.getOrNull() ?: return + val apps = File(library, "steamapps") + val acf = File(apps, "appmanifest_$appId.acf") + val manifest = acf.takeIf { it.isFile }?.let { f -> runCatching { SteamStorage.parseManifest(f, f.readText()) }.getOrNull() } + if (manifest?.installed == true) { forgetJournal(context, appId, guest); return } + val claimed = runCatching { createdMarker(context, appId, guest).readText() }.getOrNull()?.ifEmpty { null } + val dir = (installDir ?: claimed ?: manifest?.installDir ?: plans[appId]?.second?.installDir)?.takeIf { validDir(it) } + val shared = dir != null && apps.listFiles { f -> f.name.startsWith("appmanifest_") && f.name != acf.name }.orEmpty().any { f -> + runCatching { SteamStorage.parseManifest(f, f.readText()) }.getOrNull()?.installDir == dir + } + if (dir != null && createdDir && !shared) StoreInstalls.deleteTree(File(apps, "common/$dir")) + StoreInstalls.deleteTree(File(apps, "downloading/$appId")) + File(apps, "downloading").listFiles { f -> f.name.startsWith("state_${appId}_") && f.name.endsWith(".patch") }?.forEach { it.delete() } + if (manifest != null) acf.delete() + forgetJournal(context, appId, guest) + StoresState.logLine("Steam: removed the unfinished download of $appId") + } +} + +internal object SteamBackend : StoreBackend { + override val store: Store = Store.STEAM + + override fun signIn(context: Context) { + StoresState.logLine("Steam: sign in from the Steam client") + } + + override fun signOut(context: Context) = SteamEngine.forget() + + override fun syncLibrary(context: Context, force: Boolean) = SteamStore.syncLibrary(context, force) + + override fun loadShelves(context: Context, force: Boolean) {} + + override fun search(context: Context, query: String): List = + StoresState.library[store].orEmpty().filter { it.title.contains(query, ignoreCase = true) } + + override fun install(context: Context, item: CatalogItem, root: File) = SteamStore.restore(context, item) + + override fun uninstall(context: Context, game: InstalledStoreGame) {} +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt index 32597faeb7..675be0a77b 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxBackend.kt @@ -58,17 +58,30 @@ object XboxBackend : StoreBackend { if (cached != null && !cached.needsRefresh(force)) { XboxGamertag.ensure(app); return@Thread } val response = Xodus.run(app, listOf("library", "--json", "--market", market)) val licenses = XboxCatalog.access(response, account, market, report = { StoresState.logLine("Xbox: $it") }) - val products = XboxCatalog.rawProducts(licenses.keys.toList(), market) val cloud = runCatching { XboxCatalog.cloudCatalog(market) } .onFailure { StoresState.logLine("Xbox: cloud lists unavailable (${it.javaClass.simpleName})") }.getOrNull() - val games = mergeEditions(products.mapNotNull { XboxCatalog.product(it, licenses, cloud) }).sortedBy { it.title.lowercase() } - StoresState.logLine("Xbox: library catalog requested=${licenses.size} returned=${products.size} supported=${games.size} " + - "filtered=${products.size - games.size} backend-skipped=${response.optInt("skippedEntitlements")} " + + // The PC entitlement list leaves out console purchases and free games; the streaming service lists them. + val titles = runCatching { XboxCloudSession.titleList(XboxCloudSession.get(app, account), fresh = true) } + .onFailure { StoresState.logLine("Xbox: cloud titles unavailable (${it.javaClass.simpleName})") }.getOrNull() + // Without the Game Pass lists an entitled title cannot be told apart from a purchase, so none are added. + val added = if (cloud == null) emptyMap() else titles?.entitled.orEmpty().filter { it !in licenses } + .associateWith { if (it in cloud.gamePass) "gamepass" else "owned" } + StoresState.logLine("Xbox: cloud titles=${titles?.ids?.size ?: -1} entitled=${titles?.entitled?.size ?: -1} " + + "added=${added.size} (owned ${added.values.count { it == "owned" }}, gamepass ${added.values.count { it == "gamepass" }})") + val entitlements = licenses + added + val returned = java.util.concurrent.atomic.AtomicInteger() + val supported = XboxCatalog.productBatches(entitlements.keys.toList(), market) { batch -> + returned.addAndGet(batch.size) + batch.mapNotNull { XboxCatalog.product(it, entitlements, cloud) } + } + val games = mergeEditions(supported).sortedBy { it.title.lowercase() } + StoresState.logLine("Xbox: library catalog requested=${entitlements.size} returned=${returned.get()} supported=${supported.size} " + + "shown=${games.size} backend-skipped=${response.optInt("skippedEntitlements")} " + "pc=${games.count { it.xboxPc }} cloud=${games.count { it.xboxCloud }} cloud-only=${games.count { !it.xboxPc }} " + "cloud-lists=${cloud?.gamePass?.size ?: -1}/${cloud?.all?.size ?: -1}") synchronized(this) { if (current != generation || StoreAccounts.signedInAs(app, store) != account) return@Thread - access = licenses + access = entitlements runCatching { XboxLibraryCache.write(app, account, market, games) } .onFailure { StoresState.logLine("Xbox: library cache could not be saved") } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt index cd3982ebdd..405b0b955d 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCatalog.kt @@ -8,6 +8,9 @@ import org.json.JSONObject import java.time.Instant internal object XboxCatalog { + /** Package identity prefix of Microsoft's original Xbox releases for PC. */ + internal const val BACK_COMPAT_IDENTITY = "Xbox360BackwardCompatibil" + private val productId = Regex("[A-Z0-9]{12}") private val plans = setOf("CFQ7TTC0KGQ8", "CFQ7TTC0KHS0", "CFQ7TTC0P85B", "CFQ7TTC0K5DJ", "CFQ7TTC0K6L8", "CFQ7TTC10QFD") private val pcPlans = mapOf( @@ -84,10 +87,42 @@ internal object XboxCatalog { return rawProducts(ids, market).mapNotNull { product(it, access) } } - fun rawProducts(ids: List, market: String = Xodus.market()): List { - return ids.map { it.uppercase() }.filter { productId.matches(it) }.distinct().chunked(25).flatMap { batch -> + fun launchArt(id: String, market: String = Xodus.market()): List = + rawProducts(listOf(id.uppercase()), market).firstOrNull()?.let(::launchArtUrls).orEmpty() + + internal fun launchArtUrls(json: JSONObject): List { + val images = objects(objects(json.optJSONArray("LocalizedProperties")).firstOrNull()?.optJSONArray("Images")) + val order = listOf("SuperHeroArt", "TitledHeroArt", "Screenshot", "Hero") + return images.filter { it.optString("ImagePurpose") in order } + .sortedBy { order.indexOf(it.optString("ImagePurpose")) } + .mapNotNull { image -> + val raw = image.optString("Uri") + val url = if (raw.startsWith("//")) "https:$raw" else raw + runCatching { java.net.URI(url) }.getOrNull()?.takeIf { + it.scheme == "https" && it.host in setOf("store-images.s-microsoft.com", "store-images.microsoft.com") && it.userInfo == null && it.port == -1 + }?.toString() + }.distinct().take(12) + } + + fun rawProducts(ids: List, market: String = Xodus.market()): List = productBatches(ids, market) { it } + + // 25 ids per request, up to 4 requests at a time; each batch is mapped as it arrives (a whole library of raw entries is large). + fun productBatches(ids: List, market: String = Xodus.market(), map: (List) -> List): List { + val batches = ids.map { it.uppercase() }.filter { productId.matches(it) }.distinct().chunked(25) + fun fetchBatch(batch: List): List { val body = get("https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds=${batch.joinToString(",")}&market=$market&languages=en-us,neutral") - objects(body.optJSONArray("Products")).filter { it.optString("ProductId").uppercase() in batch } + return map(objects(body.optJSONArray("Products")).filter { it.optString("ProductId").uppercase() in batch }) + } + if (batches.size <= 1) return batches.flatMap(::fetchBatch) + val pool = java.util.concurrent.Executors.newFixedThreadPool(4) + try { + val tasks = batches.map { batch -> pool.submit(java.util.concurrent.Callable { fetchBatch(batch) }) } + return tasks.flatMap { task -> + try { task.get(60, java.util.concurrent.TimeUnit.SECONDS) } + catch (e: java.util.concurrent.ExecutionException) { throw e.cause ?: e } + } + } finally { + pool.shutdownNow() } } @@ -116,6 +151,13 @@ internal object XboxCatalog { .flatMap { objects(it.optJSONArray("Packages")) } val pc = packages.filter { pkg -> objects(pkg.optJSONArray("PlatformDependencies")).any { it.optString("PlatformName") == "Windows.Desktop" } } val installable = pc.any { installableFormat(it.optString("PackageFormat")) } + // An original Xbox game: its PC package is only Microsoft's emulator and an + // index; the game data comes from the console package, so that is its size. + val backCompat = pc.any { it.optString("PackageFamilyName").startsWith(BACK_COMPAT_IDENTITY, ignoreCase = true) } + val console = packages.filter { pkg -> + pkg.optString("PackageFormat").equals("XVC", true) || + objects(pkg.optJSONArray("PlatformDependencies")).any { it.optString("PlatformName") == "Windows.Xbox" } + } // The installer needs the format, not just the fact that one exists: a // legacy container takes a different subcommand from a streamed package. val format = pc.firstOrNull { installableFormat(it.optString("PackageFormat")) }?.optString("PackageFormat").orEmpty() @@ -140,7 +182,8 @@ internal object XboxCatalog { storeUrl = "https://www.xbox.com/games/store/$id", publisher = localized.optString("PublisherName"), developer = localized.optString("DeveloperName"), description = localized.optString("ProductDescription"), - sizeBytes = if (installable) pc.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } ?: 0L else 0L, + sizeBytes = if (!installable) 0L else (if (backCompat) console.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } else null) + ?.takeIf { it > 0 } ?: pc.maxOfOrNull { it.optLong("MaxDownloadSizeInBytes") } ?: 0L, extra = mapOf("market" to Xodus.market(), "access" to kind.orEmpty(), "pc" to flag(installable), "cloud" to flag(streams), "format" to format), ) @@ -180,16 +223,28 @@ val CatalogItem.xboxPc: Boolean get() = extra["pc"] != "0" val CatalogItem.xboxCloud: Boolean get() = extra["cloud"] == "1" val CatalogItem.xboxCloudId: String get() = extra["cloudId"]?.takeIf { it.isNotEmpty() } ?: id +// One card per title: a cloud-only edition folds into the PC card (which then streams, and counts as owned when +// the cloud edition is); cloud-only editions with the same title become one card, owned first. internal fun mergeEditions(games: List): List { - fun key(title: String) = title.lowercase().replace(Regex("[^a-z0-9]+"), "") + fun key(title: String): String { + val lower = title.lowercase() + val letters = StringBuilder().apply { lower.codePoints().filter { Character.isLetterOrDigit(it) }.forEach { appendCodePoint(it) } } + return letters.toString().ifEmpty { lower.trim() } + } + val pcKeys = games.filter { it.xboxPc }.map { key(it.title) }.toSet() val cloudOnly = games.filter { !it.xboxPc && it.xboxCloud }.groupBy { key(it.title) } - val folded = HashSet() - val merged = games.map { game -> - if (!game.xboxPc || game.xboxCloud) game - else cloudOnly[key(game.title)]?.firstOrNull()?.let { console -> - folded.add(console.id) - game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to console.id)) - } ?: game + .mapValues { (_, list) -> list.sortedByDescending { it.owned }.first() } + return games.mapNotNull { game -> + val console = cloudOnly[key(game.title)] + when { + !game.xboxPc -> game.takeIf { key(game.title) !in pcKeys && (console == null || console === game) } + console == null -> game + else -> { + val cloudId = if (game.xboxCloud) game.extra["cloudId"].orEmpty() else console.id + val merged = game.copy(extra = game.extra + mapOf("cloud" to "1", "cloudId" to cloudId)) + if (console.owned && !game.owned) merged.copy(owned = true, subscription = false, extra = merged.extra + ("access" to "owned")) + else merged + } + } } - return merged.filter { it.id !in folded } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt index 354850932c..cd522ff3b8 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudPlayerActivity.kt @@ -6,6 +6,7 @@ import android.content.Intent import android.graphics.Color import android.os.Bundle import android.view.Gravity +import android.view.View import android.view.KeyEvent import android.view.WindowManager import android.webkit.JavascriptInterface @@ -47,6 +48,8 @@ class XboxCloudPlayerActivity : ComponentActivity() { private lateinit var root: FrameLayout private var web: WebView? = null private var notice: LinearLayout? = null + private lateinit var art: XboxLaunchArt + private lateinit var artStatus: TextView private val worker = Executors.newSingleThreadExecutor() private val signalling = Executors.newCachedThreadPool() @Volatile private var session: XboxCloudSession.Session? = null @@ -68,15 +71,24 @@ class XboxCloudPlayerActivity : ComponentActivity() { root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) } setContentView(root) val requested = intent.getStringExtra("product").orEmpty() + art = XboxLaunchArt(this) { diag("cloud player $it") } + root.addView(art.view(intent.getStringExtra("title").orEmpty()) { cancelLaunch() }, FrameLayout.LayoutParams(-1, -1)) + artStatus = TextView(this).apply { + setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER; setShadowLayer(10f, 0f, 0f, Color.BLACK); visibility = View.GONE + } + root.addView(artStatus, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 }) + art.load(requested) showNotice("Signing in to Xbox Cloud Gaming…", withButtons = false) worker.execute { val result = runCatching { val account = StoreAccounts.signedInAs(applicationContext, Store.XBOX) ?: error("Sign in to the Xbox store first.") val cached = XboxLibraryCache.read(applicationContext, account, Xodus.market())?.games?.firstOrNull { it.id == requested } val product = cached?.extra?.get("cloudId")?.takeIf { it.isNotEmpty() } ?: requested - webUrl = XboxCatalog.cloudUrl(requested, cached?.title ?: intent.getStringExtra("title").orEmpty(), product) + val name = cached?.title ?: intent.getStringExtra("title").orEmpty() + webUrl = XboxCatalog.cloudUrl(requested, name, product) val active = XboxCloudSession.get(applicationContext, account) - val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.") + val title = XboxCloudSession.titleFor(active, product, name) { diag("cloud player: $it") } + ?: error("This game can't be streamed with this account here.") settings = XboxCloudSettings.load(applicationContext) startedWith = settings session = active.forStream(settings.region, settings.osName); titleId = title @@ -86,6 +98,7 @@ class XboxCloudPlayerActivity : ComponentActivity() { if (closed) return@runOnUiThread result.onSuccess { openPlayer() }.onFailure { diag("cloud player not started: ${it.javaClass.simpleName}: ${it.message?.take(160)}") + hideArt() showNotice(it.message ?: "Xbox Cloud Gaming could not start.", withButtons = true) } } @@ -130,6 +143,12 @@ class XboxCloudPlayerActivity : ComponentActivity() { fun call(id: Int, op: String, arg: String) { signalling.execute { val reply = runCatching { handle(op, arg) }.getOrElse { XboxCloudSession.Reply(0, it.javaClass.simpleName) } + if (closed && op == "start") { + val active = session; val path = sessionPath + if (active != null && path != null) runCatching { XboxCloudSession.request(active, "DELETE", "/$path") } + .onSuccess { diag("cloud player cancelled: session closed ${it.status}") } + return@execute + } if (reply.status !in 200..299) diag("cloud player $op: ${reply.status} ${reply.body.take(300)}") else if (op != "state" && op != "keepalive") diag("cloud player $op: ${reply.status}") runOnUiThread { web?.evaluateJavascript("window.__ddResolve($id, ${reply.status}, ${JSONObject.quote(reply.body)})", null) } @@ -137,12 +156,24 @@ class XboxCloudPlayerActivity : ComponentActivity() { } @JavascriptInterface - fun status(text: String) { android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}") } + fun status(text: String) { + android.util.Log.i("XboxCloudPlayer", "status: ${text.take(120)}") + if (art.shown) runOnUiThread { if (art.shown) { artStatus.text = text; artStatus.visibility = if (text.isEmpty()) View.GONE else View.VISIBLE } } + } @JavascriptInterface fun playing() { diag("cloud player streaming") - runOnUiThread { web?.requestFocus() } + runOnUiThread { + web?.requestFocus() + if (art.shown) { web?.evaluateJavascript(FIRST_FRAME_JS, null); root.postDelayed({ hideArt() }, 6000) } + } + } + + @JavascriptInterface + fun firstFrame() { + if (art.shown) diag("cloud player first frame") + hideArt() } @JavascriptInterface @@ -154,6 +185,7 @@ class XboxCloudPlayerActivity : ComponentActivity() { @JavascriptInterface fun failed(stage: String, detail: String) { diag("cloud player failed at ${stage.take(40)}: ${detail.take(300)}") + hideArt() runOnUiThread { if (!closed) showNotice("The stream could not start ($stage).", withButtons = true) } } } @@ -164,6 +196,13 @@ class XboxCloudPlayerActivity : ComponentActivity() { return signals.op(op, arg).also { sessionPath = signals.path } } + private fun hideArt() { + art.hide() + runOnUiThread { artStatus.visibility = View.GONE } + } + + private fun cancelLaunch() { if (!isFinishing) { diag("cloud player launch cancelled"); finish() } } + private fun showNotice(text: String, withButtons: Boolean) { notice?.let { root.removeView(it) } val box = LinearLayout(this).apply { @@ -264,6 +303,10 @@ class XboxCloudPlayerActivity : ComponentActivity() { } return super.dispatchKeyEvent(event) } + if (art.shown && (event.keyCode == KeyEvent.KEYCODE_BUTTON_B || event.keyCode == KeyEvent.KEYCODE_BACK)) { + if (event.action == KeyEvent.ACTION_UP) cancelLaunch() + return true + } if (notice == null && guideKey(event)) return true if (event.keyCode == KeyEvent.KEYCODE_BACK) { if (event.action == KeyEvent.ACTION_UP) { if (notice == null) openMenu() else finish() } @@ -379,6 +422,10 @@ class XboxCloudPlayerActivity : ComponentActivity() { companion object { private const val DOUBLE_PRESS_MS = 350L + // Calls DDCloud.firstFrame() once the page's video has decoded a frame (or after 6 s). + private const val FIRST_FRAME_JS = "(function(){var t=Date.now();(function poll(){var v=document.querySelector('video');" + + "var n=v&&v.getVideoPlaybackQuality?v.getVideoPlaybackQuality().totalVideoFrames:0;" + + "if(n>0||(v&&v.currentTime>0)||Date.now()-t>6000){DDCloud.firstFrame();return;}setTimeout(poll,100);})();})()" fun intent(context: Context, productId: String, title: String): Intent = Intent(context, XboxCloudPlayerActivity::class.java) .putExtra("product", productId.uppercase()).putExtra("title", title) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt index 835a55166c..4638e47929 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSession.kt @@ -35,7 +35,7 @@ internal object XboxCloudSession { json.optString("userToken").takeIf { !json.isNull("userToken") && it.isNotEmpty() }, System.currentTimeMillis() + seconds * 1000).also { cached = it } } - fun clear() { cached = null; titleIds = null } + fun clear() { cached = null; titleList = null; looked = null } fun fromMainProcess(app: Context, account: String, timeoutSeconds: Long = 90): Session? { cached?.takeIf { it.account == account && it.fresh }?.let { return it } @@ -61,21 +61,64 @@ internal object XboxCloudSession { b.getString("baseUri").orEmpty(), regions, b.getString("userToken"), b.getLong("expiresAt")) } - @Volatile private var titleIds: Pair>? = null + class Titles(val ids: Map, val entitled: Set) - fun titles(session: Session): Map { - titleIds?.takeIf { it.first == session.account }?.let { return it.second } + @Volatile private var titleList: Pair? = null + + fun titles(session: Session): Map = titleList(session).ids + + // Entitled = details.hasEntitlement or isFreeInStore, as Greenlight's xcloud.ts by unknownskl (MIT). + fun titleList(session: Session, fresh: Boolean = false): Titles { + if (!fresh) titleList?.takeIf { it.first == session.account }?.let { return it.second } val reply = request(session, "GET", "/v2/titles") check(reply.status == 200) { "Xbox Cloud Gaming answered ${reply.status}" } val results = JSONObject(reply.body).optJSONArray("results") ?: JSONArray() - val map = (0 until results.length()).mapNotNull { index -> - val row = results.optJSONObject(index) ?: return@mapNotNull null - val product = row.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty() + val ids = LinkedHashMap() + val entitled = LinkedHashSet() + for (index in 0 until results.length()) { + val row = results.optJSONObject(index) ?: continue + val details = row.optJSONObject("details") + val product = details?.optString("productId")?.uppercase().orEmpty() val title = row.optString("titleId") - if (product.matches(Regex("[A-Z0-9]{12}")) && title.isNotBlank() && title.length <= 64) product to title else null - }.toMap() - titleIds = session.account to map - return map + if (!product.matches(Regex("[A-Z0-9]{12}")) || title.isBlank() || title.length > 64) continue + ids.putIfAbsent(product, title) + if (details?.optBoolean("hasEntitlement") == true || details?.optBoolean("isFreeInStore") == true) entitled += product + } + return Titles(ids, entitled).also { titleList = session.account to it } + } + + @Volatile private var looked: Pair>? = null + + // Lookup by product id (POST /v2/titles with alternateIds) as Better xCloud's getTitleInfo (MIT). + fun titleFor(session: Session, productId: String, name: String = "", log: (String) -> Unit = {}): String? { + val product = productId.uppercase() + val list = titles(session) + list[product]?.let { return it } + val cache = looked?.takeIf { it.first == session.account }?.second ?: HashMap().also { looked = session.account to it } + cache[product]?.let { return it } + val body = JSONObject().put("alternateIds", JSONArray().put(product)).put("alternateIdType", "productId").toString() + val reply = runCatching { request(session, "POST", "/v2/titles", body) }.getOrNull() + val rows = reply?.takeIf { it.status == 200 }?.let { runCatching { JSONObject(it.body).optJSONArray("results") }.getOrNull() } + val row = rows?.optJSONObject(0) + val title = row?.optString("titleId").orEmpty() + val rowProduct = row?.optJSONObject("details")?.optString("productId")?.uppercase().orEmpty() + log("title lookup $product: http ${reply?.status ?: -1}, results ${rows?.length() ?: -1}, title ${title.ifEmpty { "-" }}, product ${rowProduct.ifEmpty { "-" }}") + if (title.isNotBlank() && title.length <= 64) { cache[product] = title; return title } + val key = nameKey(name) + if (key.length >= 4) { + val byName = list.values.filter { it.uppercase() == key }.distinct() + log("title by name $key: ${byName.joinToString().ifEmpty { "none" }}") + if (byName.size == 1) { cache[product] = byName[0]; return byName[0] } + } + return null + } + + private val EDITION_WORDS = Regex("(STANDARD|DELUXE|PREMIUM|ULTIMATE|GOLD|COMPLETE|DEFINITIVE|ENHANCED|ANNIVERSARY|GAMEOFTHEYEAR|GOTY)?EDITION$|GAMEPREVIEW$|FORWINDOWS(10)?$|XBOXSERIESXS$|XBOXONE$|PC$") + + internal fun nameKey(name: String): String { + var key = name.uppercase().replace(Regex("[^A-Z0-9]"), "") + repeat(3) { key = key.replace(EDITION_WORDS, "") } + return key } class Reply(val status: Int, val body: String) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt index b4f9ab9cb3..c1ddd7d704 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxCloudSettingsPanel.kt @@ -106,7 +106,7 @@ private fun PanelContent( onChange(settings.copy(frameGen = it)) } Text("Native engine (experimental): Google's WebRTC and DroidDeck's own compositor, so DroidDeck frame generation " + - "(DDFG) or LSFG can add frames. LSFG uses the Lossless.dll DroidDeck already uses for games. Screen effects " + + "(DDFG) or LSFG can add frames. LSFG requires Lossless Scaling installed through Steam. Screen effects " + "apply to the web engine.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(start = 8.dp, bottom = 6.dp)) } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt index fab04097d3..c86eff693c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt @@ -137,7 +137,7 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog delete = deleteFiles val process = child if (process == null) { - if (deleteFiles && !item.extra["baseId"].isNullOrBlank()) StoreInstalls.deleteTree(folder) + if (deleteFiles && !item.extra["baseId"].isNullOrBlank()) StoreInstalls.deleteLater(folder) else if (deleteFiles) StoreInstalls.discard(app, folder, emptyList()) return } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchArt.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchArt.kt new file mode 100644 index 0000000000..7e6cee72c7 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxLaunchArt.kt @@ -0,0 +1,142 @@ +package com.droiddeck.launcher.stores.xbox + +import android.app.Activity +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.Crossfade +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.tween +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.onClick +import androidx.compose.ui.semantics.role +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.request.ImageRequest +import com.droiddeck.launcher.R +import com.droiddeck.launcher.stores.Store +import com.droiddeck.launcher.stores.StoreAccounts +import com.droiddeck.launcher.ui.DroidDeckTheme +import kotlinx.coroutines.delay + +// The game's art as a slow slideshow while a cloud stream connects, until the first video frame. +// From Even Better Xcloud (BannerCloud) 7ec2a75. +internal class XboxLaunchArt(private val activity: Activity, private val log: (String) -> Unit) { + private val urls = mutableStateListOf() + private var visible by mutableStateOf(true) + @Volatile var shown = true + private set + + fun view(title: String, onCancel: () -> Unit): ComposeView = ComposeView(activity).apply { + setContent { DroidDeckTheme { LaunchArt(urls, title, visible, onCancel) } } + } + + fun load(product: String) { + if (product.isEmpty()) return + val app = activity.applicationContext + Thread({ + runCatching { + val account = StoreAccounts.signedInAs(app, Store.XBOX) ?: return@runCatching + val game = XboxLibraryCache.read(app, account, Xodus.market())?.games?.firstOrNull { it.id == product } + game?.imageUrl?.let { url -> activity.runOnUiThread { if (urls.isEmpty()) urls.add(url) } } + val more = XboxCatalog.launchArt(product) + if (more.isNotEmpty()) activity.runOnUiThread { urls.addAll(more.filter { it !in urls }) } + }.onFailure { log("launch art: ${it.javaClass.simpleName}") } + }, "launch-art").start() + } + + fun hide() { + shown = false + activity.runOnUiThread { visible = false } + } +} + +@Composable +private fun LaunchArt(images: List, title: String, visible: Boolean, onCancel: () -> Unit) { + AnimatedVisibility(visible, enter = fadeIn(tween(400)), exit = fadeOut(tween(700))) { + Box(Modifier.fillMaxSize().background(Color.Black)) { + var index by remember { mutableIntStateOf(0) } + LaunchedEffect(images.size) { + while (true) { + delay(SLIDE_MS) + if (images.size > 1) index = (index + 1) % images.size + } + } + Crossfade(targetState = images.getOrNull(index % images.size.coerceAtLeast(1)), animationSpec = tween(1400), + label = "launch-art") { url -> + if (url != null) Slide(url, index) + } + Box(Modifier.fillMaxSize().background(Brush.verticalGradient( + 0f to Color(0x66000000), 0.45f to Color(0x22000000), 0.78f to Color(0xB3000000), 1f to Color(0xF2000000)))) + Text(title, style = MaterialTheme.typography.headlineSmall, color = Color.White, maxLines = 2, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.align(Alignment.BottomStart).padding(start = 40.dp, end = 220.dp, bottom = 34.dp)) + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), + modifier = Modifier.align(Alignment.BottomEnd).padding(end = 40.dp, bottom = 30.dp) + .clip(RoundedCornerShape(50)).background(Color(0x99000000)) + .pointerInput(Unit) { detectTapGestures { onCancel() } } + .semantics(mergeDescendants = true) { role = Role.Button; onClick { onCancel(); true } } + .padding(start = 8.dp, end = 18.dp, top = 8.dp, bottom = 8.dp)) { + Box(Modifier.size(28.dp).clip(CircleShape).background(Color(0xFFE5484D)), contentAlignment = Alignment.Center) { + Text("B", color = Color.White, fontWeight = FontWeight.Bold, fontSize = 15.sp) + } + Text(stringResource(R.string.common_cancel), color = Color.White, fontSize = 16.sp, fontWeight = FontWeight.SemiBold) + } + } + } +} + +@Composable +private fun Slide(url: String, index: Int) { + val ctx = LocalContext.current + val progress = remember(url) { Animatable(0f) } + LaunchedEffect(url) { progress.animateTo(1f, tween((SLIDE_MS + 1600).toInt(), easing = LinearEasing)) } + val dir = if (index % 2 == 0) 1f else -1f + AsyncImage( + model = ImageRequest.Builder(ctx).data(url).crossfade(500).build(), + contentDescription = null, contentScale = ContentScale.Crop, + modifier = Modifier.fillMaxSize().graphicsLayer { + val p = progress.value + val s = 1.06f + 0.10f * p + scaleX = s; scaleY = s + translationX = dir * (p - 0.5f) * size.width * 0.04f + }) +} + +private const val SLIDE_MS = 5200L diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt index b33d1d0d77..1c88e48655 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxManifest.kt @@ -80,6 +80,10 @@ internal object XboxManifest { dependencies.singleOrNull().orEmpty(), ids, entries, entry.singleOrNull().orEmpty(), behavior.singleOrNull().orEmpty()) } + /** Microsoft's original Xbox releases for PC, which run its emulator. */ + fun backCompat(folder: File): Boolean = + runCatching { read(folder).name.startsWith(XboxCatalog.BACK_COMPAT_IDENTITY, ignoreCase = true) }.getOrDefault(false) + /** * A full trust package starts its executable directly. Anything else is activated * through the Windows app model, which this runtime has no host for, so starting @@ -94,17 +98,16 @@ internal object XboxManifest { } fun executable(folder: File): String { - for (path in read(folder).executables) { + val listed = read(folder).executables + for (path in listed) { require(!path.startsWith('/') && !path.contains(':') && path.split('/').none { it == ".." || it.isEmpty() }) - var file = folder - for (part in path.split('/')) { - val matches = file.listFiles().orEmpty().filter { it.name.equals(part, true) } - require(matches.size == 1) { "Missing or ambiguous Xbox launch path." } - file = matches.single() - } + val file = path.split('/').fold(folder) { dir, part -> + dir?.listFiles().orEmpty().filter { it.name.equals(part, true) }.singleOrNull() + } ?: continue require(file.canonicalPath.startsWith(folder.canonicalPath + File.separator)) if (file.isFile) return forwarded(folder, file) ?: file.relativeTo(folder).invariantSeparatorsPath } + require(listed.isEmpty()) { "Missing or ambiguous Xbox launch path." } error("The Xbox package has no supported PC launch executable.") } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt index 2125bf802a..346a65d9b4 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativePlayerActivity.kt @@ -5,6 +5,7 @@ import com.droiddeck.launcher.ui.focusGlide import android.content.Context import android.content.Intent import android.graphics.Color +import android.media.AudioAttributes import android.os.Build import android.os.Bundle import android.os.VibrationEffect @@ -75,6 +76,7 @@ class XboxNativePlayerActivity : ComponentActivity() { @Volatile private var connectedOnce = false @Volatile private var endedInBackground = false private var backgroundEnd: Runnable? = null + private lateinit var art: XboxLaunchArt private var notice: androidx.compose.ui.platform.ComposeView? = null @Volatile private var regionNames = emptyList() @Volatile private var serverName: String? = null @@ -103,7 +105,10 @@ class XboxNativePlayerActivity : ComponentActivity() { root = FrameLayout(this).apply { setBackgroundColor(Color.BLACK) } surfaceView = SurfaceView(this) root.addView(surfaceView, FrameLayout.LayoutParams(-1, -1)) - status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER } + art = XboxLaunchArt(this) { log(it) } + root.addView(art.view(intent.getStringExtra("title").orEmpty()) { cancelLaunch() }, FrameLayout.LayoutParams(-1, -1)) + art.load(intent.getStringExtra("product").orEmpty()) + status = TextView(this).apply { setTextColor(Color.WHITE); textSize = 16f; gravity = Gravity.CENTER; setShadowLayer(10f, 0f, 0f, Color.BLACK) } root.addView(status, FrameLayout.LayoutParams(-1, -2, Gravity.BOTTOM).apply { bottomMargin = 120 }) overlay = TextView(this).apply { setTextColor(Color.WHITE); textSize = 12f; typeface = android.graphics.Typeface.MONOSPACE @@ -118,6 +123,7 @@ class XboxNativePlayerActivity : ComponentActivity() { val egl = EglBase.create().also { eglBase = it } val nativeVideo = XboxNativeVideo(this, egl) { log(it) }.also { video = it } + nativeVideo.onFirstFrame = { hideArt() } surfaceView.holder.addCallback(object : SurfaceHolder.Callback { override fun surfaceCreated(holder: SurfaceHolder) {} override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) { @@ -137,9 +143,12 @@ class XboxNativePlayerActivity : ComponentActivity() { private fun log(text: String) = com.droiddeck.launcher.stores.StoresState.logLine("Xbox: native player: ${text.take(240)}") private fun show(text: String) = runOnUiThread { status.text = text; status.visibility = if (text.isEmpty()) android.view.View.GONE else android.view.View.VISIBLE } + private fun hideArt() { if (art.shown) { art.hide(); show("") } } + private fun cancelLaunch() { if (!isFinishing) { log("launch cancelled"); finish() } } private fun fail(stage: String, detail: String) { log("failed at $stage: $detail") + art.hide() if (closed) return if (connectedOnce) showNotice("The connection to the cloud console was lost", "The stream stopped reaching this device ($detail). Restart the stream to play again: the game starts over, " + @@ -232,12 +241,14 @@ class XboxNativePlayerActivity : ComponentActivity() { val active = (shared ?: XboxCloudSession.get(applicationContext, account)).forStream(settings.region, settings.osName) regionNames = active.regionList.map { it.name } serverName = active.regionList.firstOrNull { it.baseUri == active.baseUri }?.name - val title = XboxCloudSession.titles(active)[product] ?: error("This game can't be streamed with this account here.") + val title = XboxCloudSession.titleFor(active, product, cached?.title ?: intent.getStringExtra("title").orEmpty()) { log(it) } + ?: error("This game can't be streamed with this account here.") val signals = XboxCloudSignalling(active, title, settings).also { signalling = it } log("$product -> $title, region ${java.net.URI(active.baseUri).host}, frame gen ${settings.frameGen}") show("Starting the game on Xbox Cloud Gaming…") expect("start", signals.start()) + if (closed) { runCatching { signals.stop() }.onSuccess { log("cancelled: session closed ${it?.status}") }; return } var connected = false var waited = 0 while (!closed) { @@ -270,7 +281,15 @@ class XboxNativePlayerActivity : ComponentActivity() { log("latency: instant input ${settings.instantInput}, small buffer ${settings.smallBuffer}, fast decoder ${settings.fastDecoder}, " + "zero-copy ${zeroSurface != null}") val f = PeerConnectionFactory.builder() - .setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext).createAudioDeviceModule()) + // WebRTC defaults to voice-call audio (mono, speaker/earpiece only); game audio follows + // the normal output (HDMI, USB, Bluetooth) and keeps the stream's stereo. + .setAudioDeviceModule(JavaAudioDeviceModule.builder(applicationContext) + .setAudioAttributes(AudioAttributes.Builder() + .setUsage(AudioAttributes.USAGE_GAME) + .setContentType(AudioAttributes.CONTENT_TYPE_MOVIE) + .build()) + .setUseStereoOutput(true) + .createAudioDeviceModule()) .setVideoDecoderFactory(org.webrtc.DroidDeckLowLatencyDecoderFactory(egl.eglBaseContext, settings.fastDecoder, zeroSurface) { zeroCopyFrames++ } .also { decoders = it }) .setVideoEncoderFactory(DefaultVideoEncoderFactory(egl.eglBaseContext, true, true)) @@ -365,7 +384,7 @@ class XboxNativePlayerActivity : ComponentActivity() { when (state) { PeerConnection.PeerConnectionState.CONNECTED -> { connectedOnce = true - show("") + if (art.shown) root.postDelayed({ hideArt() }, 6000) else show("") video?.setFpsTarget(settings.fpsTarget) video?.setFrameGeneration(effectiveFrameGen()) } @@ -427,6 +446,10 @@ class XboxNativePlayerActivity : ComponentActivity() { } return super.dispatchKeyEvent(event) } + if (art.shown && (event.keyCode == KeyEvent.KEYCODE_BUTTON_B || event.keyCode == KeyEvent.KEYCODE_BACK)) { + if (event.action == KeyEvent.ACTION_UP) cancelLaunch() + return true + } if (isGuide(event)) { if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) { val pending = pendingNexus @@ -600,11 +623,11 @@ class XboxNativePlayerActivity : ComponentActivity() { XboxMenuEntry((if (current.frameGen == mode) "✓ " else "") + fgName(mode), when (mode) { XboxNativeVideo.FG_DDFG -> "DroidDeck's own frame generation (DDFG); doubles the shown frame rate" XboxNativeVideo.FG_LSFG, XboxNativeVideo.FG_LSFG3, XboxNativeVideo.FG_LSFG4 -> - "Lossless Scaling frame generation (the Lossless.dll DroidDeck uses for games); the frame-rate target caps the output" + "Lossless Scaling frame generation from the Steam installation; the frame-rate target caps the output" else -> "Show the stream's own frames only" }, choices[i]) { current = current.copy(frameGen = mode); setFrameGen(mode) } } - if (!lsfg) androidx.compose.material3.Text("LSFG appears here once DroidDeck has the Lossless.dll (frame generation settings).", + if (!lsfg) androidx.compose.material3.Text("LSFG appears here once Lossless Scaling is installed through Steam.", style = androidx.compose.material3.MaterialTheme.typography.bodySmall, color = cs.onSurfaceVariant, modifier = androidx.compose.ui.Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) if (current.zeroCopy) androidx.compose.material3.Text( diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt index 193f4e58b7..7db236e739 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxNativeVideo.kt @@ -54,6 +54,7 @@ internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, p private var nextDueNs = 0L @Volatile var frames = 0L private set + @Volatile var onFirstFrame: (() -> Unit)? = null fun setSurface(target: Surface?, width: Int, height: Int, displayRefreshHz: Float) = synchronized(lock) { refreshHz = displayRefreshHz @@ -126,7 +127,10 @@ internal class XboxNativeVideo(private val context: Context, eglBase: EglBase, p if (nextDueNs == 0L || now - nextDueNs > interval) nextDueNs = now if (now + 4_000_000L < nextDueNs) true else { nextDueNs += interval; false } } - if (attached && buffer != null && !skip) { WaylandCompositor.nativeStreamFrame(buffer); frames++ } + if (attached && buffer != null && !skip) { + WaylandCompositor.nativeStreamFrame(buffer); frames++ + onFirstFrame?.let { onFirstFrame = null; it() } + } buffer?.close() held.addLast(image) while (held.size > 2) held.removeFirst().close() diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index 39866fceea..6be4ddb14e 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -1,12 +1,10 @@ package com.droiddeck.launcher.stores.xbox import android.content.Context -import android.os.Environment import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.runtime.ProotFastPath -import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.StoreInstallRoot import org.json.JSONObject import java.io.Closeable @@ -82,7 +80,7 @@ internal object Xodus { networkLink.start() val runtime = (runtimeDirectory ?: File(app.filesDir, "xbox-runtime")).apply { mkdirs() } val root = LinuxRuntime.rootDir(app) - val external = Environment.getExternalStorageDirectory() + val external = LinuxRuntime.sharedStorage(app) val extraBinds = StoreInstallRoot.externalBindSpecsForXodus(app) val binds = LinuxRuntime.binds(app, null, null, external, extraBinds) val fastPathPreloaded = runCatching { @@ -108,7 +106,6 @@ internal object Xodus { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) - if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") fastPathKey?.let { ProotFastPath.hostEnv(it).let { (key, value) -> put(key, value) } } LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt b/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt index 052241a8b9..fc62ea718d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AddonBrowser.kt @@ -273,7 +273,7 @@ internal fun AddonBrowserDialog(targets: List, initial: WowAdd var text by remember { mutableStateOf("") } var category by remember { mutableStateOf(null) } var sort by remember { mutableStateOf(WowAddonCatalog.Sort.POPULAR) } - var source by remember { mutableStateOf(AddonSource.WOWI) } + var source by remember(curseForge != null) { mutableStateOf(if (curseForge != null) AddonSource.CURSE else AddonSource.WOWI) } val curse = if (source == AddonSource.CURSE && link != null) curseForge else null LaunchedEffect(link) { link?.refresh() } var notice by remember { mutableStateOf(null) } @@ -425,8 +425,8 @@ internal fun AddonBrowserDialog(targets: List, initial: WowAdd } val sourceChip: @Composable () -> Unit = { if (curseForge != null) BrowseDropdown(sourceName) { first, done -> - MenuItem(stringResource(R.string.addons_source_wowi), source == AddonSource.WOWI, focusRequester = first) { source = AddonSource.WOWI; done() } - MenuItem(stringResource(R.string.addons_source_curse), source == AddonSource.CURSE) { source = AddonSource.CURSE; done() } + MenuItem(stringResource(R.string.addons_source_wowi), curse == null, focusRequester = first) { source = AddonSource.WOWI; done() } + MenuItem(stringResource(R.string.addons_source_curse), curse != null) { source = AddonSource.CURSE; done() } } } val categoryChip: @Composable () -> Unit = { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentEntries.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentEntries.kt index ff282615f5..1df2b17315 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentEntries.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentEntries.kt @@ -78,7 +78,7 @@ internal fun AgentEntry( is Entry.Said -> { val reply = remember(entry.text) { choices(entry.text) } Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { - if (reply.text.isNotBlank()) SelectionContainer { AgentMarkdown(reply.text, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp)) } + if (reply.text.isNotBlank()) SelectionContainer { AgentReply(reply.text, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp)) } if (reply.options.isNotEmpty()) AgentChoices(reply.options, answerable, onSent) } } @@ -377,10 +377,11 @@ private fun CodeBox(label: String, text: String, color: Color) { internal fun AttachmentChip(path: String, onRemove: (() -> Unit)?) { val context = LocalContext.current val pal = LocalPalette.current + var viewing by remember(path) { mutableStateOf(false) } Box { if (AgentAttachments.isImage(path)) AsyncImage( model = AgentAttachments.host(context, path), contentDescription = path.substringAfterLast('/'), contentScale = ContentScale.Crop, - modifier = Modifier.size(72.dp).clip(Shape12).background(pal.surfaceVariant), + modifier = Modifier.size(72.dp).clip(Shape12).background(pal.surfaceVariant).clickable { viewing = true }, ) else Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.heightIn(min = 40.dp).clip(Shape12).background(pal.surfaceVariant).padding(horizontal = 10.dp, vertical = 8.dp), @@ -396,4 +397,5 @@ internal fun AttachmentChip(path: String, onRemove: (() -> Unit)?) { Icon(Icons.Outlined.Close, stringResource(R.string.agent_remove_attachment), tint = pal.onSurfaceVariant, modifier = Modifier.size(14.dp)) } } + if (viewing) PictureViewer(AgentAttachments.host(context, path), path.substringAfterLast('/')) { viewing = false } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentMarkdown.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentMarkdown.kt index 0d85087f85..49f351a175 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentMarkdown.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentMarkdown.kt @@ -37,6 +37,106 @@ import org.commonmark.ext.gfm.tables.TableRow import org.commonmark.node.AbstractVisitor import org.commonmark.node.CustomNode import org.commonmark.node.Node +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.widthIn +import androidx.compose.material3.Text +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.ui.draw.clip +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import com.droiddeck.launcher.runtime.LinuxRuntime +import java.io.File + +/** Part of an agent's reply: Markdown text, or an image the agent named on a line of its own. */ +internal sealed interface ReplyPart { + data class Prose(val text: String) : ReplyPart + data class Picture(val alt: String, val path: String) : ReplyPart +} + +private val PICTURE_LINE = Regex("""^\s*!\[([^\]]*)]\(\s*(?:<(?:file://)?(/[^>]*)>|(?:file://)?(/[^)<>]*?))\s*\)\s*$""") +private val FENCE = Regex("""^ {0,3}(`{3,}|~{3,})(.*)$""") + +/** Splits [text] at lines that hold only an image of a local absolute path, outside code fences. */ +internal fun replyParts(text: String): List { + val parts = mutableListOf() + val prose = StringBuilder() + fun flush() { + if (prose.isNotBlank()) parts += ReplyPart.Prose(prose.toString().trimEnd('\n')) + prose.clear() + } + var fence: String? = null + for (line in text.lines()) { + val marker = FENCE.matchEntire(line) + val picture = if (fence == null) PICTURE_LINE.matchEntire(line) else null + val open = fence + when { + picture != null -> { + flush() + val path = picture.groupValues[2].ifEmpty { picture.groupValues[3] } + parts += ReplyPart.Picture(picture.groupValues[1].trim(), path.trim()) + continue + } + marker == null -> Unit + open == null -> fence = marker.groupValues[1] + marker.groupValues[1].let { it[0] == open[0] && it.length >= open.length } && marker.groupValues[2].isBlank() -> fence = null + } + prose.append(line).append('\n') + } + flush() + return parts +} + +/** + * Where the app reads a file the agent named by its guest path: the app's own folders and shared + * storage are bound at the same paths in the guest, everything else lives in the rootfs. + */ +internal fun agentHostFile(context: Context, guestPath: String): File { + val app = context.applicationContext + val same = listOfNotNull(app.filesDir.path, app.cacheDir.path, LinuxRuntime.sharedStorage(app)?.path) + return if (same.any { guestPath == it || guestPath.startsWith("$it/") }) File(guestPath) + else File(LinuxRuntime.rootDir(app), guestPath.removePrefix("/")) +} + +/** An agent's reply, with the images it names shown in place. */ +@Composable +internal fun AgentReply(text: String, modifier: Modifier) { + val parts = remember(text) { replyParts(text) } + if (parts.size == 1 && parts[0] is ReplyPart.Prose) { + AgentMarkdown(text, modifier) + return + } + Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) { + parts.forEach { part -> + when (part) { + is ReplyPart.Prose -> AgentMarkdown(part.text, Modifier) + is ReplyPart.Picture -> AgentPicture(part) + } + } + } +} + +@Composable +private fun AgentPicture(picture: ReplyPart.Picture) { + val context = LocalContext.current + val file = remember(picture.path) { agentHostFile(context, picture.path) } + var viewing by remember(picture.path) { mutableStateOf(false) } + if (!file.isFile) { + Text(stringResource(R.string.agent_image_missing, picture.alt.ifBlank { picture.path }), color = MaterialTheme.colorScheme.onSurfaceVariant) + return + } + AsyncImage( + model = file, contentDescription = picture.alt.ifBlank { file.name }, contentScale = ContentScale.Fit, + modifier = Modifier.widthIn(max = 560.dp).heightIn(max = 420.dp).clip(Shape12).clickable { viewing = true }, + ) + if (viewing) PictureViewer(file, picture.alt.ifBlank { file.name }) { viewing = false } +} @Composable internal fun AgentMarkdown(text: String, modifier: Modifier) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPage.kt index 429db30258..b2793e5ba1 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPage.kt @@ -5,7 +5,9 @@ import android.content.ContextWrapper import android.os.Build import android.view.KeyEvent import android.view.WindowManager +import androidx.activity.compose.BackHandler import androidx.activity.compose.LocalActivityResultRegistryOwner +import androidx.activity.compose.LocalOnBackPressedDispatcherOwner import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.animation.expandVertically @@ -50,12 +52,12 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Send import androidx.compose.material.icons.outlined.Extension -import androidx.compose.material.icons.outlined.PhotoCamera import androidx.compose.material.icons.outlined.MicOff import androidx.compose.material.icons.outlined.Mic import androidx.compose.material.icons.outlined.Add import androidx.compose.material.icons.outlined.ArrowDownward import androidx.compose.material.icons.outlined.AttachFile +import androidx.compose.material.icons.outlined.Keyboard import androidx.compose.material.icons.outlined.Terminal import androidx.compose.material.icons.outlined.Build import androidx.compose.material.icons.outlined.Close @@ -79,6 +81,7 @@ import androidx.compose.runtime.MutableState import androidx.compose.runtime.Stable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -108,6 +111,7 @@ import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.testTag @@ -301,7 +305,7 @@ private fun AgentPageContent( readingBack = false scope.launch { list.scrollToItem(maxOf(0, list.layoutInfo.totalItemsCount - 1), Int.MAX_VALUE / 2) } } - val hidden = !composer.focused && !composer.hasUnconsumedFocusRequest() && readingBack && AgentHost.entries.isNotEmpty() && + val hidden = !composer.focused && !composer.tray && !composer.hasUnconsumedFocusRequest() && readingBack && AgentHost.entries.isNotEmpty() && AgentHost.approvals.isEmpty() var listHeight by remember { mutableIntStateOf(0) } Box( @@ -319,6 +323,7 @@ private fun AgentPageContent( awaitEachGesture { awaitFirstDown(requireUnconsumed = false, pass = PointerEventPass.Initial) if (panel == AgentPanel.MODEL || panel == AgentPanel.USAGE) panel = AgentPanel.NONE + composer.tray = false // Forced: the unforced path walks the focus chain and throws ("ActiveParent with no focused child") when a tap lands while focus is moving. if (composer.focused) focusManager.clearFocus(force = true) } @@ -344,6 +349,12 @@ private fun AgentPageContent( @Stable private class ComposerState { var focused by mutableStateOf(false) + /** The photo tray stands in for the keyboard, at the height the keyboard last had. */ + var tray by mutableStateOf(false) + var keyboardHeight by mutableStateOf(0.dp) + /** Tray photos copied, or being copied, for this conversation, so reopening the tray keeps their marks and copies nothing twice. */ + val photoCopies = mutableStateMapOf() + val photosCopying = mutableStateMapOf() var focusRequests by mutableIntStateOf(0) private set private var consumedFocusRequests by mutableIntStateOf(0) @@ -390,7 +401,7 @@ private fun ModelChip(panel: AgentPanel, onPanel: (AgentPanel) -> Unit, firstCon .clickable { onPanel(AgentPanel.MODEL) }.padding(horizontal = 8.dp).testTag("agent-model"), ) { val mode = AgentHost.harness.permissions.drop(1).firstOrNull { it.id == AgentHost.permission }?.let { stringResource(it.label) } - val parts = if (compact) listOfNotNull(mode ?: model) + val parts = if (compact) listOf(model) else listOfNotNull( AgentHost.harness.name, model, AgentHost.effort, mode, stringResource(R.string.agent_plan_short).takeIf { AgentHost.plan && AgentHost.harness.plans }, @@ -532,7 +543,7 @@ private fun AgentLive() { val pal = LocalPalette.current Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { if (AgentHost.liveThinking.isNotBlank()) AgentThought(AgentHost.liveThinking, live = true) - if (AgentHost.live.isNotBlank()) AgentMarkdown(AgentHost.live, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp)) + if (AgentHost.live.isNotBlank()) AgentReply(AgentHost.live, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp)) val running = AgentHost.running() Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.padding(4.dp)) { CircularProgressIndicator(Modifier.size(14.dp), strokeWidth = 2.dp, color = pal.primary) @@ -748,6 +759,8 @@ private fun AgentComposer( if (text.isEmpty() && AgentAttachments.pending.isEmpty()) return@send AgentHost.send(context, text, AgentAttachments.pending.toList()) AgentAttachments.pending.clear() + composer.photosCopying.clear() + composer.tray = false onSent() } } @@ -813,7 +826,34 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState composer.keyboardHeight) composer.keyboardHeight = height + } + LaunchedEffect(hideAttach) { if (hideAttach) composer.tray = false } + LaunchedEffect(AgentHost.chat) { + composer.photoCopies.clear() + composer.photosCopying.clear() + } + // BackHandler throws where the host provides no back dispatcher: the front end and the floating pet. + if (LocalOnBackPressedDispatcherOwner.current != null) BackHandler(composer.tray) { composer.tray = false } + val focusManager = LocalFocusManager.current + val files = if (picks) rememberLauncherForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) { + AgentAttachments.picking = false + attachUris(context, it) + } else null + val toggleTray = { + if (composer.tray) { + composer.tray = false + composer.open() + } else { + focusManager.clearFocus(force = true) + composer.tray = true + } + } BoxWithConstraints( Modifier.fillMaxWidth().padding(top = 8.dp).clip(Shape16).background(colors.surface) .border(if (focused) 2.dp else 1.dp, if (focused) pal.primary else pal.line, Shape16).padding(6.dp), @@ -841,6 +881,7 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState 0.dp) composer.keyboardHeight else 280.dp).coerceAtLeast(160.dp).coerceAtMost(most) + AgentPhotoTray(height, composer.photoCopies, composer.photosCopying, files?.let { { AgentAttachments.pick { it.launch(arrayOf("*/*")) } } }) + } } /** @@ -974,51 +1018,15 @@ private fun VoiceButton(voice: AgentVoice, onStart: () -> Unit, onSend: () -> Un } } -/** Attaches what the running game shows, taken from its own surface so nothing drawn over it is in the picture. */ +/** Opens the photo tray in place of the keyboard; while it is open, brings the keyboard back. */ @Composable -private fun GameFrameButton() { - val context = LocalContext.current +private fun AttachButton(trayOpen: Boolean, onClick: () -> Unit) { val pal = LocalPalette.current - RoundButton(Icons.Outlined.PhotoCamera, stringResource(R.string.agent_attach_game), pal.surfaceVariant, pal.onBackground, "agent-game-frame") { - val grab = AgentAttachments.gameFrame ?: return@RoundButton - val chat = AgentHost.chat - grab frame@{ frame -> - if (frame == null) { - android.widget.Toast.makeText(context, R.string.agent_attach_game_failed, android.widget.Toast.LENGTH_SHORT).show() - return@frame - } - Thread({ - val path = AgentAttachments.saveFrame(context, chat, frame) - frame.recycle() - android.os.Handler(android.os.Looper.getMainLooper()).post { - when { - path == null -> android.widget.Toast.makeText(context, R.string.agent_attach_game_failed, android.widget.Toast.LENGTH_SHORT).show() - AgentHost.chat == chat -> AgentAttachments.pending.add(path) - else -> AgentAttachments.discard(context, listOf(path)) - } - } - }, "agent-game-frame").start() - } - } -} - -@Composable -private fun AttachButton() { - val context = LocalContext.current - val pal = LocalPalette.current - val picker = rememberLauncherForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) { uris -> - if (uris.isEmpty()) return@rememberLauncherForActivityResult - val chat = AgentHost.chat - Thread({ - val paths = AgentAttachments.copy(context, chat, uris) - android.os.Handler(android.os.Looper.getMainLooper()).post { - if (AgentHost.chat == chat) AgentAttachments.pending.addAll(paths) else AgentAttachments.discard(context, paths) - } - }, "agent-attach").start() - } - RoundButton(Icons.Outlined.AttachFile, stringResource(R.string.agent_attach), pal.surfaceVariant, pal.onBackground, "agent-attach") { - runCatching { picker.launch(arrayOf("*/*")) } - } + RoundButton( + if (trayOpen) Icons.Outlined.Keyboard else Icons.Outlined.AttachFile, + stringResource(if (trayOpen) R.string.agent_keyboard else R.string.agent_attach), + if (trayOpen) pal.primary else pal.surfaceVariant, if (trayOpen) pal.onPrimary else pal.onBackground, "agent-attach", onClick = onClick, + ) } @Composable diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt index a462fca130..db538977f5 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt @@ -67,13 +67,18 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.withContext +@Composable +private fun agentPanelFrame(): Modifier = + Modifier.fillMaxWidth().clip(Shape14).background(MaterialTheme.colorScheme.surface) + .border(1.dp, LocalPalette.current.line, Shape14).padding(horizontal = 14.dp, vertical = 10.dp) + /** The model, reasoning effort, permissions and plan mode for the next turns; a conversation keeps going with whatever is chosen. */ @Composable internal fun AgentModelPicker() { val context = LocalContext.current val pal = LocalPalette.current val models = remember(AgentHost.harness) { AgentHost.models(context) } - Column(Modifier.fillMaxWidth().padding(bottom = 10.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) { + Column(agentPanelFrame(), verticalArrangement = Arrangement.spacedBy(10.dp)) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.horizontalScroll(rememberScrollState())) { val choices = listOf(AgentHarness.Model("", stringResource(R.string.agent_model_default))) + models for (choice in choices) { @@ -269,12 +274,8 @@ internal fun AgentProcessList(modifier: Modifier) { @Composable internal fun AgentUsage() { val context = LocalContext.current - val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - Column( - Modifier.fillMaxWidth().clip(Shape14).background(colors.surface).border(1.dp, pal.line, Shape14).padding(horizontal = 14.dp, vertical = 10.dp), - verticalArrangement = Arrangement.spacedBy(8.dp), - ) { + Column(agentPanelFrame(), verticalArrangement = Arrangement.spacedBy(8.dp)) { if (AgentHost.window > 0) UsageRow( stringResource(R.string.agent_usage_context), stringResource(R.string.agent_usage_of, tokens(AgentHost.context), tokens(AgentHost.window)), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPet.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPet.kt index 8adadcab9c..2ded416719 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentPet.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPet.kt @@ -88,7 +88,14 @@ internal object AgentPet { private set /** The floating windows could not be made, so the pet stays in DroidDeck's own windows instead. */ private var floatFailed by mutableStateOf(false) - val floating get() = enabled && allowed && !floatFailed + val floating get() = enabled && allowed && !floatFailed && usesOverlayWindows(onQuest) + /** Quest's shell turns overlay windows into system panels that take input from the VR view. */ + private val onQuest = com.droiddeck.launcher.session.QuestExperimental.isSupported() + + internal fun usesOverlayWindows(quest: Boolean) = !quest + + /** On Quest the chat opens as its own panel window, which Horizon moves, resizes and closes. */ + internal fun chatInOwnWindow(quest: Boolean = onQuest) = quest /** How to close the chat open inside each DroidDeck window that has one. */ private val closeInWindow = java.util.WeakHashMap Unit>() @@ -118,7 +125,7 @@ internal object AgentPet { AgentHost.prefs(context).edit().putBoolean(KEY, on).apply() if (on) { allowed = PetWindows.allowed(context) - if (!allowed) requestFloating(context) + if (!allowed && usesOverlayWindows(onQuest)) requestFloating(context) } } @@ -251,9 +258,12 @@ private fun PetLayer(host: AgentPetHost) { val density = LocalDensity.current val openLabel = androidx.compose.ui.res.stringResource(com.droiddeck.launcher.R.string.agent_pet_open) val openChat = { - motion.dock() - chatShown = true - chatOpen = true + if (AgentPet.chatInOwnWindow()) com.droiddeck.launcher.agent.AgentChatActivity.open(context) + else { + motion.dock() + chatShown = true + chatOpen = true + } } val closeChat = { chatOpen = false diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPetWindows.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPetWindows.kt index 72e5d0b635..e2381ca2a4 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentPetWindows.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPetWindows.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -495,7 +496,13 @@ internal class PetWindows(private val context: Context) { * under it. Its contents are built while it is closed, so opening only animates. */ @Composable -internal fun PetChat(open: Boolean, motion: PetMotion, onClose: () -> Unit, onClosed: () -> Unit) { +internal fun PetChat( + open: Boolean, motion: PetMotion, onClose: () -> Unit, + page: @Composable ColumnScope.(AgentMenuSlot) -> Unit = { slot -> + AgentPage(Modifier.weight(1f).fillMaxWidth(), visible = open, startTyping = AgentHost.entries.isEmpty(), hidesPet = false, menuSlot = slot) + }, + onClosed: () -> Unit, +) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val density = androidx.compose.ui.platform.LocalDensity.current @@ -552,14 +559,16 @@ internal fun PetChat(open: Boolean, motion: PetMotion, onClose: () -> Unit, onCl alpha = fade.value } .clip(Shape16).background(colors.background).border(1.dp, pal.line, Shape16) - .clickable(remember { MutableInteractionSource() }, null, enabled = open) {} + // Never disabled: a disabled clickable leaves the focus tree, and the one it puts back on reopening + // sits unfocused above the still-focused editor, where key events then find no focus target. + .clickable(remember { MutableInteractionSource() }, null) {} .padding(start = 12.dp, end = 12.dp, top = 6.dp), ) { Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(bottom = 2.dp)) { Box(Modifier.weight(1f)) { menuSlot.content?.invoke() } HeaderAction(Icons.Outlined.Close, stringResource(R.string.agent_close), size = 34.dp, tag = "agent-pet-close", onClick = onClose) } - AgentPage(Modifier.weight(1f).fillMaxWidth(), visible = open, startTyping = AgentHost.entries.isEmpty(), hidesPet = false, menuSlot = menuSlot) + page(menuSlot) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPhotoTray.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPhotoTray.kt new file mode 100644 index 0000000000..d6c5dabe68 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPhotoTray.kt @@ -0,0 +1,280 @@ +package com.droiddeck.launcher.ui + +import android.Manifest +import android.content.ContentUris +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.net.Uri +import android.os.Build +import android.os.Environment +import android.provider.MediaStore +import android.provider.Settings +import android.widget.Toast +import androidx.activity.compose.LocalActivityResultRegistryOwner +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Check +import androidx.compose.material.icons.outlined.FolderOpen +import androidx.compose.material.icons.outlined.PhotoCamera +import androidx.compose.material.icons.outlined.PhotoLibrary +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshots.SnapshotStateMap +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalLifecycleOwner +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.selected +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver +import coil.compose.AsyncImage +import coil.request.ImageRequest +import com.droiddeck.launcher.R +import com.droiddeck.launcher.agent.AgentAttachments +import com.droiddeck.launcher.agent.AgentHost +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext + +/** The device's photos, newest first, as MediaStore lets the app see them. */ +internal object AgentPhotos { + enum class Access { NONE, SELECTED, ALL } + + /** Android stops showing the request after repeated denials and answers it at once, so a denied request sends later ones to Settings. */ + var refused = false + + fun permissions(sdk: Int = Build.VERSION.SDK_INT): Array = when { + sdk >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> arrayOf(Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) + sdk >= Build.VERSION_CODES.TIRAMISU -> arrayOf(Manifest.permission.READ_MEDIA_IMAGES) + else -> arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE) + } + + fun access(context: Context): Access { + fun granted(permission: String) = context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED + val all = permissions().first() + return when { + Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && Environment.isExternalStorageManager() -> Access.ALL + granted(all) -> Access.ALL + Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && granted(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) -> Access.SELECTED + else -> Access.NONE + } + } + + class Photo(val uri: Uri, val name: String) + + fun recent(context: Context, limit: Int = 300): List = runCatching { + val images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI + context.contentResolver.query( + images, arrayOf(MediaStore.Images.Media._ID, MediaStore.Images.Media.DISPLAY_NAME), null, null, "${MediaStore.Images.Media.DATE_ADDED} DESC", + )?.use { c -> + buildList { + while (size < limit && c.moveToNext()) add(Photo(ContentUris.withAppendedId(images, c.getLong(0)), c.getString(1).orEmpty())) + } + }.orEmpty() + }.getOrDefault(emptyList()) +} + +/** + * Copies [uris] into the conversation's attachments off the main thread, then hands [onCopied] what was attached: nothing if the + * conversation changed meanwhile or [current] says the copy was superseded. + */ +internal fun attachUris(context: Context, uris: List, current: () -> Boolean = { true }, onCopied: (List>) -> Unit = {}) { + if (uris.isEmpty()) return + val chat = AgentHost.chat + Thread({ + val copied = uris.mapNotNull { uri -> AgentAttachments.copy(context, chat, listOf(uri)).firstOrNull()?.let { uri to it } } + android.os.Handler(android.os.Looper.getMainLooper()).post { + val paths = copied.map { it.second } + if (AgentHost.chat == chat && current()) { + AgentAttachments.pending.addAll(paths) + onCopied(copied) + } else { + AgentAttachments.discard(context, paths) + onCopied(emptyList()) + } + } + }, "agent-attach").start() +} + +/** Attaches what the running game shows, taken from its own surface so nothing drawn over it is in the picture. */ +private fun attachGameFrame(context: Context) { + val grab = AgentAttachments.gameFrame ?: return + val chat = AgentHost.chat + grab frame@{ frame -> + if (frame == null) { + Toast.makeText(context, R.string.agent_attach_game_failed, Toast.LENGTH_SHORT).show() + return@frame + } + Thread({ + val path = AgentAttachments.saveFrame(context, chat, frame) + frame.recycle() + android.os.Handler(android.os.Looper.getMainLooper()).post { + when { + path == null -> Toast.makeText(context, R.string.agent_attach_game_failed, Toast.LENGTH_SHORT).show() + AgentHost.chat == chat -> AgentAttachments.pending.add(path) + else -> AgentAttachments.discard(context, listOf(path)) + } + } + }, "agent-game-frame").start() + } +} + +/** Shown in place of the keyboard: recent photos to tap onto the message, and the system picker for anything else. */ +@Composable +internal fun AgentPhotoTray(height: Dp, copies: SnapshotStateMap, copying: SnapshotStateMap, onFiles: (() -> Unit)?) { + val context = LocalContext.current + val pal = LocalPalette.current + var access by remember { mutableStateOf(AgentPhotos.access(context)) } + var photos by remember { mutableStateOf?>(null) } + var reloads by remember { mutableStateOf(0) } + // A window no activity owns (the floating pet's chat) cannot ask for a permission, so it sends the user to the app's settings. + val launcher = if (LocalActivityResultRegistryOwner.current != null) { + rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { + AgentAttachments.picking = false + access = AgentPhotos.access(context) + if (access == AgentPhotos.Access.NONE) AgentPhotos.refused = true + reloads++ + } + } else null + val request = { + if (launcher != null && !AgentPhotos.refused) { + AgentAttachments.pick { launcher.launch(AgentPhotos.permissions()) } + } else { + val details = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + context.packageName)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + runCatching { context.startActivity(details) } + } + Unit + } + // Access can change in Settings, and new pictures arrive, while the app is in the background. + val lifecycle = LocalLifecycleOwner.current.lifecycle + DisposableEffect(lifecycle) { + val observer = LifecycleEventObserver { _, event -> + if (event == Lifecycle.Event.ON_RESUME) { + access = AgentPhotos.access(context) + reloads++ + } + } + lifecycle.addObserver(observer) + onDispose { lifecycle.removeObserver(observer) } + } + LaunchedEffect(access, reloads) { + photos = if (access == AgentPhotos.Access.NONE) emptyList() else withContext(Dispatchers.IO) { AgentPhotos.recent(context) } + } + LazyVerticalGrid( + GridCells.Adaptive(96.dp), + Modifier.fillMaxWidth().height(height).padding(top = 8.dp).testTag("agent-photo-tray"), + horizontalArrangement = Arrangement.spacedBy(4.dp), + verticalArrangement = Arrangement.spacedBy(4.dp), + ) { + if (AgentAttachments.gameFrame != null) item { + TrayTile(Icons.Outlined.PhotoCamera, stringResource(R.string.agent_attach_game), "agent-game-frame") { attachGameFrame(context) } + } + if (onFiles != null) item { TrayTile(Icons.Outlined.FolderOpen, stringResource(R.string.agent_attach_files), "agent-attach-files", onFiles) } + if (access != AgentPhotos.Access.ALL) item { + TrayTile( + Icons.Outlined.PhotoLibrary, + stringResource(if (access == AgentPhotos.Access.NONE) R.string.agent_photos_allow else R.string.agent_photos_more), + "agent-photos-allow", + onClick = request, + ) + } + val list = photos + if (list != null && list.isEmpty() && access != AgentPhotos.Access.NONE) item(span = { GridItemSpan(maxLineSpan) }) { + Text( + stringResource(R.string.agent_photos_empty), fontSize = 13.sp, color = pal.onSurfaceVariant, textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth().padding(16.dp), + ) + } + items(list.orEmpty(), key = { it.uri.toString() }) { photo -> + val uri = photo.uri + val path = copies[uri] + val selected = path != null && path in AgentAttachments.pending + Box( + Modifier.aspectRatio(1f).clip(Shape12).background(pal.surfaceVariant) + .then(if (selected) Modifier.border(3.dp, pal.primary, Shape12) else Modifier) + .clickable { + when { + selected -> AgentAttachments.pending.remove(path) + path != null && AgentAttachments.host(context, path).exists() -> AgentAttachments.pending.add(path) + uri in copying -> Unit + else -> { + // Leaving the conversation clears the markers, so a copy started before that is no longer current even back in it. + val copy = Any() + copying[uri] = copy + attachUris(context, listOf(uri), current = { copying[uri] === copy }) { copied -> + copied.forEach { (u, p) -> copies[u] = p } + if (copying[uri] === copy) copying.remove(uri) + } + } + } + }.semantics { + contentDescription = photo.name + this.selected = selected + }.testTag("agent-photo"), + ) { + AsyncImage( + model = ImageRequest.Builder(context).data(uri).size(320).build(), contentDescription = null, + contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize(), + ) + if (selected) Box( + contentAlignment = Alignment.Center, + modifier = Modifier.align(Alignment.TopEnd).padding(6.dp).size(22.dp).clip(CircleShape).background(pal.primary), + ) { + Icon(Icons.Outlined.Check, null, tint = pal.onPrimary, modifier = Modifier.size(16.dp)) + } + } + } + } +} + +@Composable +private fun TrayTile(icon: ImageVector, label: String, tag: String, onClick: () -> Unit) { + val pal = LocalPalette.current + Column( + horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center, + modifier = Modifier.aspectRatio(1f).clip(Shape12).background(pal.surfaceVariant).clickable(onClick = onClick).padding(8.dp).testTag(tag), + ) { + Icon(icon, null, tint = pal.onBackground, modifier = Modifier.size(26.dp)) + Text( + label, fontSize = 12.sp, color = pal.onBackground, textAlign = TextAlign.Center, maxLines = 3, overflow = TextOverflow.Ellipsis, + modifier = Modifier.padding(top = 6.dp), + ) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPictureViewer.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPictureViewer.kt new file mode 100644 index 0000000000..3dea67d609 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPictureViewer.kt @@ -0,0 +1,113 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.awaitEachGesture +import androidx.compose.foundation.gestures.awaitFirstDown +import androidx.compose.foundation.gestures.calculatePan +import androidx.compose.foundation.gestures.calculateZoom +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Close +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.input.pointer.positionChanged +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Popup +import androidx.compose.ui.window.PopupProperties +import coil.compose.AsyncImage +import com.droiddeck.launcher.R +import kotlin.math.abs + +private const val MAX_ZOOM = 5f +private const val TAP_ZOOM = 2.5f + +/** + * A picture over the whole window: pinch or double-tap to zoom, drag to pan. A tap, a swipe down, + * Back or B close it. It is a popup, not a dialog, because the pet's chat lives in an overlay window, + * which has no activity token to show a dialog with. + */ +@Composable +internal fun PictureViewer(model: Any, description: String?, onDismiss: () -> Unit) { + Popup( + alignment = Alignment.Center, onDismissRequest = onDismiss, + properties = PopupProperties(focusable = true, dismissOnBackPress = true, dismissOnClickOutside = false), + ) { + var size by remember { mutableStateOf(IntSize.Zero) } + var scale by remember { mutableFloatStateOf(1f) } + var offset by remember { mutableStateOf(Offset.Zero) } + fun clamp(o: Offset, s: Float): Offset { + val x = size.width * (s - 1f) / 2f + val y = size.height * (s - 1f) / 2f + return Offset(o.x.coerceIn(-x, x), o.y.coerceIn(-y, y)) + } + val fade = if (scale == 1f && size.height > 0) (1f - abs(offset.y) / size.height * 2f).coerceIn(0.3f, 1f) else 1f + Box( + Modifier.fillMaxSize().onSizeChanged { size = it }.background(Color.Black.copy(alpha = 0.94f * fade)) + .pointerInput(Unit) { + detectTapGestures( + onDoubleTap = { at -> + if (scale > 1f) { scale = 1f; offset = Offset.Zero } else { + scale = TAP_ZOOM + offset = clamp((Offset(size.width / 2f, size.height / 2f) - at) * (TAP_ZOOM - 1f), TAP_ZOOM) + } + }, + onTap = { if (scale == 1f) onDismiss() }, + ) + } + .pointerInput(Unit) { + awaitEachGesture { + awaitFirstDown(requireUnconsumed = false) + do { + val event = awaitPointerEvent() + val zoom = event.calculateZoom() + val pan = event.calculatePan() + if (zoom != 1f || pan != Offset.Zero) { + val next = (scale * zoom).coerceIn(1f, MAX_ZOOM) + offset = if (next > 1f) clamp(offset * (next / scale) + pan, next) else Offset(0f, offset.y + pan.y) + scale = next + event.changes.forEach { if (it.positionChanged()) it.consume() } + } + } while (event.changes.any { it.pressed }) + if (scale == 1f) { + if (abs(offset.y) > size.height / 6f) onDismiss() else offset = Offset.Zero + } + } + }, + ) { + AsyncImage( + model = model, contentDescription = description, contentScale = ContentScale.Fit, + modifier = Modifier.fillMaxSize().graphicsLayer { + scaleX = scale; scaleY = scale; translationX = offset.x; translationY = offset.y + }, + ) + IconButton( + onClick = onDismiss, + modifier = Modifier.align(Alignment.TopEnd).padding(12.dp).size(44.dp).clip(CircleShape).background(Color.Black.copy(alpha = 0.5f)), + ) { + Icon(Icons.Outlined.Close, stringResource(R.string.common_close), tint = Color.White) + } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt index 25b01904d8..615d59cb61 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentSetupView.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.platform.testTag import com.droiddeck.launcher.agent.AgentSetup.Status import com.droiddeck.launcher.agent.AgentSetup.Step import com.droiddeck.launcher.core.WirelessAdbPairingService +import com.droiddeck.launcher.session.QuestExperimental @Composable internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifier, onDone: () -> Unit = {}) { @@ -104,11 +105,16 @@ internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifie var keyOpen by rememberSaveable(harness.id) { mutableStateOf(false) } val (title, hint) = labels(step, harness.name, keyed) val lab = AgentHost.lab?.takeIf { it.prepare && it.running } + val questConnection = step == Step.CONNECTION && status != Status.DONE && QuestExperimental.isSupported() val detail = when { step == Step.PREPARE && lab != null -> stringResource(R.string.agent_prepare_progress, lab.permille / 10, clock(lab.etaSeconds.toLong().coerceAtLeast(0))) keyed && status == Status.DONE && AgentSetup.detail[step] == null -> harness.providers.filter { it.id in AgentSetup.keys }.joinToString(" · ") { it.name }.ifEmpty { stringResource(R.string.agent_step_free_models) } + // The Quest hint holds the one-time commands, so it stays under the status until the step passes. + questConnection -> AgentSetup.detail[step]?.let { "$it\n$hint" } ?: hint + // The Quest hint is setup instructions; once connected, the row says what it is for. + step == Step.CONNECTION && QuestExperimental.isSupported() -> AgentSetup.detail[step] ?: stringResource(R.string.agent_step_connection_hint) else -> AgentSetup.detail[step] ?: hint } // Shown while the sign-in is pending, so it is still there after a trip to the browser for the key. @@ -121,6 +127,7 @@ internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifie Status.TODO, Status.FAILED -> CheckState.WARN }, title, detail, divider = index < steps.lastIndex && !showKey, + detailLines = if (questConnection) Int.MAX_VALUE else 2, ) { val blocked = (step in setOf(Step.SIGN_IN, Step.GITHUB, Step.BUILD_TOOLS) && AgentSetup.status[Step.INSTALL] != Status.DONE) || (step == Step.PREPARE && AgentSetup.status[Step.BUILD_TOOLS] != Status.DONE) @@ -258,7 +265,9 @@ internal fun agentStorageWarning(item: AgentStorage.Item) = when (item) { @Composable private fun labels(step: Step, harness: String, keyed: Boolean = false): Pair = when (step) { - Step.CONNECTION -> stringResource(R.string.agent_step_connection) to stringResource(R.string.agent_step_connection_hint) + Step.CONNECTION -> stringResource(R.string.agent_step_connection) to + if (QuestExperimental.isSupported()) stringResource(R.string.agent_step_connection_quest_hint, LocalContext.current.packageName) + else stringResource(R.string.agent_step_connection_hint) Step.INSTALL -> stringResource(R.string.agent_step_install, harness) to stringResource(R.string.agent_step_install_hint) Step.SIGN_IN -> stringResource(R.string.agent_step_sign_in, harness) to stringResource(if (keyed) R.string.agent_step_sign_in_key_hint else R.string.agent_step_sign_in_hint) Step.GITHUB -> stringResource(R.string.agent_step_github) to stringResource(R.string.agent_step_github_hint) @@ -267,7 +276,7 @@ private fun labels(step: Step, harness: String, keyed: Boolean = false): Pair R.string.agent_action_pair + Step.CONNECTION -> if (QuestExperimental.isSupported()) R.string.agent_action_allow else R.string.agent_action_pair Step.INSTALL -> R.string.agent_action_install Step.SIGN_IN, Step.GITHUB -> R.string.agent_action_sign_in Step.BUILD_TOOLS -> R.string.agent_action_install @@ -276,6 +285,7 @@ private fun action(step: Step): Int = when (step) { /** The pairing DroidDeck already uses for the phantom process fix; the agent reuses its key. */ private fun pair(context: android.content.Context) { + if (QuestExperimental.isSupported()) return AgentSetup.trustOnDevice(context) if (!WirelessAdbPairingService.notificationsEnabled(context)) { context.startActivity(android.content.Intent(android.provider.Settings.ACTION_APP_NOTIFICATION_SETTINGS) .putExtra(android.provider.Settings.EXTRA_APP_PACKAGE, context.packageName) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AirTriggerGlow.kt b/app/src/main/java/com/droiddeck/launcher/ui/AirTriggerGlow.kt new file mode 100644 index 0000000000..d4d734fa02 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/AirTriggerGlow.kt @@ -0,0 +1,62 @@ +package com.droiddeck.launcher.ui + +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Canvas +import android.graphics.Color +import android.graphics.LinearGradient +import android.graphics.Paint +import android.graphics.Shader +import android.view.View +import android.widget.FrameLayout +import com.droiddeck.launcher.input.AirTrigger +import java.util.EnumMap +import java.util.EnumSet + +@SuppressLint("ViewConstructor") +class AirTriggerGlow(context: Context) : View(context) { + private val lit = EnumSet.noneOf(AirTrigger::class.java) + private val density = resources.displayMetrics.density + private val paints = EnumMap(AirTrigger::class.java) + + init { + isClickable = false + isFocusable = false + importantForAccessibility = IMPORTANT_FOR_ACCESSIBILITY_NO + layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT) + val top = TOP_DP * density + for ((trigger, look) in mapOf(AirTrigger.LEFT to LEFT, AirTrigger.RIGHT to RIGHT)) { + val (color, fade) = look + paints[trigger] = Paint().apply { + shader = LinearGradient(0f, top, 0f, top + HEIGHT_DP * density, + fade.map { Color.argb(it, Color.red(color), Color.green(color), Color.blue(color)) }.toIntArray(), + STOPS, Shader.TileMode.CLAMP) + } + } + } + + fun show(trigger: AirTrigger, on: Boolean) { + if (if (on) lit.add(trigger) else lit.remove(trigger)) invalidate() + } + + override fun onDraw(canvas: Canvas) { + val width = WIDTH_DP * density + val margin = SIDE_DP * density + val top = TOP_DP * density + for (trigger in lit) { + val left = if (trigger == AirTrigger.LEFT) margin else this.width - margin - width + canvas.drawRect(left, top, left + width, top + HEIGHT_DP * density, paints.getValue(trigger)) + } + } + + private companion object { + // Game Space's tgk_*_top_pressed images and their landscape placement on a 2688 x 1216 RedMagic screen. + const val WIDTH_DP = 78f + const val HEIGHT_DP = 33f + const val SIDE_DP = 37f + const val TOP_DP = 2f + val STOPS = floatArrayOf(0f, 0.04f, 0.05f, 0.2f, 0.4f, 0.6f, 0.8f, 1f) + val LEFT = Color.rgb(230, 23, 57) to listOf(255, 255, 150, 102, 55, 36, 18, 0) + val RIGHT = Color.rgb(23, 91, 230) to listOf(255, 255, 151, 94, 41, 27, 14, 0) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt new file mode 100644 index 0000000000..8d4c3b8bc8 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomArtPanel.kt @@ -0,0 +1,129 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.animation.Crossfade +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.RepeatMode +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.core.tween +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.widthIn +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import coil.compose.AsyncImage +import com.droiddeck.launcher.R +import com.droiddeck.launcher.agent.AgentGuest +import com.droiddeck.launcher.frontend.Library +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.withContext + +private const val ART_POLL_MS = 2_000L +private const val RESCAN_MS = 30_000L +private const val DRIFT_MS = 28_000 + +/** The game's art filling the bottom screen with a slow pan and zoom, for the running game or the one selected in Steam. */ +@Composable +internal fun ArtPanel(runningGame: () -> String?) { + val context = LocalContext.current.applicationContext + var game by remember { mutableStateOf(null) } + var playing by remember { mutableStateOf(false) } + FullScreenChrome() + LaunchedEffect(Unit) { + var games = emptyList() + var scanned = 0L + while (isActive) { + val running = runningGame()?.toLongOrNull() + val shown = running ?: withContext(Dispatchers.IO) { runCatching { AgentGuest.selectedSteamAppId(context) }.getOrNull() } + val missing = games.isEmpty() || (shown != null && games.none { it.appId.toLong() == shown }) + if (missing && (scanned == 0L || System.currentTimeMillis() - scanned > RESCAN_MS)) { + withContext(Dispatchers.IO) { runCatching { Library.steamGames(context) }.getOrNull() }?.let { games = it } + scanned = System.currentTimeMillis() + } + // Reloaded every poll so stats that failed to load once still arrive; the crossfade is keyed by app id. + // A running game that cannot be loaded is not stood in for by another game's art. + val loaded = withContext(Dispatchers.IO) { IdleHome.load(context, games, shown) } + ?.takeIf { running == null || (it.appId.toLong() and 0xFFFFFFFFL) == running } + if (loaded != game) game = loaded + playing = running != null && running == game?.appId?.toLong() + delay(ART_POLL_MS) + } + } + Box(Modifier.fillMaxSize().background(Color.Black).testTag("bottom-art")) { + // Keyed by app id so a refreshed game keeps its pan; the fading-out scene keeps its last details. + val seen = remember { HashMap() } + game?.let { seen[it.appId] = it } + Crossfade(game?.appId, label = "art") { id -> + // Read from state here, so refreshed details for the same game recompose this scene. + val shown = game?.takeIf { it.appId == id } ?: seen[id] + if (shown != null) ArtScene(shown, playing) + } + } +} + +@Composable +private fun ArtScene(game: IdleGame, playing: Boolean) { + val drift = rememberInfiniteTransition(label = "drift") + val t by drift.animateFloat(0f, 1f, infiniteRepeatable(tween(DRIFT_MS, easing = LinearEasing), RepeatMode.Reverse), label = "t") + val eased = t * t * (3 - 2 * t) + BoxWithConstraints(Modifier.fillMaxSize()) { + if (game.art != null) AsyncImage( + model = game.art, contentDescription = null, contentScale = ContentScale.Crop, + modifier = Modifier.fillMaxSize().graphicsLayer { + val scale = 1.08f + 0.14f * eased + scaleX = scale + scaleY = scale + translationX = (eased - 0.5f) * size.width * (scale - 1f) + translationY = (0.5f - eased) * size.height * (scale - 1f) * 0.5f + }, + ) + Box( + Modifier.fillMaxSize().background( + Brush.verticalGradient(0.55f to Color.Transparent, 1f to Color.Black.copy(alpha = 0.78f)), + ), + ) + Column(Modifier.align(Alignment.BottomStart).padding(28.dp).fillMaxWidth(0.6f)) { + Text( + stringResource(if (playing) R.string.bottom_art_playing else if (game.highlighted) R.string.bottom_idle_selected + else R.string.bottom_idle_recent).uppercase(), + fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.4.sp, color = Color.White.copy(alpha = 0.7f), + ) + if (game.logo != null) AsyncImage( + model = game.logo, contentDescription = game.name, contentScale = ContentScale.Fit, alignment = Alignment.BottomStart, + modifier = Modifier.padding(top = 10.dp).widthIn(max = 460.dp).height(128.dp), + ) else Text( + game.name, fontSize = 34.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 2, + overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 4.dp), + ) + Text(idleDetails(game), fontSize = 14.sp, color = Color.White.copy(alpha = 0.75f), maxLines = 1, + modifier = Modifier.padding(top = 8.dp)) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomBrightness.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomBrightness.kt new file mode 100644 index 0000000000..2cc7f31fad --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomBrightness.kt @@ -0,0 +1,84 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import android.provider.Settings +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.DarkMode +import androidx.compose.material.icons.outlined.LightMode +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.SessionPrefs + +/** The bottom screen's own brightness, in percent. It never goes below [MIN] so the slider cannot leave the screen dark. */ +internal object BottomBrightness { + const val MIN = 5 + const val STEP = 5 + + /** The window brightness to use while the screen is on, or null to follow the system. */ + fun level(context: Context): Float? = SessionPrefs.bottomBrightness(context)?.let { clamp(it) / 100f } + + fun clamp(percent: Int): Int = percent.coerceIn(MIN, 100) + + /** Where the slider starts: the saved level, else the system brightness as a percentage. */ + fun initial(context: Context): Int = clamp(SessionPrefs.bottomBrightness(context) ?: runCatching { + Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS) * 100 / 255 + }.getOrDefault(60)) + + /** Auto-dim never brightens a screen the user set darker, here or in the system's manual brightness. */ + fun dimmed(context: Context, dim: Float): Float = minOf(dim, level(context) ?: system(context) ?: dim) + + private fun system(context: Context): Float? = runCatching { + val resolver = context.contentResolver + if (Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE) != Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) null + else Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) / 255f + }.getOrNull() +} + +/** A dropdown under the bottom bar: a brightness slider and the screen-off button. A tap outside closes it. */ +@Composable +internal fun BrightnessDrop(percent: Int, onChange: (Int) -> Unit, onScreenOff: () -> Unit, onDismiss: () -> Unit) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val shape = RoundedCornerShape(16.dp) + Box( + Modifier.fillMaxSize().clickable(remember { MutableInteractionSource() }, indication = null, onClick = onDismiss) + .padding(top = BAR_HEIGHT, start = 12.dp, end = 12.dp), + ) { + Row( + Modifier.fillMaxWidth().testTag("bottom-brightness").clip(shape).background(colors.surface).border(1.dp, pal.line, shape) + .clickable(remember { MutableInteractionSource() }, indication = null) {} + .padding(horizontal = 12.dp, vertical = 6.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp), + ) { + Icon(Icons.Outlined.LightMode, contentDescription = null, tint = colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) + ValueSlider( + percent, BottomBrightness.MIN..100, BottomBrightness.STEP, true, stringResource(R.string.bottom_brightness), { "$it%" }, + modifier = Modifier.weight(1f), track = 32.dp, onChange = onChange, + ) + BarButton(stringResource(R.string.bottom_screen_off), Modifier.testTag("bottom-brightness-off"), vector = Icons.Filled.DarkMode, + onClick = onScreenOff) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomChrome.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomChrome.kt new file mode 100644 index 0000000000..2d714863e2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomChrome.kt @@ -0,0 +1,88 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectVerticalDragGestures +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.R + +/** Whether the bottom screen's bar is shown. Panels that need the whole screen ask for it hidden; a pull tab brings it back. */ +internal object BottomChrome { + private val requests = mutableIntStateOf(0) + + /** The user's choice, which wins until a panel's request changes; null follows the requests. */ + private val chosen = mutableStateOf(null) + + val barShown: Boolean get() = chosen.value ?: (requests.intValue == 0) + + fun show(shown: Boolean) { + chosen.value = shown + } + + fun reset() { + chosen.value = null + } + + internal fun request(on: Boolean) { + requests.intValue = (requests.intValue + if (on) 1 else -1).coerceAtLeast(0) + chosen.value = null + } +} + +/** Asks for the bar hidden while this is composed, as art, a page being read or a map being viewed do. */ +@Composable +internal fun FullScreenChrome() { + DisposableEffect(Unit) { + BottomChrome.request(true) + onDispose { BottomChrome.request(false) } + } +} + +private const val PULL_PX = 6f + +/** The tab at the top edge that brings the hidden bar back, by a tap or a pull down. */ +@Composable +internal fun PullTab() { + val description = stringResource(R.string.bottom_bar_show) + val shape = RoundedCornerShape(bottomStart = 14.dp, bottomEnd = 14.dp) + Box(Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.testTag("bottom-pull-tab").size(width = 72.dp, height = 26.dp) + .semantics { contentDescription = description } + .clip(shape).background(Color.Black.copy(alpha = 0.55f)).border(1.dp, Color.White.copy(alpha = 0.14f), shape) + .pointerInput(Unit) { + var pulled = 0f + detectVerticalDragGestures(onDragStart = { pulled = 0f }, onDragEnd = { pulled = 0f }, onDragCancel = { pulled = 0f }) { change, drag -> + pulled = (pulled + drag).coerceAtLeast(0f) + if (pulled > PULL_PX) { change.consume(); pulled = 0f; BottomChrome.show(true) } + } + } + .clickable(role = Role.Button) { BottomChrome.show(true) }, + ) { + Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = Color.White.copy(alpha = 0.85f), modifier = Modifier.size(22.dp)) + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt index 6838a17760..21a685eee9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomDashboard.kt @@ -68,7 +68,8 @@ internal object SessionBottomTab { } } -internal fun pageForGameStart(ids: List): String? = GAME_PAGE.takeIf { it in ids } +internal fun pageForGameStart(ids: List, remembered: String? = null): String? = + remembered?.takeIf { it in ids } ?: GAME_PAGE.takeIf { it in ids } private const val DEFAULT_PAGE = "telemetry" private const val GAME_PAGE = "telemetry" @@ -81,13 +82,14 @@ internal fun BottomDashboard( onPage: (String) -> Unit, bar: BottomBarModel? = null, gameStarts: Int = 0, + gamePage: () -> String? = { null }, strip: (@Composable (String?) -> Unit)? = null, ) { val colors = MaterialTheme.colorScheme - var current by remember { mutableStateOf(pickBottomPage(remembered, pages.map { it.id })) } + var current by remember { mutableStateOf(gamePage()?.takeIf { id -> pages.any { it.id == id } } ?: pickBottomPage(remembered, pages.map { it.id })) } val startsWhenOpened = remember { gameStarts } LaunchedEffect(gameStarts) { - if (gameStarts != startsWhenOpened) pageForGameStart(pages.map { it.id })?.let { current = it } + if (gameStarts != startsWhenOpened) pageForGameStart(pages.map { it.id }, gamePage())?.let { current = it } } val page = pages.firstOrNull { it.id == current } ?: pages.firstOrNull() Column(Modifier.fillMaxSize().background(colors.background)) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomDesktopPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomDesktopPanel.kt index c9e8362c4d..38359530db 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomDesktopPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomDesktopPanel.kt @@ -46,7 +46,11 @@ class BottomDesktopPanel( private val status = ComposeView(context).apply { setContent { DroidDeckTheme { BottomDesktopStatus(state.value, ::startAgain) } } } - private val keyboardHost = KeyboardHost(context) { event -> sendKey(event) } + private val keyboardHost = KeyboardHost( + context, + sendKeyEvent = { event -> sendKey(event) }, + sendText = BottomDesktop::sendText, + ) private var directTouch = SessionPrefs.bottomDesktopDirectTouch(context) private val touchMode = mutableStateOf(directTouch) private val trackpad = TouchpadGestures(ViewConfiguration.get(context).scaledTouchSlop.toFloat(), TrackpadInput()).apply { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt new file mode 100644 index 0000000000..832d100e1c --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomGuidesPage.kt @@ -0,0 +1,585 @@ +package com.droiddeck.launcher.ui + +import android.annotation.SuppressLint +import android.graphics.BitmapFactory +import android.net.Uri +import android.view.ViewGroup +import android.webkit.CookieManager +import android.webkit.RenderProcessGoneDetail +import android.webkit.WebResourceRequest +import android.webkit.WebView +import android.webkit.WebViewClient +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.gestures.detectTransformGestures +import androidx.compose.foundation.horizontalScroll +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.compose.ui.viewinterop.AndroidView +import coil.compose.AsyncImage +import com.droiddeck.launcher.R +import com.droiddeck.launcher.stores.SteamAchievements +import androidx.compose.foundation.verticalScroll +import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.session.GameLinks +import com.droiddeck.launcher.session.GuideLibrary +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.SteamGuides +import com.droiddeck.launcher.session.SteamWebLogin +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.launch +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext +import java.io.File +import kotlin.coroutines.resume + +private sealed class GuideList { + object Loading : GuideList() + object Failed : GuideList() + class Found(val guides: List) : GuideList() +} + +internal enum class GuideSection(val label: Int) { + GUIDES(R.string.bottom_page_guides), + ACHIEVEMENTS(R.string.achievements_title), + WIKI(R.string.bottom_guides_wiki), + MAPS(R.string.bottom_guides_maps), + SAVED(R.string.bottom_guides_saved), +} + +private val TAG_LABELS = listOf( + null to R.string.bottom_guides_tag_all, + "Walkthroughs" to R.string.bottom_guides_tag_walkthroughs, + "Achievements" to R.string.achievements_title, + "Secrets" to R.string.bottom_guides_tag_secrets, + "Maps or Levels" to R.string.bottom_guides_maps, +) + +@Composable +internal fun GuidesPanel(runningGame: () -> String?) { + val context = LocalContext.current + val id = rememberShownGame(runningGame) + if (id == null) { + PanelNote(stringResource(R.string.bottom_guides_no_game)) + return + } + val game = id.toString() + val scope = rememberCoroutineScope() + val host = rememberMenuHost() + val firstGame = remember { id } + var reading by remember(id) { mutableStateOf(if (id == firstGame) SteamGuides.place(context, game)?.url else null) } + var section by remember(id) { mutableStateOf(GuideSection.GUIDES) } + var tag by remember(id) { mutableStateOf(null) } + var list by remember(id) { mutableStateOf(GuideList.Loading) } + var cookieHeader by remember(id) { mutableStateOf(null) } + var name by remember(id) { mutableStateOf(null) } + var openMap by remember(id) { mutableStateOf(null) } + if (reading != null || openMap != null) FullScreenChrome() + var libraryRevision by remember(id) { mutableIntStateOf(0) } + var note by remember(id) { mutableStateOf(null) } + LaunchedEffect(id) { + val cookies = withContext(Dispatchers.IO) { + runCatching { + SteamWebLogin.read(LinuxRuntime.rootDir(context), SessionState.steamClientArch, File(context.cacheDir, "steam-web-login")) + }.getOrDefault(emptyList()) + } + val manager = CookieManager.getInstance() + for (c in cookies) suspendCancellableCoroutine { cont -> manager.setCookie("https://${c.host}", c.header) { cont.resume(Unit) } } + cookieHeader = cookies.filter { steamChatAllows(it.host) }.joinToString("; ") { it.header.substringBefore(';') } + name = withContext(Dispatchers.IO) { IdleHome.overview(context, id)?.name } + } + LaunchedEffect(id, tag, cookieHeader) { + val header = cookieHeader ?: return@LaunchedEffect + list = GuideList.Loading + list = withContext(Dispatchers.IO) { SteamGuides.list(id, header, tag) }?.let { GuideList.Found(it) } ?: GuideList.Failed + } + val pinnedMsg = stringResource(R.string.bottom_guides_pinned) + val pinFailedMsg = stringResource(R.string.bottom_guides_pin_failed) + val savedMsg = stringResource(R.string.bottom_guides_saved_note) + openMap?.let { map -> + MapViewer(map, onBack = { openMap = null; libraryRevision++ }, onDelete = { + GuideLibrary.delete(map) + openMap = null + libraryRevision++ + }) + return + } + reading?.let { open -> + // A new game or page needs a new WebView: its factory runs once and keeps the first page's callbacks. + key(game, open) { + GuideReaderPanel( + url = open, + scroll = SteamGuides.place(context, game)?.takeIf { it.url == open }?.scroll ?: 0f, + note = note, + onBack = { reading = null; note = null }, + onPlace = { url, s -> SteamGuides.savePlace(context, game, url, s) }, + onSave = { view -> + val file = GuideLibrary.savedFile(context, game) + val title = view.title.orEmpty() + val url = view.url.orEmpty() + view.saveWebArchive(file.path, false) { path -> + if (path != null) { + GuideLibrary.recordSaved(file, title, url) + note = savedMsg + libraryRevision++ + } + } + }, + onPin = { image -> + scope.launch { + val cookies = CookieManager.getInstance().getCookie(image) + val file = withContext(Dispatchers.IO) { GuideLibrary.pin(context, game, image, cookies) } + note = if (file != null) pinnedMsg else pinFailedMsg + libraryRevision++ + } + }, + onStopped = { reading = null }, + ) + } + return + } + PanelColumn { + TabStrip(GuideSection.entries.map { stringResource(it.label) }, section.ordinal, { section = GuideSection.entries[it] }, + modifier = Modifier.fillMaxWidth(), compact = true, centered = true) + Column(Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState())) { + when (section) { + GuideSection.GUIDES -> GuidesSection(host, list, tag, SteamGuides.place(context, game), onTag = { tag = it }, onOpen = { reading = it }) + GuideSection.ACHIEVEMENTS -> AchievementsSection(id) + GuideSection.WIKI -> WikiSection(id, name, onOpen = { reading = it }) + GuideSection.MAPS -> MapsSection(id, game, name, libraryRevision, onOpenMap = { openMap = it }, onOpen = { reading = it }) + GuideSection.SAVED -> SavedSection(game, libraryRevision, onOpen = { reading = Uri.fromFile(it).toString() }, onDelete = { + GuideLibrary.delete(it) + libraryRevision++ + }) + } + } + } +} + +@Composable +private fun GuidesSection( + host: MenuHost, list: GuideList, tag: String?, last: SteamGuides.Place?, onTag: (String?) -> Unit, onOpen: (String) -> Unit, +) { + SettingsGroup(stringResource(R.string.bottom_guides_steam)) { + if (last != null) PanelRow(stringResource(R.string.bottom_guides_continue), onClick = { onOpen(last.url) }, tag = "bottom-guides-continue", + trailing = { SecondaryButton(stringResource(R.string.store_open), compact = true) { onOpen(last.url) } }) + ChoiceRow(host, "guides-tag", stringResource(R.string.bottom_guides_category), null, + TAG_LABELS.map { (value, label) -> value to stringResource(label) }, tag) { onTag(it) } + when (list) { + GuideList.Loading -> PanelRow(stringResource(R.string.achievements_reading)) + GuideList.Failed -> PanelRow(stringResource(R.string.bottom_guides_failed)) + is GuideList.Found -> + if (list.guides.isEmpty()) PanelRow(stringResource(R.string.bottom_guides_empty)) + else for (guide in list.guides) GuideRow(guide) { onOpen(guide.url) } + } + } +} + +@Composable +private fun AchievementsSection(appId: Long) { + val game = remember(appId) { SteamAchievements.game(appId) } + val state = rememberAchievements(game) ?: return + Box(Modifier.padding(top = 8.dp)) { AchievementsTab(SteamAchievements.label, state) } +} + +@Composable +private fun WikiSection(appId: Long, name: String?, onOpen: (String) -> Unit) { + val context = LocalContext.current + var links by remember(appId) { mutableStateOf?>(null) } + var tier by remember(appId) { mutableStateOf(null) } + LaunchedEffect(appId, name) { + val (found, t) = withContext(Dispatchers.IO) { + val pending = async { GameLinks.protonTier(appId) } + GameLinks.links(context, appId, name) to pending.await() + } + tier = t + links = found + } + val open = stringResource(R.string.store_open) + val found = links + if (found == null) { + SettingsGroup(stringResource(R.string.bottom_guides_wiki)) { PanelRow(stringResource(R.string.achievements_reading)) } + return + } + tier?.let { t -> + SettingsGroup(stringResource(R.string.fex_compatibility_label)) { + PanelRow(stringResource(R.string.bottom_guides_protondb), tag = "guides-protondb", onClick = { onOpen("https://www.protondb.com/app/$appId") }, + trailing = { PanelValue(stringResource(tierLabel(t)), tierColor(t)) }) + } + } + SettingsGroup(stringResource(R.string.bottom_guides_wiki)) { + for (link in found.filter { it.kind != GameLinks.Kind.MAPGENIE }) PanelRow(stringResource(linkLabel(link.kind)), Uri.parse(link.url).host.orEmpty().removePrefix("www."), + onClick = { onOpen(link.url) }, + trailing = { SecondaryButton(open, compact = true, modifier = Modifier.testTag("guides-link-${link.kind.name.lowercase()}")) { onOpen(link.url) } }) + } + name?.let { n -> + SettingsGroup(stringResource(R.string.bottom_guides_search)) { + for (s in GameLinks.searches(n, found)) PanelRow(stringResource(searchLabel(s.id)), n, onClick = { onOpen(s.url) }, + trailing = { SecondaryButton(open, compact = true, modifier = Modifier.testTag("guides-search-${s.id}")) { onOpen(s.url) } }) + } + } +} + +@Composable +private fun MapsSection(appId: Long, game: String, name: String?, revision: Int, onOpenMap: (File) -> Unit, onOpen: (String) -> Unit) { + val context = LocalContext.current + var maps by remember(game) { mutableStateOf>(emptyList()) } + LaunchedEffect(game, revision) { maps = withContext(Dispatchers.IO) { GuideLibrary.maps(context, game) } } + SettingsGroup(stringResource(R.string.bottom_guides_maps)) { + if (maps.isEmpty()) PanelRow(stringResource(R.string.bottom_guides_maps_empty), stringResource(R.string.bottom_guides_pin_hint)) + maps.forEachIndexed { i, map -> + PanelRow( + stringResource(R.string.bottom_guides_map_name, i + 1), stringResource(R.string.bottom_guides_markers, map.markers.size), + tag = "guides-map", onClick = { onOpenMap(map.file) }, + leading = { + AsyncImage(model = map.file, contentDescription = null, contentScale = ContentScale.Crop, + modifier = Modifier.size(64.dp, 40.dp).clip(RoundedCornerShape(6.dp))) + }, + ) + } + } + var mapSite by remember(name) { mutableStateOf(null) } + LaunchedEffect(name) { + if (name != null) mapSite = withContext(Dispatchers.IO) { GameLinks.links(context, appId, name) }.firstOrNull { it.kind == GameLinks.Kind.MAPGENIE } + } + mapSite?.let { link -> + val open = stringResource(R.string.store_open) + SettingsGroup(stringResource(R.string.bottom_guides_find_maps)) { + PanelRow(stringResource(R.string.bottom_guides_search_mapgenie), Uri.parse(link.url).run { host.orEmpty() + path.orEmpty() }, + onClick = { onOpen(link.url) }, + trailing = { SecondaryButton(open, compact = true, modifier = Modifier.testTag("guides-maps-mapgenie")) { onOpen(link.url) } }) + } + } +} + +@Composable +private fun SavedSection(game: String, revision: Int, onOpen: (File) -> Unit, onDelete: (File) -> Unit) { + val context = LocalContext.current + var saved by remember(game) { mutableStateOf>(emptyList()) } + LaunchedEffect(game, revision) { saved = withContext(Dispatchers.IO) { GuideLibrary.saved(context, game) } } + val delete = stringResource(R.string.common_delete) + SettingsGroup(stringResource(R.string.bottom_guides_saved)) { + if (saved.isEmpty()) PanelRow(stringResource(R.string.bottom_guides_saved_empty), stringResource(R.string.bottom_guides_saved_hint)) + for (page in saved) PanelRow(page.title, Uri.parse(page.url).host.orEmpty().removePrefix("www."), tag = "guides-saved", + onClick = { onOpen(page.file) }, + trailing = { SecondaryButton(delete, compact = true, modifier = Modifier.testTag("guides-saved-delete")) { onDelete(page.file) } }) + } +} + +@Composable +private fun GuideReaderPanel( + url: String, + scroll: Float, + note: String?, + onBack: () -> Unit, + onPlace: (String, Float) -> Unit, + onSave: (WebView) -> Unit, + onPin: (String) -> Unit, + onStopped: () -> Unit, +) { + val pal = LocalPalette.current + var view by remember { mutableStateOf(null) } + var image by remember(url) { mutableStateOf(null) } + val local = url.startsWith("file:") + PanelColumn { + Row(Modifier.fillMaxWidth().padding(bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + BackLink(stringResource(R.string.mode_back), compact = true, onClick = onBack) + Text(note ?: stringResource(R.string.bottom_guides_pin_hint), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + image?.let { img -> SecondaryButton(stringResource(R.string.bottom_guides_pin), compact = true, modifier = Modifier.testTag("bottom-guides-pin")) { onPin(img); image = null } } + if (!local) SecondaryButton(stringResource(R.string.game_env_save), compact = true, modifier = Modifier.testTag("bottom-guides-save")) { view?.let(onSave) } + } + Box(Modifier.weight(1f).fillMaxWidth().padding(bottom = 6.dp).clip(RoundedCornerShape(14.dp)).border(1.dp, pal.line, RoundedCornerShape(14.dp))) { + GuideReader(url, scroll, onPlace, onStopped, onView = { view = it }, onImage = { image = it }) + } + } +} + +@Composable +internal fun GuideRow(guide: SteamGuides.Guide, onOpen: () -> Unit) { + val pal = LocalPalette.current + PanelRow( + guide.title, + listOfNotNull(guide.author.takeIf { it.isNotEmpty() }, "★".repeat(guide.stars).takeIf { it.isNotEmpty() }).joinToString(" · "), + tag = "guide-${guide.id}", onClick = onOpen, + leading = { + Box(Modifier.size(40.dp).clip(RoundedCornerShape(6.dp)).background(pal.line)) { + if (guide.preview != null) AsyncImage(model = guide.preview, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize()) + } + }, + ) +} + +internal object ReaderAds { + private val HOSTS = setOf( + "doubleclick.net", "googlesyndication.com", "googleadservices.com", "adservice.google.com", "google-analytics.com", + "googletagservices.com", "googletagmanager.com", "amazon-adsystem.com", "adnxs.com", "criteo.com", "criteo.net", + "taboola.com", "outbrain.com", "pubmatic.com", "rubiconproject.com", "casalemedia.com", "openx.net", "moatads.com", + "scorecardresearch.com", "quantserve.com", "adsafeprotected.com", "3lift.com", "sharethrough.com", "teads.tv", + "yieldmo.com", "media.net", "smartadserver.com", "adform.net", "bidswitch.net", "lijit.com", "sonobi.com", + "indexww.com", "gumgum.com", "nativo.com", "zemanta.com", "primis.tech", "connatix.com", "playwire.com", + "fandomadtags.com", "kargo.com", "33across.com", "onetag-sys.com", "adsrvr.org", "id5-sync.com", "ezoic.net", + "ezojs.com", "mediavine.com", "intergient.com", "nitropay.com", "freestar.io", "pbxai.com", + ) + + fun blocks(host: String?): Boolean { + var h = host?.lowercase() ?: return false + while (true) { + if (h in HOSTS) return true + val dot = h.indexOf('.') + if (dot < 0 || h.indexOf('.', dot + 1) < 0) return false + h = h.substring(dot + 1) + } + } +} + +private const val REDIRECT_GRACE_MS = 10_000L + +internal fun readerAllows(start: String, target: Uri, userInitiated: Boolean): Boolean { + val host = target.host ?: return false + if (target.scheme != "https" && target.scheme != "http") return false + if (steamChatAllows(host) || userInitiated) return true + val home = Uri.parse(start).host?.let(::siteOf) ?: return false + return siteOf(host) == home +} + +private fun siteOf(host: String): String = host.split('.').takeLast(2).joinToString(".") + +@SuppressLint("SetJavaScriptEnabled") +@Composable +private fun GuideReader( + url: String, scroll: Float, onPlace: (String, Float) -> Unit, onStopped: () -> Unit, + onView: (WebView?) -> Unit, onImage: (String) -> Unit, +) { + val context = LocalContext.current + AndroidView(factory = { ctx -> + WebView(ctx).apply { + layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + isFocusable = false + isFocusableInTouchMode = false + setBackgroundColor(0xFF1B2838.toInt()) + settings.javaScriptEnabled = true + settings.domStorageEnabled = true + settings.allowContentAccess = false + settings.allowFileAccess = url.startsWith("file:") && GuideLibrary.isSaved(context, File(Uri.parse(url).path.orEmpty())) + var restore = scroll + // Opening the page and each tapped link may redirect off the site for a moment; a page's own navigation may not. + var approvedUntil = android.os.SystemClock.uptimeMillis() + REDIRECT_GRACE_MS + webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { + val now = android.os.SystemClock.uptimeMillis() + if (request.hasGesture()) approvedUntil = now + REDIRECT_GRACE_MS + return !readerAllows(url, request.url, request.hasGesture() || (request.isRedirect && now < approvedUntil)) + } + + override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): android.webkit.WebResourceResponse? = + if (ReaderAds.blocks(request.url.host)) android.webkit.WebResourceResponse("text/plain", "utf-8", java.io.ByteArrayInputStream(ByteArray(0))) + else null + + override fun onPageFinished(view: WebView, url: String) { + if (restore > 0f) { + val ratio = restore + restore = 0f + view.postDelayed({ view.scrollTo(0, (view.contentHeight * view.scale * ratio).toInt()) }, 400) + } + } + + override fun onRenderProcessGone(view: WebView, detail: RenderProcessGoneDetail): Boolean { + onStopped() + return true + } + } + setOnLongClickListener { v -> + val hit = (v as WebView).hitTestResult + val src = hit.extra + if ((hit.type == WebView.HitTestResult.IMAGE_TYPE || hit.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) && + src != null && src.startsWith("http")) { + onImage(src) + true + } else false + } + setOnScrollChangeListener { v, _, y, _, _ -> + val web = v as WebView + val height = web.contentHeight * web.scale + val current = web.url ?: return@setOnScrollChangeListener + if (height > 0) onPlace(current, y / height) + } + onView(this) + loadUrl(url) + } + }, modifier = Modifier.fillMaxSize(), onRelease = { view -> + view.url?.let { current -> onPlace(current, view.scrollY / (view.contentHeight * view.scale).coerceAtLeast(1f)) } + onView(null) + view.destroy() + }) +} + + +@Composable +private fun MapViewer(file: File, onBack: () -> Unit, onDelete: () -> Unit) { + var image by remember(file) { mutableStateOf(null) } + var markers by remember(file) { mutableStateOf(GuideLibrary.markers(file)) } + var scale by remember(file) { mutableFloatStateOf(1f) } + var offset by remember(file) { mutableStateOf(Offset.Zero) } + LaunchedEffect(file) { image = withContext(Dispatchers.IO) { decodeMap(file) } } + val pal = LocalPalette.current + PanelColumn { + Row(Modifier.fillMaxWidth().padding(bottom = 4.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + BackLink(stringResource(R.string.mode_back), compact = true, onClick = onBack) + Text(stringResource(R.string.bottom_guides_marker_hint), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis) + SecondaryButton(stringResource(R.string.common_delete), compact = true, modifier = Modifier.testTag("guides-map-delete"), onClick = onDelete) + } + Box( + Modifier.weight(1f).fillMaxWidth().padding(bottom = 6.dp).clip(RoundedCornerShape(14.dp)).background(Color.Black) + .border(1.dp, pal.line, RoundedCornerShape(14.dp)) + .pointerInput(file) { + detectTransformGestures { _, pan, zoom, _ -> + scale = (scale * zoom).coerceIn(1f, MAX_ZOOM) + offset = if (scale == 1f) Offset.Zero else offset + pan + } + }, + contentAlignment = Alignment.Center, + ) { + val img = image ?: return@Box + Box( + Modifier.aspectRatio(img.width.toFloat() / img.height) + .graphicsLayer(scaleX = scale, scaleY = scale, translationX = offset.x, translationY = offset.y) + .pointerInput(file) { + detectTapGestures( + onDoubleTap = { p -> + if (scale > 1f) { + scale = 1f + offset = Offset.Zero + } else { + scale = DOUBLE_TAP_ZOOM + offset = Offset((size.width / 2f - p.x) * DOUBLE_TAP_ZOOM, (size.height / 2f - p.y) * DOUBLE_TAP_ZOOM) + } + }, + onLongPress = { p -> + markers = markers + (p.x / size.width to p.y / size.height) + GuideLibrary.saveMarkers(file, markers) + }, + onTap = { p -> + val hit = markers.minByOrNull { (x, y) -> MapMarkers.distance(x * size.width, y * size.height, p.x, p.y) } + if (hit != null && MapMarkers.distance(hit.first * size.width, hit.second * size.height, p.x, p.y) < MARKER_HIT_PX * density / scale) { + markers = markers - hit + GuideLibrary.saveMarkers(file, markers) + } + }, + ) + }, + ) { + Image(img, null, Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds) + Canvas(Modifier.fillMaxSize()) { + for ((x, y) in markers) { + val c = Offset(x * size.width, y * size.height) + drawCircle(Color.Black.copy(alpha = 0.6f), radius = 9.dp.toPx() / scale, center = c) + drawCircle(pal.signal, radius = 6.dp.toPx() / scale, center = c) + } + } + } + } + } +} + +internal object MapMarkers { + fun distance(x0: Float, y0: Float, x1: Float, y1: Float): Float = kotlin.math.hypot(x0 - x1, y0 - y1) + + fun sampleSize(width: Int, height: Int, longest: Int): Int { + var sample = 1 + while (maxOf(width, height) / sample > longest) sample *= 2 + return sample + } +} + +private fun decodeMap(file: File): ImageBitmap? = runCatching { + val bounds = BitmapFactory.Options().apply { inJustDecodeBounds = true } + BitmapFactory.decodeFile(file.path, bounds) + val opts = BitmapFactory.Options().apply { inSampleSize = MapMarkers.sampleSize(bounds.outWidth, bounds.outHeight, MAP_LONGEST) } + BitmapFactory.decodeFile(file.path, opts)?.asImageBitmap() +}.getOrNull() + +private const val MAX_ZOOM = 8f +private const val DOUBLE_TAP_ZOOM = 2.5f +private const val MARKER_HIT_PX = 20f +private const val MAP_LONGEST = 4096 +private fun linkLabel(kind: GameLinks.Kind): Int = when (kind) { + GameLinks.Kind.WIKI -> R.string.bottom_guides_link_wiki + GameLinks.Kind.STRATEGYWIKI -> R.string.bottom_guides_link_strategywiki + GameLinks.Kind.PCGAMINGWIKI -> R.string.bottom_guides_link_pcgw + GameLinks.Kind.GAMEFAQS -> R.string.bottom_guides_link_gamefaqs + GameLinks.Kind.IGN -> R.string.bottom_guides_link_ign + GameLinks.Kind.HOWLONGTOBEAT -> R.string.bottom_guides_link_hltb + GameLinks.Kind.MAPGENIE -> R.string.bottom_guides_search_mapgenie +} + +private fun searchLabel(id: String): Int = when (id) { + "youtube" -> R.string.bottom_guides_search_youtube + else -> R.string.bottom_guides_link_gamefaqs +} + +private fun tierLabel(tier: String): Int = when (tier) { + "platinum" -> R.string.bottom_guides_tier_platinum + "gold" -> R.string.bottom_guides_tier_gold + "silver" -> R.string.bottom_guides_tier_silver + "bronze" -> R.string.bottom_guides_tier_bronze + else -> R.string.bottom_guides_tier_borked +} + +private fun tierColor(tier: String): Color = when (tier) { + "platinum" -> Color(0xFFB4C7DC) + "gold" -> Color(0xFFCFB53B) + "silver" -> Color(0xFFA6A6A6) + "bronze" -> Color(0xFFCD7F32) + else -> Color(0xFFFF6B6B) +} + diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt new file mode 100644 index 0000000000..fa97a401cc --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomIdleHome.kt @@ -0,0 +1,102 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import android.text.format.DateUtils +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import com.droiddeck.launcher.R +import com.droiddeck.launcher.agent.AgentGuest +import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SteamLocalConfig +import java.io.File +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.withContext + +data class IdleGame( + val appId: Int, + val name: String, + val art: File?, + val playtimeMinutes: Long, + val lastPlayed: Long, + val highlighted: Boolean, + val logo: File? = null, +) + +internal object IdleHome { + fun pick(games: List, selected: Long?): Pair? { + games.firstOrNull { selected != null && it.appId.toLong() == selected }?.let { return it to true } + return games.filter { it.lastPlayed > 0 }.maxByOrNull { it.lastPlayed }?.let { it to false } + } + + class Overview(val name: String, val minutes: Long, val lastPlayed: Long) + + fun overviewExpression(appId: Long): String = "(() => { const o = globalThis.appStore?.GetAppOverviewByAppID?.($appId); " + + "return o ? JSON.stringify({name: o.display_name, minutes: o.minutes_playtime_forever, last: o.rt_last_time_played}) : null; })()" + + fun parseOverview(json: String?): Overview? = runCatching { + val o = org.json.JSONObject(json ?: return null) + Overview(o.optString("name").ifEmpty { return null }, o.optLong("minutes"), o.optLong("last")) + }.getOrNull() + + internal fun overview(context: Context, appId: Long): Overview? = runCatching { + val answer = AgentGuest.steamEval(context, overviewExpression(appId), 4_000) + if (!answer.optBoolean("ok")) null else parseOverview(answer.opt("value")?.takeIf { it != org.json.JSONObject.NULL }?.toString()) + }.getOrNull() + + fun load(context: Context, games: List, selected: Long?): IdleGame? { + if (selected != null) overview(context, selected)?.let { o -> + val id = selected.toInt() + val known = games.firstOrNull { it.appId == id } + val cache = File(SessionPrefs.activeSteamRoot(context), "appcache/librarycache") + val art = known?.let { it.hero ?: it.art } ?: runCatching { + Library.steamCacheImage(cache, id, listOf("library_hero.jpg", "library_600x900.jpg", "header.jpg")) + }.getOrNull() + val logo = known?.logo ?: runCatching { Library.steamCacheImage(cache, id, Library.STEAM_LOGOS) }.getOrNull() + return IdleGame(id, o.name, art, o.minutes, o.lastPlayed, highlighted = true, logo = logo) + } + val (game, highlighted) = pick(games, selected) ?: return null + val stats = runCatching { SteamLocalConfig.appStats(SessionPrefs.activeSteamRoot(context), game.appId) }.getOrNull() + return IdleGame( + game.appId, game.name, game.hero ?: game.art, stats?.playtimeMinutes ?: 0L, + maxOf(stats?.lastPlayed ?: 0L, game.lastPlayed), highlighted, game.logo, + ) + } +} + +private const val SELECTION_MS = 2_000L + +@Composable +internal fun rememberShownGame(runningGame: () -> String?): Long? { + val context = LocalContext.current + var appId by remember { mutableStateOf(runningGame()?.toLongOrNull()) } + LaunchedEffect(Unit) { + while (isActive) { + appId = runningGame()?.toLongOrNull() + ?: withContext(Dispatchers.IO) { runCatching { AgentGuest.selectedSteamAppId(context) }.getOrNull() } + delay(SELECTION_MS) + } + } + return appId +} + +@Composable +internal fun idleDetails(game: IdleGame): String { + val hours = game.playtimeMinutes / 60 + val played = when { + game.playtimeMinutes <= 0 -> stringResource(R.string.bottom_idle_never) + hours == 0L -> stringResource(R.string.bottom_idle_minutes, game.playtimeMinutes.toInt()) + else -> stringResource(R.string.bottom_idle_hours, hours.toInt()) + } + if (game.lastPlayed <= 0) return played + val last = DateUtils.getRelativeTimeSpanString(game.lastPlayed * 1000, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS) + return stringResource(R.string.bottom_idle_details, played, last) +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomMirrorPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomMirrorPage.kt new file mode 100644 index 0000000000..95cd939b58 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomMirrorPage.kt @@ -0,0 +1,285 @@ +package com.droiddeck.launcher.ui + +import android.graphics.Bitmap +import android.graphics.RectF +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectDragGestures +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.foundation.layout.widthIn +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.key +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.FilterQuality +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.SessionPrefs +import kotlin.coroutines.resume +import kotlin.math.max +import kotlin.math.min +import kotlin.math.roundToInt +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.suspendCancellableCoroutine + +internal enum class MirrorHide(val id: String, val label: Int) { + OFF("off", R.string.bottom_mirror_hide_off), + BLACK("black", R.string.bottom_mirror_hide_black), + DIM("dim", R.string.bottom_mirror_hide_dim); + + fun next(): MirrorHide = entries[(ordinal + 1) % entries.size] + + companion object { + fun from(id: String?): MirrorHide = entries.firstOrNull { it.id == id } ?: OFF + } +} + +internal object MirrorRegion { + const val MIN_SIZE = 0.02f + + fun parse(text: String?): RectF? { + val v = text?.split(',')?.mapNotNull { it.trim().toFloatOrNull() }?.takeIf { it.size == 4 } ?: return null + return normalize(v[0], v[1], v[2], v[3]) + } + + fun format(r: RectF): String = listOf(r.left, r.top, r.right, r.bottom).joinToString(",") { it.toString() } + + fun normalize(x0: Float, y0: Float, x1: Float, y1: Float): RectF? { + val r = RectF(min(x0, x1).coerceIn(0f, 1f), min(y0, y1).coerceIn(0f, 1f), max(x0, x1).coerceIn(0f, 1f), max(y0, y1).coerceIn(0f, 1f)) + return r.takeIf { it.width() >= MIN_SIZE && it.height() >= MIN_SIZE } + } + + fun outputSize(r: RectF, sourceAspect: Float, longest: Int): Pair { + val w = r.width() * sourceAspect + val h = r.height() + return if (w >= h) longest to max(1, (longest * h / w).roundToInt()) else max(1, (longest * w / h).roundToInt()) to longest + } +} + +private const val FRAME_MS = 66L +private const val COMPOSED_SETTLE_MS = 250L +private const val EDIT_LONGEST = 960 +private const val EDIT_TRIES = 3 +private const val EDIT_RETRY_MS = 500L +private const val LIVE_LONGEST = 720 + +@Composable +internal fun MirrorPanel(actions: BottomPageActions) { + val context = LocalContext.current + val copy = actions.copyRegion + if (copy == null) { + MirrorNote(stringResource(R.string.bottom_mirror_no_frame)) + return + } + DisposableEffect(Unit) { + actions.holdComposed(true) + onDispose { actions.holdComposed(false) } + } + val game = actions.gameKey() ?: "steam" + var region by remember(game) { mutableStateOf(MirrorRegion.parse(SessionPrefs.mirrorRegion(context, game))) } + var editing by remember(game) { mutableStateOf(region == null) } + var sharp by remember { mutableStateOf(true) } + val host = rememberMenuHost() + if (editing) { + // A game change must not carry the last game's still or pick into this one's editor. + key(game) { + MirrorEditor(copy, region, actions.sourceAspect(), + onSave = { + region = it + SessionPrefs.setMirrorRegion(context, game, MirrorRegion.format(it)) + editing = false + }, + onCancel = if (region != null) ({ editing = false }) else null) + } + return + } + val r = region ?: return + var hide by remember(game) { mutableStateOf(MirrorHide.from(SessionPrefs.mirrorHide(context, game))) } + DisposableEffect(r, hide) { + actions.maskRegion(r.takeIf { hide != MirrorHide.OFF }, hide == MirrorHide.DIM) + onDispose { actions.maskRegion(null, false) } + } + var frame by remember(r) { mutableStateOf(null) } + var failed by remember(r) { mutableStateOf(false) } + LaunchedEffect(r) { + while (isActive) { + val (w, h) = MirrorRegion.outputSize(r, actions.sourceAspect(), LIVE_LONGEST) + val bitmap = capture(copy, r, w, h) + failed = bitmap == null + if (bitmap != null) frame = bitmap.asImageBitmap() + delay(FRAME_MS) + } + } + val pal = LocalPalette.current + DisposableEffect(Unit) { onDispose { MirrorOptions.open.value = false } } + Box(Modifier.fillMaxSize().background(Color.Black), contentAlignment = Alignment.Center) { + val f = frame + if (f != null) Image(f, null, Modifier.fillMaxSize(), contentScale = ContentScale.Fit, + filterQuality = if (sharp) FilterQuality.None else FilterQuality.Medium) + else if (failed) MirrorNote(stringResource(R.string.bottom_mirror_no_frame)) + if (MirrorOptions.open.value) Box( + Modifier.fillMaxSize().clickable(remember { MutableInteractionSource() }, indication = null) { MirrorOptions.open.value = false }, + contentAlignment = Alignment.TopEnd, + ) { + val shape = RoundedCornerShape(16.dp) + Column( + Modifier.padding(12.dp).widthIn(max = 380.dp).fillMaxWidth().testTag("bottom-mirror-options").clip(shape).background(MaterialTheme.colorScheme.background) + .border(1.dp, pal.line, shape).clickable(remember { MutableInteractionSource() }, indication = null) {} + .padding(horizontal = 10.dp, vertical = 4.dp), + ) { + SettingsGroup(stringResource(R.string.bottom_page_mirror)) { + ActionRow(stringResource(R.string.bottom_mirror_region), null, stringResource(R.string.game_env_edit), + onClick = { MirrorOptions.open.value = false; editing = true }, + modifier = Modifier.testTag("bottom-mirror-edit")) + ChoiceRow(host, "mirror-hide", stringResource(R.string.bottom_mirror_top), null, + MirrorHide.entries.map { it to stringResource(it.label) }, hide) { + hide = it + SessionPrefs.setMirrorHide(context, game, it.id) + } + ChoiceRow(host, "mirror-scaling", stringResource(R.string.bottom_mirror_scaling), null, + listOf(true to stringResource(R.string.bottom_mirror_sharp), false to stringResource(R.string.bottom_mirror_smooth)), sharp) { + sharp = it + } + } + } + } + } +} + +/** Whether the mirror's options card is open, toggled from the bar so the mirror keeps the whole panel. */ +internal object MirrorOptions { + val open = androidx.compose.runtime.mutableStateOf(false) +} + +@Composable +private fun MirrorEditor( + copy: (RectF?, Int, Int, (Bitmap?) -> Unit) -> Unit, + current: RectF?, + sourceAspect: Float, + onSave: (RectF) -> Unit, + onCancel: (() -> Unit)?, +) { + val pal = LocalPalette.current + var still by remember { mutableStateOf(null) } + var failed by remember { mutableStateOf(false) } + var start by remember { mutableStateOf(null) } + var end by remember { mutableStateOf(null) } + var picked by remember { mutableStateOf(current) } + var attempt by remember { mutableIntStateOf(0) } + LaunchedEffect(attempt) { + delay(COMPOSED_SETTLE_MS) + val (w, h) = MirrorRegion.outputSize(RectF(0f, 0f, 1f, 1f), sourceAspect, EDIT_LONGEST) + // The surface can be briefly invalid while the session settles, so a failed still is retried a few times. + var bitmap: Bitmap? = null + for (i in 0 until EDIT_TRIES) { + bitmap = capture(copy, null, w, h) + if (bitmap != null) break + delay(EDIT_RETRY_MS) + } + failed = bitmap == null + still = bitmap?.asImageBitmap() + } + PanelColumn { + Row(Modifier.fillMaxWidth().padding(bottom = 6.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + onCancel?.let { BackLink(stringResource(R.string.common_cancel), compact = true, onClick = it) } + Text(stringResource(R.string.bottom_mirror_pick), fontSize = 11.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + SecondaryButton(stringResource(R.string.bottom_mirror_save), enabled = picked != null, compact = true, + modifier = Modifier.testTag("bottom-mirror-save")) { picked?.let(onSave) } + } + BoxWithConstraints(Modifier.weight(1f).fillMaxWidth().padding(bottom = 6.dp), contentAlignment = Alignment.Center) { + val image = still + if (image == null) { + if (failed) Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text(stringResource(R.string.bottom_mirror_no_frame), fontSize = 15.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + textAlign = TextAlign.Center, modifier = Modifier.padding(24.dp)) + SecondaryButton(stringResource(R.string.agent_retry), compact = true) { failed = false; attempt++ } + } + return@BoxWithConstraints + } + Box(Modifier.aspectRatio(image.width.toFloat() / image.height).clip(RoundedCornerShape(8.dp))) { + Image(image, null, Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds) + Canvas(Modifier.fillMaxSize().pointerInput(Unit) { + detectDragGestures( + onDragStart = { start = it; end = it }, + onDrag = { change, _ -> end = change.position }, + onDragEnd = { + val a = start + val b = end + if (a != null && b != null) MirrorRegion.normalize(a.x / size.width, a.y / size.height, b.x / size.width, b.y / size.height) + ?.let { picked = it } + start = null + end = null + }, + ) + }) { + val a = start + val b = end + val shown = if (a != null && b != null) RectF(min(a.x, b.x), min(a.y, b.y), max(a.x, b.x), max(a.y, b.y)) + else picked?.let { RectF(it.left * size.width, it.top * size.height, it.right * size.width, it.bottom * size.height) } + if (shown != null) { + val veil = Color.Black.copy(alpha = 0.5f) + drawRect(veil, Offset.Zero, Size(size.width, shown.top)) + drawRect(veil, Offset(0f, shown.bottom), Size(size.width, size.height - shown.bottom)) + drawRect(veil, Offset(0f, shown.top), Size(shown.left, shown.height())) + drawRect(veil, Offset(shown.right, shown.top), Size(size.width - shown.right, shown.height())) + drawRect(pal.signal, Offset(shown.left, shown.top), Size(shown.width(), shown.height()), style = Stroke(3.dp.toPx())) + } + } + } + } + } +} + +@Composable +private fun MirrorNote(text: String) { + Box(Modifier.fillMaxSize()) { + Text(text, fontSize = 15.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center, + modifier = Modifier.align(Alignment.Center).padding(24.dp)) + } +} + +private suspend fun capture(copy: (RectF?, Int, Int, (Bitmap?) -> Unit) -> Unit, region: RectF?, width: Int, height: Int): Bitmap? = + suspendCancellableCoroutine { cont -> copy(region, width, height) { if (cont.isActive) cont.resume(it) else it?.recycle() } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt index b51aec8bf1..ff1e64bdb6 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomPages.kt @@ -27,6 +27,11 @@ class BottomPageActions( val takeScreenshot: ((onDone: (Boolean) -> Unit) -> Unit)? = null, val fps: () -> Float? = { null }, val runningGame: () -> String? = { null }, + val gameKey: () -> String? = runningGame, + val copyRegion: ((android.graphics.RectF?, Int, Int, (android.graphics.Bitmap?) -> Unit) -> Unit)? = null, + val sourceAspect: () -> Float = { 16f / 9f }, + val holdComposed: (Boolean) -> Unit = {}, + val maskRegion: (android.graphics.RectF?, Boolean) -> Unit = { _, _ -> }, ) internal const val BOTTOM_PAGE_TELEMETRY = "telemetry" diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt index b6509b332d..1524da8b92 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomScreenBar.kt @@ -25,6 +25,11 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Close import androidx.compose.material.icons.outlined.Dashboard +import androidx.compose.material.icons.outlined.Extension +import androidx.compose.material.icons.outlined.ViewSidebar +import androidx.compose.material.icons.outlined.Wallpaper +import androidx.compose.material.icons.outlined.CropFree +import androidx.compose.material.icons.outlined.MenuBook import androidx.compose.material.icons.outlined.DesktopAccessDisabled import androidx.compose.material.icons.outlined.DesktopWindows import androidx.compose.material.icons.outlined.ExpandLess @@ -236,6 +241,10 @@ internal val SecondScreenMode.icon: ImageVector get() = when (this) { SecondScreenMode.DECK_CONTROLS -> Icons.Outlined.SportsEsports SecondScreenMode.CUSTOM_CONTROLS -> Icons.Outlined.Tune SecondScreenMode.DASHBOARD -> Icons.Outlined.Dashboard + SecondScreenMode.GUIDES -> Icons.Outlined.MenuBook + SecondScreenMode.MIRROR -> Icons.Outlined.CropFree + SecondScreenMode.STEAM_QAM -> Icons.Outlined.ViewSidebar + SecondScreenMode.ART -> Icons.Outlined.Wallpaper SecondScreenMode.DESKTOP -> Icons.Outlined.DesktopWindows } @@ -329,6 +338,24 @@ internal fun sessionBarModel( internal fun deckPanelTabs(context: Context, selected: DeckPanel, onSelect: (DeckPanel) -> Unit) = BarTabs(DeckPanel.entries.map { context.getString(it.label) }, selected.ordinal) { onSelect(DeckPanel.entries[it]) } +internal fun padKeysView( + context: Context, steam: Boolean, onMenu: () -> Unit, onSteam: () -> Unit, onQam: () -> Unit, +): ComposeView = ComposeView(context).apply { + setContent { DroidDeckTheme { PadKeys(steam, onMenu, onSteam, onQam) } } +} + +@Composable +internal fun PadKeys(steam: Boolean, onMenu: () -> Unit, onSteam: () -> Unit, onQam: () -> Unit) { + Row( + Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp), + horizontalArrangement = if (steam) Arrangement.SpaceBetween else Arrangement.Center, + ) { + if (steam) BarActions(null, false, onSteam, null) + BarActions(onMenu, false, null, null) + if (steam) BarActions(null, false, null, onQam) + } +} + internal fun bottomScreenBarView(context: Context, model: () -> BottomBarModel): ComposeView = ComposeView(context).apply { setContent { DroidDeckTheme { BottomScreenBar(model()) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomSessionPanels.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomSessionPanels.kt new file mode 100644 index 0000000000..10c6eac00b --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomSessionPanels.kt @@ -0,0 +1,95 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.input.SecondScreenMode + +@Composable +internal fun BottomSessionPanel(mode: SecondScreenMode, actions: BottomPageActions) { + val colors = MaterialTheme.colorScheme + Box(Modifier.fillMaxSize().background(colors.background)) { + CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true) { + when (mode) { + SecondScreenMode.GUIDES -> GuidesPanel(actions.runningGame) + SecondScreenMode.MIRROR -> MirrorPanel(actions) + SecondScreenMode.STEAM_QAM -> SteamQamPanel() + SecondScreenMode.ART -> ArtPanel(actions.runningGame) + else -> Unit + } + } + } +} + +@Composable +internal fun PanelColumn(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) { + Column(modifier.fillMaxSize().padding(horizontal = 14.dp, vertical = 6.dp), verticalArrangement = Arrangement.spacedBy(2.dp), content = content) +} + +@Composable +internal fun PanelRow( + title: String, + hint: String? = null, + tag: String? = null, + selected: Boolean = false, + leading: (@Composable () -> Unit)? = null, + trailing: (@Composable () -> Unit)? = null, + onClick: (() -> Unit)? = null, +) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + Row( + Modifier.fillMaxWidth() + .background(if (selected) pal.signal.copy(alpha = 0.10f) else Color.Transparent) + .then(if (onClick != null) Modifier.clickable(role = Role.Button, onClick = onClick) else Modifier) + .then(if (tag != null) Modifier.testTag(tag) else Modifier) + .padding(horizontal = 10.dp, vertical = 7.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(10.dp), + ) { + leading?.invoke() + Column(Modifier.weight(1f)) { + Text(title, fontSize = 13.sp, lineHeight = 16.sp, fontWeight = FontWeight.SemiBold, + color = if (selected) pal.signal else colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + if (!hint.isNullOrEmpty()) Text(hint, fontSize = 11.sp, lineHeight = 14.sp, color = colors.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 2.dp)) + } + trailing?.invoke() + } + Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line)) +} + +@Composable +internal fun PanelValue(text: String, color: Color = MaterialTheme.colorScheme.onBackground) { + Text(text, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = color, maxLines = 1) +} + +@Composable +internal fun PanelNote(text: String, modifier: Modifier = Modifier) { + Box(modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text, fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center, + modifier = Modifier.padding(24.dp)) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt new file mode 100644 index 0000000000..76a3c40636 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt @@ -0,0 +1,383 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import android.graphics.BitmapFactory +import android.util.Base64 +import androidx.annotation.StringRes +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.AlignHorizontalCenter +import androidx.compose.material.icons.outlined.AlignHorizontalLeft +import androidx.compose.material.icons.outlined.AlignHorizontalRight +import androidx.compose.material.icons.outlined.VerticalSplit +import androidx.compose.material.icons.outlined.WidthFull +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.FilterQuality +import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.asAndroidBitmap +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.IntSize +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.CdpPage +import com.droiddeck.launcher.session.SessionPhase +import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.session.SessionState +import com.droiddeck.launcher.session.SteamQam +import kotlin.math.min +import kotlin.math.roundToInt +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.cancelAndJoin +import kotlinx.coroutines.delay +import kotlinx.coroutines.ensureActive +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeoutOrNull +import org.json.JSONArray +import org.json.JSONObject + +internal class QamFrame(val image: ImageBitmap, val cssWidth: Float, val cssHeight: Float, val contentRight: Float) { + val pxPerCss: Float get() = image.width / cssWidth + + /** The menu's own background, sampled inside its right edge, to fill the panel around it. */ + val fill: Color = runCatching { + val x = (contentRight * pxPerCss).roundToInt() - 4 + Color(image.asAndroidBitmap().getPixel(x.coerceIn(0, image.width - 1), image.height / 2)) + }.getOrDefault(Color.Black) +} + +/** How Steam's Quick Access menu sits on the bottom screen. */ +internal enum class QamFit(val id: String, @StringRes val label: Int, val icon: ImageVector, val align: Int) { + FULL("full", R.string.bottom_qam_layout_full, Icons.Outlined.WidthFull, 0), + LEFT("left", R.string.bottom_qam_layout_left, Icons.Outlined.AlignHorizontalLeft, -1), + CENTER("center", R.string.bottom_qam_layout_center, Icons.Outlined.AlignHorizontalCenter, 0), + RIGHT("right", R.string.bottom_qam_layout_right, Icons.Outlined.AlignHorizontalRight, 1), + SPLIT("split", R.string.bottom_qam_layout_split, Icons.Outlined.VerticalSplit, 0); + + val next: QamFit get() = entries[(ordinal + 1) % entries.size] + + companion object { + fun from(id: String?): QamFit = entries.firstOrNull { it.id == id } ?: FULL + + private val state = mutableStateOf(null) + + fun current(context: Context): QamFit = state.value ?: from(SessionPrefs.quickAccessLayout(context)).also { state.value = it } + + fun choose(context: Context, fit: QamFit) { + state.value = fit + SessionPrefs.setQuickAccessLayout(context, fit.id) + } + } +} + +internal object QamLayout { + private const val WIDE_CSS = "div.BasicUI { width: 100% !important; } div[class*=\\\"tab_\\\"] { max-width: none !important; }" + private const val PARKED_CSS = " #Footer { display: none !important; }" + + /** Scale and left edge of the menu in a box; [align] -1, 0 or 1 places a narrower menu left, centred or right. */ + fun fit(boxWidth: Float, boxHeight: Float, contentRight: Float, cssHeight: Float, align: Int = 0): Pair { + val scale = min(boxWidth / contentRight, boxHeight / cssHeight) + return scale to (boxWidth - contentRight * scale) * (align.coerceIn(-1, 1) + 1) / 2f + } + + fun toCss(x: Float, y: Float, scale: Float, left: Float): Pair = (x - left) / scale to y / scale + + /** Makes the menu follow the panel-shaped view (Steam sizes it once, on open) and lifts each tab's 300 px cap, then measures where the content ends. */ + /** + * [wide] is false while the menu is shown on the top screen, where it keeps Steam's own layout. [parked] hides the + * button-hint footer Steam draws in a game, which stays an empty black strip while the controller is not on the menu. + */ + fun contentScript(wide: Boolean, parked: Boolean = wide): String = "(() => { let s = document.getElementById('dd-qam-wide'); " + + "if (!s) { s = document.createElement('style'); s.id = 'dd-qam-wide'; document.head.appendChild(s); } " + + "const css = '${(if (wide) WIDE_CSS else "") + (if (parked) PARKED_CSS else "")}'; " + + "if (s.textContent !== css) s.textContent = css; if (document.scrollingElement.scrollLeft) document.scrollingElement.scrollLeft = 0; " + + "const w = innerWidth; let right = 0; for (const e of document.body.querySelectorAll('*')) { " + + "const r = e.getBoundingClientRect(); const tab = /(^| )tab_/.test(String(e.className)); " + + "if (r.width > 0 && r.height > 0 && (tab || r.width < w * 0.75) && r.right > right) right = r.right; } " + + "return JSON.stringify([w, innerHeight, devicePixelRatio, right]); })()" +} + +private const val TICK_MS = 1_000L +private const val FAST_TICK_MS = 150L +private const val MAX_RETRY_MS = 4_000L + +/** One of Steam's menu pages streamed to the panel; the last frame is kept so returning to the panel shows it at once. */ +internal class MenuStream { + @Volatile var page: CdpPage? = null + val live = java.util.concurrent.atomic.AtomicBoolean(false) + val image = mutableStateOf(null) + val shape = mutableStateOf(null) + + fun show(frame: ImageBitmap) { + image.value = frame + live.set(true) + } + + /** Connects to [path] and starts its screencast; false when the page cannot be reached. */ + fun connect(port: Int, path: String): Boolean { + page?.close() + page = null + live.set(false) + val p = runCatching { + CdpPage(port, path) { method, params -> + if (method == "Page.screencastFrame") { + page?.send("Page.screencastFrameAck", JSONObject().put("sessionId", params.optInt("sessionId"))) + decodeFrame(params.optString("data"))?.let(::show) + } + } + }.onFailure { android.util.Log.w("SteamQam", "devtools connect: $it") }.getOrNull() ?: return false + page = p + p.send("Page.enable") + val started = p.call("Page.startScreencast", JSONObject().put("format", "jpeg").put("quality", 85) + .put("maxWidth", 1920).put("maxHeight", 1440)) + if (started == null || started.has("error") || !started.has("result")) { + p.close() + page = null + return false + } + return true + } + + /** Runs [script], which returns the page's [width, height, pixel ratio, content right], and refreshes a still page. */ + fun refresh(script: String) { + val p = page ?: return + // The screencast sends frames only when the menu repaints, so a still menu needs one screenshot. + if (!live.get()) { + p.call("Page.captureScreenshot", JSONObject().put("format", "jpeg").put("quality", 85)) + ?.optJSONObject("result")?.optString("data")?.let(::decodeFrame)?.let(::show) + } + (p.evaluate(script) as? String)?.let { text -> + runCatching { + val a = JSONArray(text) + val layout = FloatArray(4) { a.getDouble(it).toFloat() } + if (!layout.contentEquals(shape.value)) shape.value = layout + } + } + } + + /** Stops the stream and runs [restore] on the page, which outlives this connection. */ + fun stop(restore: String) { + val p = page ?: return + page = null + runCatching { p.send("Page.stopScreencast") } + runCatching { p.evaluate(restore) } + p.close() + } + + fun frame(): QamFrame? { + val img = image.value + val l = shape.value + return if (img != null && l != null && l[0] > 0f) QamFrame(img, l[0], l[1], l[3].coerceIn(l[0] * 0.25f, l[0])) else null + } +} + +/** Steam's main menu beside the quick access menu; Steam's side of the hold keeps it in place and filling its view. */ +internal object MainMenuLayout { + const val CONTENT_SCRIPT = "JSON.stringify([innerWidth, innerHeight, devicePixelRatio, innerWidth])" +} + +/** Panel streams kept across visits to the panel. */ +private object QamCache { + val qam = MenuStream() + val main = MenuStream() +} + +@Composable +internal fun SteamQamPanel() { + val context = LocalContext.current.applicationContext + var failed by remember { mutableStateOf(false) } + var slow by remember { mutableStateOf(false) } + LaunchedEffect(Unit) { + delay(2_500) + slow = true + } + val fit = QamFit.current(context) + val qam = QamCache.qam + val mainMenu = QamCache.main + val owner = remember { SteamQam.newOwner() } + val relay = remember { intArrayOf(0) } + val mainPath = remember { arrayOfNulls(1) } + val aspect = remember { floatArrayOf(0f) } + val measure = Modifier.fillMaxSize().onSizeChanged { if (it.height > 0) aspect[0] = it.width.toFloat() / it.height } + LaunchedEffect(Unit) { + withContext(Dispatchers.IO) { + var misses = 0 + // The main menu page backs off on its own, so Quick Access stays available while its neighbour cannot connect. + var mainMisses = 0 + var mainRetryAt = 0L + fun split() = QamFit.current(context) == QamFit.SPLIT + // The lease is renewed on its own, so slow discovery or a retry backoff never lets the held menu lapse. + val renew = launch { + while (isActive) { + if (SessionState.phase == SessionPhase.READY && aspect[0] > 0f) SteamQam.hold(context, aspect[0], owner, split()) + delay(TICK_MS) + } + } + try { + while (isActive) { + // Holding the menu before Steam's first frame keeps gamescope from presenting it. + if (SessionState.phase != SessionPhase.READY || aspect[0] == 0f) { + delay(FAST_TICK_MS) + continue + } + val split = split() + val held = SteamQam.hold(context, aspect[0], owner, split) + ensureActive() + var reached = held != null + if (held?.open == SteamQam.QUICK_ACCESS) { + if (qam.page?.closed != false) { + val t = SteamQam.target(context) + if (t != null) { + if (relay[0] != 0 && relay[0] != t.port) SteamQam.stopRelay(context, relay[0]) + relay[0] = t.port + mainPath[0] = t.mainPath + qam.connect(t.port, t.path) + mainMenu.stop(MainMenuLayout.CONTENT_SCRIPT) + } + ensureActive() + } + reached = qam.page?.closed == false + val wide = !held.top && (QamFit.current(context) == QamFit.FULL || split) + qam.refresh(QamLayout.contentScript(wide, parked = !held.top)) + val path = mainPath[0] + if (split && path != null) { + val now = android.os.SystemClock.elapsedRealtime() + if (mainMenu.page?.closed != false && now >= mainRetryAt) { + if (mainMenu.connect(relay[0], path)) { + mainMisses = 0 + } else { + mainMisses++ + mainRetryAt = now + minOf(TICK_MS shl minOf(mainMisses - 1, 2), MAX_RETRY_MS) + } + } + mainMenu.refresh(MainMenuLayout.CONTENT_SCRIPT) + } else if (!split) { + mainMenu.stop(MainMenuLayout.CONTENT_SCRIPT) + } + } + failed = !reached + // With no menu page to reach, retries slow down instead of starting guest processes several times a second. + misses = if (reached) 0 else misses + 1 + val wait = when { + !reached -> minOf(TICK_MS shl minOf(misses - 1, 2), MAX_RETRY_MS) + qam.live.get() && (!split || mainMenu.live.get() || mainMenu.page?.closed != false) -> TICK_MS + else -> FAST_TICK_MS + } + val used = QamFit.current(context) + withTimeoutOrNull(wait) { + snapshotFlow { QamFit.current(context) }.first { it != used } + } + } + } finally { + withContext(NonCancellable) { + renew.cancelAndJoin() + // The pages outlive these connections, so the widened layouts would otherwise stay on the top screen. + qam.stop(QamLayout.contentScript(wide = false)) + mainMenu.stop(MainMenuLayout.CONTENT_SCRIPT) + SteamQam.release(context, relay[0], owner) + } + } + } + } + val qamFrame = qam.frame() + if (qamFrame == null) { + Box(measure) { + if (slow) PanelNote(stringResource(if (failed) R.string.bottom_qam_unavailable else R.string.achievements_reading)) + } + return + } + if (fit != QamFit.SPLIT) { + MenuCanvas(qamFrame, fit.align, measure) { qam.page } + return + } + // Each side is as wide as its menu at the shared scale, so neither is shrunk nor padded with empty space. + val mainFrame = mainMenu.frame() + val mainWidth = mainFrame?.cssWidth ?: SteamQam.MAIN_CSS_WIDTH.toFloat() + Row(measure) { + val left = Modifier.weight(mainWidth).fillMaxHeight() + if (mainFrame != null) MenuCanvas(mainFrame, -1, left) { mainMenu.page } + else Box(left.background(qamFrame.fill)) + MenuCanvas(qamFrame, -1, Modifier.weight(qamFrame.cssWidth).fillMaxHeight()) { qam.page } + } +} + +/** Draws [f] scaled into the box, placed by [align], and forwards touches on it to [page]. */ +@Composable +private fun MenuCanvas(f: QamFrame, align: Int, modifier: Modifier, page: () -> CdpPage?) { + BoxWithConstraints(modifier.background(f.fill)) { + val density = LocalDensity.current + val boxW = with(density) { maxWidth.toPx() } + val boxH = with(density) { maxHeight.toPx() } + val (scale, left) = QamLayout.fit(boxW, boxH, f.contentRight, f.cssHeight, align) + Canvas( + Modifier.fillMaxSize().pointerInput(f.cssWidth, f.contentRight, boxW, boxH, align) { + var touching = false + var target: CdpPage? = null + try { + awaitPointerEventScope { + while (true) { + val event = awaitPointerEvent() + val change = event.changes.firstOrNull() ?: continue + val (x, y) = QamLayout.toCss(change.position.x, change.position.y, scale, left) + val type = when (event.type) { + PointerEventType.Press -> if (x in 0f..f.contentRight && y in 0f..f.cssHeight) "touchStart" else null + PointerEventType.Move -> "touchMove" + PointerEventType.Release -> "touchEnd" + else -> null + }?.takeIf { it == "touchStart" || touching } ?: continue + if (type == "touchStart") target = page() + touching = type != "touchEnd" + val points = if (type == "touchEnd") JSONArray() + else JSONArray().put(JSONObject().put("x", x.toDouble()).put("y", y.toDouble())) + target?.send("Input.dispatchTouchEvent", JSONObject().put("type", type).put("touchPoints", points)) + if (!touching) target = null + change.consume() + } + } + } finally { + if (touching) target?.send("Input.dispatchTouchEvent", + JSONObject().put("type", "touchCancel").put("touchPoints", JSONArray())) + } + }, + ) { + val px = f.pxPerCss + drawImage( + f.image, + srcOffset = IntOffset.Zero, + srcSize = IntSize((f.contentRight * px).roundToInt().coerceAtMost(f.image.width), f.image.height), + dstOffset = IntOffset(left.roundToInt(), 0), + dstSize = IntSize((f.contentRight * scale).roundToInt(), (f.cssHeight * scale).roundToInt()), + filterQuality = FilterQuality.Medium, + ) + } + } +} + +private fun decodeFrame(data: String): ImageBitmap? = runCatching { + val bytes = Base64.decode(data, Base64.DEFAULT) + BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.asImageBitmap() +}.getOrNull() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt b/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt index 446420806c..c916b3f7ad 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BuildWatermark.kt @@ -81,10 +81,13 @@ object BuildWatermark { if (activity is QuestXrActivity) return val decor = activity.window.decorView as? ViewGroup ?: return decor.findViewWithTag(TAG)?.let(decor::removeView) - if (!com.droiddeck.launcher.session.SessionPrefs.buildWatermarkEnabled(activity)) return - val lab = com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" } - val build = lineProvider().orEmpty() - val content = (listOfNotNull(lab) + build).ifEmpty { return } + val prefs = com.droiddeck.launcher.session.SessionPrefs + val debugLogs = if (prefs.logsEnabled(activity) && prefs.gameDebugLogsEnabled(activity)) DEBUG_LOGS_LINE else null + val build = if (prefs.buildWatermarkEnabled(activity)) { + listOfNotNull(com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" }) + + lineProvider().orEmpty() + } else emptyList() + val content = (build + listOfNotNull(debugLogs)).ifEmpty { return } val margin = (8 * activity.resources.displayMetrics.density).toInt() decor.addView( MarkView(activity, content).apply { tag = TAG }, @@ -96,6 +99,8 @@ object BuildWatermark { ) } + internal const val DEBUG_LOGS_LINE = "GAME DEBUG LOGS ON | slows games" + private const val TAG = "build-watermark" private class MarkView(context: Context, private val lines: List) : View(context) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ControllerHaptics.kt b/app/src/main/java/com/droiddeck/launcher/ui/ControllerHaptics.kt index da1d8d4bb4..b954512fff 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ControllerHaptics.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ControllerHaptics.kt @@ -24,7 +24,11 @@ object ControllerHaptics { tick(context) } - fun tick(context: Context) { + fun tick(context: Context) = vibrate(context, VibrationEffect.EFFECT_TICK, 10) + + fun click(context: Context) = vibrate(context, VibrationEffect.EFFECT_CLICK, 20) + + private fun vibrate(context: Context, predefined: Int, fallbackMs: Long) { val vibrator = if (Build.VERSION.SDK_INT >= 31) { context.getSystemService(VibratorManager::class.java)?.defaultVibrator } else { @@ -32,11 +36,11 @@ object ControllerHaptics { } ?: return if (!vibrator.hasVibrator()) return if (Build.VERSION.SDK_INT >= 29) { - vibrator.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_TICK)) + vibrator.vibrate(VibrationEffect.createPredefined(predefined)) } else if (Build.VERSION.SDK_INT >= 26) { - vibrator.vibrate(VibrationEffect.createOneShot(10, VibrationEffect.DEFAULT_AMPLITUDE)) + vibrator.vibrate(VibrationEffect.createOneShot(fallbackMs, VibrationEffect.DEFAULT_AMPLITUDE)) } else { - @Suppress("DEPRECATION") vibrator.vibrate(10) + @Suppress("DEPRECATION") vibrator.vibrate(fallbackMs) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt b/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt index 46ea147324..3e8b6b1d1e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DevPreview.kt @@ -57,12 +57,17 @@ import com.droiddeck.launcher.stores.StoresState /** What the Library pretends while a developer previews it. Nothing here is saved: a restart always comes back to [OFF]. */ internal enum class LibraryPreview { OFF, NOTHING_INSTALLED, SIGNED_OUT, SAMPLE } +/** How many games the Steam home pretends are installed. Nothing here is saved. */ +internal enum class SteamHomePreview(val games: Int) { OFF(-1), NONE(0), FEW(3), MANY(12) } + internal enum class DrawerPreview { STEAM, DESKTOP, GAME } /** Developer tools' preview states: screens that are otherwise hard to reach, shown without changing anything real. */ internal object DevPreview { var library by mutableStateOf(LibraryPreview.OFF) var drawer by mutableStateOf(null) + var steamHome by mutableStateOf(SteamHomePreview.OFF) + var openSteam by mutableStateOf(false) /** The UI zoo sheet: where previews are picked, one at a time, only when asked for. */ var zoo by mutableStateOf(false) /** Opt-in: a preview button where its state lives (the Library's toolbar), for switching states without the zoo. */ @@ -87,6 +92,41 @@ internal fun sampleOwned(store: Store): List = internal fun sampleInstalled(owned: Map>): Set = owned.values.flatMap { items -> items.take(SAMPLE_INSTALLED).map { it.key } }.toSet() +/** The Steam home's games while a developer previews it: this many invented titles, no art, nothing installed. */ +internal fun sampleSteamHomeGames(count: Int): List = listOf( + "Portal 2", "Hades", "Celeste", "Stardew Valley", "Hollow Knight", "Balatro", + "Dead Cells", "Terraria", "Vampire Survivors", "Slay the Spire", "Cuphead", "Inscryption", +).take(count).mapIndexed { i, name -> + com.droiddeck.launcher.frontend.Library.SteamGame(1000 + i, name, art = null, library = "steam", lastPlayed = 1_700_000_000_000L - i * 86_400_000L) +} + +/** The pill a previewed Steam home shows, so the fake state is never mistaken for the real one. */ +@Composable +internal fun SteamHomePreviewPill(modifier: Modifier = Modifier) { + val preview = DevPreview.steamHome + if (preview == SteamHomePreview.OFF) return + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val label = stringResource( + when (preview) { + SteamHomePreview.NONE -> R.string.dev_preview_steam_none + SteamHomePreview.FEW -> R.string.dev_preview_steam_few + else -> R.string.dev_preview_steam_many + }, + ) + val end = stringResource(R.string.dev_preview_end) + Row( + verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), + modifier = modifier.background(colors.surface, CircleShape).border(1.dp, pal.signal, CircleShape) + .clickable(role = Role.Button, onClickLabel = end) { DevPreview.steamHome = SteamHomePreview.OFF } + .padding(start = 14.dp, end = 10.dp, top = 8.dp, bottom = 8.dp).testTag("dev-preview-steam-end"), + ) { + Icon(Icons.Outlined.Visibility, null, tint = pal.signal, modifier = Modifier.size(18.dp)) + Text(stringResource(R.string.dev_preview_banner, label), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Icon(Icons.Filled.Close, end, tint = colors.onSurfaceVariant, modifier = Modifier.size(18.dp)) + } +} + /** The pill a previewed Library shows, so the fake state is never mistaken for the real one. */ @Composable internal fun LibraryPreviewPill(modifier: Modifier = Modifier) { @@ -159,7 +199,6 @@ internal fun SessionDrawerPreview(secondScreens: List) { secondScreenDisplays = secondScreens, selectedSecondScreenDisplay = secondScreens.firstOrNull()?.id ?: -1, onSecondScreenDisplay = {}, - onImportLossless = {}, onKeyboard = {}, onHardwareKeyboard = {}, onSteamMenu = if (steam) ({}) else null, onQam = if (steam) ({}) else null, @@ -215,6 +254,17 @@ internal fun UiZooSheet() { DrawerPreview.GAME to R.string.session_title_game, )) ActionRow(stringResource(label), null, show, onClick = { close(); DevPreview.drawer = mode }, modifier = Modifier.testTag("zoo-drawer-${mode.name.lowercase()}")) } + SettingsGroup(stringResource(R.string.dev_preview_steam_home)) { + for ((mode, label) in listOf( + SteamHomePreview.NONE to R.string.dev_preview_steam_none, + SteamHomePreview.FEW to R.string.dev_preview_steam_few, + SteamHomePreview.MANY to R.string.dev_preview_steam_many, + )) ActionRow( + stringResource(label), null, show, + onClick = { close(); DevPreview.steamHome = mode; DevPreview.openSteam = true }, + modifier = Modifier.testTag("zoo-steam-${mode.name.lowercase()}"), + ) + } SettingsGroup(stringResource(R.string.dev_preview_library)) { for ((mode, label) in listOf( LibraryPreview.NOTHING_INSTALLED to R.string.dev_preview_library_nothing_installed, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DrawerEntryHint.kt b/app/src/main/java/com/droiddeck/launcher/ui/DrawerEntryHint.kt index 59c87675e9..3810161619 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DrawerEntryHint.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DrawerEntryHint.kt @@ -7,13 +7,16 @@ import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideOutHorizontally import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectHorizontalDragGestures import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.displayCutout +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.widthIn @@ -35,6 +38,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role @@ -90,6 +94,29 @@ internal fun DrawerEntryHint(steam: Boolean, inverted: Boolean, onOpen: () -> Un } } +/** A Quest has no system Back gesture, so a laser drag in from the right edge stands in for it. */ +@Composable +internal fun DrawerEdgeSwipe(onBack: () -> Unit) { + val density = LocalDensity.current + val threshold = with(density) { 48.dp.toPx() } + val strip = with(density) { 12.toDp() } + Box(Modifier.fillMaxSize(), contentAlignment = Alignment.CenterEnd) { + Box( + Modifier.fillMaxHeight().width(strip).testTag("drawer-edge") + .pointerInput(Unit) { + var travelled = 0f + detectHorizontalDragGestures( + onDragStart = { travelled = 0f }, + onDragEnd = { if (travelled <= -threshold) onBack() }, + ) { change, amount -> + change.consume() + travelled += amount + } + }, + ) + } +} + @Composable internal fun DrawerCornerTap(onOpen: () -> Unit) { Box(Modifier.fillMaxSize().windowInsetsPadding(WindowInsets.displayCutout), contentAlignment = Alignment.TopEnd) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DrawerSections.kt b/app/src/main/java/com/droiddeck/launcher/ui/DrawerSections.kt new file mode 100644 index 0000000000..fd6839d134 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/DrawerSections.kt @@ -0,0 +1,142 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.expandVertically +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.shrinkVertically +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.hoverable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsFocusedAsState +import androidx.compose.foundation.interaction.collectIsHoveredAsState +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.compositionLocalOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateMapOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.rotate +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.stateDescription +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.SessionPrefs + +/** + * Inside the session menu every top-level settings group folds to its header and a summary of its values. + * Groups start folded; a group the player opens or folds stays that way across sessions. + */ +internal object DrawerSectionState { + private val chosen = mutableStateMapOf() + + fun load(context: Context) { + if (DevPreview.drawer != null) return + chosen.clear() + chosen.putAll(SessionPrefs.drawerSections(context)) + } + + fun isOpen(key: String) = chosen[key] ?: false + + fun toggle(context: Context, key: String) { + chosen[key] = !isOpen(key) + if (DevPreview.drawer == null) SessionPrefs.setDrawerSections(context, chosen.toMap()) + } +} + +internal class DrawerSections(val context: Context, val track: (String) -> Modifier) + +internal val LocalDrawerSections = compositionLocalOf { null } + +@Composable +internal fun DrawerSection( + sections: DrawerSections, key: String, title: String, summary: String?, tag: String?, + content: @Composable ColumnScope.() -> Unit, +) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val open = DrawerSectionState.isOpen(key) + val source = remember { MutableInteractionSource() } + val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value + val rotation by animateFloatAsState(if (open) 180f else 0f, Motion.tw(180), label = "sectionArrow") + val state = stringResource(if (open) R.string.widgets_expanded else R.string.widgets_collapsed) + val toggle = { DrawerSectionState.toggle(sections.context, key) } + val shape = RoundedCornerShape(14.dp) + Column( + Modifier.fillMaxWidth().padding(top = 6.dp).clip(shape) + .background(colors.surface).border(1.dp, if (open) pal.line2 else pal.line, shape), + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + modifier = Modifier.fillMaxWidth().heightIn(min = 48.dp) + .then(sections.track("section-$key")) + .testTag("drawer-section-$key") + .background(if (hot) pal.signal.copy(alpha = 0.12f) else androidx.compose.ui.graphics.Color.Transparent) + .glideBorder(hot, shape, pal.signal) + .hoverable(source) + .clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = toggle) + .controllerConfirm(onClick = toggle) + .semantics { contentDescription = title; stateDescription = state } + .padding(start = 12.dp, end = 8.dp, top = 6.dp, bottom = 6.dp), + ) { + Column(Modifier.weight(1f)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) { + Text(title.uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp, + color = if (open) colors.onBackground else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f, fill = false)) + if (tag != null) Text( + tag, fontSize = 10.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, maxLines = 1, + modifier = Modifier.clip(RoundedCornerShape(6.dp)).background(pal.signal.copy(alpha = 0.14f)) + .padding(horizontal = 6.dp, vertical = 2.dp), + ) + } + if (!open && !summary.isNullOrEmpty()) Text( + summary, fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, + modifier = Modifier.padding(top = 2.dp), + ) + } + Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = colors.onSurfaceVariant, + modifier = Modifier.size(22.dp).rotate(rotation)) + } + AnimatedVisibility(open, enter = expandVertically(Motion.tw(200)) + fadeIn(Motion.tw(160)), + exit = shrinkVertically(Motion.tw(160)) + fadeOut(Motion.tw(120))) { + Column(Modifier.fillMaxWidth()) { + Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line)) + // Only top-level groups fold; groups and dialogs opened from inside one draw normally. + CompositionLocalProvider(LocalDrawerSections provides null) { content() } + } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt b/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt index d14086ffc5..c2225dd513 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DroidDeckHudSettings.kt @@ -26,7 +26,8 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri fun on(key: String) = cfg[key] == "1" fun int(key: String, fallback: Int) = cfg[key]?.toIntOrNull() ?: fallback - SettingsGroup(stringResource(R.string.drawer_hud)) { + SettingsGroup(stringResource(R.string.drawer_hud), key = "performance-hud", + detail = stringResource(if (a.hudOn) R.string.widgets_on else R.string.widgets_off)) { ToggleRow(host, "hud", stringResource(R.string.drawer_hud), null, a.hudOn, chipModifier = track("hud"), onChange = a.onHud) if (a.hudOn) ToggleRow( host, "hud-only-during-game", stringResource(R.string.hud_only_during_game), @@ -38,7 +39,8 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri } if (!a.hudOn) return@SettingsGroup val size = DroidDeckHudSize.from(cfg["hudSize"]) - ChoiceRow(host, "hud-size", stringResource(R.string.hud_size), stringResource(R.string.hud_size_hint), + ChoiceRow(host, "hud-size", stringResource(R.string.hud_size), + stringResource(if (size == DroidDeckHudSize.SIDE_STRIP) R.string.hud_size_side_strip_hint else R.string.hud_size_hint), listOf( DroidDeckHudSize.FULL to stringResource(R.string.hud_size_full), DroidDeckHudSize.TILES to stringResource(R.string.hud_size_tiles), @@ -46,6 +48,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri DroidDeckHudSize.MINIMAL to stringResource(R.string.hud_size_minimal), DroidDeckHudSize.MEGA to stringResource(R.string.hud_size_mega), DroidDeckHudSize.STRIP to stringResource(R.string.hud_size_strip), + DroidDeckHudSize.SIDE_STRIP to stringResource(R.string.hud_size_side_strip), ), size, chipModifier = track("hud-size")) { a.onHudSetting("hudSize", it.token) } ChoiceRow(host, "hud-hold", stringResource(R.string.hud_hold), null, @@ -62,7 +65,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri if (a.dashboardAvailable && a.secondScreenDisplays.isNotEmpty()) BottomStripSettings(host, track) if (!a.hudOn) return - SettingsGroup(stringResource(R.string.hud_group_look)) { + SettingsGroup(stringResource(R.string.hud_group_look), key = "performance-hud-look") { SliderRow(stringResource(R.string.hud_scale), null, int("hudScale", 100), 50..150, step = 5, format = { "$it%" }, modifier = track("hud-scale")) { a.onHudSetting("hudScale", it.toString()) } SliderRow(stringResource(R.string.drawer_hud_opacity), null, int("hudOpacity", 80), 0..100, step = 5, format = { "$it%" }, @@ -85,7 +88,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri } var editing by remember { mutableStateOf(false) } - SettingsGroup(stringResource(R.string.hud_group_metrics)) { + SettingsGroup(stringResource(R.string.hud_group_metrics), key = "performance-hud-metrics") { ActionRow(stringResource(R.string.hud_group_metrics), null, stringResource(R.string.common_edit), onClick = { editing = true }, modifier = track("hud-readings")) val rows = DroidDeckHudSize.rowsFor(DroidDeckHudSize.from(cfg["hudSize"]), cfg) @@ -103,7 +106,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri ) } - if (on("showTemp") || on("showGpuTemp") || on("showBatteryTemp")) SettingsGroup(stringResource(R.string.hud_group_temps)) { + if (on("showTemp") || on("showGpuTemp") || on("showBatteryTemp")) SettingsGroup(stringResource(R.string.hud_group_temps), key = "performance-hud-temps") { ChoiceRow(host, "hud-temp-unit", stringResource(R.string.hud_temp_unit), null, listOf("c" to "°C", "f" to "°F"), if (cfg["tempUnit"].equals("f", true)) "f" else "c", chipModifier = track("hud-temp-unit")) { a.onHudSetting("tempUnit", it) } @@ -129,7 +132,7 @@ internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (Stri } } - SettingsGroup(stringResource(R.string.hud_group_more)) { + SettingsGroup(stringResource(R.string.hud_group_more), key = "performance-hud-more") { ActionRow(stringResource(R.string.hud_export), stringResource(R.string.hud_export_hint), stringResource(R.string.hud_export_button), onClick = a.onHudExport, modifier = track("hud-export")) ActionRow(stringResource(R.string.hud_reset), null, stringResource(R.string.hud_reset_button), @@ -145,7 +148,7 @@ private fun BottomStripSettings(host: MenuHost, track: (String) -> Modifier) { var hudOn by remember { mutableStateOf(SessionPrefs.bottomHud(context)) } var onTabs by remember { mutableStateOf(SessionPrefs.bottomStripOnTabs(context)) } var shown by remember { mutableStateOf(SessionPrefs.bottomStripMetrics(context)) } - SettingsGroup(stringResource(R.string.bottom_hud_group)) { + SettingsGroup(stringResource(R.string.bottom_hud_group), key = "performance-bottom-hud") { ToggleRow(host, "bottom-hud", stringResource(R.string.bottom_hud_group), null, hudOn, chipModifier = track("bottom-hud")) { on -> hudOn = on diff --git a/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt b/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt index 192afbece1..b63eada15e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/EmptyLibrary.kt @@ -15,7 +15,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue -import androidx.compose.runtime.withFrameMillis +import androidx.compose.runtime.withFrameNanos import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.Offset @@ -99,7 +99,7 @@ private fun rememberMarkClock(avoid: Rect?): MarkClock { var vx = speed * 0.8f var vy = -speed * 0.6f while (true) { - if (clock.page == Size.Zero) { withFrameMillis { }; continue } + if (clock.page == Size.Zero) { withFrameNanos { }; continue } val f = MarkFrame(clock.page, Offset.Zero) if (clock.at == Offset.Unspecified) clock.at = Offset(clock.page.width * 0.64f, clock.page.height * 0.42f) if (Motion.scale == 0f) { @@ -108,8 +108,13 @@ private fun rememberMarkClock(avoid: Rect?): MarkClock { clock.wall = 0f return@LaunchedEffect } - withFrameMillis { now -> - val dt = if (last < 0) 0f else min(50f, (now - last) / Motion.scale) + withFrameNanos { nanos -> + val scale = Motion.scale + if (scale == 0f) return@withFrameNanos + val settled = clock.intro >= END && clock.ball >= IMPACT + REVEAL_MS && !clock.poked + if (settled && last >= 0 && !IdleFrames.due(nanos)) return@withFrameNanos + val now = nanos / 1_000_000L + val dt = if (last < 0) 0f else min(50f, (now - last).toFloat()) / scale.coerceAtLeast(0.01f) last = now clock.intro += dt clock.wall += dt @@ -117,34 +122,41 @@ private fun rememberMarkClock(avoid: Rect?): MarkClock { val before = clock.ball clock.ball += dt - var x = clock.at.x + vx * dt / 1000f - var y = clock.at.y + vy * dt / 1000f + var x = clock.at.x + var y = clock.at.y val hw = f.ball val hh = f.ball - if (x - hw < 0f) { x = hw; vx = abs(vx) } - if (x + hw > clock.page.width) { x = clock.page.width - hw; vx = -abs(vx) } - if (y - hh < 0f) { y = hh; vy = abs(vy) } - if (y + hh > clock.page.height) { y = clock.page.height - hh; vy = -abs(vy) } - keepOff?.inflate(clearance)?.let { r -> - val nearX = x.coerceIn(r.left, r.right) - val nearY = y.coerceIn(r.top, r.bottom) - val gapX = x - nearX - val gapY = y - nearY - val gap = hypot(gapX, gapY) - if (gap in 0.0001f..f.ball) { - val nx = gapX / gap - val ny = gapY / gap - x = nearX + nx * f.ball - y = nearY + ny * f.ball - val into = vx * nx + vy * ny - if (into < 0f) { vx -= 2f * into * nx; vy -= 2f * into * ny } - } else if (gap <= 0.0001f) { - val outX = if (x < r.center.x) r.left - f.ball - x else r.right + f.ball - x - val outY = if (y < r.center.y) r.top - f.ball - y else r.bottom + f.ball - y - if (abs(outX) < abs(outY)) { x += outX; vx = if (outX < 0) -abs(vx) else abs(vx) } - else { y += outY; vy = if (outY < 0) -abs(vy) else abs(vy) } + var left = dt + do { + val step = min(50f, left) + left -= step + x += vx * step / 1000f + y += vy * step / 1000f + if (x - hw < 0f) { x = hw; vx = abs(vx) } + if (x + hw > clock.page.width) { x = clock.page.width - hw; vx = -abs(vx) } + if (y - hh < 0f) { y = hh; vy = abs(vy) } + if (y + hh > clock.page.height) { y = clock.page.height - hh; vy = -abs(vy) } + keepOff?.inflate(clearance)?.let { r -> + val nearX = x.coerceIn(r.left, r.right) + val nearY = y.coerceIn(r.top, r.bottom) + val gapX = x - nearX + val gapY = y - nearY + val gap = hypot(gapX, gapY) + if (gap in 0.0001f..f.ball) { + val nx = gapX / gap + val ny = gapY / gap + x = nearX + nx * f.ball + y = nearY + ny * f.ball + val into = vx * nx + vy * ny + if (into < 0f) { vx -= 2f * into * nx; vy -= 2f * into * ny } + } else if (gap <= 0.0001f) { + val outX = if (x < r.center.x) r.left - f.ball - x else r.right + f.ball - x + val outY = if (y < r.center.y) r.top - f.ball - y else r.bottom + f.ball - y + if (abs(outX) < abs(outY)) { x += outX; vx = if (outX < 0) -abs(vx) else abs(vx) } + else { y += outY; vy = if (outY < 0) -abs(vy) else abs(vy) } + } } - } + } while (left > 0f) clock.at = Offset(x, y) if (before < IMPACT && clock.ball >= IMPACT) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt index 83f2e05436..bc8576b287 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt @@ -1,52 +1,371 @@ package com.droiddeck.launcher.ui +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.withFrameNanos +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.input.InputMode +import androidx.compose.ui.platform.LocalInputModeManager +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp import com.droiddeck.launcher.R import com.droiddeck.launcher.gpu.FrameGen import com.droiddeck.launcher.gpu.Lossless @Composable internal fun FrameGenMenu( - host: MenuHost, mode: FrameGen.Mode, lossless: Lossless.State, + mode: FrameGen.Mode, + lossless: Lossless.State, onPick: (FrameGen.Mode) -> Unit, - onImportLossless: () -> Unit, gameProfileId: String? = null, hasGameOverride: Boolean = false, onResetGame: () -> Unit = {}, + focusModifier: Modifier = Modifier, + legacyButtons: Boolean = false, + listLayout: Boolean = false, + sessionHost: MenuHost? = null, ) { + val sessionEngineAnchor = remember { FocusRequester() } + val need = stringResource(R.string.lsfg_needs_steam) + val selectedEngine = mode.engine.takeIf { it != FrameGen.ENGINE_OFF } + val offLabel = FrameGen.label(LocalContext.current, FrameGen.Mode.OFF) + val colors = MaterialTheme.colorScheme val context = LocalContext.current - AnchoredMenu(host.open == "fg", onDismiss = { if (host.open == "fg") host.open = null }, title = stringResource(R.string.frame_gen_title)) { firstItemFocus -> - val need = when { - lossless.ready -> null - lossless.owned -> stringResource(R.string.lsfg_needs_install) - else -> stringResource(R.string.lsfg_needs_steam) + var pacerEnabled by remember { mutableStateOf(FrameGen.pacerEnabled(context)) } + val engines = listOf(FrameGen.ENGINE_LSFG to "LSFG", FrameGen.ENGINE_DDFG to "DDFG", FrameGen.ENGINE_ZEROFG to "ZeroFG") + + if (legacyButtons) { + val context = LocalContext.current + val options = buildList { + add(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) + (2..4).forEach { add(FrameGen.Mode(FrameGen.ENGINE_DDFG, it)) } + (2..4).forEach { add(FrameGen.Mode(FrameGen.ENGINE_ZEROFG, it)) } + (2..4).forEach { add(FrameGen.Mode(FrameGen.ENGINE_LSFG, it)) } + FrameGen.ADAPTIVE_TARGETS.forEach { add(FrameGen.Mode(FrameGen.ENGINE_LSFG, target = it)) } } - @Composable - fun item(m: FrameGen.Mode, enabled: Boolean = true, detail: String? = null, focus: FocusRequester? = null) = - MenuItem(FrameGen.label(context, m), checked = mode == m, enabled = enabled, detail = detail, focusRequester = focus) { - onPick(m); host.open = null + Column(Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, bottom = 8.dp)) { + options.forEachIndexed { index, option -> + val selected = mode == option || + (option.engine == FrameGen.ENGINE_OFF && selectedEngine == null) + val enabled = option.engine != FrameGen.ENGINE_LSFG || lossless.ready || selected + val pick = { onPick(option) } + OutlinedButton( + onClick = pick, + enabled = enabled, + modifier = (if (index == 0) focusModifier else Modifier).fillMaxWidth() + .padding(top = if (index == 0) 0.dp else 6.dp) + .controllerConfirm(enabled = enabled, onClick = pick), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface, + contentColor = if (selected) colors.primary else colors.onSurface, + ), + ) { Text(FrameGen.label(context, option)) } } - item(FrameGen.Mode.OFF, focus = firstItemFocus) - if (gameProfileId != null) { - MenuItem(stringResource(R.string.comp_game_use_general), checked = !hasGameOverride) { + if (selectedEngine == FrameGen.ENGINE_LSFG && !lossless.ready) { + Text( + need, + color = colors.onSurfaceVariant, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(top = 6.dp), + ) + } + if (gameProfileId != null) { + val resetGame = onResetGame + OutlinedButton( + onClick = resetGame, + modifier = Modifier.fillMaxWidth().padding(top = 6.dp) + .controllerConfirm(onClick = resetGame), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + ) { + Text(stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓") + } + } + } + return + } + + Column(Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, top = 0.dp, bottom = 8.dp)) { + if (sessionHost != null) { + SessionFrameGenEngine( + sessionHost, mode, listOf(FrameGen.ENGINE_OFF to offLabel) + engines, + lossless.ready, need, focusModifier, sessionEngineAnchor, onPick, + ) + } else { + OutlinedButton( + onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) }, + modifier = Modifier.fillMaxWidth().controllerConfirm( + onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) }, + ), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selectedEngine == null) colors.primary.copy(alpha = 0.16f) else colors.surface, + contentColor = if (selectedEngine == null) colors.primary else colors.onSurface, + ), + ) { Text(offLabel) } + + if (listLayout) { + Column(Modifier.fillMaxWidth().padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + engines.forEach { (engine, label) -> + val selected = selectedEngine == engine + val enabled = selected || engine != FrameGen.ENGINE_LSFG || lossless.ready + val pick = { + onPick(if (selected) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4))) + } + OutlinedButton( + onClick = pick, + enabled = enabled, + modifier = Modifier.fillMaxWidth().controllerConfirm(enabled = enabled, onClick = pick), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface, + contentColor = if (selected) colors.primary else colors.onSurface, + ), + ) { Text(label) } + } + } + } else { + Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { + val focusIndex = engines.indexOfFirst { (engine, _) -> + selectedEngine == engine || engine != FrameGen.ENGINE_LSFG || lossless.ready + } + engines.forEachIndexed { index, (engine, label) -> + val selected = selectedEngine == engine + val enabled = selected || engine != FrameGen.ENGINE_LSFG || lossless.ready + val pick = { + onPick(if (selected) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4))) + } + OutlinedButton( + onClick = pick, + enabled = enabled, + modifier = (if (index == focusIndex) focusModifier else Modifier) + .weight(1f).controllerConfirm(enabled = enabled, onClick = pick), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface, + contentColor = if (selected) colors.primary else colors.onSurface, + ), + ) { Text(label) } + } + } + } + } + + val multiplierEnabled = mode.engine != FrameGen.ENGINE_LSFG || lossless.ready + if (listLayout) { + Column( + Modifier.fillMaxWidth().padding(top = 8.dp), + verticalArrangement = Arrangement.spacedBy(6.dp), + ) { + (2..4).forEach { multiplier -> + val selected = mode.multiplier == multiplier && mode.target == 0 + val pickMultiplier = { onPick(mode.copy(multiplier = multiplier, target = 0)) } + OutlinedButton( + onClick = pickMultiplier, + enabled = multiplierEnabled, + modifier = Modifier.fillMaxWidth().controllerConfirm(enabled = multiplierEnabled, onClick = pickMultiplier) + .frameGenFocus(sessionHost), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface, + contentColor = if (selected) colors.secondary else colors.onSurface, + ), + ) { Text("${multiplier}×") } + } + } + } else { + Row( + Modifier.fillMaxWidth().padding(top = 8.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + (2..4).forEach { multiplier -> + val selected = mode.multiplier == multiplier && mode.target == 0 + val pickMultiplier = { onPick(mode.copy(multiplier = multiplier, target = 0)) } + OutlinedButton( + onClick = pickMultiplier, + enabled = multiplierEnabled, + modifier = Modifier.weight(1f).controllerConfirm(enabled = multiplierEnabled, onClick = pickMultiplier) + .frameGenFocus(sessionHost), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface, + contentColor = if (selected) colors.secondary else colors.onSurface, + ), + ) { Text("${multiplier}×") } + } + } + } + + val togglePacer = { + val enabled = !pacerEnabled + FrameGen.setPacer(context, enabled) + pacerEnabled = enabled + } + OutlinedButton( + onClick = togglePacer, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp) + .controllerConfirm(onClick = togglePacer).frameGenFocus(sessionHost), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (pacerEnabled) colors.primary.copy(alpha = 0.16f) else colors.surface, + contentColor = if (pacerEnabled) colors.primary else colors.onSurface, + ), + ) { + Text("ZeroPacer" + if (pacerEnabled) " ✓" else "") + } + + + if (selectedEngine == FrameGen.ENGINE_LSFG) { + Row( + Modifier.fillMaxWidth().padding(top = 8.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + FrameGen.ADAPTIVE_TARGETS.forEach { target -> + val adaptiveMode = FrameGen.Mode(FrameGen.ENGINE_LSFG, target = target) + val selected = mode.target == target + val pickTarget = { onPick(adaptiveMode) } + OutlinedButton( + onClick = pickTarget, + enabled = lossless.ready, + modifier = Modifier.weight(1f).controllerConfirm( + enabled = lossless.ready, + onClick = pickTarget, + ).frameGenFocus(sessionHost), + contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface, + contentColor = if (selected) colors.secondary else colors.onSurface, + ), + ) { + Text(FrameGen.label(LocalContext.current, adaptiveMode)) + } + } + } + } + + if (sessionHost == null && selectedEngine == FrameGen.ENGINE_LSFG && !lossless.ready) { + Text(need, color = colors.onSurfaceVariant, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(top = 6.dp)) + } + + if (gameProfileId != null && (sessionHost == null || hasGameOverride)) { + val input = LocalInputModeManager.current + val resetGame = { + if (sessionHost != null && input.inputMode == InputMode.Keyboard) { + sessionEngineAnchor.requestFocus() + } onResetGame() - host.open = null } + OutlinedButton( + onClick = resetGame, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp) + .testTag("framegen-use-global").controllerConfirm(onClick = resetGame) + .frameGenFocus(sessionHost), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + ) { + Text(if (sessionHost != null) stringResource(R.string.frame_gen_use_global) + else stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓") + } } - for (m in 2..4) item(FrameGen.Mode(FrameGen.ENGINE_DDFG, m)) - val lsfg = (2..4).map { FrameGen.Mode(FrameGen.ENGINE_LSFG, it) } + - FrameGen.ADAPTIVE_TARGETS.map { FrameGen.Mode(FrameGen.ENGINE_LSFG, target = it) } - lsfg.forEachIndexed { i, m -> item(m, enabled = lossless.ready, detail = need.takeIf { i == 0 }) } - if (lossless.owned) { - val using = when (lossless.source) { - Lossless.Source.STEAM -> stringResource(R.string.lsfg_using_steam) - Lossless.Source.IMPORT -> stringResource(R.string.lsfg_using_import) - Lossless.Source.NONE -> null + } +} + +@Composable +private fun Modifier.frameGenFocus(sessionHost: MenuHost?): Modifier = + if (sessionHost != null) focusGlide(RoundedCornerShape(percent = 50)) else this + +@Composable +private fun SessionFrameGenEngine( + host: MenuHost, + mode: FrameGen.Mode, + options: List>, + losslessReady: Boolean, + losslessNote: String, + focusModifier: Modifier, + anchor: FocusRequester, + onPick: (FrameGen.Mode) -> Unit, +) { + val label = stringResource(R.string.frame_gen_engine) + val selectedLabel = options.firstOrNull { (engine, _) -> engine == mode.engine }?.second + ?: options.first().second + val key = "frame-generation-engine" + val open = host.open == key + val input = LocalInputModeManager.current + var anchorFocused by remember { mutableStateOf(false) } + val selectedOption = remember { FocusRequester() } + var keyboardOpened by remember { mutableStateOf(false) } + val initial = options.firstOrNull { (engine, _) -> engine == mode.engine }?.first + ?: FrameGen.ENGINE_OFF + val close = { if (host.open == key) host.open = null } + + // Keep the options in the drawer's focus tree. A separate popup window can + // steal focus from the controller before Compose can focus the selected row. + LaunchedEffect(open) { + if (!keyboardOpened || (!open && host.open != null)) return@LaunchedEffect + val target = if (open) selectedOption else anchor + withFrameNanos { } + target.requestFocus() + if (!open) keyboardOpened = false + } + + val blockedSelection = !losslessReady && mode.engine == FrameGen.ENGINE_LSFG + SettingsRow(label, losslessNote.takeIf { blockedSelection && !open }, highlighted = open) { + ValueChip( + selectedLabel, open, + modifier = focusModifier.focusRequester(anchor).onFocusChanged { anchorFocused = it.isFocused } + .heightIn(min = 48.dp).testTag("setting-$key") + .semantics { contentDescription = label; stateDescription = selectedLabel }, + ) { + if (open) close() + else { + keyboardOpened = anchorFocused || input.inputMode == InputMode.Keyboard + host.open = key + } + } + } + if (open) { + Column(Modifier.fillMaxWidth().padding(horizontal = 8.dp).controllerBack(close)) { + options.forEach { (engine, text) -> + val selected = engine == mode.engine + val enabled = selected || engine != FrameGen.ENGINE_LSFG || losslessReady + MenuItem( + label = text, checked = selected, enabled = enabled, + detail = losslessNote.takeIf { engine == FrameGen.ENGINE_LSFG && !losslessReady }, + focusRequester = selectedOption.takeIf { engine == initial }, + modifier = Modifier.heightIn(min = 48.dp).testTag("framegen-engine:$engine"), + ) { + close() + if (!selected) { + onPick(if (engine == FrameGen.ENGINE_OFF) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) + else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4))) + } + } } - MenuItem(stringResource(R.string.lsfg_import), checked = false, detail = using) { host.open = null; onImportLossless() } } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt index bc55af594e..574ad4c56c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt @@ -272,7 +272,10 @@ private fun Content( return } if (selected == "steam") { - SteamHome(s, a, modifier) + Box(modifier) { + SteamHome(s, a, Modifier.fillMaxSize()) + SteamHomePreviewPill(Modifier.align(androidx.compose.ui.Alignment.BottomCenter).padding(bottom = 20.dp)) + } return } if (selected == "store") { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt index 2322e93827..d7d2395a3f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndRail.kt @@ -96,8 +96,7 @@ import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.onPlaced import com.droiddeck.launcher.core.PhantomProcessLimit - -internal val AttentionAmber = Color(0xFFFFB547) +internal val AttentionAmber: Color @Composable get() = LocalPalette.current.warning @Composable internal fun BottomBar( @@ -308,7 +307,7 @@ private fun RailItem( } if (badge) Box( modifier = Modifier.align(Alignment.TopEnd).padding(top = if (iconOnly) 7.dp else 8.dp, end = if (iconOnly) 9.dp else 18.dp) - .size(8.dp).clip(CircleShape).background(AttentionAmber), + .size(8.dp).clip(CircleShape).background(pal.warning), ) if (count > 0) Text( if (count > 9) "9+" else count.toString(), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 6fdea19e64..bbb0895eb6 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -88,6 +88,7 @@ import com.droiddeck.launcher.input.SecondScreenDisplay import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.PhantomProcessLimit import com.droiddeck.launcher.core.PhantomProcessStatus +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import kotlin.math.roundToInt import kotlinx.coroutines.withTimeoutOrNull @@ -142,7 +143,7 @@ class FrontEndState( val homeScreenEnabled: Boolean = false, val defaultHomeLabel: String? = null, val integration: com.droiddeck.launcher.core.SteamIntegration.State = com.droiddeck.launcher.core.SteamIntegration.State(suggested = false), - val integrationFocus: com.droiddeck.launcher.core.SteamIntegration.Feature? = null, + val integrationFocus: SteamIntegrationFocusRequest? = null, val androidApps: List = emptyList(), val secondScreenDisplays: List = emptyList(), val ownScreen: SecondScreenDisplay? = null, @@ -176,7 +177,14 @@ class FrontEndState( val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, val launcherOrientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER, val homePage: String = com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM, - val launcherFullscreen: Boolean = true, + val launcherFullscreenMode: FullscreenMode = FullscreenMode.ALWAYS, + val sessionFullscreenMode: FullscreenMode = FullscreenMode.ALWAYS, + val launcherFrost: Boolean = false, + val frostWallpaper: Boolean = true, + val frostCards: Boolean = true, + val frostTransparency: Int = FROST_WALLPAPER_DEFAULT, + val frostCardTransparency: Int = FROST_DEFAULT, + val frostSupported: Boolean = false, val controllerHaptics: Boolean = true, val downloadSource: String = DownloadSource.MODE_AUTO, val downloadMirror: String = "", @@ -240,7 +248,6 @@ class FrontEndActions( val onVkBridgeSafe: (Boolean) -> Unit = {}, val onBridgeProtonDxvk: (Boolean) -> Unit = {}, val onFrameGenPick: (FrameGen.Mode) -> Unit, - val onImportLossless: () -> Unit, val onProtons: () -> Unit, val onComponents: (focusContent: Boolean) -> Unit, val onGameComponents: (Library.SteamGame) -> Unit = { onComponents(true) }, @@ -250,7 +257,7 @@ class FrontEndActions( val onAddonDelete: (com.droiddeck.launcher.runtime.WowAddons.Target, String) -> Unit = { _, _ -> }, val onSaveExport: (Library.SteamGame, com.droiddeck.launcher.session.GameSaves.Layout) -> Unit = { _, _ -> }, val onPerformance: () -> Unit, - val performancePanel: @Composable () -> Unit = {}, + val performancePanel: @Composable (memory: @Composable () -> Unit) -> Unit = { memory -> memory() }, val onRoms: () -> Unit, val onFiles: () -> Unit, val onBrowseFiles: (File) -> Unit = {}, @@ -271,7 +278,7 @@ class FrontEndActions( val onShareSessionLog: (File) -> Unit = {}, val onSaveSessionLog: (File) -> Unit = {}, val onDeleteSessionLog: (File, () -> Unit) -> Unit = { _, done -> done() }, - val onClearLogs: () -> Unit = {}, + val onClearLogs: (() -> Unit) -> Unit = {}, val onResetSettings: () -> Unit = {}, val onOffline: () -> Unit, val onOfflineAuto: () -> Unit = {}, @@ -283,7 +290,13 @@ class FrontEndActions( val onOrientation: (Int) -> Unit = {}, val onLauncherOrientation: (Int) -> Unit = {}, val onHomePage: (String) -> Unit = {}, - val onLauncherFullscreen: (Boolean) -> Unit = {}, + val onLauncherFullscreenMode: (FullscreenMode) -> Unit = {}, + val onSessionFullscreenMode: (FullscreenMode) -> Unit = {}, + val onLauncherFrost: (Boolean) -> Unit = {}, + val onFrostWallpaper: (Boolean) -> Unit = {}, + val onFrostCards: (Boolean) -> Unit = {}, + val onFrostTransparency: (Int) -> Unit = {}, + val onFrostCardTransparency: (Int) -> Unit = {}, val onControllerHaptics: (Boolean) -> Unit = {}, val onAnimationsEnabled: (Boolean) -> Unit = {}, val onLowStorageWarning: (Boolean) -> Unit = {}, @@ -446,6 +459,15 @@ internal suspend fun focusWithinFrames(done: () -> Boolean, target: () -> FocusR } } +internal suspend fun holdFocus(held: () -> Boolean, target: () -> FocusRequester?) { + val since = MainTabSteps.otherKeys + repeat(RAIL_HOLD_FRAMES) { frame -> + androidx.compose.runtime.withFrameNanos { } + if (MainTabSteps.otherKeys != since) return + if (frame == 0 || !held()) runCatching { target()?.requestFocus() } + } +} + internal suspend fun focusSoon(target: () -> FocusRequester) { repeat(30) { androidx.compose.runtime.withFrameNanos { } @@ -658,6 +680,11 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com LaunchedEffect(SetupTabs.openSection) { if (SetupTabs.openSection != null && (railSelection != "setup" || s.pageKey != null)) showRailPage("setup", true) } + LaunchedEffect(DevPreview.openSteam) { + if (!DevPreview.openSteam) return@LaunchedEffect + DevPreview.openSteam = false + showRailPage("steam", true) + } LaunchedEffect(DevPreview.openLibrary) { if (!DevPreview.openLibrary) return@LaunchedEffect DevPreview.openLibrary = false @@ -687,9 +714,12 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com if (anyFocused) return } } + val launcherFullscreen = s.launcherFullscreenMode.hidesSystemBars( + androidx.compose.ui.platform.LocalConfiguration.current.orientation, + ) androidx.compose.foundation.layout.BoxWithConstraints( - modifier = Modifier.fillMaxSize().background(colors.background) - .windowInsetsPadding(if (s.launcherFullscreen) WindowInsets.displayCutout else WindowInsets.systemBars) + modifier = Modifier.fillMaxSize().background(if (LocalFrost.current != null) Color.Transparent else colors.background) + .windowInsetsPadding(if (launcherFullscreen) WindowInsets.displayCutout else WindowInsets.systemBars) .onFocusChanged { anyFocused = it.hasFocus }, ) { val bottomNavigation = maxHeight > maxWidth @@ -770,10 +800,13 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com val stepScope = androidx.compose.runtime.rememberCoroutineScope() val pageKeyNow = androidx.compose.runtime.rememberUpdatedState(s.pageKey) var railHold by remember { mutableStateOf(null) } + val stepView = androidx.compose.ui.platform.LocalView.current val tabStep = androidx.compose.runtime.rememberUpdatedState { step: Int -> if (!processSettingsPageVisible) { val keys = navigationKeys(s) keys.getOrNull(keys.indexOf(railSelectionNow.value) + step)?.let { key -> + releaseFocusedTextField(stepView) + OpenMenus.leaveAll(withPage = true) PageSwipe.direction = step if (s.dualScreen) { onRailSelect(key); return@let } showRailPage(key, false) @@ -842,6 +875,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com com.droiddeck.launcher.stores.StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } } com.droiddeck.launcher.stores.StoresState.itchPicking?.let { item -> StoreTheme(item.store) { ItchBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.itchPicking = null } } } com.droiddeck.launcher.stores.StoresState.gameJoltPicking?.let { item -> StoreTheme(item.store) { GameJoltBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.gameJoltPicking = null } } } + com.droiddeck.launcher.stores.StoresState.steamPicking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.StoresState.steamPicking = null } } } StepsLayer(screenAt) UiZooSheet() SessionDrawerPreview(s.secondScreenDisplays) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index 543c5f6857..21c94cc8bf 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -1,6 +1,9 @@ package com.droiddeck.launcher.ui import androidx.compose.ui.platform.LocalContext +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver +import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.FocusRequester import android.os.Build @@ -50,6 +53,7 @@ import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -81,6 +85,7 @@ import com.droiddeck.launcher.core.DeviceSupport import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.PhantomProcessLimit import com.droiddeck.launcher.core.PhantomProcessStatus +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.download.StoreDownloadTier import com.droiddeck.launcher.R @@ -103,7 +108,7 @@ internal object SetupTabs { } @Composable -internal fun CheckRow(state: CheckState, title: String, detail: String?, divider: Boolean = true, action: (@Composable () -> Unit)? = null) { +internal fun CheckRow(state: CheckState, title: String, detail: String?, divider: Boolean = true, detailLines: Int = 2, action: (@Composable () -> Unit)? = null) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val tint = when (state) { @@ -135,7 +140,7 @@ internal fun CheckRow(state: CheckState, title: String, detail: String?, divider } Column(modifier = Modifier.weight(1f)) { Text(title, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) - if (detail != null) Text(detail, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + if (detail != null) Text(detail, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = detailLines, overflow = TextOverflow.Ellipsis) } if (action != null) action() } @@ -152,6 +157,20 @@ internal fun SetupPanel( ) { val host = rememberMenuHost() val ctx = LocalContext.current + val frostRow = s.frostSupported && s.theme != Themes.TRUE_BLACK + var steamOrientation by remember { mutableStateOf(SessionPrefs.orientation(ctx, "steam")) } + var desktopOrientation by remember { mutableStateOf(SessionPrefs.orientation(ctx, "desktop")) } + val lifecycleOwner = LocalLifecycleOwner.current + DisposableEffect(lifecycleOwner, ctx) { + val observer = LifecycleEventObserver { _, event -> + if (event == Lifecycle.Event.ON_RESUME) { + steamOrientation = SessionPrefs.orientation(ctx, "steam") + desktopOrientation = SessionPrefs.orientation(ctx, "desktop") + } + } + lifecycleOwner.lifecycle.addObserver(observer) + onDispose { lifecycleOwner.lifecycle.removeObserver(observer) } + } var hideHomeFromRecents by remember { mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.hideHomeFromRecents(ctx)) } var processLimitBusy by remember { mutableStateOf(false) } var processLimitMessage by remember { mutableStateOf(null) } @@ -212,7 +231,10 @@ internal fun SetupPanel( } val chipFocus = remember { List(tabs.size) { FocusRequester() } } var tabTurned by remember { mutableStateOf(false) } - val pick: (Int) -> Unit = { i -> tab = i; tabTurned = true; searching = false; query = ""; if (i == DEVELOPER_TAB) logsRefresh++ } + remember { SettingsSearchHistory.load(ctx) } + var fromHistory by remember { mutableStateOf(false) } + val keepSearch = { if (searching && SettingsIndex.search(ctx, query, frostRow).isNotEmpty()) SettingsSearchHistory.add(ctx, query) } + val pick: (Int) -> Unit = { i -> keepSearch(); tab = i; tabTurned = true; searching = false; query = ""; if (i == DEVELOPER_TAB) logsRefresh++ } val inputModeManager = LocalInputModeManager.current LaunchedEffect(Unit) { while (true) { @@ -237,16 +259,24 @@ internal fun SetupPanel( onNext = { pick((tab + 1) % tabs.size) }, ), ) { - PageHeader(stringResource(R.string.setup_title)) { + val sectionBar: @Composable (Modifier) -> Unit = { m -> SettingsPillSearch( - Modifier.weight(1f), searching, query, { query = it }, - onOpen = { searching = true }, onClose = { searching = false; query = "" }, + m, searching, query, { query = it; fromHistory = false }, + onOpen = { searching = true }, onClose = { keepSearch(); searching = false; query = "" }, + keepOpen = SettingsSearchHistory.items.isNotEmpty(), onSearch = keepSearch, ) { SheetChips(tabs, tab, chipFocus, onPick = pick) } } + val portrait = androidx.compose.ui.platform.LocalConfiguration.current.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT + if (portrait) { + PageHeader(stringResource(R.string.setup_title)) + Row(Modifier.fillMaxWidth().padding(bottom = 10.dp)) { sectionBar(Modifier.weight(1f)) } + } else PageHeader(stringResource(R.string.setup_title)) { sectionBar(Modifier.weight(1f)) } val listing = searching && query.isNotBlank() - val fixed = tab == CONTROLLER_TAB && !listing + val history = searching && query.isBlank() && SettingsSearchHistory.items.isNotEmpty() + val fixed = tab == CONTROLLER_TAB && !listing && !history Column(modifier = Modifier.weight(1f).fillMaxWidth().then(if (fixed) Modifier else Modifier.verticalScroll(rememberScrollState())).padding(bottom = if (fixed) 0.dp else 24.dp)) { - if (listing) SettingsSearchResults(query) { section -> pick(section.ordinal) } + if (listing) SettingsSearchResults(query, frostRow, focusFirst = fromHistory, onSearched = keepSearch) { section -> pick(section.ordinal) } + else if (history) SettingsSearchHistoryList(onPick = { fromHistory = true; query = it }) { SettingsSearchHistory.clear(ctx) } else when (tab) { OVERVIEW_TAB -> { OnboardingCard(limitBlocks, a.onShowPhantomGate) @@ -393,7 +423,8 @@ internal fun SetupPanel( listOfNotNull( gpu.displayName(ctx), s.installed?.let { stringResource(R.string.setup_ready_runtime, it) }, - stringResource(R.string.setup_ready_limit_off).takeIf { !limitBlocks }, + stringResource(R.string.setup_ready_limit_off) + .takeIf { !limitBlocks && s.phantomProcessStatus != PhantomProcessStatus.UNCOUNTED }, s.offlineAccount?.takeIf { it.isNotEmpty() }?.let { stringResource(R.string.setup_ready_signed_in, it) }, ).joinToString(" · "), open = showChecks, onDetails = { showChecks = !showChecks }, @@ -411,11 +442,10 @@ internal fun SetupPanel( } } SettingsGroup(stringResource(R.string.setup_runtime)) { runtimeCheck(false) } - SteamIntegrationGroup(s.integration, s.integrationFocus, a.onIntegration, a.onIntegrationAppInfo, a.onIntegrationLocation) + SteamIntegrationGroup(s.integration, s.integrationFocus, a.onIntegration, a.onIntegrationAppInfo, a.onIntegrationLocation, collapsible = true) } PERFORMANCE_TAB -> { - a.performancePanel() - MemoryGroup(s, a, host, onPairWirelessDebugging) + a.performancePanel { MemoryGroup(s, a, host, onPairWirelessDebugging) } } CONTROLLER_TAB -> { val controller = s.controller @@ -442,6 +472,35 @@ internal fun SetupPanel( if (s.theme == Themes.GRADIENT) GradientColorRows() if (s.theme == Themes.CUSTOM) CustomColorRows() if (s.theme == Themes.TRUE_BLACK) HighlightColorRow() + if (frostRow) { + ToggleRow( + host, "launcher-frost", stringResource(R.string.setup_frosted_background), + stringResource(R.string.setup_frosted_background_hint), s.launcherFrost, onChange = a.onLauncherFrost, + ) + if (s.launcherFrost) { + val ctx = androidx.compose.ui.platform.LocalContext.current + val percent: (Int) -> String = { ctx.getString(R.string.ctrl_percent, it) } + ToggleRow( + host, "launcher-frost-wallpaper", stringResource(R.string.setup_frosted_wallpaper), null, + s.frostWallpaper, onChange = a.onFrostWallpaper, + ) + SliderRow( + stringResource(R.string.setup_frost_transparency), stringResource(R.string.setup_frost_transparency_hint), + s.frostTransparency, 0..FROST_MAX, step = FROST_STEP, enabled = s.frostWallpaper, format = percent, + onChange = a.onFrostTransparency, + ) + ToggleRow( + host, "launcher-frost-cards", stringResource(R.string.setup_frosted_cards), + stringResource(if (s.frostWallpaper) R.string.setup_frosted_cards_hint else R.string.setup_frosted_cards_needs_wallpaper), + s.frostCards, enabled = s.frostWallpaper, onChange = a.onFrostCards, + ) + SliderRow( + stringResource(R.string.setup_frost_card_transparency), stringResource(R.string.setup_frost_card_transparency_hint), + s.frostCardTransparency, 0..FROST_MAX, step = FROST_STEP, enabled = s.frostWallpaper && s.frostCards, format = percent, + onChange = a.onFrostCardTransparency, + ) + } + } ChoiceRow( host, "app-scale", stringResource(R.string.setup_app_scale), stringResource(R.string.setup_app_scale_hint), com.droiddeck.launcher.core.AppUiPrefs.scales.map { percent -> @@ -468,11 +527,11 @@ internal fun SetupPanel( } } val device: @Composable () -> Unit = { - SettingsGroup(stringResource(R.string.setup_group_device)) { + SettingsGroup(stringResource(R.string.setup_group_home_navigation)) { ToggleRow( host, "home-screen", stringResource(R.string.setup_home), if (s.homeScreenEnabled) stringResource(R.string.setup_home_on) else stringResource(R.string.setup_home_off), - s.homeScreenEnabled, + s.homeScreenEnabled, sideBySide = true, ) { a.onHomeScreen(it) } if (s.homeScreenEnabled) { ActionRow(stringResource(R.string.setup_default_home), s.defaultHomeLabel ?: stringResource(R.string.setup_choose_home), stringResource(R.string.setup_choose), a.onHomeApp) @@ -489,10 +548,35 @@ internal fun SetupPanel( s.homePage, onPick = a.onHomePage, ) } + ToggleRow( + host, "page-swipe", stringResource(R.string.setup_page_swipe), + stringResource(R.string.setup_page_swipe_hint), PageSwipe.on, sideBySide = true, + ) { on -> + PageSwipe.on = on + com.droiddeck.launcher.core.AppUiPrefs.setPageSwipe(ctx, on) + } + } + SettingsGroup(stringResource(R.string.setup_group_display)) { + var sessionDisplay by rememberSaveable { mutableStateOf(false) } + val jump = SettingsJump.target + val sessionLabels = listOf( + stringResource(R.string.setup_session_orientation), + stringResource(R.string.setup_session_fullscreen), + stringResource(R.string.setup_dual_screen_sessions), + ) + LaunchedEffect(jump) { + if (jump != null && jump.label in sessionLabels) sessionDisplay = true + } ChoiceRow( host, "launcher-orientation", stringResource(R.string.setup_launcher_orientation), null, com.droiddeck.launcher.core.AppUiPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, - s.launcherOrientation, onPick = a.onLauncherOrientation, + s.launcherOrientation, onPick = a.onLauncherOrientation, sideBySide = true, + ) + val fullscreenModes = FullscreenMode.entries.map { it to stringResource(it.label) } + ChoiceRow( + host, "launcher-fullscreen", stringResource(R.string.setup_launcher_fullscreen), + stringResource(R.string.setup_fullscreen_on), + fullscreenModes, s.launcherFullscreenMode, onPick = a.onLauncherFullscreenMode, sideBySide = true, ) s.tpUbwcMode?.let { ubwc -> ChoiceRow( @@ -508,48 +592,74 @@ internal fun SetupPanel( else Note(stringResource(R.string.gpu_ubwc_restart)) } } - ChoiceRow( - host, "orientation", stringResource(R.string.setup_session_orientation), stringResource(R.string.setup_session_orientation_hint), - SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, - s.orientation, onPick = a.onOrientation, + val dualModes = listOf( + com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto), + com.droiddeck.launcher.input.DualScreen.MODE_ON to stringResource(R.string.setup_dual_screen_on), + com.droiddeck.launcher.input.DualScreen.MODE_OFF to stringResource(R.string.setup_dual_screen_off), ) - ToggleRow( - host, "launcher-fullscreen", stringResource(R.string.setup_fullscreen), - if (s.launcherFullscreen) stringResource(R.string.setup_fullscreen_on) else stringResource(R.string.setup_fullscreen_off), - s.launcherFullscreen, - ) { a.onLauncherFullscreen(it) } - ToggleRow( - host, "page-swipe", stringResource(R.string.setup_page_swipe), - stringResource(R.string.setup_page_swipe_hint), PageSwipe.on, - ) { on -> - PageSwipe.on = on - com.droiddeck.launcher.core.AppUiPrefs.setPageSwipe(ctx, on) - } - ToggleRow( - host, "controller-haptics", stringResource(R.string.setup_controller_haptics), - stringResource(R.string.setup_controller_haptics_hint), - s.controllerHaptics, - ) { a.onControllerHaptics(it) } if (s.dualScreenDevice) { - val dualModes = listOf( - com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto), - com.droiddeck.launcher.input.DualScreen.MODE_ON to stringResource(R.string.setup_dual_screen_on), - com.droiddeck.launcher.input.DualScreen.MODE_OFF to stringResource(R.string.setup_dual_screen_off), - ) ChoiceRow( host, "dual-screen", stringResource(R.string.setup_dual_screen_launcher), stringResource(R.string.setup_dual_screen_launcher_hint), dualModes, s.dualScreenMode, onPick = a.onDualScreenMode, ) + } + ActionRow( + stringResource(R.string.setup_session_display), stringResource(R.string.setup_session_display_hint), + stringResource(if (sessionDisplay) R.string.common_close else R.string.setup_expand_open), + onClick = { sessionDisplay = !sessionDisplay }, sideBySide = true, + ) + if (sessionDisplay) { ChoiceRow( - host, "dual-screen-sessions", stringResource(R.string.setup_dual_screen_sessions), stringResource(R.string.setup_dual_screen_sessions_hint), - dualModes.take(2) + (com.droiddeck.launcher.input.DualScreen.MODE_SWAPPED to stringResource(R.string.setup_dual_screen_swapped)) + dualModes.drop(2), s.dualScreenSessions, onPick = a.onDualScreenSessions, + host, "orientation", stringResource(R.string.setup_session_orientation), stringResource(R.string.setup_session_orientation_hint), + SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, + s.orientation, onPick = { value -> + a.onOrientation(value) + steamOrientation = SessionPrefs.orientation(ctx, "steam") + desktopOrientation = SessionPrefs.orientation(ctx, "desktop") + }, ) - if (s.dualScreenSessions != com.droiddeck.launcher.input.DualScreen.MODE_OFF) { - ToggleRow(host, "dual-screen-controls", stringResource(R.string.setup_dual_screen_controls), - stringResource(R.string.setup_dual_screen_controls_hint), s.dualScreenControls) { a.onDualScreenControls(it) } + ChoiceRow( + host, "orientation-steam", stringResource(R.string.setup_session_orientation) + " (Steam)", stringResource(R.string.setup_session_orientation_hint), + SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, + steamOrientation, onPick = { value -> + steamOrientation = value + SessionPrefs.setOrientation(ctx, "steam", value) + }, + ) + ChoiceRow( + host, "orientation-desktop", stringResource(R.string.setup_session_orientation) + " (Desktop)", stringResource(R.string.setup_session_orientation_hint), + SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, + desktopOrientation, onPick = { value -> + desktopOrientation = value + SessionPrefs.setOrientation(ctx, "desktop", value) + }, + ) + ChoiceRow( + host, "session-fullscreen", stringResource(R.string.setup_session_fullscreen), + stringResource(R.string.setup_fullscreen_on), + fullscreenModes, s.sessionFullscreenMode, onPick = a.onSessionFullscreenMode, + ) + if (s.dualScreenDevice) { + ChoiceRow( + host, "dual-screen-sessions", stringResource(R.string.setup_dual_screen_sessions), stringResource(R.string.setup_dual_screen_sessions_hint), + dualModes.take(2) + (com.droiddeck.launcher.input.DualScreen.MODE_SWAPPED to stringResource(R.string.setup_dual_screen_swapped)) + dualModes.drop(2), s.dualScreenSessions, onPick = a.onDualScreenSessions, + ) + if (s.dualScreenSessions != com.droiddeck.launcher.input.DualScreen.MODE_OFF) { + ToggleRow(host, "dual-screen-controls", stringResource(R.string.setup_dual_screen_controls), + stringResource(R.string.setup_dual_screen_controls_hint), s.dualScreenControls) { a.onDualScreenControls(it) } + } } + } + } + SettingsGroup(stringResource(R.string.setup_group_input)) { + ToggleRow( + host, "controller-haptics", stringResource(R.string.setup_controller_haptics), + stringResource(R.string.setup_controller_haptics_hint), + s.controllerHaptics, sideBySide = true, + ) { a.onControllerHaptics(it) } + if (s.dualScreenDevice) { ToggleRow(host, "android-text-field-keyboard", stringResource(R.string.setup_android_text_field_keyboard), - null, s.androidTextFieldKeyboard) { a.onAndroidTextFieldKeyboard(it) } + null, s.androidTextFieldKeyboard, sideBySide = true) { a.onAndroidTextFieldKeyboard(it) } } } } @@ -599,95 +709,108 @@ internal fun SetupPanel( } BoxWithConstraints(Modifier.fillMaxWidth()) { if (maxWidth >= 840.dp && !LocalNarrowPane.current) Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.Top) { - Column(Modifier.weight(1f)) { look() } - Column(Modifier.weight(1f)) { device(); art(); download() } - } else Column { look(); device(); art(); download() } + Column(Modifier.weight(1f)) { device() } + Column(Modifier.weight(1f)) { look(); art(); download() } + } else Column { device(); look(); art(); download() } } } DEVELOPER_TAB -> { - val devContext = LocalContext.current + var manageLogs by rememberSaveable { mutableStateOf(false) } SettingsGroup(stringResource(R.string.dev_tools_title)) { - ToggleRow(host, "developer-tools", stringResource(R.string.dev_tools_title), stringResource(R.string.dev_tools_hint), DeveloperTools.on) { - DeveloperTools.set(devContext, it) + ToggleRow(host, "developer-tools", stringResource(R.string.dev_tools_show), stringResource(R.string.dev_tools_hint), DeveloperTools.on, sideBySide = true) { + DeveloperTools.set(ctx, it) + } + if (DeveloperTools.on) ToggleRow(host, "agent-commands", stringResource(R.string.setup_agent_commands), stringResource(R.string.setup_agent_commands_hint), s.agentCommands, sideBySide = true) { a.onAgentCommands() } + if (DeveloperTools.on && com.droiddeck.launcher.agent.AgentHost.available) { + ToggleRow(host, "agent-pet", stringResource(R.string.rail_agent), stringResource(R.string.dev_harness_overlay_hint), AgentPet.enabled, sideBySide = true) { + AgentPet.set(ctx, it) + } + if (AgentPet.enabled && !AgentPet.allowed && AgentPet.usesOverlayWindows(com.droiddeck.launcher.session.QuestExperimental.isSupported())) ActionRow( + stringResource(R.string.setup_agent_pet_float), stringResource(R.string.setup_agent_pet_float_hint), + stringResource(R.string.setup_agent_pet_allow), onClick = { AgentPet.requestFloating(ctx) }, sideBySide = true, + ) } - if (DeveloperTools.on) ActionRow( - stringResource(R.string.dev_ui_zoo), stringResource(R.string.dev_ui_zoo_hint), stringResource(R.string.dev_ui_zoo_open), - onClick = { DevPreview.zoo = true }, modifier = Modifier.testTag("dev-ui-zoo"), - ) - if (DeveloperTools.on) ToggleRow( - host, "preview-shortcuts", stringResource(R.string.dev_preview_shortcuts), stringResource(R.string.dev_preview_shortcuts_hint), - DevPreview.shortcuts, - ) { DevPreview.setShortcuts(devContext, it) } } - SettingsGroup(stringResource(R.string.dev_group_logs)) { - ToggleRow(host, "logs", stringResource(R.string.setup_logs), stringResource(R.string.setup_logs_hint), s.logsEnabled) { a.onLogs() } + if (DeveloperTools.on) SettingsGroup(stringResource(R.string.dev_group_previews)) { + ActionRow( + stringResource(R.string.dev_ui_zoo), stringResource(R.string.dev_ui_zoo_hint), stringResource(R.string.dev_ui_zoo_open), + onClick = { DevPreview.zoo = true }, modifier = Modifier.testTag("dev-ui-zoo"), sideBySide = true, + ) + ToggleRow( + host, "preview-shortcuts", stringResource(R.string.dev_preview_shortcuts), stringResource(R.string.dev_preview_shortcuts_hint), + DevPreview.shortcuts, sideBySide = true, + ) { DevPreview.setShortcuts(ctx, it) } + } + SettingsGroup(stringResource(R.string.dev_group_diagnostics)) { + ToggleRow(host, "logs", stringResource(R.string.setup_logs), stringResource(R.string.setup_logs_hint), s.logsEnabled, sideBySide = true) { a.onLogs() } if (DeveloperTools.on) ToggleRow( host, "enhanced-diagnostics", stringResource(R.string.setup_enhanced_diagnostics), - stringResource(R.string.setup_enhanced_diagnostics_hint), s.enhancedDiagnosticsArmed, + stringResource(R.string.setup_enhanced_diagnostics_hint), s.enhancedDiagnosticsArmed, sideBySide = true, ) { a.onEnhancedDiagnostics() } ToggleRow( host, "game-debug-logs", stringResource(R.string.setup_game_debug_logs), stringResource(if (s.gameDebugLogsNeedsRestart) R.string.setup_game_debug_logs_restart else R.string.setup_game_debug_logs_hint), s.gameDebugLogsEnabled, - enabled = s.logsEnabled, + enabled = s.logsEnabled, sideBySide = true, ) { a.onGameDebugLogs() } - if (DeveloperTools.on) ToggleRow(host, "vacdiag", stringResource(R.string.setup_vac_diag), stringResource(R.string.setup_vac_diag_hint), s.vacDiagnostics) { a.onVacDiagnostics() } - if (DeveloperTools.on) ToggleRow(host, "agent-commands", stringResource(R.string.setup_agent_commands), null, s.agentCommands) { a.onAgentCommands() } - if (DeveloperTools.on && com.droiddeck.launcher.agent.AgentHost.available) { - val agentContext = androidx.compose.ui.platform.LocalContext.current - ToggleRow(host, "agent-pet", stringResource(R.string.setup_agent_pet), stringResource(R.string.setup_agent_pet_hint), AgentPet.enabled) { - AgentPet.set(agentContext, it) - } - if (AgentPet.enabled && !AgentPet.allowed) ActionRow( - stringResource(R.string.setup_agent_pet_float), stringResource(R.string.setup_agent_pet_float_hint), - stringResource(R.string.setup_agent_pet_allow), onClick = { AgentPet.requestFloating(agentContext) }, - ) - } - if (DeveloperTools.on) ToggleRow(host, "graphics-logs", stringResource(R.string.setup_graphics_logs), stringResource(R.string.setup_graphics_logs_hint), s.graphicsLogs) { a.onGraphicsLogs() } - if (DeveloperTools.on && !s.adreno && com.droiddeck.launcher.session.SessionPrefs.steamGpuCompositingAllowed()) ToggleRow(host, "steam-gpu-drawing", stringResource(R.string.setup_steam_gpu_drawing), stringResource(R.string.setup_steam_gpu_drawing_hint), s.steamGpuDrawing) { a.onSteamGpuDrawing() } + if (DeveloperTools.on) ToggleRow(host, "vacdiag", stringResource(R.string.setup_vac_diag), stringResource(R.string.setup_vac_diag_hint), s.vacDiagnostics, sideBySide = true) { a.onVacDiagnostics() } + if (DeveloperTools.on) ToggleRow(host, "graphics-logs", stringResource(R.string.setup_graphics_logs), stringResource(R.string.setup_graphics_logs_hint), s.graphicsLogs, sideBySide = true) { a.onGraphicsLogs() } + if (DeveloperTools.on && !s.adreno && com.droiddeck.launcher.session.SessionPrefs.steamGpuCompositingAllowed()) ToggleRow(host, "steam-gpu-drawing", stringResource(R.string.setup_steam_gpu_drawing), stringResource(R.string.setup_steam_gpu_drawing_hint), s.steamGpuDrawing, sideBySide = true) { a.onSteamGpuDrawing() } + } + SettingsGroup(stringResource(R.string.dev_group_log_files)) { ActionRow(stringResource(R.string.setup_latest_logs), stringResource(R.string.drawer_logs_hint), stringResource(R.string.drawer_share_logs), a.onShareLogs, - progress = com.droiddeck.launcher.session.SessionLogShare.progress) - androidx.compose.material3.HorizontalDivider() - Text(stringResource(R.string.setup_log_sessions), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, - color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) - Text(stringResource(R.string.setup_log_export_hint), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(start = 14.dp, end = 14.dp, bottom = 8.dp)) - val sessionLogs = remember(ctx, logsRefresh) { com.droiddeck.launcher.session.SessionLogShare.sessions(ctx).asReversed() } - if (sessionLogs.isEmpty()) { - Text(stringResource(R.string.setup_log_empty), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) - } - sessionLogs.forEach { folder -> - val active = folder == com.droiddeck.launcher.session.SessionPaths.current() - var details by remember(folder) { mutableStateOf(null) } - LaunchedEffect(folder, logsRefresh) { - details = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { - com.droiddeck.launcher.session.SessionLogShare.details(folder) - } + progress = com.droiddeck.launcher.session.SessionLogShare.progress, sideBySide = true) + ActionRow( + stringResource(R.string.setup_saved_logs), stringResource(R.string.dev_log_manage_hint), + stringResource(if (manageLogs) R.string.common_close else R.string.setup_manage), + onClick = { manageLogs = !manageLogs }, sideBySide = true, + ) + if (manageLogs) { + Text(stringResource(R.string.setup_log_sessions), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, + color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) + Text(stringResource(R.string.setup_log_export_hint), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(start = 14.dp, end = 14.dp, bottom = 8.dp)) + val sessionLogs = remember(ctx, logsRefresh) { com.droiddeck.launcher.session.SessionLogShare.sessions(ctx).asReversed() } + if (sessionLogs.isEmpty()) { + Text(stringResource(R.string.setup_log_empty), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) } - Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp)) { - Text(folder.name, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground, - maxLines = 1, overflow = TextOverflow.Ellipsis) - details?.let { detail -> - Text( - stringResource(R.string.setup_log_size_date, - android.text.format.Formatter.formatShortFileSize(ctx, detail.sizeBytes), - "${android.text.format.DateFormat.getDateFormat(ctx).format(java.util.Date(detail.modifiedAt))} ${android.text.format.DateFormat.getTimeFormat(ctx).format(java.util.Date(detail.modifiedAt))}"), - fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - ) + sessionLogs.forEach { folder -> + val active = folder == com.droiddeck.launcher.session.SessionPaths.current() + var details by remember(folder) { mutableStateOf(null) } + LaunchedEffect(folder, logsRefresh) { + details = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { + com.droiddeck.launcher.session.SessionLogShare.details(folder) + } } - if (active) Text(stringResource(R.string.setup_log_current), fontSize = 12.sp, color = MaterialTheme.colorScheme.primary) - Row(Modifier.fillMaxWidth().padding(top = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - SecondaryButton(stringResource(R.string.setup_log_share), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onShareSessionLog(folder) } - SecondaryButton(stringResource(R.string.setup_log_save), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onSaveSessionLog(folder) } - SecondaryButton(stringResource(R.string.setup_log_delete), compact = true, enabled = !active, modifier = Modifier.weight(1f)) { deleteSessionLogs = folder } + Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp)) { + Text(folder.name, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground, + maxLines = 1, overflow = TextOverflow.Ellipsis) + details?.let { detail -> + Text( + stringResource(R.string.setup_log_size_date, + android.text.format.Formatter.formatShortFileSize(ctx, detail.sizeBytes), + "${android.text.format.DateFormat.getDateFormat(ctx).format(java.util.Date(detail.modifiedAt))} ${android.text.format.DateFormat.getTimeFormat(ctx).format(java.util.Date(detail.modifiedAt))}"), + fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + if (active) Text(stringResource(R.string.setup_log_current), fontSize = 12.sp, color = MaterialTheme.colorScheme.primary) + Row(Modifier.fillMaxWidth().padding(top = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { + SecondaryButton(stringResource(R.string.setup_log_share), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onShareSessionLog(folder) } + SecondaryButton(stringResource(R.string.setup_log_save), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onSaveSessionLog(folder) } + SecondaryButton(stringResource(R.string.setup_log_delete), compact = true, enabled = !active, modifier = Modifier.weight(1f)) { deleteSessionLogs = folder } + } } + androidx.compose.material3.HorizontalDivider() } - androidx.compose.material3.HorizontalDivider() + ActionRow(stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), + null, stringResource(R.string.setup_clear_logs), + onClick = { a.onClearLogs { logsRefresh++ } }, sideBySide = true) } - ActionRow(stringResource(R.string.setup_saved_logs), stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), stringResource(R.string.setup_clear_logs), a.onClearLogs) + } + SettingsGroup(stringResource(R.string.dev_group_reset)) { ActionRow(stringResource(R.string.setup_reset_settings), stringResource(R.string.setup_reset_settings_hint), - stringResource(R.string.setup_reset_settings_button), a.onResetSettings) + stringResource(R.string.setup_reset_settings_button), a.onResetSettings, sideBySide = true) } } GLASSES_TAB -> GlassesSetupPanel() @@ -713,11 +836,11 @@ internal fun SetupPanel( @Composable private fun MemoryGroup(s: FrontEndState, a: FrontEndActions, host: MenuHost, onPairWirelessDebugging: () -> Unit) { - SettingsGroup(stringResource(R.string.setup_group_background_apps)) { + SettingsGroup(stringResource(R.string.setup_group_memory)) { ToggleRow( host, "clear-cached-apps", stringResource(R.string.setup_clear_cached), stringResource(if (s.adbPaired) R.string.setup_clear_cached_hint else R.string.setup_clear_cached_unpaired), - s.clearCachedApps, enabled = s.adbPaired || s.clearCachedApps, + s.clearCachedApps, enabled = s.adbPaired || s.clearCachedApps, sideBySide = true, ) { a.onClearCachedApps(it) } ChoiceRow( host, "background-app-limit", stringResource(R.string.setup_bg_limit), @@ -729,7 +852,7 @@ private fun MemoryGroup(s: FrontEndState, a: FrontEndActions, host: MenuHost, on 0 to stringResource(R.string.setup_bg_limit_0), ), s.backgroundAppLimit, enabled = s.adbPaired || s.backgroundAppLimit != com.droiddeck.launcher.core.BackgroundAppLimit.OFF, - onPick = a.onBackgroundAppLimit, + onPick = a.onBackgroundAppLimit, sideBySide = true, ) ChoiceRow( host, "memory-hud", stringResource(R.string.setup_memory_hud), stringResource(R.string.setup_memory_hud_hint), @@ -738,7 +861,7 @@ private fun MemoryGroup(s: FrontEndState, a: FrontEndActions, host: MenuHost, on com.droiddeck.launcher.session.SessionPrefs.MEMORY_HUD_SIMPLE to stringResource(R.string.setup_memory_hud_simple), com.droiddeck.launcher.session.SessionPrefs.MEMORY_HUD_ADVANCED to stringResource(R.string.setup_memory_hud_advanced), ), - s.memoryHud, onPick = a.onMemoryHud, + s.memoryHud, onPick = a.onMemoryHud, sideBySide = true, ) if (!s.adbPaired) ActionRow( stringResource(R.string.setup_adb_pair), stringResource(R.string.setup_adb_pair_hint), @@ -787,7 +910,7 @@ internal fun ReadinessCard( @Composable private fun FrameGenMenu(s: FrontEndState, a: FrontEndActions, host: MenuHost) { - FrameGenMenu(host, s.frameGen, s.lossless, a.onFrameGenPick, a.onImportLossless) + FrameGenMenu(s.frameGen, s.lossless, a.onFrameGenPick, legacyButtons = true) } @Composable @@ -808,12 +931,80 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost com.droiddeck.launcher.gpu.FrameGen.hasGameOverride(context, it) } ?: false) } + val scalingFilterChoices = SessionPrefs.upscalerChoices(context) + var gameUpscaler by remember(frameGenProfileKey) { + mutableStateOf(frameGenProfileKey?.let { + SessionPrefs.screenEffectsUpscaler(context, "game:$it") + } ?: SessionPrefs.upscaler(context)) + } + var gameUpscalerOverride by remember(frameGenProfileKey) { + mutableStateOf(frameGenProfileKey?.let { SessionPrefs.hasGameUpscalerOverride(context, it) } ?: false) + } + val lifecycleOwner = LocalLifecycleOwner.current + DisposableEffect(lifecycleOwner, frameGenProfileKey) { + val observer = LifecycleEventObserver { _, event -> + if (event == Lifecycle.Event.ON_RESUME) { + frameGenProfileKey?.let { key -> + gameUpscaler = SessionPrefs.screenEffectsUpscaler(context, "game:$key") + gameUpscalerOverride = SessionPrefs.hasGameUpscalerOverride(context, key) + } + } + } + lifecycleOwner.lifecycle.addObserver(observer) + onDispose { lifecycleOwner.lifecycle.removeObserver(observer) } + } var wincompOpen by remember(wincompKey) { mutableStateOf(null) } val wincompPicks = remember(wincompKey, wincompOpen) { wincompKey?.let { com.droiddeck.launcher.session.WinComponents.picks(context, it) }.orEmpty() } val steamScope = game?.let { com.droiddeck.launcher.session.NoSteamLaunch.scope(it) } val steamCard: (@Composable (Modifier) -> Unit)? = if (game != null && steamScope != null) { m -> Box(m) { GameSettingsCard(host, game, steamScope) } } else null + val frameGenMenuContent: @Composable () -> Unit = { + FrameGenMenu( + mode = if (frameGenProfileKey != null) gameFrameGenMode else s.frameGen, + lossless = s.lossless, + onPick = { mode -> + val key = frameGenProfileKey + if (key == null) { + a.onFrameGenPick(mode) + } else { + com.droiddeck.launcher.gpu.FrameGen.setForGame(context, key, mode) + gameFrameGenMode = mode + gameFrameGenOverride = true + } + }, + legacyButtons = true, + gameProfileId = frameGenProfileKey, + hasGameOverride = gameFrameGenOverride, + onResetGame = { + val key = frameGenProfileKey + if (key != null) { + com.droiddeck.launcher.gpu.FrameGen.clearGame(context, key) + gameFrameGenMode = com.droiddeck.launcher.gpu.FrameGen.mode(context) + gameFrameGenOverride = false + } + }, + ) + } + val scalingFilterMenuContent: @Composable () -> Unit = { + val key = frameGenProfileKey + if (key != null) ScalingFilterMenu( + mode = gameUpscaler, + options = scalingFilterChoices, + hasGameOverride = gameUpscalerOverride, + onPick = { mode -> + SessionPrefs.setGameUpscaler(context, key, mode) + gameUpscaler = SessionPrefs.screenEffectsUpscaler(context, "game:$key") + gameUpscalerOverride = SessionPrefs.hasGameUpscalerOverride(context, key) + }, + onResetGame = { + SessionPrefs.clearGameUpscaler(context, key) + gameUpscaler = SessionPrefs.upscaler(context) + gameUpscalerOverride = false + }, + gameName = game?.name, + ) + } val cards = if (game?.library == com.droiddeck.launcher.frontend.Library.EPIC_LAUNCHER) listOfNotNull(steamCard) else buildList<@Composable (Modifier) -> Unit> { add { m -> val back = stringResource(R.string.hop_from_games) @@ -835,33 +1026,18 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost ) { host.open = if (host.open == "fg") null else "fg" } - FrameGenMenu( - host = host, - mode = if (frameGenProfileKey != null) gameFrameGenMode else s.frameGen, - lossless = s.lossless, - onPick = { mode -> - val key = frameGenProfileKey - if (key == null) { - a.onFrameGenPick(mode) - } else { - com.droiddeck.launcher.gpu.FrameGen.setForGame(context, key, mode) - gameFrameGenMode = mode - gameFrameGenOverride = true - } - }, - onImportLossless = a.onImportLossless, - gameProfileId = frameGenProfileKey, - hasGameOverride = gameFrameGenOverride, - onResetGame = { - val key = frameGenProfileKey - if (key != null) { - com.droiddeck.launcher.gpu.FrameGen.clearGame(context, key) - gameFrameGenMode = - com.droiddeck.launcher.gpu.FrameGen.mode(context) - gameFrameGenOverride = false - } - } - ) + + } + } + if (frameGenProfileKey != null) add { m -> + Box(m) { + SettingCard( + stringResource(R.string.display_filter), + scalingFilterChoices.firstOrNull { it.first == gameUpscaler }?.second ?: scalingFilterChoices.first().second, + "card:scaling-filter", Modifier.fillMaxSize(), + ) { + host.open = if (host.open == "scaling-filter") null else "scaling-filter" + } } } if (controller != null) add { m -> SettingCard(stringResource(R.string.setup_card_controls), stringResource(R.string.setup_card_controls_hint), "card:controls", m, controller.onMapping) } @@ -893,6 +1069,16 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost repeat(columns - row.size) { Spacer(Modifier.weight(1f)) } } } + if (host.open == "fg") { + Box(Modifier.fillMaxWidth().padding(top = 4.dp)) { + frameGenMenuContent() + } + } + if (host.open == "scaling-filter") { + Box(Modifier.fillMaxWidth().padding(top = 4.dp)) { + scalingFilterMenuContent() + } + } } } @@ -1254,6 +1440,7 @@ private fun CustomColorRows() { Triple("signal", stringResource(R.string.theme_custom_signal), colors.signal), Triple("good", stringResource(R.string.theme_custom_good), colors.good), Triple("error", stringResource(R.string.theme_custom_error), colors.error), + Triple("warning", stringResource(R.string.theme_custom_warning), colors.warning), ) rows.forEach { (key, label, argb) -> diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt index 4245236747..adfa9eebcd 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndWidgets.kt @@ -308,7 +308,8 @@ internal fun SecondaryButton(text: String, enabled: Boolean = true, compact: Boo Box( contentAlignment = Alignment.Center, modifier = modifier.paneItem("btn:$text").downToFirstTile().heightIn(min = if (pill) 40.dp else if (compact) 44.dp else 48.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(shape).background(fill).glideBorder(hot, shape, pal.signal, if (pill) Color.White.copy(alpha = 0.14f) else pal.line2) - .alpha(if (enabled) 1f else 0.5f) + // The label always gets a layer of its own: sharing one with the fill and outline, they did not draw under the agent's latest reply. + .graphicsLayer { alpha = if (enabled) 1f else 0.5f } .hoverable(src).clickable(role = androidx.compose.ui.semantics.Role.Button, interactionSource = src, indication = LocalIndication.current, enabled = enabled, onClick = onClick) .controllerConfirm(enabled = enabled, onClick = onClick) .padding(horizontal = if (pill) 16.dp else if (compact) 10.dp else 16.dp, vertical = if (pill) 8.dp else if (compact) 7.dp else 11.dp), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt b/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt index bb4cc867cf..5415293cfb 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GameDetail.kt @@ -56,6 +56,7 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.SideEffect import androidx.compose.runtime.key +import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.produceState import androidx.compose.runtime.remember @@ -95,6 +96,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import coil.compose.AsyncImage import com.droiddeck.launcher.R +import com.droiddeck.launcher.frontend.AddedGameEdits import com.droiddeck.launcher.frontend.GameRemoval import com.droiddeck.launcher.frontend.Library import com.droiddeck.launcher.runtime.CurseForgeApp @@ -103,6 +105,7 @@ import com.droiddeck.launcher.runtime.WowAddonCatalog import com.droiddeck.launcher.runtime.WowAddons import com.droiddeck.launcher.store.UserAppsState import com.droiddeck.launcher.session.GameSaves +import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionState import com.droiddeck.launcher.stores.CatalogItem import com.droiddeck.launcher.stores.CloudSaves @@ -139,6 +142,7 @@ import androidx.compose.foundation.layout.offset internal class GameRef(val appId: Int?, val store: Store?, val storeId: String?) { fun game(games: List): Library.SteamGame? = when { appId != null -> games.firstOrNull { it.appId == appId } + store == Store.STEAM && storeId != null -> games.firstOrNull { Library.fromSteamClient(it) && it.appId.toString() == storeId } store != null && storeId != null -> games.firstOrNull { it.source == store.id && it.storeId == storeId } else -> null } @@ -182,7 +186,7 @@ internal fun GameDetail( if (nothing) return val source = game?.source ?: store?.id ?: Library.SOURCE_STEAM val title = game?.name ?: item?.title ?: installed?.sidecar?.title ?: id.orEmpty() - val favoriteKey = if (store != null && id != null) "${store.id}:$id" else game?.let { GameRef.key(it) } ?: key + val favoriteKey = if (store == Store.STEAM && id != null) "app:$id" else if (store != null && id != null) "${store.id}:$id" else game?.let { GameRef.key(it) } ?: key val scores = if (source != Library.ADDED) rememberGameScores(title.takeIf { it.isNotBlank() && it != id }) else null val achievements = remember(store, id, item?.accessible, installed) { when { @@ -224,10 +228,22 @@ internal fun GameDetail( val t = tab ?: return@LaunchedEffect if (!inPage) focusWithinFrames({ onStrip }) { tabFocus.getValue(t) } } + var steppedTo by remember(key) { mutableStateOf(null) } + LaunchedEffect(steppedTo, tab) { + val t = steppedTo ?: return@LaunchedEffect + if (t != tab) { + steppedTo = null + return@LaunchedEffect + } + holdFocus({ onStrip }) { tabFocus.getValue(t) } + steppedTo = null + } fun cycle(step: Int) { if (tabs.size < 2) return val at = tabs.indexOf(tab).coerceAtLeast(0) - picked = tabs[(at + step + tabs.size) % tabs.size] + val next = tabs[(at + step + tabs.size) % tabs.size] + picked = next + steppedTo = next } val art: Any? = game?.hero ?: item?.imageUrl ?: installed?.sidecar?.hero ?: installed?.sidecar?.cover val artModel: Any? = if (art is String) cardArtRequest(art, item?.tallImageUrl) else art @@ -380,7 +396,7 @@ private fun GameCapsule(scores: GameScores?, actions: @Composable () -> Unit) { } @Composable -private fun GameTabBar( +internal fun GameTabBar( tabs: List, selected: Int, onSelect: (Int) -> Unit, modifier: Modifier = Modifier, focusRequesters: List? = null, bumpers: Boolean = true, compact: Boolean = false, @@ -987,6 +1003,25 @@ private fun LaunchTab(game: Library.SteamGame, s: FrontEndState, a: FrontEndActi } val folder = game.gameFiles if (game.library == Library.ADDED && game.source == Library.ADDED && !s.shortcutPicker && folder != null) ShortcutFields(game, folder) + if (game.library == Library.ADDED && Store.byId(game.source) == Store.EA && folder != null) StoreLaunchOptions(folder, a) + } +} + +@Composable +private fun StoreLaunchOptions(folder: File, a: FrontEndActions) { + val app = LocalContext.current.applicationContext + val scope = rememberCoroutineScope() + var saved by remember(folder.path) { mutableStateOf(SessionPrefs.addedGameLaunch(app, folder.path)) } + var editing by remember(folder.path) { mutableStateOf(false) } + Column(Modifier.fillMaxWidth().tabPanel()) { + MenuItem(stringResource(R.string.edit_launch_options), checked = false, detail = saved.ifEmpty { "—" }) { editing = true } + } + if (editing) TextEntryDialog(stringResource(R.string.edit_launch_options), saved, onDismiss = { editing = false }) { value -> + scope.launch { + withContext(Dispatchers.IO) { AddedGameEdits.setLaunchOptions(app, folder.path, value) } + saved = value + a.onAddedGamesChanged(listOf(folder.path)) + } } } @@ -1068,8 +1103,36 @@ private fun AddonsTab(g: Library.SteamGame, targets: List, ses runCatching { CurseForgeApp.byFolder(link.installed(context, target, scanKey)) }.getOrDefault(emptyMap()) } } + val progress = remember(target.addOns) { mutableStateMapOf() } + val curseOf = { item: WowAddons.Installed -> link?.let { l -> managed[item.name.lowercase()]?.let { it to l } } } + val outdated = names.filter { item -> curseOf(item)?.first?.update ?: (updates[item.name] != null) } + val scope = rememberCoroutineScope() if (targets.size > 1) SectionLabel(target.flavor) MenuItem(stringResource(R.string.addons_download), checked = false) { browsing = target } + if (outdated.size > 1 && !SessionState.running) MenuItem( + stringResource(R.string.store_update_all, outdated.size), checked = false, enabled = progress.isEmpty(), + ) { + val plan = outdated.groupBy { item -> curseOf(item)?.first?.id?.let { "curse:$it" } ?: "folder:${item.name}" }.values.map { group -> + Triple(group.map { it.name }, updates[group.first().name], curseOf(group.first())) + } + plan.forEach { (folders) -> folders.forEach { progress[it] = 0 } } + val owned = plan.flatMap { it.first }.toMutableSet() + scope.launch { + try { + plan.forEach { (folders, wowi, curse) -> + val name = folders.first() + val (message, ok) = updateAddon(context, name, wowi.takeIf { curse == null }, target, curse) { pct -> + scope.launch { folders.forEach { progress[it] = pct } } + } + folders.forEach { progress.remove(it) } + owned.removeAll(folders.toSet()) + if (!ok && message != null) android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_LONG).show() + } + } finally { + owned.forEach { progress.remove(it) } + } + } + } MenuItem( stringResource(R.string.games_import_addons), checked = false, detail = pluralStringResource(R.plurals.games_addons_count, names.size, names.size), @@ -1078,7 +1141,7 @@ private fun AddonsTab(g: Library.SteamGame, targets: List, ses target.addOns.mkdirs() a.onBrowseFiles(target.addOns) } - names.forEach { item -> key(target.addOns, item.name) { AddonRow(item, updates[item.name], target, a, link?.let { l -> managed[item.name.lowercase()]?.let { it to l } }) } } + names.forEach { item -> key(target.addOns, item.name) { AddonRow(item, updates[item.name], target, a, progress, curseOf(item)) } } } } } @@ -1132,12 +1195,12 @@ private fun CurseForgeEntry(a: FrontEndActions) { } @Composable -internal fun AddonRow(item: WowAddons.Installed, wowiUpdate: WowAddonCatalog.Addon?, target: WowAddons.Target, a: FrontEndActions, curse: Pair? = null) { +internal fun AddonRow(item: WowAddons.Installed, wowiUpdate: WowAddonCatalog.Addon?, target: WowAddons.Target, a: FrontEndActions, progresses: MutableMap, curse: Pair? = null) { val name = item.name val update = wowiUpdate.takeIf { curse == null } val outdated = update != null || curse?.first?.update == true var asking by remember(target.addOns, name) { mutableStateOf(false) } - var progress by remember(target.addOns, name) { mutableStateOf(null) } + val progress = progresses[name] val context = LocalContext.current val scope = rememberCoroutineScope() val delete = stringResource(R.string.common_delete) @@ -1152,31 +1215,39 @@ internal fun AddonRow(item: WowAddons.Installed, wowiUpdate: WowAddonCatalog.Add ) } if (outdated && !SessionState.running) IconAction(Icons.Outlined.Download, stringResource(R.string.common_update), "addon:update:${target.flavor}:$name", enabled = progress == null) { - progress = 0 + progresses[name] = 0 scope.launch { - val message = withContext(Dispatchers.IO) { - if (curse != null) { - val (project, link) = curse - val done = runCatching { link.change(context, target) { CurseForgeApp.update(context, it.inspector, it.guid, project.id) } }.getOrDefault(false) - WowAddons.changed() - if (done) context.getString(R.string.user_apps_updated, name) else context.getString(R.string.stores_dl_failed_reason, name) - } else update?.let { installAddon(context, it, target) { pct -> scope.launch { progress = pct } }.first } + try { + val message = updateAddon(context, name, update, target, curse) { pct -> scope.launch { progresses[name] = pct } }.first + if (message != null) android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_LONG).show() + } finally { + progresses.remove(name) } - progress = null - if (message != null) android.widget.Toast.makeText(context, message, android.widget.Toast.LENGTH_LONG).show() } } - if (!SessionState.running) IconAction(Icons.Outlined.Delete, if (curse != null) stringResource(R.string.common_uninstall) else delete, "addon:delete:${target.flavor}:$name", danger = true) { asking = true } + if (!SessionState.running) IconAction(Icons.Outlined.Delete, if (curse != null) stringResource(R.string.common_uninstall) else delete, "addon:delete:${target.flavor}:$name", danger = true, enabled = progress == null) { asking = true } } if (asking) ConfirmDialog( title = if (curse != null) stringResource(R.string.stores_uninstall_title, name) else stringResource(R.string.games_delete_addon_title, name), text = stringResource(R.string.games_delete_addon_body), confirm = if (curse != null) stringResource(R.string.common_uninstall) else delete, - onConfirm = { a.onAddonDelete(target, name) }, + onConfirm = { asking = false; if (progresses[name] == null) a.onAddonDelete(target, name) }, onDismiss = { asking = false }, ) } +private suspend fun updateAddon( + context: android.content.Context, name: String, update: WowAddonCatalog.Addon?, target: WowAddons.Target, + curse: Pair?, onProgress: (Int) -> Unit, +): Pair = withContext(Dispatchers.IO) { + if (curse != null) { + val (project, link) = curse + val done = runCatching { link.change(context, target) { CurseForgeApp.update(context, it.inspector, it.guid, project.id) } }.getOrDefault(false) + WowAddons.changed() + (if (done) context.getString(R.string.user_apps_updated, name) else context.getString(R.string.stores_dl_failed_reason, name)) to done + } else update?.let { installAddon(context, it, target, onProgress).let { (message, version) -> message to (version != null) } } ?: (null to false) +} + @Composable private fun CloudRows(g: Library.SteamGame, onSynced: () -> Unit = {}) { val store = Store.byId(g.source)?.takeIf { it != Store.AMAZON } ?: return diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt index 877cad9240..ba44249ca9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GlassesPanel.kt @@ -23,6 +23,9 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.draw.clip @@ -31,6 +34,7 @@ import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.sp import androidx.compose.runtime.getValue +import com.droiddeck.launcher.session.SessionPrefs import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor @@ -67,6 +71,21 @@ internal val GlassesIcon: ImageVector by lazy { }.build() } +@Composable +internal fun rememberShowGlassesShortcut(): Boolean { + val context = LocalContext.current + var show by remember(context) { mutableStateOf(SessionPrefs.showGlassesShortcut(context)) } + DisposableEffect(context) { + val preferences = context.getSharedPreferences("session", android.content.Context.MODE_PRIVATE) + val listener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key -> + if (key == "showGlassesShortcut") show = SessionPrefs.showGlassesShortcut(context) + } + preferences.registerOnSharedPreferenceChangeListener(listener) + onDispose { preferences.unregisterOnSharedPreferenceChangeListener(listener) } + } + return show +} + @Composable internal fun rememberGlasses(): Pair { val g by Glasses.state.collectAsState() @@ -88,7 +107,7 @@ internal fun VrControllerGroups(host: MenuHost, track: (String) -> Modifier = { androidx.compose.runtime.LaunchedEffect(Unit) { com.droiddeck.launcher.input.VrControllers.load(context) } val c by com.droiddeck.launcher.input.VrControllers.settings.collectAsState() val emulate = com.droiddeck.launcher.input.VrControllers.Emulate.entries - SettingsGroup(stringResource(R.string.vr_controllers_group)) { + SettingsGroup(stringResource(R.string.vr_controllers_group), key = "vr-controllers") { ChoiceRow(host, "vr-emulate", stringResource(R.string.vr_controllers_emulate), stringResource(R.string.vr_controllers_emulate_hint), emulate.map { it to stringResource(when (it) { com.droiddeck.launcher.input.VrControllers.Emulate.OFF -> R.string.vr_controllers_off @@ -133,6 +152,7 @@ internal fun GlassesGroups( ) { val display = tab == null || tab == GlassesTab.DISPLAY val vr = tab == null || tab == GlassesTab.VR + val showShortcut = rememberShowGlassesShortcut() val picture = GlassesRendering.picture(s, g.sbs, steamVrRunning) val usesGlasses = GlassesRendering.usesGlasses(g, outputActive, steamVrRunning) val spatialTracking = g.spatialConnected && s.positionalTracking @@ -142,13 +162,13 @@ internal fun GlassesGroups( val directView = usesGlasses && picture == GlassesRendering.Picture.STEREO val menuScreen = !inSession && g.usable && s.gameOnGlasses && s.screen3dof if (g.canControl && onRecenter != null && s.headTracking && (virtualScreen || menuScreen || (directView && steamVrRunning))) { - SettingsGroup(stringResource(R.string.glasses_quick_actions), compact = true) { + SettingsGroup(stringResource(R.string.glasses_quick_actions), compact = true, key = "vr-glasses-quick") { ActionRow(stringResource(R.string.glasses_recenter), if (virtualScreen || menuScreen) stringResource(R.string.glasses_recenter_screen_hint) else null, stringResource(R.string.cardboard_recenter_button), onRecenter) } } - if (display) SettingsGroup(g.model) { + if (display) SettingsGroup(g.model, key = "vr-glasses") { if (g.experimental) SettingsRow(stringResource(R.string.glasses_control), stringResource( if (g.supportsDisplayModeControl) R.string.glasses_xreal_experimental else R.string.glasses_pro2_experimental)) {} val status = if (g.hasDisplay) stringResource(R.string.glasses_status, g.width, g.height, kotlin.math.round(g.hz).toInt(), @@ -168,9 +188,15 @@ internal fun GlassesGroups( } ToggleRow(host, "glasses-game", stringResource(R.string.glasses_game_on), stringResource(R.string.glasses_game_on_hint), s.gameOnGlasses, chipModifier = track("glasses-game")) { Glasses.setGameOnGlasses(it) } + if (inSession) { + val context = androidx.compose.ui.platform.LocalContext.current + ToggleRow(host, "glasses-shortcut", stringResource(R.string.glasses_show_shortcut), + stringResource(R.string.glasses_show_shortcut_hint), showShortcut, + chipModifier = track("glasses-shortcut")) { SessionPrefs.setShowGlassesShortcut(context, it) } + } } if (display && g.canControl && g.supportsDisplayModeControl && (inSession || g.sbs || g.sbsSupport == GlassesState.SBS_FAILS)) { - SettingsGroup(stringResource(R.string.glasses_display_mode)) { + SettingsGroup(stringResource(R.string.glasses_display_mode), key = "vr-glasses-mode") { if (g.sbsSupport == GlassesState.SBS_FAILS && !g.sbs) { ActionRow(stringResource(R.string.glasses_3d), stringResource(R.string.glasses_3d_failed), stringResource(R.string.stores_dl_retry), { Glasses.set3d(true) }) @@ -182,12 +208,12 @@ internal fun GlassesGroups( val profiles = if (inSession) listOf(GlassesDisplayModes.profile(g.sbs, false)) else listOf(GlassesDisplayProfile.TWO_D, GlassesDisplayProfile.THREE_D) for (profile in profiles) SettingsGroup(stringResource(if (profile == GlassesDisplayProfile.TWO_D) - R.string.glasses_output_2d else R.string.glasses_output_3d)) { + R.string.glasses_output_2d else R.string.glasses_output_3d), key = "vr-glasses-output-${profile.name.lowercase()}") { GlassesResolutionRow(host, g, s, profile, track) if ((profile == GlassesDisplayProfile.THREE_D) == g.sbs) GlassesRefreshRow(host, g, s, track) } } - if (display && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.glasses_picture_group)) { + if (display && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.glasses_picture_group), key = "vr-glasses-picture") { ChoiceRow(host, "glasses-picture", stringResource(R.string.glasses_picture), stringResource(R.string.glasses_picture_hint), listOf( GlassesSettings.PICTURE_AUTO to stringResource(R.string.glasses_picture_auto), @@ -213,7 +239,7 @@ internal fun GlassesGroups( format = { SpatialMeasurements.distance(it / 10f) }, modifier = track("glasses-distance")) { Glasses.setScreenDistanceDm(it) } } } - if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr)) { + if (vr && (g.canControl || g.hasDisplay)) SettingsGroup(stringResource(R.string.cardboard_steamvr), key = "vr-glasses-steamvr") { steamVr() if (g.supportsDisplayModeControl) ToggleRow(host, "glasses-auto3d", stringResource(R.string.glasses_auto3d), stringResource(R.string.glasses_auto3d_hint), s.auto3d, chipModifier = track("glasses-auto3d")) { Glasses.setAuto3d(it) } @@ -226,7 +252,7 @@ internal fun GlassesGroups( format = { "$it°" }, modifier = track("glasses-vr-fov")) { Glasses.setVrFovDeg(it) } } if ((tab == null || tab == GlassesTab.TRACKING) && g.canControl) { - SettingsGroup(stringResource(R.string.glasses_head_tracking)) { + SettingsGroup(stringResource(R.string.glasses_head_tracking), key = "vr-glasses-tracking") { val trackingHint = when { inSession && !usesGlasses -> R.string.glasses_screen_no_output spatialVr -> R.string.glasses_head_tracking_spatial_vr_hint @@ -240,13 +266,13 @@ internal fun GlassesGroups( chipModifier = track("glasses-tracking")) { Glasses.setHeadTracking(it) } } val calibration by Glasses.calibration.collectAsState() - if (calibration.supported) SettingsGroup(stringResource(R.string.glasses_calibration)) { + if (calibration.supported) SettingsGroup(stringResource(R.string.glasses_calibration), key = "vr-glasses-calibration") { GlassesCalibrationControls(calibration, onStart = Glasses::startCalibration, onCancel = Glasses::cancelCalibration, onReset = Glasses::resetCalibration, onDone = { onRecenter?.invoke() }) } } - if ((tab == null || tab == GlassesTab.HARDWARE) && g.canControl && g.hardwareControls) SettingsGroup(stringResource(R.string.glasses_hardware)) { + if ((tab == null || tab == GlassesTab.HARDWARE) && g.canControl && g.hardwareControls) SettingsGroup(stringResource(R.string.glasses_hardware), key = "vr-glasses-hardware") { if (g.brightnessMax > 0) SliderRow(stringResource(R.string.glasses_brightness), null, g.brightness.coerceAtLeast(0), 0..g.brightnessMax, step = 1, modifier = track("glasses-brightness")) { Glasses.setBrightness(it) } if (g.volumeMax > 0) SliderRow(stringResource(R.string.glasses_volume), null, g.volume.coerceAtLeast(0), 0..g.volumeMax, step = 1, @@ -259,7 +285,7 @@ internal fun GlassesGroups( androidx.compose.runtime.LaunchedEffect(Unit) { HandTracking.load(context) } if ((tab == null || tab == GlassesTab.TRACKING) && g.canControl) { if (g.spatialConnected) { - SettingsGroup(stringResource(R.string.glasses_experimental)) { + SettingsGroup(stringResource(R.string.glasses_experimental), key = "vr-glasses-experimental") { val spatial by SpatialTracking.status.collectAsState() ToggleRow(host, "glasses-position", stringResource(R.string.glasses_position), stringResource(R.string.glasses_position_hint), s.positionalTracking, chipModifier = track("glasses-position")) { Glasses.setPositionalTracking(it) } @@ -282,7 +308,7 @@ internal fun GlassesGroups( s.joyConTracking, enabled = s.positionalTracking, chipModifier = track("glasses-joycons")) { Glasses.setJoyConTracking(it) } } } - if (hands.usable) SettingsGroup(stringResource(R.string.phone_camera_tracking_group)) { + if (hands.usable) SettingsGroup(stringResource(R.string.phone_camera_tracking_group), key = "vr-hand-camera") { HandCameraRows(host, track, inSession) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GlassesSetupPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/GlassesSetupPanel.kt index 8b2378ae4d..ced0d6b579 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GlassesSetupPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GlassesSetupPanel.kt @@ -21,12 +21,20 @@ internal fun GlassesSetupPanel() { val (glasses, settings) = rememberGlasses() val host = rememberMenuHost() val tabs = glassesTabs(glasses) + val context = androidx.compose.ui.platform.LocalContext.current + val showShortcut = rememberShowGlassesShortcut() var selectedTab by rememberSaveable { mutableStateOf(GlassesTab.DISPLAY) } val tab = selectedTab.takeIf { selected -> tabs.any { it.first == selected } } ?: GlassesTab.DISPLAY LaunchedEffect(tab, glasses.present, glasses.canControl, glasses.model) { host.open = null } Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(12.dp)) { Note(stringResource(R.string.setup_glasses_scope)) + SettingsGroup(stringResource(R.string.glasses_shortcut_group), key = "glasses-shortcut") { + ToggleRow(host, "glasses-shortcut", stringResource(R.string.glasses_show_shortcut), + stringResource(R.string.glasses_show_shortcut_hint), showShortcut) { + com.droiddeck.launcher.session.SessionPrefs.setShowGlassesShortcut(context, it) + } + } if (!glasses.present && !glasses.hasDisplay && !glasses.canControl) { Note(stringResource(R.string.setup_glasses_connect)) } else { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/GlideWindows.kt b/app/src/main/java/com/droiddeck/launcher/ui/GlideWindows.kt index c13bebef13..7000bb936f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/GlideWindows.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/GlideWindows.kt @@ -76,7 +76,7 @@ internal fun WindowDialog( content: @Composable () -> Unit, ) { if (!LocalPresentationWindow.current) { - Dialog(onDismissRequest, properties, content) + Dialog(onDismissRequest, properties) { SolidSurfaces(content) } return } Popup( @@ -87,7 +87,7 @@ internal fun WindowDialog( Modifier.fillMaxSize().background(androidx.compose.ui.graphics.Color.Black.copy(alpha = 0.6f)) .tapOutside { if (properties.dismissOnClickOutside) onDismissRequest() }, contentAlignment = Alignment.Center, - ) { content() } + ) { SolidSurfaces(content) } } } @@ -150,7 +150,7 @@ internal fun GlidePopup( ) { Popup(popupPositionProvider, onDismissRequest, properties) { if (properties.focusable) TrackKeyWindow() - FocusGlideHost(content = content) + SolidSurfaces { FocusGlideHost(content = content) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt index a8eb95b347..23302a090c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/InputBindingWidgets.kt @@ -33,6 +33,8 @@ internal fun commandLabel(command: InputCommand) = stringResource(when (command) InputCommand.KEYBOARD -> R.string.input_command_keyboard InputCommand.STEAM -> R.string.input_command_steam InputCommand.QUICK_ACCESS -> R.string.input_command_qam + InputCommand.GAME_ZOOM_IN -> R.string.input_command_zoom_in + InputCommand.GAME_ZOOM_OUT -> R.string.input_command_zoom_out }) @Composable diff --git a/app/src/main/java/com/droiddeck/launcher/ui/InputElementProperties.kt b/app/src/main/java/com/droiddeck/launcher/ui/InputElementProperties.kt index 406e6f7f5f..7d55ab8132 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/InputElementProperties.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/InputElementProperties.kt @@ -67,8 +67,18 @@ internal fun InputElementProperties(element: InputSurfaceElement, action: InputA } if (element.kind == InputElementKind.STICK) { val host = rememberMenuHost() - ToggleRow(host, "element-floating", stringResource(R.string.input_floating_stick), null, element.floating) { onChange(element.copy(floating = it)) } - ToggleRow(host, "element-hide-idle", stringResource(R.string.input_hide_idle), null, element.hideWhenIdle) { onChange(element.copy(hideWhenIdle = it)) } + val adaptive = element.adaptiveCapture ?: element.adaptiveStick + ToggleRow(host, "element-floating", stringResource(R.string.input_floating_stick), null, element.floating) { + onChange(element.copy(floating = it, hideWhenIdle = element.hideStickAtRest, adaptiveCapture = adaptive)) + } + if (element.floating) { + ToggleRow(host, "element-adaptive-capture", stringResource(R.string.input_adaptive_capture), null, element.adaptiveStick) { + onChange(element.copy(hideWhenIdle = element.hideStickAtRest, adaptiveCapture = it)) + } + } + ToggleRow(host, "element-hide-idle", stringResource(R.string.input_hide_idle), null, element.hideStickAtRest) { + onChange(element.copy(hideWhenIdle = it, adaptiveCapture = adaptive)) + } } val host = rememberMenuHost() if ((element.kind == InputElementKind.BUTTON || element.kind == InputElementKind.TRIGGER) && element.icon == 0 && element.image.isEmpty() || diff --git a/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt index 2fe1346034..1274945a3b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/InputSettingsPage.kt @@ -174,14 +174,15 @@ private fun InputSettingsContent(onBack: () -> Unit, onChanged: () -> Unit, embe detail = if (library.usersOfBindings(b.id).size > 1) stringResource(R.string.input_shared_detail, b.name, library.usersOfBindings(b.id).size) else "${profile.name} · ${roleLabel(role)}", onSave = { action -> if (update { l -> + val currentPreset = l.preset(editing.preset) val geometry = if (!editing.click && elementProperties != null && layout != null) l.withLayout(layout.copy(elements = layout.elements.map { if (it.id == elementProperties!!.id) elementProperties!!.copy(name = elementProperties!!.name.trim().ifBlank { it.name }) else it })) else l geometry.withPreset(when { - editing.element != null && editing.click -> b.copy(clicks = b.clicks + (editing.element.id to action)) - editing.element != null -> b.copy(elements = b.elements + (editing.element.id to action)) - editing.key != null -> b.copy(keys = b.keys.filterNot { it.key == editing.key } + PhysicalInputBinding(editing.key, action)) - else -> b.copy(controls = b.controls + (editing.control to action)) + editing.element != null && editing.click -> currentPreset.copy(clicks = currentPreset.clicks + (editing.element.id to action)) + editing.element != null -> currentPreset.copy(elements = currentPreset.elements + (editing.element.id to action)) + editing.key != null -> currentPreset.copy(keys = currentPreset.keys.filterNot { it.key == editing.key } + PhysicalInputBinding(editing.key, action)) + else -> currentPreset.copy(controls = currentPreset.controls + (editing.control to action)) }) }) edit = null }) } else if (!surface) key(page, profileId, role) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/InputSurfaceView.kt b/app/src/main/java/com/droiddeck/launcher/ui/InputSurfaceView.kt index f06c43851c..5e4b854d07 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/InputSurfaceView.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/InputSurfaceView.kt @@ -44,6 +44,7 @@ import com.droiddeck.launcher.session.SessionPrefs import kotlin.math.abs import kotlin.math.atan2 import kotlin.math.hypot +import kotlin.math.max import kotlin.math.min @SuppressLint("ViewConstructor") @@ -63,6 +64,7 @@ class InputSurfaceView( private val art by lazy(LazyThreadSafetyMode.NONE) { PadArt(context) } private var artworkDpad = emptyList() private val artworkDpadBounds = RectF() + private var crossDpads = emptyList, RectF>>() private var requestedLayout = customLayout init { customLayout = surfaceStyle.shown(customLayout); addView(content, LayoutParams(-1, -1)); renderCustom(pad) } @@ -135,7 +137,7 @@ class InputSurfaceView( val views = owners.values.distinct() owners.clear() for (view in views) { - if (view is HoldButton) { view.cancel(); continue } + if (view is HoldButton) { view.cancelTouches(); continue } val cancel = MotionEvent.obtain(event.downTime, event.eventTime, MotionEvent.ACTION_CANCEL, 0f, 0f, 0) try { view.dispatchTouchEvent(cancel) } finally { cancel.recycle() } } @@ -174,10 +176,23 @@ class InputSurfaceView( val now = android.os.SystemClock.uptimeMillis() val cancel = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0f, 0f, 0) try { cancelOwners(cancel) } finally { cancel.recycle() } + customCanvas?.let { canvas -> for (i in 0 until canvas.childCount) (canvas.getChildAt(i) as? HoldButton)?.cancel() } forwardedPointers = 0 elementSources.forEach { it.release() } } + /** Presses a button as a finger would, for input from outside the screen; [holder] tells holds apart. */ + fun hold(elementId: String, holder: Int, held: Boolean, cancelled: Boolean = false): Boolean { + val canvas = customCanvas ?: return false + for (i in 0 until canvas.childCount) { + val button = canvas.getChildAt(i) as? HoldButton ?: continue + if ((button.tag as? InputSurfaceElement)?.id != elementId) continue + button.press(-1 - holder, held, cancelled) + return true + } + return false + } + override fun onVisibilityChanged(changedView: View, visibility: Int) { super.onVisibilityChanged(changedView, visibility) if (visibility != VISIBLE) releaseInputs() @@ -185,6 +200,7 @@ class InputSurfaceView( private fun renderCustom(pad: PadBridge?) { artworkDpad = emptyList() + crossDpads = emptyList() val canvas = object : ViewGroup(context) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { val layout = customLayout @@ -203,6 +219,7 @@ class InputSurfaceView( child.layout(x, y, x + child.measuredWidth, y + child.measuredHeight) } updateArtworkDpad(this) + updateCrossDpad(this) } override fun dispatchDraw(canvas: Canvas) { @@ -219,11 +236,11 @@ class InputSurfaceView( super.dispatchDraw(canvas) } } - canvas.clipChildren = customLayout.none { it.kind == InputElementKind.STICK && (classic(it) || adaptive(it)) } + canvas.clipChildren = customLayout.none { it.kind == InputElementKind.STICK && (classic(it) || it.adaptiveStick) } for (element in customLayout) { val source = pad?.let { InputSurfaceSource(it, inputRole, element).also { s -> elementSources += s } } canvas.addView(when (element.kind) { - InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideWhenIdle && pad != null) + InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideStickAtRest && pad != null) InputElementKind.TRACKPAD -> TrackpadView(context, element.control == InputControl.RIGHT_PAD, captioned = element.showLabel, stock = element.id == "legacy:${element.control.id}", source = source) InputElementKind.DPAD -> DirectionPad(context, element, source) @@ -244,11 +261,39 @@ class InputSurfaceView( canvas.getChildAt(index) as? HoldButton } val previous = artworkDpad - artworkDpad = if (crossed(buttons)) buttons else emptyList() + artworkDpad = if (crossed(buttons, artworkDpadBounds)) buttons else emptyList() if (artworkDpad != previous) (previous + artworkDpad).forEach { it.invalidate() } } - private fun crossed(buttons: List): Boolean { + private fun updateCrossDpad(canvas: ViewGroup) { + val buttons = (0 until canvas.childCount).map(canvas::getChildAt).filterIsInstance() + val (ups, rights, downs, lefts) = DIRECTIONS.map { direction -> buttons.filter { (it.tag as? InputSurfaceElement)?.control == direction } } + crossDpads = ups.flatMap { up -> rights.flatMap { right -> downs.flatMap { down -> + lefts.mapNotNull { left -> listOf(up, right, down, left).let { arms -> hole(arms)?.let { arms to it } } } } } } + } + + private fun hole(buttons: List): RectF? { + val (up, right, down, left) = buttons + val hole = RectF(left.right.toFloat(), up.bottom.toFloat(), right.left.toFloat(), down.top.toFloat()) + val across = max(up.left, down.left) to min(up.right, down.right) + val along = max(left.top, right.top) to min(left.bottom, right.bottom) + return hole.takeIf { + !it.isEmpty && across.first < across.second && along.first < along.second && + across.first < it.right && across.second > it.left && along.first < it.bottom && along.second > it.top + } + } + + private fun crossTarget(x: Float, y: Float): HoldButton? { + val first = crossDpads.firstOrNull()?.first?.first() ?: return null + val hx = x - (originX(first) - first.left) + val hy = y - (originY(first) - first.top) + return crossDpads.filter { (arms, hole) -> arms.all { it.visibility == VISIBLE } && hole.contains(hx, hy) } + .flatMap { it.first }.distinct().minByOrNull { arm -> + hypot(max(max(arm.left - hx, hx - arm.right), 0f), max(max(arm.top - hy, hy - arm.bottom), 0f)) + } + } + + private fun crossed(buttons: List, bounds: RectF): Boolean { if (buttons.size != DIRECTIONS.size) return false val (up, right, down, left) = buttons val centerX = (left.left + right.right) / 2f @@ -258,7 +303,7 @@ class InputSurfaceView( kotlin.math.abs((left.top + left.bottom) / 2f - centerY) > 2f || kotlin.math.abs((right.top + right.bottom) / 2f - centerY) > 2f || up.bottom >= down.top || left.right >= right.left) return false - artworkDpadBounds.set(left.left.toFloat(), up.top.toFloat(), right.right.toFloat(), down.bottom.toFloat()) + bounds.set(left.left.toFloat(), up.top.toFloat(), right.right.toFloat(), down.bottom.toFloat()) return true } @@ -284,6 +329,7 @@ class InputSurfaceView( val views = (canvas.childCount - 1 downTo 0).map(canvas::getChildAt).filter { it.visibility == VISIBLE } views.firstOrNull { !(it is StickView && it.adaptive) && hits(it, x, y, 0f) }?.let { return it } views.filter { it is HoldButton && hits(it, x, y, slack(it)) }.minByOrNull { distance(it, x, y) }?.let { return it } + crossTarget(x, y)?.let { return it } if (views.any { it is HoldButton && hits(it, x, y, slack(it) + ADAPTIVE_CLEARANCE_PX) }) return null return views.filter { it is StickView && it.adaptive && it !in owners.values && (hits(it, x, y, 0f) || it.captures(x - originX(it), y - originY(it))) } .minByOrNull { distance(it, x, y) } @@ -449,17 +495,22 @@ class InputSurfaceView( fun press(pointer: Int, pressed: Boolean, cancelled: Boolean = false) { if (pressed) pointers.add(pointer) else pointers.remove(pointer) - set(pointers.isNotEmpty(), cancelled) + set(pointers.isNotEmpty(), cancelled, touch = pointer >= 0) } fun cancel() { pointers.clear(); set(false, cancelled = true); source?.release() } + fun cancelTouches() { + pointers.removeAll { it >= 0 } + if (pointers.isEmpty()) cancel() + } + override fun onDetachedFromWindow() { cancel(); super.onDetachedFromWindow() } - private fun set(pressed: Boolean, cancelled: Boolean = false) { + private fun set(pressed: Boolean, cancelled: Boolean = false, touch: Boolean = true) { if (down == pressed) return down = pressed - if (pressed) feedback(this, HapticFeedbackConstants.VIRTUAL_KEY) + if (pressed && touch) feedback(this, HapticFeedbackConstants.VIRTUAL_KEY) if (!pressed && cancelled) source?.cancel() else source?.update(if (pressed) 1f else 0f) invalidate() if (artwork != null && this in artworkDpad) customCanvas?.invalidate() @@ -590,7 +641,7 @@ class InputSurfaceView( private val ring = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.STROKE } private val knob = Paint(Paint.ANTI_ALIAS_FLAG) - val adaptive get() = adaptive(element) + val adaptive get() = element.adaptiveStick fun reach() = min(width, height) * if (classic(element)) CLASSIC_REACH else PANEL_REACH @@ -808,8 +859,6 @@ class InputSurfaceView( private val TEXT_DIM = Color.rgb(0x7A, 0x80, 0x8A) private val KNOB = Color.rgb(0x2A, 0x2D, 0x33) - private fun adaptive(element: InputSurfaceElement) = element.kind == InputElementKind.STICK && element.floating && element.hideWhenIdle - private fun classic(element: InputSurfaceElement) = (element.id == "legacy:${element.control.id}" || element.id == "builtin:keyboard") && (element.buttonShape == InputButtonShape.CIRCLE || element.buttonShape == InputButtonShape.PILL) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LabBuilds.kt b/app/src/main/java/com/droiddeck/launcher/ui/LabBuilds.kt index 8bfc59306b..c813b4fa1c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LabBuilds.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LabBuilds.kt @@ -3,6 +3,9 @@ package com.droiddeck.launcher.ui import android.text.format.DateUtils import androidx.compose.foundation.background import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.hoverable +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -26,8 +29,11 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp @@ -41,7 +47,7 @@ import com.droiddeck.launcher.lab.LabOverlay * [onRebuild] offers to build a kept one again for this install, when something can. */ @Composable -internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay.Info) -> Unit)? = null) { +internal fun LabBuilds(sessionRunning: Boolean = false, header: (@Composable () -> Unit)? = null, onRebuild: ((LabOverlay.Info) -> Unit)? = null) { val context = LocalContext.current var version by remember { mutableIntStateOf(0) } var busy by remember { mutableStateOf(false) } @@ -54,6 +60,7 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay. val paused = active == null && current != null && LabOverlay.skipped == LabOverlay.SKIPPED_APP_IMAGE val restartFailed = stringResource(R.string.lab_restart_failed) val canRestart = !busy && !sessionRunning + var showKept by androidx.compose.runtime.saveable.rememberSaveable { mutableStateOf(false) } /** Android may have given the APK an app image again, which a Lab build cannot load over. */ fun restart() { @@ -73,8 +80,8 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay. val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - Column(Modifier.fillMaxWidth().padding(top = 18.dp)) { - Text( + Column(Modifier.fillMaxWidth().padding(top = if (header == null) 18.dp else 0.dp)) { + if (header != null) header() else Text( stringResource(R.string.lab_builds).uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 10.dp), ) @@ -99,7 +106,29 @@ internal fun LabBuilds(sessionRunning: Boolean = false, onRebuild: ((LabOverlay. PrimaryButton(stringResource(R.string.lab_restart), compact = true, enabled = canRestart) { restart() } } } - for (build in saved) rows += { + val foldKept = (current != null || pending != null) && saved.isNotEmpty() + if (foldKept) rows += { + val src = remember { MutableInteractionSource() } + val toggle = { showKept = !showKept } + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth().paneItem("lab:kept") + .background(if (rememberHot(src)) pal.signal.copy(alpha = 0.14f) else Color.Transparent) + .hoverable(src).clickable(interactionSource = src, indication = null, role = Role.Button, onClick = toggle) + .controllerConfirm(onClick = toggle) + .padding(horizontal = 14.dp, vertical = 12.dp), + ) { + Text( + pluralStringResource(R.plurals.lab_kept_count, saved.size, saved.size), fontSize = 14.sp, + color = colors.onSurfaceVariant, modifier = Modifier.weight(1f), + ) + Text( + stringResource(if (showKept) R.string.common_hide else R.string.common_show), fontSize = 13.5.sp, + fontWeight = FontWeight.SemiBold, color = pal.signal, + ) + } + } + if (!foldKept || showKept) for (build in saved) rows += { var armed by remember(build.dir) { mutableStateOf(false) } val info = build.info BuildRow( diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LauncherFrost.kt b/app/src/main/java/com/droiddeck/launcher/ui/LauncherFrost.kt new file mode 100644 index 0000000000..91f2cdf402 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/LauncherFrost.kt @@ -0,0 +1,130 @@ +package com.droiddeck.launcher.ui + +import android.app.Activity +import android.graphics.drawable.ColorDrawable +import android.os.Build +import android.os.PowerManager +import android.view.WindowManager +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.compositeOver +import androidx.compose.ui.graphics.lerp +import androidx.compose.ui.graphics.luminance +import java.util.function.Consumer + +internal val LocalFrost = staticCompositionLocalOf { null } + +internal const val FROST_MAX = 100 +internal const val FROST_STEP = 10 +internal const val FROST_DEFAULT = 50 +internal const val FROST_WALLPAPER_DEFAULT = 80 +private const val FROST_TEXT_LIFT = 0.5f +private const val FROST_LIFT_STEPS = 5 +private const val FROST_TINT_MAX = 0.9f +private const val FROST_SEARCH_STEPS = 12 +private const val FROST_BLUR_DP = 28 + +private class FrostScale(val solid: Float, val default: Float, val clear: Float) { + fun at(percent: Int): Float { + val t = percent.coerceIn(0, FROST_MAX) / FROST_DEFAULT.toFloat() + return if (t <= 1f) solid + (default - solid) * t else default + (clear - default) * (t - 1f) + } +} + +private val TINT_DARK = FrostScale(0.9f, 0.58f, 0.32f) +private val TINT_LIGHT = FrostScale(0.94f, 0.7f, 0.48f) +private val CARD_DARK = FrostScale(1f, 0.6f, 0.3f) +private val CARD_LIGHT = FrostScale(1f, 0.74f, 0.45f) +private val TEXT_LIFT_MAX = FrostScale(FROST_TEXT_LIFT, FROST_TEXT_LIFT, 1f) + +class FrostChoice( + val transparency: Int = FROST_WALLPAPER_DEFAULT, + val cards: Boolean = false, + val cardTransparency: Int = FROST_DEFAULT, +) + +internal class FrostLook(val veil: Color, val lift: Float, val cardAlpha: Float) + +internal fun frostLook(palette: Palette, choice: FrostChoice): FrostLook { + val light = palette.background.luminance() > 0.5f + val cardAlpha = if (!choice.cards) 1f else (if (light) CARD_LIGHT else CARD_DARK).at(choice.cardTransparency) + val maxLift = maxOf(TEXT_LIFT_MAX.at(choice.transparency), if (choice.cards) TEXT_LIFT_MAX.at(choice.cardTransparency) else 0f) + // Android reports only the wallpaper's main colours, and any part of it can sit behind text. + fun readable(alpha: Float, lift: Float): Boolean = listOf(Color.Black, Color.White).all { behind -> + val page = palette.background.copy(alpha = alpha).compositeOver(behind) + val card = palette.surface.copy(alpha = cardAlpha).compositeOver(page) + val hint = lerp(palette.onSurfaceVariant, palette.onBackground, lift) + minOf(ThemeColors.contrast(hint, page), ThemeColors.contrast(hint, card)) >= ThemeColors.MIN_CONTRAST + } + var low = 0f + var high = FROST_TINT_MAX + if (readable(low, maxLift)) high = low + else if (!readable(high, maxLift)) high = 1f + else repeat(FROST_SEARCH_STEPS) { + val mid = (low + high) / 2 + if (readable(mid, maxLift)) high = mid else low = mid + } + val lifts = (0..FROST_LIFT_STEPS).map { FROST_TEXT_LIFT + (maxLift - FROST_TEXT_LIFT) * it / FROST_LIFT_STEPS } + val tint = maxOf((if (light) TINT_LIGHT else TINT_DARK).at(choice.transparency), kotlin.math.ceil(high * 255f) / 255f) + val alpha = if (lifts.any { readable(tint, it) }) tint else 1f + val lift = lifts.firstOrNull { readable(alpha, it) } ?: maxLift + return FrostLook(palette.background.copy(alpha = alpha), lift, cardAlpha) +} + +internal fun Palette.frosted(look: FrostLook): Palette = Palette( + id, label, detail, + background = background, + surface = if (look.cardAlpha < 1f) surface.copy(alpha = look.cardAlpha) else surface, + surfaceVariant = if (look.cardAlpha < 1f) surfaceVariant.copy(alpha = look.cardAlpha) else surfaceVariant, + line = line, line2 = line2, + onBackground = onBackground, onSurfaceVariant = lerp(onSurfaceVariant, onBackground, look.lift), + primary = primary, primary2 = primary2, onPrimary = onPrimary, signal = signal, + good = good, error = error, warning = warning, +) + + +internal class LauncherFrost(private val activity: Activity) { + var available by mutableStateOf(false) + private set + var prepared = false + private set + + private var stopListening: (() -> Unit)? = null + + val supported: Boolean + get() = Build.VERSION.SDK_INT >= 31 && + (available || activity.getSystemService(PowerManager::class.java)?.isPowerSaveMode == true) + + fun start() { + if (Build.VERSION.SDK_INT < 31 || stopListening != null) return + val windows = activity.windowManager + val blur = Consumer { available = it } + available = windows.isCrossWindowBlurEnabled + windows.addCrossWindowBlurEnabledListener(blur) + stopListening = { windows.removeCrossWindowBlurEnabledListener(blur) } + } + + fun stop() { + stopListening?.invoke() + stopListening = null + } + + // A window made see-through after its first frame keeps drawing over its old frames, so this runs before setContent. + fun prepare(on: Boolean) { + prepared = on && Build.VERSION.SDK_INT >= 31 + if (prepared) activity.window.setBackgroundDrawable(ColorDrawable(android.graphics.Color.TRANSPARENT)) + } + + fun show(on: Boolean) { + if (!prepared || Build.VERSION.SDK_INT < 31) return + val window = activity.window + val flags = WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER or WindowManager.LayoutParams.FLAG_BLUR_BEHIND + if (on) window.addFlags(flags) else window.clearFlags(flags) + window.attributes = window.attributes.apply { + blurBehindRadius = if (on) (FROST_BLUR_DP * activity.resources.displayMetrics.density).toInt() else 0 + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt b/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt index c50a6c8978..584fee1072 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LibraryHidden.kt @@ -15,6 +15,7 @@ import com.droiddeck.launcher.frontend.AddedGames import com.droiddeck.launcher.frontend.Library import com.droiddeck.launcher.frontend.SteamHidden import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.stores.Store internal const val LIBRARY_HIDDEN = "hidden" internal val HIDDEN_DOT = androidx.compose.ui.graphics.Color(0xFF9AA0A6) @@ -46,14 +47,18 @@ internal object LibraryHidden { } } - fun steamId(game: Library.SteamGame?): Long? = game?.takeIf { Library.fromSteamClient(it) }?.appId?.toLong() + /** The Steam client's own id for a game it lists, or for an owned Steam game it has not installed ([key] `steamstore:`). */ + fun steamId(game: Library.SteamGame?, key: String = ""): Long? = + game?.takeIf { Library.fromSteamClient(it) }?.appId?.toLong() + ?: key.takeIf { game == null && it.startsWith("${Store.STEAM.id}:") }?.substringAfter(':')?.toLongOrNull() - fun isHidden(key: String, game: Library.SteamGame?): Boolean = key in keys || steamId(game)?.let { it in steam } == true + fun isHidden(key: String, game: Library.SteamGame?): Boolean = key in keys || steamId(game, key)?.let { it in steam } == true - fun isHidden(entry: LibraryEntry): Boolean = isHidden(entry.favoriteKey, entry.game) + fun isHidden(entry: LibraryEntry): Boolean = + isHidden(entry.favoriteKey, entry.game) || entry.item?.takeIf { it.store == Store.STEAM }?.let { it.key in keys || it.id.toLongOrNull()?.let { id -> id in steam } == true } == true fun set(context: Context, key: String, game: Library.SteamGame?, hidden: Boolean): Boolean { - val id = steamId(game) + val id = steamId(game, key) val root = SessionPrefs.activeSteamRoot(context) val written = id?.let { SteamHidden.write(root, it, hidden) } if (id != null) { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt index e940e7b47f..20e61f1d1f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LibraryPage.kt @@ -17,6 +17,7 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope +import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row @@ -139,7 +140,8 @@ internal class LibraryEntry( val game: Library.SteamGame?, val item: CatalogItem?, val installed: Boolean, ) { val storeKey: String? get() = item?.key ?: game?.storeId?.let { "${game.source}:$it" } - val favoriteKey: String get() = storeKey ?: key + /** A Steam game keeps the key it has once the Steam client lists it, so favoriting it before the install carries over. */ + val favoriteKey: String get() = if (item?.store == Store.STEAM) "app:${item.id}" else storeKey ?: key } internal fun libraryEntries( @@ -149,6 +151,7 @@ internal fun libraryEntries( val out = ArrayList() for (g in games.sortedBy { it.library == Library.XBOX_CLOUD }) { if (g.library == Library.EPIC_LAUNCHER) continue + if (Library.fromSteamClient(g)) claimed.add("${Store.STEAM.id}:${g.appId}") val storeKey = g.storeId?.let { "${g.source}:$it" } val item = storeKey?.let { k -> Store.byId(g.source)?.let { st -> owned[st]?.firstOrNull { it.key == k } } } if (storeKey != null) { @@ -160,7 +163,7 @@ internal fun libraryEntries( } for (store in Store.entries) for (item in owned[store].orEmpty()) { if (!claimed.add(item.key)) continue - out += LibraryEntry(GameRef.key(item), store.id, item.title, null, item, installed = item.key in installedStore) + out += LibraryEntry(GameRef.key(item), store.librarySource, item.title, null, item, installed = item.key in installedStore) } return out.distinctBy { it.key } } @@ -193,14 +196,18 @@ internal fun librarySources( } } +internal fun alwaysLibraryTabs(signedIn: Collection, stores: Boolean, soundMode: Boolean): Set = + (if (soundMode) emptyList() else signedIn.map { it.librarySource }).toSet() + + listOfNotNull(Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores }) + internal object LibraryDisplay { const val DEFAULT_LEVEL = 2 val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f) var level by mutableIntStateOf(DEFAULT_LEVEL) private set - var title by mutableStateOf(true) + var title by mutableStateOf(false) private set - var size by mutableStateOf(true) + var size by mutableStateOf(false) private set fun load(context: android.content.Context) { @@ -297,7 +304,7 @@ internal object LibraryView { fun showOwned(context: android.content.Context, store: Store) { SessionPrefs.setLibraryShowUninstalled(context, true) ownedRequest++ - source = store.id + source = store.librarySource query = "" focusFirst = true } @@ -372,7 +379,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String, .map { it.store.id }.toSet() val sources = librarySources( all, storeTabs.map { it.store.id }, - listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }).toSet() + signInChips, + alwaysLibraryTabs(owned.keys, stores, soundMode) + signInChips, favorites, concealed, offStores = if (soundMode) emptySet() else storeTabs.filterNot { it.shown }.map { it.store.id }.toSet(), places = if (soundMode) DEFAULT_LIBRARY_PLACES else StoreTabsState.libraryPlaces, @@ -525,13 +532,11 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String, val grid = remember { LazyGridState() } val detailScroll = rememberScrollState() var cycled by remember { mutableIntStateOf(0) } - var gridFocused by remember { mutableStateOf(false) } LaunchedEffect(source, sort) { grid.scrollToItem(0) } LaunchedEffect(cycled) { if (cycled == 0 || ff == null || inputMode.inputMode != androidx.compose.ui.input.InputMode.Keyboard) return@LaunchedEffect - focusWithinFrames({ gridFocused }) { - if (ff.firstTileAttached > 0) ff.firstTile else ff.items["libchip:$source"] ?: FocusRequester.Default - } + val chip = "libchip:$source" + holdFocus({ ff.last == chip }) { ff.items[chip] } } CardDetailHost( open, detailScroll, @@ -557,7 +562,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String, else { focusManager.clearFocus(force = true); onSelect(it) } }, searchCleared = open != null, - onFocus = { gridFocused = it }, + onFocus = {}, soundMode = soundMode, wallArt = { wallTiles(all.filterNot(concealed).mapNotNull { entryArt(it, tall = true) }) }, emptyText = when { @@ -630,7 +635,8 @@ private fun LibraryGrid( // A search that matches nothing keeps the toolbar, so the search can still be cleared. val customEmpty = !soundMode && source == Library.ADDED && visible.isEmpty() && hiddenUninstalled == 0 && LibraryView.query.isBlank() val splash = !soundMode && (signInStore != null || customEmpty) - val headerItems = (if (splash) 1 else 2) + (if (sizesPending) 1 else 0) + syncing.size + val showHeader = !splash || source == Store.BATTLENET.id + val headerItems = (if (showHeader) 2 else 1) + (if (sizesPending) 1 else 0) + syncing.size val expanded = showUninstalled == true val notInstalled = if (expanded) visible.count { !it.installed } else hiddenUninstalled val toggleAt = when { @@ -746,25 +752,28 @@ private fun LibraryGrid( } } } + val manage = !soundMode && !s.shortcutPicker LazyVerticalGrid( columns = if (listMode) GridCells.Fixed(1) else remember(baseWidth, level) { LevelCells(baseWidth, level) }, state = grid, - modifier = Modifier.fillMaxSize().onFocusChanged { onFocus(it.hasFocus) }.focusGroup().bumpers(onPrevious = { onCycle(-1) }, onNext = { onCycle(1) }).onSizeChanged { - val gap = with(density) { 10.dp.roundToPx() } - columns = if (listMode) 1 else libraryColumns(it.width, with(density) { baseWidth.roundToPx() }, gap, level) - gridH = it.height - }, + modifier = Modifier.fillMaxSize().onFocusChanged { onFocus(it.hasFocus) }.focusGroup() + .then(if (sourceChipsShown(sources, manage)) Modifier.bumpers(onPrevious = { onCycle(-1) }, onNext = { onCycle(1) }) else Modifier) + .onSizeChanged { + val gap = with(density) { 10.dp.roundToPx() } + columns = if (listMode) 1 else libraryColumns(it.width, with(density) { baseWidth.roundToPx() }, gap, level) + gridH = it.height + }, horizontalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp), contentPadding = PaddingValues(top = 4.dp, bottom = 16.dp), ) { val header: @Composable () -> Unit = { LibraryHeader(s, a, if (soundMode) total else visible.size + hiddenUninstalled, searchCleared, source == Store.XBOX.id, showUninstalled, onShowUninstalled, collections = Store.byId(source)?.takeIf { it == Store.ITCH || it == Store.GAMEJOLT }, soundMode = soundMode, onAddSoundtrack = onAddSoundtrack, onCollections = onCollections, source = source) } - val filters: @Composable () -> Unit = { LibraryFilters(sources, source, onSource, manage = !soundMode && !s.shortcutPicker) } + val filters: @Composable () -> Unit = { LibraryFilters(sources, source, onSource, manage) } item(key = if (soundMode) "header" else "filters", span = { GridItemSpan(maxLineSpan) }) { Box(Modifier.onSizeChanged { chipsH = it.height }) { Rise(0) { if (soundMode) header() else filters() } } } val splashHeight = with(density) { (gridH - chipsH).toDp() - 28.dp }.coerceAtLeast(300.dp) - if (!splash) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } } + if (showHeader) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } } for ((store, line) in syncing) item(key = "sync-${store.id}", span = { GridItemSpan(maxLineSpan) }) { Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.fillMaxWidth()) { Text(store.shortLabel + " · " + line, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) @@ -880,6 +889,12 @@ private fun LibraryHeader( clearSearchFocus = searchCleared, inlineWhenStacked = true, lead = soundLead, ) { + if (!soundMode && !s.shortcutPicker && source == Store.BATTLENET.id) { + SecondaryButton( + stringResource(R.string.bnet_open), enabled = !s.busy && DevPreview.library == LibraryPreview.OFF, + compact = true, modifier = Modifier.testTag("library-battlenet-open"), onClick = a.onBattleNet, + ) + } if (soundMode) HeaderIconButton(stringResource(R.string.soundtracks_saved), Icons.Filled.BookmarkBorder, "collections", onClick = onCollections) if (!soundMode && DeveloperTools.on && DevPreview.shortcuts) LibraryPreviewButton() DisplayButton() @@ -895,10 +910,13 @@ private fun LibraryHeader( if (s.steamGamesX64 && narrow) Box(Modifier.padding(top = 4.dp)) { ClientTag() } } +private fun sourceChipsShown(sources: List, manage: Boolean): Boolean = + (manage && sources.isNotEmpty()) || sources.size >= 2 || sources.singleOrNull() == LIBRARY_HIDDEN + @OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class) @Composable -private fun LibraryFilters(sources: List, source: String, onSource: (String) -> Unit, manage: Boolean) { - val chips = (manage && sources.isNotEmpty()) || sources.size >= 2 || sources.singleOrNull() == LIBRARY_HIDDEN +internal fun LibraryFilters(sources: List, source: String, onSource: (String) -> Unit, manage: Boolean) { + val chips = sourceChipsShown(sources, manage) if (!chips && !manage) return val pal = LocalPalette.current val keys = if (chips) listOf(LIBRARY_ALL) + sources else emptyList() @@ -914,42 +932,54 @@ private fun LibraryFilters(sources: List, source: String, onSource: (Str horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 4.dp, bottom = 2.dp), ) { - Box(Modifier.weight(1f).edgeFade(scroll).horizontalScroll(scroll)) { - Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) { - for (id in keys) { - val store = Store.byId(id) - val dot = sourceDot(id) - val label = when (id) { - LIBRARY_ALL -> stringResource(R.string.stores_tab_all) - Library.ADDED -> stringResource(R.string.library_custom_games) - LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites) - LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden) - else -> store?.shortLabel ?: sourceLabel(id) - } - androidx.compose.runtime.key(id) { - val reveal = remember { BringIntoViewRequester() } - LaunchedEffect(source) { if (source == id) reveal.bringIntoView() } - StoreChip( - label = label, on = source == id, under = fillShown && highlighted == id, key = id, mark = dot ?: pal.signal, - modifier = Modifier.bringIntoViewRequester(reveal).testTag("library-source-$id") - .onGloballyPositioned { bounds[id] = it.boundsInParent() }, - lead = { - if (dot != null) Box(Modifier.size(9.dp).background(dot, CircleShape)) - else Icon(Icons.Filled.GridView, null, modifier = Modifier.size(14.dp)) - }, - onFocused = { focused = it }, - paneKey = "libchip:$id", - ) { onSource(id) } + BoxWithConstraints(Modifier.weight(1f)) { + if (sourceTabsAsMenu(maxWidth, keys.size)) { + TabMenu( + keys.map { librarySourceChipLabel(it) }, keys.indexOf(source), { onSource(keys[it]) }, + chipModifier = Modifier.paneItem("libchip:$source"), + leading = { i, _ -> LibrarySourceMark(sourceDot(keys[i])) }, + ) + } else Box(Modifier.edgeFade(scroll).horizontalScroll(scroll)) { + Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) { + for (id in keys) { + val dot = sourceDot(id) + androidx.compose.runtime.key(id) { + val reveal = remember { BringIntoViewRequester() } + LaunchedEffect(source) { if (source == id) reveal.bringIntoView() } + StoreChip( + label = librarySourceChipLabel(id), on = source == id, under = fillShown && highlighted == id, key = id, mark = dot ?: pal.signal, + modifier = Modifier.bringIntoViewRequester(reveal).testTag("library-source-$id") + .onGloballyPositioned { bounds[id] = it.boundsInParent() }, + lead = { LibrarySourceMark(dot) }, + onFocused = { focused = it }, + paneKey = "libchip:$id", + ) { onSource(id) } + } } } + if (highlighted in keys) ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown) } - if (highlighted in keys) ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown) } if (manage) ManageStoresChip() } } } +@Composable +private fun librarySourceChipLabel(id: String): String = when (id) { + LIBRARY_ALL -> stringResource(R.string.stores_tab_all) + Library.ADDED -> stringResource(R.string.library_custom_games) + LIBRARY_FAVORITES -> stringResource(R.string.soundtracks_favorites) + LIBRARY_HIDDEN -> stringResource(R.string.apps_filter_hidden) + else -> Store.byId(id)?.shortLabel ?: sourceLabel(id) +} + +@Composable +private fun LibrarySourceMark(dot: Color?) { + if (dot != null) Box(Modifier.size(9.dp).background(dot, CircleShape)) + else Icon(Icons.Filled.GridView, null, modifier = Modifier.size(14.dp)) +} + @Composable private fun sourceTitle(src: String): String = when (src) { LIBRARY_ALL -> stringResource(R.string.library_all_games) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt b/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt index f58ee90807..6769798ad9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/LiftSheet.kt @@ -100,7 +100,6 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalInputModeManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role -import androidx.compose.animation.core.animateFloat import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight @@ -649,20 +648,20 @@ internal fun Handle(height: Dp, above: Boolean = false) { val pal = LocalPalette.current val shape = if (above) RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp) else RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp) val still = Motion.scale == 0f - val bob = androidx.compose.animation.core.rememberInfiniteTransition(label = "handle") - val lift by bob.animateFloat( - 0f, 0f, - androidx.compose.animation.core.infiniteRepeatable( + val lift = remember { Animatable(0f) } + LaunchedEffect(still) { + lift.snapTo(0f) + if (!still) lift.animateTo( + 0f, androidx.compose.animation.core.keyframes { - durationMillis = 2400 + durationMillis = 620 0f at 0 1f at 180 using androidx.compose.animation.core.FastOutSlowInEasing -0.25f at 420 0f at 620 }, - ), - label = "handleBob", - ) + ) + } Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.height(height).clip(shape).background(colors.surface) @@ -672,7 +671,7 @@ internal fun Handle(height: Dp, above: Boolean = false) { Text(stringResource(R.string.sheet_lip), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, maxLines = 1) Icon( if (above) Icons.Filled.KeyboardArrowDown else Icons.Filled.KeyboardArrowUp, null, tint = colors.onSurfaceVariant, - modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else (if (above) 3.dp else -3.dp).toPx() * lift }, + modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else (if (above) 3.dp else -3.dp).toPx() * lift.value }, ) } } @@ -712,6 +711,10 @@ internal fun SheetChips( Modifier.fillMaxWidth().onFocusChanged { within = it.hasFocus }, contentAlignment = Alignment.CenterStart, ) { + if (tabsAsMenu(maxWidth, labels.size)) { + TabMenu(labels, selected, onPick, focus = chips) + return@BoxWithConstraints + } val equal = !width.isSpecified && maxWidth / labels.size.coerceAtLeast(1) >= 96.dp val least = if (width.isSpecified) maxOf(width, 64.dp) else 64.dp val scroll = rememberScrollState() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt b/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt index 2b3a4a5413..add703ce09 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ManageStores.kt @@ -79,7 +79,7 @@ internal object StoreTabsState { private set fun load(context: android.content.Context) { - SessionPrefs.settleStoresTabOrder(context, Store.entries.map { it.id }) + SessionPrefs.settleStoresTabOrder(context, Store.tabbed.map { it.id }) tabs = arrangeStoreTabs(SessionPrefs.storesTabOrder(context), SessionPrefs.storesTabHidden(context)) libraryPlaces = SessionPrefs.libraryTabPlaces(context) ?: DEFAULT_LIBRARY_PLACES libraryHidden = SessionPrefs.libraryTabsHidden(context) + listOfNotNull(LIBRARY_HIDDEN.takeUnless { SessionPrefs.libraryShowHidden(context) }) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index 3509d0a83d..2f0cc48a1f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -62,6 +62,7 @@ class ModeSettings( val hdrReason: String?, val hdrDisplay: Boolean = true, val zeroCopy: Boolean = true, + val producerAcquireFences: Boolean? = null, val gpuDrivers: String? = null, val upscaler: Int = 0, val upscaleSharpness: Int = 75, @@ -86,7 +87,8 @@ class ModeSettings( val fexPreset: String? = null, val forceSsbs: Boolean = false, val syncBackend: String? = null, - val picturePosition: String? = null, + val picturePositionLandscape: String? = null, + val picturePositionPortrait: String? = null, val integerScaling: Boolean? = null, val stretch16x9: Boolean? = null, val avoidNotch: Boolean? = null, @@ -125,6 +127,7 @@ class ModeSettingsActions( val onResolutionPortrait: (String) -> Unit = {}, val onHdr: (Boolean) -> Unit, val onZeroCopy: (Boolean) -> Unit = {}, + val onProducerAcquireFences: (Boolean) -> Unit = {}, val onGpuDrivers: () -> Unit = {}, val onUpscaler: (Int) -> Unit = {}, val onUpscaleSharpness: (Int) -> Unit = {}, @@ -150,7 +153,7 @@ class ModeSettingsActions( val onFexPreset: (String) -> Unit = {}, val onForceSsbs: (Boolean) -> Unit = {}, val onSyncBackend: (String) -> Unit = {}, - val onPicturePosition: (String) -> Unit = {}, + val onPicturePosition: (Boolean, String) -> Unit = { _, _ -> }, val onIntegerScaling: (Boolean) -> Unit = {}, val onStretch16x9: (Boolean) -> Unit = {}, val onAvoidNotch: (Boolean) -> Unit = {}, @@ -260,15 +263,16 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras: ResolutionRow(host, "resolution-portrait", stringResource(R.string.display_resolution_portrait), s.resolutionPortrait, portraitChoice, com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE, if (sessionDisplay.isLink(s.resolution)) portraitChoice else sessionDisplay.orientCustom(s.resolution, true), - s.panelSize, a.onResolutionPortrait, portrait = true) - s.picturePosition?.let { position -> - ChoiceRow(host, "picture-position", stringResource(R.string.display_picture_position), null, - listOf("top" to stringResource(R.string.display_position_top), - "bottom" to stringResource(R.string.display_position_bottom), - "left" to stringResource(R.string.display_position_left), - "right" to stringResource(R.string.display_position_right), - "center" to stringResource(R.string.display_position_center)), - position, onPick = a.onPicturePosition) + s.panelSize, a.onResolutionPortrait, portrait = true, + defaultChoice = if (s.mode == SessionService.MODE_STEAM) sessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION + else sessionDisplay.DEFAULT_RESOLUTION) + s.picturePositionLandscape?.let { position -> + PicturePositionRow(host, position, key = "picture-position-landscape", + labelRes = R.string.display_picture_position_landscape) { a.onPicturePosition(false, it) } + } + s.picturePositionPortrait?.let { position -> + PicturePositionRow(host, position, key = "picture-position-portrait", + labelRes = R.string.display_picture_position_portrait) { a.onPicturePosition(true, it) } } if (s.stretch16x9 != null && (com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(s.panelSize) || com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize))) { @@ -284,6 +288,11 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras: stringResource(R.string.display_avoid_notch_hint), checked = enabled, onChange = a.onAvoidNotch) } ToggleRow(host, "zero-copy", stringResource(R.string.display_zero_copy), null, checked = s.zeroCopy, onChange = a.onZeroCopy) + s.producerAcquireFences?.let { enabled -> + ToggleRow(host, "producer-acquire-fences", stringResource(R.string.producer_acquire_fences), + stringResource(R.string.producer_acquire_fences_summary), checked = enabled, + onChange = a.onProducerAcquireFences) + } } SettingsGroup(stringResource(R.string.display_image_scaling)) { s.integerScaling?.let { enabled -> @@ -735,3 +744,22 @@ internal fun CustomFollowScaleDialog(initial: Float?, onSave: (Float) -> Unit, o dismissButton = { androidx.compose.material3.TextButton(onClick = onDismiss, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } }, ) } + +@Composable +internal fun PicturePositionRow( + host: MenuHost, position: String, + chipModifier: Modifier = Modifier, + key: String = "picture-position", + @androidx.annotation.StringRes labelRes: Int = R.string.display_picture_position, + onPick: (String) -> Unit, +) { + ChoiceRow(host, key, stringResource(labelRes), null, + listOf( + "center" to stringResource(R.string.display_position_center), + "top" to stringResource(R.string.display_position_top), + "bottom" to stringResource(R.string.display_position_bottom), + "left" to stringResource(R.string.display_position_left), + "right" to stringResource(R.string.display_position_right), + ), + position, chipModifier = chipModifier, onPick = onPick) +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt b/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt index 19b6ced051..dcf1050ee7 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/NavTabs.kt @@ -27,7 +27,7 @@ internal object DeveloperTools { internal object NavTabs { const val MORE = "more" val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent") - val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent") + val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent") val DEFAULT_HIDDEN = setOf("android-apps", "agent") private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "agent") private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates") @@ -116,10 +116,7 @@ internal object NavTabs { fun more(s: FrontEndState) = listed(s).filter { place(s, it) == TabPlace.MORE } - fun bar(s: FrontEndState): List { - val shown = listed(s).filter { place(s, it) == TabPlace.BAR } - return if (more(s).isEmpty()) shown else shown + MORE - } + fun bar(s: FrontEndState): List = listed(s).filter { place(s, it) == TabPlace.BAR } + MORE fun setHidden(context: Context, key: String, hide: Boolean) { hidden = if (hide && hideable(key)) hidden + key else hidden - key diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt b/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt index 5c40727031..bd63dce034 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PcKeyboard.kt @@ -8,6 +8,9 @@ import com.droiddeck.launcher.input.PcKey import androidx.compose.ui.res.stringResource import android.view.KeyEvent import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.foundation.hoverable +import androidx.compose.foundation.interaction.collectIsHoveredAsState import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable @@ -69,6 +72,9 @@ fun PcKeyboard( sendKey: (Int, Boolean) -> Unit, onAndroidKeyboard: () -> Unit, onClose: () -> Unit, + heightFraction: Float? = null, + showButtons: Boolean = true, + hoverFeedback: Boolean = false, ) { val pal = LocalPalette.current val colors = MaterialTheme.colorScheme @@ -76,31 +82,40 @@ fun PcKeyboard( var capsOn by remember { mutableStateOf(false) } val firstKey = remember { FocusRequester() } val shifted = (mods[42] ?: MOD_OFF) != MOD_OFF || (mods[54] ?: MOD_OFF) != MOD_OFF + // Keys go to wherever sendKey points now, but a held key is let go where it went down. + val currentSend by androidx.compose.runtime.rememberUpdatedState(sendKey) + val heldAt = remember { mutableMapOf Unit>() } + fun down(code: Int) { + val send = currentSend + heldAt[code] = send + send(code, true) + } + fun up(code: Int) = (heldAt.remove(code) ?: currentSend)(code, false) fun releaseOnceModifiers() { - for ((code, state) in mods.toMap()) if (state == MOD_ONCE) { sendKey(code, false); mods[code] = MOD_OFF } + for ((code, state) in mods.toMap()) if (state == MOD_ONCE) { up(code); mods[code] = MOD_OFF } } fun press(key: PcKey) { if (key.code in PC_MODIFIERS) { when (mods[key.code] ?: MOD_OFF) { - MOD_OFF -> { sendKey(key.code, true); mods[key.code] = MOD_ONCE } + MOD_OFF -> { down(key.code); mods[key.code] = MOD_ONCE } MOD_ONCE -> mods[key.code] = MOD_LOCKED - else -> { sendKey(key.code, false); mods[key.code] = MOD_OFF } + else -> { up(key.code); mods[key.code] = MOD_OFF } } return } - sendKey(key.code, true) + down(key.code) } fun release(key: PcKey) { if (key.code in PC_MODIFIERS) return - sendKey(key.code, false) + up(key.code) if (key.code == 58) capsOn = !capsOn releaseOnceModifiers() } androidx.compose.runtime.DisposableEffect(Unit) { - onDispose { for ((code, state) in mods.toMap()) if (state != MOD_OFF) sendKey(code, false) } + onDispose { for (code in heldAt.keys.toList()) up(code) } } - LaunchedEffect(Unit) { runCatching { firstKey.requestFocus() } } + LaunchedEffect(Unit) { if (!hoverFeedback) runCatching { firstKey.requestFocus() } } val prefsContext = LocalContext.current remember { PcKeyboardPrefs.load(prefsContext) } @@ -108,7 +123,7 @@ fun PcKeyboard( val rows = PC_KEY_ROWS.map { row -> row.filter { it.code !in hiddenCodes } }.filter { it.isNotEmpty() } BoxWithConstraints(Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) { - val rowHeight = ((maxHeight * (PcKeyboardPrefs.size / 100f) - 24.dp - 3.dp * rows.size - 10.dp) / rows.size) + val rowHeight = ((maxHeight * (heightFraction ?: (PcKeyboardPrefs.size / 100f)) - 24.dp - 3.dp * rows.size - 10.dp) / rows.size) .coerceIn(20.dp, 56.dp) Box( Modifier.fillMaxWidth() @@ -122,9 +137,11 @@ fun PcKeyboard( Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().height(24.dp)) { Text(stringResource(R.string.drawer_pc_keyboard), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant) Spacer(Modifier.weight(1f)) - HeaderButton(stringResource(R.string.pckb_android), onAndroidKeyboard) - Spacer(Modifier.width(8.dp)) - HeaderButton(stringResource(R.string.pckb_hide), onClose) + if (showButtons) { + HeaderButton(stringResource(R.string.pckb_android), onAndroidKeyboard) + Spacer(Modifier.width(8.dp)) + HeaderButton(stringResource(R.string.pckb_hide), onClose) + } } rows.forEachIndexed { r, row -> Row(horizontalArrangement = Arrangement.spacedBy(3.dp), modifier = Modifier.fillMaxWidth().height(rowHeight)) { @@ -139,7 +156,7 @@ fun PcKeyboard( } key(key.code) { KeyCap( - label, key.weight, lit, locked = state == MOD_LOCKED, + label, key.weight, lit, locked = state == MOD_LOCKED, hoverFeedback = hoverFeedback, modifier = if (r == 0 && i == 0) Modifier.focusRequester(firstKey) else Modifier, onDown = { press(key) }, onUp = { release(key) }, ) @@ -154,25 +171,35 @@ fun PcKeyboard( @Composable private fun RowScope.KeyCap( - label: String, weight: Float, lit: Boolean, locked: Boolean, + label: String, weight: Float, lit: Boolean, locked: Boolean, hoverFeedback: Boolean, modifier: Modifier, onDown: () -> Unit, onUp: () -> Unit, ) { val pal = LocalPalette.current val src = remember { MutableInteractionSource() } val focused by src.collectIsFocusedAsState() + val hovered by src.collectIsHoveredAsState() + val (pointedAt, laser) = com.droiddeck.launcher.session.xr.rememberXrPointed() + val pointed = hoverFeedback && (hovered || laser.value) var down by remember { mutableStateOf(false) } val fill by animateColorAsState( when { down -> pal.signal.copy(alpha = 0.55f) lit -> pal.signal.copy(alpha = if (locked) 0.45f else 0.28f) + pointed -> Color.White.copy(alpha = 0.2f) else -> Color.White.copy(alpha = 0.07f) - }, Motion.tw(160), label = "keyFill", + }, Motion.tw(if (down) 40 else 160), label = "keyFill", + ) + val scale by animateFloatAsState( + if (!hoverFeedback) 1f else if (down) 0.9f else if (pointed) 1.06f else 1f, Motion.tw(if (down) 40 else 140), label = "keyScale", ) Box( contentAlignment = Alignment.Center, modifier = modifier.weight(weight).fillMaxHeight() + .then(pointedAt) + .graphicsLayer { scaleX = 1f + (scale - 1f) * size.height / size.width; scaleY = scale } .background(fill, RoundedCornerShape(7.dp)) - .glideBorder(focused, RoundedCornerShape(7.dp), pal.signal, if (lit) pal.signal.copy(alpha = 0.7f) else Color.White.copy(alpha = 0.12f)) + .glideBorder(if (hoverFeedback) pointed || down else focused, RoundedCornerShape(7.dp), pal.signal, if (lit) pal.signal.copy(alpha = 0.7f) else Color.White.copy(alpha = 0.12f)) + .then(if (hoverFeedback) Modifier.hoverable(src) else Modifier) .pointerInput(Unit) { awaitEachGesture { awaitFirstDown().consume() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt b/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt index 646c8cfcc6..772c6cc27c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PenSettingsGroup.kt @@ -11,7 +11,7 @@ internal fun PenSettingsGroup( host: MenuHost, pen: SessionPrefs.Pen, track: (String) -> Modifier = { Modifier }, onPick: (key: String, value: String) -> Unit, ) { - SettingsGroup(stringResource(R.string.mode_pen)) { + SettingsGroup(stringResource(R.string.mode_pen), key = "controller-pen") { ChoiceRow(host, "pen", stringResource(R.string.mode_pen), null, listOf(SessionPrefs.PEN_MOUSE to stringResource(R.string.mode_pen_mouse), SessionPrefs.PEN_TOUCH to stringResource(R.string.mode_pen_touch)), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt index 0c3947f986..de71ca6682 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -15,6 +15,8 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -46,9 +48,8 @@ fun PerformancePage( fsyncFirst: Boolean, gamescopeRealtime: Boolean, gpuClockPin: Boolean, - prootNoSeccomp: Boolean, - prootFastPath: Boolean, - nativeUserland: Boolean, + nativeDesktopAvailable: Boolean, + desktopAsUser: Boolean, cursorComposite: Boolean, guestHostname: String, phantomWarning: String?, @@ -64,134 +65,143 @@ fun PerformancePage( onFsyncFirst: (Boolean) -> Unit, onGamescopeRealtime: (Boolean) -> Unit, onGpuClockPin: (Boolean) -> Unit, - onProotNoSeccomp: (Boolean) -> Unit, - onProotFastPath: (Boolean) -> Unit, - onNativeUserland: (Boolean) -> Unit, + onDesktopAsUser: (Boolean) -> Unit, onCursorComposite: (Boolean) -> Unit, onGuestHostname: (String) -> Unit, onClientCore: (Int, Boolean) -> Unit, onGameCore: (Int, Boolean) -> Unit, onDismiss: () -> Unit, embedded: Boolean = false, + memory: @Composable () -> Unit = {}, ) { val host = rememberMenuHost() val colors = MaterialTheme.colorScheme val coreItems = cores.map { it.core to it.label } + var showCompatibility by rememberSaveable { mutableStateOf(false) } + var hostnameDraft by remember(guestHostname) { mutableStateOf(guestHostname) } + val jump = SettingsJump.target + val compatibilityLabels = listOf( + R.string.perf_glthread, R.string.perf_zink, R.string.perf_noglerror, R.string.perf_gsrealtime, + R.string.perf_sysmem, R.string.perf_xalia, R.string.perf_esync, R.string.perf_fsync, + R.string.perf_fastsync, + R.string.perf_cursor_composite, R.string.perf_hostname, R.string.perf_desktop_as_user, + ).map { stringResource(it) } + LaunchedEffect(jump) { + if (jump != null && jump.label in compatibilityLabels) showCompatibility = true + } val body: @Composable () -> Unit = { - SettingsGroup(stringResource(R.string.perf_client_cores_group)) { + SettingsGroup(stringResource(R.string.setup_performance_cpu)) { ToggleRow( host, "override", stringResource(R.string.perf_override), stringResource(R.string.perf_override_hint), - clientOverride, onChange = onClientOverride, + clientOverride, sideBySide = true, onChange = onClientOverride, ) MultiRow( host, "clientCores", stringResource(R.string.perf_client_cores), if (clientOverride) stringResource(R.string.perf_client_cores_on) else stringResource(R.string.perf_client_cores_off), - coreItems, clientCores, enabled = clientOverride, onToggle = onClientCore, + coreItems, clientCores, enabled = clientOverride, sideBySide = true, onToggle = onClientCore, ) - } - SettingsGroup(stringResource(R.string.perf_game_cores_group)) { MultiRow( host, "gameCores", stringResource(R.string.perf_game_cores), stringResource(R.string.perf_game_cores_hint), - coreItems, gameCores, onToggle = onGameCore, + coreItems, gameCores, sideBySide = true, onToggle = onGameCore, ) + } + SettingsGroup(stringResource(R.string.setup_performance_graphics), key = "performance-gpu") { ToggleRow( host, "paceCores", stringResource(R.string.perf_pace_cores), stringResource(R.string.perf_pace_cores_hint), - paceCores, onChange = onPaceCores, + paceCores, sideBySide = true, onChange = onPaceCores, + ) + if (GpuClockPin.supported) ToggleRow( + host, "gpuclock", stringResource(R.string.perf_gpuclock), null, + gpuClockPin, sideBySide = true, onChange = onGpuClockPin, ) } - SettingsGroup(stringResource(R.string.perf_client_ui)) { - ToggleRow( - host, "glthread", stringResource(R.string.perf_glthread), - stringResource(R.string.perf_glthread_hint), - glThread, onChange = onGlThread, - ) - ToggleRow( - host, "zink", stringResource(R.string.perf_zink), - stringResource(R.string.perf_zink_hint), - zinkLazy, onChange = onZinkLazy, - ) - ToggleRow( - host, "noglerror", stringResource(R.string.perf_noglerror), - stringResource(R.string.perf_noglerror_hint), - noGlError, onChange = onNoGlError, - ) - ToggleRow( - host, "gsrealtime", stringResource(R.string.perf_gsrealtime), - stringResource(R.string.perf_gsrealtime_hint), - gamescopeRealtime, onChange = onGamescopeRealtime, + memory() + if (embedded) SettingsGroup(stringResource(R.string.setup_performance_advanced)) { + ActionRow( + stringResource(R.string.setup_performance_compatibility), stringResource(R.string.setup_performance_compatibility_hint), + stringResource(if (showCompatibility) R.string.common_close else R.string.setup_expand_open), + onClick = { showCompatibility = !showCompatibility }, sideBySide = true, ) } - if (GpuClockPin.supported) GpuClockGroup(host, gpuClockPin, onChange = onGpuClockPin) - SettingsGroup(stringResource(R.string.perf_fixes)) { - ToggleRow( - host, "sysmem", stringResource(R.string.perf_sysmem), - stringResource(R.string.perf_sysmem_hint), - tuSysmem, onChange = onTuSysmem, - ) - ToggleRow( - host, "xalia", stringResource(R.string.perf_xalia), - stringResource(R.string.perf_xalia_hint), - noXalia, onChange = onNoXalia, - ) - ToggleRow( - host, "syncfallback", stringResource(R.string.perf_esync), - stringResource(R.string.perf_esync_hint), - syncFallback, onChange = onSyncFallback, - ) - ToggleRow( - host, "fsyncfirst", stringResource(R.string.perf_fsync), - stringResource(R.string.perf_fsync_hint), - fsyncFirst, onChange = onFsyncFirst, - ) - ToggleRow( - host, "fastsync", stringResource(R.string.perf_fastsync), - stringResource(R.string.perf_fastsync_hint), - fastSync, onChange = onFastSync, - ) - ToggleRow( - host, "seccomp", stringResource(R.string.perf_seccomp), - stringResource(R.string.perf_seccomp_hint), - prootNoSeccomp, onChange = onProotNoSeccomp, - ) - ToggleRow( - host, "fastpath", stringResource(R.string.perf_fastpath), - when { - nativeUserland -> stringResource(R.string.perf_fastpath_needs_proot) - prootNoSeccomp -> stringResource(R.string.perf_fastpath_needs_seccomp) - else -> stringResource(R.string.perf_fastpath_hint) - }, - prootFastPath && !prootNoSeccomp && !nativeUserland, enabled = !prootNoSeccomp && !nativeUserland, - onChange = onProotFastPath, - ) - ToggleRow( - host, "nativeuserland", stringResource(R.string.perf_native_userland), - stringResource(R.string.perf_native_userland_hint), - nativeUserland, onChange = onNativeUserland, - ) - ToggleRow( - host, "cursorcomposite", stringResource(R.string.perf_cursor_composite), - stringResource(R.string.perf_cursor_composite_hint), - cursorComposite, onChange = onCursorComposite, - ) - } - SettingsGroup(stringResource(R.string.perf_identity)) { - var draft by remember(guestHostname) { mutableStateOf(guestHostname) } - val valid = SessionPrefs.validGuestHostname(draft) != null - SettingsRow( - stringResource(R.string.perf_hostname), - if (valid || draft.isBlank()) stringResource(R.string.perf_hostname_hint, SessionPrefs.DEFAULT_GUEST_HOSTNAME) - else stringResource(R.string.perf_hostname_invalid), - ) { - OutlinedTextField( - draft, { v -> - draft = v.take(63) - if (draft.isBlank() || SessionPrefs.validGuestHostname(draft) != null) onGuestHostname(draft) - }, - singleLine = true, isError = !valid && draft.isNotBlank(), - placeholder = { Text(SessionPrefs.DEFAULT_GUEST_HOSTNAME) }, - modifier = Modifier.width(220.dp).focusGlide(), + if (!embedded || showCompatibility) { + SettingsGroup(stringResource(R.string.perf_client_ui)) { + ToggleRow( + host, "glthread", stringResource(R.string.perf_glthread), + stringResource(R.string.perf_glthread_hint), + glThread, onChange = onGlThread, + ) + ToggleRow( + host, "zink", stringResource(R.string.perf_zink), + stringResource(R.string.perf_zink_hint), + zinkLazy, onChange = onZinkLazy, + ) + ToggleRow( + host, "noglerror", stringResource(R.string.perf_noglerror), + stringResource(R.string.perf_noglerror_hint), + noGlError, onChange = onNoGlError, + ) + ToggleRow( + host, "gsrealtime", stringResource(R.string.perf_gsrealtime), + stringResource(R.string.perf_gsrealtime_hint), + gamescopeRealtime, onChange = onGamescopeRealtime, + ) + } + SettingsGroup(stringResource(R.string.perf_fixes)) { + ToggleRow( + host, "sysmem", stringResource(R.string.perf_sysmem), + stringResource(R.string.perf_sysmem_hint), + tuSysmem, onChange = onTuSysmem, + ) + ToggleRow( + host, "xalia", stringResource(R.string.perf_xalia), + stringResource(R.string.perf_xalia_hint), + noXalia, onChange = onNoXalia, + ) + ToggleRow( + host, "syncfallback", stringResource(R.string.perf_esync), + stringResource(R.string.perf_esync_hint), + syncFallback, onChange = onSyncFallback, + ) + ToggleRow( + host, "fsyncfirst", stringResource(R.string.perf_fsync), + stringResource(R.string.perf_fsync_hint), + fsyncFirst, onChange = onFsyncFirst, + ) + ToggleRow( + host, "fastsync", stringResource(R.string.perf_fastsync), + stringResource(R.string.perf_fastsync_hint), + fastSync, onChange = onFastSync, + ) + ToggleRow( + host, "cursorcomposite", stringResource(R.string.perf_cursor_composite), + stringResource(R.string.perf_cursor_composite_hint), + cursorComposite, onChange = onCursorComposite, + ) + } + SettingsGroup(stringResource(R.string.perf_identity)) { + val valid = SessionPrefs.validGuestHostname(hostnameDraft) != null + SettingsRow( + stringResource(R.string.perf_hostname), + if (valid || hostnameDraft.isBlank()) stringResource(R.string.perf_hostname_hint, SessionPrefs.DEFAULT_GUEST_HOSTNAME) + else stringResource(R.string.perf_hostname_invalid), + ) { + OutlinedTextField( + hostnameDraft, { v -> + hostnameDraft = v.take(63) + if (hostnameDraft.isBlank() || SessionPrefs.validGuestHostname(hostnameDraft) != null) onGuestHostname(hostnameDraft) + }, + singleLine = true, isError = !valid && hostnameDraft.isNotBlank(), + placeholder = { Text(SessionPrefs.DEFAULT_GUEST_HOSTNAME) }, + modifier = Modifier.width(220.dp).focusGlide(), + ) + } + ToggleRow( + host, "desktopasuser", stringResource(R.string.perf_desktop_as_user), + stringResource(R.string.perf_desktop_as_user_hint), + desktopAsUser && nativeDesktopAvailable, enabled = nativeDesktopAvailable, + onChange = onDesktopAsUser, ) } } @@ -206,10 +216,7 @@ fun PerformancePage( } } } - if (embedded) Column { - Text(stringResource(R.string.perf_lede), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp, vertical = 6.dp)) - body() - } else SettingsPage( + if (embedded) body() else SettingsPage( host, title = stringResource(R.string.perf_title), lede = stringResource(R.string.perf_lede), onBack = onDismiss, @@ -218,7 +225,7 @@ fun PerformancePage( @Composable internal fun GpuClockGroup(host: MenuHost, on: Boolean, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) { - SettingsGroup(stringResource(R.string.perf_gpu)) { + SettingsGroup(stringResource(R.string.perf_gpu), key = "performance-gpu") { ToggleRow( host, "gpuclock", stringResource(R.string.perf_gpuclock), null, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ResolutionRow.kt b/app/src/main/java/com/droiddeck/launcher/ui/ResolutionRow.kt index ca9ca5976c..34121eb342 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ResolutionRow.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ResolutionRow.kt @@ -16,12 +16,14 @@ fun ResolutionRow( panel: Pair, onPick: (String) -> Unit, chipModifier: Modifier = Modifier, portrait: Boolean = false, + defaultChoice: String = SessionDisplay.DEFAULT_RESOLUTION, ) { val custom = "custom" val linked = stored == link val size = SessionDisplay.resolveChoice(panel, choice, portrait) val screen = SessionDisplay.resolveChoice(panel, SessionDisplay.MATCH_SCREEN, portrait) - val choices = SessionDisplay.resolutionOptions(panel) + val presets = SessionDisplay.resolutionOptions(panel) + val choices = if (defaultChoice == SessionDisplay.DEFAULT_RESOLUTION) presets else listOf(defaultChoice) + presets val customFollow = !linked && SessionDisplay.isFollow(choice) && choice !in choices val selected = if (linked) link else if (SessionDisplay.isFollow(choice)) choice else if (size == screen) SessionDisplay.MATCH_SCREEN else choice @@ -36,7 +38,7 @@ fun ResolutionRow( else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen) else if (SessionDisplay.isFollow(value)) stringResource(R.string.display_follow_screen_scaled, SessionDisplay.formatScale(SessionDisplay.followScale(value) ?: 1f)) + " (${dimensions.first}×${dimensions.second})" - else if (value == SessionDisplay.DEFAULT_RESOLUTION) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}") + else if (value == defaultChoice) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}") else "${dimensions.first}×${dimensions.second}" } + listOf(SessionDisplay.FOLLOW_CUSTOM to stringResource(R.string.display_follow_screen_scaled, if (customFollow) SessionDisplay.formatScale(SessionDisplay.followScale(choice) ?: 1f) else "…" diff --git a/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt index 2504a2eee3..e9e09f7e45 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/RomsDialog.kt @@ -3,6 +3,8 @@ package com.droiddeck.launcher.ui import androidx.compose.foundation.shape.CircleShape import com.droiddeck.launcher.R import androidx.compose.ui.res.stringResource +import androidx.compose.ui.platform.LocalContext +import com.droiddeck.launcher.session.SessionPrefs import androidx.compose.foundation.layout.Column import androidx.compose.ui.Modifier import androidx.compose.foundation.layout.Spacer @@ -22,7 +24,7 @@ fun RomsDialog(path: String?, onChoose: () -> Unit, onClear: () -> Unit, onDismi text = { Column { Text( - stringResource(R.string.roms_text), + stringResource(if (SessionPrefs.mountSharedStorage(LocalContext.current)) R.string.roms_text else R.string.roms_text_unmounted), style = MaterialTheme.typography.bodyMedium, ) Spacer(Modifier.height(10.dp)) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ScalingFilterMenu.kt b/app/src/main/java/com/droiddeck/launcher/ui/ScalingFilterMenu.kt new file mode 100644 index 0000000000..b012bb1292 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/ScalingFilterMenu.kt @@ -0,0 +1,69 @@ +package com.droiddeck.launcher.ui + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.droiddeck.launcher.R + +@Composable +internal fun ScalingFilterMenu( + mode: Int, + options: List>, + hasGameOverride: Boolean, + onPick: (Int) -> Unit, + onResetGame: () -> Unit, + gameName: String? = null, +) { + val colors = MaterialTheme.colorScheme + Column(Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, bottom = 8.dp)) { + val selectedLabel = options.firstOrNull { it.first == mode }?.second ?: mode.toString() + Text( + stringResource( + if (hasGameOverride) R.string.display_filter_game_profile else R.string.display_filter_default_profile, + if (hasGameOverride) gameName.orEmpty() else selectedLabel, + selectedLabel, + ), + color = colors.onSurfaceVariant, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(bottom = 6.dp), + ) + options.forEachIndexed { index, (option, label) -> + val selected = mode == option + val pick = { onPick(option) } + OutlinedButton( + onClick = pick, + modifier = Modifier.fillMaxWidth() + .padding(top = if (index == 0) 0.dp else 6.dp) + .controllerConfirm(onClick = pick), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + colors = ButtonDefaults.outlinedButtonColors( + containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface, + contentColor = if (selected) colors.primary else colors.onSurface, + ), + ) { Text(label) } + } + Text( + stringResource(R.string.display_filter_note), + color = colors.onSurfaceVariant, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(top = 6.dp), + ) + OutlinedButton( + onClick = onResetGame, + modifier = Modifier.fillMaxWidth().padding(top = 6.dp) + .controllerConfirm(onClick = onResetGame), + contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp), + ) { + Text(stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓") + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ScreenTaps.kt b/app/src/main/java/com/droiddeck/launcher/ui/ScreenTaps.kt index 20c942dea6..d61e51bdd7 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ScreenTaps.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ScreenTaps.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.ui import android.content.Context +import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.EditText import androidx.compose.foundation.gestures.awaitEachGesture @@ -48,10 +49,18 @@ internal fun releaseTextField(field: EditText, origin: IntArray, x: Float, y: Fl val insideX = x >= origin[0] - margin && x <= origin[0] + field.width + margin val insideY = y >= origin[1] - margin && y <= origin[1] + field.height + margin if (insideX && insideY) return + releaseTextField(field) +} + +internal fun releaseTextField(field: EditText) { field.clearFocus() (field.context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager)?.hideSoftInputFromWindow(field.windowToken, 0) } +internal fun releaseFocusedTextField(view: View) { + (view.rootView.findFocus() as? EditText)?.let(::releaseTextField) +} + /** A dialog's touches never reach the activity, so a dialog holding a search field counts its taps and releases the field itself. */ internal fun Modifier.releaseTextFieldOnTap(): Modifier = composed { val view = LocalView.current diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt b/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt index ff0400860c..508c0f4ea9 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SecondScreenPresentation.kt @@ -15,12 +15,18 @@ import android.view.WindowManager import android.widget.FrameLayout import android.widget.LinearLayout import androidx.activity.setViewTreeOnBackPressedDispatcherOwner +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandLess +import androidx.compose.material.icons.outlined.LightMode +import androidx.compose.material.icons.outlined.Tune import androidx.lifecycle.setViewTreeLifecycleOwner import androidx.lifecycle.setViewTreeViewModelStoreOwner import androidx.savedstate.setViewTreeSavedStateRegistryOwner +import com.droiddeck.launcher.input.ControllerPrefs import com.droiddeck.launcher.input.DeckPanel import com.droiddeck.launcher.input.KeyboardHost import com.droiddeck.launcher.input.PadBridge +import com.droiddeck.launcher.wayland.WaylandCompositor import com.droiddeck.launcher.input.SecondScreenMode import com.droiddeck.launcher.SessionActivity import com.droiddeck.launcher.session.BottomDesktop @@ -43,6 +49,7 @@ class SecondScreenPresentation( private val onMenuTouched: () -> Unit = {}, private val onDeckPanel: (DeckPanel) -> Unit = { SessionPrefs.setDeckPanel(sessionActivity, it) }, private val picker: ((SecondScreenMode) -> ScreenPicker?)? = null, + private val panel: (SecondScreenMode) -> (@androidx.compose.runtime.Composable () -> Unit)? = { null }, ) : Presentation(sessionActivity, display) { private val frame = FrameLayout(context) private var menuView: androidx.compose.ui.platform.ComposeView? = null @@ -67,6 +74,19 @@ class SecondScreenPresentation( var controlsView: InputSurfaceView? = null private set private var created = false + private val brightnessOpen = androidx.compose.runtime.mutableStateOf(false) + private val brightness = androidx.compose.runtime.mutableIntStateOf(BottomBrightness.MIN) + private val brightnessView by lazy { + androidx.compose.ui.platform.ComposeView(context).apply { + setContent { + DroidDeckTheme { + if (!BottomChrome.barShown && currentMode.hasBar) PullTab() + if (brightnessOpen.value) BrightnessDrop(brightness.intValue, ::setBrightness, + onScreenOff = { brightnessOpen.value = false; screenOff() }, onDismiss = { brightnessOpen.value = false }) + } + } + } + } init { setCancelable(false) @@ -80,6 +100,9 @@ class SecondScreenPresentation( window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) frame.addView(root, FrameLayout.LayoutParams(-1, -1)) + frame.addView(brightnessView, FrameLayout.LayoutParams(-1, -1)) + frame.addView(sleepView, FrameLayout.LayoutParams(-1, -1)) + light(BottomScreenLight.ON) setContentView(frame) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { root.setOnApplyWindowInsetsListener { view, insets -> @@ -94,6 +117,7 @@ class SecondScreenPresentation( fun requestKeyboard(forField: Boolean = false) { if (!showsKeyboard || keyboardHost == null) return + wake() if (forField) fieldKeyboard = true keyboardPending = true if (window?.decorView?.hasWindowFocus() == true) showPendingKeyboard() @@ -127,6 +151,8 @@ class SecondScreenPresentation( fun showMode(mode: SecondScreenMode) { if (currentMode == mode && isShowing) return currentMode = mode + brightnessOpen.value = false + BottomChrome.reset() if (created) renderMode() } @@ -136,6 +162,7 @@ class SecondScreenPresentation( fun showChat(onLost: () -> Unit, content: @androidx.compose.runtime.Composable () -> Unit) { if (!showsKeyboard || chatView != null) return + wake() keyboardHost?.takeIf { it.shown }?.hide() keyboardShown.value = false keyboardPending = false @@ -174,6 +201,7 @@ class SecondScreenPresentation( val content = menu ?: return menuShown = on if (on) { + wake() keyboardHost?.takeIf { it.shown }?.hide() keyboardShown.value = false ownComposeViews() @@ -192,6 +220,7 @@ class SecondScreenPresentation( menuView?.let { frame.removeView(it); it.disposeComposition() } menuView = null root.visibility = View.VISIBLE + scheduleDim() } } @@ -223,21 +252,93 @@ class SecondScreenPresentation( } override fun dispatchKeyEvent(event: KeyEvent): Boolean { - val ownKeys = currentMode == SecondScreenMode.TERMINAL || currentMode == SecondScreenMode.DASHBOARD || + val ownKeys = currentMode == SecondScreenMode.TERMINAL || currentMode == SecondScreenMode.DASHBOARD || currentMode.sessionPanel || currentMode == SecondScreenMode.DESKTOP val back = event.keyCode == KeyEvent.KEYCODE_BACK && currentMode == SecondScreenMode.DASHBOARD - val forward = menuShown || !ownKeys || back || PadBridge.isControllerKeyEvent(event) + val pad = PadBridge.isControllerKeyEvent(event) + if (!pad) uiActivity() + val forward = menuShown || !ownKeys || back || pad if (forward && sessionActivity.dispatchKeyEvent(event)) return true return super.dispatchKeyEvent(event) } override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.actionMasked == MotionEvent.ACTION_DOWN && screen == BottomScreenLight.ON) waking = false + if (screen != BottomScreenLight.ON || waking) { + // The touch that wakes the screen is swallowed whole, so its release does not click what is under it. + when (event.actionMasked) { + MotionEvent.ACTION_DOWN -> if (screen != BottomScreenLight.ON) { waking = true; wake() } + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> waking = false + } + return true + } + scheduleDim() if (menuShown && event.actionMasked == MotionEvent.ACTION_DOWN) onMenuTouched() return super.dispatchTouchEvent(event) } + private val sleepView = View(context).apply { + setBackgroundColor(Color.BLACK) + visibility = View.GONE + } + private var screen = BottomScreenLight.ON + private var waking = false + private val dim = Runnable { if (screen == BottomScreenLight.ON) light(BottomScreenLight.DIM) } + + fun screenOff() { + // A control held by another finger would keep its press, since the screen-off overlay takes the release. + controlsView?.releaseInputs() + light(BottomScreenLight.OFF) + } + + /** Keyboard or mouse use of the bottom screen's own UI counts as activity; an explicit screen off stays off. */ + private fun uiActivity() { + when (screen) { + BottomScreenLight.DIM -> wake() + BottomScreenLight.ON -> scheduleDim() + BottomScreenLight.OFF -> Unit + } + } + + fun wake() { + light(BottomScreenLight.ON) + scheduleDim() + } + + private fun light(state: BottomScreenLight) { + screen = state + sleepView.visibility = if (state == BottomScreenLight.OFF) View.VISIBLE else View.GONE + sleepView.alpha = 1f + val w = window ?: return + w.attributes = w.attributes.apply { + screenBrightness = when (state) { + BottomScreenLight.ON -> BottomBrightness.level(context) ?: state.brightness + BottomScreenLight.DIM -> BottomBrightness.dimmed(context, state.brightness) + BottomScreenLight.OFF -> state.brightness + } + } + } + + private fun toggleBrightness() { + if (!brightnessOpen.value) brightness.intValue = BottomBrightness.initial(context) + brightnessOpen.value = !brightnessOpen.value + } + + private fun setBrightness(percent: Int) { + val value = BottomBrightness.clamp(percent) + brightness.intValue = value + SessionPrefs.setBottomBrightness(context, value) + if (screen == BottomScreenLight.ON) light(BottomScreenLight.ON) + } + + private fun scheduleDim() { + frame.removeCallbacks(dim) + if (!menuShown && BottomScreenLight.autoDims(currentMode) && SessionPrefs.bottomAutoDim(context)) frame.postDelayed(dim, BottomScreenLight.DIM_AFTER_MS) + } + override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean { if (PadBridge.isControllerMotionEvent(event) && sessionActivity.dispatchGenericMotionEvent(event)) return true + if (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE)) uiActivity() return super.dispatchGenericMotionEvent(event) } @@ -266,6 +367,7 @@ class SecondScreenPresentation( } private fun renderMode() { + if (created) wake() dropChat() fieldKeyboard = false keyboardHost?.hide() @@ -282,6 +384,7 @@ class SecondScreenPresentation( val mode = when { requested == SecondScreenMode.DECK_CONTROLS && !SessionState.deckPad -> SecondScreenMode.NONE requested == SecondScreenMode.DASHBOARD && dashboard == null -> SecondScreenMode.NONE + requested.sessionPanel && panel(requested) == null -> SecondScreenMode.NONE requested == SecondScreenMode.DESKTOP && !BottomDesktop.available() -> SecondScreenMode.NONE else -> requested } @@ -295,11 +398,13 @@ class SecondScreenPresentation( val layout = panelLayout(mode) val controls = InputSurfaceView(context, pad, layout?.elements.orEmpty(), surfaceStyle = layout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()) + controls.alpha = ControllerPrefs.onScreenOpacity(context) / 100f controlsView = controls root.addView(controls, weightParams()) attachKeyboard() } SecondScreenMode.DASHBOARD -> renderDashboard() + SecondScreenMode.GUIDES, SecondScreenMode.MIRROR, SecondScreenMode.STEAM_QAM, SecondScreenMode.ART -> renderPanel(mode) SecondScreenMode.DESKTOP -> { root.addView(BottomDesktopPanel(context, onClose, onMenu, (onSteamMenu to onQam).takeIf { SessionState.mode == SessionService.MODE_STEAM }, onSwap, @@ -314,21 +419,47 @@ class SecondScreenPresentation( private fun bar(mode: SecondScreenMode) { val first = barModel(mode) ?: return - root.addView(bottomScreenBarView(context) { barModel(mode) ?: first }, LinearLayout.LayoutParams(-1, -2)) + root.addView(androidx.compose.ui.platform.ComposeView(context).apply { + setContent { + DroidDeckTheme { + androidx.compose.animation.AnimatedVisibility(BottomChrome.barShown, + enter = androidx.compose.animation.expandVertically(), exit = androidx.compose.animation.shrinkVertically()) { + BottomScreenBar(barModel(mode) ?: first) + } + } + } + }, LinearLayout.LayoutParams(-1, -2)) } internal fun barModel(mode: SecondScreenMode): BottomBarModel? { - val swap = listOfNotNull(onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, tag = "bottom-swap", onClick = it) }) + val extras = listOfNotNull(onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, tag = "bottom-swap", onClick = it) }) + + BarExtra(context.getString(R.string.bottom_brightness), vector = Icons.Outlined.LightMode, active = brightnessOpen.value, + tag = "bottom-brightness-toggle", onClick = ::toggleBrightness) + + BarExtra(context.getString(R.string.bottom_bar_hide), vector = Icons.Outlined.ExpandLess, tag = "bottom-bar-hide") { + brightnessOpen.value = false + BottomChrome.show(false) + } fun model(extras: List, tabs: BarTabs? = null) = sessionBarModel(context.getString(mode.label), onClose, onMenu, onSteamMenu, onQam, extras, tabs, picker?.invoke(mode)) return when (mode) { SecondScreenMode.KEYBOARD_TRACKPAD -> model(listOf(BarExtra( context.getString(if (keyboardShown.value) R.string.second_hide_keyboard else R.string.second_show_keyboard), - icon = R.drawable.ic_bottom_keyboard, active = keyboardShown.value, tag = "bottom-keyboard") { showKeyboard() }) + swap) - SecondScreenMode.DECK_CONTROLS -> model(swap, deckPanelTabs(context, deckPanel.value, ::selectDeckPanel)) - SecondScreenMode.DASHBOARD, SecondScreenMode.CUSTOM_CONTROLS -> model(swap) + icon = R.drawable.ic_bottom_keyboard, active = keyboardShown.value, tag = "bottom-keyboard") { showKeyboard() }) + extras) + SecondScreenMode.DECK_CONTROLS -> model(extras, deckPanelTabs(context, deckPanel.value, ::selectDeckPanel)) + SecondScreenMode.STEAM_QAM -> { + val fit = QamFit.current(context) + model(listOf(BarExtra(context.getString(R.string.bottom_qam_layout, context.getString(fit.label)), vector = fit.icon, + tag = "bottom-qam-layout") { QamFit.choose(context, fit.next) }) + extras) + } + SecondScreenMode.MIRROR -> model(listOf(BarExtra(context.getString(R.string.bottom_mirror_options), vector = Icons.Outlined.Tune, + active = MirrorOptions.open.value, tag = "bottom-mirror-options-toggle") { + brightnessOpen.value = false + MirrorOptions.open.value = !MirrorOptions.open.value + }) + extras) + SecondScreenMode.DASHBOARD, SecondScreenMode.CUSTOM_CONTROLS, SecondScreenMode.GUIDES, + SecondScreenMode.ART -> model(extras) SecondScreenMode.TERMINAL -> model(listOf(BarExtra(context.getString(R.string.drawer_keyboard), icon = R.drawable.ic_bottom_keyboard, - tag = "bottom-keyboard") { terminalPanel?.showKeyboard() }) + swap) + tag = "bottom-keyboard") { terminalPanel?.showKeyboard() }) + extras) else -> null } } @@ -348,18 +479,33 @@ class SecondScreenPresentation( root.addView(view, weightParams()) } + private fun renderPanel(mode: SecondScreenMode) { + val content = panel(mode) ?: return + bar(mode) + val view = androidx.compose.ui.platform.ComposeView(context).apply { setContent { PresentationWindows(content) } } + dashboardView = view + root.addView(view, weightParams()) + } + private fun closeDashboard() { dashboardView?.disposeComposition() dashboardView = null } private fun attachKeyboard() { - val host = KeyboardHost(context) { event -> - val handled = sessionActivity.dispatchKeyEvent(event) - if (fieldKeyboard && event.action == KeyEvent.ACTION_UP && - (event.keyCode == KeyEvent.KEYCODE_ENTER || event.keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER)) root.post { closeFieldKeyboard() } - handled - } + val host = KeyboardHost( + context, + sendKeyEvent = { event -> + val handled = sessionActivity.dispatchImeKeyEvent(event) + if (fieldKeyboard && event.action == KeyEvent.ACTION_UP && + (event.keyCode == KeyEvent.KEYCODE_ENTER || event.keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER)) root.post { closeFieldKeyboard() } + handled + }, + sendText = { text -> + WaylandCompositor.textInputCommit(text) + if (fieldKeyboard && text == "\r") root.post { closeFieldKeyboard() } + }, + ) host.onImeChanged = { visible -> if (!visible && keyboardShown.value) keyboardClosed() } keyboardHost = host root.addView(host, ViewGroup.LayoutParams(1, 1)) @@ -396,3 +542,17 @@ class SecondScreenPresentation( private fun PresentationWindows(content: @androidx.compose.runtime.Composable () -> Unit) { androidx.compose.runtime.CompositionLocalProvider(LocalPresentationWindow provides true) { content() } } + +internal enum class BottomScreenLight(val brightness: Float) { + ON(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE), + DIM(0.05f), + OFF(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF); + + companion object { + const val DIM_AFTER_MS = 60_000L + fun autoDims(mode: SecondScreenMode) = mode == SecondScreenMode.DASHBOARD + } +} + +/** Modes drawn with the bottom bar, which the pull tab can bring back. */ +internal val SecondScreenMode.hasBar: Boolean get() = this != SecondScreenMode.NONE && this != SecondScreenMode.MENU && this != SecondScreenMode.DESKTOP diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt index b2bc10c8a4..f9e8924c8f 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionDrawerPage.kt @@ -6,21 +6,28 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import com.droiddeck.launcher.session.SessionPrefs +/** HUD holds the Performance page and GAMES the Game page; the names stay because saved page orders use them. */ internal enum class SessionDrawerPage(val firstControl: String) { - CONTROLLER("input-profile"), - GLASSES("glasses-game"), - DISPLAY("fg"), - HUD("hud"), - EFFECTS("look"), - GAMES("anisotropy"), - AGENT("agent-input"), - SESSION("suspend"), + CONTROLLER("section-controller-input"), + HUD("section-performance-pacing"), + FRAMEGEN("fg"), + DISPLAY("section-display"), + EFFECTS("section-effects-look"), + GAMES("section-game-profile"), + VR("section-vr-steamvr"), + SESSION("pause"), MORE("more-edit"), - VR("steamvr"), + ACHIEVEMENTS("achievements"), + AGENT("agent-input"), } internal object DrawerPages { - var order by mutableStateOf(SessionDrawerPage.entries.toList()) + private val defaultOrder = SessionDrawerPage.entries.toMutableList().apply { + remove(SessionDrawerPage.VR) + add(indexOf(SessionDrawerPage.MORE) + 1, SessionDrawerPage.VR) + }.toList() + + var order by mutableStateOf(defaultOrder) private set var hidden by mutableStateOf(emptySet()) private set @@ -37,6 +44,7 @@ internal object DrawerPages { } fun arrange(saved: List): List { + if (saved.isEmpty()) return defaultOrder val all = SessionDrawerPage.entries val out = saved.mapNotNull { name -> all.firstOrNull { it.name == name } }.distinct().toMutableList() for (page in all.filterNot { it in out }) { @@ -60,27 +68,27 @@ internal object DrawerPages { } fun reset(context: Context) { - order = SessionDrawerPage.entries.toList() + order = defaultOrder hidden = emptySet() if (DevPreview.drawer != null) return SessionPrefs.setDrawerPageOrder(context, order.map { it.name }) SessionPrefs.setDrawerPageHidden(context, emptySet()) } - fun isDefault() = order == SessionDrawerPage.entries.toList() && hidden.isEmpty() + fun isDefault() = order == defaultOrder && hidden.isEmpty() } internal fun offeredDrawerPages( - hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, + hasAchievements: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, ): List = DrawerPages.order.filter { - (hasGlasses || it != SessionDrawerPage.GLASSES) && + (hasAchievements || it != SessionDrawerPage.ACHIEVEMENTS) && (hasAgent || it != SessionDrawerPage.AGENT) } internal fun sessionDrawerPages( - hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, -): List = offeredDrawerPages(hasGlasses, hasAgent).filter { it !in DrawerPages.hidden } + hasAchievements: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown, +): List = offeredDrawerPages(hasAchievements, hasAgent).filter { it !in DrawerPages.hidden } /** The pages shown as tabs: everything up to and including the More tab. */ internal fun List.strip(): List { diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index d4b22a2909..e014982138 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -16,11 +16,15 @@ import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.type import androidx.compose.ui.layout.LayoutCoordinates +import androidx.compose.ui.unit.Constraints +import androidx.compose.ui.layout.Layout import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.unit.LayoutDirection import kotlin.math.roundToInt import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay @@ -37,6 +41,7 @@ import androidx.compose.material.icons.outlined.DesktopWindows import androidx.compose.material.icons.outlined.Keyboard import androidx.compose.material.icons.outlined.AutoFixHigh import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material.icons.outlined.EmojiEvents import androidx.compose.material.icons.outlined.Home import androidx.compose.material.icons.outlined.MoreHoriz import androidx.compose.material.icons.automirrored.outlined.ArrowBack @@ -72,6 +77,7 @@ import androidx.compose.foundation.interaction.PressInteraction import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight @@ -81,6 +87,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.systemGestureExclusion import androidx.compose.foundation.ScrollState import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.rememberScrollState @@ -88,6 +95,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Slider import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -95,6 +103,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.unit.Dp import androidx.compose.runtime.rememberUpdatedState @@ -107,6 +116,11 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.droiddeck.launcher.HomeApp +import com.droiddeck.launcher.input.AirTrigger +import com.droiddeck.launcher.input.AirTriggerAction +import com.droiddeck.launcher.input.AirTriggerLed +import com.droiddeck.launcher.input.RapidFireRate +import com.droiddeck.launcher.input.ControllerPrefs import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.Spring @@ -152,6 +166,7 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.res.stringResource +import androidx.compose.ui.res.vectorResource import androidx.compose.ui.platform.LocalContext import com.droiddeck.launcher.R import com.droiddeck.launcher.core.FexPreset @@ -162,6 +177,7 @@ import com.droiddeck.launcher.gpu.ScreenEffectLooks import com.droiddeck.launcher.gpu.Cardboard import com.droiddeck.launcher.gpu.SteamVr import com.droiddeck.launcher.gpu.ScreenEffects +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.ComponentsManager import com.droiddeck.launcher.input.PC_KEY_GROUP_IDS @@ -175,12 +191,13 @@ import java.util.Locale internal val SessionDrawerPage.title: Int get() = when (this) { SessionDrawerPage.CONTROLLER -> R.string.drawer_page_controller - SessionDrawerPage.GLASSES -> R.string.drawer_page_glasses SessionDrawerPage.DISPLAY -> R.string.drawer_page_display - SessionDrawerPage.HUD -> R.string.drawer_hud - SessionDrawerPage.VR -> R.string.vr_title + SessionDrawerPage.HUD -> R.string.drawer_page_performance + SessionDrawerPage.FRAMEGEN -> R.string.frame_gen_title + SessionDrawerPage.VR -> R.string.drawer_page_vr SessionDrawerPage.EFFECTS -> R.string.drawer_page_effects - SessionDrawerPage.GAMES -> R.string.game_settings_title + SessionDrawerPage.GAMES -> R.string.drawer_page_game + SessionDrawerPage.ACHIEVEMENTS -> R.string.achievements_title SessionDrawerPage.AGENT -> R.string.rail_agent SessionDrawerPage.SESSION -> R.string.mode_session SessionDrawerPage.MORE -> R.string.drawer_page_more @@ -188,12 +205,13 @@ internal val SessionDrawerPage.title: Int get() = when (this) { internal val SessionDrawerPage.icon get() = when (this) { SessionDrawerPage.CONTROLLER -> Icons.Outlined.SportsEsports - SessionDrawerPage.GLASSES -> GlassesIcon SessionDrawerPage.DISPLAY -> Icons.Outlined.DesktopWindows SessionDrawerPage.HUD -> Icons.Outlined.Speed + SessionDrawerPage.FRAMEGEN -> Icons.Outlined.Layers SessionDrawerPage.VR -> VrHeadsetIcon SessionDrawerPage.EFFECTS -> Icons.Outlined.AutoFixHigh SessionDrawerPage.GAMES -> Icons.Outlined.Layers + SessionDrawerPage.ACHIEVEMENTS -> Icons.Outlined.EmojiEvents SessionDrawerPage.AGENT -> Icons.Outlined.Terminal SessionDrawerPage.SESSION -> Icons.Outlined.Settings SessionDrawerPage.MORE -> Icons.Outlined.MoreHoriz @@ -205,9 +223,15 @@ private class DrawerFocus { var focused by mutableStateOf(null) private set + private val sectionOrder = mutableMapOf>() + private fun requester(key: String) = requesters.getOrPut(key) { FocusRequester() } - fun track(page: SessionDrawerPage, key: String): Modifier = Modifier.focusRequester(requester(key)).onFocusChanged { + fun sections(page: SessionDrawerPage): List = sectionOrder[page]?.toList().orEmpty() + + fun track(page: SessionDrawerPage, key: String): Modifier = Modifier.focusRequester(requester(key)).also { + if (key.startsWith("section-")) sectionOrder.getOrPut(page) { LinkedHashSet() }.add(key) + }.onFocusChanged { if (it.isFocused) { last[page] = key focused = key @@ -219,6 +243,12 @@ private class DrawerFocus { fun forget(page: SessionDrawerPage) { last.remove(page) } } +data class AirTriggerMenu( + val enabled: Boolean, val selected: Map, val buttons: List>, + val vibration: Boolean = false, val screenLight: Boolean = false, val led: AirTriggerLed = AirTriggerLed.STEADY, + val actions: Map = emptyMap(), val rates: Map = emptyMap(), +) + class DrawerActions( val steam: Boolean, val desktop: Boolean, @@ -258,6 +288,11 @@ class DrawerActions( val upscaleSharpness: Int = 75, val integerScaling: Boolean = false, val onIntegerScaling: (Boolean) -> Unit = {}, + val picturePosition: String = "center", + val onPicturePosition: (String) -> Unit = {}, + val gameZoomAvailable: Boolean = false, + val gameZoom: Float = 1.0f, + val onGameZoom: (Float) -> Unit = {}, val effects: ScreenEffects = ScreenEffects.OFF, val screenEffectsTarget: String = "auto", val screenEffectsTargets: List> = emptyList(), @@ -302,7 +337,6 @@ class DrawerActions( val hdr: Boolean = false, val hdrAvailable: Boolean = false, val onHdr: (Boolean) -> Unit = {}, - val onImportLossless: () -> Unit, val onKeyboard: () -> Unit, val onHardwareKeyboard: () -> Unit, val wowChatShown: Boolean = false, @@ -310,12 +344,24 @@ class DrawerActions( val onWowChat: (String?) -> Unit = {}, val onSteamMenu: (() -> Unit)?, val onQam: (() -> Unit)?, - val onAchievements: (() -> Unit)? = null, + val controllerConnected: Boolean = false, + val achievementsGame: com.droiddeck.launcher.stores.StoreAchievements.Game? = null, + val achievementsTitle: String? = null, val achievementsProgress: Pair? = null, val onOsc: (String) -> Unit, val onEditSteamTouch: (() -> Unit)? = null, val controller: com.droiddeck.launcher.input.ControllerPrefs.Settings? = null, + val onControllerSize: (Int) -> Unit = {}, + val onControllerOpacity: (Int) -> Unit = {}, val onRumble: (Boolean) -> Unit = {}, + val airTriggers: AirTriggerMenu? = null, + val onAirTriggers: (Boolean) -> Unit = {}, + val onAirTriggerButton: (AirTrigger, String) -> Unit = { _, _ -> }, + val onAirTriggerAction: (AirTrigger, AirTriggerAction) -> Unit = { _, _ -> }, + val onAirTriggerRate: (AirTrigger, RapidFireRate) -> Unit = { _, _ -> }, + val onAirTriggerVibration: (Boolean) -> Unit = {}, + val onAirTriggerScreenLight: (Boolean) -> Unit = {}, + val onAirTriggerLed: (AirTriggerLed) -> Unit = {}, val onSuspendPolicy: (String) -> Unit, val onSteamDownloadsInBackground: (Boolean) -> Unit = {}, val onBackActionsInverted: (Boolean) -> Unit, @@ -361,11 +407,16 @@ class DrawerActions( val paused: Boolean = false, val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, val onOrientation: (Int) -> Unit = {}, + val fullscreenMode: FullscreenMode = FullscreenMode.ALWAYS, + val onFullscreenMode: (FullscreenMode) -> Unit = {}, val onResume: () -> Unit = {}, val onPipAutoEnter: (Boolean) -> Unit = {}, val unfoldedControls: Boolean? = null, val adaptiveSticks: Boolean? = null, val onAdaptiveSticks: (Boolean) -> Unit = {}, + /** dd-directcontroller's mode for the running game; null = the game does not use it. */ + val directController: Boolean? = null, + val onDirectController: (Boolean) -> Unit = {}, val showFloatingSteamControls: Boolean = false, val oscRearButtons: Boolean = false, val oscTrackpads: Boolean = false, @@ -374,6 +425,8 @@ class DrawerActions( val quickButtons: Map = emptyMap(), val onQuickButton: (com.droiddeck.launcher.input.InputCommand, Boolean) -> Unit = { _, _ -> }, val onUnfoldedControls: (Boolean) -> Unit = {}, + val deckPanel: com.droiddeck.launcher.input.DeckPanel? = null, + val onDeckPanel: (com.droiddeck.launcher.input.DeckPanel) -> Unit = {}, val unfoldedControlsWithController: Boolean = false, val onUnfoldedControlsWithController: (Boolean) -> Unit = {}, val onShareLogs: () -> Unit, @@ -414,7 +467,7 @@ class DrawerActions( @Composable internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, controllerActive: Boolean, onPageChange: (SessionDrawerPage) -> Unit, a: DrawerActions, docked: Boolean = false, backRequest: Int = 0, onLayerChange: (Boolean) -> Unit = {}) { - val pages = sessionDrawerPages(a.glassesPresent) + val pages = sessionDrawerPages(a.achievementsGame != null) val page = requestedPage.takeIf { it in pages } ?: pages.first() var managing by rememberSaveable { mutableStateOf(false) } var releaseSignal by remember { mutableStateOf(0) } @@ -424,37 +477,32 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont val pal = LocalPalette.current val host = rememberMenuHost() val (glasses, glassesSettings) = rememberGlasses() - val glassesPages = glassesTabs(glasses) + (GlassesTab.CONTROLLERS to stringResource(R.string.vr_controllers_tab)) - var selectedGlassesTab by rememberSaveable { mutableStateOf(GlassesTab.DISPLAY) } - val glassesTab = selectedGlassesTab.takeIf { key -> glassesPages.any { it.first == key } } ?: GlassesTab.DISPLAY - var androidAppsExpanded by rememberSaveable { mutableStateOf(false) } - var advancedEffectsExpanded by rememberSaveable { mutableStateOf(false) } + remember { DrawerSectionState.load(drawerContext) } var appToChooseDisplay by remember { mutableStateOf(null) } var confirmStop by remember { mutableStateOf(false) } + var airTriggersShown by remember { mutableStateOf(false) } var sheetCoords by remember { mutableStateOf(null) } val widthContext = LocalContext.current var savedWidth by remember { mutableStateOf(SessionPrefs.drawerWidthDp(widthContext)) } var stopCoords by remember { mutableStateOf(null) } val pageScroll = remember { SessionDrawerPage.entries.associateWith { ScrollState(0) } } - LaunchedEffect(glassesTab) { - if (page == SessionDrawerPage.GLASSES) host.open = null - pageScroll.getValue(SessionDrawerPage.GLASSES).scrollTo(0) - } val veil by animateFloatAsState(if (open) 1f else 0f, Motion.tw(260), label = "veil") val focus = remember { DrawerFocus() } val inputModeManager = LocalInputModeManager.current val focusManager = LocalFocusManager.current // A page kept inside More is one step deeper than the strip: back returns to More before it closes the menu. val insideMore = page in pages.inMore() + val airPanel = airTriggersShown && page == SessionDrawerPage.CONTROLLER && a.airTriggers != null BackHandler(enabled = open) { when { host.open != null -> host.open = null + airPanel -> airTriggersShown = false insideMore -> onPageChange(SessionDrawerPage.MORE) else -> a.onClose() } } BackHandler(enabled = open && confirmStop) { confirmStop = false } - val layerOpen = open && (host.open != null || appToChooseDisplay != null || confirmStop || insideMore) + val layerOpen = open && (host.open != null || appToChooseDisplay != null || confirmStop || insideMore || airPanel) LaunchedEffect(layerOpen) { onLayerChange(layerOpen) } var seenBackRequest by remember { mutableStateOf(backRequest) } LaunchedEffect(backRequest) { @@ -464,10 +512,30 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont confirmStop -> confirmStop = false appToChooseDisplay != null -> appToChooseDisplay = null host.open != null -> host.open = null + airPanel -> airTriggersShown = false insideMore -> onPageChange(SessionDrawerPage.MORE) } } - LaunchedEffect(page) { host.open = null; appToChooseDisplay = null; managing = false } + LaunchedEffect(page) { host.open = null; appToChooseDisplay = null; managing = false; airTriggersShown = false } + var airPanelFocused by remember { mutableStateOf(airPanel) } + LaunchedEffect(airPanel) { + val moved = airPanel != airPanelFocused + airPanelFocused = airPanel + if (!moved || !open || !controllerActive) return@LaunchedEffect + val target = if (airPanel) "air-triggers-toggle" else "air-triggers" + repeat(24) { + androidx.compose.runtime.withFrameNanos { } + focus.request(target) + if (focus.focused == target) return@LaunchedEffect + } + } + LaunchedEffect(host.open) { + if (host.open == "frame-generation") repeat(24) { + androidx.compose.runtime.withFrameNanos { } + focus.request("frame-generation") + if (focus.focused == "frame-generation") return@LaunchedEffect + } + } LaunchedEffect(a.selectedGameProfileId) { if (host.open == "fex") host.open = null } @@ -488,7 +556,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont if (open && !controllerActive) focusManager.clearFocus(force = true) } var focusedPage by remember { mutableStateOf(page) } - LaunchedEffect(open, page, glassesTab, controllerActive, host.open, appToChooseDisplay, confirmStop) { + LaunchedEffect(open, page, controllerActive, host.open, appToChooseDisplay, confirmStop) { if (!open) { host.open = null confirmStop = false @@ -497,24 +565,19 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont if (host.open != null || appToChooseDisplay != null || confirmStop) return@LaunchedEffect val turned = page != focusedPage focusedPage = page - val first = when { - page == SessionDrawerPage.GLASSES -> "glasses-tab-$glassesTab" - page == SessionDrawerPage.SESSION && a.isHomeApp -> "apps" - else -> page.firstControl - } if (turned) focus.forget(page) - val target = focus.target(page) ?: first + val target = focus.target(page) ?: page.firstControl repeat(24) { androidx.compose.runtime.withFrameNanos { } focus.request(target) if (focus.focused == target) return@LaunchedEffect } focus.forget(page) - focus.request(first) - if (first != page.firstControl) repeat(4) { + // Which sections a page shows depends on the session, so the first one shown takes focus. + for (key in listOf(page.firstControl) + focus.sections(page)) repeat(2) { androidx.compose.runtime.withFrameNanos { } - if (focus.focused == first) return@LaunchedEffect - focus.request(page.firstControl) + focus.request(key) + if (focus.focused == key) return@LaunchedEffect } } } @@ -529,8 +592,8 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont } androidx.compose.foundation.layout.BoxWithConstraints(modifier = Modifier.fillMaxSize().exposeTestTags(), contentAlignment = Alignment.CenterEnd) { val short = maxHeight < 440.dp - // The handle keeps a strip on the left free, so a sheet dragged wide can always be dragged back. - val maxSheet = (maxWidth - DRAWER_EDGE_GAP).coerceAtLeast(0.dp) + // At full width the handle's strip sits on the screen's left edge, so the sheet can still be dragged back. + val maxSheet = (maxWidth - DRAWER_HANDLE_STRIP).coerceAtLeast(0.dp) val minSheet = minOf(DRAWER_MIN_WIDTH, maxSheet) val defaultSheet = minOf(420.dp, maxWidth * 0.92f) val sheetWidth = if (docked) maxWidth else (savedWidth?.dp ?: defaultSheet).coerceIn(minSheet, maxSheet) @@ -551,6 +614,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont .controllerBack { when { host.open != null -> host.open = null + airPanel -> airTriggersShown = false managing -> DrawerPages.heldFrom?.let { held -> DrawerPages.rearrange(drawerContext, held) releaseSignal++ @@ -583,13 +647,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont focus.track(page, "screen").testTag("drawer-screen-picker"), ) } else if (roomyHeader) Spacer(Modifier.weight(1f)) - SteamActionPill( - stringResource(if (a.paused) R.string.resume_session else R.string.stores_dl_pause), - if (a.paused) Icons.Outlined.PlayArrow else Icons.Outlined.Pause, focus.track(page, "pause"), - ) { host.open = null; if (a.paused) a.onResume() else a.onPause() } - if (a.pipSupported) SteamActionPill( - stringResource(R.string.pip_title), Icons.Outlined.PictureInPictureAlt, focus.track(page, "pip"), - ) { host.open = null; a.onPip() } val steamActions = a.steam && a.onSteamMenu != null && a.onQam != null val qamInteraction = remember { MutableInteractionSource() } var qamStartedOnPress by remember { mutableStateOf(false) } @@ -622,12 +679,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont } StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true } } - a.onAchievements?.let { show -> - DrawerAchievementsRow(a.achievementsProgress, Modifier.padding(top = if (short) 6.dp else 10.dp).then(focus.track(page, "achievements"))) { - host.open = null; show() - } - } - Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 6.dp), @@ -640,16 +691,14 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont host.open = null; onPageChange(pages.strip().step(pages.tabFor(page), 1)) } } - if (insideMore && !managing) DrawerMoreBack(stringResource(page.title), focus.track(page, "more-back")) { host.open = null; onPageChange(SessionDrawerPage.MORE) } + if (insideMore && !managing && !airPanel) DrawerMoreBack(stringResource(page.title), focus.track(page, "more-back")) { host.open = null; onPageChange(SessionDrawerPage.MORE) } + if (airPanel && !managing) DrawerMoreBack(stringResource(R.string.air_triggers_title), focus.track(page, "air-triggers-back"), + parent = stringResource(page.title)) { host.open = null; airTriggersShown = false } if (managing) ManageDrawerPages( - offeredDrawerPages(a.glassesPresent), + offeredDrawerPages(a.achievementsGame != null), Modifier.weight(1f).fillMaxWidth().padding(top = 8.dp, start = 14.dp, end = 14.dp), releaseSignal, ) { managing = false } else { - if (page == SessionDrawerPage.GLASSES) SegmentedTabs( - glassesPages, glassesTab, modifier = Modifier.fillMaxWidth().padding(top = 8.dp), - tabModifier = { key -> focus.track(page, "glasses-tab-$key").testTag("glasses-tab-$key") }, - ) { selectedGlassesTab = it } // The agent's chat scrolls itself and keeps its composer at the bottom, so it takes the height left. if (page == SessionDrawerPage.AGENT) AgentPageWithControls( Modifier.weight(1f).fillMaxWidth().padding(top = 8.dp, start = 14.dp, end = 14.dp), @@ -659,336 +708,31 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont showControlsWithoutKeyboard = true, ) else Column( modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(pageScroll.getValue(page)), - ) { CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true) { + ) { + val track: (String) -> Modifier = { key -> focus.track(page, key) } + val sections = remember(page) { DrawerSections(drawerContext, track) } + CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true, LocalDrawerSections provides sections) { + DrawerColumns(two = sheetWidth >= DRAWER_TWO_COLUMN_WIDTH && page.inColumns) { when (page) { - SessionDrawerPage.HUD -> DroidDeckHudSettings(host, a) { key -> focus.track(page, key) } - SessionDrawerPage.DISPLAY -> { - SettingsGroup(stringResource(R.string.drawer_page_display)) { - val fgOpen = host.open == "fg" - val offLabel = stringResource(R.string.frame_gen_off) - val fgLabel = FrameGen.label(LocalContext.current, a.frameGen) - SettingsRow( - stringResource(R.string.frame_gen_title), - if (a.frameGenTargetGameId != null) - "${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}" - else stringResource(R.string.frame_gen_scope_global), - highlighted = fgOpen - ) { - Box { - ValueChip(fgLabel, fgOpen, modifier = focus.track(page, "fg")) { host.open = if (fgOpen) null else "fg" } - FrameGenMenu( - host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless, - gameProfileId = a.frameGenTargetGameId, - hasGameOverride = a.hasGameOverride, - onResetGame = a.onFrameGenReset, - ) - } - } - if (a.direct) SliderRow( - stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_note), - a.fpsLimit.takeIf { it > 0 } ?: SessionPrefs.FPS_LIMIT_OFF, - SessionPrefs.FPS_LIMIT_OFF..SessionPrefs.FPS_LIMIT_MAX, step = 5, - format = { if (it <= SessionPrefs.FPS_LIMIT_OFF) offLabel else it.toString() }, - modifier = focus.track(page, "fps-limit"), - onChange = { a.onFpsLimit(if (it <= SessionPrefs.FPS_LIMIT_OFF) 0 else it) }) - if (a.steam && !a.direct && a.onQam != null) SettingsRow( - stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_steam_hint), - ) { - DrawerOutlineButton(stringResource(R.string.drawer_open_steam_qam), modifier = focus.track(page, "fps-limit-steam")) { - host.open = null - a.onQam?.invoke() - } - } - } - SettingsGroup(stringResource(R.string.setup_orientation)) { - ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null, - SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }, - a.orientation, chipModifier = focus.track(page, "orientation"), onPick = a.onOrientation) - } - SettingsGroup(stringResource(R.string.display_image_scaling)) { - if (a.steam) SettingsRow(stringResource(R.string.display_integer_scaling), null) { - PadTextButton( - onClick = { a.onIntegerScaling(!a.integerScaling) } - ) { - Text(stringResource( - if (a.integerScaling) R.string.display_scaling_integer - else R.string.display_scaling_fit - )) - } - } - ChoiceRow(host, "upscaler", stringResource(R.string.display_filter), null, - SessionPrefs.upscalerChoices(LocalContext.current), a.upscaler, - note = stringResource(R.string.display_filter_note), - chipModifier = focus.track(page, "upscaler"), onPick = a.onUpscaler) - if (SessionPrefs.upscalerHasSharpness(a.upscaler)) SliderRow( - stringResource(R.string.display_sharpness), null, a.upscaleSharpness, 0..100, step = 5, - format = { "$it%" }, modifier = focus.track(page, "upscale-sharpness"), onChange = a.onUpscaleSharpness) - } - SecondScreenGroup(host, a) { key -> focus.track(page, key) } - } - SessionDrawerPage.EFFECTS -> { - ScreenEffectsGroup(host, a, advancedEffectsExpanded, - onAdvancedToggle = { advancedEffectsExpanded = !advancedEffectsExpanded }) { key -> focus.track(page, key) } - } - SessionDrawerPage.VR -> { - SteamVrGroup(a) { key -> focus.track(page, key) } - if (!a.glassesOutput) CardboardGroup(host, a) { key -> focus.track(page, key) } - } SessionDrawerPage.CONTROLLER -> { - SettingsGroup(stringResource(R.string.drawer_page_controller)) { - InputQuickSettings(host, desktop = a.desktop, onChanged = a.onInputSelection, onEdit = a.onInputSettings) { key -> focus.track(page, key) } - } - SettingsGroup(stringResource(R.string.input_device_settings)) { - a.padType?.let { type -> - ChoiceRow(host, "pad-type", stringResource(R.string.input_virtual_controller), stringResource(R.string.input_virtual_controller_hint), - listOf(SessionPrefs.CONTROLLER_DECK to stringResource(R.string.mode_controller_deck), - SessionPrefs.CONTROLLER_STEAM to stringResource(R.string.mode_controller_steam), - SessionPrefs.CONTROLLER_DS4 to stringResource(R.string.mode_controller_ds4), - SessionPrefs.CONTROLLER_DUALSENSE to stringResource(R.string.mode_controller_dualsense), - SessionPrefs.CONTROLLER_XBOX360 to stringResource(R.string.mode_controller_x360)), - type, chipModifier = focus.track(page, "pad-type"), onPick = a.onPadType) - } - a.controller?.let { c -> - ToggleRow(host, "rumble", stringResource(R.string.ctrl_rumble), null, c.rumble, - chipModifier = focus.track(page, "rumble"), onChange = a.onRumble) - - } - } - SettingsGroup(stringResource(R.string.input_touchscreen)) { - ChoiceRow(host, "touch", stringResource(R.string.input_touchscreen), stringResource(R.string.input_touchscreen_hint), - listOf(SessionPrefs.TOUCH_AUTO to stringResource(R.string.drawer_touch_auto, a.touchAuto), SessionPrefs.TOUCH_PAD to stringResource(R.string.mode_touch_touchpad), SessionPrefs.TOUCH_DIRECT to stringResource(R.string.mode_touch_direct), SessionPrefs.TOUCH_GESTURES to stringResource(R.string.mode_touch_gestures), SessionPrefs.TOUCH_OFF to stringResource(R.string.widgets_off)), - a.touchMode, chipModifier = focus.track(page, "touch"), onPick = a.onTouch) - if (a.touchActive == SessionPrefs.TOUCH_PAD) - RelativeMouseRow(host, a, focus.track(page, "relative-mouse")) - if (a.touchActive == SessionPrefs.TOUCH_DIRECT) - ToggleRow(host, "direct-cursor", stringResource(R.string.input_touch_cursor), - stringResource(R.string.input_touch_cursor_hint), a.directCursor, - chipModifier = focus.track(page, "direct-cursor"), onChange = a.onDirectCursor) - when (a.touchActive) { - SessionPrefs.TOUCH_GESTURES -> ActionRow(stringResource(R.string.gesture_settings), null, - stringResource(R.string.ctrl_edit), a.onGestureSettings, - modifier = focus.track(page, "gesture-settings")) - SessionPrefs.TOUCH_DIRECT -> ChoiceRow(host, "long-press", stringResource(R.string.input_touch_hold), stringResource(R.string.input_touch_hold_hint), - listOf(MOUSE_BEHAVIOR_NONE to stringResource(R.string.gesture_hold_left), - MOUSE_BEHAVIOR_CLICK to stringResource(R.string.gesture_right_click), - MOUSE_BEHAVIOR_HOLD to stringResource(R.string.gesture_hold_right)), - a.directHoldBehavior, chipModifier = focus.track(page, "long-press"), - onPick = a.onDirectHoldBehavior) - } - } - a.pen?.let { PenSettingsGroup(host, it, track = { key -> focus.track(page, key) }, onPick = a.onPen) } - SettingsGroup(stringResource(R.string.input_screen_visibility)) { - ChoiceRow(host, "osc", stringResource(R.string.mode_osc), null, - if (a.steam) listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_STEAM_TOUCH to stringResource(R.string.osc_steam_touch), SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)) - else listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)), - if (!a.steam && a.oscMode == SessionPrefs.OSC_STEAM_TOUCH) SessionPrefs.OSC_AUTO else a.oscMode, - chipModifier = focus.track(page, "osc"), onPick = a.onOsc) - a.adaptiveSticks?.let { on -> - ToggleRow(host, "adaptive-sticks", stringResource(R.string.ctrl_adaptive), null, on, - chipModifier = focus.track(page, "adaptive-sticks"), onChange = a.onAdaptiveSticks) - } - if (a.showFloatingSteamControls) { - ToggleRow(host, "rear-buttons", stringResource(R.string.osc_rear_buttons), null, a.oscRearButtons, - chipModifier = focus.track(page, "rear-buttons"), onChange = a.onOscRearButtons) - ToggleRow(host, "trackpads", stringResource(R.string.osc_trackpads), null, a.oscTrackpads, - chipModifier = focus.track(page, "trackpads"), onChange = a.onOscTrackpads) - } - for ((button, shown) in a.quickButtons) { - val key = "quick-${button.name.lowercase()}" - ToggleRow(host, key, stringResource(quickButtonLabel(button)), null, shown, - chipModifier = focus.track(page, key)) { a.onQuickButton(button, it) } - } - a.onEditSteamTouch?.let { edit -> - ActionRow(stringResource(R.string.osc_steam_layout), stringResource(R.string.osc_steam_layout_hint), stringResource(R.string.ctrl_edit), edit) - } - if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls), - stringResource(R.string.unfolded_controls_hint), a.unfoldedControls, - chipModifier = focus.track(page, "unfolded-controls"), onChange = a.onUnfoldedControls) - if (a.steam && a.unfoldedControls == true) ToggleRow(host, "unfolded-controls-with-controller", - stringResource(R.string.unfolded_controls_with_controller), - stringResource(R.string.unfolded_controls_with_controller_hint), a.unfoldedControlsWithController, - chipModifier = focus.track(page, "unfolded-controls-with-controller"), - onChange = a.onUnfoldedControlsWithController) - } - SettingsGroup(stringResource(R.string.shortcuts_title)) { - if (a.steam) ToggleRow(host, "back-hold", stringResource(R.string.back_hold), - stringResource(R.string.back_hold_hint), a.backHold, - chipModifier = focus.track(page, "back-hold"), onChange = a.onBackHold) - if (a.steam) ChoiceRow(host, "back-actions", stringResource(R.string.input_back_taps), stringResource(R.string.input_back_taps_hint), - listOf(false to stringResource(SessionPrefs.BACK_MENU_THEN_QAM), true to stringResource(SessionPrefs.BACK_QAM_THEN_MENU)), - a.backActionsInverted, chipModifier = focus.track(page, "back-actions"), onPick = a.onBackActionsInverted) - if (a.steam) ChoiceRow(host, "back-double-tap", stringResource(R.string.back_double_tap_window), null, - SessionPrefs.BACK_DOUBLE_TAP_MS_OPTIONS.map { it to stringResource(R.string.back_tap_ms, it) }, - a.backDoubleTapMs, chipModifier = focus.track(page, "back-double-tap"), onPick = a.onBackDoubleTapMs) - PhysicalShortcutRows(modifierFor = { focus.track(page, "physical-shortcut-${it.name}") }) - if (a.secondScreenDisplays.isNotEmpty()) ToggleRow(host, "docked-menu-controller", stringResource(R.string.drawer_docked_menu_controller), - null, a.dockedMenuController, - chipModifier = focus.track(page, "docked-menu-controller"), onChange = a.onDockedMenuController) - ToggleRow(host, "corner-tap", stringResource(R.string.drawer_corner_tap), - stringResource(R.string.drawer_corner_tap_hint), a.cornerTap, - chipModifier = focus.track(page, "corner-tap"), onChange = a.onCornerTap) - } - SettingsGroup(stringResource(R.string.drawer_latency)) { - ToggleRow(host, "low-latency", stringResource(R.string.drawer_low_latency), - stringResource(R.string.drawer_low_latency_hint), a.lowLatency, - chipModifier = focus.track(page, "low-latency"), onChange = a.onLowLatency) - ToggleRow(host, "evdev-mouse", stringResource(R.string.drawer_evdev_mouse), - null, a.evdevMouse, - chipModifier = focus.track(page, "evdev-mouse"), onChange = a.onEvdevMouse) - if (a.touchActive != SessionPrefs.TOUCH_PAD) - RelativeMouseRow(host, a, focus.track(page, "relative-mouse")) - } - SettingsGroup(stringResource(R.string.drawer_keyboard)) { - Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(8.dp)) { - DrawerOutlineButton(stringResource(R.string.drawer_pc_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(focus.track(page, "hardware"))) { - host.open = null; a.onHardwareKeyboard() - } - DrawerOutlineButton(stringResource(R.string.drawer_android_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(focus.track(page, "android"))) { - host.open = null; a.onKeyboard() - } - } - if (a.wowChatShown) ChoiceRow( - host, "wow-chat", stringResource(R.string.wow_chat_title), null, - listOf( - null to stringResource(R.string.wow_chat_ask), - SessionPrefs.WOW_CHAT_VOICE to stringResource(R.string.wow_chat_voice), - SessionPrefs.WOW_CHAT_KEYBOARD to stringResource(R.string.pckb_android), - ), - a.wowChat, chipModifier = focus.track(page, "wow-chat"), onPick = a.onWowChat, - ) - val keyboardContext = LocalContext.current - remember { PcKeyboardPrefs.load(keyboardContext) } - SliderRow( - stringResource(R.string.pckb_size), stringResource(R.string.pckb_size_hint), - PcKeyboardPrefs.size, SessionPrefs.PC_KEYBOARD_SIZE_RANGE, step = 1, - format = { "$it%" }, modifier = focus.track(page, "pckb-size"), - onChange = { PcKeyboardPrefs.setSize(keyboardContext, it) }) - SliderRow( - stringResource(R.string.pckb_opacity), stringResource(R.string.pckb_opacity_hint), - PcKeyboardPrefs.opacity, SessionPrefs.PC_KEYBOARD_OPACITY_RANGE, step = 5, - format = { "$it%" }, modifier = focus.track(page, "pckb-opacity"), - onChange = { PcKeyboardPrefs.setOpacity(keyboardContext, it) }) - MultiRow( - host, "pckb-hidden", stringResource(R.string.pckb_hidden_keys), - stringResource(R.string.pckb_hidden_keys_hint), - listOf( - 0 to stringResource(R.string.pckb_group_function), - 1 to stringResource(R.string.pckb_group_nav), - 2 to stringResource(R.string.pckb_group_arrows), - ), - PC_KEY_GROUP_IDS.filterValues { it in PcKeyboardPrefs.hiddenKeys }.keys, - onToggle = { id, on -> PcKeyboardPrefs.toggleHiddenKey(keyboardContext, PC_KEY_GROUP_IDS.getValue(id), on) }) - } + val airTriggers = a.airTriggers + if (airPanel && airTriggers != null) AirTriggersPanel(host, airTriggers, a, track) + else DrawerControllerPage(host, a, a.controllerConnected || controllerActive, track) { host.open = null; airTriggersShown = true } } - SessionDrawerPage.GLASSES -> if (glassesTab == GlassesTab.CONTROLLERS) { - VrControllerGroups(host) { key -> focus.track(page, key) } - } else { - GlassesGroups(host, glasses, glassesSettings, { key -> focus.track(page, key) }, onRecenter = a.onGlassesRecenter, - tab = glassesTab, outputActive = a.glassesOutput, steamVrRunning = a.steamVr == SteamVr.Status.RUNNING, - steamVr = { SteamVrRow(a) }) - } - SessionDrawerPage.GAMES -> { - if (a.steam || a.direct) SelectedGameProfileGroup(host, a) { key -> focus.track(page, key) } - Text(stringResource(R.string.fex_next_launch), fontSize = 12.sp, - color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)) - TextureFilteringGroup(host, a) { key -> focus.track(page, key) } - if (a.steam || a.direct) SettingsGroup(stringResource(R.string.game_settings_title)) { - DrawerFexPresetRow(host, a, focus.track(page, "fex")) - DrawerNoSteamRow(host, a, focus.track(page, "no-steam")) - GameEnvironmentRow( - modifier = focus.track(page, "game-env"), - showHint = false, - initialScope = a.selectedGameProfileId?.toString().orEmpty(), - ) - } - ComponentsDrawerPage(host, a) { key -> focus.track(page, key) } - ComponentDownloadsDrawerGroup( - host = host, - catalog = a.componentCatalog, - catalogAt = a.componentCatalogAt, - checking = a.componentCatalogChecking, - packages = a.components?.packages.orEmpty(), - downloads = a.componentDownloads, - onRefresh = a.onComponentCatalogRefresh, - onDownload = a.onComponentDownload, - track = { key -> focus.track(page, key) }, - ) + SessionDrawerPage.HUD -> DrawerPerformancePage(host, a, track) + SessionDrawerPage.FRAMEGEN -> DrawerFrameGenPage(host, a, track) + SessionDrawerPage.DISPLAY -> DrawerDisplayPage(host, a, track) + SessionDrawerPage.EFFECTS -> ScreenEffectsGroup(host, a, track) + SessionDrawerPage.GAMES -> DrawerGamePage(host, a, track) + SessionDrawerPage.VR -> DrawerVrPage(host, a, glasses, glassesSettings, track) + SessionDrawerPage.SESSION -> DrawerSessionPage(host, a, track) { app -> + host.open = null + if (a.secondScreenDisplays.isEmpty()) a.onLaunchAndroidApp(app, null) else appToChooseDisplay = app } + SessionDrawerPage.MORE -> DrawerMorePage(host, pages.inMore(), a, { host.open = null; onPageChange(it) }, { host.open = null; managing = true }, track) + SessionDrawerPage.ACHIEVEMENTS -> a.achievementsGame?.let { DrawerAchievementsPage(it, a.achievementsTitle, track) } SessionDrawerPage.AGENT -> Unit - SessionDrawerPage.MORE -> DrawerMorePage(host, pages.inMore(), { host.open = null; onPageChange(it) }, { host.open = null; managing = true }) { key -> focus.track(page, key) } - SessionDrawerPage.SESSION -> { - SettingsGroup(stringResource(R.string.drawer_support)) { - SettingsRow(stringResource(R.string.report_problem), stringResource(R.string.report_problem_hint)) { - DrawerOutlineButton(stringResource(R.string.drawer_share_logs), modifier = focus.track(page, "share-logs"), - progress = com.droiddeck.launcher.session.SessionLogShare.progress) { - host.open = null - a.onShareLogs() - } - } - } - if (a.isHomeApp) SettingsGroup(stringResource(R.string.drawer_android_apps)) { - SettingsRow(stringResource(R.string.drawer_launch_app), null) { - DrawerOutlineButton(if (androidAppsExpanded) stringResource(R.string.common_hide) else stringResource(R.string.common_show), modifier = focus.track(page, "apps")) { - androidAppsExpanded = !androidAppsExpanded - } - } - if (androidAppsExpanded) { - if (a.androidApps.isEmpty()) { - Text(stringResource(R.string.drawer_no_apps), fontSize = 12.sp, color = colors.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) - } else for (app in a.androidApps) { - MenuItem( - app.label, checked = false, - modifier = focus.track(page, "app:${app.packageName}/${app.className}"), - leading = { - app.icon?.let { icon -> - Image(bitmap = icon.asImageBitmap(), contentDescription = null, - modifier = Modifier.size(26.dp).clip(RoundedCornerShape(6.dp))) - } - }, - ) { - host.open = null - if (a.secondScreenDisplays.isEmpty()) a.onLaunchAndroidApp(app, null) - else appToChooseDisplay = app - } - } - } - } - SettingsGroup(stringResource(R.string.drawer_session_behavior)) { - if (a.micAvailable) ToggleRow(host, "microphone", stringResource(R.string.mode_mic), - stringResource(R.string.drawer_mic_hint), a.micEnabled, - chipModifier = focus.track(page, "microphone"), onChange = a.onMicEnabled) - ChoiceRow( - host, "suspend", stringResource(R.string.mode_suspend), - null, - listOf( - SessionPrefs.SUSPEND_AUTO to stringResource(R.string.common_auto), - SessionPrefs.SUSPEND_MANUAL to stringResource(R.string.mode_suspend_manual), - SessionPrefs.SUSPEND_NEVER to stringResource(R.string.common_never), - ) + if (a.steam) listOf( - SessionPrefs.SUSPEND_NATIVE to stringResource(R.string.mode_suspend_native), - ) else emptyList(), - a.suspendPolicy, - note = stringResource(if (a.steam) R.string.mode_suspend_steam_note else R.string.mode_suspend_note), - chipModifier = focus.track(page, "suspend"), - onPick = a.onSuspendPolicy, - ) - if (a.steam && a.suspendPolicy != SessionPrefs.SUSPEND_NEVER) ToggleRow( - host, "background-downloads", stringResource(R.string.mode_background_downloads), - stringResource(R.string.mode_background_downloads_hint), - a.steamDownloadsInBackground, - onChange = a.onSteamDownloadsInBackground, - ) - } - if (a.pipSupported) SettingsGroup(stringResource(R.string.pip_title)) { - ToggleRow(host, "pip-auto", stringResource(R.string.pip_auto), null, - a.pipAutoEnter, onChange = a.onPipAutoEnter) - } - Column(Modifier.fillMaxWidth().padding(top = 12.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { - if (!a.isHomeApp) DrawerActionButton(stringResource(R.string.drawer_background), Icons.AutoMirrored.Outlined.ExitToApp, - modifier = focus.track(page, "background")) { host.open = null; a.onBackground() } - } - } + } } } } } @@ -1033,6 +777,452 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont } } +@Composable +private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected: Boolean, track: (String) -> Modifier, onAirTriggers: () -> Unit) { + val on = stringResource(R.string.widgets_on) + val off = stringResource(R.string.widgets_off) + val padTag = if (padConnected) stringResource(R.string.drawer_tag_controller) else null + val noPadTag = if (padConnected) null else stringResource(R.string.drawer_tag_no_controller) + SettingsGroup(stringResource(R.string.drawer_section_input), key = "controller-input") { + InputQuickSettings(host, desktop = a.desktop, onChanged = a.onInputSelection, onEdit = a.onInputSettings, track = track) + } + val c = a.controller + val padTypes = listOf(SessionPrefs.CONTROLLER_DECK to stringResource(R.string.mode_controller_deck), + SessionPrefs.CONTROLLER_STEAM to stringResource(R.string.mode_controller_steam), + SessionPrefs.CONTROLLER_DS4 to stringResource(R.string.mode_controller_ds4), + SessionPrefs.CONTROLLER_DUALSENSE to stringResource(R.string.mode_controller_dualsense), + SessionPrefs.CONTROLLER_XBOX360 to stringResource(R.string.mode_controller_x360)) + val rumbleLabel = stringResource(R.string.ctrl_rumble) + val airTriggers = a.airTriggers + val airTriggersLabel = stringResource(R.string.air_triggers_title) + val directControllerLabel = stringResource(R.string.ctrl_direct_controller) + if (a.padType != null || c != null || airTriggers != null || a.directController != null) SettingsGroup( + stringResource(R.string.input_device_settings), key = "controller-pad", tag = padTag, + detail = summary(a.padType?.let { padTypes.labelOf(it) }, c?.let { "$rumbleLabel ${if (it.rumble) on else off}" }, + airTriggers?.let { "$airTriggersLabel ${if (it.enabled) on else off}" }, + a.directController?.let { "$directControllerLabel ${if (it) on else off}" }), + ) { + a.padType?.let { type -> + ChoiceRow(host, "pad-type", stringResource(R.string.input_virtual_controller), stringResource(R.string.input_virtual_controller_hint), + padTypes, type, chipModifier = track("pad-type"), onPick = a.onPadType) + } + c?.let { + ToggleRow(host, "rumble", rumbleLabel, null, it.rumble, chipModifier = track("rumble"), onChange = a.onRumble) + } + a.directController?.let { + ToggleRow(host, "direct-controller", directControllerLabel, null, it, chipModifier = track("direct-controller"), onChange = a.onDirectController) + } + airTriggers?.let { + ActionRow(airTriggersLabel, if (it.enabled) on else off, stringResource(R.string.air_triggers_open), onAirTriggers, + modifier = track("air-triggers")) + } + } + val oscChoices = if (a.steam) listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_STEAM_TOUCH to stringResource(R.string.osc_steam_touch), SessionPrefs.OSC_STEAM_QAM to stringResource(R.string.mode_osc_qam), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)) + else listOf(SessionPrefs.OSC_AUTO to stringResource(R.string.common_auto), SessionPrefs.OSC_ALWAYS to stringResource(R.string.common_always), SessionPrefs.OSC_NEVER to stringResource(R.string.common_never)) + val oscValue = if (!a.steam && a.oscMode == SessionPrefs.OSC_STEAM_TOUCH) SessionPrefs.OSC_AUTO else a.oscMode + SettingsGroup(stringResource(R.string.input_screen_visibility), key = "controller-osc", tag = noPadTag, + detail = summary(oscChoices.labelOf(oscValue), c?.let { "${it.size}%" })) { + ChoiceRow(host, "osc", stringResource(R.string.mode_osc), null, oscChoices, oscValue, chipModifier = track("osc"), onPick = a.onOsc) + c?.let { + SliderRow(stringResource(R.string.ctrl_size), null, it.size, 80..125, step = 5, + format = { v -> "$v%" }, modifier = track("controller-size"), onChange = a.onControllerSize) + SliderRow(stringResource(R.string.ctrl_opacity), null, it.onScreenOpacity, ControllerPrefs.onScreenOpacityRange, step = 5, + format = { v -> "$v%" }, modifier = track("controller-opacity").testTag("controller-opacity"), + onChange = a.onControllerOpacity) + } + a.adaptiveSticks?.let { adaptive -> + ToggleRow(host, "adaptive-sticks", stringResource(R.string.ctrl_adaptive), null, adaptive, + chipModifier = track("adaptive-sticks"), onChange = a.onAdaptiveSticks) + } + if (a.showFloatingSteamControls) { + ToggleRow(host, "rear-buttons", stringResource(R.string.osc_rear_buttons), null, a.oscRearButtons, + chipModifier = track("rear-buttons"), onChange = a.onOscRearButtons) + ToggleRow(host, "trackpads", stringResource(R.string.osc_trackpads), null, a.oscTrackpads, + chipModifier = track("trackpads"), onChange = a.onOscTrackpads) + } + for ((button, shown) in a.quickButtons) { + val key = "quick-${button.name.lowercase()}" + ToggleRow(host, key, stringResource(quickButtonLabel(button)), null, shown, + chipModifier = track(key)) { a.onQuickButton(button, it) } + } + a.onEditSteamTouch?.let { edit -> + ActionRow(stringResource(R.string.osc_steam_layout), stringResource(R.string.osc_steam_layout_hint), stringResource(R.string.ctrl_edit), edit, + modifier = track("steam-touch-layout")) + } + if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls), + stringResource(R.string.unfolded_controls_hint), a.unfoldedControls, + chipModifier = track("unfolded-controls"), onChange = a.onUnfoldedControls) + a.deckPanel?.let { panel -> + ChoiceRow(host, "deck-panel", stringResource(R.string.ctrl_layout), null, + com.droiddeck.launcher.input.DeckPanel.entries.map { it to stringResource(it.label) }, panel, + chipModifier = track("deck-panel"), onPick = a.onDeckPanel) + } + if (a.steam && a.unfoldedControls == true) ToggleRow(host, "unfolded-controls-with-controller", + stringResource(R.string.unfolded_controls_with_controller), + stringResource(R.string.unfolded_controls_with_controller_hint), a.unfoldedControlsWithController, + chipModifier = track("unfolded-controls-with-controller"), + onChange = a.onUnfoldedControlsWithController) + } + val touchChoices = listOf(SessionPrefs.TOUCH_AUTO to stringResource(R.string.drawer_touch_auto, a.touchAuto), SessionPrefs.TOUCH_PAD to stringResource(R.string.mode_touch_touchpad), SessionPrefs.TOUCH_DIRECT to stringResource(R.string.mode_touch_direct), SessionPrefs.TOUCH_GESTURES to stringResource(R.string.mode_touch_gestures), SessionPrefs.TOUCH_OFF to stringResource(R.string.widgets_off)) + SettingsGroup(stringResource(R.string.input_touchscreen), key = "controller-touch", tag = noPadTag, detail = touchChoices.labelOf(a.touchMode)) { + ChoiceRow(host, "touch", stringResource(R.string.input_touchscreen), stringResource(R.string.input_touchscreen_hint), + touchChoices, a.touchMode, chipModifier = track("touch"), onPick = a.onTouch) + if (a.touchActive == SessionPrefs.TOUCH_PAD) RelativeMouseRow(host, a, track("relative-mouse")) + if (a.touchActive == SessionPrefs.TOUCH_DIRECT) + ToggleRow(host, "direct-cursor", stringResource(R.string.input_touch_cursor), + stringResource(R.string.input_touch_cursor_hint), a.directCursor, + chipModifier = track("direct-cursor"), onChange = a.onDirectCursor) + when (a.touchActive) { + SessionPrefs.TOUCH_GESTURES -> ActionRow(stringResource(R.string.gesture_settings), null, + stringResource(R.string.ctrl_edit), a.onGestureSettings, modifier = track("gesture-settings")) + SessionPrefs.TOUCH_DIRECT -> ChoiceRow(host, "long-press", stringResource(R.string.input_touch_hold), stringResource(R.string.input_touch_hold_hint), + listOf(MOUSE_BEHAVIOR_NONE to stringResource(R.string.gesture_hold_left), + MOUSE_BEHAVIOR_CLICK to stringResource(R.string.gesture_right_click), + MOUSE_BEHAVIOR_HOLD to stringResource(R.string.gesture_hold_right)), + a.directHoldBehavior, chipModifier = track("long-press"), onPick = a.onDirectHoldBehavior) + } + } + a.pen?.let { PenSettingsGroup(host, it, track = track, onPick = a.onPen) } + SettingsGroup(stringResource(R.string.drawer_section_mouse), key = "controller-mouse", + detail = "${stringResource(R.string.drawer_evdev_mouse)} ${if (a.evdevMouse) on else off}") { + ToggleRow(host, "evdev-mouse", stringResource(R.string.drawer_evdev_mouse), null, a.evdevMouse, + chipModifier = track("evdev-mouse"), onChange = a.onEvdevMouse) + if (a.touchActive != SessionPrefs.TOUCH_PAD) RelativeMouseRow(host, a, track("relative-mouse")) + } + val backOrders = listOf(false to stringResource(SessionPrefs.BACK_MENU_THEN_QAM), true to stringResource(SessionPrefs.BACK_QAM_THEN_MENU)) + SettingsGroup(stringResource(R.string.shortcuts_title), key = "controller-shortcuts", + detail = if (a.steam) summary(backOrders.labelOf(a.backActionsInverted), stringResource(R.string.back_tap_ms, a.backDoubleTapMs)) else null) { + if (a.steam) ToggleRow(host, "back-hold", stringResource(R.string.back_hold), + stringResource(R.string.back_hold_hint), a.backHold, + chipModifier = track("back-hold"), onChange = a.onBackHold) + if (a.steam) ChoiceRow(host, "back-actions", stringResource(R.string.input_back_taps), stringResource(R.string.input_back_taps_hint), + backOrders, a.backActionsInverted, chipModifier = track("back-actions"), onPick = a.onBackActionsInverted) + if (a.steam) ChoiceRow(host, "back-double-tap", stringResource(R.string.back_double_tap_window), null, + SessionPrefs.BACK_DOUBLE_TAP_MS_OPTIONS.map { it to stringResource(R.string.back_tap_ms, it) }, + a.backDoubleTapMs, chipModifier = track("back-double-tap"), onPick = a.onBackDoubleTapMs) + PhysicalShortcutRows(modifierFor = { track("physical-shortcut-${it.name}") }) + if (a.secondScreenDisplays.isNotEmpty()) ToggleRow(host, "docked-menu-controller", stringResource(R.string.drawer_docked_menu_controller), + null, a.dockedMenuController, + chipModifier = track("docked-menu-controller"), onChange = a.onDockedMenuController) + ToggleRow(host, "corner-tap", stringResource(R.string.drawer_corner_tap), + stringResource(R.string.drawer_corner_tap_hint), a.cornerTap, + chipModifier = track("corner-tap"), onChange = a.onCornerTap) + } + val keyboardContext = LocalContext.current + remember { PcKeyboardPrefs.load(keyboardContext) } + SettingsGroup(stringResource(R.string.drawer_section_keyboard_layout), key = "controller-keyboard", + detail = summary("${PcKeyboardPrefs.size}%", "${PcKeyboardPrefs.opacity}%")) { + if (a.wowChatShown) ChoiceRow( + host, "wow-chat", stringResource(R.string.wow_chat_title), null, + listOf( + null to stringResource(R.string.wow_chat_ask), + SessionPrefs.WOW_CHAT_VOICE to stringResource(R.string.wow_chat_voice), + SessionPrefs.WOW_CHAT_KEYBOARD to stringResource(R.string.pckb_android), + ), + a.wowChat, chipModifier = track("wow-chat"), onPick = a.onWowChat, + ) + SliderRow( + stringResource(R.string.pckb_size), stringResource(R.string.pckb_size_hint), + PcKeyboardPrefs.size, SessionPrefs.PC_KEYBOARD_SIZE_RANGE, step = 1, + format = { "$it%" }, modifier = track("pckb-size"), + onChange = { PcKeyboardPrefs.setSize(keyboardContext, it) }) + SliderRow( + stringResource(R.string.pckb_opacity), stringResource(R.string.pckb_opacity_hint), + PcKeyboardPrefs.opacity, SessionPrefs.PC_KEYBOARD_OPACITY_RANGE, step = 5, + format = { "$it%" }, modifier = track("pckb-opacity"), + onChange = { PcKeyboardPrefs.setOpacity(keyboardContext, it) }) + MultiRow( + host, "pckb-hidden", stringResource(R.string.pckb_hidden_keys), + stringResource(R.string.pckb_hidden_keys_hint), + listOf( + 0 to stringResource(R.string.pckb_group_function), + 1 to stringResource(R.string.pckb_group_nav), + 2 to stringResource(R.string.pckb_group_arrows), + ), + PC_KEY_GROUP_IDS.filterValues { it in PcKeyboardPrefs.hiddenKeys }.keys, + onToggle = { id, shown -> PcKeyboardPrefs.toggleHiddenKey(keyboardContext, PC_KEY_GROUP_IDS.getValue(id), shown) }) + } + Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(top = 12.dp)) { + DrawerOutlineButton(stringResource(R.string.drawer_pc_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(track("hardware"))) { + host.open = null; a.onHardwareKeyboard() + } + DrawerOutlineButton(stringResource(R.string.drawer_android_keyboard), modifier = Modifier.weight(1f).height(48.dp).then(track("android"))) { + host.open = null; a.onKeyboard() + } + } +} + +@Composable +private fun DrawerPerformancePage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val offLabel = stringResource(R.string.frame_gen_off) + val limit = if (a.direct && a.fpsLimit > 0) "${stringResource(R.string.drawer_frame_limit)} ${a.fpsLimit}" else null + SettingsGroup(stringResource(R.string.drawer_section_pacing), key = "performance-pacing", detail = summary(limit)) { + if (a.direct) SliderRow( + stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_note), + a.fpsLimit.takeIf { it > 0 } ?: SessionPrefs.FPS_LIMIT_OFF, + SessionPrefs.FPS_LIMIT_OFF..SessionPrefs.FPS_LIMIT_MAX, step = 5, + format = { if (it <= SessionPrefs.FPS_LIMIT_OFF) offLabel else it.toString() }, + modifier = track("fps-limit"), + onChange = { a.onFpsLimit(if (it <= SessionPrefs.FPS_LIMIT_OFF) 0 else it) }) + if (a.steam && !a.direct && a.onQam != null) SettingsRow( + stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_steam_hint), + ) { + DrawerOutlineButton(stringResource(R.string.drawer_open_steam_qam), modifier = track("fps-limit-steam")) { + host.open = null + a.onQam?.invoke() + } + } + if (a.blackFrameInsertionAvailable) ToggleRow(host, "bfi", stringResource(R.string.drawer_bfi), + stringResource(R.string.drawer_bfi_note), a.blackFrameInsertion, + chipModifier = track("bfi"), onChange = a.onBlackFrameInsertion) + ToggleRow(host, "low-latency", stringResource(R.string.drawer_low_latency), + stringResource(R.string.drawer_low_latency_hint), a.lowLatency, + chipModifier = track("low-latency"), onChange = a.onLowLatency) + } + DroidDeckHudSettings(host, a, track) +} + + + +@Composable +private fun DrawerFrameGenSettings(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val fgLabel = FrameGen.label(LocalContext.current, a.frameGen) + val scope = if (a.frameGenTargetGameId != null) + "${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}" + else stringResource(R.string.frame_gen_scope_global) + + SettingsGroup(stringResource(R.string.frame_gen_title), compact = true, key = "frame-generation", detail = summary(fgLabel, scope)) { + FrameGenMenu( + mode = a.frameGen, + lossless = a.lossless, + onPick = a.onFrameGenPick, + + gameProfileId = a.frameGenTargetGameId, + hasGameOverride = a.hasGameOverride, + onResetGame = a.onFrameGenReset, + focusModifier = track("frame-generation"), + sessionHost = host, + ) + } +} + +@Composable +private fun DrawerFrameGenPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + DrawerFrameGenSettings(host, a, track) +} + + +@Composable +private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val orientations = SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) } + SettingsGroup(stringResource(R.string.drawer_page_display), key = "display", + detail = summary(if (a.gameZoomAvailable) "${(a.gameZoom * 100.0f).toInt()}%" else null, orientations.labelOf(a.orientation))) { + if (a.gameZoomAvailable) GameZoomRow(a.gameZoom, track, a.onGameZoom) + ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null, + orientations, a.orientation, chipModifier = track("orientation"), onPick = a.onOrientation) + ChoiceRow(host, "session-fullscreen", stringResource(R.string.setup_session_fullscreen), + stringResource(R.string.setup_fullscreen_on), + FullscreenMode.entries.map { it to stringResource(it.label) }, a.fullscreenMode, + chipModifier = track("session-fullscreen"), onPick = a.onFullscreenMode) + if (a.steam) PicturePositionRow(host, a.picturePosition, track("picture-position"), onPick = a.onPicturePosition) + } + val filters = SessionPrefs.upscalerChoices(LocalContext.current) + val integer = stringResource(if (a.integerScaling) R.string.display_scaling_integer else R.string.display_scaling_fit) + SettingsGroup(stringResource(R.string.display_image_scaling), key = "display-scaling", + detail = summary(filters.labelOf(a.upscaler), integer.takeIf { a.steam })) { + if (a.steam) SettingsRow(stringResource(R.string.display_integer_scaling), null) { + PadTextButton(onClick = { a.onIntegerScaling(!a.integerScaling) }, modifier = track("integer-scaling")) { Text(integer) } + } + ChoiceRow(host, "upscaler", stringResource(R.string.display_filter), null, filters, a.upscaler, + note = stringResource(R.string.display_filter_note), + chipModifier = track("upscaler"), onPick = a.onUpscaler) + if (SessionPrefs.upscalerHasSharpness(a.upscaler)) SliderRow( + stringResource(R.string.display_sharpness), null, a.upscaleSharpness, 0..100, step = 5, + format = { "$it%" }, modifier = track("upscale-sharpness"), onChange = a.onUpscaleSharpness) + } + SecondScreenGroup(host, a, track) +} + +private const val GAME_ZOOM_MIN = 100 +private const val GAME_ZOOM_MAX = 300 +private const val GAME_ZOOM_STEP = 25 +private const val GAME_ZOOM_INTERVALS = (GAME_ZOOM_MAX - GAME_ZOOM_MIN) / GAME_ZOOM_STEP + +@Composable +internal fun GameZoomRow( + zoom: Float, + track: (String) -> Modifier, + onZoom: (Float) -> Unit, +) { + val source = remember { MutableInteractionSource() } + val focused by source.collectIsFocusedAsState() + val label = stringResource(R.string.game_zoom_title) + val percent = (zoom * 100f).roundToInt().coerceIn(GAME_ZOOM_MIN, GAME_ZOOM_MAX) + val value = stringResource(R.string.game_zoom_value, percent) + fun detent(value: Float): Int = ((value - GAME_ZOOM_MIN) / GAME_ZOOM_STEP).roundToInt() + val selectedDetent = detent(percent.toFloat()) + val rtl = LocalLayoutDirection.current == LayoutDirection.Rtl + val pal = LocalPalette.current + val colors = MaterialTheme.colorScheme + + fun chooseDetent(index: Int) { + val next = GAME_ZOOM_MIN + index.coerceIn(0, GAME_ZOOM_INTERVALS) * GAME_ZOOM_STEP + if (next != percent) onZoom(next / 100f) + } + Column(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 6.dp)) { + Row( + Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text(label, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Text(value, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold, + color = colors.onSurface, modifier = Modifier.testTag("game-zoom-value")) + } + Slider( + value = (GAME_ZOOM_MIN + selectedDetent * GAME_ZOOM_STEP).toFloat(), + onValueChange = { chooseDetent(detent(it)) }, + valueRange = GAME_ZOOM_MIN.toFloat()..GAME_ZOOM_MAX.toFloat(), + steps = GAME_ZOOM_INTERVALS - 1, + interactionSource = source, + modifier = track("game-zoom-slider").fillMaxWidth().heightIn(min = 48.dp) + .glideBorder(focused, RoundedCornerShape(10.dp), pal.signal) + .testTag("game-zoom-slider") + .semantics { contentDescription = label; stateDescription = value } + .onPreviewKeyEvent { event -> + val delta = when (event.key) { + Key.DirectionLeft -> if (rtl) 1 else -1 + Key.DirectionRight -> if (rtl) -1 else 1 + else -> return@onPreviewKeyEvent false + } + if (event.type == KeyEventType.KeyDown && event.nativeKeyEvent.repeatCount == 0) { + chooseDetent(selectedDetent + delta) + } + true + }, + ) + } + Box(Modifier.fillMaxWidth().height(1.dp).background(pal.line)) +} + +@Composable +private fun DrawerGamePage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { + val colors = MaterialTheme.colorScheme + if (a.steam || a.direct) SelectedGameProfileGroup(host, a, track) + if (a.steam || a.direct) SettingsGroup(stringResource(R.string.drawer_section_compat), key = "game-compat") { + DrawerFexPresetRow(host, a, track("fex")) + DrawerNoSteamRow(host, a, track("no-steam")) + GameEnvironmentRow( + modifier = track("game-env"), + showHint = false, + initialScope = a.selectedGameProfileId?.toString().orEmpty(), + ) + Text(stringResource(R.string.fex_next_launch), fontSize = 12.sp, + color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 10.dp, vertical = 8.dp)) + } + TextureFilteringGroup(host, a, track) + ComponentsDrawerPage(host, a, track) + ComponentDownloadsDrawerGroup( + host = host, + catalog = a.componentCatalog, + catalogAt = a.componentCatalogAt, + checking = a.componentCatalogChecking, + packages = a.components?.packages.orEmpty(), + downloads = a.componentDownloads, + onRefresh = a.onComponentCatalogRefresh, + onDownload = a.onComponentDownload, + track = track, + ) +} + +@Composable +private fun DrawerVrPage(host: MenuHost, a: DrawerActions, glasses: com.droiddeck.launcher.glasses.GlassesState, + glassesSettings: com.droiddeck.launcher.glasses.GlassesSettings, track: (String) -> Modifier) { + val running = a.steamVr == SteamVr.Status.RUNNING + if (a.glassesPresent) { + GlassesGroups(host, glasses, glassesSettings, track, onRecenter = a.onGlassesRecenter, + outputActive = a.glassesOutput, steamVrRunning = running) + VrControllerGroups(host, track) + } + SteamVrGroup(a, track) + if (!a.glassesOutput) CardboardGroup(host, a, track) +} + +@Composable +private fun DrawerSessionPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier, onLaunch: (HomeApp.LaunchableApp) -> Unit) { + val colors = MaterialTheme.colorScheme + Column(Modifier.fillMaxWidth().padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { + DrawerActionButton(stringResource(if (a.paused) R.string.resume_session else R.string.drawer_pause_game), + if (a.paused) Icons.Outlined.PlayArrow else Icons.Outlined.Pause, modifier = track("pause")) { + host.open = null + if (a.paused) a.onResume() else a.onPause() + } + if (a.pipSupported) DrawerActionButton(stringResource(R.string.pip_title), Icons.Outlined.PictureInPictureAlt, modifier = track("pip")) { + host.open = null + a.onPip() + } + } + val suspendChoices = listOf( + SessionPrefs.SUSPEND_AUTO to stringResource(R.string.common_auto), + SessionPrefs.SUSPEND_MANUAL to stringResource(R.string.mode_suspend_manual), + SessionPrefs.SUSPEND_NEVER to stringResource(R.string.common_never), + ) + if (a.steam) listOf(SessionPrefs.SUSPEND_NATIVE to stringResource(R.string.mode_suspend_native)) else emptyList() + SettingsGroup(stringResource(R.string.drawer_session_behavior), key = "session-behavior", + detail = summary(stringResource(R.string.mode_suspend) + " " + suspendChoices.labelOf(a.suspendPolicy).orEmpty())) { + if (a.micAvailable) ToggleRow(host, "microphone", stringResource(R.string.mode_mic), + stringResource(R.string.drawer_mic_hint), a.micEnabled, + chipModifier = track("microphone"), onChange = a.onMicEnabled) + ChoiceRow( + host, "suspend", stringResource(R.string.mode_suspend), null, suspendChoices, a.suspendPolicy, + note = stringResource(if (a.steam) R.string.mode_suspend_steam_note else R.string.mode_suspend_note), + chipModifier = track("suspend"), onPick = a.onSuspendPolicy, + ) + if (a.steam && a.suspendPolicy != SessionPrefs.SUSPEND_NEVER) ToggleRow( + host, "background-downloads", stringResource(R.string.mode_background_downloads), + stringResource(R.string.mode_background_downloads_hint), a.steamDownloadsInBackground, + chipModifier = track("background-downloads"), onChange = a.onSteamDownloadsInBackground, + ) + if (a.pipSupported) ToggleRow(host, "pip-auto", stringResource(R.string.pip_auto), null, + a.pipAutoEnter, chipModifier = track("pip-auto"), onChange = a.onPipAutoEnter) + } + if (a.isHomeApp) SettingsGroup(stringResource(R.string.drawer_android_apps), key = "session-apps", + detail = a.androidApps.take(3).joinToString(", ") { it.label }) { + if (a.androidApps.isEmpty()) { + Text(stringResource(R.string.drawer_no_apps), fontSize = 12.sp, color = colors.onSurfaceVariant, + modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) + } else for (app in a.androidApps) { + MenuItem( + app.label, checked = false, + modifier = track("app:${app.packageName}/${app.className}"), + leading = { + app.icon?.let { icon -> + Image(bitmap = icon.asImageBitmap(), contentDescription = null, + modifier = Modifier.size(26.dp).clip(RoundedCornerShape(6.dp))) + } + }, + ) { onLaunch(app) } + } + } + // Players reach for Share logs while something is going wrong, so Support never folds. + CompositionLocalProvider(LocalDrawerSections provides null) { SettingsGroup(stringResource(R.string.drawer_support)) { + SettingsRow(stringResource(R.string.report_problem), stringResource(R.string.report_problem_hint)) { + DrawerOutlineButton(stringResource(R.string.drawer_share_logs), modifier = track("share-logs"), + progress = com.droiddeck.launcher.session.SessionLogShare.progress) { + host.open = null + a.onShareLogs() + } + } + } } + if (!a.isHomeApp) Column(Modifier.fillMaxWidth().padding(top = 12.dp)) { + DrawerActionButton(stringResource(R.string.drawer_background), Icons.AutoMirrored.Outlined.ExitToApp, + modifier = track("background")) { host.open = null; a.onBackground() } + } +} + +private fun List>.labelOf(value: T): String? = firstOrNull { it.first == value }?.second + +private fun summary(vararg parts: String?): String = parts.filterNot { it.isNullOrEmpty() }.joinToString(" · ") + @Composable private fun DrawerActionButton(text: String, icon: androidx.compose.ui.graphics.vector.ImageVector, modifier: Modifier = Modifier, onClick: () -> Unit) { val colors = MaterialTheme.colorScheme @@ -1174,7 +1364,16 @@ private fun DrawerPageTabs(page: SessionDrawerPage, pages: List Unit) { +private fun DrawerMoreBack(title: String, modifier: Modifier, parent: String = stringResource(R.string.drawer_page_more), onBack: () -> Unit) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val source = remember { MutableInteractionSource() } val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value val shape = RoundedCornerShape(12.dp) - val label = stringResource(R.string.drawer_more_back, stringResource(R.string.drawer_page_more)) + val label = stringResource(R.string.drawer_more_back, parent) Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = modifier.padding(top = 8.dp, start = 14.dp, end = 14.dp).fillMaxWidth().heightIn(min = 44.dp).clip(shape) @@ -1208,18 +1407,112 @@ private fun DrawerMoreBack(title: String, modifier: Modifier, onBack: () -> Unit .padding(horizontal = 8.dp), ) { Icon(Icons.AutoMirrored.Outlined.ArrowBack, null, tint = colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) - Text(stringResource(R.string.drawer_page_more), fontSize = 13.sp, color = colors.onSurfaceVariant) + Text(parent, fontSize = 13.sp, color = colors.onSurfaceVariant) Text("·", fontSize = 13.sp, color = colors.onSurfaceVariant) Text(title, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1) } } +@Composable +private fun AirTriggersPanel(host: MenuHost, t: AirTriggerMenu, a: DrawerActions, track: (String) -> Modifier) { + CompositionLocalProvider(LocalDrawerSections provides null) { SettingsGroup(stringResource(R.string.air_triggers_title)) { + ToggleRow(host, "air-triggers-toggle", stringResource(R.string.air_triggers_use), stringResource(R.string.air_triggers_use_hint), t.enabled, + chipModifier = track("air-triggers-toggle"), onChange = a.onAirTriggers) + ToggleRow(host, "air-triggers-vibration", stringResource(R.string.air_triggers_vibration), stringResource(R.string.air_triggers_vibration_hint), + t.vibration, enabled = t.enabled, chipModifier = track("air-triggers-vibration"), onChange = a.onAirTriggerVibration) + ToggleRow(host, "air-triggers-screen-light", stringResource(R.string.air_triggers_screen_light), stringResource(R.string.air_triggers_screen_light_hint), + t.screenLight, enabled = t.enabled, chipModifier = track("air-triggers-screen-light"), onChange = a.onAirTriggerScreenLight) + val leds = listOf(AirTriggerLed.OFF to R.string.air_triggers_led_off, AirTriggerLed.STEADY to R.string.air_triggers_led_steady, + AirTriggerLed.PULSE to R.string.air_triggers_led_pulse).map { (led, text) -> led to stringResource(text) } + ChoiceRow(host, "air-triggers-led", stringResource(R.string.air_triggers_led), null, leds, t.led, + enabled = t.enabled, chipModifier = track("air-triggers-led"), onPick = a.onAirTriggerLed) + for (trigger in AirTrigger.entries) { + val key = "air-trigger-${trigger.name.lowercase()}" + val left = trigger == AirTrigger.LEFT + val label = stringResource(if (left) R.string.air_trigger_left else R.string.air_trigger_right) + ChoiceRow(host, key, label, stringResource(R.string.air_trigger_button_hint), t.buttons, t.selected.getValue(trigger), + enabled = t.enabled, chipModifier = track(key)) { a.onAirTriggerButton(trigger, it) } + AirTriggerActionRow(host, "$key-action", stringResource(if (left) R.string.air_trigger_left_action else R.string.air_trigger_right_action), + t.actions[trigger] ?: AirTriggerAction.TAP, t.rates[trigger] ?: RapidFireRate.NORMAL, t.enabled, track("$key-action"), + onAction = { a.onAirTriggerAction(trigger, it) }, onRate = { a.onAirTriggerRate(trigger, it) }) + } + } } +} + +@Composable +private fun AirTriggerActionRow( + host: MenuHost, key: String, label: String, action: AirTriggerAction, rate: RapidFireRate, enabled: Boolean, chipModifier: Modifier, + onAction: (AirTriggerAction) -> Unit, onRate: (RapidFireRate) -> Unit, +) { + val open = host.open == key + var rateOpen by remember { mutableStateOf(false) } + LaunchedEffect(open) { if (!open) rateOpen = false } + val actions = listOf(AirTriggerAction.TAP to R.string.air_trigger_action_tap, AirTriggerAction.LATCH to R.string.air_trigger_action_hold, + AirTriggerAction.RAPID to R.string.air_trigger_action_rapid).map { (value, text) -> value to stringResource(text) } + val rates = listOf(R.string.air_trigger_rate_low, R.string.air_trigger_rate_normal, R.string.air_trigger_rate_high).map { stringResource(it) } + val rapidLabel = actions.last().second + val frequency = stringResource(R.string.air_trigger_rapid_frequency) + SettingsRow(label, null, highlighted = open) { Box { + ValueChip(actions.first { it.first == action }.second, open, enabled, modifier = chipModifier.testTag("setting-$key")) { + host.open = if (open) null else key + } + AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = if (rateOpen) null else label) { first -> + val arrowFocus = remember { FocusRequester() } + val keyboard = LocalInputModeManager.current.inputMode == InputMode.Keyboard + var shown by remember { mutableStateOf(rateOpen) } + LaunchedEffect(rateOpen) { + if (shown == rateOpen) return@LaunchedEffect + shown = rateOpen + withFrameNanos { } + if (keyboard) runCatching { (if (rateOpen) first else arrowFocus).requestFocus() } + } + if (rateOpen) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(start = 10.dp)) { + Text(rapidLabel.uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, + color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.weight(1f)) + MenuGlyphButton("✕", stringResource(R.string.common_close), Modifier.testTag("$key-rate-close")) { rateOpen = false } + } + ValueSlider(rate.ordinal, 0..RapidFireRate.entries.lastIndex, 1, true, frequency, { rates[it] }, + modifier = Modifier.focusRequester(first).testTag("$key-rate")) { if (it != rate.ordinal) onRate(RapidFireRate.entries[it]) } + } else actions.forEachIndexed { index, (value, text) -> + val pick = { onAction(value); host.open = null } + if (value != AirTriggerAction.RAPID) MenuItem(text, checked = value == action, focusRequester = if (index == 0) first else null, onClick = pick) + else Row(verticalAlignment = Alignment.CenterVertically) { + MenuItem(text, checked = value == action, modifier = Modifier.weight(1f), onClick = pick) + MenuGlyphButton("›", stringResource(R.string.air_trigger_rapid_settings), + Modifier.focusRequester(arrowFocus).testTag("$key-rate-open")) { rateOpen = true } + } + } + } + } } +} + +@Composable +private fun MenuGlyphButton(glyph: String, description: String, modifier: Modifier = Modifier, onClick: () -> Unit) { + val pal = LocalPalette.current + val src = remember { MutableInteractionSource() } + val hot = src.collectIsFocusedAsState().value || src.collectIsHoveredAsState().value + val shape = RoundedCornerShape(8.dp) + Box( + contentAlignment = Alignment.Center, + modifier = modifier.size(40.dp).clip(shape) + .background(if (hot) Color.White.copy(alpha = 0.07f) else Color.Transparent) + .glideBorder(hot, shape, pal.signal) + .hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClick = onClick) + .controllerConfirm(onClick = onClick) + .semantics { contentDescription = description }, + ) { + Text(glyph, fontSize = 18.sp, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground) + } +} + /** The pages kept inside More, and the way into arranging which pages sit on the strip and which here. */ @Composable -private fun DrawerMorePage(host: MenuHost, pages: List, onOpen: (SessionDrawerPage) -> Unit, onEdit: () -> Unit, track: (String) -> Modifier) { +private fun DrawerMorePage(host: MenuHost, pages: List, a: DrawerActions, onOpen: (SessionDrawerPage) -> Unit, onEdit: () -> Unit, track: (String) -> Modifier) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - SettingsGroup(stringResource(R.string.drawer_page_more)) { + // The list of pages is the page itself, so it never folds. + CompositionLocalProvider(LocalDrawerSections provides null) { SettingsGroup(stringResource(R.string.drawer_page_more)) { if (pages.isEmpty()) Text( stringResource(R.string.drawer_more_empty), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp), @@ -1243,23 +1536,23 @@ private fun DrawerMorePage(host: MenuHost, pages: List, onOpe ) { Icon(item.icon, null, tint = colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) Text(stringResource(item.title), fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, modifier = Modifier.weight(1f)) + if (item == SessionDrawerPage.ACHIEVEMENTS) a.achievementsProgress?.takeIf { it.second > 0 }?.let { (done, total) -> + Text(stringResource(R.string.achievements_count_short, done, total), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = pal.signal) + } } } - } + } } Spacer(Modifier.height(10.dp)) DrawerOutlineButton(stringResource(R.string.drawer_manage_pages), modifier = track("more-edit").testTag("drawer-more-edit"), onClick = onEdit) } @Composable -private fun ScreenEffectsGroup( - host: MenuHost, a: DrawerActions, advancedExpanded: Boolean, onAdvancedToggle: () -> Unit, - track: (String) -> Modifier, -) { +private fun ScreenEffectsGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { val e = a.effects val preset = ScreenEffectLooks.match(e, a.upscaler) - val colors = MaterialTheme.colorScheme - val pal = LocalPalette.current - SettingsGroup(stringResource(R.string.drawer_effects)) { + val lookLabel = preset?.let { stringResource(it.label) } ?: stringResource(R.string.drawer_look_custom) + SettingsGroup(stringResource(R.string.drawer_effects), key = "effects-look", + detail = summary(lookLabel, a.screenEffectsTargets.labelOf(a.screenEffectsTarget))) { ChoiceRow( host, "effects-profile", stringResource(R.string.screen_effects_target), stringResource(R.string.screen_effects_target_hint), a.screenEffectsTargets, @@ -1313,31 +1606,13 @@ private fun ScreenEffectsGroup( if (a.hdrAvailable) ToggleRow(host, "hdr", stringResource(R.string.mode_hdr), null, a.hdr, chipModifier = track("hdr"), onChange = a.onHdr) else ToggleRow(host, "fake-hdr", stringResource(R.string.drawer_fake_hdr), null, e.hdr, chipModifier = track("fake-hdr")) { a.onEffects(e.copy(hdr = it)) } - if (a.blackFrameInsertionAvailable) ToggleRow(host, "bfi", stringResource(R.string.drawer_bfi), - stringResource(R.string.drawer_bfi_note), a.blackFrameInsertion, - chipModifier = track("bfi"), onChange = a.onBlackFrameInsertion) } - val source = remember { MutableInteractionSource() } - val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value - val rotation by animateFloatAsState(if (advancedExpanded) 180f else 0f, Motion.tw(180), label = "advancedArrow") - val description = stringResource(if (advancedExpanded) R.string.widgets_expanded else R.string.widgets_collapsed) - val toggle = { host.open = null; onAdvancedToggle() } - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(10.dp), - modifier = track("effects-advanced").fillMaxWidth().padding(top = 12.dp).heightIn(min = 48.dp) - .glideBorder(hot, RoundedCornerShape(8.dp), pal.signal) - .hoverable(source).clickable(interactionSource = source, indication = LocalIndication.current, role = Role.Button, onClick = toggle) - .controllerConfirm(onClick = toggle).semantics { stateDescription = description }.padding(horizontal = 4.dp), - ) { - Text(stringResource(R.string.drawer_effects_advanced).uppercase(), fontSize = 12.sp, - fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, color = colors.onSurfaceVariant) - Box(Modifier.weight(1f).height(1.dp).background(pal.line)) - Icon(Icons.Outlined.ExpandMore, contentDescription = null, tint = colors.onSurfaceVariant, - modifier = Modifier.size(22.dp).rotate(rotation)) - } - AnimatedVisibility(advancedExpanded) { - Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(14.dp)).background(colors.surface).border(1.dp, pal.line, RoundedCornerShape(14.dp))) { + val tuned = listOfNotNull( + stringResource(R.string.drawer_cas).takeIf { e.cas }, stringResource(R.string.drawer_deband).takeIf { e.deband }, + ) + SettingsGroup(stringResource(R.string.drawer_section_tuning), key = "effects-tune", + tag = if (preset == null) stringResource(R.string.drawer_tag_custom) else null, detail = summary(*tuned.toTypedArray())) { + run { ToggleRow(host, "cas", stringResource(R.string.drawer_cas), null, e.cas, chipModifier = track("cas")) { a.onEffects(e.copy(cas = it)) } if (e.cas) SliderRow(stringResource(R.string.drawer_cas_level), null, e.casLevel, 0..100, step = 5, format = { "$it%" }, modifier = track("cas-level")) { a.onEffects(e.copy(casLevel = it)) } @@ -1359,7 +1634,8 @@ private fun ScreenEffectsGroup( @Composable private fun CardboardGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) { val c = a.cardboard - SettingsGroup(stringResource(R.string.cardboard_title)) { + SettingsGroup(stringResource(R.string.cardboard_title), key = "vr-cardboard", + detail = stringResource(if (c.enabled) R.string.widgets_on else R.string.widgets_off)) { ToggleRow(host, "cardboard", stringResource(R.string.cardboard_mode), stringResource(R.string.cardboard_mode_hint), c.enabled, chipModifier = track("cardboard")) { a.onCardboard(c.copy(enabled = it)) } if (!c.enabled) return@SettingsGroup @@ -1392,7 +1668,8 @@ private fun CardboardGroup(host: MenuHost, a: DrawerActions, track: (String) -> @Composable private fun SteamVrGroup(a: DrawerActions, track: (String) -> Modifier) { - SettingsGroup(stringResource(R.string.steamvr_title)) { + SettingsGroup(stringResource(R.string.steamvr_title), key = "vr-steamvr", + tag = if (a.steamVr == SteamVr.Status.RUNNING) stringResource(R.string.drawer_tag_running) else null) { val vrLabel = stringResource(R.string.cardboard_steamvr) val enterLabel = stringResource(if (a.immersiveSteamVr) R.string.steamvr_enter else R.string.cardboard_steamvr_start) @Composable fun button(label: String, text: String, action: String) { @@ -1430,15 +1707,55 @@ private fun SteamVrRow(a: DrawerActions) { } } -internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boolean, desktop: Boolean): List = +internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boolean, desktop: Boolean, + steam: Boolean = com.droiddeck.launcher.session.SessionState.mode == com.droiddeck.launcher.session.SessionService.MODE_STEAM): List = (if (none) listOf(SecondScreenMode.NONE) else emptyList()) + listOf(SecondScreenMode.KEYBOARD_TRACKPAD, SecondScreenMode.TERMINAL) + (if (deckPad) listOf(SecondScreenMode.DECK_CONTROLS) else emptyList()) + listOf(SecondScreenMode.CUSTOM_CONTROLS) + (if (dashboard) listOf(SecondScreenMode.DASHBOARD) else emptyList()) + + (if (dashboard && steam) listOf(SecondScreenMode.STEAM_QAM, SecondScreenMode.ART) else emptyList()) + + (if (dashboard) listOf(SecondScreenMode.GUIDES, SecondScreenMode.MIRROR) else emptyList()) + (if (desktop) listOf(SecondScreenMode.DESKTOP) else emptyList()) private val DRAWER_MIN_WIDTH = 300.dp private val DRAWER_HANDLE_STRIP = 24.dp -private val DRAWER_EDGE_GAP = 80.dp +private val DRAWER_COLUMN_GAP = 10.dp +// Two columns once each would be as wide as the narrowest single-column sheet. +private val DRAWER_TWO_COLUMN_WIDTH = DRAWER_MIN_WIDTH * 2 + DRAWER_COLUMN_GAP + +private val SessionDrawerPage.inColumns: Boolean + get() = this != SessionDrawerPage.MORE && this != SessionDrawerPage.ACHIEVEMENTS + +/** + * On a wide sheet, lays a page's groups out in two columns, the first half on the left. The split is by count, not + * height, so a group keeps its column while others fold and unfold. + */ +@Composable +internal fun DrawerColumns(two: Boolean, content: @Composable () -> Unit) { + // Keep a single composition so resizing only remeasures existing children. + Layout(content, Modifier.fillMaxWidth()) { measurables, constraints -> + val width = constraints.maxWidth + if (!two || measurables.size < 2) { + val placeables = measurables.map { it.measure(constraints.copy(minWidth = 0, minHeight = 0)) } + return@Layout layout(width, placeables.sumOf { it.height }) { + var y = 0 + placeables.forEach { it.placeRelative(0, y); y += it.height } + } + } + val gap = DRAWER_COLUMN_GAP.roundToPx() + val column = ((width - gap) / 2).coerceAtLeast(0) + val child = Constraints(maxWidth = column) + val placeables = measurables.map { it.measure(child) } + val half = (placeables.size + 1) / 2 + val left = placeables.take(half) + val right = placeables.drop(half) + layout(width, maxOf(left.sumOf { it.height }, right.sumOf { it.height })) { + var y = 0 + left.forEach { it.placeRelative(0, y); y += it.height } + y = 0 + right.forEach { it.placeRelative(column + gap, y); y += it.height } + } + } +} /** A grip on the sheet's left edge: dragging it, or pressing left and right on a controller, resizes the sheet. */ @Composable @@ -1460,6 +1777,8 @@ private fun DrawerResizeHandle(width: Dp, min: Dp, max: Dp, onWidth: (Dp) -> Uni contentAlignment = Alignment.Center, modifier = modifier.width(24.dp).height(96.dp) .onGloballyPositioned { coords = it } + // On the screen's edge, Android's back swipe would take the drag. + .systemGestureExclusion() .focusable(true, source) .onPreviewKeyEvent { event -> val key = event.nativeKeyEvent @@ -1515,7 +1834,8 @@ private fun SecondScreenGroup(host: MenuHost, a: DrawerActions, track: (String) val swapsGame = a.gameSwapAvailable || a.gameOnBottom val hasSecondScreen = a.secondScreenDisplays.isNotEmpty() if (!hasSecondScreen && !choosesDisplay && !swapsGame) return - SettingsGroup(stringResource(R.string.drawer_second_screen)) { + SettingsGroup(stringResource(R.string.drawer_second_screen), key = "display-second", + tag = if (hasSecondScreen) stringResource(R.string.drawer_tag_attached) else null) { if (hasSecondScreen) ChoiceRow(host, "dual-screen-mode", stringResource(R.string.setup_dual_screen_sessions), null, listOf( com.droiddeck.launcher.input.DualScreen.MODE_AUTO to stringResource(R.string.setup_dual_screen_auto), @@ -1595,7 +1915,8 @@ private fun TextureFilteringGroup(host: MenuHost, a: DrawerActions, track: (Stri val lodBiasChoices: List> = (if (inherited) listOf(null to stringResource(R.string.comp_game_use_general)) else emptyList()) + SessionPrefs.textureLodBiasChoices(LocalContext.current).map { (value, label) -> value as String? to label } - SettingsGroup(stringResource(R.string.drawer_texture)) { + SettingsGroup(stringResource(R.string.drawer_texture), key = "game-textures", + detail = summary(anisotropyChoices.labelOf(a.textureAnisotropy), lodBiasChoices.labelOf(a.textureLodBias))) { ChoiceRow(host, "anisotropy", stringResource(R.string.drawer_anisotropy), null, anisotropyChoices, a.textureAnisotropy, chipModifier = track("anisotropy"), onPick = a.onTextureAnisotropy) ChoiceRow(host, "texture-sharpness", stringResource(R.string.drawer_texture_sharpness), null, @@ -1612,7 +1933,7 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S val options: List> = listOf(null to stringResource(R.string.comp_scope_general)) + a.gameProfiles.map { (id, name) -> Pair(id, name) } val profile = a.selectedGameProfile - SettingsGroup(stringResource(R.string.drawer_selected_profile)) { + SettingsGroup(stringResource(R.string.drawer_selected_profile), key = "game-profile", detail = options.labelOf(a.selectedGameProfileId)) { DrawerStackedChoice( host = host, key = "game-profile", @@ -1751,7 +2072,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin val colors = MaterialTheme.colorScheme val snap = a.components if (snap == null) { - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { Text(stringResource(R.string.comp_reading), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(14.dp)) } return @@ -1761,7 +2082,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } if (a.selectedGameProfileId != null) { if (gameProfile == null) { - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { Text( stringResource(R.string.comp_reading), fontSize = 13.sp, @@ -1771,7 +2092,7 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } return } - SettingsGroup(stringResource(R.string.drawer_page_components)) { + DrawerComponentSettingsGroup(stringResource(R.string.drawer_game_components_note, gameProfile.name)) { DrawerStackedChoice( host = host, key = "game-cmp-proton", @@ -1814,17 +2135,11 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin ) } } - Text( - stringResource(R.string.drawer_game_components_note, gameProfile.name), - fontSize = 12.sp, - color = colors.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 4.dp, vertical = 12.dp), - ) return } val running = snap.protons.filter { it.inUseByGame } val view = snap.protons.firstOrNull { it.proton.id == a.defaultProtonId } ?: running.firstOrNull() ?: snap.protons.firstOrNull() - SettingsGroup(stringResource(R.string.drawer_running_now)) { + SettingsGroup(stringResource(R.string.drawer_running_now), key = "game-running-now") { val src = remember { MutableInteractionSource() } val hot = src.collectIsFocusedAsState().value val pal = LocalPalette.current @@ -1854,13 +2169,13 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin } } if (view == null) { - SettingsGroup(stringResource(R.string.drawer_page_components)) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components") { Text(stringResource(R.string.drawer_no_proton), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(14.dp)) } return } val p = view.proton - SettingsGroup(stringResource(R.string.drawer_page_components)) { + DrawerComponentSettingsGroup(stringResource(R.string.drawer_components_note)) { DrawerStackedChoice( host, "cmp-proton", stringResource(R.string.comp_proton), listOfNotNull( @@ -1896,10 +2211,16 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin ) } } - Text( - stringResource(R.string.drawer_components_note), - fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp, vertical = 12.dp), - ) +} + +@Composable +internal fun DrawerComponentSettingsGroup(note: String, content: @Composable ColumnScope.() -> Unit) { + // The note stays visible when collapsed, but both belong to one drawer column item. + Column(Modifier.fillMaxWidth()) { + SettingsGroup(stringResource(R.string.drawer_page_components), key = "game-components", content = content) + Text(note, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(horizontal = 4.dp, vertical = 12.dp)) + } } @Composable @@ -1917,7 +2238,8 @@ internal fun ComponentDownloadsDrawerGroup( val colors = MaterialTheme.colorScheme val installed = packages.map { it.file }.toSet() val nightlyPicked = remember { mutableStateMapOf() } - SettingsGroup(stringResource(R.string.drawer_component_downloads)) { + SettingsGroup(stringResource(R.string.drawer_component_downloads), key = "game-downloads", + tag = if (downloads.isNotEmpty()) stringResource(R.string.drawer_tag_downloading) else null) { Text(stringResource(R.string.drawer_component_downloads_hint), fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp)) SettingsRow(stringResource(R.string.comp_nightlies_checked, diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt index b95dd6ae1b..4359813c07 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt @@ -39,6 +39,7 @@ internal class SettingsEntry( val words: List = emptyList(), val developer: Boolean = false, val tab: String? = null, + val frost: Boolean = false, ) { val within: Int? get() = section?.title ?: tab?.let { railLabelIcon(it).first } ?: group @@ -84,20 +85,23 @@ internal object SettingsIndex { s(SettingsSection.PERFORMANCE, R.string.perf_esync, "esync", "sync", "wine"), s(SettingsSection.PERFORMANCE, R.string.perf_fsync, "fsync", "sync", "wine"), s(SettingsSection.PERFORMANCE, R.string.perf_fastsync, "ntsync", "sync", "wine"), - s(SettingsSection.PERFORMANCE, R.string.perf_seccomp, "proot"), - s(SettingsSection.PERFORMANCE, R.string.perf_fastpath, "proot"), - s(SettingsSection.PERFORMANCE, R.string.perf_native_userland, "proot"), s(SettingsSection.PERFORMANCE, R.string.perf_cursor_composite, "mouse", "cursor"), s(SettingsSection.PERFORMANCE, R.string.perf_hostname, "name"), + s(SettingsSection.PERFORMANCE, R.string.perf_desktop_as_user, "root", "user", "sudo", "fakeroot"), s(SettingsSection.CONTROLLER, R.string.setup_tab_controller, "gamepad", "buttons", "mapping", "profile", "remap"), SettingsEntry(SettingsPlace.TAB, R.string.rail_storage, tab = "storage", words = listOf("sd card", "space", "uninstall", "disk")), + SettingsEntry(SettingsPlace.TAB, R.string.storage_shared_mount, tab = "storage", words = listOf("sdcard", "mount", "privacy", "files")), SettingsEntry(SettingsPlace.TAB, R.string.rail_sync, tab = "sync", words = listOf("syncthing", "saves")), SettingsEntry(SettingsPlace.TAB, R.string.rail_decky, tab = "decky", words = listOf("plugins", "plugin store", "homebrew", "loader")), SettingsEntry(SettingsPlace.TAB, R.string.rail_boot_movies, tab = "boot-movies", words = listOf("startup movie", "boot video", "animation", "steamdeckrepo")), s(SettingsSection.GLASSES, R.string.setup_tab_glasses, "xreal", "viture", "vr", "ar"), s(SettingsSection.LAUNCHER, R.string.setup_theme, "color", "dark"), + SettingsEntry( + SettingsPlace.SETTINGS, R.string.setup_frosted_background, section = SettingsSection.LAUNCHER, frost = true, + words = listOf("blur", "wallpaper", "background", "cards", "transparent", "transparency", "opacity", "glass"), + ), s(SettingsSection.LAUNCHER, R.string.setup_app_scale, "size", "zoom"), s(SettingsSection.LAUNCHER, R.string.setup_launcher_icon), s(SettingsSection.LAUNCHER, R.string.setup_animations), @@ -109,7 +113,8 @@ internal object SettingsIndex { s(SettingsSection.LAUNCHER, R.string.setup_home, "home screen", "launcher"), s(SettingsSection.LAUNCHER, R.string.setup_launcher_orientation, "rotate", "portrait"), s(SettingsSection.LAUNCHER, R.string.setup_session_orientation, "rotate", "portrait"), - s(SettingsSection.LAUNCHER, R.string.setup_fullscreen), + s(SettingsSection.LAUNCHER, R.string.setup_launcher_fullscreen, "status bar", "navigation bar", "portrait"), + s(SettingsSection.LAUNCHER, R.string.setup_session_fullscreen, "status bar", "navigation bar", "portrait"), s(SettingsSection.LAUNCHER, R.string.setup_page_swipe, "gesture"), s(SettingsSection.LAUNCHER, R.string.setup_controller_haptics, "vibration", "rumble"), s(SettingsSection.LAUNCHER, R.string.setup_dual_screen_launcher, "thor", "second screen", "bottom screen"), @@ -123,7 +128,8 @@ internal object SettingsIndex { s(SettingsSection.DEVELOPER, R.string.setup_game_debug_logs, "logs", "wine", "proton"), SettingsEntry(SettingsPlace.SETTINGS, R.string.setup_enhanced_diagnostics, section = SettingsSection.DEVELOPER, words = listOf("logs"), developer = true), s(SettingsSection.DEVELOPER, R.string.setup_reset_settings, "default"), - s(SettingsSection.DEVELOPER, R.string.dev_tools_title, "agent", "ai", "claude", "codex"), + s(SettingsSection.DEVELOPER, R.string.dev_tools_show, "agent", "ai", "claude", "codex"), + SettingsEntry(SettingsPlace.SETTINGS, R.string.setup_agent_commands, section = SettingsSection.DEVELOPER, words = listOf("debugging tools", "cli"), developer = true), SettingsEntry(SettingsPlace.SETTINGS, R.string.setup_graphics_logs, section = SettingsSection.DEVELOPER, words = listOf("logs", "gpu"), developer = true), d(R.string.drawer_page_display, R.string.drawer_frame_limit, "fps", "cap", "limit", "non-steam", "desktop"), @@ -149,6 +155,6 @@ internal object SettingsIndex { sh(R.string.stores_tab_library, R.string.stores_tab_library, "second library", "sd card", "steam library"), ) - fun search(context: Context, query: String): List = - entries.filter { (!it.developer || DeveloperTools.on) && it.matches(context, query) } + fun search(context: Context, query: String, frost: Boolean = false): List = + entries.filter { (!it.developer || DeveloperTools.on) && (!it.frost || frost) && it.matches(context, query) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsJump.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsJump.kt new file mode 100644 index 0000000000..c0357dae4b --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsJump.kt @@ -0,0 +1,86 @@ +package com.droiddeck.launcher.ui + +import android.os.SystemClock +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.tween +import androidx.compose.foundation.relocation.BringIntoViewRequester +import androidx.compose.foundation.relocation.bringIntoViewRequester +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.SideEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.withFrameNanos +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.drawBehind +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.layout.LayoutCoordinates +import androidx.compose.ui.layout.onPlaced + +/** The row a settings search result opens, so the page it lands on can scroll to it and flash it. */ +internal object SettingsJump { + class Target(val label: String, val at: Long = SystemClock.uptimeMillis()) + + var target: Target? by mutableStateOf(null) + + fun to(label: String) { target = Target(label) } +} + +private const val JUMP_WINDOW_MS = 5_000L + +/** False in the search results, whose rows carry the same labels as the rows they open. */ +internal val LocalSearchTargets = staticCompositionLocalOf { true } + +/** How far a page has to be scrolled to show a row in its middle, or as near to it as the page's ends allow. */ +internal fun centeredScroll(rowTop: Float, rowHeight: Float, page: Float, content: Float): Float = + (rowTop + rowHeight / 2f - page / 2f).coerceIn(0f, (content - page).coerceAtLeast(0f)) + +/** The part of the page to show around a row to have it in the middle, relative to the row. Null when nothing around it scrolls. */ +private fun pageAround(row: LayoutCoordinates): Rect? { + var content = row + while (true) { + val page = content.parentCoordinates ?: return null + if (content.size.height > page.size.height) { + val top = content.localPositionOf(row, Offset.Zero).y + val height = page.size.height.toFloat() + val from = centeredScroll(top, row.size.height.toFloat(), height, content.size.height.toFloat()) - top + return Rect(0f, from, row.size.width.toFloat(), from + height) + } + content = page + } +} + +@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class) +@Composable +internal fun Modifier.searchTarget(label: String): Modifier { + val pal = LocalPalette.current + val flash = remember { Animatable(0f) } + val reveal = remember { BringIntoViewRequester() } + val row = remember { arrayOfNulls(1) } + var claimed by remember { mutableStateOf(null) } + val target = SettingsJump.target.takeIf { LocalSearchTargets.current } + if (target != null && target.label == label) SideEffect { + if (SettingsJump.target === target) { + SettingsJump.target = null + if (SystemClock.uptimeMillis() - target.at <= JUMP_WINDOW_MS) claimed = target + } + } + claimed?.let { mine -> + LaunchedEffect(mine) { + withFrameNanos { } + reveal.bringIntoView(row[0]?.takeIf { it.isAttached }?.let(::pageAround)) + repeat(2) { + flash.animateTo(1f, tween(220)) + flash.animateTo(0f, tween(420)) + } + claimed = null + } + } + return bringIntoViewRequester(reveal).onPlaced { row[0] = it }.drawBehind { + if (flash.value > 0f) drawRect(pal.signal.copy(alpha = 0.28f * flash.value)) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearch.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearch.kt index 0a4ab5590c..0c12348717 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearch.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearch.kt @@ -42,7 +42,7 @@ import androidx.compose.ui.semantics.clearAndSetSemantics @Composable internal fun SettingsPillSearch( modifier: Modifier, searching: Boolean, query: String, onQuery: (String) -> Unit, - onOpen: () -> Unit, onClose: () -> Unit, pills: @Composable () -> Unit, + onOpen: () -> Unit, onClose: () -> Unit, keepOpen: Boolean = false, onSearch: () -> Unit = {}, pills: @Composable () -> Unit, ) { val colors = MaterialTheme.colorScheme val open by animateFloatAsState(if (searching) 1f else 0f, Motion.sp(0.75f, 420f), label = "settingsSearch") @@ -53,10 +53,11 @@ internal fun SettingsPillSearch( var fieldFocused by remember { mutableStateOf(false) } CancelPendingFocus(focusOnOpen, focusTap, fieldFocused) { focusOnOpen = false - if (query.isEmpty()) onClose() + if (query.isEmpty() && !keepOpen) onClose() } val close = { toIcon = true; focusOnOpen = false; onClose() } BackHandler(enabled = searching) { close() } + LaunchedEffect(keepOpen) { if (!keepOpen && searching && !fieldFocused && !focusOnOpen && query.isEmpty()) close() } LaunchedEffect(toIcon, searching, open <= 0.01f) { if (searching) toIcon = false else if (toIcon && open <= 0.01f) { focusSoon { icon }; toIcon = false } @@ -80,10 +81,13 @@ internal fun SettingsPillSearch( AdbTextField( value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, placeholder = stringResource(R.string.settings_search), compact = true, showLabel = false, focusOnShow = focusOnOpen, focusAtTap = focusTap, - clearFocus = !searching, + clearFocus = !searching, onDone = onSearch, onFocusChange = { focused -> fieldFocused = focused - if (!focused && query.isEmpty() && searching) { focusOnOpen = false; onClose() } + if (!focused && query.isEmpty() && searching) { + focusOnOpen = false + if (!keepOpen) onClose() + } }, ) } @@ -96,14 +100,20 @@ internal fun SettingsPillSearch( } @Composable -internal fun SettingsSearchResults(query: String, onOpen: (SettingsSection) -> Unit) { +internal fun SettingsSearchResults(query: String, frost: Boolean, focusFirst: Boolean = false, onSearched: () -> Unit = {}, onOpen: (SettingsSection) -> Unit) { val ctx = LocalContext.current - val found = remember(query) { SettingsIndex.search(ctx, query) } + val found = remember(query, frost) { SettingsIndex.search(ctx, query, frost) } if (found.isEmpty()) { Note(stringResource(R.string.settings_search_none, query.trim())) return } - Column { + val first = remember { FocusRequester() } + val firstToOpen = found.groupBy { it.place }.values.flatten().firstOrNull { it.section != null || it.tab != null } + val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current + LaunchedEffect(Unit) { + if (focusFirst && firstToOpen != null && inputMode.inputMode == androidx.compose.ui.input.InputMode.Keyboard) focusSoon { first } + } + androidx.compose.runtime.CompositionLocalProvider(LocalSearchTargets provides false) { Column { found.groupBy { it.place }.forEach { (place, entries) -> SettingsGroup(stringResource(place.title)) { entries.forEach { entry -> @@ -111,10 +121,13 @@ internal fun SettingsSearchResults(query: String, onOpen: (SettingsSection) -> U val title = stringResource(entry.title) val section = entry.section val tab = entry.tab + val button = if (entry === firstToOpen) Modifier.focusRequester(first) else Modifier if (section != null) { - ActionRow(title, within, stringResource(R.string.store_open), onClick = { onOpen(section) }) + ActionRow(title, within, stringResource(R.string.store_open), modifier = button, onClick = { onSearched(); SettingsJump.to(title); onOpen(section) }) } else if (tab != null) { - ActionRow(title, within, stringResource(R.string.store_open), onClick = { + ActionRow(title, within, stringResource(R.string.store_open), modifier = button, onClick = { + onSearched() + SettingsJump.to(title) if (tab == NavTabs.MORE) MoreTabs.editing = true if (tab == "downloads") DownloadsNav.showSettings = true RailRequest.key = tab @@ -125,5 +138,5 @@ internal fun SettingsSearchResults(query: String, onOpen: (SettingsSection) -> U } } } - } + } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearchHistory.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearchHistory.kt new file mode 100644 index 0000000000..10c0364e23 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsSearchHistory.kt @@ -0,0 +1,101 @@ +package com.droiddeck.launcher.ui + +import android.content.Context +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.hoverable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Delete +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.droiddeck.launcher.R +import com.droiddeck.launcher.session.SessionPrefs + +/** What was searched for in Settings, newest first. */ +internal object SettingsSearchHistory { + const val MAX = 8 + + var items by mutableStateOf>(emptyList()) + private set + + fun load(context: Context) { items = SessionPrefs.settingsSearches(context) } + + fun add(context: Context, query: String) { + val next = withSearch(items, query) + if (next == items) return + items = next + SessionPrefs.setSettingsSearches(context, next) + } + + fun clear(context: Context) { + items = emptyList() + SessionPrefs.setSettingsSearches(context, emptyList()) + } + + fun withSearch(items: List, query: String): List { + val text = query.trim().replace(Regex("\\s+"), " ") + if (text.isEmpty()) return items + return (listOf(text) + items.filterNot { it.equals(text, ignoreCase = true) }).take(MAX) + } +} + +@OptIn(ExperimentalLayoutApi::class) +@Composable +internal fun SettingsSearchHistoryList(onPick: (String) -> Unit, onClear: () -> Unit) { + val colors = MaterialTheme.colorScheme + Column(Modifier.fillMaxWidth()) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 12.dp, bottom = 8.dp)) { + Text( + stringResource(R.string.settings_search_history), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, + modifier = Modifier.weight(1f).padding(start = 4.dp), + ) + SmallIconButton(Icons.Outlined.Delete, stringResource(R.string.settings_search_history_clear), tint = colors.onSurfaceVariant, onClick = onClear) + } + FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { + SettingsSearchHistory.items.forEach { HistoryChip(it) { onPick(it) } } + } + } +} + +@Composable +private fun HistoryChip(text: String, onClick: () -> Unit) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val src = remember { MutableInteractionSource() } + val hot = rememberHot(src) + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.heightIn(min = 40.dp).widthIn(min = 56.dp, max = 260.dp).clip(CircleShape) + .background(colors.surface).glideBorder(hot, CircleShape, pal.signal, pal.line) + .hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClick = onClick) + .controllerConfirm(onClick = onClick) + .padding(horizontal = 16.dp, vertical = 8.dp), + ) { Text(text, fontSize = 14.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt index 977fb98c44..767ea55449 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt @@ -87,6 +87,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.TransformOrigin import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.input.key.onPreviewKeyEvent +import androidx.compose.ui.node.currentValueOf import androidx.compose.foundation.focusable import androidx.compose.foundation.gestures.detectHorizontalDragGestures import androidx.compose.foundation.gestures.detectTapGestures @@ -152,14 +153,43 @@ internal fun Modifier.blockTouches(): Modifier = pointerInput(Unit) { detectTapG internal fun Modifier.tapOutside(onTap: () -> Unit): Modifier = pointerInput(onTap) { detectTapGestures(onTap = { onTap() }) } -internal fun Modifier.bumpers(onPrevious: () -> Unit, onNext: () -> Unit): Modifier = onPreviewKeyEvent { event -> - val keyEvent = event.nativeKeyEvent - val previous = keyEvent.keyCode == KeyEvent.KEYCODE_BUTTON_L1 - if (!previous && keyEvent.keyCode != KeyEvent.KEYCODE_BUTTON_R1) { - false - } else { - if (keyEvent.action == KeyEvent.ACTION_DOWN && keyEvent.repeatCount == 0) { if (previous) onPrevious() else onNext() } - true +internal fun Modifier.bumpers(onPrevious: () -> Unit, onNext: () -> Unit): Modifier = this then BumpersElement(onPrevious, onNext) + +private data class BumpersElement(val onPrevious: () -> Unit, val onNext: () -> Unit) : + androidx.compose.ui.node.ModifierNodeElement() { + override fun create() = BumpersNode(onPrevious, onNext) + override fun update(node: BumpersNode) { + node.onPrevious = onPrevious + node.onNext = onNext + } +} + +internal class BumpersNode(var onPrevious: () -> Unit, var onNext: () -> Unit) : + Modifier.Node(), androidx.compose.ui.input.key.KeyInputModifierNode, androidx.compose.ui.node.CompositionLocalConsumerModifierNode { + override fun onAttach() { PageBumpers.attached += this } + override fun onDetach() { PageBumpers.attached -= this } + override fun onPreKeyEvent(event: androidx.compose.ui.input.key.KeyEvent): Boolean = PageBumpers.handle(event.nativeKeyEvent, this) + override fun onKeyEvent(event: androidx.compose.ui.input.key.KeyEvent): Boolean = false + + @OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class) + fun step(previous: Boolean) { + releaseFocusedTextField(currentValueOf(androidx.compose.ui.platform.LocalView)) + OpenMenus.leaveAll(withPage = false) + if (previous) onPrevious() else onNext() + // Android keeps touch mode through gamepad buttons, and the pages move the focus only outside it. + val input = currentValueOf(LocalInputModeManager) + if (input.inputMode != InputMode.Keyboard) input.requestInputMode(InputMode.Keyboard) + } +} + +internal object PageBumpers { + val attached = ArrayList() + + fun handle(event: KeyEvent, node: BumpersNode? = attached.lastOrNull()): Boolean { + val previous = event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 + if (node == null || (!previous && event.keyCode != KeyEvent.KEYCODE_BUTTON_R1)) return false + if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) node.step(previous) + return true } } @@ -170,7 +200,7 @@ internal val LocalRevealChecked = androidx.compose.runtime.compositionLocalOf { internal fun TabStrip( tabs: List, selected: Int, onSelect: (Int) -> Unit, modifier: Modifier = Modifier, focusRequesters: List? = null, - bumpers: Boolean = true, compact: Boolean = false, + bumpers: Boolean = true, compact: Boolean = false, centered: Boolean = false, ) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current @@ -181,8 +211,10 @@ internal fun TabStrip( val tabPadding = if (compact) 10.dp else if (tight) 10.dp else 16.dp Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = modifier) { if (bumpers) BumperKey("LB", stringResource(R.string.widgets_prev_tab)) { onSelect((selected + tabs.size - 1) % tabs.size) } - Row( - modifier = Modifier.weight(1f, fill = false).clip(shape).background(colors.surfaceVariant).border(1.dp, pal.line2, shape) + // Centred, the bumpers sit at the edges and the tabs in the middle, as in the bottom bar. + Box(if (centered) Modifier.weight(1f) else Modifier.weight(1f, fill = false), contentAlignment = Alignment.Center) { androidx.compose.foundation.layout.BoxWithConstraints { + if (tabsAsMenu(maxWidth, tabs.size)) TabMenu(tabs, selected, onSelect, focus = focusRequesters) else Row( + modifier = Modifier.clip(shape).background(colors.surfaceVariant).border(1.dp, pal.line2, shape) .horizontalScroll(scroll).selectableGroup().padding(3.dp), ) { tabs.forEachIndexed { i, label -> @@ -208,7 +240,7 @@ internal fun TabStrip( .padding(horizontal = tabPadding, vertical = if (compact) 6.dp else 12.dp), ) } - } + } } } if (bumpers) BumperKey("RB", stringResource(R.string.widgets_next_tab)) { onSelect((selected + 1) % tabs.size) } } } @@ -266,6 +298,25 @@ private class BelowEndProvider(private val gap: Int) : PopupPositionProvider { } } +private val StepKeys = setOf(KeyEvent.KEYCODE_BUTTON_L1, KeyEvent.KEYCODE_BUTTON_R1, KeyEvent.KEYCODE_BUTTON_L2, KeyEvent.KEYCODE_BUTTON_R2) + +private fun launcherOf(view: android.view.View) = view.context.findActivity() as? com.droiddeck.launcher.FrontEndActivity + +// A popup is a window of its own, so controller input sent to it never reaches the launcher's. +private fun Modifier.passSteps(host: android.view.View): Modifier = onPreviewKeyEvent { event -> + event.nativeKeyEvent.keyCode in StepKeys && launcherOf(host) != null && host.rootView.dispatchKeyEvent(event.nativeKeyEvent) +} + +@Composable +private fun PassTriggerMotion(host: android.view.View) { + val popup = androidx.compose.ui.platform.LocalView.current + androidx.compose.runtime.DisposableEffect(popup, host) { + val launcher = launcherOf(host)?.takeIf { it.window.decorView === host.rootView } + if (launcher != null) popup.setOnGenericMotionListener { _, event -> launcher.onMenuMotion(event); false } + onDispose { popup.setOnGenericMotionListener(null) } + } +} + @OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class) @Composable fun AnchoredMenu( @@ -276,6 +327,13 @@ fun AnchoredMenu( val state = remember { MutableTransitionState(false) } state.targetState = open if (!state.currentState && !state.targetState && state.isIdle) return + val dismissNow = rememberUpdatedState(onDismiss) + if (open) androidx.compose.runtime.DisposableEffect(Unit) { + val leave = { _: Boolean -> dismissNow.value() } + OpenMenus.leave += leave + onDispose { OpenMenus.leave -= leave } + } + val hostView = androidx.compose.ui.platform.LocalView.current val firstItemFocus = remember { FocusRequester() } val inputMode = LocalInputModeManager.current.inputMode LaunchedEffect(open, inputMode) { @@ -293,6 +351,7 @@ fun AnchoredMenu( val pal = LocalPalette.current Popup(popupPositionProvider = provider, onDismissRequest = onDismiss, properties = PopupProperties(focusable = true)) { TrackKeyWindow() + PassTriggerMotion(hostView) val popupInput = LocalInputModeManager.current LaunchedEffect(open, inputMode) { if (!open || inputMode != InputMode.Keyboard) return@LaunchedEffect @@ -306,7 +365,7 @@ fun AnchoredMenu( runCatching { firstItemFocus.requestFocus() } } } - CompositionLocalProvider(LocalDensity provides density, LocalConfiguration provides configuration) { + SolidSurfaces { CompositionLocalProvider(LocalDensity provides density, LocalConfiguration provides configuration) { AnimatedVisibility( visibleState = state, enter = fadeIn(Motion.tw(180)) + scaleIn(Motion.sp(0.7f), initialScale = 0.94f, transformOrigin = TransformOrigin(if (compact) 0f else 1f, 0f)), @@ -322,6 +381,7 @@ fun AnchoredMenu( .clip(RowShape) .background(pal.surfaceVariant.copy(alpha = 0.95f)) .border(1.dp, pal.signal.copy(alpha = 0.22f), RowShape) + .passSteps(hostView) .controllerBack(onDismiss) .padding(6.dp), ) { @@ -362,7 +422,7 @@ fun AnchoredMenu( } } } - } + } } } } @@ -396,12 +456,13 @@ fun MenuItem( .padding(horizontal = 10.dp, vertical = 9.dp), ) { Text("✓", fontSize = 12.sp, color = pal.signal, modifier = Modifier.width(18.dp).alpha(if (checked) 1f else 0f).clearAndSetSemantics {}) + val ink = if (checked) pal.signal else colors.onBackground if (leading != null) { - leading() + androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides ink) { leading() } Spacer(Modifier.width(8.dp)) } Column(modifier = Modifier.weight(1f)) { - Text(label, fontSize = 13.5.sp, color = if (checked) pal.signal else colors.onBackground, maxLines = 2, overflow = TextOverflow.Ellipsis) + Text(label, fontSize = 13.5.sp, color = ink, maxLines = 2, overflow = TextOverflow.Ellipsis) if (detail != null) Text(detail, fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) } if (trailing != null) { Spacer(Modifier.width(8.dp)); trailing() } @@ -442,7 +503,11 @@ fun ValueChip(text: String, open: Boolean, enabled: Boolean = true, modifier: Mo } @Composable -fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, content: @Composable ColumnScope.() -> Unit) { +fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = null, key: String? = null, tag: String? = null, content: @Composable ColumnScope.() -> Unit) { + LocalDrawerSections.current?.let { sections -> + DrawerSection(sections, key ?: title, title, detail, tag, content) + return + } val tight = compact || LocalCompactSettings.current val colors = MaterialTheme.colorScheme val pal = LocalPalette.current @@ -461,7 +526,7 @@ fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = nul } @Composable -fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, control: @Composable () -> Unit) { +fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, tightControlSpacing: Boolean = false, sideBySide: Boolean = false, control: @Composable () -> Unit) { val compact = LocalCompactSettings.current val colors = MaterialTheme.colorScheme val pal = LocalPalette.current @@ -471,8 +536,8 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint lineHeight = if (compact) 14.sp else androidx.compose.ui.unit.TextUnit.Unspecified, minLines = hintLines ?: 1, maxLines = hintLines ?: Int.MAX_VALUE, overflow = TextOverflow.Ellipsis) } - if (compact && !stacked) Column( - modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp), + if (compact && !stacked && !sideBySide) Column( + modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp), ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { Text(label, fontSize = 13.sp, lineHeight = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, @@ -480,19 +545,19 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint control() } if (hint != null || hintLines != null) hintText(11.sp) - } else if (stacked || LocalNarrowPane.current) Column( - modifier = Modifier.fillMaxWidth().background(bg).padding( + } else if (stacked || (LocalNarrowPane.current && !sideBySide)) Column( + modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding( horizontal = if (compact) 10.dp else 14.dp, - vertical = if (compact) 6.dp else 12.dp), + vertical = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 12.dp), ) { Text(label, fontSize = if (compact) 13.sp else 15.sp, lineHeight = if (compact) 16.sp else androidx.compose.ui.unit.TextUnit.Unspecified, fontWeight = FontWeight.SemiBold, color = colors.onBackground) if (hint != null || hintLines != null) hintText(if (compact) 11.sp else 13.sp) - Box(Modifier.padding(top = if (compact) 6.dp else 8.dp)) { control() } + Box(Modifier.padding(top = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 8.dp)) { control() } } else Row( verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp), + modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp), ) { Column(modifier = Modifier.weight(1f).padding(end = 12.dp)) { Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) @@ -510,9 +575,10 @@ fun ChoiceRow( chipModifier: Modifier = Modifier, hintLines: Int? = null, stacked: Boolean = false, + sideBySide: Boolean = false, onPick: (T) -> Unit, ) { - SettingsRow(label, hint, highlighted = host.open == key, hintLines = hintLines, stacked = stacked) { + SettingsRow(label, hint, highlighted = host.open == key, hintLines = hintLines, stacked = stacked, sideBySide = sideBySide) { ChoiceChip(host, key, label, options, selected, enabled, note, chipModifier, onPick) } } @@ -548,8 +614,8 @@ fun UncertainMark(description: String) { } @Composable -fun ToggleRow(host: MenuHost, key: String, label: String, hint: String?, checked: Boolean, enabled: Boolean = true, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) = - SettingsRow(label, hint) { +fun ToggleRow(host: MenuHost, key: String, label: String, hint: String?, checked: Boolean, enabled: Boolean = true, chipModifier: Modifier = Modifier, sideBySide: Boolean = false, onChange: (Boolean) -> Unit) = + SettingsRow(label, hint, sideBySide = sideBySide) { ToggleSwitch(checked, enabled, label, chipModifier.testTag("setting-$key")) { host.open = null; onChange(it) } } @@ -596,7 +662,7 @@ fun SliderRow( ) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - Column(Modifier.fillMaxWidth()) { + Column(Modifier.searchTarget(label).fillMaxWidth()) { ValueSlider(value, range, step, enabled, label, format, modifier = modifier.padding(horizontal = 6.dp, vertical = 3.dp), onChange = onChange) if (hint != null) Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, @@ -687,6 +753,7 @@ fun ValueSlider( fun MultiRow( host: MenuHost, key: String, label: String, hint: String?, items: List>, selected: Set, enabled: Boolean = true, note: String? = null, + sideBySide: Boolean = false, onToggle: (Int, Boolean) -> Unit, ) { val open = host.open == key @@ -695,7 +762,7 @@ fun MultiRow( selected.isEmpty() -> stringResource(R.string.widgets_none) else -> stringResource(R.string.widgets_n_of_m, selected.size, items.size) } - SettingsRow(label, hint, highlighted = open) { + SettingsRow(label, hint, highlighted = open, sideBySide = sideBySide) { Box { ValueChip(summary, open, enabled) { host.open = if (open) null else key } AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = label, note = note) { firstItemFocus -> @@ -709,8 +776,10 @@ fun MultiRow( } @Composable -fun ActionRow(label: String, hint: String?, button: String, onClick: () -> Unit, progress: Float? = null, modifier: Modifier = Modifier) { - SettingsRow(label, hint) { SecondaryButton(button, modifier = modifier, progress = progress, onClick = onClick) } +fun ActionRow(label: String, hint: String?, button: String, onClick: () -> Unit, progress: Float? = null, modifier: Modifier = Modifier, sideBySide: Boolean = false) { + SettingsRow(label, hint, sideBySide = sideBySide) { + SecondaryButton(button, compact = sideBySide, modifier = modifier, progress = progress, onClick = onClick) + } } @Composable diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SheetRows.kt b/app/src/main/java/com/droiddeck/launcher/ui/SheetRows.kt index 181a837065..af9136fba4 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SheetRows.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SheetRows.kt @@ -2,7 +2,10 @@ package com.droiddeck.launcher.ui import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp import com.droiddeck.launcher.R @@ -12,8 +15,26 @@ internal fun FrameGenGroup(s: FrontEndState, a: FrontEndActions) { SettingsGroup(stringResource(R.string.frame_gen_title)) { SettingsRow(stringResource(R.string.frame_gen_title), stringResource(R.string.frame_gen_hint), highlighted = host.open == "fg") { Box { - ValueChip(s.frameGenLabel, host.open == "fg") { host.open = if (host.open == "fg") null else "fg" } - FrameGenMenu(host, s.frameGen, s.lossless, a.onFrameGenPick, a.onImportLossless) + val open = host.open == "fg" + ValueChip(s.frameGenLabel, open) { host.open = if (open) null else "fg" } + AnchoredMenu( + open = open, + onDismiss = { if (host.open == "fg") host.open = null }, + title = stringResource(R.string.frame_gen_title), + compact = true, + minWidth = 220.dp, + ) { firstItemFocus -> + FrameGenMenu( + mode = s.frameGen, + lossless = s.lossless, + onPick = { mode -> + a.onFrameGenPick(mode) + host.open = null + }, + focusModifier = Modifier.focusRequester(firstItemFocus), + legacyButtons = true, + ) + } } } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt b/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt index 0551f602fd..95a4ece552 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SteamHome.kt @@ -82,7 +82,26 @@ import kotlinx.coroutines.withContext private const val WALL_MIN_GAMES = 4 private const val WALL_DISTINCT = 40 -private const val DRIFT_STEP_NS = 15_000_000L +internal val IdleFrames = IdleFrameGate() + +internal class IdleFrameGate { + private var next = Long.MIN_VALUE + private var shown = Long.MIN_VALUE + + fun due(nanos: Long): Boolean { + if (nanos == shown) return true + // Allow sub-ms vsync jitter; carry the phase on panels whose refresh isn't a multiple of 60. + if (nanos + VSYNC_TOLERANCE_NS < next) return false + next = if (next == Long.MIN_VALUE || nanos - next >= FRAME_NS) nanos + FRAME_NS else next + FRAME_NS + shown = nanos + return true + } + + private companion object { + const val FRAME_NS = 1_000_000_000L / 60 + const val VSYNC_TOLERANCE_NS = 500_000L + } +} @Composable internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) { @@ -102,7 +121,8 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) } val owned = remember(ownedAll, concealed) { ownedAll.filter { it.first.toLong() !in concealed } } val featured = remember(featuredAll, concealed) { featuredAll.filter { it.appId.toLong() !in concealed } } - val games = remember(s.steamGames, LibraryHidden.keys, LibraryHidden.steam) { s.steamGames.filterNot { LibraryHidden.isHidden(hideKey(it), it) }.sortedWith(compareByDescending { it.lastPlayed }.thenBy { it.gameId }) } + val previewing = DevPreview.steamHome + val games = remember(s.steamGames, previewing, LibraryHidden.keys, LibraryHidden.steam) { (if (previewing == SteamHomePreview.OFF) s.steamGames else sampleSteamHomeGames(previewing.games)).filterNot { LibraryHidden.isHidden(hideKey(it), it) }.sortedWith(compareByDescending { it.lastPlayed }.thenBy { it.gameId }) } val narrow = LocalNarrowPane.current var words by remember { mutableStateOf(null) } val mode = com.droiddeck.launcher.session.SessionService.MODE_STEAM @@ -152,12 +172,12 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier) games.isEmpty() -> EmptyLibrary( avoid = words, wall = if (owned.isEmpty() && featured.isEmpty()) null else { { CapsuleWall(emptyList(), owned = owned, featured = featured) } }, - ) { Box(Modifier.fillMaxSize().graphicsLayer { scaleX = 1.06f; scaleY = 1.06f }) { WallFade() } } + ) { Box(Modifier.fillMaxSize().graphicsLayer { scaleX = 1.06f; scaleY = 1.06f }) { WallFade(bottomWhenTall = true) } } games.size < WALL_MIN_GAMES -> CapsuleFan(games) else -> CapsuleWall(games, owned = owned, featured = featured) } }, - scrim = { if (games.size >= WALL_MIN_GAMES) WallFade() }, + scrim = { if (games.size >= WALL_MIN_GAMES) WallFade(bottomWhenTall = true) }, words = { val onboardingActive by com.droiddeck.launcher.session.Onboarding.active.collectAsState() val onboardingFailed by com.droiddeck.launcher.session.Onboarding.failed.collectAsState() @@ -221,19 +241,35 @@ internal fun Modifier.overhang(by: androidx.compose.ui.unit.Dp = 4.dp): Modifier } @Composable -internal fun WallFade(modifier: Modifier = Modifier.fillMaxSize().overhang()) { +internal fun WallFade(modifier: Modifier = Modifier.fillMaxSize().overhang(), bottomWhenTall: Boolean = false) { val colors = MaterialTheme.colorScheme - Box( - modifier.background( - Brush.horizontalGradient( - 0f to colors.background.copy(alpha = 0.86f), - 0.34f to colors.background.copy(alpha = 0.6f), - 0.68f to colors.background.copy(alpha = 0.14f), - 1f to colors.background.copy(alpha = 0.04f), - ), - ), - ) - Box(modifier.background(Brush.verticalGradient(0.6f to Color.Transparent, 1f to colors.background.copy(alpha = 0.75f)))) + BoxWithConstraints(modifier) { + if (bottomWhenTall && maxHeight > maxWidth) { + // The words sit at the bottom of a tall page, so the art stays clear above them and darkens only behind them. + Box( + Modifier.fillMaxSize().background( + Brush.verticalGradient( + 0f to colors.background.copy(alpha = 0.12f), + 0.5f to colors.background.copy(alpha = 0.18f), + 0.72f to colors.background.copy(alpha = 0.72f), + 1f to colors.background.copy(alpha = 0.94f), + ), + ), + ) + } else { + Box( + Modifier.fillMaxSize().background( + Brush.horizontalGradient( + 0f to colors.background.copy(alpha = 0.86f), + 0.34f to colors.background.copy(alpha = 0.6f), + 0.68f to colors.background.copy(alpha = 0.14f), + 1f to colors.background.copy(alpha = 0.04f), + ), + ), + ) + Box(Modifier.fillMaxSize().background(Brush.verticalGradient(0.6f to Color.Transparent, 1f to colors.background.copy(alpha = 0.75f)))) + } + } } @Composable @@ -281,7 +317,7 @@ internal fun TiltedWall( var shown = 0L while (true) withFrameNanos { now -> if (shown == 0L) shown = now - else if (now - shown >= DRIFT_STEP_NS) { + else if (IdleFrames.due(now)) { drift.floatValue = ((drift.floatValue + (now - shown) / (period.value * 1_000_000.0 * Motion.scale)) % 1.0).toFloat() shown = now } @@ -376,31 +412,45 @@ private fun CapsuleFan(games: List) { transition.animateFloat(0f, 1f, infiniteRepeatable(tween(ms, easing = FastOutSlowInEasing), RepeatMode.Reverse), label = "float") } val still = Motion.scale == 0f - val slots = listOf( + val landscape = listOf( FanSlot(0.54f, 0.14f, 0.62f, -9f), FanSlot(0.70f, 0.24f, 0.56f, 5f), FanSlot(0.40f, 0.30f, 0.50f, -17f), ) + // A tall page sizes the cards from its width, so they fit any aspect; heights are fractions of the width. + val portrait = listOf( + FanSlot(0.27f, 0.11f, 0.70f, -9f), + FanSlot(0.55f, 0.19f, 0.64f, 5f), + FanSlot(0.04f, 0.26f, 0.56f, -17f), + ) BoxWithConstraints( Modifier.fillMaxSize().drawBehind { drawRect( Brush.radialGradient( listOf(pal.signal.copy(alpha = 0.14f), Color.Transparent), - center = Offset(size.width * 0.68f, size.height * 0.45f), radius = size.height * 0.6f, + center = if (size.height > size.width) Offset(size.width * 0.55f, size.height * 0.28f) else Offset(size.width * 0.68f, size.height * 0.45f), + radius = if (size.height > size.width) size.width * 0.9f else size.height * 0.6f, ), ) }, ) { val radius = with(density) { 14.dp.toPx() } + val tall = maxHeight > maxWidth + val slots = if (tall) portrait else landscape for (i in games.indices.reversed()) { val slot = slots[i] - val h = maxHeight * slot.height + val h = if (tall) maxWidth * slot.height else maxHeight * slot.height + val x = if (tall) { + // The lean and the float swing the corners out by about h/2 * sin(angle). + val swing = h * kotlin.math.sin(Math.toRadians(kotlin.math.abs(slot.lean) + 2.0)).toFloat() / 2f + (maxWidth * slot.x).coerceIn(swing, (maxWidth - h * 2f / 3f - swing).coerceAtLeast(swing)) + } else maxWidth * slot.x val v: State = floats[i] val look = WallCapsule(artBrush(hueOf(games[i].name)), games[i].art) val art = look.art?.let { rememberCapsuleArt(it, with(density) { Size((h * 2f / 3f).toPx(), h.toPx()) }, radius) } Spacer( Modifier - .offset(x = maxWidth * slot.x, y = maxHeight * slot.y) + .offset(x = x, y = maxHeight * slot.y) .size(h * 2f / 3f, h) .graphicsLayer { val t = if (still) 0f else v.value diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SteamIntegrationGroup.kt b/app/src/main/java/com/droiddeck/launcher/ui/SteamIntegrationGroup.kt index e7b6a09b19..5e162e6e60 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SteamIntegrationGroup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SteamIntegrationGroup.kt @@ -37,6 +37,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -67,20 +68,48 @@ internal fun SteamIntegration.State.enabled(feature: Feature) = when (feature) { internal fun SteamIntegration.State.enabledCount() = Feature.entries.count { enabled(it) } +class SteamIntegrationFocusRequest(val feature: Feature?) { + private var pending = true + + internal fun consume(): Boolean { + if (!pending) return false + pending = false + return true + } +} + @Composable internal fun SteamIntegrationGroup( state: SteamIntegration.State, - focus: Feature? = null, + focus: SteamIntegrationFocusRequest? = null, onFeature: (Feature) -> Unit, onAppInfo: () -> Unit, onLocation: () -> Unit = {}, + collapsible: Boolean = false, ) { + var expanded by rememberSaveable { mutableStateOf(false) } + var revealRequest by remember { mutableStateOf(null) } + LaunchedEffect(focus) { + revealRequest = focus?.takeIf { it.consume() } + if (revealRequest != null) expanded = true + } + val count = stringResource(R.string.integration_count, state.enabledCount(), Feature.entries.size) SettingsGroup( stringResource(R.string.integration_title), - detail = stringResource(R.string.integration_count, state.enabledCount(), Feature.entries.size), + detail = count.takeUnless { collapsible }, ) { - Feature.entries.forEachIndexed { i, feature -> - IntegrationRow(state, feature, focus == feature, i < Feature.entries.lastIndex, onFeature, onAppInfo, onLocation) + if (collapsible) ActionRow( + count, stringResource(R.string.integration_manage_hint), + stringResource(if (expanded) R.string.common_close else R.string.setup_manage), + onClick = { + revealRequest = null + expanded = !expanded + }, sideBySide = true, + ) + if (!collapsible || expanded) { + Feature.entries.forEachIndexed { i, feature -> + IntegrationRow(state, feature, revealRequest?.takeIf { it.feature == feature }, i < Feature.entries.lastIndex, onFeature, onAppInfo, onLocation) + } } } } @@ -90,7 +119,7 @@ internal fun SteamIntegrationGroup( private fun IntegrationRow( state: SteamIntegration.State, feature: Feature, - focused: Boolean, + focus: SteamIntegrationFocusRequest?, divider: Boolean, onFeature: (Feature) -> Unit, onAppInfo: () -> Unit, @@ -101,8 +130,8 @@ private fun IntegrationRow( val on = state.enabled(feature) var flash by remember { mutableStateOf(false) } val reveal = remember { BringIntoViewRequester() } - LaunchedEffect(focused) { - if (focused) try { flash = true; reveal.bringIntoView(); kotlinx.coroutines.delay(1600) } finally { flash = false } + LaunchedEffect(focus) { + if (focus != null) try { flash = true; reveal.bringIntoView(); kotlinx.coroutines.delay(1600) } finally { flash = false } } val bg by animateColorAsState(if (flash) pal.signal.copy(alpha = 0.12f) else Color.Transparent, Motion.tw(400), label = "integrationFlash") val wifiLocationOff = feature == Feature.WIFI && state.wifi && state.locationPermission && !state.locationOn diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StepOut.kt b/app/src/main/java/com/droiddeck/launcher/ui/StepOut.kt index b888f08065..20a18aa845 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StepOut.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StepOut.kt @@ -145,11 +145,16 @@ internal class StepOutScope(private val items: List Unit>() + + fun leaveAll(withPage: Boolean) = leave.toList().forEach { it(withPage) } +} + private val OutPull = 6.dp private val OutBoxCorner = 16.dp private val OutFillet = 10.dp -@OptIn(ExperimentalComposeUiApi::class) @Composable internal fun StepOut( open: Boolean, @@ -163,6 +168,22 @@ internal fun StepOut( items: Int = 4, handle: @Composable () -> Unit, content: @Composable StepOutScope.() -> Unit, +) = SolidSurfaces { StepOutPanel(open, pill, preferredSide, accent, onDismiss, onClosed, pillCorner, maxWidth, items, handle, content) } + +@OptIn(ExperimentalComposeUiApi::class) +@Composable +private fun StepOutPanel( + open: Boolean, + pill: Rect, + preferredSide: StepSide, + accent: Color, + onDismiss: () -> Unit, + onClosed: () -> Unit, + pillCorner: Dp?, + maxWidth: Dp, + items: Int, + handle: @Composable () -> Unit, + content: @Composable StepOutScope.() -> Unit, ) { val colors = MaterialTheme.colorScheme val density = LocalDensity.current @@ -179,13 +200,25 @@ internal fun StepOut( val glide = LocalFocusGlide.current val opener = remember { arrayOfNulls(1) } val openNow = androidx.compose.runtime.rememberUpdatedState(open) + val dismissNow = androidx.compose.runtime.rememberUpdatedState(onDismiss) + val leavesWithPage = remember { booleanArrayOf(false) } + val presence = remember { Animatable(1f) } + if (open) androidx.compose.runtime.DisposableEffect(Unit) { + val leave = { withPage: Boolean -> + opener[0] = null + leavesWithPage[0] = withPage + dismissNow.value() + } + OpenMenus.leave += leave + onDispose { OpenMenus.leave -= leave } + } var moving by remember { mutableStateOf(false) } val placed = remember { arrayOfNulls(3) } if (moving) VeilRing() val pull = with(density) { OutPull.toPx() } val corner = pillCorner?.let { with(density) { it.toPx() } } ?: minOf(pill.height, pill.width) / 2f - BoxWithConstraints(Modifier.fillMaxSize()) { + BoxWithConstraints(Modifier.fillMaxSize().graphicsLayer { alpha = presence.value }) { val hostWidth = constraints.maxWidth.toFloat() val hostHeight = constraints.maxHeight.toFloat() val availableHeight = with(density) { @@ -206,9 +239,11 @@ internal fun StepOut( if (grown && flipped) edge.snapTo(if (open) out else rest) val boxBottom = pill.bottom + pull + c.height if (open) { + leavesWithPage[0] = false + presence.snapTo(1f) if (!grown) { opener[0] = glide?.current - edge.snapTo(rest); bottom.snapTo(pill.bottom); tint.snapTo(0f) + edge.snapTo(rest); bottom.snapTo(pill.bottom); tint.snapTo(0f); dim.snapTo(0f) pieces.forEach { it.snapTo(0f) } grown = true } @@ -226,7 +261,10 @@ internal fun StepOut( } else { opener[0]?.let { o -> if (inputMode.inputMode == InputMode.Keyboard) runCatching { o.requester.requestFocus() } } opener[0] = null - coroutineScope { + if (leavesWithPage[0]) { + moving = true + presence.animateTo(0f, Motion.tw(160)) + } else coroutineScope { pieces.forEach { launch { it.animateTo(0f, Motion.tw(90)) } } launch { delay(Motion.ms(60).toLong()); dim.animateTo(0f, Motion.tw(300)) } moving = true diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt index 00b09f2145..caa629aa55 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoragePage.kt @@ -168,6 +168,20 @@ internal fun StoragePanel(s: FrontEndState, a: FrontEndActions) { } } +@Composable +private fun SharedStorageGroup() { + val ctx = LocalContext.current + var on by remember { mutableStateOf(SessionPrefs.mountSharedStorage(ctx)) } + SettingsGroup(stringResource(R.string.setup_runtime)) { + SettingsRow(stringResource(R.string.storage_shared_mount), stringResource(R.string.storage_shared_mount_hint)) { + ToggleSwitch(on, label = stringResource(R.string.storage_shared_mount), modifier = Modifier.testTag("setting-shared-storage")) { + SessionPrefs.setMountSharedStorage(ctx, it) + on = it + } + } + } +} + @Composable private fun DefaultStorageGroup() { val ctx = LocalContext.current @@ -347,6 +361,7 @@ private fun OverviewContent(report: StorageSummary, sessionRunning: Boolean, wid Note(stringResource(R.string.storage_session_running)) } DefaultStorageGroup() + SharedStorageGroup() SectionTitle(stringResource(R.string.storage_where), null) val unused = report.unusedTools val tiles = listOf<@Composable (Modifier) -> Unit>( diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt index 2d6e37753c..2f7c962934 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoreAchievementsUi.kt @@ -56,6 +56,7 @@ import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext @@ -358,6 +359,67 @@ internal fun SessionAchievementsPanel(label: String, state: AchievementsState, t } } +/** The Achievements page of the session menu: the same list as the full panel, inside the menu's own scroll. */ +@Composable +internal fun DrawerAchievementsPage(game: StoreAchievements.Game, title: String?, track: (String) -> Modifier) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val label = StoreAchievements.forSource(game.source)?.label.orEmpty() + val state = rememberAchievements(game) ?: AchievementsState.READING + val kinds = remember(state.list) { + val list = state.list.orEmpty() + val split = groups(list) + if (split.size < 2) emptyList() else listOf(R.string.stores_tab_all to list) + split + } + var pick by remember { mutableIntStateOf(0) } + if (pick >= kinds.size) pick = 0 + var noteHadFocus by remember { mutableStateOf(false) } + val firstRow = remember { FocusRequester() } + val loaded = !state.list.isNullOrEmpty() + LaunchedEffect(loaded) { + if (loaded && noteHadFocus) { + noteHadFocus = false + withFrameNanos { } + runCatching { firstRow.requestFocus() } + } + } + Column(Modifier.fillMaxWidth().padding(top = 8.dp, start = 4.dp, end = 4.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { + Text(title.orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f)) + state.list?.takeIf { it.isNotEmpty() }?.let { list -> + if (state.all) Trophy(18.dp, Modifier.padding(end = 6.dp)) + Text(stringResource(R.string.achievements_count_short, state.done, list.size), fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = pal.signal) + } + } + val list = state.list + if (list.isNullOrEmpty()) { + Text(achievementsNote(state, label).orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, + modifier = Modifier.padding(top = 12.dp).then(track("achievements")) + .onFocusChanged { if (it.isFocused) noteHadFocus = true }.focusable()) + return@Column + } + LinearProgressIndicator( + progress = { state.done / list.size.toFloat() }, color = pal.signal, trackColor = pal.line, + modifier = Modifier.padding(top = 8.dp).fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)), + ) + if (kinds.isNotEmpty()) TabStrip( + kinds.map { (name, group) -> if (name == R.string.stores_tab_all) stringResource(name) + " · " + group.size else stringResource(name, group.size) }, + pick, { pick = it }, Modifier.padding(top = 10.dp), bumpers = false, compact = true, + ) + val shown = kinds.getOrNull(pick)?.second ?: list + val sections = if (pick == 0) groups(shown).filter { it.second.isNotEmpty() } else listOf(null to shown) + val first = sections.firstOrNull()?.second?.firstOrNull()?.id + Column(Modifier.padding(top = 6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + for ((group, items) in sections) { + if (group != null) AchievementGroupLabel(stringResource(group, items.size)) + for (a in items) androidx.compose.runtime.key(a.id) { + AchievementRow(a, compact = true, if (a.id == first) track("achievements").focusRequester(firstRow) else Modifier) + } + } + } + } +} + @Composable internal fun DrawerAchievementsRow(progress: Pair?, modifier: Modifier = Modifier, onClick: () -> Unit) { val colors = MaterialTheme.colorScheme diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt index a822548739..806975b3ee 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoreChips.kt @@ -39,7 +39,7 @@ internal fun sourceColours(source: String): SourceColours = when (source) { Store.UBISOFT.id -> SourceColours(Color(0xFF0B1E44), Color(0xFFA8C6FF), Color(0xFF2E7DFF)) Store.EA.id -> SourceColours(Color(0xFF3A0E12), Color(0xFFFF9A9A), Color(0xFFFF4747)) Store.ROCKSTAR.id -> SourceColours(Color(0xFF3A2A06), Color(0xFFFFD780), Color(0xFFFCAF17)) - Library.SOURCE_STEAM -> SourceColours(Color(0xFF16293D), Color(0xFF7CC4FF), Color(0xFF1A9FFF)) + Library.SOURCE_STEAM, Store.STEAM.id -> SourceColours(Color(0xFF16293D), Color(0xFF7CC4FF), Color(0xFF1A9FFF)) Library.SOURCE_COLLECTION -> SourceColours(Color(0xFF2B1A3D), Color(0xFFD2A8FF), Color(0xFFA25BFF)) FLATHUB -> SourceColours(Color(0xFF0B2E2B), Color(0xFF9FE3DD), FlathubTeal) else -> SourceColours(Color(0xFF1A1D22), Color(0xFF9AA3AF), Color(0xFF9AA3AF)) @@ -47,7 +47,7 @@ internal fun sourceColours(source: String): SourceColours = when (source) { @Composable internal fun sourceLabel(source: String): String = when (source) { - Library.SOURCE_STEAM -> stringResource(R.string.source_steam) + Library.SOURCE_STEAM, Store.STEAM.id -> stringResource(R.string.source_steam) Library.SOURCE_COLLECTION -> stringResource(R.string.soundtracks_collections) Store.GOG.id -> Store.GOG.label Store.EPIC.id -> Store.EPIC.label diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt index c5dd008edb..ea7483e531 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresInstallDialog.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -46,7 +47,10 @@ import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.CatalogItem import com.droiddeck.launcher.stores.StoreInstallRoot import com.droiddeck.launcher.stores.StoreLanguage +import com.droiddeck.launcher.stores.StoreSizes import com.droiddeck.launcher.stores.StoresState +import com.droiddeck.launcher.stores.steam.SteamClient +import com.droiddeck.launcher.stores.steam.SteamStore import com.droiddeck.launcher.stores.formatBytes import com.droiddeck.launcher.stores.gog.GogDownloadManager import kotlinx.coroutines.Dispatchers @@ -133,6 +137,61 @@ internal fun InstallWhereDialog(item: CatalogItem, onDismiss: () -> Unit) { } } +@Composable +internal fun SteamInstallWhereDialog(item: CatalogItem, onDismiss: () -> Unit) { + val ctx = LocalContext.current + val colors = MaterialTheme.colorScheme + val shown = rememberShown(onDismiss) + val close = { shown.targetState = false } + val targets by produceState?>(null, item.key) { + value = withContext(Dispatchers.IO) { runCatching { SteamClient.targets(ctx) }.getOrDefault(emptyList()) } + } + val needed by produceState(StoreSizes.size(item), item.key) { + val bytes = withContext(Dispatchers.IO) { runCatching { SteamStore.plannedBytes(ctx, item) }.getOrDefault(0L) } + if (bytes > 0L) value = bytes + } + val list = targets + val focus = remember(list?.size) { List(list?.size ?: 0) { FocusRequester() } } + LaunchedEffect(focus) { if (focus.isNotEmpty()) focusWithinFrames({ false }) { focus[0] } } + AppDialog(shown, close, "steamInstallWhere", wide = false, maxWidth = 440.dp) { + Rise(0) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { + Text( + stringResource(R.string.stores_install_title, item.title), fontSize = 15.sp, color = colors.onBackground, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f), + ) + Text( + stringResource(R.string.common_cancel), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, + modifier = Modifier.clip(Shape12).focusGlide().clickable(role = Role.Button, onClick = close).controllerConfirm(onClick = close).padding(horizontal = 10.dp, vertical = 6.dp), + ) + } + } + Rise(1) { + when { + list == null -> androidx.compose.material3.LinearProgressIndicator(Modifier.fillMaxWidth().height(3.dp)) + list.isEmpty() -> Note(stringResource(R.string.game_sync_err_steam_library)) + else -> Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth()) { + list.forEachIndexed { i, t -> + val isLow = StoreInstallRoot.insufficientSpace(needed, t.freeBytes) + val freeText = when { + t.freeBytes < 0L -> stringResource(R.string.stores_target_free_unknown) + isLow -> stringResource(R.string.stores_storage_low, formatBytes(t.freeBytes), formatBytes(needed)) + else -> stringResource(R.string.stores_target_free, formatBytes(t.freeBytes)) + } + TargetRow( + label = t.label, free = freeText, removable = t.removable, folder = t.folder, focus = focus[i], + modifier = Modifier.fillMaxWidth(), warning = isLow, + ) { + SteamStore.install(ctx, item, t) + close() + } + } + } + } + } + } +} + @Composable private fun TargetRow(label: String, free: String, removable: Boolean, folder: Boolean, focus: FocusRequester, modifier: Modifier, warning: Boolean = false, onPick: () -> Unit) { val colors = MaterialTheme.colorScheme diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt index 30caa5fca7..33963e2d34 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt @@ -453,7 +453,7 @@ private fun StoreDot(store: Store, signedIn: Boolean) { @OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class) @Composable -private fun StoreChips( +internal fun StoreChips( selected: String, focused: String?, tabs: List, onStore: (Store) -> Unit, onSettings: (Rect?) -> Unit, onFocusChip: (String?) -> Unit, ) { @@ -470,27 +470,42 @@ private fun StoreChips( val tabScroll = rememberScrollState() Box(Modifier.fillMaxWidth()) { Row(horizontalArrangement = Arrangement.spacedBy(gap), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { - Box(Modifier.weight(1f).edgeFade(tabScroll).horizontalScroll(tabScroll)) { - Row(horizontalArrangement = Arrangement.spacedBy(gap), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) { - for (tab in tabs) { - val store = tab.store - if (tab.shown) { - val signedIn = StoresState.isSignedIn(store) && StoresState.expired[store] != true - key(store) { - val reveal = remember { BringIntoViewRequester() } - LaunchedEffect(selected) { if (selected == store.id) reveal.bringIntoView() } - StoreChip( - label = store.shortLabel, on = selected == store.id, under = fillShown && highlighted == store.id, key = store.id, mark = sourceColours(store.id).dot, - modifier = Modifier.bringIntoViewRequester(reveal).onGloballyPositioned { bounds[store.id] = it.boundsInParent() }, - lead = { StoreDot(store, signedIn) }, - description = store.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out), - onFocused = onFocusChip, - ) { onStore(store) } + val shown = tabs.filter { it.shown }.map { it.store } + BoxWithConstraints(Modifier.weight(1f)) { + if (sourceTabsAsMenu(maxWidth, shown.size)) TabMenu( + shown.map { it.shortLabel }, shown.indexOfFirst { it.id == selected }, { onStore(shown[it]) }, + chipModifier = shown.fold(Modifier as Modifier) { m, st -> key(st) { m.paneItem("storechip:${st.id}") } }, + descriptions = shown.map { st -> + val signedIn = StoresState.isSignedIn(st) && StoresState.expired[st] != true + st.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out) + }, + leading = { i, inList -> + val signedIn = StoresState.isSignedIn(shown[i]) && StoresState.expired[shown[i]] != true + if (inList) Box(Modifier.size(12.dp).background(sourceColours(shown[i].id).dot.copy(alpha = if (signedIn) 1f else 0.35f), CircleShape)) + else StoreDot(shown[i], signedIn) + }, + ) else Box(Modifier.edgeFade(tabScroll).horizontalScroll(tabScroll)) { + Row(horizontalArrangement = Arrangement.spacedBy(gap), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.focusGroup()) { + for (tab in tabs) { + val store = tab.store + if (tab.shown) { + val signedIn = StoresState.isSignedIn(store) && StoresState.expired[store] != true + key(store) { + val reveal = remember { BringIntoViewRequester() } + LaunchedEffect(selected) { if (selected == store.id) reveal.bringIntoView() } + StoreChip( + label = store.shortLabel, on = selected == store.id, under = fillShown && highlighted == store.id, key = store.id, mark = sourceColours(store.id).dot, + modifier = Modifier.bringIntoViewRequester(reveal).onGloballyPositioned { bounds[store.id] = it.boundsInParent() }, + lead = { StoreDot(store, signedIn) }, + description = store.label + if (signedIn || !StoresState.accountsLoaded) "" else " " + stringResource(R.string.stores_chip_signed_out), + onFocused = onFocusChip, + ) { onStore(store) } + } } } } + ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown) } - ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown) } var cogAt by remember { mutableStateOf(null) } Box(Modifier.onGloballyPositioned { cogAt = it.boundsInRoot() }) { @@ -1031,6 +1046,7 @@ internal fun storePalette(base: Palette, store: Store?): Palette { Store.UBISOFT -> Color(0xFF2E7DFF) to Color(0xFF1A5BD6) Store.EA -> Color(0xFFFF4747) to Color(0xFFE03030) Store.ROCKSTAR -> Color(0xFFFCAF17) to Color(0xFFD98E00) + Store.STEAM -> Color(0xFF1A9FFF) to Color(0xFF0F6FC0) null -> return base } val on = if (accent.luminance() > 0.18f) Color(0xFF0B0B0D) else Color.White @@ -1323,6 +1339,6 @@ internal fun openUrl(ctx: android.content.Context, url: String) { } internal fun launchStoreGame(store: Store, id: String, s: FrontEndState, a: FrontEndActions) { - val game = s.steamGames.firstOrNull { it.source == store.id && it.storeId == id } + val game = GameRef(null, store, id).game(s.steamGames) if (game != null) a.onSteamGame(game) else a.onStoreGame(store, id) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/TabMenu.kt b/app/src/main/java/com/droiddeck/launcher/ui/TabMenu.kt new file mode 100644 index 0000000000..1a05328069 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/ui/TabMenu.kt @@ -0,0 +1,111 @@ +package com.droiddeck.launcher.ui + +import android.content.res.Configuration +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.hoverable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsFocusedAsState +import androidx.compose.foundation.interaction.collectIsHoveredAsState +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ExpandLess +import androidx.compose.material.icons.outlined.ExpandMore +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +private val TAB_MENU_BELOW = 600.dp +private val TAB_MIN_WIDTH = 96.dp + +/** Whether [count] tabs in [width] become a [TabMenu]: on a narrow page, when they would not fit side by side. */ +internal fun tabsAsMenu(width: Dp, count: Int): Boolean = + count > 2 && width < TAB_MENU_BELOW && width / count < TAB_MIN_WIDTH + +@Composable +internal fun sourceTabsAsMenu(width: Dp, count: Int): Boolean = + count > 1 && (LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT || + (width < TAB_MENU_BELOW && width / count < TAB_MIN_WIDTH)) + +/** + * Tabs as one chip naming the shown tab, which opens the list of them, as the second screen's + * picker does. Each of [focus] lands on the chip, so callers that focus a tab still reach it. + */ +@Composable +internal fun TabMenu( + labels: List, selected: Int, onPick: (Int) -> Unit, + modifier: Modifier = Modifier, focus: List? = null, + chipModifier: Modifier = Modifier, descriptions: List? = null, + leading: (@Composable (index: Int, inList: Boolean) -> Unit)? = null, +) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + var open by remember { mutableStateOf(false) } + val source = remember { MutableInteractionSource() } + val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value + val shape = RoundedCornerShape(22.dp) + val label = labels.getOrNull(selected).orEmpty() + val description = descriptions?.getOrNull(selected) ?: label + val toggle = { open = !open } + Box(modifier) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + modifier = focus.orEmpty().fold(chipModifier.height(44.dp)) { m, r -> m.focusRequester(r) } + .testTag("tab-menu") + .semantics { contentDescription = description } + .clip(shape).background(if (hot || open) pal.signal.copy(alpha = 0.14f) else colors.surfaceVariant) + .glideBorder(hot || open, shape, pal.signal, pal.line2) + .hoverable(source) + .clickable(role = Role.Button, interactionSource = source, indication = LocalIndication.current, onClick = toggle) + .controllerConfirm(onClick = toggle) + .padding(start = 14.dp, end = 10.dp), + ) { + if (selected in labels.indices) androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides colors.onBackground) { + leading?.invoke(selected, false) + } + Text(label, fontSize = 14.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, + overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false)) + Icon(if (open) Icons.Outlined.ExpandLess else Icons.Outlined.ExpandMore, contentDescription = null, + tint = colors.onSurfaceVariant, modifier = Modifier.size(20.dp)) + } + AnchoredMenu(open, { open = false }, compact = true, minWidth = 200.dp) { first -> + labels.forEachIndexed { i, item -> + MenuItem( + item, checked = i == selected, + leading = leading?.let { { it(i, true) } }, + focusRequester = first.takeIf { i == selected || (i == 0 && selected !in labels.indices) }, + modifier = Modifier.testTag("tab-menu:$i") + .then(descriptions?.getOrNull(i)?.let { d -> Modifier.semantics { contentDescription = d } } ?: Modifier), + ) { open = false; onPick(i) } + } + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt index 8cf7013d0f..6aacdeea3e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/Theme.kt @@ -14,6 +14,7 @@ import androidx.compose.animation.core.infiniteRepeatable import androidx.compose.animation.core.rememberInfiniteTransition import androidx.compose.animation.core.tween import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.key import androidx.compose.runtime.SideEffect import androidx.compose.runtime.CompositionLocalProvider @@ -38,7 +39,7 @@ class Palette( val background: Color, val surface: Color, val surfaceVariant: Color, val line: Color, val line2: Color, val onBackground: Color, val onSurfaceVariant: Color, val primary: Color, val primary2: Color, val onPrimary: Color, val signal: Color, - val good: Color, val error: Color = Color(0xFFFF8A80), + val good: Color, val error: Color = Color(0xFFFF8A80), val warning: Color = Color(0xFFFFB547), ) data class CustomThemeColors( @@ -54,6 +55,7 @@ data class CustomThemeColors( val signal: Int = 0xFF1A9FFF.toInt(), val good: Int = 0xFF4CD37F.toInt(), val error: Int = 0xFFFF8A80.toInt(), + val warning: Int = 0xFFFFB547.toInt(), ) object Themes { @@ -87,7 +89,7 @@ object Themes { var rgbSpeed by mutableStateOf(DEFAULT_RGB_SPEED) private set - var rgbHue by mutableStateOf(0f) + @Volatile var rgbHue = 0f private set fun moveRgbHue(hue: Float) { @@ -144,6 +146,7 @@ object Themes { "signal" -> current.copy(signal = color) "good" -> current.copy(good = color) "error" -> current.copy(error = color) + "warning" -> current.copy(warning = color) else -> return } setCustomColors(context, updated) @@ -164,6 +167,7 @@ object Themes { signal = Color(colors.signal), good = Color(colors.good), error = Color(colors.error), + warning = Color(colors.warning), ) fun current(context: Context): Palette { @@ -227,33 +231,79 @@ val LocalPalette = staticCompositionLocalOf { Themes.byId(Themes.GRAPHITE) } val Palette.onSignal: Color get() = if (signal.luminance() > 0.18f) Color(0xFF03111F) else Color.White +internal val LocalSolidPalette = staticCompositionLocalOf { null } + @Composable -fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCALE, content: @Composable () -> Unit) { - val id = theme ?: SessionPrefs.theme(LocalContext.current) - if (id == Themes.INNER_GAMER) InnerGamerHue(Themes.rgbSpeed) - val p = Themes.byId(id) - val scheme = darkColorScheme( - primary = p.primary, onPrimary = p.onPrimary, secondary = p.onSurfaceVariant, - background = p.background, onBackground = p.onBackground, - surface = p.surface, onSurface = p.onBackground, - surfaceVariant = p.surfaceVariant, onSurfaceVariant = p.onSurfaceVariant, - error = p.error, +fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCALE, frost: FrostChoice? = null, content: @Composable () -> Unit) { + val context = LocalContext.current + remember(context) { Themes.loadGradient(context) } + val id = theme ?: SessionPrefs.theme(context) + val solid = if (id == Themes.INNER_GAMER) { + rememberInnerGamerPalette(Themes.rgbSpeed) + } else { + Themes.byId(id) + } + DroidDeckThemePalette(solid, appScale, frost, content) +} + +@Composable +private fun rememberInnerGamerPalette(speed: Int): Palette = key(speed) { + val start = remember { Themes.rgbHue } + val animatedHue by rememberInfiniteTransition(label = "innerGamer").animateFloat( + start, start + 360f, + infiniteRepeatable( + tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing), + RepeatMode.Restart, + ), + label = "hue", ) + val steppedHue by remember { + derivedStateOf { + ((animatedHue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP + } + } + SideEffect { Themes.moveRgbHue(steppedHue) } + Themes.innerGamer(steppedHue) +} + +@Composable +private fun DroidDeckThemePalette(solid: Palette, appScale: Int, frost: FrostChoice?, content: @Composable () -> Unit) { + val look = frost?.let { frostLook(solid, it) } + val p = if (look == null) solid else solid.frosted(look) val baseDensity = LocalDensity.current val baseConfiguration = LocalConfiguration.current val density = remember(baseDensity, appScale) { scaledAppDensity(baseDensity, appScale) } val configuration = remember(baseConfiguration, appScale) { scaledAppConfiguration(baseConfiguration, appScale) } CompositionLocalProvider( LocalPalette provides p, + LocalSolidPalette provides solid.takeIf { look != null }, + LocalFrost provides look?.veil, LocalDensity provides density, LocalConfiguration provides configuration, ) { - MaterialTheme(colorScheme = scheme, typography = ContentDirected) { + MaterialTheme(colorScheme = p.scheme(), typography = ContentDirected) { FocusGlideHost { ProvideTextStyle(TextStyle(textDirection = TextDirection.Content), content) } } } } +private fun Palette.scheme() = darkColorScheme( + primary = primary, onPrimary = onPrimary, secondary = onSurfaceVariant, + background = background, onBackground = onBackground, + surface = surface, onSurface = onBackground, + surfaceVariant = surfaceVariant, onSurfaceVariant = onSurfaceVariant, + error = error, +) + +@Composable +internal fun SolidSurfaces(content: @Composable () -> Unit) { + val solid = LocalSolidPalette.current + if (solid == null) content() + else CompositionLocalProvider(LocalPalette provides solid, LocalSolidPalette provides null, LocalFrost provides null) { + MaterialTheme(colorScheme = solid.scheme(), typography = MaterialTheme.typography, content = content) + } +} + private val ContentDirected = Typography().run { fun TextStyle.byContent() = copy(textDirection = TextDirection.Content) Typography( @@ -265,17 +315,3 @@ private val ContentDirected = Typography().run { ) } -@Composable -private fun InnerGamerHue(speed: Int) { - key(speed) { InnerGamerCycle(speed) } -} - -@Composable -private fun InnerGamerCycle(speed: Int) { - val start = remember { Themes.rgbHue } - val hue by rememberInfiniteTransition(label = "innerGamer").animateFloat( - start, start + 360f, infiniteRepeatable(tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing), RepeatMode.Restart), label = "hue", - ) - val stepped = ((hue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP - SideEffect { Themes.moveRgbHue(stepped) } -} diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt b/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt index 279941154f..88cd13355a 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ThemeColors.kt @@ -69,7 +69,7 @@ internal object ThemeColors { private val DARK_INK = Color(0xFF03111F) - private fun contrast(a: Color, b: Color): Float { + internal fun contrast(a: Color, b: Color): Float { val x = a.luminance() val y = b.luminance() return (max(x, y) + 0.05f) / (min(x, y) + 0.05f) @@ -80,7 +80,7 @@ internal object ThemeColors { return if (worst(DARK_INK) >= worst(Color.White)) DARK_INK else Color.White } - private const val MIN_CONTRAST = 4.5f + internal const val MIN_CONTRAST = 4.5f private fun fitTo(ink: Color, argb: Int): Int { fun short(color: Int) = contrast(ink, Color(color)) < MIN_CONTRAST diff --git a/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt index 92478a6cd2..f15b69287b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/UpdatesPage.kt @@ -9,7 +9,6 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.shrinkVertically import androidx.compose.foundation.background -import androidx.compose.foundation.basicMarquee import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.hoverable @@ -21,10 +20,14 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.selection.selectable +import androidx.compose.foundation.selection.selectableGroup import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -44,6 +47,7 @@ import androidx.compose.material.icons.outlined.Science import androidx.compose.material.icons.outlined.SwapHoriz import androidx.compose.material.icons.outlined.Sync import androidx.compose.material.icons.outlined.Verified +import androidx.compose.material.icons.outlined.WarningAmber import androidx.compose.material3.Icon import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.vector.ImageVector @@ -109,49 +113,49 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie val me = remember { AppUpdates.installed() } val colors = MaterialTheme.colorScheme Column(modifier = modifier) { - Row( - verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp), - modifier = Modifier.fillMaxWidth().padding(bottom = 10.dp), - ) { - Text( - stringResource(R.string.upd_build, me.version, s.buildLabel), fontSize = 12.5.sp, color = colors.onSurfaceVariant, - maxLines = 1, modifier = Modifier.weight(1f) - .basicMarquee(iterations = Int.MAX_VALUE, initialDelayMillis = 700, velocity = 40.dp), - ) - val checked = u.catalog?.checkedAt?.takeIf { it > 0 } - if (!LocalNarrowPane.current) Text( - if (u.checking) stringResource(R.string.common_checking) else if (checked != null) stringResource(R.string.upd_checked, ago(checked).replaceFirstChar { it.lowercase() }) else stringResource(R.string.upd_not_checked), - fontSize = 13.sp, color = colors.onSurfaceVariant, - ) - val clipboard = LocalClipboardManager.current - val context = LocalContext.current - val details = buildDetails(me, s.buildLabel) - ToolIcon(Icons.Outlined.ContentCopy, stringResource(R.string.upd_copy_build)) { - clipboard.setText(AnnotatedString(details)) - android.widget.Toast.makeText(context, context.getString(R.string.upd_copied), android.widget.Toast.LENGTH_SHORT).show() - } - ToolIcon(Icons.Outlined.Refresh, stringResource(R.string.store_check_updates), busy = u.checking, enabled = !u.checking && u.stage == null, onClick = ua.onCheck) - } BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) { val stacked = LocalNarrowPane.current || maxWidth < 600.dp - Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) { - if (stacked) { - StatusPanel(s, u, ua, me) + val context = LocalContext.current + val agentReady = com.droiddeck.launcher.agent.AgentHost.installed && + (com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context)) + val installed: @Composable () -> Unit = { + SectionLabel(stringResource(R.string.upd_installed_label)) + InstalledCard(s, u, me) + CheckRow(u, ua) + LabBuilds(s.sessionRunning, header = { SectionLabel(stringResource(R.string.lab_builds)) }, onRebuild = if (agentReady) { info -> + com.droiddeck.launcher.agent.AgentHost.send(context, context.getString(R.string.agent_rebuild_lab, info.label)) + context.startActivity(android.content.Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java) + .putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent") + .addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP or android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)) + } else null) + } + val channel: @Composable () -> Unit = { + SectionLabel(stringResource(R.string.upd_channel)) + ChannelPicker(u, ua) { StatusPanel(s, u, ua, me, embedded = it) } + } + val testers: @Composable () -> Unit = { + SectionLabel(stringResource(R.string.upd_testers), top = 22.dp) + ToggleRow( + host, "build-watermark", stringResource(R.string.setup_build_watermark), + stringResource(R.string.setup_build_watermark_hint), s.buildWatermark, + ) { a.onBuildWatermark() } + } + if (stacked) { + Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) { + installed() Box(Modifier.height(18.dp)) - ChannelLabel() - ChannelPicker(u, ua, s.sessionRunning) - } else { - ChannelLabel() - Row(horizontalArrangement = Arrangement.spacedBy(18.dp)) { - Box(Modifier.weight(1f)) { ChannelPicker(u, ua, s.sessionRunning) } - Box(Modifier.weight(1.15f)) { StatusPanel(s, u, ua, me) } - } + channel() + testers() } - Box(Modifier.padding(top = 18.dp)) { - ToggleRow( - host, "build-watermark", stringResource(R.string.setup_build_watermark), - stringResource(R.string.setup_build_watermark_hint), s.buildWatermark, - ) { a.onBuildWatermark() } + } else { + Row(Modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(24.dp)) { + Column(Modifier.weight(1f).fillMaxHeight().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) { + installed() + testers() + } + Column(Modifier.weight(1.15f).fillMaxHeight().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) { + channel() + } } } } @@ -169,8 +173,114 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie ) } +private val TEST_TINT = Color(0xFF9B6CFF) + @Composable -private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed) { +private fun SectionLabel(text: String, top: androidx.compose.ui.unit.Dp = 4.dp) { + Text( + text, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, + color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = top, bottom = 10.dp), + ) +} + +/** What is installed: which kind of build, its version and versionCode, and its commit, as the first thing on the page. */ +@Composable +private fun InstalledCard(s: FrontEndState, u: UpdatesState, me: AppUpdates.Installed) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val catalog = u.catalog + val lab = com.droiddeck.launcher.lab.LabOverlay.active + val basePr = if (me.pr > 0) me.pr else Regex("""\bpr(\d+)\b""").find(s.buildLabel)?.groupValues?.get(1)?.toIntOrNull() ?: 0 + val kind = when { + lab != null -> stringResource(R.string.upd_kind_lab) + me.pr > 0 -> stringResource(R.string.upd_kind_test) + catalog?.stable?.let { AppUpdates.isRunning(it, me) } == true -> stringResource(R.string.upd_stable) + catalog?.preview?.let { AppUpdates.isRunning(it, me) } == true -> stringResource(R.string.upd_preview) + else -> null + } + val tint = if (lab != null || me.pr > 0) TEST_TINT else pal.signal + val title = when { + lab != null -> lab.label + me.pr > 0 -> stringResource(R.string.upd_pr, me.pr) + else -> stringResource(R.string.upd_droiddeck_version, me.version) + } + val subtitle = when { + lab != null && basePr > 0 -> stringResource(R.string.upd_lab_on_pr, basePr) + lab != null -> stringResource(R.string.upd_lab_on_version, me.version) + me.pr > 0 -> catalog?.tests?.firstOrNull { it.pr == me.pr }?.title?.takeIf { it.isNotBlank() }?.let(::changeTitle) + else -> null + } + val built = lab?.built?.takeIf { it > 0 } ?: me.committedAt + val meta = listOfNotNull( + me.version.takeIf { lab != null || me.pr > 0 }, + stringResource(R.string.upd_version_code, me.versionCode), + me.commit.take(7).takeIf { it.length == 7 }, + built.takeIf { it > 0 }?.let { stringResource(R.string.upd_built_ago, ago(it).replaceFirstChar { c -> c.lowercase() }) }, + ).joinToString(" · ") + val clipboard = LocalClipboardManager.current + val context = LocalContext.current + val details = buildDetails(me, s.buildLabel) + Row( + verticalAlignment = Alignment.Top, horizontalArrangement = Arrangement.spacedBy(12.dp), + modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(start = 18.dp, end = 12.dp, top = 14.dp, bottom = 16.dp), + ) { + Column(Modifier.weight(1f).padding(top = 2.dp)) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) { + if (kind != null) Text( + kind.uppercase(), fontSize = 10.5.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.6.sp, color = tint, maxLines = 1, + modifier = Modifier.clip(CircleShape).background(tint.copy(alpha = 0.16f)).padding(horizontal = 8.dp, vertical = 3.dp), + ) + Text(title, fontSize = 20.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + } + if (subtitle != null) Text(subtitle, fontSize = 14.sp, fontWeight = FontWeight.Medium, color = colors.onBackground, maxLines = 2, + overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 6.dp)) + Text(meta, fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 4.dp)) + } + ToolIcon(Icons.Outlined.ContentCopy, stringResource(R.string.upd_copy_build)) { + clipboard.setText(AnnotatedString(details)) + android.widget.Toast.makeText(context, context.getString(R.string.upd_copied), android.widget.Toast.LENGTH_SHORT).show() + } + } +} + +@Composable +private fun CheckRow(u: UpdatesState, ua: UpdatesActions) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val src = remember { MutableInteractionSource() } + val hot = rememberHot(src) + val enabled = !u.checking && u.stage == null + val checked = u.catalog?.checkedAt?.takeIf { it > 0 } + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth().padding(top = 6.dp, bottom = 14.dp), + ) { + Row( + verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp), + modifier = Modifier.offset(x = (-6).dp).paneItem("updates:check").heightIn(min = 40.dp).clip(Shape12) + .background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent) + .glideBorder(hot, Shape12, pal.signal) + .hoverable(src).clickable(interactionSource = src, indication = null, enabled = enabled, role = Role.Button, onClick = ua.onCheck) + .controllerConfirm(enabled = enabled, onClick = ua.onCheck) + .padding(horizontal = 6.dp), + ) { + if (u.checking) androidx.compose.material3.CircularProgressIndicator(Modifier.size(16.dp), color = pal.signal, strokeWidth = 2.dp) + else Icon(Icons.Outlined.Refresh, contentDescription = null, tint = pal.signal.copy(alpha = if (enabled) 1f else 0.5f), modifier = Modifier.size(18.dp)) + Text( + if (u.checking) stringResource(R.string.common_checking) else stringResource(R.string.upd_check_now), + fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = pal.signal.copy(alpha = if (enabled || u.checking) 1f else 0.5f), + ) + } + Box(Modifier.weight(1f)) + Text( + if (checked != null) stringResource(R.string.upd_checked, ago(checked).replaceFirstChar { it.lowercase() }) else stringResource(R.string.upd_not_checked), + fontSize = 12.5.sp, color = colors.onSurfaceVariant, maxLines = 1, + ) + } +} + +@Composable +private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed, embedded: Boolean = false) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val catalog = u.catalog @@ -196,17 +306,24 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m else -> Look(pal.good, stringResource(R.string.upd_current_status), stringResource(R.string.upd_current_headline, name), null) } Column( - modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp), + modifier = if (embedded) Modifier.fillMaxWidth().padding(start = 12.dp, end = 12.dp, bottom = 14.dp) + else Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(18.dp), ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) { Box(Modifier.size(7.dp).clip(CircleShape).background(look.tint)) Text(look.status, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = look.tint) - if (offered) Text(stringResource(R.string.upd_dot_ago, ago(release!!.publishedAt)), fontSize = 13.sp, color = colors.onSurfaceVariant) } - Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp)) + if (!embedded) Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp)) if (offered) { - ReleaseNotes(changeTitle(release!!.title.ifBlank { release.tag }), release.summary, release.tag) - ReleaseFacts(release) + val size = release!!.apk?.size?.takeIf { it > 0 }?.let { megabytes(it) } + Text( + listOfNotNull(stringResource(R.string.upd_released_ago, ago(release.publishedAt)), size).joinToString(" · "), + fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 2.dp), + ) + val older = (release.committedAt.takeIf { it > 0 } ?: release.publishedAt).let { it > 0 && me.committedAt > 0 && it < me.committedAt } + if (offer == Offer.SWITCH && older) OlderNote(me.committedAt) + val title = changeTitle(release.title.ifBlank { release.tag }) + ReleaseNotes(title.takeUnless { it == look.headline || (release.version != null && it.endsWith(release.version)) }, release.summary, release.tag) } if (release != null && u.follow.channel == Channel.TEST && catalog != null) { androidx.compose.runtime.LaunchedEffect(release.tag, release.commit, release.apk?.sha256) { ua.onSeen(release) } @@ -228,8 +345,10 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m else LinearProgressIndicator(modifier = Modifier.fillMaxWidth().height(6.dp).clip(CircleShape)) } offered && installBlock != null -> Unit - offer == Offer.UPDATE -> PrimaryButton(stringResource(R.string.upd_update_button, button), enabled = installable, main = true) { ua.onInstall(release!!) } - offer == Offer.SWITCH -> PrimaryButton(stringResource(R.string.upd_install_button, button), enabled = installable, main = true) { ua.onInstall(release!!) } + offer == Offer.UPDATE -> PrimaryButton(stringResource(R.string.upd_update_button, button), enabled = installable, main = true, fill = true, + modifier = Modifier.fillMaxWidth()) { ua.onInstall(release!!) } + offer == Offer.SWITCH -> PrimaryButton(stringResource(R.string.upd_switch_to_button, channelTitle(u.follow), button), enabled = installable, main = true, + fill = true, modifier = Modifier.fillMaxWidth()) { ua.onInstall(release!!) } offer == Offer.AHEAD && u.follow.channel == Channel.STABLE && installBlock == null -> SecondaryButton(stringResource(R.string.upd_install_anyway, release?.version.orEmpty()), enabled = installable) { ua.onInstall(release!!) } offer == Offer.GONE -> PrimaryButton(stringResource(R.string.upd_follow_preview), main = true) { ua.onFollow(Follow(Channel.NIGHTLY)) } @@ -238,25 +357,53 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m if (s.sessionRunning && (offered || offer == Offer.AHEAD)) { Text(stringResource(R.string.upd_stop_session), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp)) } + if (offered) ReleaseFacts(release!!) if (u.follow.channel == Channel.NIGHTLY) { PreviewHistory(catalog, me, s, u, ua) } } } +/** A switch that installs a build made before the installed one; Android keeps the app's data across it. */ @Composable -private fun ReleaseNotes(title: String, notes: String, key: String) { +private fun OlderNote(installedAt: Long) { + val context = LocalContext.current + val date = android.text.format.DateUtils.formatDateTime(context, installedAt, + android.text.format.DateUtils.FORMAT_SHOW_DATE or android.text.format.DateUtils.FORMAT_ABBREV_MONTH) + Row( + verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), + modifier = Modifier.padding(top = 12.dp).fillMaxWidth().clip(Shape12).background(AttentionAmber.copy(alpha = 0.12f)) + .padding(horizontal = 12.dp, vertical = 10.dp), + ) { + Icon(Icons.Outlined.WarningAmber, contentDescription = null, tint = AttentionAmber, modifier = Modifier.size(20.dp)) + Column { + Text(stringResource(R.string.upd_older_than_installed, date), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = AttentionAmber) + Text(stringResource(R.string.upd_data_stays), fontSize = 12.5.sp, color = MaterialTheme.colorScheme.onSurfaceVariant) + } + } +} + +@Composable +private fun channelTitle(f: Follow) = when (f.channel) { + Channel.STABLE -> stringResource(R.string.upd_stable) + Channel.NIGHTLY -> stringResource(R.string.upd_preview) + Channel.TEST -> stringResource(R.string.upd_pr, f.pr) +} + +@Composable +private fun ReleaseNotes(title: String?, notes: String, key: String) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current var open by rememberSaveable(key) { mutableStateOf(false) } var cut by remember(key) { mutableStateOf(false) } - Text( + if (title != null) Text( title, fontSize = 15.sp, color = colors.onBackground, maxLines = if (open) Int.MAX_VALUE else 2, overflow = TextOverflow.Ellipsis, onTextLayout = { if (it.hasVisualOverflow) cut = true }, modifier = Modifier.padding(top = 10.dp), ) if (notes.isNotBlank()) Text( - notes, fontSize = 13.5.sp, color = colors.onSurfaceVariant, maxLines = if (open) Int.MAX_VALUE else 1, overflow = TextOverflow.Ellipsis, - onTextLayout = { if (it.hasVisualOverflow) cut = true }, modifier = Modifier.padding(top = 4.dp), + notes, fontSize = 13.5.sp, color = colors.onSurfaceVariant, maxLines = if (open) Int.MAX_VALUE else if (title == null) 3 else 1, + overflow = TextOverflow.Ellipsis, onTextLayout = { if (it.hasVisualOverflow) cut = true }, + modifier = Modifier.padding(top = if (title == null) 10.dp else 4.dp), ) if (cut || open) { val src = remember { MutableInteractionSource() } @@ -287,47 +434,77 @@ private fun changeTitle(t: String): String = private fun megabytes(bytes: Long) = stringResource(R.string.upd_mb, ((bytes + 524_288) / 1_048_576).toInt()) @Composable -private fun ChannelLabel() { - Text( - stringResource(R.string.upd_channel), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp, - color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 10.dp), - ) -} - -@Composable -private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions, sessionRunning: Boolean) { +private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions, status: @Composable (embedded: Boolean) -> Unit) { val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current val catalog = u.catalog val tests = catalog?.tests.orEmpty() val me = remember { AppUpdates.installed() } val ready = tests.count { AppUpdates.installable(it, me) } var showTests by rememberSaveable { mutableStateOf(false) } + val listing = (showTests || u.follow.channel == Channel.TEST) && tests.isNotEmpty() + val shown = if (listing || showTests) Channel.TEST else u.follow.channel Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { - ChannelCard( - Icons.Outlined.Verified, stringResource(R.string.upd_stable), stringResource(R.string.upd_stable_hint), - catalog?.stable?.let { stringResource(R.string.upd_version_ago, it.version ?: it.tag, ago(it.publishedAt)) }, u.follow.channel == Channel.STABLE, - ) { ua.onFollow(Follow(Channel.STABLE)) } - ChannelCard( - Icons.Outlined.Bolt, stringResource(R.string.upd_preview), stringResource(R.string.upd_preview_hint), - catalog?.preview?.let { ago(it.publishedAt) }, u.follow.channel == Channel.NIGHTLY, - ) { ua.onFollow(Follow(Channel.NIGHTLY)) } - ChannelCard( - Icons.Outlined.Science, stringResource(R.string.upd_tests), stringResource(R.string.upd_tests_hint), - if (tests.isEmpty()) stringResource(R.string.upd_tests_none) else pluralStringResource(R.plurals.upd_tests_count, ready, ready), - u.follow.channel == Channel.TEST, enabled = tests.isNotEmpty() || u.follow.channel == Channel.TEST, - ) { showTests = !showTests } - AnimatedVisibility((showTests || u.follow.channel == Channel.TEST) && tests.isNotEmpty(), enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) { - TestList(tests, me, u, ua) + Row( + horizontalArrangement = Arrangement.spacedBy(4.dp), + modifier = Modifier.fillMaxWidth().clip(CircleShape).background(colors.surface).border(1.dp, pal.line, CircleShape) + .padding(4.dp).selectableGroup(), + ) { + ChannelSegment(Icons.Outlined.Verified, stringResource(R.string.upd_stable), null, shown == Channel.STABLE) { + showTests = false; ua.onFollow(Follow(Channel.STABLE)) + } + ChannelSegment(Icons.Outlined.Bolt, stringResource(R.string.upd_preview), null, shown == Channel.NIGHTLY) { + showTests = false; ua.onFollow(Follow(Channel.NIGHTLY)) + } + ChannelSegment( + Icons.Outlined.Science, stringResource(R.string.upd_tests_short), ready.takeIf { it > 0 }?.toString(), + shown == Channel.TEST, enabled = tests.isNotEmpty() || u.follow.channel == Channel.TEST, + ) { showTests = !showTests } } - val context = androidx.compose.ui.platform.LocalContext.current - val agentReady = com.droiddeck.launcher.agent.AgentHost.installed && - (com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context)) - LabBuilds(sessionRunning, onRebuild = if (agentReady) { info -> - com.droiddeck.launcher.agent.AgentHost.send(context, context.getString(R.string.agent_rebuild_lab, info.label)) - context.startActivity(android.content.Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java) - .putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent") - .addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP or android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)) - } else null) + val hint = when { + listing || u.follow.channel == Channel.TEST -> stringResource(R.string.upd_tests_hint) + u.follow.channel == Channel.NIGHTLY -> stringResource(R.string.upd_preview_hint) + + (catalog?.preview?.let { " · " + stringResource(R.string.upd_latest_ago, ago(it.publishedAt)) } ?: "") + else -> stringResource(R.string.upd_stable_hint) + + (catalog?.stable?.let { " · " + stringResource(R.string.upd_version_ago, it.version ?: it.tag, ago(it.publishedAt)) } ?: "") + } + Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp)) + if (tests.isEmpty() && catalog != null && showTests) Text(stringResource(R.string.upd_tests_none), fontSize = 12.5.sp, color = colors.onSurfaceVariant) + if (!listing) status(false) + AnimatedVisibility(listing, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) { + TestList(tests, me, u, ua, status) + } + } +} + +@Composable +private fun RowScope.ChannelSegment( + icon: ImageVector, title: String, badge: String?, selected: Boolean, + enabled: Boolean = true, onClick: () -> Unit, +) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val src = remember { MutableInteractionSource() } + val hot = rememberHot(src) + Row( + verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterHorizontally), + modifier = Modifier.weight(1f).heightIn(min = 44.dp).paneItem("channel:$title") + .clip(CircleShape) + .background(if (selected) pal.signal.copy(alpha = 0.16f) else if (hot) pal.signal.copy(alpha = 0.10f) else Color.Transparent) + .glideBorder(hot, CircleShape, pal.signal, if (selected) pal.signal else Color.Transparent) + .alpha(if (enabled) 1f else 0.5f) + .hoverable(src) + .selectable(selected = selected, interactionSource = src, indication = null, enabled = enabled, role = Role.RadioButton, onClick = onClick) + .controllerConfirm(enabled = enabled, onClick = onClick) + .padding(horizontal = 6.dp), + ) { + Icon(icon, contentDescription = null, tint = if (selected) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(18.dp)) + Text(title, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = if (selected) colors.onBackground else colors.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false)) + if (badge != null) Text( + badge, fontSize = 11.sp, fontWeight = FontWeight.Bold, color = colors.onSurfaceVariant, + modifier = Modifier.clip(CircleShape).background(colors.surfaceVariant).padding(horizontal = 6.dp, vertical = 1.dp), + ) } } @@ -514,7 +691,7 @@ private fun LinkPill(label: String, url: String) { } @Composable -private fun TestList(tests: List, me: AppUpdates.Installed, u: UpdatesState, ua: UpdatesActions) { +private fun TestList(tests: List, me: AppUpdates.Installed, u: UpdatesState, ua: UpdatesActions, status: @Composable (embedded: Boolean) -> Unit) { val colors = MaterialTheme.colorScheme var query by rememberSaveable { mutableStateOf("") } val needle = query.trim().removePrefix("#").removePrefix("@") @@ -525,58 +702,30 @@ private fun TestList(tests: List, me: AppUpdates.Installed, u: UpdatesS val (ready, old) = matches.partition { it.versionCode >= me.versionCode } val followedOld = u.follow.channel == Channel.TEST && old.any { it.pr == u.follow.pr } var showOld by rememberSaveable { mutableStateOf(false) } - Column(Modifier.padding(start = 18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { - if (tests.size > 5 || query.isNotEmpty()) AdbTextField( - value = query, onValueChange = { query = it }, label = stringResource(R.string.upd_tests_find), - keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, compact = true, showLabel = false, - placeholder = stringResource(R.string.upd_tests_find), modifier = Modifier.fillMaxWidth(), - ) - if (matches.isEmpty()) Text(stringResource(R.string.upd_tests_no_match), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(4.dp)) - ready.forEach { t -> TestRow(t, u.follow.pr == t.pr && u.follow.channel == Channel.TEST) { ua.onFollow(Follow(Channel.TEST, t.pr)) } } - if (old.isNotEmpty()) { - MoreLink(stringResource(R.string.upd_tests_old, old.size, me.versionCode), "tests:old") { showOld = !showOld } - if (showOld || followedOld || needle.isNotEmpty()) old.forEach { t -> - TestRow(t, u.follow.pr == t.pr && u.follow.channel == Channel.TEST, tooOld = true) { ua.onFollow(Follow(Channel.TEST, t.pr)) } + val oldShown = showOld || followedOld || needle.isNotEmpty() + val followed = u.follow.pr.takeIf { u.follow.channel == Channel.TEST } + val rowShown = followed != null && (ready.any { it.pr == followed } || (oldShown && old.any { it.pr == followed })) + Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { + // A followed test's row carries the status; browsing Tests while following Stable or Preview shows it only for an install running or failed. + if (if (followed != null) !rowShown else u.stage != null || u.error != null) status(false) + Column(Modifier.padding(start = 18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) { + if (tests.size > 5 || query.isNotEmpty()) AdbTextField( + value = query, onValueChange = { query = it }, label = stringResource(R.string.upd_tests_find), + keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, compact = true, showLabel = false, + placeholder = stringResource(R.string.upd_tests_find), modifier = Modifier.fillMaxWidth(), + ) + if (matches.isEmpty()) Text(stringResource(R.string.upd_tests_no_match), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(4.dp)) + ready.forEach { t -> TestRow(t, followed == t.pr, status = status) { ua.onFollow(Follow(Channel.TEST, t.pr)) } } + if (old.isNotEmpty()) { + MoreLink(stringResource(R.string.upd_tests_old, old.size, me.versionCode), "tests:old") { showOld = !showOld } + if (oldShown) old.forEach { t -> + TestRow(t, followed == t.pr, tooOld = true, status = status) { ua.onFollow(Follow(Channel.TEST, t.pr)) } + } } } } } -@Composable -private fun ChannelCard( - icon: ImageVector, title: String, hint: String, latest: String?, selected: Boolean, - enabled: Boolean = true, onClick: () -> Unit, -) { - val colors = MaterialTheme.colorScheme - val pal = LocalPalette.current - val src = remember { MutableInteractionSource() } - val hot = rememberHot(src) - val fill = if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(14.dp), - modifier = Modifier.fillMaxWidth().paneItem("channel:$title") - .clip(Shape14).background(colors.surface).background(fill).glideBorder(hot, Shape14, pal.signal, pal.line) - .alpha(if (enabled) 1f else 0.55f) - .hoverable(src) - .clickable(interactionSource = src, indication = null, enabled = enabled, role = Role.RadioButton, onClick = onClick) - .controllerConfirm(enabled = enabled, onClick = onClick) - .padding(horizontal = 14.dp, vertical = 10.dp), - ) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.size(38.dp).clip(Shape12).background(if (selected) pal.signal.copy(alpha = 0.18f) else colors.surfaceVariant)) { - Icon(icon, contentDescription = null, tint = if (selected) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(22.dp)) - } - Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) { - Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { - Text(title, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) - if (latest != null) Text(latest, fontSize = 12.sp, fontWeight = FontWeight.Medium, color = if (selected) pal.signal else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) - } - Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) - } - RadioDot(selected) - } -} - @Composable private fun RadioDot(selected: Boolean, size: androidx.compose.ui.unit.Dp = 22.dp) { val pal = LocalPalette.current @@ -586,40 +735,46 @@ private fun RadioDot(selected: Boolean, size: androidx.compose.ui.unit.Dp = 22.d } @Composable -private fun TestRow(t: Release, selected: Boolean, tooOld: Boolean = false, onClick: () -> Unit) { +private fun TestRow(t: Release, selected: Boolean, tooOld: Boolean = false, status: @Composable (embedded: Boolean) -> Unit, onClick: () -> Unit) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current val src = remember { MutableInteractionSource() } val hot = rememberHot(src) - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(12.dp), - modifier = Modifier.fillMaxWidth().paneItem("test:${t.pr}") - .heightIn(min = 52.dp) - .clip(Shape12) - .background(colors.surface).background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent) - .glideBorder(hot, Shape12, pal.signal, pal.line) - .alpha(if (tooOld && !selected) 0.6f else 1f) - .hoverable(src) - .clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onClick) - .controllerConfirm(onClick = onClick) - .padding(horizontal = 12.dp, vertical = 8.dp), + Column( + Modifier.fillMaxWidth().clip(Shape12).background(colors.surface) + .glideBorder(hot, Shape12, pal.signal, if (selected) pal.signal.copy(alpha = 0.5f) else pal.line), ) { - Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant) - Column(Modifier.weight(1f)) { - Text(changeTitle(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) - val detail = when { - t.apk == null -> stringResource(R.string.upd_not_built) - tooOld -> stringResource(R.string.upd_tests_old_row, t.versionCode) - else -> stringResource(R.string.upd_updated, ago(t.builtAt.takeIf { it > 0 } ?: t.publishedAt)) + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp), + modifier = Modifier.fillMaxWidth().paneItem("test:${t.pr}") + .heightIn(min = 52.dp) + .background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent) + .alpha(if (tooOld && !selected) 0.6f else 1f) + .hoverable(src) + .clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onClick) + .controllerConfirm(onClick = onClick) + .padding(horizontal = 12.dp, vertical = 8.dp), + ) { + Text("#${t.pr}", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = if (selected) pal.signal else colors.onSurfaceVariant) + Column(Modifier.weight(1f)) { + Text(changeTitle(t.title.ifBlank { stringResource(R.string.upd_pr, t.pr) }), fontSize = 13.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + val detail = when { + t.apk == null -> stringResource(R.string.upd_not_built) + tooOld -> stringResource(R.string.upd_tests_old_row, t.versionCode) + else -> stringResource(R.string.upd_updated, ago(t.builtAt.takeIf { it > 0 } ?: t.publishedAt)) + } + Text( + listOfNotNull(detail, t.author.takeIf { it.isNotEmpty() }?.let { "@$it" }, t.shortCommit).joinToString(" · "), + fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, + ) + if (t.newerCommitPushed) Text(stringResource(R.string.upd_newer_commit_short), fontSize = 12.sp, color = AttentionAmber, maxLines = 1, overflow = TextOverflow.Ellipsis) } - Text( - listOfNotNull(detail, t.author.takeIf { it.isNotEmpty() }?.let { "@$it" }, t.shortCommit).joinToString(" · "), - fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis, - ) - if (t.newerCommitPushed) Text(stringResource(R.string.upd_newer_commit_short), fontSize = 12.sp, color = AttentionAmber, maxLines = 1, overflow = TextOverflow.Ellipsis) + RadioDot(selected, 20.dp) + } + AnimatedVisibility(selected, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) { + status(true) } - RadioDot(selected, 20.dp) } } diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/BottomDesktopCompositorService.kt b/app/src/main/java/com/droiddeck/launcher/wayland/BottomDesktopCompositorService.kt index d1c64b4b39..4b9d25957a 100644 --- a/app/src/main/java/com/droiddeck/launcher/wayland/BottomDesktopCompositorService.kt +++ b/app/src/main/java/com/droiddeck/launcher/wayland/BottomDesktopCompositorService.kt @@ -31,7 +31,7 @@ class BottomDesktopCompositorService : Service() { MSG_RESIZE -> resize(msg.arg1, msg.arg2) MSG_TOUCH -> WaylandCompositor.nativeSendTouch(msg.arg1 and 0xff, msg.arg1 shr 8, msg.arg2 ushr 16, msg.arg2 and 0xffff) - MSG_KEY -> WaylandCompositor.nativeSendKey(msg.arg1, msg.arg2) + MSG_KEY -> WaylandCompositor.nativeSendKeyOrdered(msg.arg1, msg.arg2) MSG_POINTER -> WaylandCompositor.nativeSendPointer(1, msg.arg1, msg.arg2) MSG_SCENE -> WaylandCompositor.nativeSendSceneInput(msg.arg1, msg.arg2, msg.peekData()?.getInt(KEY_B) ?: 0) MSG_CURSOR -> if (CompositorHost.isStarted) WaylandCompositor.nativeSetCursorComposite(msg.arg1 != 0) diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt b/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt index d9d2eb111f..d193c2b025 100644 --- a/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/wayland/CompositorHost.kt @@ -67,13 +67,14 @@ object CompositorHost { outputHeight: Int, refreshHz: Float, fpsLimit: Int, + layerFpsLimit: Int = fpsLimit, ): Boolean { WaylandCompositor.nativeSetClockControl(java.io.File(context.filesDir, "${com.droiddeck.launcher.runtime.LinuxRuntime.DIR}/tmp/.dd-clock").path) ownVsyncThread = SessionPrefs.vsyncThread(context) WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context)) blackFrameInsertion = SessionPrefs.blackFrameInsertion(context) WaylandCompositor.nativeSetBlackFrameInsertion(blackFrameInsertion) - pace(refreshHz, fpsLimit) + pace(refreshHz, fpsLimit, layerFpsLimit) if (!SessionState.running) WaylandCompositor.nativeSetOutputSize(outputWidth, outputHeight) if (started) { attached = surface @@ -95,23 +96,23 @@ object CompositorHost { private var blackFrameInsertion = false private var pictureHolds = 0 - private fun pace(refreshHz: Float, fpsLimit: Int) { + private fun pace(refreshHz: Float, fpsLimit: Int, layerFpsLimit: Int) { WaylandCompositor.nativeSetFpsLimit(fpsLimit) - WaylandCompositor.nativeSetLayerFrameRate(if (fpsLimit > 0 && !blackFrameInsertion) fpsLimit.toFloat() else refreshHz) + WaylandCompositor.nativeSetLayerFrameRate(SessionPrefs.layerFrameRate(layerFpsLimit, refreshHz, blackFrameInsertion)) WaylandCompositor.nativeSetOutputRefreshRate(refreshHz) SessionState.refreshHz = refreshHz } @Synchronized - fun updatePacing(refreshHz: Float, fpsLimit: Int) { - if (started) pace(refreshHz, fpsLimit) + fun updatePacing(refreshHz: Float, fpsLimit: Int, layerFpsLimit: Int = fpsLimit) { + if (started) pace(refreshHz, fpsLimit, layerFpsLimit) } @Synchronized - fun setBlackFrameInsertion(on: Boolean, refreshHz: Float, fpsLimit: Int) { + fun setBlackFrameInsertion(on: Boolean, refreshHz: Float, fpsLimit: Int, layerFpsLimit: Int = fpsLimit) { blackFrameInsertion = on WaylandCompositor.nativeSetBlackFrameInsertion(on) - if (started) pace(refreshHz, fpsLimit) + if (started) pace(refreshHz, fpsLimit, layerFpsLimit) } /** Presents only pictures until the matching release; false when nothing is strobing. */ diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java index 4e824f6dba..a2676304d9 100644 --- a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java +++ b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java @@ -9,6 +9,10 @@ public final class WaylandCompositor { private WaylandCompositor() {} + public static native boolean frameWorkerProbeEnabled(); + public static native boolean frameWorkerProbeGrant(int owner, int pid, long expires, String path, long dev, long ino, long startTicks); + public static native void frameWorkerProbeRevoke(int owner, int pid); + private static volatile Runnable firstFrameListener; public static void setFirstFrameListener(Runnable r) { firstFrameListener = r; } @@ -202,6 +206,27 @@ public final class WaylandCompositor { if (l != null) l.onTextInput(enabled, program, x, y, w, h); } + public interface TextInputFallbackListener { + boolean onTextInputFallback(String text, int token); + } + + private static volatile TextInputFallbackListener textInputFallbackListener; + + public static void setTextInputFallbackListener(TextInputFallbackListener l) { textInputFallbackListener = l; } + + public static boolean isTextInputFallbackListener(TextInputFallbackListener l) { return textInputFallbackListener == l; } + + public static void clearTextInputFallbackListener(TextInputFallbackListener l) { + if (textInputFallbackListener == l) textInputFallbackListener = null; + } + + @SuppressWarnings("unused") + static boolean onTextInputFallback(byte[] utf8, int token) { + TextInputFallbackListener l = textInputFallbackListener; + if (l == null || utf8 == null) return false; + return l.onTextInputFallback(new String(utf8, java.nio.charset.StandardCharsets.UTF_8), token); + } + private static byte[] utf8(String s) { return s == null ? new byte[0] : s.getBytes(java.nio.charset.StandardCharsets.UTF_8); } @@ -210,14 +235,28 @@ public final class WaylandCompositor { public static void textInputCommit(String text) { if (text != null && !text.isEmpty()) nativeTextInputCommit(utf8(text)); } + public static void textInputCommitAndSubmit(String text) { + if (text != null && !text.isEmpty()) nativeTextInputCommitAndSubmit(utf8(text)); + } + public static void textInputPreedit(String text, int cursor) { nativeTextInputPreedit(utf8(text), cursor, cursor); } public static void textInputDelete(int before, int after) { nativeTextInputDelete(before, after); } + public static final int TEXT_NOT_DELIVERED = 0; + public static final int TEXT_DELIVERED = 1; + public static final int TEXT_UNRESOLVED = 2; + + public static void completeTextInputFallback(int token, int result) { + nativeCompleteTextInputFallback(token, result); + } + private static native void nativeSetClipboardText(byte[] utf8); private static native void nativeTextInputCommit(byte[] utf8); + private static native void nativeTextInputCommitAndSubmit(byte[] utf8); private static native void nativeTextInputPreedit(byte[] utf8, int cursorBegin, int cursorEnd); private static native void nativeTextInputDelete(int before, int after); + private static native void nativeCompleteTextInputFallback(int token, int result); public static native void nativeStart(String xdgRuntimeDir); @@ -248,6 +287,10 @@ public final class WaylandCompositor { public static native void nativeSendKey(int evdev, int state); + // Ordered delivery: key events share the host queue with text commits so keys cannot overtake pending text. + public static native void nativeSendKeyOrdered(int evdev, int state); + public static native void nativeSelectGameField(boolean copy); + public static native boolean nativeFocusTakesTouch(); public static native boolean nativeCursorInputPos(int[] out); @@ -290,6 +333,8 @@ public final class WaylandCompositor { public static native void nativeSetZeroCopy(boolean on); + public static native void nativeSetMirrorCapture(boolean on); + public static native void nativeSetDisplayBufferDriver(boolean on); public static native int nativeZeroCopyFrames(); @@ -371,6 +416,7 @@ public final class WaylandCompositor { public static native void nativeHdrNoteHeadroomRequest(float ratio); public static native void nativeSetScaleMode(int fullscreenMode, int screenAlignment); + public static native void nativeSetZoom(float zoom); public static native void nativeSetUpscaler(int mode); @@ -416,12 +462,14 @@ public final class WaylandCompositor { public static final int SCENE_BUTTON = 3, SCENE_WHEEL = 4, SCENE_POINTER_DELTA = 6, SCENE_AXIS = 11, SCENE_AXIS_FINGER = 12; public static final int WHEEL_STEP_UNITS = 120, POINTER_DELTA_SCALE = 256; - public static final int FG_ENGINE_LSFG = 0, FG_ENGINE_DDFG = 1; + public static final int FG_ENGINE_LSFG = 0, FG_ENGINE_DDFG = 1, FG_ENGINE_ZEROFG = 2; public static native void nativeSetFrameGenEngine(int kind); public static native void nativeSetFrameGenArmed(boolean armed, int multiplier, int targetFps); + public static native void nativeSetFrameGenPacer(boolean on); + public static native void nativeSetLsfgCachePath(String path); public static native void nativeSetFrameGenTuning(float flowScale, float refreshHz); diff --git a/app/src/main/res/color/wireless_pairing_key_text.xml b/app/src/main/res/color/wireless_pairing_key_text.xml new file mode 100644 index 0000000000..62b63fbefb --- /dev/null +++ b/app/src/main/res/color/wireless_pairing_key_text.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_frame_generation.xml b/app/src/main/res/drawable/ic_frame_generation.xml new file mode 100644 index 0000000000..bf643a0c8d --- /dev/null +++ b/app/src/main/res/drawable/ic_frame_generation.xml @@ -0,0 +1,14 @@ + + + + diff --git a/app/src/main/res/drawable/wireless_pairing_key.xml b/app/src/main/res/drawable/wireless_pairing_key.xml new file mode 100644 index 0000000000..51bffe4ff2 --- /dev/null +++ b/app/src/main/res/drawable/wireless_pairing_key.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/wireless_pairing_panel.xml b/app/src/main/res/drawable/wireless_pairing_panel.xml new file mode 100644 index 0000000000..4e88b9b826 --- /dev/null +++ b/app/src/main/res/drawable/wireless_pairing_panel.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/wireless_pairing_keypad.xml b/app/src/main/res/layout/wireless_pairing_keypad.xml new file mode 100644 index 0000000000..159a4e75fd --- /dev/null +++ b/app/src/main/res/layout/wireless_pairing_keypad.xml @@ -0,0 +1,38 @@ + + + + +