From d3db964ed0075963d9ecbb708dc37a7f5ce649c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 29 Mar 2005 17:36:38 +0000 Subject: [PATCH] code refactoring, moved common stuff into the base class git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12129 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 11 +- .../app/drawing/AccelerantHWInterface.cpp | 216 +---------------- .../app/drawing/AccelerantHWInterface.h | 9 +- .../app/drawing/DisplayDriverPainter.cpp | 8 +- src/servers/app/drawing/HWInterface.cpp | 219 +++++++++++++++++- src/servers/app/drawing/HWInterface.h | 16 +- src/servers/app/drawing/ViewHWInterface.cpp | 212 +---------------- src/servers/app/drawing/ViewHWInterface.h | 13 +- 8 files changed, 256 insertions(+), 448 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index a64ddb31a5..d4a445d115 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -42,9 +42,11 @@ #include "Workspace.h" #include "AccelerantDriver.h" -#include "ViewDriver.h" -#include "DirectDriver.h" -#include "DisplayDriverPainter.h" +#ifndef __HAIKU__ + #include "ViewDriver.h" + #include "DirectDriver.h" + #include "DisplayDriverPainter.h" +#endif // __HAIKU__ //#define DEBUG_DESKTOP @@ -125,7 +127,8 @@ Desktop::AddDriver(DisplayDriver *driver) { if (driver->Initialize()) { // TODO: be careful of screen initialization - monitor may not support 640x480 - Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, fScreenList.CountItems()+1); +// Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, fScreenList.CountItems()+1); + Screen *sc = new Screen(driver, BPoint(1024, 768), B_RGB32, fScreenList.CountItems()+1); // Screen *sc = new Screen(driver, BPoint(640, 480), B_CMAP8, fScreenList.CountItems()+1); // Screen *sc = new Screen(driver, BPoint(640, 480), B_GRAY8, fScreenList.CountItems()+1); // Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB15, fScreenList.CountItems()+1); diff --git a/src/servers/app/drawing/AccelerantHWInterface.cpp b/src/servers/app/drawing/AccelerantHWInterface.cpp index ce1405ad98..95a012714d 100644 --- a/src/servers/app/drawing/AccelerantHWInterface.cpp +++ b/src/servers/app/drawing/AccelerantHWInterface.cpp @@ -94,17 +94,11 @@ AccelerantHWInterface::AccelerantHWInterface() fModeList(NULL), fBackBuffer(NULL), - fFrontBuffer(NULL), - fUpdateExecutor(new UpdateQueue(this)) + fFrontBuffer(new AccelerantBuffer()) { fDisplayMode.virtual_width = 640; fDisplayMode.virtual_height = 480; fDisplayMode.space = B_RGB32; - - fFrontBuffer = new AccelerantBuffer(); - - // TODO: isn't this supposed to be called form outside? - Initialize(); } // destructor @@ -522,62 +516,12 @@ AccelerantHWInterface::BackBuffer() const return fBackBuffer; } -// Invalidate -status_t -AccelerantHWInterface::Invalidate(const BRect& frame) -{ - return CopyBackToFront(frame);; - -// TODO: get this working, the locking in the DisplayDriverPainter needs -// to be based on locking this object, which essentially means the access -// to the back buffer is locked, or more precise the access to the invalid -// region scheduled to be copied to the front buffer - //fUpdateExecutor->AddRect(frame); - //return B_OK; -} - -// CopyBackToFront -status_t -AccelerantHWInterface::CopyBackToFront(const BRect &frame) -{ - if (!fBackBuffer || !fFrontBuffer) - return B_NO_INIT; - - // we need to mess with the area, but it is const - BRect area(frame); - - if (area.IsValid() && area.Intersects(fBackBuffer->Bitmap()->Bounds())) { - const BBitmap *from = fBackBuffer->Bitmap(); - - // make sure we don't copy out of bounds - area = from->Bounds() & area; - - uint32 src_bytes = fBackBuffer->BytesPerRow(); - uint8 *src_bits = (uint8 *)fBackBuffer->Bits(); - - // convert to integer coordinates - int32 x = (int32)floorf(area.left); - int32 y = (int32)floorf(area.top); - int32 right = (int32)ceilf(area.right); - int32 bottom = (int32)ceilf(area.bottom); - - // offset to left top pixel in source buffer (always B_RGBA32) - src_bits += y * src_bytes + x * 4; - - _CopyToFront(src_bits, src_bytes, x, y, right, bottom); - //_DrawCursor(area); - - // update the region on screen - //Invalidate(area); - } - - return B_OK; -} - // _DrawCursor void AccelerantHWInterface::_DrawCursor(BRect area) const { + return; +#if 0 BRect cf = _CursorFrame(); if (cf.IsValid() && area.Intersects(cf)) { // clip to common area @@ -639,161 +583,9 @@ AccelerantHWInterface::_DrawCursor(BRect area) const delete[] buffer; } +#endif } -// _CopyToFront -// -// * source is assumed to be already at the right offset -// * source is assumed to be in B_RGBA32 format -// * location in front buffer is calculated -// * conversion from B_RGBA32 to format of front buffer is taken care of -void -AccelerantHWInterface::_CopyToFront(uint8* src, uint32 srcBPR, - int32 x, int32 y, - int32 right, int32 bottom) const -{ - uint8* dst = (uint8*)fFrontBuffer->Bits(); - uint32 dstBPR = fFrontBuffer->BytesPerRow(); - - // transfer, handle colorspace conversion - switch (fFrontBuffer->ColorSpace()) { - case B_RGB32: - case B_RGBA32: { - int32 bytes = (right - x + 1) * 4; - - if (bytes > 0) { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 4; - // copy - for (; y <= bottom; y++) { - memcpy(dst, src, bytes); - dst += dstBPR; - src += srcBPR; - } - } - break; - } - // NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap() - case B_RGB24: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 3; - int32 left = x; - // copy - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint8* dstHandle = dst; - x = left; - for (; x <= right; x++) { - dstHandle[0] = srcHandle[0]; - dstHandle[1] = srcHandle[1]; - dstHandle[2] = srcHandle[2]; - dstHandle += 3; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_RGB16: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 2; - int32 left = x; - // copy - // TODO: assumes BGR order, does this work on big endian as well? - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint16* dstHandle = (uint16*)dst; - x = left; - for (; x <= right; x++) { - *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8) | - ((srcHandle[1] & 0xfc) << 3) | - (srcHandle[0] >> 3)); - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_RGB15: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 2; - int32 left = x; - // copy - // TODO: assumes BGR order, does this work on big endian as well? - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint16* dstHandle = (uint16*)dst; - x = left; - for (; x <= right; x++) { - *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7) | - ((srcHandle[1] & 0xf8) << 2) | - (srcHandle[0] >> 3)); - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_CMAP8: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x; - int32 left = x; - // copy - // TODO: using BScreen will not be an option in the - // final implementation, will it? The BBitmap implementation - // has a class that handles this, something so useful - // should be moved to a more public place. - // TODO: assumes BGR order again - BScreen screen; - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint8* dstHandle = dst; - x = left; - for (; x <= right; x++) { - *dstHandle = screen.IndexForColor(srcHandle[2], - srcHandle[1], - srcHandle[0]); - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_GRAY8: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x; - int32 left = x; - // copy - // TODO: assumes BGR order, does this work on big endian as well? - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint8* dstHandle = dst; - x = left; - for (; x <= right; x++) { - *dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1] + 116 * srcHandle[0]) / 1024; - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - default: - fprintf(stderr, "AccelerantHWInterface::CopyBackToFront() - unsupported front buffer format!\n"); - break; - } - -} - - /*void AccelerantHWInterface::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d) { if(!is_initialized || !bitmap || !d) diff --git a/src/servers/app/drawing/AccelerantHWInterface.h b/src/servers/app/drawing/AccelerantHWInterface.h index e13870a0f3..6478d3d8a9 100644 --- a/src/servers/app/drawing/AccelerantHWInterface.h +++ b/src/servers/app/drawing/AccelerantHWInterface.h @@ -53,8 +53,8 @@ virtual uint32 DPMSCapabilities() const; virtual RenderingBuffer *FrontBuffer() const; virtual RenderingBuffer *BackBuffer() const; -virtual status_t Invalidate(const BRect& frame); -virtual status_t CopyBackToFront(const BRect& area); +protected: +virtual void _DrawCursor(BRect area) const; private: int OpenGraphicsDevice(int deviceNumber); @@ -62,11 +62,6 @@ private: status_t UpdateModeList(); status_t UpdateFrameBufferConfig(); - void _DrawCursor(BRect area) const; - void _CopyToFront(uint8* src, uint32 srcBPR, - int32 x, int32 y, - int32 right, int32 bottom) const; - int fCardFD; image_id fAccelerantImage; GetAccelerantHook fAccelerantHook; diff --git a/src/servers/app/drawing/DisplayDriverPainter.cpp b/src/servers/app/drawing/DisplayDriverPainter.cpp index 58a1100a08..8e43716cf6 100644 --- a/src/servers/app/drawing/DisplayDriverPainter.cpp +++ b/src/servers/app/drawing/DisplayDriverPainter.cpp @@ -55,7 +55,13 @@ DisplayDriverPainter::~DisplayDriverPainter() bool DisplayDriverPainter::Initialize() { - return DisplayDriver::Initialize(); + if (DisplayDriver::Initialize()) { + status_t err = fGraphicsCard->Initialize(); + if (err < B_OK) + fprintf(stderr, "HWInterface::Initialize() failed: %s\n", strerror(err)); + return err >= B_OK; + } + return false; } // Shutdown diff --git a/src/servers/app/drawing/HWInterface.cpp b/src/servers/app/drawing/HWInterface.cpp index 0e9480522e..a9dbcff10a 100644 --- a/src/servers/app/drawing/HWInterface.cpp +++ b/src/servers/app/drawing/HWInterface.cpp @@ -1,6 +1,15 @@ // HWInterface.cpp +#include +#include + +#ifndef __HAIKU__ + #include +#endif + +#include "RenderingBuffer.h" #include "ServerCursor.h" +#include "UpdateQueue.h" #include "HWInterface.h" @@ -9,7 +18,8 @@ HWInterface::HWInterface() : BLocker("hw interface lock"), fCursor(NULL), fCursorVisible(true), - fCursorLocation(0.5, 0.5) + fCursorLocation(0.5, 0.5), + fUpdateExecutor(new UpdateQueue(this)) { } @@ -17,6 +27,7 @@ HWInterface::HWInterface() HWInterface::~HWInterface() { delete fCursor; + delete fUpdateExecutor; } // SetCursor @@ -88,6 +99,212 @@ HWInterface::GetCursorPosition() return location; } +// Invalidate +status_t +HWInterface::Invalidate(const BRect& frame) +{ + return CopyBackToFront(frame);; + +// TODO: get this working, the locking in the DisplayDriverPainter needs +// to be based on locking this object, which essentially means the access +// to the back buffer is locked, or more precise the access to the invalid +// region scheduled to be copied to the front buffer +// fUpdateExecutor->AddRect(frame); +// return B_OK; +} + +// CopyBackToFront +// * the object must already be locked! +status_t +HWInterface::CopyBackToFront(const BRect& frame) +{ + RenderingBuffer* frontBuffer = FrontBuffer(); + RenderingBuffer* backBuffer = BackBuffer(); + + if (!backBuffer || !frontBuffer) + return B_NO_INIT; + + // we need to mess with the area, but it is const + BRect area(frame); + BRect bufferClip(0.0, 0.0, backBuffer->Width() - 1, backBuffer->Height() - 1); + + if (area.IsValid() && area.Intersects(bufferClip)) { + + // make sure we don't copy out of bounds + area = bufferClip & area; + + uint32 srcBPR = backBuffer->BytesPerRow(); + uint8* src = (uint8*)backBuffer->Bits(); + + // convert to integer coordinates + int32 x = (int32)floorf(area.left); + int32 y = (int32)floorf(area.top); + int32 right = (int32)ceilf(area.right); + int32 bottom = (int32)ceilf(area.bottom); + + // offset to left top pixel in source buffer (always B_RGBA32) + src += y * srcBPR + x * 4; + + _CopyToFront(src, srcBPR, x, y, right, bottom); + + _DrawCursor(area); + } + + return B_OK; +} + + +// _CopyToFront +// +// * source is assumed to be already at the right offset +// * source is assumed to be in B_RGBA32 format +// * 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 +{ + RenderingBuffer* frontBuffer = FrontBuffer(); + + uint8* dst = (uint8*)frontBuffer->Bits(); + uint32 dstBPR = frontBuffer->BytesPerRow(); + + // transfer, handle colorspace conversion + switch (frontBuffer->ColorSpace()) { + case B_RGB32: + case B_RGBA32: { + int32 bytes = (right - x + 1) * 4; + + if (bytes > 0) { + // offset to left top pixel in dest buffer + dst += y * dstBPR + x * 4; + // copy + for (; y <= bottom; y++) { + memcpy(dst, src, bytes); + dst += dstBPR; + src += srcBPR; + } + } + break; + } + // NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap() + case B_RGB24: { + // offset to left top pixel in dest buffer + dst += y * dstBPR + x * 3; + int32 left = x; + // copy + for (; y <= bottom; y++) { + uint8* srcHandle = src; + uint8* dstHandle = dst; + for (x = left; x <= right; x++) { + dstHandle[0] = srcHandle[0]; + dstHandle[1] = srcHandle[1]; + dstHandle[2] = srcHandle[2]; + dstHandle += 3; + srcHandle += 4; + } + dst += dstBPR; + src += srcBPR; + } + break; + } + case B_RGB16: { + // offset to left top pixel in dest buffer + dst += y * dstBPR + x * 2; + int32 left = x; + // copy + // TODO: assumes BGR order, does this work on big endian as well? + for (; y <= bottom; y++) { + uint8* srcHandle = src; + uint16* dstHandle = (uint16*)dst; + for (x = left; x <= right; x++) { + *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8) | + ((srcHandle[1] & 0xfc) << 3) | + (srcHandle[0] >> 3)); + dstHandle ++; + srcHandle += 4; + } + dst += dstBPR; + src += srcBPR; + } + break; + } + case B_RGB15: { + // offset to left top pixel in dest buffer + dst += y * dstBPR + x * 2; + int32 left = x; + // copy + // TODO: assumes BGR order, does this work on big endian as well? + for (; y <= bottom; y++) { + uint8* srcHandle = src; + uint16* dstHandle = (uint16*)dst; + for (x = left; x <= right; x++) { + *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7) | + ((srcHandle[1] & 0xf8) << 2) | + (srcHandle[0] >> 3)); + dstHandle ++; + srcHandle += 4; + } + dst += dstBPR; + src += srcBPR; + } + break; + } + case B_CMAP8: { +#ifndef __HAIKU__ + // offset to left top pixel in dest buffer + dst += y * dstBPR + x; + int32 left = x; + // copy + // TODO: using BScreen will not be an option in the + // final implementation, will it? The BBitmap implementation + // has a class that handles this, something so useful + // should be moved to a more public place. + // TODO: assumes BGR order again + BScreen screen; + for (; y <= bottom; y++) { + uint8* srcHandle = src; + uint8* dstHandle = dst; + for (x = left; x <= right; x++) { + *dstHandle = screen.IndexForColor(srcHandle[2], + srcHandle[1], + srcHandle[0]); + dstHandle ++; + srcHandle += 4; + } + dst += dstBPR; + src += srcBPR; + } +#endif // __HAIKU__ + break; + } + case B_GRAY8: { + // offset to left top pixel in dest buffer + dst += y * dstBPR + x; + int32 left = x; + // copy + // TODO: assumes BGR order, does this work on big endian as well? + for (; y <= bottom; y++) { + uint8* srcHandle = src; + uint8* dstHandle = dst; + for (x = left; x <= right; x++) { + *dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1] + 116 * srcHandle[0]) / 1024; + dstHandle ++; + srcHandle += 4; + } + dst += dstBPR; + src += srcBPR; + } + break; + } + default: + fprintf(stderr, "ViewHWInterface::CopyBackToFront() - unsupported front buffer format!\n"); + break; + } +} + + // _CursorFrame // // PRE: the object must be locked diff --git a/src/servers/app/drawing/HWInterface.h b/src/servers/app/drawing/HWInterface.h index 1caf3a178a..b0168eca2c 100644 --- a/src/servers/app/drawing/HWInterface.h +++ b/src/servers/app/drawing/HWInterface.h @@ -17,6 +17,7 @@ class RenderingBuffer; class ServerCursor; +class UpdateQueue; class HWInterface : public BLocker { public: @@ -60,16 +61,27 @@ class HWInterface : public BLocker { virtual RenderingBuffer* BackBuffer() const = 0; // Invalidate is planned to be used for scheduling an area for updating - virtual status_t Invalidate(const BRect& frame) = 0; + status_t Invalidate(const BRect& frame); // while as CopyBackToFront() actually performs the operation - virtual status_t CopyBackToFront(const BRect& frame) = 0; + status_t CopyBackToFront(const BRect& frame); protected: + // implement this in derived classes + virtual void _DrawCursor(BRect area) const = 0; + + // does the actual transfer and handles color space conversion + void _CopyToFront(uint8* src, uint32 srcBPR, + int32 x, int32 y, + int32 right, int32 bottom) const; + BRect _CursorFrame() const; ServerCursor* fCursor; bool fCursorVisible; BPoint fCursorLocation; + + private: + UpdateQueue* fUpdateExecutor; }; #endif // HW_INTERFACE_H diff --git a/src/servers/app/drawing/ViewHWInterface.cpp b/src/servers/app/drawing/ViewHWInterface.cpp index e42f164033..762ed8f7ca 100644 --- a/src/servers/app/drawing/ViewHWInterface.cpp +++ b/src/servers/app/drawing/ViewHWInterface.cpp @@ -330,8 +330,7 @@ ViewHWInterface::ViewHWInterface() : HWInterface(), fBackBuffer(NULL), fFrontBuffer(NULL), - fWindow(NULL), - fUpdateExecutor(new UpdateQueue(this)) + fWindow(NULL) { fDisplayMode.virtual_width = 640; fDisplayMode.virtual_height = 480; @@ -596,64 +595,6 @@ ViewHWInterface::BackBuffer() const return fBackBuffer; } -// Invalidate -status_t -ViewHWInterface::Invalidate(const BRect& frame) -{ - return CopyBackToFront(frame);; - -// TODO: get this working, the locking in the DisplayDriverPainter needs -// to be based on locking this object, which essentially means the access -// to the back buffer is locked, or more precise the access to the invalid -// region scheduled to be copied to the front buffer -// fUpdateExecutor->AddRect(frame); -// return B_OK; -} - -// CopyBackToFront -status_t -ViewHWInterface::CopyBackToFront(const BRect& frame) -{ - if (!fBackBuffer || !fFrontBuffer) - return B_NO_INIT; - - // we need to mess with the area, but it is const - BRect area(frame); - - if (area.IsValid() && area.Intersects(fFrontBuffer->Bitmap()->Bounds())) { -// if we couldn't be sure the bitmaps had the same size: -// && area.Intersects(fBackBuffer->Bitmap()->Bounds())) { - - const BBitmap* from = fBackBuffer->Bitmap(); -// const BBitmap* into = fFrontBuffer->Bitmap(); - - // make sure we don't copy out of bounds - area = from->Bounds() & area; -// area = into->Bounds() & area; - - uint32 srcBPR = fBackBuffer->BytesPerRow(); - uint8* src = (uint8*)fBackBuffer->Bits(); - - // convert to integer coordinates - int32 x = (int32)floorf(area.left); - int32 y = (int32)floorf(area.top); - int32 right = (int32)ceilf(area.right); - int32 bottom = (int32)ceilf(area.bottom); - - // offset to left top pixel in source buffer (always B_RGBA32) - src += y * srcBPR + x * 4; - - _CopyToFront(src, srcBPR, x, y, right, bottom); - - _DrawCursor(area); - - // update the region on screen - fWindow->Invalidate(area); - } - - return B_OK; -} - // _DrawCursor void ViewHWInterface::_DrawCursor(BRect area) const @@ -721,157 +662,6 @@ ViewHWInterface::_DrawCursor(BRect area) const } } -// _CopyToFront -// -// * source is assumed to be already at the right offset -// * source is assumed to be in B_RGBA32 format -// * location in front buffer is calculated -// * conversion from B_RGBA32 to format of front buffer is taken care of -void -ViewHWInterface::_CopyToFront(uint8* src, uint32 srcBPR, - int32 x, int32 y, - int32 right, int32 bottom) const -{ - uint8* dst = (uint8*)fFrontBuffer->Bits(); - uint32 dstBPR = fFrontBuffer->BytesPerRow(); - - // transfer, handle colorspace conversion - switch (fFrontBuffer->ColorSpace()) { - case B_RGB32: - case B_RGBA32: { - int32 bytes = (right - x + 1) * 4; - - if (bytes > 0) { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 4; - // copy - for (; y <= bottom; y++) { - memcpy(dst, src, bytes); - dst += dstBPR; - src += srcBPR; - } - } - break; - } - // NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap() - case B_RGB24: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 3; - int32 left = x; - // copy - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint8* dstHandle = dst; - x = left; - for (; x <= right; x++) { - dstHandle[0] = srcHandle[0]; - dstHandle[1] = srcHandle[1]; - dstHandle[2] = srcHandle[2]; - dstHandle += 3; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_RGB16: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 2; - int32 left = x; - // copy - // TODO: assumes BGR order, does this work on big endian as well? - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint16* dstHandle = (uint16*)dst; - x = left; - for (; x <= right; x++) { - *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 8) | - ((srcHandle[1] & 0xfc) << 3) | - (srcHandle[0] >> 3)); - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_RGB15: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x * 2; - int32 left = x; - // copy - // TODO: assumes BGR order, does this work on big endian as well? - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint16* dstHandle = (uint16*)dst; - x = left; - for (; x <= right; x++) { - *dstHandle = (uint16)(((srcHandle[2] & 0xf8) << 7) | - ((srcHandle[1] & 0xf8) << 2) | - (srcHandle[0] >> 3)); - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_CMAP8: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x; - int32 left = x; - // copy - // TODO: using BScreen will not be an option in the - // final implementation, will it? The BBitmap implementation - // has a class that handles this, something so useful - // should be moved to a more public place. - // TODO: assumes BGR order again - BScreen screen; - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint8* dstHandle = dst; - x = left; - for (; x <= right; x++) { - *dstHandle = screen.IndexForColor(srcHandle[2], - srcHandle[1], - srcHandle[0]); - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - case B_GRAY8: { - // offset to left top pixel in dest buffer - dst += y * dstBPR + x; - int32 left = x; - // copy - // TODO: assumes BGR order, does this work on big endian as well? - for (; y <= bottom; y++) { - uint8* srcHandle = src; - uint8* dstHandle = dst; - x = left; - for (; x <= right; x++) { - *dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1] + 116 * srcHandle[0]) / 1024; - dstHandle ++; - srcHandle += 4; - } - dst += dstBPR; - src += srcBPR; - } - break; - } - default: - fprintf(stderr, "ViewHWInterface::CopyBackToFront() - unsupported front buffer format!\n"); - break; - } - -} /*void ViewHWInterface::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d) diff --git a/src/servers/app/drawing/ViewHWInterface.h b/src/servers/app/drawing/ViewHWInterface.h index 728e238e81..4713aa8813 100644 --- a/src/servers/app/drawing/ViewHWInterface.h +++ b/src/servers/app/drawing/ViewHWInterface.h @@ -53,23 +53,16 @@ class ViewHWInterface : public HWInterface { virtual RenderingBuffer* FrontBuffer() const; virtual RenderingBuffer* BackBuffer() const; - virtual status_t Invalidate(const BRect& frame); - virtual status_t CopyBackToFront(const BRect& area); - -private: - void _DrawCursor(BRect area) const; - void _CopyToFront(uint8* src, uint32 srcBPR, - int32 x, int32 y, - int32 right, int32 bottom) const; + protected: + virtual void _DrawCursor(BRect area) const; + private: BitmapBuffer* fBackBuffer; BitmapBuffer* fFrontBuffer; CardWindow* fWindow; display_mode fDisplayMode; - - UpdateQueue* fUpdateExecutor; }; #endif // VIEW_GRAPHICS_CARD_H