s/OpenBeOS/Haiku/

Bugfixes to graphics cases in ServerWindow
Added assignment operator to GraphicsBuffer
Style fixes for ServerCursor and ServerBitmap
Implemented and integrated CursorHandler to clean up DisplayDriver code some
Hotspot bugfix for ServerCursor(cursordata *)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9019 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-09-20 22:50:02 +00:00
parent 66133bb5d9
commit 8dd37bd51b
69 changed files with 799 additions and 317 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
// Copyright (c) 2001-2003, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
// Copyright (c) 2001-2003, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+2 -2
View File
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,7 @@
// Author: John Walker <[email protected]>
// DarkWyrm <[email protected]>
// Description: public domain BGET pool allocator converted to C++
// Distributed with OpenBeOS under MIT license
// Distributed with Haiku under MIT license
//
//------------------------------------------------------------------------------*/
+8 -8
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -112,9 +112,9 @@ void BitmapDriver::SetTarget(ServerBitmap *target)
if(target)
{
_displaymode.virtual_width=target->Width();
_displaymode.virtual_height=target->Height();
_displaymode.space=target->ColorSpace();
fDisplayMode.virtual_width=target->Width();
fDisplayMode.virtual_height=target->Height();
fDisplayMode.space=target->ColorSpace();
fGraphicsBuffer=new GraphicsBuffer((uint8*)fTarget->Bits(),fTarget->Bounds().Width(),
fTarget->Bounds().Height(),fTarget->BytesPerRow());
@@ -840,7 +840,7 @@ void BitmapDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &sourcerect, con
return;
}
if(((uint32)bitmap->ColorSpace() & 0x000F) != (_displaymode.space & 0x000F))
if(((uint32)bitmap->ColorSpace() & 0x000F) != (fDisplayMode.space & 0x000F))
{
printf("CopyBitmap returned - unequal buffer pixel depth\n");
return;
@@ -881,7 +881,7 @@ void BitmapDriver::CopyBitmap(ServerBitmap *bitmap, const BRect &sourcerect, con
source.bottom = work_rect.bottom;
}
work_rect.Set(0,0,_displaymode.virtual_width-1,_displaymode.virtual_height-1);
work_rect.Set(0,0,fDisplayMode.virtual_width-1,fDisplayMode.virtual_height-1);
if( !(work_rect.Contains(destrect)) )
{
@@ -936,7 +936,7 @@ void BitmapDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
return;
}
if(((uint32)destbmp->ColorSpace() & 0x000F) != (_displaymode.space & 0x000F))
if(((uint32)destbmp->ColorSpace() & 0x000F) != (fDisplayMode.space & 0x000F))
{
printf("CopyToBitmap returned - unequal buffer pixel depth\n");
return;
@@ -970,7 +970,7 @@ void BitmapDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
destrect.bottom = work_rect.bottom;
}
work_rect.Set(0,0,_displaymode.virtual_width-1,_displaymode.virtual_height-1);
work_rect.Set(0,0,fDisplayMode.virtual_width-1,fDisplayMode.virtual_height-1);
// Is there anything at all to copy?
if(!work_rect.Contains(sourcerect))
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+9 -9
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -69,7 +69,7 @@ BitmapManager::~BitmapManager(void)
tbmp=(ServerBitmap*)bmplist->RemoveItem(0L);
if(tbmp)
{
fMemPool->ReleaseBuffer(tbmp->_buffer);
fMemPool->ReleaseBuffer(tbmp->fBuffer);
delete tbmp;
tbmp=NULL;
}
@@ -105,15 +105,15 @@ ServerBitmap * BitmapManager::CreateBitmap(BRect bounds, color_space space, int3
delete bmp;
return NULL;
}
bmp->_area=area_for(bmpbuffer);
bmp->_buffer=bmpbuffer;
bmp->_token=tokenizer.GetToken();
bmp->_initialized=true;
bmp->fArea=area_for(bmpbuffer);
bmp->fBuffer=bmpbuffer;
bmp->fToken=tokenizer.GetToken();
bmp->fInitialized=true;
// calculate area offset
area_info ai;
get_area_info(bmp->_area,&ai);
bmp->_offset=bmpbuffer-(uint8*)ai.address;
get_area_info(bmp->fArea,&ai);
bmp->fOffset=bmpbuffer-(uint8*)ai.address;
bmplist->AddItem(bmp);
release_sem(lock);
@@ -136,7 +136,7 @@ void BitmapManager::DeleteBitmap(ServerBitmap *bitmap)
}
// Server code will require a check to ensure bitmap doesn't have its own area
fMemPool->ReleaseBuffer(tbmp->_buffer);
fMemPool->ReleaseBuffer(tbmp->fBuffer);
delete tbmp;
release_sem(lock);
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
// Copyright (c) 2001-2003, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
// Copyright (c) 2001-2003, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+239
View File
@@ -0,0 +1,239 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: CursorHandler.cpp
// Author: DarkWyrm <[email protected]>
// Description: class for handling cursor display for DisplayDriver
//
//------------------------------------------------------------------------------
#include "CursorHandler.h"
#include "DisplayDriver.h"
#include "RectUtils.h"
CursorHandler::CursorHandler(DisplayDriver *driver)
: fDriver(driver),
fOldPosition(0,0,0,0),
fPosition(0,0,0,0),
fCursorPos(0,0),
fSavedData(NULL),
fCursor(NULL),
fHideLevel(0),
fDriverHidden(false),
fIsObscured(false),
fValidSaveData(false)
{
}
//! Frees any memory used for saving screen data
CursorHandler::~CursorHandler(void)
{
delete fSavedData;
}
/*!
\brief Tests to see if the passed rectangle intersects the cursor's current position
\param r The rectangle to test against
\return true if r intersects the cursor's current screen footprint
*/
bool CursorHandler::IntersectsCursor(const BRect &r)
{
return TestRectIntersection(r, fPosition);
}
void CursorHandler::SetCursor(ServerCursor *cursor)
{
// we may start empty, but we will never need to stay that way
if(!cursor)
return;
Hide();
if(fSavedData && cursor->Bounds()!=fSavedData->Bounds())
{
delete fSavedData;
fSavedData=NULL;
}
if(!fSavedData)
fSavedData=new UtilityBitmap(cursor);
fCursor=cursor;
// We change the position rectangles to reflect the new cursor, compensating for the
// new cursor's hotspot.
fPosition=cursor->Bounds().OffsetToCopy(fCursorPos.x-fCursor->GetHotSpot().x,
fCursorPos.y-fCursor->GetHotSpot().y);
fOldPosition=fPosition;
Show();
}
/*!
\brief Moves the cursor to the specified place on screen
\param pt The new cursor location
This function fails if asked to move the cursor outside the screen boundaries
*/
void CursorHandler::MoveTo(const BPoint &pt)
{
if(pt.x<0 || pt.y<0 || (pt.x>fDriver->fDisplayMode.virtual_width-1) ||
(pt.y>fDriver->fDisplayMode.virtual_height-1))
return;
fCursorPos=pt;
fDriver->CopyBitmap(fSavedData,fSavedData->Bounds(),fOldPosition,&(fDriver->fDrawData));
fPosition.OffsetTo(fCursorPos.x-fCursor->GetHotSpot().x,
fCursorPos.y-fCursor->GetHotSpot().y);
fDriver->CopyToBitmap(fSavedData,fPosition);
fDriver->fDrawData.draw_mode=B_OP_ALPHA;
fDriver->CopyBitmap(fCursor,fCursor->Bounds(),fPosition,&(fDriver->fDrawData));
fDriver->fDrawData.draw_mode=B_OP_COPY;
fDriver->Invalidate(fOldPosition);
fOldPosition=fPosition;
fDriver->Invalidate(fPosition);
}
//! Shows the cursor. Unlike BView, calls are not cumulative
void CursorHandler::Show(void)
{
// This call is pretty simple -- save the area underneath the cursor and draw the thing
if(fHideLevel==0)
return;
fIsObscured=false;
fHideLevel--;
if(fHideLevel>0)
return;
fOldPosition=fPosition;
if(!fCursor)
return;
fValidSaveData=true;
if(!fSavedData)
fSavedData=new UtilityBitmap(fCursor->Bounds(),(color_space)fDriver->fDisplayMode.space,0);
fDriver->CopyToBitmap(fSavedData,fPosition);
// Draw the data to the buffer
fDriver->fDrawData.draw_mode=B_OP_ALPHA;
fDriver->CopyBitmap(fCursor,fCursor->Bounds(),fPosition,&(fDriver->fDrawData));
fDriver->fDrawData.draw_mode=B_OP_COPY;
fDriver->Invalidate(fPosition);
}
//! Hides the cursor. Unlike BView, calls are not cumulative
void CursorHandler::Hide(void)
{
fHideLevel++;
// TODO: find out what the behavior is if a Hide is called on an obscured cursor
// For now, we will change the state from obscured to hidden and leave it at that
if(fIsObscured)
{
fIsObscured=false;
return;
}
if(fHideLevel>1)
return;
if(!fCursor)
return;
if(!fSavedData)
fSavedData=new UtilityBitmap(fCursor);
fDriver->CopyBitmap(fSavedData,fSavedData->Bounds(),fOldPosition,&(fDriver->fDrawData));
fDriver->Invalidate(fPosition);
}
//! Hides the cursor until the next MoveTo call. Unlike BView, calls are not cumulative
void CursorHandler::Obscure(void)
{
if(IsObscured())
return;
fIsObscured=true;
// TODO: find out what the behavior is if an Obscure is called on a hidden cursor
// For now, we will change the state from obscured to hidden and leave it at that
if(fHideLevel>0)
{
fHideLevel=0;
return;
}
fDriver->CopyBitmap(fSavedData,fSavedData->Bounds(),fOldPosition,&(fDriver->fDrawData));
fDriver->Invalidate(fPosition);
}
void CursorHandler::DriverHide(void)
{
if(fDriverHidden)
return;
fDriverHidden=true;
if(!fCursor)
return;
if(!fSavedData)
fSavedData=new UtilityBitmap(fCursor);
fDriver->CopyBitmap(fSavedData,fSavedData->Bounds(),fOldPosition,&(fDriver->fDrawData));
fDriver->Invalidate(fPosition);
}
void CursorHandler::DriverShow(void)
{
if(!fDriverHidden)
return;
fDriverHidden=false;
fOldPosition=fPosition;
if(!fCursor)
return;
fValidSaveData=true;
if(!fSavedData)
fSavedData=new UtilityBitmap(fCursor->Bounds(),(color_space)fDriver->fDisplayMode.space,0);
fDriver->CopyToBitmap(fSavedData,fPosition);
// Draw the data to the buffer
fDriver->fDrawData.draw_mode=B_OP_ALPHA;
fDriver->CopyBitmap(fCursor,fCursor->Bounds(),fPosition,&(fDriver->fDrawData));
fDriver->fDrawData.draw_mode=B_OP_COPY;
fDriver->Invalidate(fPosition);
}
+78
View File
@@ -0,0 +1,78 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: CursorHandler.h
// Author: DarkWyrm <[email protected]>
// Description: class for handling cursor display for DisplayDriver
//
//------------------------------------------------------------------------------
#ifndef CURSORHANDLER_H
#define CURSORHANDLER_H
#include "GraphicsBuffer.h"
#include "ServerCursor.h"
#include "ServerBitmap.h"
class DisplayDriver;
/*!
\class CursorHandler CursorHandler.h
\brief Object used by DisplayDriver to handle all the messiness of displaying the cursor
*/
class CursorHandler
{
public:
CursorHandler(DisplayDriver *driver);
~CursorHandler(void);
bool IntersectsCursor(const BRect &r);
void SetCursor(ServerCursor *cursor);
ServerCursor *GetCursor(void) const { return fCursor; }
void MoveTo(const BPoint &pt);
void Hide(void);
void Show(void);
void Obscure(void);
bool IsHidden(void) const { return (fHideLevel>0); }
bool IsObscured(void) const { return fIsObscured; }
void DriverHide(void);
void DriverShow(void);
private:
DisplayDriver *fDriver;
BRect fOldPosition;
BRect fPosition;
BPoint fCursorPos;
UtilityBitmap *fSavedData;
ServerCursor *fCursor;
int8 fHideLevel;
bool fDriverHidden;
bool fIsObscured;
bool fValidSaveData;
};
#endif
+4 -4
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -119,7 +119,7 @@ int32 CursorManager::AddCursor(ServerCursor *sc)
Lock();
fCursorList->AddItem(sc);
int32 value=fTokenizer.GetToken();
sc->_token=value;
sc->fToken=value;
Unlock();
return value;
@@ -139,7 +139,7 @@ void CursorManager::DeleteCursor(int32 token)
for(int32 i=0; i<fCursorList->CountItems();i++)
{
temp=(ServerCursor*)fCursorList->ItemAt(i);
if(temp && temp->_token==token)
if(temp && temp->fToken==token)
{
fCursorList->RemoveItem(i);
delete temp;
@@ -607,7 +607,7 @@ ServerCursor *CursorManager::FindCursor(int32 token)
for(int32 i=0; i<fCursorList->CountItems();i++)
{
temp=(ServerCursor*)fCursorList->ItemAt(i);
if(temp && temp->_token==token)
if(temp && temp->fToken==token)
return temp;
}
return NULL;
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+3 -3
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -625,7 +625,7 @@ void DirectDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
destrect.bottom = work_rect.bottom;
}
work_rect.Set(0,0,_displaymode.virtual_width-1,_displaymode.virtual_height-1);
work_rect.Set(0,0,fDisplayMode.virtual_width-1,fDisplayMode.virtual_height-1);
if(!work_rect.Contains(sourcerect))
return;
@@ -912,7 +912,7 @@ void DDView::MessageReceived(BMessage *msg)
}
DDWindow::DDWindow(uint16 width, uint16 height, color_space space, DirectDriver *owner)
: BDirectWindow(BRect(0,0,width-1,height-1), "OpenBeOS App Server",B_TITLED_WINDOW,
: BDirectWindow(BRect(0,0,width-1,height-1), "Haiku, Inc. App Server",B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_MOVABLE)
{
AddChild(new DDView(Bounds()));
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+216 -134
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -32,6 +32,7 @@
#include <stdio.h>
#include "DisplayDriver.h"
#include "RectUtils.h"
#include "Utils.h"
#include "ServerCursor.h"
// TODO: Remove remnants of old API. Inplement all functions. Bounds checking needs to be
@@ -50,12 +51,13 @@ DisplayDriver::DisplayDriver(void)
{
_locker=new BLocker();
_is_cursor_hidden=false;
_is_cursor_obscured=false;
_cursor=NULL;
_cursorsave=NULL;
_dpms_caps=B_DPMS_ON;
_dpms_state=B_DPMS_ON;
// _is_cursor_hidden=false;
// _is_cursor_obscured=false;
// _cursor=NULL;
// _cursorsave=NULL;
fCursorHandler=new CursorHandler(this);
fDPMSCaps=B_DPMS_ON;
fDPMSState=B_DPMS_ON;
}
@@ -67,6 +69,7 @@ DisplayDriver::DisplayDriver(void)
DisplayDriver::~DisplayDriver(void)
{
delete _locker;
delete fCursorHandler;
}
/*!
@@ -104,7 +107,11 @@ void DisplayDriver::CopyBits(const BRect &src, const BRect &dest, const DrawData
return;
Lock();
if(fCursorHandler->IntersectsCursor(dest))
fCursorHandler->DriverHide();
Blit(src,dest,d);
fCursorHandler->DriverShow();
Unlock();
}
@@ -143,6 +150,9 @@ void DisplayDriver::DrawBitmap(BRegion *region, ServerBitmap *bitmap, const BRec
return;
}
if(fCursorHandler->IntersectsCursor(dest))
fCursorHandler->DriverHide();
uint8 colorspace_size = (bitmap->BitsPerPixel() + 7) / 8;
int32 count = region->CountRects();
@@ -252,6 +262,7 @@ void DisplayDriver::DrawBitmap(BRegion *region, ServerBitmap *bitmap, const BRec
}
}
fCursorHandler->DriverShow();
ReleaseBuffer();
Unlock();
Invalidate(destrect);
@@ -439,7 +450,10 @@ void DisplayDriver::DrawString(const char *string, const int32 &length, const BP
return;
Lock();
// TODO: Test for cursor intersection in DisplayDriver::DrawString
fCursorHandler->DriverHide();
BPoint point(pt);
point.y--; // because of Be's backward compatibility hack
@@ -579,7 +593,10 @@ void DisplayDriver::DrawString(const char *string, const int32 &length, const BP
r.right=MAX(point.x,pen.x>>6);
r.top=point.y-face->height;
r.bottom=point.y+face->height;
fCursorHandler->DriverShow();
Invalidate(r);
FT_Done_Face(face);
Unlock();
@@ -676,9 +693,6 @@ void DisplayDriver::BlitMono2RGB32(FT_Bitmap *src, const BPoint &pt, const DrawD
destindex+=destinc;
}
ReleaseBuffer();
// TODO: test to see if Invalidate calls should be made in DisplayDriver::BlitMono2RGB32
Invalidate(BRect(pt.x, pt.y, pt.x + srcwidth, pt.y + srcheight));
}
void DisplayDriver::BlitGray2RGB32(FT_Bitmap *src, const BPoint &pt, const DrawData *d)
@@ -800,8 +814,6 @@ void DisplayDriver::BlitGray2RGB32(FT_Bitmap *src, const BPoint &pt, const DrawD
destindex+=destinc;
}
ReleaseBuffer();
// TODO: test to see if Invalidate calls should be made in DisplayDriver::BlitGray2RGB32
Invalidate(BRect(pt.x, pt.y, pt.x + srcwidth, pt.y + srcheight));
}
bool DisplayDriver::AcquireBuffer(FBBitmap *bmp)
@@ -826,6 +838,9 @@ void DisplayDriver::Invalidate(const BRect &r)
*/
void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &span, const RGBColor &color)
{
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
float xc = (r.left+r.right)/2;
float yc = (r.top+r.bottom)/2;
float rx = r.Width()/2;
@@ -1173,6 +1188,7 @@ void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &spa
}
}
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -1186,6 +1202,9 @@ void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &spa
*/
void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &span, const DrawData *d)
{
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
float xc = (r.left+r.right)/2;
float yc = (r.top+r.bottom)/2;
float rx = r.Width()/2;
@@ -1537,6 +1556,7 @@ void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &spa
}
}
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -1546,8 +1566,13 @@ void DisplayDriver::FillBezier(BPoint *pts, const RGBColor &color)
Lock();
BezierCurve curve(pts);
if(fCursorHandler->IntersectsCursor(curve.Frame()))
fCursorHandler->DriverHide();
FillPolygon(curve.GetPointArray(), curve.points.CountItems(), curve.Frame(), color);
fCursorHandler->DriverShow();
Unlock();
}
@@ -1562,8 +1587,13 @@ void DisplayDriver::FillBezier(BPoint *pts, const DrawData *d)
Lock();
BezierCurve curve(pts);
if(fCursorHandler->IntersectsCursor(curve.Frame()))
fCursorHandler->DriverHide();
FillPolygon(curve.GetPointArray(), curve.points.CountItems(), curve.Frame(), d);
fCursorHandler->DriverShow();
Unlock();
}
@@ -1590,6 +1620,9 @@ void DisplayDriver::FillEllipse(const BRect &r, const RGBColor &color)
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc),ROUND(yc-y),color);
StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc),ROUND(yc+y),color);
@@ -1628,6 +1661,8 @@ void DisplayDriver::FillEllipse(const BRect &r, const RGBColor &color)
StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color);
StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color);
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -1655,6 +1690,9 @@ void DisplayDriver::FillEllipse(const BRect &r, const DrawData *d)
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
data = *d;
data.pensize = 1;
@@ -1696,6 +1734,7 @@ void DisplayDriver::FillEllipse(const BRect &r, const DrawData *d)
StrokeLine(BPoint(xc-x,yc-y),BPoint(xc+x,yc-y),&data);
StrokeLine(BPoint(xc-x,yc+y),BPoint(xc+x,yc+y),&data);
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -1721,6 +1760,9 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
BPoint *currentPoint, *nextPoint;
BPoint tempNextPoint;
BPoint tempCurrentPoint;
@@ -1819,7 +1861,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
}
if (segmentArray[i].MinY() == segmentArray[i].MaxY())
{
if ( (segmentArray[i].MinX() < _displaymode.virtual_width) &&
if ( (segmentArray[i].MinX() < fDisplayMode.virtual_width) &&
(segmentArray[i].MaxX() >= 0) )
StrokeSolidLine(ROUND(segmentArray[i].MinX()), y,
ROUND(segmentArray[i].MaxX()), y, color);
@@ -1827,7 +1869,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
}
else
{
if ( (segmentArray[i+1].GetX(y) < _displaymode.virtual_width) &&
if ( (segmentArray[i+1].GetX(y) < fDisplayMode.virtual_width) &&
(segmentArray[i].GetX(y) >= 0) )
StrokeSolidLine(ROUND(segmentArray[i].GetX(y)), y,
ROUND(segmentArray[i+1].GetX(y)), y, color);
@@ -1837,6 +1879,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
}
delete[] segmentArray;
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
@@ -1863,6 +1906,9 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
BPoint *currentPoint, *nextPoint;
BPoint tempNextPoint;
BPoint tempCurrentPoint;
@@ -1963,7 +2009,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
}
if (segmentArray[i].MinY() == segmentArray[i].MaxY())
{
if ( (segmentArray[i].MinX() < _displaymode.virtual_width) &&
if ( (segmentArray[i].MinX() < fDisplayMode.virtual_width) &&
(segmentArray[i].MaxX() >= 0) )
StrokePatternLine(ROUND(segmentArray[i].MinX()), y,
ROUND(segmentArray[i].MaxX()), y, d);
@@ -1971,7 +2017,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
}
else
{
if ( (segmentArray[i+1].GetX(y) < _displaymode.virtual_width) &&
if ( (segmentArray[i+1].GetX(y) < fDisplayMode.virtual_width) &&
(segmentArray[i].GetX(y) >= 0) )
StrokePatternLine(ROUND(segmentArray[i].GetX(y)), y,
ROUND(segmentArray[i+1].GetX(y)), y, d);
@@ -2050,6 +2096,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
}
}
delete[] segmentArray;
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
}
@@ -2062,7 +2109,13 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
void DisplayDriver::FillRect(const BRect &r, const RGBColor &color)
{
Lock();
if(fCursorHandler->IntersectsCursor(r))
{
debugger("");
fCursorHandler->DriverHide();
}
FillSolidRect(r,color);
fCursorHandler->DriverShow();
Unlock();
}
@@ -2079,6 +2132,8 @@ void DisplayDriver::FillRect(const BRect &r, const DrawData *d)
return;
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
if ( d->clipReg )
{
if ( d->clipReg->Intersects(r) )
@@ -2093,6 +2148,7 @@ void DisplayDriver::FillRect(const BRect &r, const DrawData *d)
}
else
FillPatternRect(r,d);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -2106,11 +2162,16 @@ void DisplayDriver::FillRegion(BRegion& r, const RGBColor &color)
{
Lock();
if(fCursorHandler->IntersectsCursor(r.Frame()))
fCursorHandler->DriverHide();
int numRects;
numRects = r.CountRects();
for(int32 i=0; i<numRects;i++)
FillSolidRect(r.RectAt(i),color);
fCursorHandler->DriverShow();
Invalidate(r.Frame());
Unlock();
}
@@ -2129,6 +2190,9 @@ void DisplayDriver::FillRegion(BRegion& r, const DrawData *d)
Lock();
if(fCursorHandler->IntersectsCursor(r.Frame()))
fCursorHandler->DriverHide();
int numRects;
if ( d->clipReg )
@@ -2148,6 +2212,7 @@ void DisplayDriver::FillRegion(BRegion& r, const DrawData *d)
for(int32 i=0; i<numRects;i++)
FillPatternRect(r.RectAt(i),d);
}
fCursorHandler->DriverShow();
Invalidate(r.Frame());
Unlock();
}
@@ -2160,6 +2225,8 @@ void DisplayDriver::FillRoundRect(const BRect &r, const float &xrad, const float
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
for (i=0; i<=(int)yrad; i++)
{
arc_x = xrad*sqrt(1-i*i/yrad2);
@@ -2167,6 +2234,7 @@ void DisplayDriver::FillRoundRect(const BRect &r, const float &xrad, const float
StrokeSolidLine(ROUND(r.left+xrad-arc_x), ROUND(r.bottom-yrad+i), ROUND(r.right-xrad+arc_x), ROUND(r.bottom-yrad+i),color);
}
FillSolidRect(BRect(r.left,r.top+yrad,r.right,r.bottom-yrad),color);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -2186,6 +2254,9 @@ void DisplayDriver::FillRoundRect(const BRect &r, const float &xrad, const float
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
if ( d->clipReg )
{
int numRects, rectIndex;
@@ -2227,6 +2298,7 @@ void DisplayDriver::FillRoundRect(const BRect &r, const float &xrad, const float
}
}
FillPatternRect(BRect(r.left,r.top+yrad,r.right,r.bottom-yrad),d);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -2244,6 +2316,9 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const RGBColo
return;
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
BPoint first, second, third;
// Sort points according to their y values and x values (y is primary)
@@ -2329,6 +2404,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const RGBColo
for(i=(int32)second.y; i<=third.y; i++)
StrokeSolidLine(ROUND(lineC.GetX(i)), i, ROUND(lineB.GetX(i)), i, color);
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
@@ -2346,6 +2422,9 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
if ( d->clipReg )
{
// For now, cop out and use FillPolygon
@@ -2440,6 +2519,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
StrokePatternLine(ROUND(lineC.GetX(i)), i, ROUND(lineB.GetX(i)), i, d);
}
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
@@ -2455,20 +2535,8 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
*/
void DisplayDriver::HideCursor(void)
{
Lock();
if(_is_cursor_hidden)
{
Unlock();
return;
}
_is_cursor_hidden=true;
if(_cursorsave)
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
fCursorHandler->Hide();
Unlock();
}
@@ -2480,9 +2548,7 @@ void DisplayDriver::HideCursor(void)
bool DisplayDriver::IsCursorHidden(void)
{
Lock();
bool value=(_is_cursor_hidden || _is_cursor_obscured);
bool value=fCursorHandler->IsHidden();
Unlock();
return value;
@@ -2499,38 +2565,7 @@ bool DisplayDriver::IsCursorHidden(void)
void DisplayDriver::MoveCursorTo(const float &x, const float &y)
{
Lock();
if(cursorframe.left==x && cursorframe.top==y)
{
Unlock();
return;
}
if(_is_cursor_obscured)
_is_cursor_obscured=false;
oldcursorframe=cursorframe;
cursorframe.OffsetTo(x,y);
if(_is_cursor_hidden)
{
Unlock();
return;
}
if(!_cursorsave)
_cursorsave=new UtilityBitmap(_cursor->Bounds(),(color_space)_displaymode.space,0);
_drawdata.draw_mode=B_OP_COPY;
CopyBitmap(_cursorsave,_cursor->Bounds(),saveframe,&_drawdata);
CopyToBitmap(_cursorsave,cursorframe);
saveframe=cursorframe;
_drawdata.draw_mode=B_OP_ALPHA;
CopyBitmap(_cursor,_cursor->Bounds(),cursorframe,&_drawdata);
_drawdata.draw_mode=B_OP_COPY;
fCursorHandler->MoveTo(BPoint(x,y));
Unlock();
}
@@ -2552,22 +2587,8 @@ void DisplayDriver::InvertRect(const BRect &r)
*/
void DisplayDriver::ShowCursor(void)
{
if(!_cursor)
{
printf("ERROR: Call to ShowCursor and driver has no defined cursor\n");
return;
}
Lock();
_is_cursor_hidden=false;
_is_cursor_obscured=false;
CopyToBitmap(_cursorsave,cursorframe);
saveframe=cursorframe;
CopyBitmap(_cursor,_cursor->Bounds(),cursorframe,&_drawdata);
fCursorHandler->Show();
Unlock();
}
@@ -2582,18 +2603,7 @@ void DisplayDriver::ShowCursor(void)
void DisplayDriver::ObscureCursor(void)
{
Lock();
if(_is_cursor_obscured)
{
Unlock();
return;
}
_is_cursor_obscured=true;
if(_cursorsave)
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
fCursorHandler->Obscure();
Unlock();
}
@@ -2609,36 +2619,7 @@ void DisplayDriver::ObscureCursor(void)
void DisplayDriver::SetCursor(ServerCursor *cursor)
{
Lock();
bool visible=false;
if(!_is_cursor_hidden && !_is_cursor_obscured)
visible=true;
if(_cursor)
{
// We need to restore the stuff because the cursor very well may not be the same size
if(visible)
CopyBitmap(_cursorsave,_cursorsave->Bounds(),cursorframe, &_drawdata);
delete _cursor;
}
_cursor=new ServerCursor(cursor);
if(visible)
_cursorsave=new UtilityBitmap((ServerBitmap*)cursor);
// TODO: make this take the hotspot into account -- too tired to bother right now...
saveframe=_cursor->Bounds().OffsetToCopy(cursorframe.LeftTop());
cursorframe=saveframe;
if(visible)
{
CopyToBitmap(_cursorsave, cursorframe);
_drawdata.draw_mode=B_OP_ALPHA;
CopyBitmap(_cursor, _cursor->Bounds(), cursorframe, &_drawdata);
_drawdata.draw_mode=B_OP_COPY;
}
fCursorHandler->SetCursor(cursor);
Unlock();
}
@@ -2673,6 +2654,9 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
// Watch out for bozos giving us whacko spans
if ( (span >= 360) || (span <= -360) )
{
@@ -2801,6 +2785,7 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s
(shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) )
StrokePoint(BPoint(xc+x,yc+y),color);
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -2836,6 +2821,9 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
// Watch out for bozos giving us whacko spans
if ( (span >= 360) || (span <= -360) )
{
@@ -2964,6 +2952,7 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s
(shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) )
StrokePoint(BPoint(xc+x,yc+y),d);
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -2980,9 +2969,14 @@ void DisplayDriver::StrokeBezier(BPoint *pts, const RGBColor &color)
Lock();
BezierCurve curve(pts);
if(fCursorHandler->IntersectsCursor(curve.Frame()))
fCursorHandler->DriverHide();
numLines = curve.points.CountItems()-1;
for (i=0; i<numLines; i++)
StrokeLine(*((BPoint*)curve.points.ItemAt(i)),*((BPoint*)curve.points.ItemAt(i+1)),color);
fCursorHandler->DriverShow();
Invalidate(curve.Frame());
Unlock();
}
@@ -2998,10 +2992,15 @@ void DisplayDriver::StrokeBezier(BPoint *pts, const DrawData *d)
Lock();
BezierCurve curve(pts);
if(fCursorHandler->IntersectsCursor(curve.Frame()))
fCursorHandler->DriverHide();
numLines = curve.points.CountItems()-1;
for (i=0; i<numLines; i++)
StrokeLine(*((BPoint*)curve.points.ItemAt(i)),*((BPoint*)curve.points.ItemAt(i+1)),d);
fCursorHandler->DriverShow();
Invalidate(curve.Frame());
Unlock();
}
@@ -3030,6 +3029,9 @@ void DisplayDriver::StrokeEllipse(const BRect &r, const RGBColor &color)
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
p = ROUND (Ry2 - (Rx2 * ry) + (.25 * Rx2));
while (px < py)
{
@@ -3073,6 +3075,8 @@ void DisplayDriver::StrokeEllipse(const BRect &r, const RGBColor &color)
StrokeLine(BPoint(xc-lastx,yc+lasty),BPoint(xc-x,yc+y),color);
StrokeLine(BPoint(xc+lastx,yc+lasty),BPoint(xc+x,yc+y),color);
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -3101,6 +3105,9 @@ void DisplayDriver::StrokeEllipse(const BRect &r, const DrawData *d)
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
p = ROUND (Ry2 - (Rx2 * ry) + (.25 * Rx2));
while (px < py)
{
@@ -3144,6 +3151,7 @@ void DisplayDriver::StrokeEllipse(const BRect &r, const DrawData *d)
StrokeLine(BPoint(xc-lastx,yc+lasty),BPoint(xc-x,yc+y),d);
StrokeLine(BPoint(xc+lastx,yc+lasty),BPoint(xc+x,yc+y),d);
}
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -3157,7 +3165,11 @@ void DisplayDriver::StrokeEllipse(const BRect &r, const DrawData *d)
void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, const RGBColor &color)
{
Lock();
if(fCursorHandler->IntersectsCursor(BRect(start,end)))
fCursorHandler->DriverHide();
StrokeSolidLine(ROUND(start.x),ROUND(start.y),ROUND(end.x),ROUND(end.y),color);
fCursorHandler->DriverShow();
Invalidate(BRect(start,end));
Unlock();
}
@@ -3171,6 +3183,10 @@ void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, const RGB
void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, const DrawData *d)
{
Lock();
if(fCursorHandler->IntersectsCursor(BRect(start,end)))
fCursorHandler->DriverHide();
if ( d->pensize == 1 )
{
if ( d->clipReg )
@@ -3266,6 +3282,7 @@ void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, const Dra
FillPolygon(corners,4,BRect(start,end),d);
}
}
fCursorHandler->DriverShow();
Invalidate(BRect(start,end));
Unlock();
}
@@ -3278,6 +3295,8 @@ void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, const Dra
*/
void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, DisplayDriver* driver, SetPixelFuncType setPixel)
{
// TODO: What's this particular StrokeLine call for?
int x1 = ROUND(start.x);
int y1 = ROUND(start.y);
int x2 = ROUND(end.x);
@@ -3324,10 +3343,15 @@ void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, const BRect &bou
return;
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
for(int32 i=0; i<(numpts-1); i++)
StrokeLine(ptlist[i],ptlist[i+1],color);
if(is_closed)
StrokeLine(ptlist[numpts-1],ptlist[0],color);
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
}
@@ -3344,10 +3368,15 @@ void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, const BRect &bou
return;
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
for(int32 i=0; i<(numpts-1); i++)
StrokeLine(ptlist[i],ptlist[i+1],d);
if(is_closed)
StrokeLine(ptlist[numpts-1],ptlist[0],d);
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
}
@@ -3361,7 +3390,12 @@ void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, const BRect &bou
void DisplayDriver::StrokeRect(const BRect &r, const RGBColor &color)
{
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
StrokeSolidRect(r,color);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -3369,10 +3403,14 @@ void DisplayDriver::StrokeRect(const BRect &r, const RGBColor &color)
void DisplayDriver::StrokeRect(const BRect &r, const DrawData *d)
{
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
StrokeLine(r.LeftTop(),r.RightTop(),d);
StrokeLine(r.LeftTop(),r.LeftBottom(),d);
StrokeLine(r.RightTop(),r.RightBottom(),d);
StrokeLine(r.LeftBottom(),r.RightBottom(),d);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -3388,8 +3426,13 @@ void DisplayDriver::StrokeRegion(BRegion& r, const RGBColor &color)
{
Lock();
if(fCursorHandler->IntersectsCursor(r.Frame()))
fCursorHandler->DriverHide();
for(int32 i=0; i<r.CountRects();i++)
StrokeRect(r.RectAt(i),color);
fCursorHandler->DriverShow();
Invalidate(r.Frame());
Unlock();
}
@@ -3397,9 +3440,14 @@ void DisplayDriver::StrokeRegion(BRegion& r, const RGBColor &color)
void DisplayDriver::StrokeRegion(BRegion& r, const DrawData *d)
{
Lock();
if(fCursorHandler->IntersectsCursor(r.Frame()))
fCursorHandler->DriverHide();
for(int32 i=0; i<r.CountRects();i++)
StrokeRect(r.RectAt(i),d);
fCursorHandler->DriverShow();
Invalidate(r.Frame());
Unlock();
}
@@ -3420,6 +3468,9 @@ void DisplayDriver::StrokeRoundRect(const BRect &r, const float &xrad, const flo
bBottom = vBottom - yrad;
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
StrokeArc(BRect(bRight, r.top, r.right, bTop), 0, 90, color);
StrokeLine(BPoint(hRight, r.top), BPoint(hLeft, r.top), color);
@@ -3431,6 +3482,8 @@ void DisplayDriver::StrokeRoundRect(const BRect &r, const float &xrad, const flo
StrokeArc(BRect(bRight,bBottom,r.right,r.bottom), 270, 90, color);
StrokeLine(BPoint(r.right, vBottom), BPoint(r.right, vTop), color);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -3458,6 +3511,10 @@ void DisplayDriver::StrokeRoundRect(const BRect &r, const float &xrad, const flo
bBottom = vBottom - yrad;
Lock();
if(fCursorHandler->IntersectsCursor(r))
fCursorHandler->DriverHide();
StrokeArc(BRect(bRight, r.top, r.right, bTop), 0, 90, d);
StrokeLine(BPoint(hRight, r.top), BPoint(hLeft, r.top), d);
@@ -3469,6 +3526,8 @@ void DisplayDriver::StrokeRoundRect(const BRect &r, const float &xrad, const flo
StrokeArc(BRect(bRight,bBottom,r.right,r.bottom), 270, 90, d);
StrokeLine(BPoint(r.right, vBottom), BPoint(r.right, vTop), d);
fCursorHandler->DriverShow();
Invalidate(r);
Unlock();
}
@@ -3488,9 +3547,14 @@ void DisplayDriver::StrokeShape(const BRect &bounds, const int32 &opcount, const
void DisplayDriver::StrokeTriangle(BPoint *pts, const BRect &bounds, const RGBColor &color)
{
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
StrokeLine(pts[0],pts[1],color);
StrokeLine(pts[1],pts[2],color);
StrokeLine(pts[2],pts[0],color);
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
}
@@ -3498,9 +3562,14 @@ void DisplayDriver::StrokeTriangle(BPoint *pts, const BRect &bounds, const RGBCo
void DisplayDriver::StrokeTriangle(BPoint *pts, const BRect &bounds, const DrawData *d)
{
Lock();
if(fCursorHandler->IntersectsCursor(bounds))
fCursorHandler->DriverHide();
StrokeLine(pts[0],pts[1],d);
StrokeLine(pts[1],pts[2],d);
StrokeLine(pts[2],pts[0],d);
fCursorHandler->DriverShow();
Invalidate(bounds);
Unlock();
}
@@ -3519,6 +3588,11 @@ void DisplayDriver::StrokeLineArray(BPoint *pts, const int32 &numlines, const Dr
Lock();
BRect invalid=CalculatePolygonBounds(pts,numlines*2);
if(fCursorHandler->IntersectsCursor(invalid))
fCursorHandler->DriverHide();
data = *d;
for (i=0; i<numlines; i++)
{
@@ -3526,8 +3600,8 @@ void DisplayDriver::StrokeLineArray(BPoint *pts, const int32 &numlines, const Dr
StrokeLine(pts[i<<1],pts[i<<1+1],&data);
}
// TODO: calculate invalid region for DisplayDriver::StrokeLineArray
fCursorHandler->DriverShow();
Unlock();
}
@@ -3552,7 +3626,7 @@ void DisplayDriver::GetMode(display_mode *mode)
return;
Lock();
*mode=_displaymode;
*mode=fDisplayMode;
Unlock();
}
@@ -3813,7 +3887,11 @@ void DisplayDriver::GetTruncatedStrings(const char **instrings,const int32 &stri
*/
bool DisplayDriver::IsCursorObscured(bool state)
{
return _is_cursor_obscured;
Lock();
bool value=fCursorHandler->IsObscured();
Unlock();
return value;
}
// Protected Internal Functions
@@ -3866,7 +3944,7 @@ status_t DisplayDriver::SetDPMSMode(const uint32 &state)
*/
uint32 DisplayDriver::DPMSMode(void) const
{
return _dpms_state;
return fDPMSState;
}
/*!
@@ -3878,7 +3956,7 @@ uint32 DisplayDriver::DPMSMode(void) const
*/
uint32 DisplayDriver::DPMSCapabilities(void) const
{
return _dpms_caps;
return fDPMSCaps;
}
/*!
@@ -3994,7 +4072,11 @@ status_t DisplayDriver::WaitForRetrace(bigtime_t timeout)
*/
ServerCursor *DisplayDriver::_GetCursor(void)
{
return _cursor;
Lock();
ServerCursor *c=fCursorHandler->GetCursor();
Unlock();
return c;
}
/*!
+27
View File
@@ -1,3 +1,30 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: DisplaySupport.cpp
// Author: DarkWyrm <[email protected]>
// Gabe Yoder <[email protected]>
// Description: Support classes for the DisplayDriver class
//
//------------------------------------------------------------------------------
#include "DisplaySupport.h"
BezierCurve::BezierCurve(BPoint* pts)
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+11 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -39,6 +39,11 @@ GraphicsBuffer::GraphicsBuffer(uint8 *buffer, uint32 width, uint32 height, uint3
SetTo(buffer, width, height, rowbytes);
}
GraphicsBuffer::GraphicsBuffer(const GraphicsBuffer &buffer)
{
SetTo(buffer.fBuffer, buffer.fWidth, buffer.fHeight, buffer.fBytesPerRow);
}
GraphicsBuffer::~GraphicsBuffer()
{
delete [] fRowList;
@@ -85,3 +90,8 @@ void GraphicsBuffer::Unset(void)
}
GraphicsBuffer &GraphicsBuffer::operator=(const GraphicsBuffer &buffer)
{
SetTo(buffer.fBuffer, buffer.fWidth, buffer.fHeight, buffer.fBytesPerRow);
return *this;
}
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+28
View File
@@ -1,3 +1,31 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Layer.cpp
// Author: DarkWyrm <[email protected]>
// Adi Oanca <[email protected]>
// Description: Class used for rendering to the frame buffer. One layer per
// view on screen and also for window decorators
//
//------------------------------------------------------------------------------
#include <View.h>
#include <Message.h>
#include <AppDefs.h>
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
// Copyright (c) 2001-2003, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
// Copyright (c) 2001-2003, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+51 -51
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -39,16 +39,16 @@
ServerBitmap::ServerBitmap(BRect rect,color_space space, int32 flags,
int32 bytesperline, screen_id screen)
{
_initialized=false;
fInitialized=false;
// WARNING: '1' is added to the width and height. Same is done in FBBitmap
// subclass, so if you modify here make sure to do the same under FBBitmap::SetSize(...)
_width=rect.IntegerWidth()+1;
_height=rect.IntegerHeight()+1;
_space=space;
_area=B_ERROR;
_buffer=NULL;
_flags=flags;
fWidth=rect.IntegerWidth()+1;
fHeight=rect.IntegerHeight()+1;
fSpace=space;
fArea=B_ERROR;
fBuffer=NULL;
fFlags=flags;
_HandleSpace(space, bytesperline);
}
@@ -56,27 +56,27 @@ ServerBitmap::ServerBitmap(BRect rect,color_space space, int32 flags,
//! Copy constructor does not copy the buffer.
ServerBitmap::ServerBitmap(const ServerBitmap *bmp)
{
_initialized=false;
_area=B_ERROR;
_buffer=NULL;
fInitialized=false;
fArea=B_ERROR;
fBuffer=NULL;
if(bmp)
{
_width=bmp->_width;
_height=bmp->_height;
_bytesperrow=bmp->_bytesperrow;
_space=bmp->_space;
_flags=bmp->_flags;
_bpp=bmp->_bpp;
fWidth=bmp->fWidth;
fHeight=bmp->fHeight;
fBytesPerRow=bmp->fBytesPerRow;
fSpace=bmp->fSpace;
fFlags=bmp->fFlags;
fBitsPerPixel=bmp->fBitsPerPixel;
}
else
{
_width=0;
_height=0;
_bytesperrow=0;
_space=B_NO_COLOR_SPACE;
_flags=0;
_bpp=0;
fWidth=0;
fHeight=0;
fBytesPerRow=0;
fSpace=B_NO_COLOR_SPACE;
fFlags=0;
fBitsPerPixel=0;
}
}
@@ -93,7 +93,7 @@ ServerBitmap::~ServerBitmap(void)
*/
uint32 ServerBitmap::BitsLength(void) const
{
return (uint32)(_bytesperrow*_height);
return (uint32)(fBytesPerRow*fHeight);
}
/*!
@@ -104,9 +104,9 @@ uint32 ServerBitmap::BitsLength(void) const
*/
void ServerBitmap::_AllocateBuffer(void)
{
if(_buffer!=NULL)
delete _buffer;
_buffer=new uint8[BitsLength()];
if(fBuffer!=NULL)
delete fBuffer;
fBuffer=new uint8[BitsLength()];
}
/*!
@@ -116,10 +116,10 @@ void ServerBitmap::_AllocateBuffer(void)
*/
void ServerBitmap::_FreeBuffer(void)
{
if(_buffer!=NULL)
if(fBuffer!=NULL)
{
delete _buffer;
_buffer=NULL;
delete fBuffer;
fBuffer=NULL;
}
}
@@ -165,11 +165,11 @@ void ServerBitmap::_HandleSpace(color_space space, int32 bytesperline)
case B_HLS24:
case B_CMY24:
{
if(bytesperline<(_width*4))
_bytesperrow=_width*4;
if(bytesperline<(fWidth*4))
fBytesPerRow=fWidth*4;
else
_bytesperrow=bytesperline;
_bpp=32;
fBytesPerRow=bytesperline;
fBitsPerPixel=32;
break;
}
// Calculate size and dword-align
@@ -177,8 +177,8 @@ void ServerBitmap::_HandleSpace(color_space space, int32 bytesperline)
// 1-bit
case B_GRAY1:
{
int32 numbytes=_width>>3;
if((_width % 8) != 0)
int32 numbytes=fWidth>>3;
if((fWidth % 8) != 0)
numbytes++;
if(bytesperline<numbytes)
{
@@ -186,14 +186,14 @@ void ServerBitmap::_HandleSpace(color_space space, int32 bytesperline)
{
if( (numbytes+i)%4==0)
{
_bytesperrow=numbytes+i;
fBytesPerRow=numbytes+i;
break;
}
}
}
else
_bytesperrow=bytesperline;
_bpp=1;
fBytesPerRow=bytesperline;
fBitsPerPixel=1;
}
// 8-bit
@@ -206,20 +206,20 @@ void ServerBitmap::_HandleSpace(color_space space, int32 bytesperline)
case B_YCbCr420:
case B_YUV422:
{
if(bytesperline<_width)
if(bytesperline<fWidth)
{
for(int8 i=0;i<4;i++)
{
if( (_width+i)%4==0)
if( (fWidth+i)%4==0)
{
_bytesperrow=_width+i;
fBytesPerRow=fWidth+i;
break;
}
}
}
else
_bytesperrow=bytesperline;
_bpp=8;
fBytesPerRow=bytesperline;
fBitsPerPixel=8;
break;
}
@@ -235,20 +235,20 @@ void ServerBitmap::_HandleSpace(color_space space, int32 bytesperline)
case B_YCbCr444:
case B_YUV444:
{
if(bytesperline<_width*2)
if(bytesperline<fWidth*2)
{
if( (_width*2) % 4 !=0)
_bytesperrow=(_width+1)*2;
if( (fWidth*2) % 4 !=0)
fBytesPerRow=(fWidth+1)*2;
else
_bytesperrow=_width*2;
fBytesPerRow=fWidth*2;
}
else
_bytesperrow=bytesperline;
_bpp=16;
fBytesPerRow=bytesperline;
fBitsPerPixel=16;
break;
}
case B_NO_COLOR_SPACE:
_bpp=0;
fBitsPerPixel=0;
break;
}
}
+17 -16
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -38,8 +38,8 @@
ServerCursor::ServerCursor(BRect r, color_space cspace, int32 flags, BPoint hotspot, int32 bytesperrow, screen_id screen)
: ServerBitmap(r,cspace,flags,bytesperrow,screen)
{
_hotspot=hotspot;
_hotspot.ConstrainTo(Bounds());
fHotSpot=hotspot;
fHotSpot.ConstrainTo(Bounds());
_AllocateBuffer();
}
@@ -58,7 +58,7 @@ ServerCursor::ServerCursor(int8 *data)
// to RGBA32. Eventually, there will be support for 16 and 8-bit depths
if(data)
{
_initialized=true;
fInitialized=true;
uint32 black=0xFF000000,
white=0xFFFFFFFF,
*bmppos;
@@ -68,13 +68,14 @@ ServerCursor::ServerCursor(int8 *data)
cursorpos=(uint16*)(data+4);
maskpos=(uint16*)(data+36);
fHotSpot.Set(data[3],data[2]);
_AllocateBuffer();
// for each row in the cursor data
for(j=0;j<16;j++)
{
bmppos=(uint32*)(_buffer+ (j*BytesPerRow()) );
bmppos=(uint32*)(fBuffer+ (j*BytesPerRow()) );
// On intel, our bytes end up swapped, so we must swap them back
cursorflip=(cursorpos[j] & 0xFF) << 8;
@@ -96,10 +97,10 @@ ServerCursor::ServerCursor(int8 *data)
}
else
{
_width=0;
_height=0;
_bytesperrow=0;
_space=B_NO_COLOR_SPACE;
fWidth=0;
fHeight=0;
fBytesPerRow=0;
fSpace=B_NO_COLOR_SPACE;
}
}
@@ -111,13 +112,13 @@ ServerCursor::ServerCursor(const ServerCursor *cursor)
: ServerBitmap(cursor)
{
_AllocateBuffer();
_initialized=true;
fInitialized=true;
if(cursor)
{
if(cursor->_buffer)
memcpy(_buffer, cursor->_buffer, BitsLength());
_hotspot=cursor->_hotspot;
if(cursor->fBuffer)
memcpy(fBuffer, cursor->fBuffer, BitsLength());
fHotSpot=cursor->fHotSpot;
}
}
@@ -133,11 +134,11 @@ ServerCursor::~ServerCursor(void)
*/
void ServerCursor::SetHotSpot(BPoint pt)
{
_hotspot=pt;
_hotspot.ConstrainTo(Bounds());
fHotSpot=pt;
fHotSpot.ConstrainTo(Bounds());
}
void ServerCursor::SetAppSignature(const char *signature)
{
_app_signature.SetTo( (signature)?signature:"" );
fAppSignature.SetTo( (signature)?signature:"" );
}
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+37 -20
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -29,6 +29,7 @@
#include <Rect.h>
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <View.h> // for B_XXXXX_MOUSE_BUTTON defines
#include <Message.h>
#include <GraphicsDefs.h>
@@ -50,7 +51,7 @@
#include "CursorManager.h"
#include "Workspace.h"
#define DEBUG_SERVERWINDOW
//#define DEBUG_SERVERWINDOW
//#define DEBUG_SERVERWINDOW_MOUSE
//#define DEBUG_SERVERWINDOW_KEYBOARD
@@ -1891,10 +1892,11 @@ void ServerWindow::DispatchMessage(int32 code)
pointlist=new BPoint[pointcount];
fSession->Read(pointlist, sizeof(BPoint)*pointcount);
for(int32 i=0; i<pointcount; i++)
pointlist[i]=cl->ConvertToTop(pointlist[i]);
// TODO: modify DisplayDriver::StrokePolygon to utilize a boundary BRect
desktop->GetDisplayDriver()->StrokePolygon(pointlist,pointcount,polyframe,
cl->fLayerData,isclosed);
@@ -1905,12 +1907,10 @@ void ServerWindow::DispatchMessage(int32 code)
case AS_FILL_POLYGON:
{
BRect polyframe;
bool isclosed;
int32 pointcount;
BPoint *pointlist;
fSession->Read<BRect>(&polyframe);
fSession->Read<bool>(&isclosed);
fSession->Read<int32>(&pointcount);
pointlist=new BPoint[pointcount];
@@ -1920,8 +1920,7 @@ void ServerWindow::DispatchMessage(int32 code)
for(int32 i=0; i<pointcount; i++)
pointlist[i]=cl->ConvertToTop(pointlist[i]);
// TODO: modify DisplayDriver::FillPolygon to utilize a boundary BRect
desktop->GetDisplayDriver()->StrokePolygon(pointlist,pointcount,polyframe,cl->fLayerData);
desktop->GetDisplayDriver()->FillPolygon(pointlist,pointcount,polyframe,cl->fLayerData);
delete [] pointlist;
@@ -1984,7 +1983,6 @@ void ServerWindow::DispatchMessage(int32 code)
}
case AS_FILL_REGION:
{
// TODO: Implement AS_FILL_REGION
int32 rectcount;
BRect *rectlist;
@@ -1998,7 +1996,7 @@ void ServerWindow::DispatchMessage(int32 code)
// in repeatedly calling FillRect(), this is definitely in need of optimization. At
// least it works for now. :)
for(int32 i=0; i<rectcount; i++)
desktop->GetDisplayDriver()->FillRect(cl->ConvertToTop(cl->ConvertToTop(rectlist[i])),cl->fLayerData);
desktop->GetDisplayDriver()->FillRect(cl->ConvertToTop(rectlist[i]),cl->fLayerData);
delete [] rectlist;
@@ -2012,34 +2010,53 @@ void ServerWindow::DispatchMessage(int32 code)
// TODO: Implement AS_STROKE_LINEARRAY
break;
}
case AS_MOVEPENBY:
case AS_DRAW_STRING:
{
// TODO: Implement AS_MOVEPENBY
char *string;
int32 length;
BPoint location;
escapement_delta delta;
fSession->Read<BPoint>(&location);
fSession->Read<escapement_delta>(&delta);
fSession->ReadString(&string);
if(cl && cl->fLayerData)
desktop->GetDisplayDriver()->DrawString(string,length,cl->ConvertToTop(location),
cl->fLayerData);
free(string);
break;
}
case AS_MOVEPENTO:
{
// TODO: Implement AS_MOVEPENTO
float x,y;
fSession->Read<float>(&x);
fSession->Read<float>(&y);
if(cl && cl->fLayerData)
cl->fLayerData->penlocation.Set(x,y);
break;
}
case AS_SETPENSIZE:
{
// TODO: Implement AS_SETPENSIZE
break;
}
case AS_DRAW_STRING:
{
// TODO: Implement AS_DRAW_STRING
float size;
fSession->Read<float>(&size);
if(cl && cl->fLayerData)
cl->fLayerData->pensize=size;
break;
}
case AS_SET_FONT:
{
// TODO: Implement AS_SET_FONT
// TODO: Implement AS_SET_FONT?
break;
}
case AS_SET_FONT_SIZE:
{
// TODO: Implement AS_SET_FONT_SIZE
// TODO: Implement AS_SET_FONT_SIZE?
break;
}
default:
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+14 -14
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -244,7 +244,7 @@ void VDView::MessageReceived(BMessage *msg)
}
VDWindow::VDWindow(BRect frame)
: BWindow(frame, "OpenBeOS App Server", B_TITLED_WINDOW,
: BWindow(frame, "Haiku App Server", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
view=new VDView(Bounds());
@@ -466,11 +466,11 @@ void VDWindow::WindowActivated(bool active)
ViewDriver::ViewDriver(void)
{
_displaymode.virtual_width=640;
_displaymode.virtual_height=480;
_displaymode.space=B_RGBA32;
fDisplayMode.virtual_width=640;
fDisplayMode.virtual_height=480;
fDisplayMode.space=B_RGBA32;
screenwin=new VDWindow(BRect(0,0,_displaymode.virtual_width-1,_displaymode.virtual_height-1).OffsetToCopy(offset));
screenwin=new VDWindow(BRect(0,0,fDisplayMode.virtual_width-1,fDisplayMode.virtual_height-1).OffsetToCopy(offset));
framebuffer=screenwin->view->viewbmp;
serverlink=screenwin->view->serverlink;
hide_cursor=0;
@@ -527,9 +527,9 @@ void ViewDriver::SetMode(const display_mode &mode)
if(!is_initialized)
return;
if (_displaymode.virtual_width==mode.virtual_width &&
_displaymode.virtual_height==mode.virtual_height &&
_displaymode.space==mode.space)
if (fDisplayMode.virtual_width==mode.virtual_width &&
fDisplayMode.virtual_height==mode.virtual_height &&
fDisplayMode.space==mode.space)
{
return;
}
@@ -930,8 +930,8 @@ status_t ViewDriver::GetDeviceInfo(accelerant_device_info *info)
// a software-only driver, but we'll have some fun, anyway.
info->version=100;
sprintf(info->name,"OpenBeOS ViewDriver");
sprintf(info->chipset,"OpenBeOS Chipset");
sprintf(info->name,"Haiku, Inc. ViewDriver");
sprintf(info->chipset,"Haiku, Inc. Chipset");
sprintf(info->serial_no,"3.14159265358979323846");
info->memory=134217728; // 128 MB, not that we really have that much. :)
info->dac_speed=0xFFFFFFFF; // *heh*
@@ -1083,7 +1083,7 @@ void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
return;
}
if(((uint32)destbmp->ColorSpace() & 0x000F) != (_displaymode.space & 0x000F))
if(((uint32)destbmp->ColorSpace() & 0x000F) != (fDisplayMode.space & 0x000F))
{
printf("CopyToBitmap returned - unequal buffer pixel depth\n");
return;
@@ -1117,7 +1117,7 @@ void ViewDriver::CopyToBitmap(ServerBitmap *destbmp, const BRect &sourcerect)
destrect.bottom = work_rect.bottom;
}
work_rect.Set(0,0,_displaymode.virtual_width-1,_displaymode.virtual_height-1);
work_rect.Set(0,0,fDisplayMode.virtual_width-1,fDisplayMode.virtual_height-1);
if(!work_rect.Contains(sourcerect))
return;
@@ -1211,6 +1211,6 @@ void ViewDriver::Invalidate(const BRect &r)
return;
screenwin->Lock();
screenwin->view->Invalidate();
screenwin->view->Draw(r);
screenwin->Unlock();
}
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
+2 -2
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@@ -1525,4 +1525,4 @@ void Workspace::RemoveItem(ListData *item)
fCurrentItem = NULL;
}
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
+1 -1
View File
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2002, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),