[haiku-development] Re: Integer image scaling code

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 23 Sep 2009 09:58:58 +0200

On 2009-09-23 at 09:46:54 [+0200], Michael Crawford <mdcrawford@xxxxxxxxx> 
wrote:
> Hey Folks,
> 
> A while back I wrote an image scaler in C++ that used only integer math.  
> It was quite fast; even on a 150 MHz PowerPC Mac, I could drag my mouse 
> rapidly around on the resize handle for an image, and it would keep up 
> with my movements with very little lag.  I'm sure that on today's 
> processors it would be blazing.
> 
> Now this wouldn't be an advantage on modern x86 processors that have 
> vectorized floating point.  But possibly it would on the ARM port of 
> Haiku, or on older x86 chips that have more modest capabilities.  Many 
> embedded chips don't have hardware floating point, and even some chips 
> that do, can't do it as fast as integer.
> 
> This code included alpha channel support, so the image could be 
> transparent or semitransparent, and it would do the right thing.
> 
> If you think Haiku could use it, I'll dig up the code and make a 
> standalone demo.
> 
> There is one other advantage to it over floating point methods: some CPUs 
> have multiple integer units but only one FPU.  So doing an intensive 
> operation in integer can potentially be faster even if a floating point 
> operation is as fast as an integer op.

We already have integer image scaling code in the app_server and it is 
supposedly quite fast, but I have no idea if it matches up with what you 
wrote. Christian Packman accelerated it using SIMD code. IIRC, we didn't 
write a version that does also alpha blending, although it would be quite 
easy to add (except the source image needs to be pre-multiplied for it to 
work correctly). That being said, it would be very interesting to see your 
code, so if it would be fun for you to dig it up and put it into a 
stand-alone test, that would be awesome!

Best regards,
-Stephan

Other related posts: