Files
openchamber-android-native/third_party/mygo/ui/shader/code_other.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set:

- servers: saved servers, passwordless and password login, proxy,
  self-signed certificates, per-server device tokens (Keystore), connect
  form, instance list sheet with switch/disconnect
- sessions: virtualized list, search, new session, rename/archive/delete,
  running indicator, event stream keeps it live
- chat: pushed window with system back bar, streaming Markdown via
  ui/markdown, reasoning and tool rows with image previews, footer menu
  (read aloud via a Kotlin TTS plugin, copy, fork), user message menu
  (copy, revert, fork), context usage ring and detail sheet, attachments
  (photos/files via the document picker), permissions
- release builds allow plain http:// LAN servers (Go's net/http dials
  directly, no cleartext manifest needed)
- a local fork of MyGo (third_party/mygo) lowers the Android host's
  minSdk to 24 (Android 7.0); Go 1.27.4 via mise

Version 0.3.0.
2026-11-18 13:22:59 +08:00

37 lines
1.6 KiB
Go

//go:build !(darwin && !ios) && !windows
package shader
import (
"github.com/egoist/mygo/internal/scene"
"github.com/egoist/mygo/internal/shader"
"github.com/egoist/mygo/internal/shaderir"
"github.com/egoist/mygo/internal/shaderir/glsl"
)
// code gives fx p's code for the OpenGL and WebGL 2 renderer, as an
// effect's, with the uniforms in the std140 block ShaderUniforms and the
// images in the samplers T0 to T3, and returns where the uniforms' lanes
// lie in the block and its size. The renderer draws with GL's y going up,
// which negates dFdy, and keeps canvases' rows going up, which it tells
// the shader in uShaderFlipRows. What it reads of a quad of those one
// draw draws (DrawInstances) comes from the instance drawing it, in the
// slots of an effect's parameters (gpu.Builder).
func code(p *shaderir.Program, fx *scene.Effect) ([]int, int) {
fx.GLSL = glsl.Fragment(p, "shaderFragment", glsl.Options{FlipY: "true", Block: "ShaderUniforms", FlipRows: "uShaderFlipRows", Instance: shader.InstanceUniform}) + `
vec4 effect(vec2 p, Effect e) {
// p4.z is 1 for a mask glyph, its positions from the box's corner in
// p4.xy, and 2 for a quad of those one draw draws.
bool many = e.p4.z > 1.5;
vec4 none = vec4(0.0);
shaderInstance[0] = many ? e.p0 : none;
shaderInstance[1] = many ? e.p1 : none;
shaderInstance[2] = many ? e.p2 : none;
shaderInstance[3] = many ? e.p3 : none;
shaderInstance[4] = many ? vec4(e.p4.w, e.p4.xy, 1.0) : none;
return shaderFragment(vec4(p, 0.0, 1.0), (p - (e.p4.z > 0.5 && !many ? e.p4.xy : e.rect.xy)) / U2);
}
`
return glsl.UniformLanes(p)
}