Brand New AggPas Canvas ready for testing #170
Replies: 4 comments 9 replies
-
|
This sounds amazing Graeme, nicely done. I'll give it ago |
Beta Was this translation helpful? Give feedback.
-
|
The text looks fine in maximus, no problems there. :) I had the window set to full screen though and I think there's a noticeable delay in the painting. This video is with hybrid. Note the keys appear at a constant rate. (The text disappears but I think that's a different bug that happens in dev too.) Making the window smaller Hybrid/Full screen: Screencast.from.2026-03-21.09-39-20.mp4Develop/Full screen Screencast.from.2026-03-21.09-37-09.mp4Hybrid/small window: Screencast.from.2026-03-21.09-56-02.mp4 |
Beta Was this translation helpful? Give feedback.
-
|
here's the gprof output: |
Beta Was this translation helpful? Give feedback.
-
|
UPDATE: For easier testing, and because I consider the new Hybrid Canvas way better than the original AggPas canvas, I've merged this branch into 'develop'. See updated instructions on how to activate and build it. It has now taken over the original -dAggCanvas compiler define. The old Aggpas Canvas (Agg2D.pas) is still their, but unused. I'll probably delete it some time in the future. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone. 👋
UPDATE: This branch has been merged into the 'develop' branch. The original Agg2Dpas (old Aggpas based canvas) has been disabled, and replaced with this new Hybrid Canvas. It has been tested under Linux, FreeBSD and Windows.
TL;DR:
Compile it with:
The Back Story
All I really wanted was to speed up large amounts of horizontal text rendering. Think of an IDE with 60 lines of code, syntax highlighting, different styles (normal, bold, italic) and about 120 characters wide. Well, the existing AggCanvas (compiled with -dAggCanvas) showed that the quality was great, but the performance was terrible. 🙄
To be fair, AggPas is a software renderer, and using glyph outline mode to render high-quality text took its toll. Running the IDE through the Valgrind Profiler showed that a screen of text caused over 1.2mil internal scanline calculation calls. 😬
So, I had an idea... Why not use AggPas for all the 2D rendering (rectangles, lines, fills etc). We get the the beautiful anti-aliased graphics, transparency support etc. And then use native libraries (Xft or GDI) for high speed text rendering. It sounded great and I had a very elegant design in mind (no include files etc). So I implemented it over a few days. But I hit problems with clipping, then problem with z-order, then problems with event queueing the text rendering, the destruction order of popup window and the list went on... I was playing whack-a-mole!🔨
I needed a new plan. How does GTK3/4 and Qt do it so fast? I then stumbled upon an old Haiku article about how they use AGG for the whole OS rendering, including text. They explained it in detail [thank you!], and that was the Eureka moment! Glyph Bitmap Mask Cacheing! Then bypass AGG's scanline calculations and just blend the glyph masks character by character on the screen using AGG (AggPas in my case). No glyph outline calculations for every piece of text I render!
And so I started with implementation number 2. Lessons learnt from my first attempt, made this go much faster than I expected, and I could reuse a lot of code. The results.... It's way better than both the previous and original attempts - no include files - and way way faster than the original.
I present Hybrid Canvas [the name will change 😂]. I did extensive tests with the ide (maximus), docview, uidesigner and every single examples/gui/* demo. I noted two minor bugs only, which I'll fix soon.
If you are willing to test, it's Linux & FreeBSD only for now. If you can report any bugs in this thread, it would be greatly appreciated. 🙏
Beta Was this translation helpful? Give feedback.
All reactions