Friday, November 5, 2010

TDirect2DCanvas Performance

A question about the performance of TDirect2DCanvas was brought to my attention on Stack Overflow the other day and I decided to answer it. Check it out here. Hopefully this solves some of the mystery around the performance issues of Direct2D. Direct2D really is cool.

6 comments:

Tiago Lima Trinidad said...

Hi Chris,
That really was helpful and I updated my question according to your suggestion of disabling anti-aliasing.

But, as you can see, GDI is in fact still faster, and there's not quality improvement to use Direct2D, as it's also aliased.

The problem is that in my case those milliseconds accumulate to be actually noticeable (there are some situations in which GDI takes about 2 seconds to draw everything).

Thanks and god bless!

Chris Bensen said...

@Tiago - glad the answer helped. Did you try creating the geometry beforehand? That will also speed things up. When I did that I got better results from Direct2D than GDI. I'm also not sure if BeginPaint and EndPaint need to be called.

Xepol said...

I can't speeak to XE yet, but in 2010 TDirect2DCanvas is a kludge. It sort of works, but it ignores a LOT of issues related to making Direct2D work correctly, but it also hides result codes, such as when you need to recreate your bitmaps.

abouchez said...

What about GDI+ speed, in comparison?

We wrote a free unit, able to render any VCL TCanvas content (using a TMetaFile) using the GDI+ engine. In practice, performance was very good, and anti-aliaising was on...

See http://synopse.info/forum/viewtopic.php?id=10

Marko said...

I'm looking into using AGG (AntiGrain) for graphics. I haven't done any benchmarks but it seems to be quite fast. It also supports subpixels which is really nice.

Just a tip for those looking alternatives ;)

abouchez said...

AGG is nice, and performance is great!
Graphics32 is not a bad choice.
Both are pure Delphi open source units.
But none is TCanvas compatible, as far as I remember.

Post a Comment