[haiku-development] Re: Blitting
- From: Caitlin Shaw <rogueeve@xxxxxxxxxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Tue, 15 Sep 2009 13:07:51 -0700
> What you want to accomplish is done via DrawBitmap(). You just need to
> keep different BBitmaps around for the various layers of your drawings.
> One bitmap would be the background, of the size of your view, the other
> would be the cursor, of the size of just the cursor. When you want to
> redraw the cursor, it would work like this:
>
> BRect originalCursorRectInViewCoordinates = ...;
> BRect newCursorRect
> = originalCursorRectInViewCoordinates.OffsetByCopy(cursorOffset);
> Invalidate(originalCursorRectInViewCoordinates | newCursorRect);
>
Thank you so much for the info. That is, more or less, what I have been
doing in the latest revisions--just not doing any buffering at all, and
I noticed that it really does not flicker hardly at all, as it would on
other OS's, but I wasn't sure why that was.
I don't currently have any sort of backbuffer to store the image of the
document beyond what's up on the screen, as when I had it that way it
ran a bit slower, so I took it out. I do occasionally notice a bit of
flicker on the current line when you're typing, so I was thinking of
implementing my own level of backbuffering again but doing it for the
current line only, which would also give the cursor a backstore to erase
itself via--currently the whole line is redrawn everytime it blinks,
which is really dumb.
Also when scrolling up and down in the document I was thinking THAT
would be a good candidate for the CopyBits function, since most of the
data on the screen is the same, just moved up/down a line. I assume
CopyBits would probably be faster than redrawing the whole screen manually.
The editor is usable just as it is--in fact I'm now using it to write
itself--but I really have a thing for speed and like to make my code as
efficient as possible, probably comes from doing a lot of game
programming and embedded systems, so being new to Haiku development I
wasn't sure which API were the right ones.
Other related posts: