-

@ Mike Dilger ☑️
2025-05-23 21:43:49
0. Images start as a URL.
1. The 'Fetcher' then handles it and moves it through these states: Starting, CheckingCache, LoadingFromCache, Queued, Fetching, Ready, Taken, Failed. These states are so that subsequent calls to the Fetcher don't start over and fetch it yet-again. This consults a local file cache and then gets it from the network.
2. Then the media handler hashes the data and compares it to any file metadata that was specified to see if the hash matches what was expected.
3. Then it scales the image and converts SVGs into images and makes this result available for the UI as an RgbaImage.
4. The UI then takes the image and turns it into a UI-friendly ColorImage which is loaded to the GPU, and the UI remembers just a TextureHandle.
5. The UI can now draw it with the TextureHandle as needed. When the UI draws it, it also draws the menu that lets you copy the URL (which it remembered).
In order to add "Copy Image to Clipboard" there will need to be sigificant refactoring because you'll want the original bytes before the media handler scaled and converted the data for rendering purposes back in step 3, which the UI never sees currently (it is part of the lib media handler, which I admit is wrong) and also the UI dropped the bytes itself as soon as it got a TextureHandle (it never needed to keep the bytes so far, and keeping all the images might hog CPU-side memory unnecessarily).