Thursday, 15 May 2014

performance - Delphi slow bitblt from very large bitmap -



performance - Delphi slow bitblt from very large bitmap -

i creating component, in 1 can design tables drag&drop.

i managed write drag&drop part , table rendering, have problem.

i utilize double buffering, cut down flickering, drawing in-memory bitmap, bitblt portion of screen.

steps:

draw table in-memory bitmap (this can large, maximum). partial in-memory bitmap contents on command canvas.

the problem is, larger in-memory bitmap is, slower bitblt operation (obviously).

my question is:

how improve performance of this? i'm interested in alternative solutions too.

code:

procedure tcustomgraphicscrollcontrol.paint; var x,y: integer; begin inherited; // rendering done in kid class. frender 4-bit color depth // in-memory bitmap. if horzscrollbar.visible x := horzscrollbar.position else x:=0; if vertscrollbar.visible y := vertscrollbar.position else y:=0; // create sec in-memory bitmap, same dimensions command // , same color depth frender. way bitblt little faster, won't needed conversion. // bitblt part of big in-memory bitmap screen bitblt( fcanvas.handle, 0, 0, width, height, frender.canvas.handle, x, y, srccopy ); end;

update:

removed "triple buffering" , updatescrollbars code , question.

draw table in-memory bitmap (this can large, maximum). blit partial in-memory bitmap contents on command canvas.

the problem is, larger in-memory bitmap is, slower bitblt operation (obviously).

i don't believe have correctly diagnosed problem. performance of blit largely determined size of target rectangle. true big source bitmap, memory access may less efficient. 1 time source bitmap big plenty create each scanline read blit reside in different cache line, performance should constant target rectangle size.

so, obvious conclusion draw if performance degrades total in-memory bitmap size increased, drawing of in-memory bitmap bottleneck. included no details of cannot offer detailed optimisation suggestions. next step seek work out performance bottleneck is. if believe, bottleneck total in-memory bitmap, you'll need find way improve performance there.

performance delphi bitblt

No comments:

Post a Comment