PRODUCTS
  • Blog
  • What's new
  • Newsletter
  • Visit the Store
  • Zoom Player
  • Zoom Player Awards
  • Zoom Player Press
  • Zoom Commander
  • WhiteWash Wizard
DOWNLOADS
  • Zoom Player MAX
  • Zoom Player IPTV
  • Zoom Player Remote
  • Zoom Player Languages
  • Zoom Player Skins
  • Zoom Player MAX Beta
  • Zoom Player IPTV Beta
  • Zoom Commander
  • Backgrounds
  • Graphic Assets
  • Other Downloads
SUPPORT
  • Zoom Player Help
  • Zoom Player Interface
  • Zoom Player on Tablets
  • Video Tutorials
  • Zoom Commander
  • Support on Reddit
  • Registration Support
ZOOM PLAYER GUIDE
  • SETUParrow
    • Formats & Decoders
    • Options & Settings
    • Media Library Basics
    • Media Library Scraping
    • IPTV
    • Skin Selection
    • Player Modes
    • Streaming
    • Presets
    • Calibration Patterns
    • Articles
    • Resources
    • FAQ
  • CONTROLarrow
    • Keyboard Shortcuts
    • Remote Control
    • Command Line
    • Control API
    • Zoom Player Functions
  • THE USER INTERFACEarrow
    • Screenshots
    • Fullscreen Navigation
    • The Control Bar
    • The Playlist
    • The Equalizer
    • IPTV
    • Chapters & Bookmarks
    • The Scheduler
    • Dynamic Video Editing
CONTACT
  • Registration Support
  • Licensing & Marketing
  • Business Development
  • Affiliate Signup
  • Client Showcase
  • About Inmatrix
  • PRODUCTSarrow
    • Blog
    • What's new
    • Newsletter
    • Visit the Store
    • Zoom Player
    • Zoom Player Awards
    • Zoom Player Press
    • Zoom Commander
    • WhiteWash Wizard
  • DOWNLOADSarrow
    • Zoom Player MAX
    • Zoom Player IPTV
    • Zoom Player Remote
    • Zoom Player Languages
    • Zoom Player Skins
    • Zoom Player MAX Beta
    • Zoom Player IPTV Beta
    • Zoom Commander
    • Backgrounds
    • Graphic Assets
    • Other Downloads
  • SUPPORTarrow
    • Zoom Player Help
    • Zoom Player Interface
    • Zoom Player on Tablets
    • Video Tutorials
    • Zoom Commander
    • Support on Reddit
    • Registration Support
  • ZOOM PLAYER GUIDEarrow
    • FAQ
    • Articles
    • Screenshots
    • Backgrounds
    • Player Modes
    • Fullscreen Navigation
    • Playlist
    • Equalizer
    • Control Bar
    • Skin Selection
    • Media Library Basics
    • Media Library Scraping
    • Scheduler
    • Remote Control
    • Command Line
    • Functions
    • Control API
    • Options & Settings
    • Keyboard Shortcuts
    • Formats & Decoders
    • Chapters & Bookmarks
    • Dynamic Video Editing
    • Presets
    • Calibration Patterns
    • Streaming
    • Resources
    • Graphic Assets
  • CONTACTarrow
    • Registration Support
    • Licensing & Marketing
    • Business Development
    • Affiliate Signup
    • Client Showcase
    • About Inmatrix

Some musing on code optimization

Playing Blu-ray with Zoom Player

Published February 3rd, 2025

When initially designing a new UI such as the Modern UI, I always work on the design first and then when I feel the code is mature enough, I go in and optimize to make sure the UI is as responsive and smoothly as I can make it.

Initial optimizations

My initial code included an icon-size caching system I designed years ago. I also calculated most of the layout math in advance to make the code more legible as I was coding it and to prevent silly things like repeating the same math over and over and over.

Don't repeat the math

Since drawing the volume/timeline bar graphics requires higher-level math, from the start I kept cached images of both bars in their two states. This means every volume/timeline updates only need to copy a bitmap rather than calculating anti-aliased curves.

Starting point

At this point, drawing the Modern UI took 1.8 milliseconds (using the screenshot's resolution). That's actually quite speedy, but I knew there was lots more to optimize.

Caching the background gradient

First thing, I cached the background gradient, if the window size is not changed, there's no reason to redraw it each time. This action alone reduced the draw time from 1.8ms to 1.2ms.

Buttons & Title text

The second optimization addressed the buttons and title text. Again, if the window is not resized, they stay the same and there's no need to update them. This reduced the draw time from 1.2ms to 0.7ms.

The volume bar

The third optimization addressed the volume bar. If you're just changing the volume, there's no need to update anything else, just clear the region by copying from the cached background image and draw the new volume bar. Changing the volume level alone now takes 0.25ms.

The timeline bar

The forth and final optimization addressed the timeline bar and text. Both elements are updated every second, but again, I just clear the region by copying from the cached background image and then draw the new timeline. Updating the current position now takes 0.35ms.

Conclusion

I'm sure if I spent more time on the code, I may be able to shave a few more microseconds, but as it stands now, I'm very satisfied with the 500-600% average draw speedup.



Attribution • Privacy Policy • Terms of Usage
Discord Facebook Youtube Reddit