implemented cursor support in the DisplayDriverPainter
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12107 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
31f3fbc45c
commit
e33b90ea35
@ -38,8 +38,7 @@
|
|||||||
\brief Sets up internal variables needed by all DisplayDriver subclasses
|
\brief Sets up internal variables needed by all DisplayDriver subclasses
|
||||||
*/
|
*/
|
||||||
DisplayDriver::DisplayDriver()
|
DisplayDriver::DisplayDriver()
|
||||||
: fCursorHandler(this),
|
: fDPMSState(B_DPMS_ON),
|
||||||
fDPMSState(B_DPMS_ON),
|
|
||||||
fDPMSCaps(B_DPMS_ON)
|
fDPMSCaps(B_DPMS_ON)
|
||||||
{
|
{
|
||||||
fDisplayMode.virtual_width = 640;
|
fDisplayMode.virtual_width = 640;
|
||||||
@ -68,7 +67,7 @@ DisplayDriver::~DisplayDriver()
|
|||||||
bool
|
bool
|
||||||
DisplayDriver::Initialize()
|
DisplayDriver::Initialize()
|
||||||
{
|
{
|
||||||
fCursorHandler.SetCursor(new ServerCursor(default_cursor_data));
|
SetCursor(new ServerCursor(default_cursor_data));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,127 +82,6 @@ DisplayDriver::Shutdown()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Hides the cursor.
|
|
||||||
|
|
||||||
Hide calls are not nestable, unlike that of the BApplication class. Subclasses should
|
|
||||||
call _SetCursorHidden(true) somewhere within this function to ensure that data is
|
|
||||||
maintained accurately. Subclasses must include a call to DisplayDriver::HideCursor
|
|
||||||
for proper state tracking.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
DisplayDriver::HideCursor()
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
fCursorHandler.Hide();
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether the cursor is visible or not.
|
|
||||||
\return true if hidden or obscured, false if not.
|
|
||||||
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
DisplayDriver::IsCursorHidden()
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
bool value = fCursorHandler.IsHidden();
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Moves the cursor to the given point.
|
|
||||||
|
|
||||||
The coordinates passed to MoveCursorTo are guaranteed to be within the frame buffer's
|
|
||||||
range, but the cursor data itself will need to be clipped. A check to see if the
|
|
||||||
cursor is obscured should be made and if so, a call to _SetCursorObscured(false)
|
|
||||||
should be made the cursor in addition to displaying at the passed coordinates.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
DisplayDriver::MoveCursorTo(const float &x, const float &y)
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
fCursorHandler.MoveTo(BPoint(x, y));
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Shows the cursor.
|
|
||||||
|
|
||||||
Show calls are not nestable, unlike that of the BApplication class. Subclasses should
|
|
||||||
call _SetCursorHidden(false) somewhere within this function to ensure that data is
|
|
||||||
maintained accurately. Subclasses must call DisplayDriver::ShowCursor at some point
|
|
||||||
to ensure proper state tracking.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
DisplayDriver::ShowCursor()
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
fCursorHandler.Show();
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Obscures the cursor.
|
|
||||||
|
|
||||||
Obscure calls are not nestable. Subclasses should call DisplayDriver::ObscureCursor
|
|
||||||
somewhere within this function to ensure that data is maintained accurately. A check
|
|
||||||
will be made by the system before the next MoveCursorTo call to show the cursor if
|
|
||||||
it is obscured.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
DisplayDriver::ObscureCursor()
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
fCursorHandler.Obscure();
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Changes the cursor.
|
|
||||||
\param cursor The new cursor. Guaranteed to be non-NULL.
|
|
||||||
|
|
||||||
The driver does not take ownership of the given cursor. Subclasses should make
|
|
||||||
a copy of the cursor passed to it. The default version of this function hides the
|
|
||||||
cursory, replaces it, and shows the cursor if previously visible.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
DisplayDriver::SetCursor(ServerCursor *cursor)
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
fCursorHandler.SetCursor(cursor);
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns the cursor's current position
|
|
||||||
BPoint
|
|
||||||
DisplayDriver::GetCursorPosition()
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
BPoint pos = fCursorHandler.GetPosition();
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns whether or not the cursor is currently obscured
|
|
||||||
\return True if obscured, false if not.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
DisplayDriver::IsCursorObscured(bool state)
|
|
||||||
{
|
|
||||||
Lock();
|
|
||||||
bool obscured = fCursorHandler.IsObscured();
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
return obscured;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Protected Internal Functions
|
// Protected Internal Functions
|
||||||
/*
|
/*
|
||||||
\brief Sets the screen mode to specified resolution and color depth.
|
\brief Sets the screen mode to specified resolution and color depth.
|
||||||
|
@ -51,7 +51,8 @@ static Blitter blitter;
|
|||||||
*/
|
*/
|
||||||
DisplayDriverImpl::DisplayDriverImpl()
|
DisplayDriverImpl::DisplayDriverImpl()
|
||||||
: DisplayDriver(),
|
: DisplayDriver(),
|
||||||
fLocker("DisplayDriver lock")
|
fLocker("DisplayDriver lock"),
|
||||||
|
fCursorHandler(this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2272,6 +2273,127 @@ void DisplayDriverImpl::GetTruncatedStrings(const char **instrings,const int32 &
|
|||||||
// TODO: Implement DisplayDriverImpl::GetTruncatedStrings
|
// TODO: Implement DisplayDriverImpl::GetTruncatedStrings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Hides the cursor.
|
||||||
|
|
||||||
|
Hide calls are not nestable, unlike that of the BApplication class. Subclasses should
|
||||||
|
call _SetCursorHidden(true) somewhere within this function to ensure that data is
|
||||||
|
maintained accurately. Subclasses must include a call to DisplayDriver::HideCursor
|
||||||
|
for proper state tracking.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
DisplayDriverImpl::HideCursor()
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
fCursorHandler.Hide();
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Returns whether the cursor is visible or not.
|
||||||
|
\return true if hidden or obscured, false if not.
|
||||||
|
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
DisplayDriverImpl::IsCursorHidden()
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
bool value = fCursorHandler.IsHidden();
|
||||||
|
Unlock();
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Moves the cursor to the given point.
|
||||||
|
|
||||||
|
The coordinates passed to MoveCursorTo are guaranteed to be within the frame buffer's
|
||||||
|
range, but the cursor data itself will need to be clipped. A check to see if the
|
||||||
|
cursor is obscured should be made and if so, a call to _SetCursorObscured(false)
|
||||||
|
should be made the cursor in addition to displaying at the passed coordinates.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
DisplayDriverImpl::MoveCursorTo(const float &x, const float &y)
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
fCursorHandler.MoveTo(BPoint(x, y));
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Shows the cursor.
|
||||||
|
|
||||||
|
Show calls are not nestable, unlike that of the BApplication class. Subclasses should
|
||||||
|
call _SetCursorHidden(false) somewhere within this function to ensure that data is
|
||||||
|
maintained accurately. Subclasses must call DisplayDriver::ShowCursor at some point
|
||||||
|
to ensure proper state tracking.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
DisplayDriverImpl::ShowCursor()
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
fCursorHandler.Show();
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Obscures the cursor.
|
||||||
|
|
||||||
|
Obscure calls are not nestable. Subclasses should call DisplayDriver::ObscureCursor
|
||||||
|
somewhere within this function to ensure that data is maintained accurately. A check
|
||||||
|
will be made by the system before the next MoveCursorTo call to show the cursor if
|
||||||
|
it is obscured.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
DisplayDriverImpl::ObscureCursor()
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
fCursorHandler.Obscure();
|
||||||
|
Unlock();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Changes the cursor.
|
||||||
|
\param cursor The new cursor. Guaranteed to be non-NULL.
|
||||||
|
|
||||||
|
The driver does not take ownership of the given cursor. Subclasses should make
|
||||||
|
a copy of the cursor passed to it. The default version of this function hides the
|
||||||
|
cursory, replaces it, and shows the cursor if previously visible.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
DisplayDriverImpl::SetCursor(ServerCursor *cursor)
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
fCursorHandler.SetCursor(cursor);
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns the cursor's current position
|
||||||
|
BPoint
|
||||||
|
DisplayDriverImpl::GetCursorPosition()
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
BPoint pos = fCursorHandler.GetPosition();
|
||||||
|
Unlock();
|
||||||
|
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Returns whether or not the cursor is currently obscured
|
||||||
|
\return True if obscured, false if not.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
DisplayDriverImpl::IsCursorObscured(bool state)
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
bool obscured = fCursorHandler.IsObscured();
|
||||||
|
Unlock();
|
||||||
|
|
||||||
|
return obscured;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Locks the driver
|
\brief Locks the driver
|
||||||
\param timeout Optional timeout specifier
|
\param timeout Optional timeout specifier
|
||||||
|
@ -128,7 +128,7 @@ DisplayDriverPainter::CopyRegionList(BList* list, BList* pList,
|
|||||||
if (!clipReg || !Lock())
|
if (!clipReg || !Lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// This is the same implementation as in DisplayDriverImpl for now
|
// This is the same implementation as in DisplayDriverPainter for now
|
||||||
|
|
||||||
// since we're not using painter.... this won't do much good, will it?
|
// since we're not using painter.... this won't do much good, will it?
|
||||||
// fPainter->ConstrainClipping(*clipReg);
|
// fPainter->ConstrainClipping(*clipReg);
|
||||||
@ -755,6 +755,65 @@ DisplayDriverPainter::GetTruncatedStrings(const char **instrings,
|
|||||||
printf("DisplayDriverPainter::GetTruncatedStrings()\n");
|
printf("DisplayDriverPainter::GetTruncatedStrings()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HideCursor
|
||||||
|
void
|
||||||
|
DisplayDriverPainter::HideCursor()
|
||||||
|
{
|
||||||
|
fGraphicsCard->SetCursorVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCursorHidden
|
||||||
|
bool
|
||||||
|
DisplayDriverPainter::IsCursorHidden()
|
||||||
|
{
|
||||||
|
return !fGraphicsCard->IsCursorVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoveCursorTo
|
||||||
|
void
|
||||||
|
DisplayDriverPainter::MoveCursorTo(const float &x, const float &y)
|
||||||
|
{
|
||||||
|
fGraphicsCard->MoveCursorTo(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShowCursor
|
||||||
|
void
|
||||||
|
DisplayDriverPainter::ShowCursor()
|
||||||
|
{
|
||||||
|
fGraphicsCard->SetCursorVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObscureCursor
|
||||||
|
void
|
||||||
|
DisplayDriverPainter::ObscureCursor()
|
||||||
|
{
|
||||||
|
// TODO: I don't think this has anything to do with the DisplayDriver
|
||||||
|
// implement elsewhere!!
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCursor
|
||||||
|
void
|
||||||
|
DisplayDriverPainter::SetCursor(ServerCursor *cursor)
|
||||||
|
{
|
||||||
|
fGraphicsCard->SetCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCursorPosition
|
||||||
|
BPoint
|
||||||
|
DisplayDriverPainter::GetCursorPosition()
|
||||||
|
{
|
||||||
|
return fGraphicsCard->GetCursorPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCursorObscured
|
||||||
|
bool
|
||||||
|
DisplayDriverPainter::IsCursorObscured(bool state)
|
||||||
|
{
|
||||||
|
// TODO: I don't think this has anything to do with the DisplayDriver
|
||||||
|
// implement elsewhere!!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Lock
|
// Lock
|
||||||
bool
|
bool
|
||||||
DisplayDriverPainter::Lock(bigtime_t timeout)
|
DisplayDriverPainter::Lock(bigtime_t timeout)
|
||||||
|
@ -217,10 +217,8 @@ class DisplayDriverPainter : public DisplayDriver {
|
|||||||
const float &maxwidth,
|
const float &maxwidth,
|
||||||
char **outstrings);
|
char **outstrings);
|
||||||
|
|
||||||
virtual bool Lock(bigtime_t timeout = B_INFINITE_TIMEOUT);
|
// cursor handling
|
||||||
virtual void Unlock();
|
virtual void HideCursor();
|
||||||
|
|
||||||
/* virtual void HideCursor();
|
|
||||||
virtual bool IsCursorHidden();
|
virtual bool IsCursorHidden();
|
||||||
virtual void MoveCursorTo( const float &x,
|
virtual void MoveCursorTo( const float &x,
|
||||||
const float &y);
|
const float &y);
|
||||||
@ -228,9 +226,12 @@ class DisplayDriverPainter : public DisplayDriver {
|
|||||||
virtual void ObscureCursor();
|
virtual void ObscureCursor();
|
||||||
virtual void SetCursor(ServerCursor *cursor);
|
virtual void SetCursor(ServerCursor *cursor);
|
||||||
BPoint GetCursorPosition();
|
BPoint GetCursorPosition();
|
||||||
virtual bool IsCursorObscured(bool state);*/
|
virtual bool IsCursorObscured(bool state);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool Lock(bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||||
|
virtual void Unlock();
|
||||||
|
|
||||||
// display mode access
|
// display mode access
|
||||||
virtual void SetMode(const display_mode &mode);
|
virtual void SetMode(const display_mode &mode);
|
||||||
|
|
||||||
|
@ -1,14 +1,106 @@
|
|||||||
// HWInterface.cpp
|
// HWInterface.cpp
|
||||||
|
|
||||||
|
#include "ServerCursor.h"
|
||||||
|
|
||||||
#include "HWInterface.h"
|
#include "HWInterface.h"
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
HWInterface::HWInterface()
|
HWInterface::HWInterface()
|
||||||
: BLocker("hw interface lock")
|
: BLocker("hw interface lock"),
|
||||||
|
fCursor(NULL),
|
||||||
|
fCursorVisible(true),
|
||||||
|
fCursorLocation(0.5, 0.5)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
HWInterface::~HWInterface()
|
HWInterface::~HWInterface()
|
||||||
{
|
{
|
||||||
|
delete fCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetCursor
|
||||||
|
void
|
||||||
|
HWInterface::SetCursor(ServerCursor* cursor)
|
||||||
|
{
|
||||||
|
if (Lock()) {
|
||||||
|
if (fCursor != cursor) {
|
||||||
|
BRect oldFrame = _CursorFrame();
|
||||||
|
delete fCursor;
|
||||||
|
fCursor = cursor;
|
||||||
|
Invalidate(oldFrame);
|
||||||
|
Invalidate(_CursorFrame());
|
||||||
|
}
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCursorVisible
|
||||||
|
void
|
||||||
|
HWInterface::SetCursorVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (Lock()) {
|
||||||
|
if (fCursorVisible != visible) {
|
||||||
|
fCursorVisible = visible;
|
||||||
|
Invalidate(_CursorFrame());
|
||||||
|
}
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCursorVisible
|
||||||
|
bool
|
||||||
|
HWInterface::IsCursorVisible()
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
if (Lock()) {
|
||||||
|
visible = fCursorVisible;
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoveCursorTo
|
||||||
|
void
|
||||||
|
HWInterface::MoveCursorTo(const float& x, const float& y)
|
||||||
|
{
|
||||||
|
if (Lock()) {
|
||||||
|
BPoint p(x, y);
|
||||||
|
if (p != fCursorLocation) {
|
||||||
|
BRect oldFrame = _CursorFrame();
|
||||||
|
fCursorLocation = p;
|
||||||
|
Invalidate(oldFrame);
|
||||||
|
Invalidate(_CursorFrame());
|
||||||
|
}
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCursorPosition
|
||||||
|
BPoint
|
||||||
|
HWInterface::GetCursorPosition()
|
||||||
|
{
|
||||||
|
BPoint location;
|
||||||
|
if (Lock()) {
|
||||||
|
location = fCursorLocation;
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
// _CursorFrame
|
||||||
|
//
|
||||||
|
// PRE: the object must be locked
|
||||||
|
BRect
|
||||||
|
HWInterface::_CursorFrame() const
|
||||||
|
{
|
||||||
|
BRect frame(0.0, 0.0, -1.0, -1.0);
|
||||||
|
if (fCursor && fCursorVisible) {
|
||||||
|
frame = fCursor->Bounds();
|
||||||
|
frame.OffsetTo(fCursorLocation - fCursor->GetHotSpot());
|
||||||
|
}
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
#include <GraphicsCard.h>
|
#include <GraphicsCard.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
|
||||||
class RenderingBuffer;
|
class RenderingBuffer;
|
||||||
class BRect;
|
class ServerCursor;
|
||||||
|
|
||||||
class HWInterface : public BLocker {
|
class HWInterface : public BLocker {
|
||||||
public:
|
public:
|
||||||
@ -25,10 +26,10 @@ class HWInterface : public BLocker {
|
|||||||
virtual status_t Initialize() = 0;
|
virtual status_t Initialize() = 0;
|
||||||
virtual status_t Shutdown() = 0;
|
virtual status_t Shutdown() = 0;
|
||||||
|
|
||||||
|
// screen mode stuff
|
||||||
virtual status_t SetMode(const display_mode &mode) = 0;
|
virtual status_t SetMode(const display_mode &mode) = 0;
|
||||||
// virtual void GetMode(display_mode *mode) = 0;
|
// virtual void GetMode(display_mode *mode) = 0;
|
||||||
|
|
||||||
|
|
||||||
virtual status_t GetDeviceInfo(accelerant_device_info *info) = 0;
|
virtual status_t GetDeviceInfo(accelerant_device_info *info) = 0;
|
||||||
virtual status_t GetModeList(display_mode **mode_list,
|
virtual status_t GetModeList(display_mode **mode_list,
|
||||||
uint32 *count) = 0;
|
uint32 *count) = 0;
|
||||||
@ -46,6 +47,14 @@ class HWInterface : public BLocker {
|
|||||||
virtual uint32 DPMSMode() const = 0;
|
virtual uint32 DPMSMode() const = 0;
|
||||||
virtual uint32 DPMSCapabilities() const = 0;
|
virtual uint32 DPMSCapabilities() const = 0;
|
||||||
|
|
||||||
|
// cursor handling
|
||||||
|
virtual void SetCursor(ServerCursor* cursor);
|
||||||
|
virtual void SetCursorVisible(bool visible);
|
||||||
|
virtual bool IsCursorVisible();
|
||||||
|
virtual void MoveCursorTo(const float& x,
|
||||||
|
const float& y);
|
||||||
|
BPoint GetCursorPosition();
|
||||||
|
|
||||||
// frame buffer access
|
// frame buffer access
|
||||||
virtual RenderingBuffer* FrontBuffer() const = 0;
|
virtual RenderingBuffer* FrontBuffer() const = 0;
|
||||||
virtual RenderingBuffer* BackBuffer() const = 0;
|
virtual RenderingBuffer* BackBuffer() const = 0;
|
||||||
@ -54,6 +63,13 @@ class HWInterface : public BLocker {
|
|||||||
virtual status_t Invalidate(const BRect& frame) = 0;
|
virtual status_t Invalidate(const BRect& frame) = 0;
|
||||||
// while as CopyBackToFront() actually performs the operation
|
// while as CopyBackToFront() actually performs the operation
|
||||||
virtual status_t CopyBackToFront(const BRect& frame) = 0;
|
virtual status_t CopyBackToFront(const BRect& frame) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BRect _CursorFrame() const;
|
||||||
|
|
||||||
|
ServerCursor* fCursor;
|
||||||
|
bool fCursorVisible;
|
||||||
|
BPoint fCursorLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HW_INTERFACE_H
|
#endif // HW_INTERFACE_H
|
||||||
|
@ -150,7 +150,7 @@ Painter::SetDrawData(const DrawData* data)
|
|||||||
SetLowColor(data->lowcolor.GetColor32());
|
SetLowColor(data->lowcolor.GetColor32());
|
||||||
SetScale(data->scale);
|
SetScale(data->scale);
|
||||||
SetPenSize(data->pensize);
|
SetPenSize(data->pensize);
|
||||||
// SetOrigin();
|
// fOrigin = data->coordOrigin;
|
||||||
SetDrawingMode(data->draw_mode);
|
SetDrawingMode(data->draw_mode);
|
||||||
SetBlendingMode(data->alphaSrcMode, data->alphaFncMode);
|
SetBlendingMode(data->alphaSrcMode, data->alphaFncMode);
|
||||||
SetPenLocation(data->penlocation);
|
SetPenLocation(data->penlocation);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "BitmapBuffer.h"
|
#include "BitmapBuffer.h"
|
||||||
#include "PortLink.h"
|
#include "PortLink.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
|
#include "ServerCursor.h"
|
||||||
#include "ServerProtocol.h"
|
#include "ServerProtocol.h"
|
||||||
#include "UpdateQueue.h"
|
#include "UpdateQueue.h"
|
||||||
|
|
||||||
@ -112,12 +113,6 @@ class CardView : public BView {
|
|||||||
private:
|
private:
|
||||||
BPortLink* fServerLink;
|
BPortLink* fServerLink;
|
||||||
const BBitmap* fBitmap;
|
const BBitmap* fBitmap;
|
||||||
|
|
||||||
/* int hide_cursor;
|
|
||||||
BBitmap *cursor;
|
|
||||||
|
|
||||||
BRect cursorframe, oldcursorframe;
|
|
||||||
bool obscure_cursor;*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CardWindow : public BWindow {
|
class CardWindow : public BWindow {
|
||||||
@ -157,31 +152,11 @@ CardView::CardView(BRect bounds)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fServerLink = new BPortLink(serverInputPort);
|
fServerLink = new BPortLink(serverInputPort);
|
||||||
|
|
||||||
// Create a cursor which isn't just a box
|
|
||||||
/* cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true);
|
|
||||||
BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW);
|
|
||||||
hide_cursor=0;
|
|
||||||
|
|
||||||
cursor->Lock();
|
|
||||||
cursor->AddChild(v);
|
|
||||||
|
|
||||||
v->SetHighColor(255,255,255,0);
|
|
||||||
v->FillRect(cursor->Bounds());
|
|
||||||
v->SetHighColor(255,0,0,255);
|
|
||||||
v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom());
|
|
||||||
|
|
||||||
cursor->RemoveChild(v);
|
|
||||||
cursor->Unlock();
|
|
||||||
|
|
||||||
cursorframe=cursor->Bounds();
|
|
||||||
oldcursorframe=cursor->Bounds();*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CardView::~CardView()
|
CardView::~CardView()
|
||||||
{
|
{
|
||||||
delete fServerLink;
|
delete fServerLink;
|
||||||
/* delete cursor;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AttachedToWindow
|
// AttachedToWindow
|
||||||
@ -197,16 +172,6 @@ CardView::Draw(BRect updateRect)
|
|||||||
if (fBitmap) {
|
if (fBitmap) {
|
||||||
DrawBitmapAsync(fBitmap, updateRect, updateRect);
|
DrawBitmapAsync(fBitmap, updateRect, updateRect);
|
||||||
}
|
}
|
||||||
/* if (viewbmp) {
|
|
||||||
DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe);
|
|
||||||
DrawBitmapAsync(viewbmp,rect,rect);
|
|
||||||
|
|
||||||
if (hide_cursor == 0 && obscure_cursor == false) {
|
|
||||||
SetDrawingMode(B_OP_ALPHA);
|
|
||||||
DrawBitmapAsync(cursor,cursor->Bounds(), cursorframe);
|
|
||||||
SetDrawingMode(B_OP_COPY);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These functions emulate the Input Server by sending the *exact* same kind of messages
|
// These functions emulate the Input Server by sending the *exact* same kind of messages
|
||||||
@ -228,12 +193,11 @@ CardView::MouseMoved(BPoint pt, uint32 transit, const BMessage* dragMessage)
|
|||||||
{
|
{
|
||||||
if (!Bounds().Contains(pt))
|
if (!Bounds().Contains(pt))
|
||||||
return;
|
return;
|
||||||
// TODO: no cursor support yet
|
|
||||||
|
|
||||||
// A bug in R5 prevents this call from having an effect if
|
// A bug in R5 prevents this call from having an effect if
|
||||||
// called elsewhere, and calling it here works, if we're lucky :-)
|
// called elsewhere, and calling it here works, if we're lucky :-)
|
||||||
// BCursor cursor(kEmptyCursor);
|
BCursor cursor(kEmptyCursor);
|
||||||
// SetViewCursor(&cursor, true);
|
SetViewCursor(&cursor, true);
|
||||||
|
|
||||||
#ifdef ENABLE_INPUT_SERVER_EMULATION
|
#ifdef ENABLE_INPUT_SERVER_EMULATION
|
||||||
send_mouse_moved(fServerLink, pt, Window()->CurrentMessage());
|
send_mouse_moved(fServerLink, pt, Window()->CurrentMessage());
|
||||||
@ -420,9 +384,6 @@ ViewHWInterface::SetMode(const display_mode &mode)
|
|||||||
|
|
||||||
printf("ViewHWInterface::SetMode(%s)\n", string_for_color_space((color_space)fDisplayMode.space));
|
printf("ViewHWInterface::SetMode(%s)\n", string_for_color_space((color_space)fDisplayMode.space));
|
||||||
|
|
||||||
// left over code
|
|
||||||
// hide_cursor=0;
|
|
||||||
|
|
||||||
BRect frame(0.0, 0.0,
|
BRect frame(0.0, 0.0,
|
||||||
fDisplayMode.virtual_width - 1,
|
fDisplayMode.virtual_width - 1,
|
||||||
fDisplayMode.virtual_height - 1);
|
fDisplayMode.virtual_height - 1);
|
||||||
@ -494,9 +455,6 @@ printf("ViewHWInterface::SetMode(%s)\n", string_for_color_space((color_space)fDi
|
|||||||
status_t
|
status_t
|
||||||
ViewHWInterface::GetDeviceInfo(accelerant_device_info *info)
|
ViewHWInterface::GetDeviceInfo(accelerant_device_info *info)
|
||||||
{
|
{
|
||||||
// if(!info || !is_initialized)
|
|
||||||
// return B_ERROR;
|
|
||||||
|
|
||||||
// We really don't have to provide anything here because this is strictly
|
// We really don't have to provide anything here because this is strictly
|
||||||
// a software-only driver, but we'll have some fun, anyway.
|
// a software-only driver, but we'll have some fun, anyway.
|
||||||
|
|
||||||
@ -514,11 +472,6 @@ ViewHWInterface::GetDeviceInfo(accelerant_device_info *info)
|
|||||||
status_t
|
status_t
|
||||||
ViewHWInterface::GetModeList(display_mode **modes, uint32 *count)
|
ViewHWInterface::GetModeList(display_mode **modes, uint32 *count)
|
||||||
{
|
{
|
||||||
// if(!count || !is_initialized)
|
|
||||||
// return B_ERROR;
|
|
||||||
|
|
||||||
// screenwin->Lock();
|
|
||||||
|
|
||||||
// DEPRECATED:
|
// DEPRECATED:
|
||||||
// NOTE: Originally, I was going to figure out good timing values to be
|
// NOTE: Originally, I was going to figure out good timing values to be
|
||||||
// returned in each of the modes supported, but I won't bother, being this
|
// returned in each of the modes supported, but I won't bother, being this
|
||||||
@ -576,7 +529,6 @@ ViewHWInterface::GetModeList(display_mode **modes, uint32 *count)
|
|||||||
modes[i]->v_display_start=0;
|
modes[i]->v_display_start=0;
|
||||||
modes[i]->flags=B_PARALLEL_ACCESS;
|
modes[i]->flags=B_PARALLEL_ACCESS;
|
||||||
}
|
}
|
||||||
// screenwin->Unlock();
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -675,16 +627,14 @@ ViewHWInterface::CopyBackToFront(const BRect& frame)
|
|||||||
// && area.Intersects(fBackBuffer->Bitmap()->Bounds())) {
|
// && area.Intersects(fBackBuffer->Bitmap()->Bounds())) {
|
||||||
|
|
||||||
const BBitmap* from = fBackBuffer->Bitmap();
|
const BBitmap* from = fBackBuffer->Bitmap();
|
||||||
const BBitmap* into = fFrontBuffer->Bitmap();
|
// const BBitmap* into = fFrontBuffer->Bitmap();
|
||||||
|
|
||||||
// make sure we don't copy out of bounds
|
// make sure we don't copy out of bounds
|
||||||
area = from->Bounds() & area;
|
area = from->Bounds() & area;
|
||||||
// area = into->Bounds() & area;
|
// area = into->Bounds() & area;
|
||||||
|
|
||||||
uint32 srcBPR = from->BytesPerRow();
|
uint32 srcBPR = fBackBuffer->BytesPerRow();
|
||||||
uint32 dstBPR = into->BytesPerRow();
|
uint8* src = (uint8*)fBackBuffer->Bits();
|
||||||
uint8* dst = (uint8*)into->Bits();
|
|
||||||
uint8* src = (uint8*)from->Bits();
|
|
||||||
|
|
||||||
// convert to integer coordinates
|
// convert to integer coordinates
|
||||||
int32 x = (int32)floorf(area.left);
|
int32 x = (int32)floorf(area.left);
|
||||||
@ -695,141 +645,9 @@ ViewHWInterface::CopyBackToFront(const BRect& frame)
|
|||||||
// offset to left top pixel in source buffer (always B_RGBA32)
|
// offset to left top pixel in source buffer (always B_RGBA32)
|
||||||
src += y * srcBPR + x * 4;
|
src += y * srcBPR + x * 4;
|
||||||
|
|
||||||
// transfer, handle colorspace conversion
|
_CopyToFront(src, srcBPR, x, y, right, bottom);
|
||||||
switch (into->ColorSpace()) {
|
|
||||||
case B_RGB32:
|
|
||||||
case B_RGBA32: {
|
|
||||||
int32 bytes = (right - x + 1) * 4;
|
|
||||||
|
|
||||||
if (bytes > 0) {
|
_DrawCursor(area);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the region on screen
|
// update the region on screen
|
||||||
fWindow->Invalidate(area);
|
fWindow->Invalidate(area);
|
||||||
@ -838,6 +656,225 @@ ViewHWInterface::CopyBackToFront(const BRect& frame)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _DrawCursor
|
||||||
|
void
|
||||||
|
ViewHWInterface::_DrawCursor(BRect area) const
|
||||||
|
{
|
||||||
|
BRect cf = _CursorFrame();
|
||||||
|
if (cf.IsValid() && area.Intersects(cf)) {
|
||||||
|
// clip to common area
|
||||||
|
area = area & cf;
|
||||||
|
|
||||||
|
int32 left = (int32)floorf(area.left);
|
||||||
|
int32 top = (int32)floorf(area.top);
|
||||||
|
int32 right = (int32)ceilf(area.right);
|
||||||
|
int32 bottom = (int32)ceilf(area.bottom);
|
||||||
|
int32 width = right - left + 1;
|
||||||
|
int32 height = bottom - top + 1;
|
||||||
|
|
||||||
|
// make a bitmap from the backbuffer
|
||||||
|
// that has the cursor blended on top of it
|
||||||
|
|
||||||
|
// blending buffer
|
||||||
|
uint8* buffer = new uint8[width * height * 4];
|
||||||
|
|
||||||
|
// offset into back buffer
|
||||||
|
uint8* src = (uint8*)fBackBuffer->Bits();
|
||||||
|
uint32 srcBPR = fBackBuffer->BytesPerRow();
|
||||||
|
src += top * srcBPR + left * 4;
|
||||||
|
|
||||||
|
// offset into cursor bitmap
|
||||||
|
uint8* crs = (uint8*)fCursor->Bits();
|
||||||
|
uint32 crsBPR = fCursor->BytesPerRow();
|
||||||
|
// since area is clipped to cf,
|
||||||
|
// the diff between top and cf.top is always positive,
|
||||||
|
// same for diff between left and cf.left
|
||||||
|
crs += (top - (int32)floorf(cf.top)) * crsBPR
|
||||||
|
+ (left - (int32)floorf(cf.left)) * 4;
|
||||||
|
|
||||||
|
uint8* dst = buffer;
|
||||||
|
|
||||||
|
// blending
|
||||||
|
for (int32 y = top; y <= bottom; y++) {
|
||||||
|
uint8* s = src;
|
||||||
|
uint8* c = crs;
|
||||||
|
uint8* d = dst;
|
||||||
|
for (int32 x = left; x <= right; x++) {
|
||||||
|
// assume backbuffer alpha = 255
|
||||||
|
// TODO: it appears alpha in cursor us upside down
|
||||||
|
uint8 a = 255 - c[3];
|
||||||
|
d[0] = (((s[0] - c[0]) * a) + (c[0] << 8)) >> 8;
|
||||||
|
d[1] = (((s[1] - c[1]) * a) + (c[1] << 8)) >> 8;
|
||||||
|
d[2] = (((s[2] - c[2]) * a) + (c[2] << 8)) >> 8;
|
||||||
|
d[3] = 255;
|
||||||
|
s += 4;
|
||||||
|
c += 4;
|
||||||
|
d += 4;
|
||||||
|
}
|
||||||
|
crs += crsBPR;
|
||||||
|
src += srcBPR;
|
||||||
|
dst += width * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy result to front buffer
|
||||||
|
_CopyToFront(buffer, width * 4, left, top, right, bottom);
|
||||||
|
|
||||||
|
delete[] buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _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)
|
/*void ViewHWInterface::CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,11 @@ class ViewHWInterface : public HWInterface {
|
|||||||
virtual status_t CopyBackToFront(const BRect& area);
|
virtual status_t CopyBackToFront(const BRect& area);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _DrawCursor(BRect area) const;
|
||||||
|
void _CopyToFront(uint8* src, uint32 srcBPR,
|
||||||
|
int32 x, int32 y,
|
||||||
|
int32 right, int32 bottom) const;
|
||||||
|
|
||||||
BitmapBuffer* fBackBuffer;
|
BitmapBuffer* fBackBuffer;
|
||||||
BitmapBuffer* fFrontBuffer;
|
BitmapBuffer* fFrontBuffer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user