app_server memory management: use ObjectDeleter to mark ownership
Make object ownership explicit by use of ObjectDeleter where possible. Change-Id: I499a00aa3390d1510ae284419e73faffa5166430 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2695 Reviewed-by: Adrien Destugues <[email protected]> Reviewed-by: Alex von Gluck IV <[email protected]>
This commit is contained in:
@@ -465,8 +465,6 @@ Desktop::Desktop(uid_t userID, const char* targetScreen)
|
||||
|
||||
Desktop::~Desktop()
|
||||
{
|
||||
delete fSettings;
|
||||
|
||||
delete_area(fSharedReadOnlyArea);
|
||||
delete_port(fMessagePort);
|
||||
gFontManager->DetachUser(fUserID);
|
||||
@@ -504,7 +502,7 @@ Desktop::Init()
|
||||
|
||||
gFontManager->AttachUser(fUserID);
|
||||
|
||||
fSettings = new DesktopSettingsPrivate(fServerReadOnlyMemory);
|
||||
fSettings.SetTo(new DesktopSettingsPrivate(fServerReadOnlyMemory));
|
||||
|
||||
for (int32 i = 0; i < kMaxWorkspaces; i++) {
|
||||
_Windows(i).SetIndex(i);
|
||||
@@ -2562,10 +2560,10 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
if (link.ReadString(&appSignature) != B_OK)
|
||||
break;
|
||||
|
||||
ServerApp* app = new (std::nothrow) ServerApp(this, clientReplyPort,
|
||||
clientLooperPort, clientTeamID, htoken, appSignature);
|
||||
ObjectDeleter<ServerApp> app(new (std::nothrow) ServerApp(this, clientReplyPort,
|
||||
clientLooperPort, clientTeamID, htoken, appSignature));
|
||||
status_t status = B_OK;
|
||||
if (app == NULL)
|
||||
if (app.Get() == NULL)
|
||||
status = B_NO_MEMORY;
|
||||
if (status == B_OK)
|
||||
status = app->InitCheck();
|
||||
@@ -2574,11 +2572,9 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
if (status == B_OK) {
|
||||
// add the new ServerApp to the known list of ServerApps
|
||||
fApplicationsLock.Lock();
|
||||
fApplications.AddItem(app);
|
||||
fApplications.AddItem(app.Detach());
|
||||
fApplicationsLock.Unlock();
|
||||
} else {
|
||||
delete app;
|
||||
|
||||
// if everything went well, ServerApp::Run() will notify
|
||||
// the client - but since it didn't, we do it here
|
||||
BPrivate::LinkSender reply(clientReplyPort);
|
||||
@@ -3773,13 +3769,11 @@ Desktop::_SetWorkspace(int32 index, bool moveFocusWindow)
|
||||
} else {
|
||||
// We need to remember the previous visible region of the
|
||||
// window if they changed their order
|
||||
BRegion* region = new (std::nothrow)
|
||||
BRegion(window->VisibleRegion());
|
||||
if (region != NULL) {
|
||||
if (previousRegions.AddItem(region))
|
||||
ObjectDeleter<BRegion> region(new (std::nothrow)
|
||||
BRegion(window->VisibleRegion()));
|
||||
if (region.Get() != NULL) {
|
||||
if (previousRegions.AddItem(region.Detach()))
|
||||
windows.AddWindow(window);
|
||||
else
|
||||
delete region;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
#define DESKTOP_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Autolock.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <List.h>
|
||||
#include <Menu.h>
|
||||
#include <ObjectList.h>
|
||||
#include <Region.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <ServerProtocolStructs.h>
|
||||
@@ -326,7 +328,8 @@ private:
|
||||
uid_t fUserID;
|
||||
char* fTargetScreen;
|
||||
::VirtualScreen fVirtualScreen;
|
||||
DesktopSettingsPrivate* fSettings;
|
||||
ObjectDeleter<DesktopSettingsPrivate>
|
||||
fSettings;
|
||||
port_id fMessagePort;
|
||||
::EventDispatcher fEventDispatcher;
|
||||
area_id fSharedReadOnlyArea;
|
||||
|
||||
@@ -830,7 +830,7 @@ DesktopSettingsPrivate::_ValidateWorkspacesLayout(int32& columns,
|
||||
|
||||
DesktopSettings::DesktopSettings(Desktop* desktop)
|
||||
:
|
||||
fSettings(desktop->fSettings)
|
||||
fSettings(desktop->fSettings.Get())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ DrawState::DrawState()
|
||||
fCombinedScale(1.0f),
|
||||
fTransform(),
|
||||
fCombinedTransform(),
|
||||
fClippingRegion(NULL),
|
||||
fAlphaMask(NULL),
|
||||
|
||||
fHighColor((rgb_color){ 0, 0, 0, 255 }),
|
||||
@@ -63,8 +62,7 @@ DrawState::DrawState()
|
||||
fLineCapMode(B_BUTT_CAP),
|
||||
fLineJoinMode(B_MITER_JOIN),
|
||||
fMiterLimit(B_DEFAULT_MITER_LIMIT),
|
||||
fFillRule(B_NONZERO),
|
||||
fPreviousState(NULL)
|
||||
fFillRule(B_NONZERO)
|
||||
{
|
||||
fUnscaledFontSize = fFont.Size();
|
||||
}
|
||||
@@ -118,8 +116,6 @@ DrawState::DrawState(const DrawState& other)
|
||||
|
||||
DrawState::~DrawState()
|
||||
{
|
||||
delete fClippingRegion;
|
||||
delete fPreviousState;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +129,7 @@ DrawState::PushState()
|
||||
next->fOrigin = BPoint(0.0, 0.0);
|
||||
next->fScale = 1.0;
|
||||
next->fTransform.Reset();
|
||||
next->fPreviousState = this;
|
||||
next->fPreviousState.SetTo(this);
|
||||
next->SetAlphaMask(fAlphaMask);
|
||||
}
|
||||
|
||||
@@ -144,12 +140,7 @@ DrawState::PushState()
|
||||
DrawState*
|
||||
DrawState::PopState()
|
||||
{
|
||||
DrawState* previous = PreviousState();
|
||||
|
||||
fPreviousState = NULL;
|
||||
delete this;
|
||||
|
||||
return previous;
|
||||
return fPreviousState.Detach();
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +244,7 @@ DrawState::ReadFromLink(BPrivate::LinkReceiver& link)
|
||||
fAlphaFncMode = info.alphaFunctionMode;
|
||||
fFontAliasing = info.fontAntialiasing;
|
||||
|
||||
if (fPreviousState != NULL) {
|
||||
if (fPreviousState.Get() != NULL) {
|
||||
fCombinedOrigin = fPreviousState->fCombinedOrigin + fOrigin;
|
||||
fCombinedScale = fPreviousState->fCombinedScale * fScale;
|
||||
fCombinedTransform = fPreviousState->fCombinedTransform * fTransform;
|
||||
@@ -332,7 +323,7 @@ DrawState::WriteToLink(BPrivate::LinkSender& link) const
|
||||
|
||||
// TODO: Could be optimized, but is low prio, since most views do not
|
||||
// use a custom clipping region...
|
||||
if (fClippingRegion != NULL) {
|
||||
if (fClippingRegion.Get() != NULL) {
|
||||
int32 clippingRectCount = fClippingRegion->CountRects();
|
||||
link.Attach<int32>(clippingRectCount);
|
||||
for (int i = 0; i < clippingRectCount; i++)
|
||||
@@ -351,7 +342,7 @@ DrawState::SetOrigin(BPoint origin)
|
||||
|
||||
// NOTE: the origins of earlier states are never expected to
|
||||
// change, only the topmost state ever changes
|
||||
if (fPreviousState != NULL) {
|
||||
if (fPreviousState.Get() != NULL) {
|
||||
fCombinedOrigin.x = fPreviousState->fCombinedOrigin.x
|
||||
+ fOrigin.x * fPreviousState->fCombinedScale;
|
||||
fCombinedOrigin.y = fPreviousState->fCombinedOrigin.y
|
||||
@@ -372,7 +363,7 @@ DrawState::SetScale(float scale)
|
||||
|
||||
// NOTE: the scales of earlier states are never expected to
|
||||
// change, only the topmost state ever changes
|
||||
if (fPreviousState != NULL)
|
||||
if (fPreviousState.Get() != NULL)
|
||||
fCombinedScale = fPreviousState->fCombinedScale * fScale;
|
||||
else
|
||||
fCombinedScale = fScale;
|
||||
@@ -394,7 +385,7 @@ DrawState::SetTransform(BAffineTransform transform)
|
||||
|
||||
// NOTE: the transforms of earlier states are never expected to
|
||||
// change, only the topmost state ever changes
|
||||
if (fPreviousState != NULL)
|
||||
if (fPreviousState.Get() != NULL)
|
||||
fCombinedTransform = fPreviousState->fCombinedTransform * fTransform;
|
||||
else
|
||||
fCombinedTransform = fTransform;
|
||||
@@ -429,13 +420,12 @@ void
|
||||
DrawState::SetClippingRegion(const BRegion* region)
|
||||
{
|
||||
if (region) {
|
||||
if (fClippingRegion != NULL)
|
||||
*fClippingRegion = *region;
|
||||
if (fClippingRegion.Get() != NULL)
|
||||
*fClippingRegion.Get() = *region;
|
||||
else
|
||||
fClippingRegion = new(nothrow) BRegion(*region);
|
||||
fClippingRegion.SetTo(new(nothrow) BRegion(*region));
|
||||
} else {
|
||||
delete fClippingRegion;
|
||||
fClippingRegion = NULL;
|
||||
fClippingRegion.Unset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,9 +433,9 @@ DrawState::SetClippingRegion(const BRegion* region)
|
||||
bool
|
||||
DrawState::HasClipping() const
|
||||
{
|
||||
if (fClippingRegion != NULL)
|
||||
if (fClippingRegion.Get() != NULL)
|
||||
return true;
|
||||
if (fPreviousState != NULL)
|
||||
if (fPreviousState.Get() != NULL)
|
||||
return fPreviousState->HasClipping();
|
||||
return false;
|
||||
}
|
||||
@@ -454,26 +444,26 @@ DrawState::HasClipping() const
|
||||
bool
|
||||
DrawState::HasAdditionalClipping() const
|
||||
{
|
||||
return fClippingRegion != NULL;
|
||||
return fClippingRegion.Get() != NULL;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DrawState::GetCombinedClippingRegion(BRegion* region) const
|
||||
{
|
||||
if (fClippingRegion != NULL) {
|
||||
BRegion localTransformedClipping(*fClippingRegion);
|
||||
if (fClippingRegion.Get() != NULL) {
|
||||
BRegion localTransformedClipping(*fClippingRegion.Get());
|
||||
SimpleTransform penTransform;
|
||||
Transform(penTransform);
|
||||
penTransform.Apply(&localTransformedClipping);
|
||||
if (fPreviousState != NULL
|
||||
if (fPreviousState.Get() != NULL
|
||||
&& fPreviousState->GetCombinedClippingRegion(region)) {
|
||||
localTransformedClipping.IntersectWith(region);
|
||||
}
|
||||
*region = localTransformedClipping;
|
||||
return true;
|
||||
} else {
|
||||
if (fPreviousState != NULL)
|
||||
if (fPreviousState.Get() != NULL)
|
||||
return fPreviousState->GetCombinedClippingRegion(region);
|
||||
}
|
||||
return false;
|
||||
@@ -516,16 +506,16 @@ DrawState::ClipToRect(BRect rect, bool inverse)
|
||||
}
|
||||
|
||||
if (inverse) {
|
||||
if (fClippingRegion == NULL) {
|
||||
fClippingRegion = new(nothrow) BRegion(BRect(
|
||||
-(1 << 16), -(1 << 16), (1 << 16), (1 << 16)));
|
||||
if (fClippingRegion.Get() == NULL) {
|
||||
fClippingRegion.SetTo(new(nothrow) BRegion(BRect(
|
||||
-(1 << 16), -(1 << 16), (1 << 16), (1 << 16))));
|
||||
// TODO: we should have a definition for a rect (or region)
|
||||
// with "infinite" area. For now, this region size should do...
|
||||
}
|
||||
fClippingRegion->Exclude(rect);
|
||||
} else {
|
||||
if (fClippingRegion == NULL)
|
||||
fClippingRegion = new(nothrow) BRegion(rect);
|
||||
if (fClippingRegion.Get() == NULL)
|
||||
fClippingRegion.SetTo(new(nothrow) BRegion(rect));
|
||||
else {
|
||||
BRegion rectRegion(rect);
|
||||
fClippingRegion->IntersectWith(&rectRegion);
|
||||
@@ -837,7 +827,7 @@ DrawState::PrintToStream() const
|
||||
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %.2f\n",
|
||||
(int16)fLineCapMode, (int16)fLineJoinMode, fMiterLimit);
|
||||
|
||||
if (fClippingRegion != NULL)
|
||||
if (fClippingRegion.Get() != NULL)
|
||||
fClippingRegion->PrintToStream();
|
||||
|
||||
printf("\t ===== Font Data =====\n");
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#define _DRAW_STATE_H_
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <AffineTransform.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
@@ -44,7 +45,8 @@ public:
|
||||
|
||||
DrawState* PushState();
|
||||
DrawState* PopState();
|
||||
DrawState* PreviousState() const { return fPreviousState; }
|
||||
DrawState* PreviousState() const
|
||||
{ return fPreviousState.Get(); }
|
||||
|
||||
uint16 ReadFontFromLink(BPrivate::LinkReceiver& link);
|
||||
// NOTE: ReadFromLink() does not read Font state!!
|
||||
@@ -176,7 +178,8 @@ protected:
|
||||
BAffineTransform fTransform;
|
||||
BAffineTransform fCombinedTransform;
|
||||
|
||||
BRegion* fClippingRegion;
|
||||
ObjectDeleter<BRegion>
|
||||
fClippingRegion;
|
||||
|
||||
BReference<AlphaMask> fAlphaMask;
|
||||
|
||||
@@ -220,7 +223,8 @@ protected:
|
||||
// of the font (again) when the scale changes
|
||||
float fUnscaledFontSize;
|
||||
|
||||
DrawState* fPreviousState;
|
||||
ObjectDeleter<DrawState>
|
||||
fPreviousState;
|
||||
};
|
||||
|
||||
#endif // _DRAW_STATE_H_
|
||||
|
||||
@@ -343,9 +343,9 @@ EventDispatcher::RemoveTarget(EventTarget& target)
|
||||
if (fPreviousMouseTarget == &target)
|
||||
fPreviousMouseTarget = NULL;
|
||||
|
||||
if (fKeyboardFilter != NULL)
|
||||
if (fKeyboardFilter.Get() != NULL)
|
||||
fKeyboardFilter->RemoveTarget(&target);
|
||||
if (fMouseFilter != NULL)
|
||||
if (fMouseFilter.Get() != NULL)
|
||||
fMouseFilter->RemoveTarget(&target);
|
||||
|
||||
fTargets.RemoveItem(&target);
|
||||
@@ -468,11 +468,10 @@ EventDispatcher::SetMouseFilter(EventFilter* filter)
|
||||
{
|
||||
BAutolock _(this);
|
||||
|
||||
if (fMouseFilter == filter)
|
||||
if (fMouseFilter.Get() == filter)
|
||||
return;
|
||||
|
||||
delete fMouseFilter;
|
||||
fMouseFilter = filter;
|
||||
fMouseFilter.SetTo(filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -481,11 +480,10 @@ EventDispatcher::SetKeyboardFilter(EventFilter* filter)
|
||||
{
|
||||
BAutolock _(this);
|
||||
|
||||
if (fKeyboardFilter == filter)
|
||||
if (fKeyboardFilter.Get() == filter)
|
||||
return;
|
||||
|
||||
delete fKeyboardFilter;
|
||||
fKeyboardFilter = filter;
|
||||
fKeyboardFilter.SetTo(filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -814,7 +812,7 @@ EventDispatcher::_EventLoop()
|
||||
#endif
|
||||
pointerEvent = true;
|
||||
|
||||
if (fMouseFilter == NULL)
|
||||
if (fMouseFilter.Get() == NULL)
|
||||
break;
|
||||
|
||||
EventTarget* mouseTarget = fPreviousMouseTarget;
|
||||
@@ -892,7 +890,7 @@ EventDispatcher::_EventLoop()
|
||||
case B_INPUT_METHOD_EVENT:
|
||||
ETRACE(("key event, focus = %p\n", fFocus));
|
||||
|
||||
if (fKeyboardFilter != NULL
|
||||
if (fKeyboardFilter.Get() != NULL
|
||||
&& fKeyboardFilter->Filter(event, &fFocus)
|
||||
== B_SKIP_MESSAGE) {
|
||||
break;
|
||||
@@ -994,7 +992,7 @@ void
|
||||
EventDispatcher::_CursorLoop()
|
||||
{
|
||||
BPoint where;
|
||||
const bigtime_t toolTipDelay = BToolTipManager::Manager()->ShowDelay();
|
||||
const bigtime_t toolTipDelay = BToolTipManager::Manager()->ShowDelay();
|
||||
bool mouseIdleSent = true;
|
||||
status_t status = B_OK;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define EVENT_DISPATCHER_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Locker.h>
|
||||
#include <Message.h>
|
||||
#include <MessageFilter.h>
|
||||
@@ -137,8 +138,10 @@ class EventDispatcher : public BLocker {
|
||||
EventTarget* fFocus;
|
||||
bool fSuspendFocus;
|
||||
|
||||
EventFilter* fMouseFilter;
|
||||
EventFilter* fKeyboardFilter;
|
||||
ObjectDeleter <EventFilter>
|
||||
fMouseFilter;
|
||||
ObjectDeleter<EventFilter>
|
||||
fKeyboardFilter;
|
||||
|
||||
BObjectList<EventTarget> fTargets;
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ OffscreenWindow::OffscreenWindow(ServerBitmap* bitmap,
|
||||
fBitmap(bitmap),
|
||||
fHWInterface(new (nothrow) BitmapHWInterface(fBitmap))
|
||||
{
|
||||
if (!fHWInterface || !GetDrawingEngine())
|
||||
if (fHWInterface.Get() == NULL || !GetDrawingEngine())
|
||||
return;
|
||||
|
||||
fHWInterface->Initialize();
|
||||
GetDrawingEngine()->SetHWInterface(fHWInterface);
|
||||
GetDrawingEngine()->SetHWInterface(fHWInterface.Get());
|
||||
|
||||
fVisibleRegion.Set(fFrame);
|
||||
fVisibleContentRegion.Set(fFrame);
|
||||
@@ -50,11 +50,10 @@ OffscreenWindow::~OffscreenWindow()
|
||||
if (GetDrawingEngine())
|
||||
GetDrawingEngine()->SetHWInterface(NULL);
|
||||
|
||||
if (fHWInterface) {
|
||||
if (fHWInterface.Get() != NULL) {
|
||||
fHWInterface->LockExclusiveAccess();
|
||||
fHWInterface->Shutdown();
|
||||
fHWInterface->UnlockExclusiveAccess();
|
||||
delete fHWInterface;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "Window.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
|
||||
class BitmapHWInterface;
|
||||
class ServerBitmap;
|
||||
@@ -26,7 +28,8 @@ public:
|
||||
|
||||
private:
|
||||
ServerBitmap* fBitmap;
|
||||
BitmapHWInterface* fHWInterface;
|
||||
ObjectDeleter<BitmapHWInterface>
|
||||
fHWInterface;
|
||||
};
|
||||
|
||||
#endif // OFFSCREEN_WINDOW_H
|
||||
|
||||
@@ -50,9 +50,7 @@ Screen::Screen(::HWInterface *interface, int32 id)
|
||||
|
||||
Screen::Screen()
|
||||
:
|
||||
fID(-1),
|
||||
fDriver(NULL),
|
||||
fHWInterface(NULL)
|
||||
fID(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,8 +58,6 @@ Screen::Screen()
|
||||
Screen::~Screen()
|
||||
{
|
||||
Shutdown();
|
||||
delete fDriver;
|
||||
delete fHWInterface;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +67,7 @@ Screen::~Screen()
|
||||
status_t
|
||||
Screen::Initialize()
|
||||
{
|
||||
if (fHWInterface) {
|
||||
if (fHWInterface.Get() != NULL) {
|
||||
// init the graphics hardware
|
||||
return fHWInterface->Initialize();
|
||||
}
|
||||
@@ -83,7 +79,7 @@ Screen::Initialize()
|
||||
void
|
||||
Screen::Shutdown()
|
||||
{
|
||||
if (fHWInterface)
|
||||
if (fHWInterface.Get() != NULL)
|
||||
fHWInterface->Shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define SCREEN_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Accelerant.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Point.h>
|
||||
@@ -50,9 +51,9 @@ public:
|
||||
color_space ColorSpace() const;
|
||||
|
||||
inline DrawingEngine* GetDrawingEngine() const
|
||||
{ return fDriver; }
|
||||
{ return fDriver.Get(); }
|
||||
inline ::HWInterface* HWInterface() const
|
||||
{ return fHWInterface; }
|
||||
{ return fHWInterface.Get(); }
|
||||
|
||||
private:
|
||||
int32 _FindBestMode(const display_mode* modeList,
|
||||
@@ -60,8 +61,10 @@ private:
|
||||
uint32 colorspace, float frequency) const;
|
||||
|
||||
int32 fID;
|
||||
DrawingEngine* fDriver;
|
||||
::HWInterface* fHWInterface;
|
||||
ObjectDeleter<DrawingEngine>
|
||||
fDriver;
|
||||
ObjectDeleter< ::HWInterface>
|
||||
fHWInterface;
|
||||
};
|
||||
|
||||
#endif /* SCREEN_H */
|
||||
|
||||
@@ -85,8 +85,6 @@ ScreenManager::~ScreenManager()
|
||||
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
||||
screen_item* item = fScreenList.ItemAt(i);
|
||||
|
||||
delete item->screen;
|
||||
delete item->listener;
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +98,7 @@ ScreenManager::ScreenAt(int32 index) const
|
||||
|
||||
screen_item* item = fScreenList.ItemAt(index);
|
||||
if (item != NULL)
|
||||
return item->screen;
|
||||
return item->screen.Get();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -128,7 +126,7 @@ ScreenManager::AcquireScreens(ScreenOwner* owner, int32* wishList,
|
||||
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
||||
screen_item* item = fScreenList.ItemAt(i);
|
||||
|
||||
if (item->owner == NULL && list.AddItem(item->screen)) {
|
||||
if (item->owner == NULL && list.AddItem(item->screen.Get())) {
|
||||
item->owner = owner;
|
||||
added++;
|
||||
}
|
||||
@@ -146,7 +144,7 @@ ScreenManager::AcquireScreens(ScreenOwner* owner, int32* wishList,
|
||||
#endif
|
||||
if (interface != NULL) {
|
||||
screen_item* item = _AddHWInterface(interface);
|
||||
if (item != NULL && list.AddItem(item->screen)) {
|
||||
if (item != NULL && list.AddItem(item->screen.Get())) {
|
||||
item->owner = owner;
|
||||
added++;
|
||||
}
|
||||
@@ -168,7 +166,7 @@ ScreenManager::ReleaseScreens(ScreenList& list)
|
||||
for (int32 j = 0; j < list.CountItems(); j++) {
|
||||
Screen* screen = list.ItemAt(j);
|
||||
|
||||
if (item->screen == screen)
|
||||
if (item->screen.Get() == screen)
|
||||
item->owner = NULL;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +180,7 @@ ScreenManager::ScreenChanged(Screen* screen)
|
||||
|
||||
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
||||
screen_item* item = fScreenList.ItemAt(i);
|
||||
if (item->screen == screen)
|
||||
if (item->screen.Get() == screen)
|
||||
item->owner->ScreenChanged(screen);
|
||||
}
|
||||
}
|
||||
@@ -232,18 +230,18 @@ ScreenManager::_AddHWInterface(HWInterface* interface)
|
||||
screen_item* item = new(nothrow) screen_item;
|
||||
|
||||
if (item != NULL) {
|
||||
item->screen = screen;
|
||||
item->screen.SetTo(screen);
|
||||
item->owner = NULL;
|
||||
item->listener = new(nothrow) ScreenChangeListener(*this, screen);
|
||||
if (item->listener != NULL
|
||||
&& interface->AddListener(item->listener)) {
|
||||
item->listener.SetTo(
|
||||
new(nothrow) ScreenChangeListener(*this, screen));
|
||||
if (item->listener.Get() != NULL
|
||||
&& interface->AddListener(item->listener.Get())) {
|
||||
if (fScreenList.AddItem(item))
|
||||
return item;
|
||||
|
||||
interface->RemoveListener(item->listener);
|
||||
interface->RemoveListener(item->listener.Get());
|
||||
}
|
||||
|
||||
delete item->listener;
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define SCREEN_MANAGER_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Looper.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
@@ -54,9 +55,10 @@ class ScreenManager : public BLooper {
|
||||
|
||||
private:
|
||||
struct screen_item {
|
||||
Screen* screen;
|
||||
ObjectDeleter<Screen> screen;
|
||||
ScreenOwner* owner;
|
||||
HWInterfaceListener* listener;
|
||||
ObjectDeleter<HWInterfaceListener>
|
||||
listener;
|
||||
};
|
||||
|
||||
void _ScanDrivers();
|
||||
|
||||
@@ -111,9 +111,6 @@ ServerBitmap::~ServerBitmap()
|
||||
delete fMemory;
|
||||
} else
|
||||
delete[] fBuffer;
|
||||
|
||||
delete fOverlay;
|
||||
// deleting the overlay will also free the overlay buffer
|
||||
}
|
||||
|
||||
|
||||
@@ -181,14 +178,14 @@ ServerBitmap::AreaOffset() const
|
||||
void
|
||||
ServerBitmap::SetOverlay(::Overlay* overlay)
|
||||
{
|
||||
fOverlay = overlay;
|
||||
fOverlay.SetTo(overlay);
|
||||
}
|
||||
|
||||
|
||||
::Overlay*
|
||||
ServerBitmap::Overlay() const
|
||||
{
|
||||
return fOverlay;
|
||||
return fOverlay.Get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define SERVER_BITMAP_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Rect.h>
|
||||
#include <OS.h>
|
||||
@@ -96,7 +97,8 @@ protected:
|
||||
protected:
|
||||
ClientMemory fClientMemory;
|
||||
AreaMemory* fMemory;
|
||||
::Overlay* fOverlay;
|
||||
ObjectDeleter< ::Overlay>
|
||||
fOverlay;
|
||||
uint8* fBuffer;
|
||||
|
||||
int32 fWidth;
|
||||
|
||||
@@ -163,7 +163,6 @@ ServerWindow::ServerWindow(const char* title, ServerApp* app,
|
||||
fTitle(NULL),
|
||||
fDesktop(app->GetDesktop()),
|
||||
fServerApp(app),
|
||||
fWindow(NULL),
|
||||
fWindowAddedToDesktop(false),
|
||||
|
||||
fClientTeam(app->ClientTeam()),
|
||||
@@ -178,7 +177,6 @@ ServerWindow::ServerWindow(const char* title, ServerApp* app,
|
||||
fCurrentDrawingRegion(),
|
||||
fCurrentDrawingRegionValid(false),
|
||||
|
||||
fDirectWindowInfo(NULL),
|
||||
fIsDirectlyAccessing(false)
|
||||
{
|
||||
STRACE(("ServerWindow(%s)::ServerWindow()\n", title));
|
||||
@@ -206,7 +204,7 @@ ServerWindow::~ServerWindow()
|
||||
|
||||
if (!fWindow->IsOffscreenWindow()) {
|
||||
fWindowAddedToDesktop = false;
|
||||
fDesktop->RemoveWindow(fWindow);
|
||||
fDesktop->RemoveWindow(fWindow.Get());
|
||||
}
|
||||
|
||||
if (App() != NULL) {
|
||||
@@ -214,14 +212,14 @@ ServerWindow::~ServerWindow()
|
||||
fServerApp = NULL;
|
||||
}
|
||||
|
||||
delete fWindow;
|
||||
fWindow.Unset(); // TODO: is it really needed?
|
||||
|
||||
free(fTitle);
|
||||
delete_port(fMessagePort);
|
||||
|
||||
BPrivate::gDefaultTokens.RemoveToken(fServerToken);
|
||||
|
||||
delete fDirectWindowInfo;
|
||||
fDirectWindowInfo.Unset(); // TODO: is it really needed?
|
||||
STRACE(("ServerWindow(%p) will exit NOW\n", this));
|
||||
|
||||
delete_sem(fDeathSemaphore);
|
||||
@@ -281,15 +279,14 @@ ServerWindow::Init(BRect frame, window_look look, window_feel feel,
|
||||
|
||||
// We cannot call MakeWindow in the constructor, since it
|
||||
// is a virtual function!
|
||||
fWindow = MakeWindow(frame, fTitle, look, feel, flags, workspace);
|
||||
if (!fWindow || fWindow->InitCheck() != B_OK) {
|
||||
delete fWindow;
|
||||
fWindow = NULL;
|
||||
fWindow.SetTo(MakeWindow(frame, fTitle, look, feel, flags, workspace));
|
||||
if (fWindow.Get() == NULL || fWindow->InitCheck() != B_OK) {
|
||||
fWindow.Unset();
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (!fWindow->IsOffscreenWindow()) {
|
||||
fDesktop->AddWindow(fWindow);
|
||||
fDesktop->AddWindow(fWindow.Get());
|
||||
fWindowAddedToDesktop = true;
|
||||
}
|
||||
|
||||
@@ -308,7 +305,7 @@ ServerWindow::Window() const
|
||||
if (!fWindowAddedToDesktop)
|
||||
return NULL;
|
||||
|
||||
return fWindow;
|
||||
return fWindow.Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -351,8 +348,8 @@ ServerWindow::_Show()
|
||||
// TODO: Maybe we need to dispatch a message to the desktop to show/hide us
|
||||
// instead of doing it from this thread.
|
||||
fDesktop->UnlockSingleWindow();
|
||||
fDesktop->ShowWindow(fWindow);
|
||||
if (fDirectWindowInfo && fDirectWindowInfo->IsFullScreen())
|
||||
fDesktop->ShowWindow(fWindow.Get());
|
||||
if (fDirectWindowInfo.Get() != NULL && fDirectWindowInfo->IsFullScreen())
|
||||
_ResizeToFullScreen();
|
||||
|
||||
fDesktop->LockSingleWindow();
|
||||
@@ -371,7 +368,7 @@ ServerWindow::_Hide()
|
||||
return;
|
||||
|
||||
fDesktop->UnlockSingleWindow();
|
||||
fDesktop->HideWindow(fWindow);
|
||||
fDesktop->HideWindow(fWindow.Get());
|
||||
fDesktop->LockSingleWindow();
|
||||
}
|
||||
|
||||
@@ -411,8 +408,8 @@ ServerWindow::SetTitle(const char* newTitle)
|
||||
rename_thread(Thread(), name);
|
||||
}
|
||||
|
||||
if (fWindow != NULL)
|
||||
fDesktop->SetWindowTitle(fWindow, newTitle);
|
||||
if (fWindow.Get() != NULL)
|
||||
fDesktop->SetWindowTitle(fWindow.Get(), newTitle);
|
||||
}
|
||||
|
||||
|
||||
@@ -627,7 +624,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
"minimize: %d\n", Title(), minimize));
|
||||
|
||||
fDesktop->UnlockSingleWindow();
|
||||
fDesktop->MinimizeWindow(fWindow, minimize);
|
||||
fDesktop->MinimizeWindow(fWindow.Get(), minimize);
|
||||
fDesktop->LockSingleWindow();
|
||||
}
|
||||
break;
|
||||
@@ -645,9 +642,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
fDesktop->UnlockSingleWindow();
|
||||
|
||||
if (activate)
|
||||
fDesktop->SelectWindow(fWindow);
|
||||
fDesktop->SelectWindow(fWindow.Get());
|
||||
else
|
||||
fDesktop->SendWindowBehind(fWindow, NULL);
|
||||
fDesktop->SendWindowBehind(fWindow.Get(), NULL);
|
||||
|
||||
fDesktop->LockSingleWindow();
|
||||
break;
|
||||
@@ -668,7 +665,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
Title(), behindOf != NULL ? behindOf->Title() : "NULL"));
|
||||
|
||||
if (behindOf != NULL || token == -1) {
|
||||
fDesktop->SendWindowBehind(fWindow, behindOf);
|
||||
fDesktop->SendWindowBehind(fWindow.Get(), behindOf);
|
||||
status = B_OK;
|
||||
} else
|
||||
status = B_NAME_NOT_FOUND;
|
||||
@@ -730,7 +727,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
if (window == NULL || window->Feel() != B_NORMAL_WINDOW_FEEL) {
|
||||
status = B_BAD_VALUE;
|
||||
} else {
|
||||
status = fDesktop->AddWindowToSubset(fWindow, window)
|
||||
status = fDesktop->AddWindowToSubset(fWindow.Get(), window)
|
||||
? B_OK : B_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
@@ -750,7 +747,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
::Window* window = fDesktop->FindWindowByClientToken(token,
|
||||
App()->ClientTeam());
|
||||
if (window != NULL) {
|
||||
fDesktop->RemoveWindowFromSubset(fWindow, window);
|
||||
fDesktop->RemoveWindowFromSubset(fWindow.Get(), window);
|
||||
status = B_OK;
|
||||
} else
|
||||
status = B_BAD_VALUE;
|
||||
@@ -775,7 +772,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
}
|
||||
|
||||
if (status == B_OK && !fWindow->IsOffscreenWindow())
|
||||
fDesktop->SetWindowLook(fWindow, (window_look)look);
|
||||
fDesktop->SetWindowLook(fWindow.Get(), (window_look)look);
|
||||
|
||||
fLink.StartMessage(status);
|
||||
fLink.Flush();
|
||||
@@ -795,7 +792,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
}
|
||||
|
||||
if (status == B_OK && !fWindow->IsOffscreenWindow())
|
||||
fDesktop->SetWindowFeel(fWindow, (window_feel)feel);
|
||||
fDesktop->SetWindowFeel(fWindow.Get(), (window_feel)feel);
|
||||
|
||||
fLink.StartMessage(status);
|
||||
fLink.Flush();
|
||||
@@ -815,7 +812,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
}
|
||||
|
||||
if (status == B_OK && !fWindow->IsOffscreenWindow())
|
||||
fDesktop->SetWindowFlags(fWindow, flags);
|
||||
fDesktop->SetWindowFlags(fWindow.Get(), flags);
|
||||
|
||||
fLink.StartMessage(status);
|
||||
fLink.Flush();
|
||||
@@ -839,7 +836,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
#endif
|
||||
case AS_IS_FRONT_WINDOW:
|
||||
{
|
||||
bool isFront = fDesktop->FrontWindow() == fWindow;
|
||||
bool isFront = fDesktop->FrontWindow() == fWindow.Get();
|
||||
DTRACE(("ServerWindow %s: Message AS_IS_FRONT_WINDOW: %d\n",
|
||||
Title(), isFront));
|
||||
fLink.StartMessage(isFront ? B_OK : B_ERROR);
|
||||
@@ -866,7 +863,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
DTRACE(("ServerWindow %s: Message AS_SET_WORKSPACES %" B_PRIx32 "\n",
|
||||
Title(), newWorkspaces));
|
||||
|
||||
fDesktop->SetWindowWorkspaces(fWindow, newWorkspaces);
|
||||
fDesktop->SetWindowWorkspaces(fWindow.Get(), newWorkspaces);
|
||||
break;
|
||||
}
|
||||
case AS_WINDOW_RESIZE:
|
||||
@@ -888,7 +885,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
// pragmatically set window bounds
|
||||
// fLink.StartMessage(B_BUSY);
|
||||
// } else {
|
||||
fDesktop->ResizeWindowBy(fWindow,
|
||||
fDesktop->ResizeWindowBy(fWindow.Get(),
|
||||
xResizeTo - fWindow->Frame().Width(),
|
||||
yResizeTo - fWindow->Frame().Height());
|
||||
fLink.StartMessage(B_OK);
|
||||
@@ -913,7 +910,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
// pragmatically set window positions
|
||||
fLink.StartMessage(B_BUSY);
|
||||
} else {
|
||||
fDesktop->MoveWindowBy(fWindow, xMoveTo - fWindow->Frame().left,
|
||||
fDesktop->MoveWindowBy(fWindow.Get(),
|
||||
xMoveTo - fWindow->Frame().left,
|
||||
yMoveTo - fWindow->Frame().top);
|
||||
fLink.StartMessage(B_OK);
|
||||
}
|
||||
@@ -962,7 +960,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
|
||||
fLink.Flush();
|
||||
|
||||
fDesktop->NotifySizeLimitsChanged(fWindow, minWidth, maxWidth,
|
||||
fDesktop->NotifySizeLimitsChanged(fWindow.Get(), minWidth, maxWidth,
|
||||
minHeight, maxHeight);
|
||||
break;
|
||||
}
|
||||
@@ -974,12 +972,13 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
Title()));
|
||||
|
||||
int32 size;
|
||||
if (fWindow && link.Read<int32>(&size) == B_OK) {
|
||||
if (fWindow.Get() != NULL && link.Read<int32>(&size) == B_OK) {
|
||||
char buffer[size];
|
||||
if (link.Read(buffer, size) == B_OK) {
|
||||
BMessage settings;
|
||||
if (settings.Unflatten(buffer) == B_OK)
|
||||
fDesktop->SetWindowDecoratorSettings(fWindow, settings);
|
||||
fDesktop->SetWindowDecoratorSettings(
|
||||
fWindow.Get(), settings);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1014,7 +1013,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
case AS_SYSTEM_FONT_CHANGED:
|
||||
{
|
||||
// Has the all-window look
|
||||
fDesktop->FontsChanged(fWindow);
|
||||
fDesktop->FontsChanged(fWindow.Get());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1097,7 +1096,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
link.Read<bool>(&enable);
|
||||
|
||||
status_t status = B_OK;
|
||||
if (fDirectWindowInfo != NULL)
|
||||
if (fDirectWindowInfo.Get() != NULL)
|
||||
_DirectWindowSetFullScreen(enable);
|
||||
else
|
||||
status = B_BAD_TYPE;
|
||||
@@ -1170,7 +1169,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
|
||||
case AS_TALK_TO_DESKTOP_LISTENER:
|
||||
{
|
||||
if (fDesktop->MessageForListener(fWindow, fLink.Receiver(),
|
||||
if (fDesktop->MessageForListener(fWindow.Get(), fLink.Receiver(),
|
||||
fLink.Sender()))
|
||||
break;
|
||||
// unhandled message at least send an error if needed
|
||||
@@ -1352,7 +1351,7 @@ fDesktop->UnlockSingleWindow();
|
||||
// TODO: possible deadlock
|
||||
if (eventMask != 0 || options != 0) {
|
||||
if (options & B_LOCK_WINDOW_FOCUS)
|
||||
fDesktop->SetFocusLocked(fWindow);
|
||||
fDesktop->SetFocusLocked(fWindow.Get());
|
||||
fDesktop->EventDispatcher().AddTemporaryListener(EventTarget(),
|
||||
fCurrentView->Token(), eventMask, options);
|
||||
} else {
|
||||
@@ -4290,7 +4289,7 @@ ServerWindow::ScreenChanged(const BMessage* message)
|
||||
{
|
||||
SendMessageToClient(message);
|
||||
|
||||
if (fDirectWindowInfo != NULL && fDirectWindowInfo->IsFullScreen())
|
||||
if (fDirectWindowInfo.Get() != NULL && fDirectWindowInfo->IsFullScreen())
|
||||
_ResizeToFullScreen();
|
||||
}
|
||||
|
||||
@@ -4324,7 +4323,7 @@ ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState)
|
||||
{
|
||||
ASSERT_MULTI_LOCKED(fDesktop->WindowLocker());
|
||||
|
||||
if (fDirectWindowInfo == NULL)
|
||||
if (fDirectWindowInfo.Get() == NULL)
|
||||
return;
|
||||
|
||||
STRACE(("HandleDirectConnection(bufferState = %" B_PRId32 ", driverState = "
|
||||
@@ -4345,8 +4344,7 @@ ServerWindow::HandleDirectConnection(int32 bufferState, int32 driverState)
|
||||
// The client application didn't release the semaphore
|
||||
// within the given timeout. Or something else went wrong.
|
||||
// Deleting this member should make it crash.
|
||||
delete fDirectWindowInfo;
|
||||
fDirectWindowInfo = NULL;
|
||||
fDirectWindowInfo.Unset();
|
||||
} else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_START)
|
||||
fIsDirectlyAccessing = true;
|
||||
else if ((bufferState & B_DIRECT_MODE_MASK) == B_DIRECT_STOP)
|
||||
@@ -4465,10 +4463,10 @@ ServerWindow::_ResizeToFullScreen()
|
||||
screenFrame = fWindow->Screen()->Frame();
|
||||
}
|
||||
|
||||
fDesktop->MoveWindowBy(fWindow,
|
||||
fDesktop->MoveWindowBy(fWindow.Get(),
|
||||
screenFrame.left - fWindow->Frame().left,
|
||||
screenFrame.top - fWindow->Frame().top);
|
||||
fDesktop->ResizeWindowBy(fWindow,
|
||||
fDesktop->ResizeWindowBy(fWindow.Get(),
|
||||
screenFrame.Width() - fWindow->Frame().Width(),
|
||||
screenFrame.Height() - fWindow->Frame().Height());
|
||||
}
|
||||
@@ -4477,7 +4475,7 @@ ServerWindow::_ResizeToFullScreen()
|
||||
status_t
|
||||
ServerWindow::_EnableDirectWindowMode()
|
||||
{
|
||||
if (fDirectWindowInfo != NULL) {
|
||||
if (fDirectWindowInfo.Get() != NULL) {
|
||||
// already in direct window mode
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -4487,14 +4485,13 @@ ServerWindow::_EnableDirectWindowMode()
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
fDirectWindowInfo = new(std::nothrow) DirectWindowInfo;
|
||||
if (fDirectWindowInfo == NULL)
|
||||
fDirectWindowInfo.SetTo(new(std::nothrow) DirectWindowInfo);
|
||||
if (fDirectWindowInfo.Get() == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
status_t status = fDirectWindowInfo->InitCheck();
|
||||
if (status != B_OK) {
|
||||
delete fDirectWindowInfo;
|
||||
fDirectWindowInfo = NULL;
|
||||
fDirectWindowInfo.Unset();
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -4519,15 +4516,15 @@ ServerWindow::_DirectWindowSetFullScreen(bool enable)
|
||||
fDirectWindowInfo->DisableFullScreen();
|
||||
|
||||
// Resize window back to its original size
|
||||
fDesktop->MoveWindowBy(fWindow,
|
||||
fDesktop->MoveWindowBy(fWindow.Get(),
|
||||
originalFrame.left - fWindow->Frame().left,
|
||||
originalFrame.top - fWindow->Frame().top);
|
||||
fDesktop->ResizeWindowBy(fWindow,
|
||||
fDesktop->ResizeWindowBy(fWindow.Get(),
|
||||
originalFrame.Width() - fWindow->Frame().Width(),
|
||||
originalFrame.Height() - fWindow->Frame().Height());
|
||||
|
||||
fDesktop->HWInterface()->SetCursorVisible(true);
|
||||
}
|
||||
|
||||
fDesktop->SetWindowFeel(fWindow, feel);
|
||||
fDesktop->SetWindowFeel(fWindow.Get(), feel);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define SERVER_WINDOW_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Locker.h>
|
||||
#include <Message.h>
|
||||
@@ -106,7 +107,7 @@ public:
|
||||
void HandleDirectConnection(int32 bufferState,
|
||||
int32 driverState = 0);
|
||||
bool HasDirectFrameBufferAccess() const
|
||||
{ return fDirectWindowInfo != NULL; }
|
||||
{ return fDirectWindowInfo.Get() != NULL; }
|
||||
bool IsDirectlyAccessing() const
|
||||
{ return fIsDirectlyAccessing; }
|
||||
|
||||
@@ -152,7 +153,8 @@ private:
|
||||
|
||||
::Desktop* fDesktop;
|
||||
ServerApp* fServerApp;
|
||||
::Window* fWindow;
|
||||
ObjectDeleter< ::Window>
|
||||
fWindow;
|
||||
bool fWindowAddedToDesktop;
|
||||
|
||||
team_id fClientTeam;
|
||||
@@ -173,7 +175,8 @@ private:
|
||||
BRegion fCurrentDrawingRegion;
|
||||
bool fCurrentDrawingRegionValid;
|
||||
|
||||
DirectWindowInfo* fDirectWindowInfo;
|
||||
ObjectDeleter<DirectWindowInfo>
|
||||
fDirectWindowInfo;
|
||||
bool fIsDirectlyAccessing;
|
||||
};
|
||||
|
||||
|
||||
+21
-26
@@ -90,8 +90,6 @@ Window::Window(const BRect& frame, const char *name,
|
||||
|
||||
fRegionPool(),
|
||||
|
||||
fWindowBehaviour(NULL),
|
||||
fTopView(NULL),
|
||||
fWindow(window),
|
||||
fDrawingEngine(drawingEngine),
|
||||
fDesktop(window->Desktop()),
|
||||
@@ -140,7 +138,7 @@ Window::Window(const BRect& frame, const char *name,
|
||||
}
|
||||
}
|
||||
if (fFeel != kOffscreenWindowFeel)
|
||||
fWindowBehaviour = gDecorManager.AllocateWindowBehaviour(this);
|
||||
fWindowBehaviour.SetTo(gDecorManager.AllocateWindowBehaviour(this));
|
||||
|
||||
// do we need to change our size to let the decorator fit?
|
||||
// _ResizeBy() will adapt the frame for validity before resizing
|
||||
@@ -169,16 +167,12 @@ Window::Window(const BRect& frame, const char *name,
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
if (fTopView) {
|
||||
if (fTopView.Get() != NULL) {
|
||||
fTopView->DetachedFromWindow();
|
||||
delete fTopView;
|
||||
}
|
||||
|
||||
DetachFromWindowStack(false);
|
||||
|
||||
delete fWindowBehaviour;
|
||||
delete fDrawingEngine;
|
||||
|
||||
gDecorManager.CleanupForWindow(this);
|
||||
}
|
||||
|
||||
@@ -186,8 +180,8 @@ Window::~Window()
|
||||
status_t
|
||||
Window::InitCheck() const
|
||||
{
|
||||
if (fDrawingEngine == NULL
|
||||
|| (fFeel != kOffscreenWindowFeel && fWindowBehaviour == NULL))
|
||||
if (GetDrawingEngine() == NULL
|
||||
|| (fFeel != kOffscreenWindowFeel && fWindowBehaviour.Get() == NULL))
|
||||
return B_NO_MEMORY;
|
||||
// TODO: anything else?
|
||||
return B_OK;
|
||||
@@ -304,7 +298,7 @@ Window::MoveBy(int32 x, int32 y, bool moveStack)
|
||||
|
||||
fEffectiveDrawingRegionValid = false;
|
||||
|
||||
if (fTopView != NULL) {
|
||||
if (fTopView.Get() != NULL) {
|
||||
fTopView->MoveBy(x, y, NULL);
|
||||
fTopView->UpdateOverlay();
|
||||
}
|
||||
@@ -371,7 +365,7 @@ Window::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion, bool resizeStack)
|
||||
fContentRegionValid = false;
|
||||
fEffectiveDrawingRegionValid = false;
|
||||
|
||||
if (fTopView != NULL) {
|
||||
if (fTopView.Get() != NULL) {
|
||||
fTopView->ResizeBy(x, y, dirtyRegion);
|
||||
fTopView->UpdateOverlay();
|
||||
}
|
||||
@@ -405,7 +399,7 @@ Window::ScrollViewBy(View* view, int32 dx, int32 dy)
|
||||
// this is executed in ServerWindow with the Readlock
|
||||
// held
|
||||
|
||||
if (!view || view == fTopView || (dx == 0 && dy == 0))
|
||||
if (!view || view == fTopView.Get() || (dx == 0 && dy == 0))
|
||||
return;
|
||||
|
||||
BRegion* dirty = fRegionPool.GetRegion();
|
||||
@@ -521,9 +515,13 @@ Window::CopyContents(BRegion* region, int32 xOffset, int32 yOffset)
|
||||
void
|
||||
Window::SetTopView(View* topView)
|
||||
{
|
||||
fTopView = topView;
|
||||
if (fTopView.Get() != NULL) {
|
||||
fTopView->DetachedFromWindow();
|
||||
}
|
||||
|
||||
if (fTopView) {
|
||||
fTopView.SetTo(topView);
|
||||
|
||||
if (fTopView.Get() != NULL) {
|
||||
// the top view is special, it has a coordinate system
|
||||
// as if it was attached directly to the desktop, therefor,
|
||||
// the coordinate conversion through the view tree works
|
||||
@@ -621,8 +619,7 @@ Window::ReloadDecor()
|
||||
|
||||
stack->SetDecorator(decorator);
|
||||
|
||||
delete fWindowBehaviour;
|
||||
fWindowBehaviour = windowBehaviour;
|
||||
fWindowBehaviour.SetTo(windowBehaviour);
|
||||
|
||||
// set the correct focus and top layer tab
|
||||
for (int32 i = 0; i < stack->CountWindows(); i++) {
|
||||
@@ -1121,7 +1118,7 @@ Window::IsVisible() const
|
||||
bool
|
||||
Window::IsDragging() const
|
||||
{
|
||||
if (!fWindowBehaviour)
|
||||
if (fWindowBehaviour.Get() == NULL)
|
||||
return false;
|
||||
return fWindowBehaviour->IsDragging();
|
||||
}
|
||||
@@ -1130,7 +1127,7 @@ Window::IsDragging() const
|
||||
bool
|
||||
Window::IsResizing() const
|
||||
{
|
||||
if (!fWindowBehaviour)
|
||||
if (fWindowBehaviour.Get() == NULL)
|
||||
return false;
|
||||
return fWindowBehaviour->IsResizing();
|
||||
}
|
||||
@@ -1917,7 +1914,7 @@ Window::BeginUpdate(BPrivate::PortLink& link)
|
||||
if (fDrawingEngine->LockParallelAccess()) {
|
||||
fDrawingEngine->SuspendAutoSync();
|
||||
|
||||
fTopView->Draw(fDrawingEngine, dirty, &fContentRegion, true);
|
||||
fTopView->Draw(GetDrawingEngine(), dirty, &fContentRegion, true);
|
||||
|
||||
fDrawingEngine->Sync();
|
||||
fDrawingEngine->UnlockParallelAccess();
|
||||
@@ -2108,7 +2105,7 @@ Window::DetachFromWindowStack(bool ownStackNeeded)
|
||||
Window* remainingTop = fCurrentStack->TopLayerWindow();
|
||||
if (remainingTop != NULL) {
|
||||
if (decorator != NULL)
|
||||
decorator->SetDrawingEngine(remainingTop->fDrawingEngine);
|
||||
decorator->SetDrawingEngine(remainingTop->GetDrawingEngine());
|
||||
// propagate focus to the decorator
|
||||
remainingTop->SetFocus(remainingTop->IsFocus());
|
||||
remainingTop->SetLook(remainingTop->Look(), NULL);
|
||||
@@ -2220,7 +2217,7 @@ Window::MoveToTopStackLayer()
|
||||
::Decorator* decorator = Decorator();
|
||||
if (decorator == NULL)
|
||||
return false;
|
||||
decorator->SetDrawingEngine(fDrawingEngine);
|
||||
decorator->SetDrawingEngine(GetDrawingEngine());
|
||||
SetLook(Look(), NULL);
|
||||
decorator->SetTopTab(PositionInStack());
|
||||
return fCurrentStack->MoveToTopLayer(this);
|
||||
@@ -2277,22 +2274,20 @@ WindowStack::WindowStack(::Decorator* decorator)
|
||||
|
||||
WindowStack::~WindowStack()
|
||||
{
|
||||
delete fDecorator;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WindowStack::SetDecorator(::Decorator* decorator)
|
||||
{
|
||||
delete fDecorator;
|
||||
fDecorator = decorator;
|
||||
fDecorator.SetTo(decorator);
|
||||
}
|
||||
|
||||
|
||||
::Decorator*
|
||||
WindowStack::Decorator()
|
||||
{
|
||||
return fDecorator;
|
||||
return fDecorator.Get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "View.h"
|
||||
#include "WindowList.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <ObjectList.h>
|
||||
#include <Referenceable.h>
|
||||
#include <Region.h>
|
||||
@@ -53,7 +54,8 @@ public:
|
||||
bool MoveToTopLayer(Window* window);
|
||||
bool Move(int32 from, int32 to);
|
||||
private:
|
||||
::Decorator* fDecorator;
|
||||
ObjectDeleter< ::Decorator>
|
||||
fDecorator;
|
||||
|
||||
StackWindows fWindowList;
|
||||
StackWindows fWindowLayerOrder;
|
||||
@@ -133,7 +135,7 @@ public:
|
||||
void ScrollViewBy(View* view, int32 dx, int32 dy);
|
||||
|
||||
void SetTopView(View* topView);
|
||||
View* TopView() const { return fTopView; }
|
||||
View* TopView() const { return fTopView.Get(); }
|
||||
View* ViewAt(const BPoint& where);
|
||||
|
||||
virtual bool IsOffscreenWindow() const { return false; }
|
||||
@@ -167,7 +169,7 @@ public:
|
||||
{ return fUpdateRequested; }
|
||||
|
||||
DrawingEngine* GetDrawingEngine() const
|
||||
{ return fDrawingEngine; }
|
||||
{ return fDrawingEngine.Get(); }
|
||||
|
||||
// managing a region pool
|
||||
::RegionPool* RegionPool()
|
||||
@@ -362,10 +364,12 @@ protected:
|
||||
|
||||
BObjectList<Window> fSubsets;
|
||||
|
||||
WindowBehaviour* fWindowBehaviour;
|
||||
View* fTopView;
|
||||
ObjectDeleter<WindowBehaviour>
|
||||
fWindowBehaviour;
|
||||
ObjectDeleter<View> fTopView;
|
||||
::ServerWindow* fWindow;
|
||||
DrawingEngine* fDrawingEngine;
|
||||
ObjectDeleter<DrawingEngine>
|
||||
fDrawingEngine;
|
||||
::Desktop* fDesktop;
|
||||
|
||||
// The synchronization, which client drawing commands
|
||||
|
||||
@@ -685,7 +685,6 @@ DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
|
||||
:
|
||||
fWindow(window),
|
||||
fDesktop(window->Desktop()),
|
||||
fState(NULL),
|
||||
fLastModifiers(0)
|
||||
{
|
||||
}
|
||||
@@ -693,7 +692,6 @@ DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
|
||||
|
||||
DefaultWindowBehaviour::~DefaultWindowBehaviour()
|
||||
{
|
||||
delete fState;
|
||||
}
|
||||
|
||||
|
||||
@@ -726,7 +724,7 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where,
|
||||
}
|
||||
|
||||
// if a state is active, let it do the job
|
||||
if (fState != NULL) {
|
||||
if (fState.Get() != NULL) {
|
||||
bool unhandled = false;
|
||||
bool result = fState->MouseDown(message, where, unhandled);
|
||||
if (!unhandled)
|
||||
@@ -919,7 +917,7 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where,
|
||||
void
|
||||
DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
|
||||
{
|
||||
if (fState != NULL)
|
||||
if (fState.Get() != NULL)
|
||||
fState->MouseUp(message, where);
|
||||
}
|
||||
|
||||
@@ -927,7 +925,7 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
|
||||
void
|
||||
DefaultWindowBehaviour::MouseMoved(BMessage* message, BPoint where, bool isFake)
|
||||
{
|
||||
if (fState != NULL) {
|
||||
if (fState.Get() != NULL) {
|
||||
fState->MouseMoved(message, where, isFake);
|
||||
} else {
|
||||
// If the window modifiers are hold, enter the window management state.
|
||||
@@ -954,7 +952,7 @@ DefaultWindowBehaviour::ModifiersChanged(int32 modifiers)
|
||||
int32 buttons;
|
||||
fDesktop->GetLastMouseState(&where, &buttons);
|
||||
|
||||
if (fState != NULL) {
|
||||
if (fState.Get() != NULL) {
|
||||
fState->ModifiersChanged(where, modifiers);
|
||||
} else {
|
||||
// If the window modifiers are hold, enter the window management state.
|
||||
@@ -1166,21 +1164,19 @@ void
|
||||
DefaultWindowBehaviour::_NextState(State* state)
|
||||
{
|
||||
// exit the old state
|
||||
if (fState != NULL)
|
||||
if (fState.Get() != NULL)
|
||||
fState->ExitState(state);
|
||||
|
||||
// set and enter the new state
|
||||
State* oldState = fState;
|
||||
fState = state;
|
||||
ObjectDeleter<State> oldState(fState.Detach());
|
||||
fState.SetTo(state);
|
||||
|
||||
if (fState != NULL) {
|
||||
fState->EnterState(oldState);
|
||||
if (fState.Get() != NULL) {
|
||||
fState->EnterState(oldState.Get());
|
||||
fDesktop->SetMouseEventWindow(fWindow);
|
||||
} else if (oldState != NULL) {
|
||||
} else if (oldState.Get() != NULL) {
|
||||
// no state anymore -- reset the mouse event window, if it's still us
|
||||
if (fDesktop->MouseEventWindow() == fWindow)
|
||||
fDesktop->SetMouseEventWindow(NULL);
|
||||
}
|
||||
|
||||
delete oldState;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "MagneticBorder.h"
|
||||
#include "ServerCursor.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
|
||||
class Desktop;
|
||||
class Window;
|
||||
@@ -107,7 +109,8 @@ private:
|
||||
protected:
|
||||
Window* fWindow;
|
||||
Desktop* fDesktop;
|
||||
State* fState;
|
||||
ObjectDeleter<State>
|
||||
fState;
|
||||
int32 fLastModifiers;
|
||||
|
||||
MagneticBorder fMagneticBorder;
|
||||
|
||||
@@ -394,7 +394,6 @@ PictureAlphaMask::PictureAlphaMask(AlphaMask* previousMask,
|
||||
|
||||
PictureAlphaMask::~PictureAlphaMask()
|
||||
{
|
||||
delete fDrawState;
|
||||
}
|
||||
|
||||
|
||||
@@ -409,7 +408,7 @@ BRect
|
||||
PictureAlphaMask::DetermineBoundingBox() const
|
||||
{
|
||||
BRect boundingBox;
|
||||
PictureBoundingBoxPlayer::Play(fPicture, fDrawState, &boundingBox);
|
||||
PictureBoundingBoxPlayer::Play(fPicture, fDrawState.Get(), &boundingBox);
|
||||
|
||||
if (!boundingBox.IsValid())
|
||||
return boundingBox;
|
||||
@@ -428,7 +427,7 @@ PictureAlphaMask::DetermineBoundingBox() const
|
||||
const DrawState&
|
||||
PictureAlphaMask::GetDrawState() const
|
||||
{
|
||||
return *fDrawState;
|
||||
return *fDrawState.Get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
|
||||
private:
|
||||
BReference<ServerPicture> fPicture;
|
||||
DrawState* fDrawState;
|
||||
ObjectDeleter<DrawState> fDrawState;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ BBitmapBuffer::BBitmapBuffer(BBitmap* bitmap)
|
||||
// destructor
|
||||
BBitmapBuffer::~BBitmapBuffer()
|
||||
{
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
// InitCheck
|
||||
@@ -21,7 +20,7 @@ status_t
|
||||
BBitmapBuffer::InitCheck() const
|
||||
{
|
||||
status_t ret = B_NO_INIT;
|
||||
if (fBitmap)
|
||||
if (fBitmap.Get() != NULL)
|
||||
ret = fBitmap->InitCheck();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "RenderingBuffer.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
class BBitmap;
|
||||
|
||||
class BBitmapBuffer : public RenderingBuffer {
|
||||
@@ -22,10 +24,11 @@ class BBitmapBuffer : public RenderingBuffer {
|
||||
|
||||
// BBitmapBuffer
|
||||
const BBitmap* Bitmap() const
|
||||
{ return fBitmap; }
|
||||
{ return fBitmap.Get(); }
|
||||
private:
|
||||
|
||||
BBitmap* fBitmap;
|
||||
ObjectDeleter<BBitmap>
|
||||
fBitmap;
|
||||
};
|
||||
|
||||
#endif // B_BITMAP_BUFFER_H
|
||||
|
||||
@@ -33,8 +33,6 @@ BitmapHWInterface::BitmapHWInterface(ServerBitmap* bitmap)
|
||||
|
||||
BitmapHWInterface::~BitmapHWInterface()
|
||||
{
|
||||
delete fBackBuffer;
|
||||
delete fFrontBuffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,12 +54,11 @@ BitmapHWInterface::Initialize()
|
||||
&& fFrontBuffer->ColorSpace() != B_RGBA32) {
|
||||
BBitmap* backBitmap = new BBitmap(fFrontBuffer->Bounds(),
|
||||
B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
||||
fBackBuffer = new BBitmapBuffer(backBitmap);
|
||||
fBackBuffer.SetTo(new BBitmapBuffer(backBitmap));
|
||||
|
||||
ret = fBackBuffer->InitCheck();
|
||||
if (ret < B_OK) {
|
||||
delete fBackBuffer;
|
||||
fBackBuffer = NULL;
|
||||
fBackBuffer.Unset();
|
||||
} else {
|
||||
// import the current contents of the bitmap
|
||||
// into the back bitmap
|
||||
@@ -193,14 +190,14 @@ BitmapHWInterface::GetBrightness(float*)
|
||||
RenderingBuffer*
|
||||
BitmapHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
return fFrontBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
RenderingBuffer*
|
||||
BitmapHWInterface::BackBuffer() const
|
||||
{
|
||||
return fBackBuffer;
|
||||
return fBackBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +205,8 @@ bool
|
||||
BitmapHWInterface::IsDoubleBuffered() const
|
||||
{
|
||||
// overwrite double buffered preference
|
||||
if (fFrontBuffer)
|
||||
return fBackBuffer != NULL;
|
||||
if (fFrontBuffer.Get() != NULL)
|
||||
return fBackBuffer.Get() != NULL;
|
||||
|
||||
return HWInterface::IsDoubleBuffered();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
class BitmapBuffer;
|
||||
class MallocBuffer;
|
||||
class ServerBitmap;
|
||||
@@ -60,8 +62,10 @@ public:
|
||||
virtual bool IsDoubleBuffered() const;
|
||||
|
||||
private:
|
||||
BBitmapBuffer* fBackBuffer;
|
||||
BitmapBuffer* fFrontBuffer;
|
||||
ObjectDeleter<BBitmapBuffer>
|
||||
fBackBuffer;
|
||||
ObjectDeleter<BitmapBuffer>
|
||||
fFrontBuffer;
|
||||
};
|
||||
|
||||
#endif // BITMAP_HW_INTERFACE_H
|
||||
|
||||
@@ -356,8 +356,6 @@ DWindowHWInterface::~DWindowHWInterface()
|
||||
delete[] fRectParams;
|
||||
delete[] fBlitParams;
|
||||
|
||||
delete fFrontBuffer;
|
||||
|
||||
be_app->Lock();
|
||||
be_app->Quit();
|
||||
delete be_app;
|
||||
@@ -655,7 +653,7 @@ DWindowHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
status_t ret = B_OK;
|
||||
// prevent from doing the unnecessary
|
||||
if (fFrontBuffer
|
||||
if (fFrontBuffer.Get() != NULL
|
||||
&& fDisplayMode.virtual_width == mode.virtual_width
|
||||
&& fDisplayMode.virtual_height == mode.virtual_height
|
||||
&& fDisplayMode.space == mode.space)
|
||||
@@ -709,7 +707,7 @@ DWindowHWInterface::SetMode(const display_mode& mode)
|
||||
return ret;
|
||||
|
||||
fWindow = new DWindow(frame.OffsetByCopy(fXOffset, fYOffset), this,
|
||||
fFrontBuffer);
|
||||
fFrontBuffer.Get());
|
||||
|
||||
// fire up the window thread but don't show it on screen yet
|
||||
fWindow->Hide();
|
||||
@@ -774,7 +772,7 @@ DWindowHWInterface::GetDeviceInfo(accelerant_device_info* info)
|
||||
status_t
|
||||
DWindowHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
|
||||
{
|
||||
if (fFrontBuffer == NULL)
|
||||
if (fFrontBuffer.Get() == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
config.frame_buffer = fFrontBuffer->Bits();
|
||||
@@ -1071,14 +1069,14 @@ DWindowHWInterface::Sync()
|
||||
RenderingBuffer*
|
||||
DWindowHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
return fFrontBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
RenderingBuffer*
|
||||
DWindowHWInterface::BackBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
return fFrontBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Accelerant.h>
|
||||
#include <image.h>
|
||||
#include <Region.h>
|
||||
@@ -81,7 +82,8 @@ public:
|
||||
void SetOffset(int32 left, int32 top);
|
||||
|
||||
private:
|
||||
DWindowBuffer* fFrontBuffer;
|
||||
ObjectDeleter<DWindowBuffer>
|
||||
fFrontBuffer;
|
||||
|
||||
DWindow* fWindow;
|
||||
|
||||
|
||||
@@ -116,7 +116,6 @@ DrawingEngine::DrawingEngine(HWInterface* interface)
|
||||
DrawingEngine::~DrawingEngine()
|
||||
{
|
||||
SetHWInterface(NULL);
|
||||
delete fPainter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define DRAWING_ENGINE_H_
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Accelerant.h>
|
||||
#include <Font.h>
|
||||
#include <Locker.h>
|
||||
@@ -206,7 +207,8 @@ private:
|
||||
|
||||
inline void _CopyToFront(const BRect& frame);
|
||||
|
||||
Painter* fPainter;
|
||||
ObjectDeleter<Painter>
|
||||
fPainter;
|
||||
HWInterface* fGraphicsCard;
|
||||
uint32 fAvailableHWAccleration;
|
||||
int32 fSuspendSyncLevel;
|
||||
|
||||
@@ -411,9 +411,6 @@ ViewHWInterface::~ViewHWInterface()
|
||||
fWindow->Quit();
|
||||
}
|
||||
|
||||
delete fBackBuffer;
|
||||
delete fFrontBuffer;
|
||||
|
||||
be_app->Lock();
|
||||
be_app->Quit();
|
||||
}
|
||||
@@ -440,7 +437,7 @@ ViewHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
status_t ret = B_OK;
|
||||
// prevent from doing the unnecessary
|
||||
if (fBackBuffer && fFrontBuffer
|
||||
if (fBackBuffer.Get() != NULL && fFrontBuffer.Get() != NULL
|
||||
&& fDisplayMode.virtual_width == mode.virtual_width
|
||||
&& fDisplayMode.virtual_height == mode.virtual_height
|
||||
&& fDisplayMode.space == mode.space)
|
||||
@@ -508,9 +505,8 @@ ViewHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
// free and reallocate the bitmaps while the window is locked,
|
||||
// so that the view does not accidentally draw a freed bitmap
|
||||
delete fBackBuffer;
|
||||
fBackBuffer = NULL;
|
||||
delete fFrontBuffer;
|
||||
fBackBuffer.Unset();
|
||||
fFrontBuffer.Unset();
|
||||
|
||||
// NOTE: backbuffer is always B_RGBA32, this simplifies the
|
||||
// drawing backend implementation tremendously for the time
|
||||
@@ -526,12 +522,11 @@ ViewHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
BBitmap* frontBitmap
|
||||
= new BBitmap(frame, 0, (color_space)fDisplayMode.space);
|
||||
fFrontBuffer = new BBitmapBuffer(frontBitmap);
|
||||
fFrontBuffer.SetTo(new BBitmapBuffer(frontBitmap));
|
||||
|
||||
status_t err = fFrontBuffer->InitCheck();
|
||||
if (err < B_OK) {
|
||||
delete fFrontBuffer;
|
||||
fFrontBuffer = NULL;
|
||||
fFrontBuffer.Unset();
|
||||
ret = err;
|
||||
}
|
||||
|
||||
@@ -540,12 +535,11 @@ ViewHWInterface::SetMode(const display_mode& mode)
|
||||
// since we override IsDoubleBuffered(), the drawing buffer
|
||||
// is in effect also always B_RGBA32.
|
||||
BBitmap* backBitmap = new BBitmap(frame, 0, B_RGBA32);
|
||||
fBackBuffer = new BBitmapBuffer(backBitmap);
|
||||
fBackBuffer.SetTo(new BBitmapBuffer(backBitmap));
|
||||
|
||||
err = fBackBuffer->InitCheck();
|
||||
if (err < B_OK) {
|
||||
delete fBackBuffer;
|
||||
fBackBuffer = NULL;
|
||||
fBackBuffer.Unset();
|
||||
ret = err;
|
||||
}
|
||||
}
|
||||
@@ -555,7 +549,7 @@ ViewHWInterface::SetMode(const display_mode& mode)
|
||||
if (ret >= B_OK) {
|
||||
// clear out buffers, alpha is 255 this way
|
||||
// TODO: maybe this should handle different color spaces in different ways
|
||||
if (fBackBuffer)
|
||||
if (fBackBuffer.Get() != NULL)
|
||||
memset(fBackBuffer->Bits(), 255, fBackBuffer->BitsLength());
|
||||
memset(fFrontBuffer->Bits(), 255, fFrontBuffer->BitsLength());
|
||||
|
||||
@@ -609,7 +603,7 @@ ViewHWInterface::GetDeviceInfo(accelerant_device_info* info)
|
||||
status_t
|
||||
ViewHWInterface::GetFrameBufferConfig(frame_buffer_config& config)
|
||||
{
|
||||
if (fFrontBuffer == NULL)
|
||||
if (fFrontBuffer.Get() == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
config.frame_buffer = fFrontBuffer->Bits();
|
||||
@@ -769,22 +763,22 @@ ViewHWInterface::WaitForRetrace(bigtime_t timeout)
|
||||
RenderingBuffer*
|
||||
ViewHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
return fFrontBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
RenderingBuffer*
|
||||
ViewHWInterface::BackBuffer() const
|
||||
{
|
||||
return fBackBuffer;
|
||||
return fBackBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ViewHWInterface::IsDoubleBuffered() const
|
||||
{
|
||||
if (fFrontBuffer)
|
||||
return fBackBuffer != NULL;
|
||||
if (fFrontBuffer.Get() != NULL)
|
||||
return fBackBuffer.Get() != NULL;
|
||||
|
||||
return HWInterface::IsDoubleBuffered();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
class BBitmap;
|
||||
class BBitmapBuffer;
|
||||
@@ -63,8 +64,10 @@ public:
|
||||
virtual status_t CopyBackToFront(const BRect& frame);
|
||||
|
||||
private:
|
||||
BBitmapBuffer* fBackBuffer;
|
||||
BBitmapBuffer* fFrontBuffer;
|
||||
ObjectDeleter<BBitmapBuffer>
|
||||
fBackBuffer;
|
||||
ObjectDeleter<BBitmapBuffer>
|
||||
fFrontBuffer;
|
||||
|
||||
CardWindow* fWindow;
|
||||
|
||||
|
||||
@@ -177,9 +177,6 @@ AccelerantHWInterface::AccelerantHWInterface()
|
||||
|
||||
AccelerantHWInterface::~AccelerantHWInterface()
|
||||
{
|
||||
delete fBackBuffer;
|
||||
delete fFrontBuffer;
|
||||
|
||||
delete[] fRectParams;
|
||||
delete[] fBlitParams;
|
||||
|
||||
@@ -567,7 +564,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
// error.
|
||||
|
||||
// prevent from doing the unnecessary
|
||||
if (fModeCount > 0 && fFrontBuffer && fDisplayMode == mode) {
|
||||
if (fModeCount > 0 && fFrontBuffer.Get() != NULL && fDisplayMode == mode) {
|
||||
// TODO: better comparison of display modes
|
||||
return B_OK;
|
||||
}
|
||||
@@ -577,7 +574,7 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
if (!_IsValidMode(mode))
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (fFrontBuffer == NULL)
|
||||
if (fFrontBuffer.Get() == NULL)
|
||||
return B_NO_INIT;
|
||||
|
||||
// just try to set the mode - we let the graphics driver
|
||||
@@ -683,17 +680,17 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
fOffscreenBackBuffer = false;
|
||||
|
||||
// update backbuffer if neccessary
|
||||
if (!fBackBuffer || fBackBuffer->Width() != fFrontBuffer->Width()
|
||||
if (fBackBuffer.Get() == NULL
|
||||
|| fBackBuffer->Width() != fFrontBuffer->Width()
|
||||
|| fBackBuffer->Height() != fFrontBuffer->Height()
|
||||
|| fOffscreenBackBuffer
|
||||
|| (fFrontBuffer->ColorSpace() == B_RGB32 && fBackBuffer != NULL
|
||||
|| (fFrontBuffer->ColorSpace() == B_RGB32 && fBackBuffer.Get() != NULL
|
||||
&& !HWInterface::IsDoubleBuffered())) {
|
||||
// NOTE: backbuffer is always B_RGBA32, this simplifies the
|
||||
// drawing backend implementation tremendously for the time
|
||||
// being. The color space conversion is handled in CopyBackToFront()
|
||||
|
||||
delete fBackBuffer;
|
||||
fBackBuffer = NULL;
|
||||
fBackBuffer.Unset();
|
||||
|
||||
// TODO: Above not true anymore for single buffered mode!!!
|
||||
// -> fall back to double buffer for fDisplayMode.space != B_RGB32
|
||||
@@ -709,17 +706,17 @@ AccelerantHWInterface::SetMode(const display_mode& mode)
|
||||
|
||||
if (doubleBuffered) {
|
||||
if (fOffscreenBackBuffer) {
|
||||
fBackBuffer = new(nothrow) AccelerantBuffer(*fFrontBuffer,
|
||||
true);
|
||||
fBackBuffer.SetTo(
|
||||
new(nothrow) AccelerantBuffer(*fFrontBuffer.Get(), true));
|
||||
} else {
|
||||
fBackBuffer = new(nothrow) MallocBuffer(fFrontBuffer->Width(),
|
||||
fFrontBuffer->Height());
|
||||
fBackBuffer.SetTo(new(nothrow) MallocBuffer(
|
||||
fFrontBuffer->Width(), fFrontBuffer->Height()));
|
||||
}
|
||||
|
||||
status = fBackBuffer ? fBackBuffer->InitCheck() : B_NO_MEMORY;
|
||||
status = fBackBuffer.Get() != NULL
|
||||
? fBackBuffer->InitCheck() : B_NO_MEMORY;
|
||||
if (status < B_OK) {
|
||||
delete fBackBuffer;
|
||||
fBackBuffer = NULL;
|
||||
fBackBuffer.Unset();
|
||||
fOffscreenBackBuffer = false;
|
||||
return status;
|
||||
}
|
||||
@@ -1519,21 +1516,21 @@ AccelerantHWInterface::MoveCursorTo(float x, float y)
|
||||
RenderingBuffer*
|
||||
AccelerantHWInterface::FrontBuffer() const
|
||||
{
|
||||
return fFrontBuffer;
|
||||
return fFrontBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
RenderingBuffer*
|
||||
AccelerantHWInterface::BackBuffer() const
|
||||
{
|
||||
return fBackBuffer;
|
||||
return fBackBuffer.Get();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AccelerantHWInterface::IsDoubleBuffered() const
|
||||
{
|
||||
return fBackBuffer != NULL;
|
||||
return fBackBuffer.Get() != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <image.h>
|
||||
#include <video_overlay.h>
|
||||
|
||||
@@ -181,8 +182,10 @@ private:
|
||||
int fModeCount;
|
||||
display_mode* fModeList;
|
||||
|
||||
RenderingBuffer* fBackBuffer;
|
||||
AccelerantBuffer* fFrontBuffer;
|
||||
ObjectDeleter<RenderingBuffer>
|
||||
fBackBuffer;
|
||||
ObjectDeleter<AccelerantBuffer>
|
||||
fFrontBuffer;
|
||||
bool fOffscreenBackBuffer;
|
||||
|
||||
display_mode fDisplayMode;
|
||||
|
||||
@@ -41,7 +41,7 @@ NetReceiver::NetReceiver(BNetEndpoint *listener, StreamingRingBuffer *target,
|
||||
NetReceiver::~NetReceiver()
|
||||
{
|
||||
fStopThread = true;
|
||||
delete fEndpoint;
|
||||
fEndpoint.Unset();
|
||||
|
||||
suspend_thread(fReceiverThread);
|
||||
resume_thread(fReceiverThread);
|
||||
@@ -69,14 +69,8 @@ NetReceiver::_Listen()
|
||||
}
|
||||
|
||||
while (!fStopThread) {
|
||||
if (fEndpoint != NULL) {
|
||||
TRACE("closing previous connection\n");
|
||||
delete fEndpoint;
|
||||
fEndpoint = NULL;
|
||||
}
|
||||
|
||||
fEndpoint = fListener->Accept(5000);
|
||||
if (fEndpoint == NULL) {
|
||||
fEndpoint.SetTo(fListener->Accept(5000));
|
||||
if (fEndpoint.Get() == NULL) {
|
||||
TRACE("got NULL endpoint from accept\n");
|
||||
continue;
|
||||
}
|
||||
@@ -84,7 +78,8 @@ NetReceiver::_Listen()
|
||||
TRACE("new endpoint connection: %p\n", fEndpoint);
|
||||
|
||||
if (fNewConnectionCallback != NULL
|
||||
&& fNewConnectionCallback(fNewConnectionCookie, *fEndpoint) != B_OK)
|
||||
&& fNewConnectionCallback(
|
||||
fNewConnectionCookie, *fEndpoint.Get()) != B_OK)
|
||||
{
|
||||
TRACE("connection callback rejected connection\n");
|
||||
continue;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef NET_RECEIVER_H
|
||||
#define NET_RECEIVER_H
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <OS.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
@@ -25,7 +26,7 @@ public:
|
||||
void *newConnectionCookie = NULL);
|
||||
~NetReceiver();
|
||||
|
||||
BNetEndpoint * Endpoint() { return fEndpoint; }
|
||||
BNetEndpoint * Endpoint() { return fEndpoint.Get(); }
|
||||
|
||||
private:
|
||||
static int32 _NetworkReceiverEntry(void *data);
|
||||
@@ -41,7 +42,8 @@ static int32 _NetworkReceiverEntry(void *data);
|
||||
NewConnectionCallback fNewConnectionCallback;
|
||||
void * fNewConnectionCookie;
|
||||
|
||||
BNetEndpoint * fEndpoint;
|
||||
ObjectDeleter<BNetEndpoint>
|
||||
fEndpoint;
|
||||
};
|
||||
|
||||
#endif // NET_RECEIVER_H
|
||||
|
||||
@@ -49,8 +49,6 @@ RemoteDrawingEngine::~RemoteDrawingEngine()
|
||||
message.Add(fToken);
|
||||
message.Flush();
|
||||
|
||||
delete fBitmapDrawingEngine;
|
||||
|
||||
if (fCallbackAdded)
|
||||
fHWInterface->RemoveCallback(fToken);
|
||||
if (fResultNotify >= 0)
|
||||
@@ -1109,10 +1107,10 @@ RemoteDrawingEngine::_ExtractBitmapRegions(ServerBitmap& bitmap, uint32 options,
|
||||
* (int32)(sourceRect.Height() + 1.5))) {
|
||||
// the target bitmap is smaller than the source, scale it locally
|
||||
// and send over the smaller version to avoid sending any extra data
|
||||
if (fBitmapDrawingEngine == NULL) {
|
||||
fBitmapDrawingEngine
|
||||
= new(std::nothrow) BitmapDrawingEngine(B_RGBA32);
|
||||
if (fBitmapDrawingEngine == NULL)
|
||||
if (fBitmapDrawingEngine.Get() == NULL) {
|
||||
fBitmapDrawingEngine.SetTo(
|
||||
new(std::nothrow) BitmapDrawingEngine(B_RGBA32));
|
||||
if (fBitmapDrawingEngine.Get() == NULL)
|
||||
result = B_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "RemoteHWInterface.h"
|
||||
#include "ServerFont.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
class BPoint;
|
||||
class BRect;
|
||||
class BRegion;
|
||||
@@ -175,7 +177,7 @@ private:
|
||||
float fStringWidthResult;
|
||||
BBitmap* fReadBitmapResult;
|
||||
|
||||
BitmapDrawingEngine*
|
||||
ObjectDeleter<BitmapDrawingEngine>
|
||||
fBitmapDrawingEngine;
|
||||
};
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ RemoteHWInterface::RemoteHWInterface(const char* target)
|
||||
return;
|
||||
}
|
||||
|
||||
fListenEndpoint = new(std::nothrow) BNetEndpoint();
|
||||
if (fListenEndpoint == NULL) {
|
||||
fListenEndpoint.SetTo(new(std::nothrow) BNetEndpoint());
|
||||
if (fListenEndpoint.Get() == NULL) {
|
||||
fInitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ RemoteHWInterface::RemoteHWInterface(const char* target)
|
||||
if (fInitStatus != B_OK)
|
||||
return;
|
||||
|
||||
fSendBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
|
||||
if (fSendBuffer == NULL) {
|
||||
fSendBuffer.SetTo(new(std::nothrow) StreamingRingBuffer(16 * 1024));
|
||||
if (fSendBuffer.Get() == NULL) {
|
||||
fInitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
@@ -86,8 +86,8 @@ RemoteHWInterface::RemoteHWInterface(const char* target)
|
||||
if (fInitStatus != B_OK)
|
||||
return;
|
||||
|
||||
fReceiveBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
|
||||
if (fReceiveBuffer == NULL) {
|
||||
fReceiveBuffer.SetTo(new(std::nothrow) StreamingRingBuffer(16 * 1024));
|
||||
if (fReceiveBuffer.Get() == NULL) {
|
||||
fInitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
@@ -96,15 +96,15 @@ RemoteHWInterface::RemoteHWInterface(const char* target)
|
||||
if (fInitStatus != B_OK)
|
||||
return;
|
||||
|
||||
fReceiver = new(std::nothrow) NetReceiver(fListenEndpoint, fReceiveBuffer,
|
||||
_NewConnectionCallback, this);
|
||||
if (fReceiver == NULL) {
|
||||
fReceiver.SetTo(new(std::nothrow) NetReceiver(fListenEndpoint.Get(), fReceiveBuffer.Get(),
|
||||
_NewConnectionCallback, this));
|
||||
if (fReceiver.Get() == NULL) {
|
||||
fInitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
fEventStream = new(std::nothrow) RemoteEventStream();
|
||||
if (fEventStream == NULL) {
|
||||
fEventStream.SetTo(new(std::nothrow) RemoteEventStream());
|
||||
if (fEventStream.Get() == NULL) {
|
||||
fInitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
@@ -122,15 +122,16 @@ RemoteHWInterface::RemoteHWInterface(const char* target)
|
||||
|
||||
RemoteHWInterface::~RemoteHWInterface()
|
||||
{
|
||||
delete fReceiver;
|
||||
delete fReceiveBuffer;
|
||||
//TODO: check order
|
||||
fReceiver.Unset();
|
||||
fReceiveBuffer.Unset();
|
||||
|
||||
delete fSendBuffer;
|
||||
delete fSender;
|
||||
fSendBuffer.Unset();
|
||||
fSender.Unset();
|
||||
|
||||
delete fListenEndpoint;
|
||||
fListenEndpoint.Unset();
|
||||
|
||||
delete fEventStream;
|
||||
fEventStream.Unset();
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +160,7 @@ RemoteHWInterface::CreateDrawingEngine()
|
||||
EventStream*
|
||||
RemoteHWInterface::CreateEventStream()
|
||||
{
|
||||
return fEventStream;
|
||||
return fEventStream.Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +231,7 @@ RemoteHWInterface::_EventThreadEntry(void* data)
|
||||
status_t
|
||||
RemoteHWInterface::_EventThread()
|
||||
{
|
||||
RemoteMessage message(fReceiveBuffer, NULL);
|
||||
RemoteMessage message(fReceiveBuffer.Get(), NULL);
|
||||
while (true) {
|
||||
uint16 code;
|
||||
status_t result = message.NextMessage(code);
|
||||
@@ -252,7 +253,7 @@ RemoteHWInterface::_EventThread()
|
||||
switch (code) {
|
||||
case RP_INIT_CONNECTION:
|
||||
{
|
||||
RemoteMessage reply(NULL, fSendBuffer);
|
||||
RemoteMessage reply(NULL, fSendBuffer.Get());
|
||||
reply.Start(RP_INIT_CONNECTION);
|
||||
status_t result = reply.Flush();
|
||||
(void)result;
|
||||
@@ -280,7 +281,7 @@ RemoteHWInterface::_EventThread()
|
||||
|
||||
case RP_GET_SYSTEM_PALETTE:
|
||||
{
|
||||
RemoteMessage reply(NULL, fSendBuffer);
|
||||
RemoteMessage reply(NULL, fSendBuffer.Get());
|
||||
reply.Start(RP_GET_SYSTEM_PALETTE_RESULT);
|
||||
|
||||
const color_map *map = SystemColorMap();
|
||||
@@ -325,10 +326,7 @@ RemoteHWInterface::_NewConnectionCallback(void *cookie, BNetEndpoint &endpoint)
|
||||
status_t
|
||||
RemoteHWInterface::_NewConnection(BNetEndpoint &endpoint)
|
||||
{
|
||||
if (fSender != NULL) {
|
||||
delete fSender;
|
||||
fSender = NULL;
|
||||
}
|
||||
fSender.Unset();
|
||||
|
||||
fSendBuffer->MakeEmpty();
|
||||
|
||||
@@ -336,8 +334,8 @@ RemoteHWInterface::_NewConnection(BNetEndpoint &endpoint)
|
||||
if (sendEndpoint == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
fSender = new(std::nothrow) NetSender(sendEndpoint, fSendBuffer);
|
||||
if (fSender == NULL) {
|
||||
fSender.SetTo(new(std::nothrow) NetSender(sendEndpoint, fSendBuffer.Get()));
|
||||
if (fSender.Get() == NULL) {
|
||||
delete sendEndpoint;
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
@@ -350,13 +348,13 @@ void
|
||||
RemoteHWInterface::_Disconnect()
|
||||
{
|
||||
if (fIsConnected) {
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_CLOSE_CONNECTION);
|
||||
message.Flush();
|
||||
fIsConnected = false;
|
||||
}
|
||||
|
||||
if (fListenEndpoint != NULL)
|
||||
if (fListenEndpoint.Get() != NULL)
|
||||
fListenEndpoint->Close();
|
||||
}
|
||||
|
||||
@@ -517,7 +515,7 @@ void
|
||||
RemoteHWInterface::SetCursor(ServerCursor* cursor)
|
||||
{
|
||||
HWInterface::SetCursor(cursor);
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_SET_CURSOR);
|
||||
message.AddCursor(CursorAndDragBitmap().Get());
|
||||
}
|
||||
@@ -527,7 +525,7 @@ void
|
||||
RemoteHWInterface::SetCursorVisible(bool visible)
|
||||
{
|
||||
HWInterface::SetCursorVisible(visible);
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_SET_CURSOR_VISIBLE);
|
||||
message.Add(visible);
|
||||
}
|
||||
@@ -537,7 +535,7 @@ void
|
||||
RemoteHWInterface::MoveCursorTo(float x, float y)
|
||||
{
|
||||
HWInterface::MoveCursorTo(x, y);
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_MOVE_CURSOR_TO);
|
||||
message.Add(x);
|
||||
message.Add(y);
|
||||
@@ -549,7 +547,7 @@ RemoteHWInterface::SetDragBitmap(const ServerBitmap* bitmap,
|
||||
const BPoint& offsetFromCursor)
|
||||
{
|
||||
HWInterface::SetDragBitmap(bitmap, offsetFromCursor);
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_SET_CURSOR);
|
||||
message.AddCursor(CursorAndDragBitmap().Get());
|
||||
}
|
||||
@@ -579,7 +577,7 @@ RemoteHWInterface::IsDoubleBuffered() const
|
||||
status_t
|
||||
RemoteHWInterface::InvalidateRegion(BRegion& region)
|
||||
{
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_INVALIDATE_REGION);
|
||||
message.AddRegion(region);
|
||||
return B_OK;
|
||||
@@ -589,7 +587,7 @@ RemoteHWInterface::InvalidateRegion(BRegion& region)
|
||||
status_t
|
||||
RemoteHWInterface::Invalidate(const BRect& frame)
|
||||
{
|
||||
RemoteMessage message(NULL, fSendBuffer);
|
||||
RemoteMessage message(NULL, fSendBuffer.Get());
|
||||
message.Start(RP_INVALIDATE_RECT);
|
||||
message.Add(frame);
|
||||
return B_OK;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "HWInterface.h"
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Locker.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
@@ -80,8 +81,9 @@ virtual status_t Invalidate(const BRect& frame);
|
||||
virtual status_t CopyBackToFront(const BRect& frame);
|
||||
|
||||
// drawing engine interface
|
||||
StreamingRingBuffer* ReceiveBuffer() { return fReceiveBuffer; }
|
||||
StreamingRingBuffer* SendBuffer() { return fSendBuffer; }
|
||||
StreamingRingBuffer* ReceiveBuffer()
|
||||
{ return fReceiveBuffer.Get(); }
|
||||
StreamingRingBuffer* SendBuffer() { return fSendBuffer.Get(); }
|
||||
|
||||
typedef bool (*CallbackFunction)(void* cookie, RemoteMessage& message);
|
||||
|
||||
@@ -116,15 +118,18 @@ static status_t _NewConnectionCallback(void *cookie,
|
||||
display_mode fClientMode;
|
||||
uint16 fListenPort;
|
||||
|
||||
BNetEndpoint* fListenEndpoint;
|
||||
StreamingRingBuffer* fSendBuffer;
|
||||
StreamingRingBuffer* fReceiveBuffer;
|
||||
ObjectDeleter<BNetEndpoint> fListenEndpoint;
|
||||
ObjectDeleter<StreamingRingBuffer>
|
||||
fSendBuffer;
|
||||
ObjectDeleter<StreamingRingBuffer>
|
||||
fReceiveBuffer;
|
||||
|
||||
NetSender* fSender;
|
||||
NetReceiver* fReceiver;
|
||||
ObjectDeleter<NetSender> fSender;
|
||||
ObjectDeleter<NetReceiver> fReceiver;
|
||||
|
||||
thread_id fEventThread;
|
||||
RemoteEventStream* fEventStream;
|
||||
ObjectDeleter<RemoteEventStream>
|
||||
fEventStream;
|
||||
|
||||
BLocker fCallbackLocker;
|
||||
BObjectList<callback_info> fCallbacks;
|
||||
|
||||
@@ -143,14 +143,13 @@ FontCacheEntry::FontCacheEntry()
|
||||
FontCacheEntry::~FontCacheEntry()
|
||||
{
|
||||
//printf("~FontCacheEntry()\n");
|
||||
delete fGlyphCache;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FontCacheEntry::Init(const ServerFont& font, bool forceVector)
|
||||
{
|
||||
if (fGlyphCache == NULL)
|
||||
if (fGlyphCache.Get() == NULL)
|
||||
return false;
|
||||
|
||||
glyph_rendering renderingType = _RenderTypeFor(font, forceVector);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define FONT_CACHE_ENTRY_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <Locker.h>
|
||||
|
||||
#include <agg_conv_curve.h>
|
||||
@@ -144,7 +145,8 @@ class FontCacheEntry : public MultiLocker, public BReferenceable {
|
||||
|
||||
class GlyphCachePool;
|
||||
|
||||
GlyphCachePool* fGlyphCache;
|
||||
ObjectDeleter<GlyphCachePool>
|
||||
fGlyphCache;
|
||||
FontEngine fEngine;
|
||||
|
||||
static BLocker sUsageUpdateLock;
|
||||
|
||||
@@ -124,8 +124,8 @@ FontManager::FontManager()
|
||||
|
||||
if (fInitStatus == B_OK) {
|
||||
// Precache the plain and bold fonts
|
||||
_PrecacheFontFile(fDefaultPlainFont);
|
||||
_PrecacheFontFile(fDefaultBoldFont);
|
||||
_PrecacheFontFile(fDefaultPlainFont.Get());
|
||||
_PrecacheFontFile(fDefaultBoldFont.Get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,9 +134,9 @@ FontManager::FontManager()
|
||||
//! Frees items allocated in the constructor and shuts down FreeType
|
||||
FontManager::~FontManager()
|
||||
{
|
||||
delete fDefaultPlainFont;
|
||||
delete fDefaultBoldFont;
|
||||
delete fDefaultFixedFont;
|
||||
fDefaultPlainFont.Unset();
|
||||
fDefaultBoldFont.Unset();
|
||||
fDefaultFixedFont.Unset();
|
||||
|
||||
// free families before we're done with FreeType
|
||||
|
||||
@@ -467,27 +467,27 @@ FontManager::_SetDefaultFonts()
|
||||
if (style == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
fDefaultPlainFont = new (std::nothrow) ServerFont(*style,
|
||||
DEFAULT_PLAIN_FONT_SIZE);
|
||||
if (fDefaultPlainFont == NULL)
|
||||
fDefaultPlainFont.SetTo(new (std::nothrow) ServerFont(*style,
|
||||
DEFAULT_PLAIN_FONT_SIZE));
|
||||
if (fDefaultPlainFont.Get() == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// bold font
|
||||
style = _GetDefaultStyle(DEFAULT_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE,
|
||||
FALLBACK_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE, B_BOLD_FACE);
|
||||
|
||||
fDefaultBoldFont = new (std::nothrow) ServerFont(*style,
|
||||
DEFAULT_BOLD_FONT_SIZE);
|
||||
if (fDefaultBoldFont == NULL)
|
||||
fDefaultBoldFont.SetTo(new (std::nothrow) ServerFont(*style,
|
||||
DEFAULT_BOLD_FONT_SIZE));
|
||||
if (fDefaultBoldFont.Get() == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// fixed font
|
||||
style = _GetDefaultStyle(DEFAULT_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,
|
||||
FALLBACK_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE, B_REGULAR_FACE);
|
||||
|
||||
fDefaultFixedFont = new (std::nothrow) ServerFont(*style,
|
||||
DEFAULT_FIXED_FONT_SIZE);
|
||||
if (fDefaultFixedFont == NULL)
|
||||
fDefaultFixedFont.SetTo(new (std::nothrow) ServerFont(*style,
|
||||
DEFAULT_FIXED_FONT_SIZE));
|
||||
if (fDefaultFixedFont.Get() == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
fDefaultFixedFont->SetSpacing(B_FIXED_SPACING);
|
||||
@@ -1121,21 +1121,21 @@ FontManager::RemoveStyle(FontStyle* style)
|
||||
const ServerFont*
|
||||
FontManager::DefaultPlainFont() const
|
||||
{
|
||||
return fDefaultPlainFont;
|
||||
return fDefaultPlainFont.Get();
|
||||
}
|
||||
|
||||
|
||||
const ServerFont*
|
||||
FontManager::DefaultBoldFont() const
|
||||
{
|
||||
return fDefaultBoldFont;
|
||||
return fDefaultBoldFont.Get();
|
||||
}
|
||||
|
||||
|
||||
const ServerFont*
|
||||
FontManager::DefaultFixedFont() const
|
||||
{
|
||||
return fDefaultFixedFont;
|
||||
return fDefaultFixedFont.Get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define FONT_MANAGER_H
|
||||
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <HashMap.h>
|
||||
#include <Looper.h>
|
||||
#include <ObjectList.h>
|
||||
@@ -143,9 +144,12 @@ private:
|
||||
|
||||
HashMap<FontKey, BReference<FontStyle> > fStyleHashTable;
|
||||
|
||||
ServerFont* fDefaultPlainFont;
|
||||
ServerFont* fDefaultBoldFont;
|
||||
ServerFont* fDefaultFixedFont;
|
||||
ObjectDeleter<ServerFont>
|
||||
fDefaultPlainFont;
|
||||
ObjectDeleter<ServerFont>
|
||||
fDefaultBoldFont;
|
||||
ObjectDeleter<ServerFont>
|
||||
fDefaultFixedFont;
|
||||
|
||||
bool fScanned;
|
||||
int32 fNextID;
|
||||
|
||||
@@ -637,7 +637,7 @@ Tab::Tab(SATGroup* group, Variable* variable, orientation_t orientation)
|
||||
fVariable(variable),
|
||||
fOrientation(orientation)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -647,8 +647,6 @@ Tab::~Tab()
|
||||
fGroup->_RemoveVerticalTab(this);
|
||||
else
|
||||
fGroup->_RemoveHorizontalTab(this);
|
||||
|
||||
delete fVariable;
|
||||
}
|
||||
|
||||
|
||||
@@ -806,7 +804,7 @@ SATGroup::~SATGroup()
|
||||
debugger("Deleting a SATGroup which is not empty");
|
||||
//while (fSATWindowList.CountItems() > 0)
|
||||
// RemoveWindow(fSATWindowList.ItemAt(0));
|
||||
|
||||
|
||||
fLinearSpec->ReleaseReference();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <Rect.h>
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include "ObjectList.h"
|
||||
#include "Referenceable.h"
|
||||
|
||||
@@ -107,7 +108,7 @@ public:
|
||||
float Position() const;
|
||||
void SetPosition(float position);
|
||||
orientation_t Orientation() const;
|
||||
Variable* Var() { return fVariable; }
|
||||
Variable* Var() { return fVariable.Get(); }
|
||||
|
||||
//! Caller takes ownership of the constraint.
|
||||
Constraint* Connect(Variable* variable);
|
||||
@@ -126,7 +127,8 @@ public:
|
||||
|
||||
private:
|
||||
SATGroup* fGroup;
|
||||
Variable* fVariable;
|
||||
ObjectDeleter<Variable>
|
||||
fVariable;
|
||||
orientation_t fOrientation;
|
||||
|
||||
CrossingList fCrossingList;
|
||||
|
||||
Reference in New Issue
Block a user