* Refactor the method that actually copies rectangles from the back buffer to

the front buffer so that derived classes could override it.
* Minor coding style changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26542 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-07-21 12:31:27 +00:00
parent 22e1bd0701
commit c5ac899aac
2 changed files with 31 additions and 19 deletions

View File

@ -336,20 +336,11 @@ HWInterface::CopyBackToFront(const BRect& frame)
// make sure we don't copy out of bounds
area = bufferClip & area;
uint32 srcBPR = backBuffer->BytesPerRow();
uint8* src = (uint8*)backBuffer->Bits();
BRegion region((BRect)area);
if (IsDoubleBuffered())
region.Exclude((clipping_rect)_CursorFrame());
int32 count = region.CountRects();
for (int32 i = 0; i < count; i++) {
clipping_rect r = region.RectAtInt(i);
// offset to left top pixel in source buffer (always B_RGBA32)
uint8* srcOffset = src + r.top * srcBPR + r.left * 4;
_CopyToFront(srcOffset, srcBPR, r.left, r.top, r.right, r.bottom);
}
CopyBackToFront(region);
_DrawCursor(area);
@ -359,6 +350,24 @@ HWInterface::CopyBackToFront(const BRect& frame)
}
void
HWInterface::CopyBackToFront(/*const*/ BRegion& region)
{
RenderingBuffer* backBuffer = BackBuffer();
uint32 srcBPR = backBuffer->BytesPerRow();
uint8* src = (uint8*)backBuffer->Bits();
int32 count = region.CountRects();
for (int32 i = 0; i < count; i++) {
clipping_rect r = region.RectAtInt(i);
// offset to left top pixel in source buffer (always B_RGBA32)
uint8* srcOffset = src + r.top * srcBPR + r.left * 4;
_CopyToFront(srcOffset, srcBPR, r.left, r.top, r.right, r.bottom);
}
}
// #pragma mark -
@ -609,9 +618,8 @@ HWInterface::_DrawCursor(IntRect area) const
// * location in front buffer is calculated
// * conversion from B_RGBA32 to format of front buffer is taken care of
void
HWInterface::_CopyToFront(uint8* src, uint32 srcBPR,
int32 x, int32 y,
int32 right, int32 bottom) const
HWInterface::_CopyToFront(uint8* src, uint32 srcBPR, int32 x, int32 y,
int32 right, int32 bottom) const
{
RenderingBuffer* frontBuffer = FrontBuffer();
@ -727,7 +735,7 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR,
case B_GRAY8:
if (frontBuffer->Width() > dstBPR) {
// VGA 16 color grayscale planar mode
if (fVGADevice > 0) {
if (fVGADevice >= 0) {
vga_planar_blit_args args;
args.source = src;
args.source_bytes_per_row = srcBPR;

View File

@ -125,10 +125,10 @@ class HWInterface : protected MultiLocker {
virtual status_t GetOverlayRestrictions(const Overlay* overlay,
overlay_restrictions* restrictions);
virtual bool CheckOverlayRestrictions(int32 width, int32 height,
color_space colorSpace);
virtual const overlay_buffer* AllocateOverlayBuffer(int32 width, int32 height,
color_space space);
virtual bool CheckOverlayRestrictions(int32 width,
int32 height, color_space colorSpace);
virtual const overlay_buffer* AllocateOverlayBuffer(int32 width,
int32 height, color_space space);
virtual void FreeOverlayBuffer(const overlay_buffer* buffer);
virtual void ConfigureOverlay(Overlay* overlay);
@ -146,6 +146,10 @@ class HWInterface : protected MultiLocker {
// while as CopyBackToFront() actually performs the operation
status_t CopyBackToFront(const BRect& frame);
protected:
virtual void CopyBackToFront(/*const*/ BRegion& region);
public:
// TODO: Just a quick and primitive way to get single buffered mode working.
// Later, the implementation should be smarter, right now, it will
// draw the cursor for almost every drawing operation.