From d1071ff01bfca0aa7952a6c0cc995ce137681908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 20 Nov 2005 16:09:16 +0000 Subject: [PATCH] Removed Utils.cpp - it's not really useful anymore. Note, I temporarily kept the Utils.h in, because I have other local changes to be committed soon (sorry for this, but it shouldn't harm). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15043 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Jamfile | 1 - src/servers/app/PicturePlayer.cpp | 31 +- src/servers/app/Utils.cpp | 334 ------------------- src/servers/app/Utils.h | 13 - src/tests/apps/fake_app_server/AppServer.cpp | 1 - src/tests/apps/fake_app_server/Jamfile | 1 - src/tests/apps/fake_app_server/ServerApp.cpp | 1 - src/tests/apps/fake_app_server/Utils.cpp | 333 ------------------ src/tests/apps/fake_app_server/Utils.h | 43 --- src/tests/servers/app/Jamfile | 1 - 10 files changed, 30 insertions(+), 729 deletions(-) delete mode 100644 src/servers/app/Utils.cpp delete mode 100644 src/tests/apps/fake_app_server/Utils.cpp delete mode 100644 src/tests/apps/fake_app_server/Utils.h diff --git a/src/servers/app/Jamfile b/src/servers/app/Jamfile index 32ade9dcb8..700dbe2c41 100644 --- a/src/servers/app/Jamfile +++ b/src/servers/app/Jamfile @@ -51,7 +51,6 @@ Server app_server : ServerWindow.cpp SubWindowList.cpp SystemPalette.cpp - Utils.cpp VirtualScreen.cpp WinBorder.cpp Workspace.cpp diff --git a/src/servers/app/PicturePlayer.cpp b/src/servers/app/PicturePlayer.cpp index 9ef51735a6..8caf50e649 100644 --- a/src/servers/app/PicturePlayer.cpp +++ b/src/servers/app/PicturePlayer.cpp @@ -34,10 +34,39 @@ #include "DrawingEngine.h" #include "PictureProtocol.h" -#include "Utils.h" #include "PicturePlayer.h" + +BRect +CalculatePolygonBounds(BPoint *pts, int32 pointcount) +{ + if (!pts) + return BRect(0,0,0,0); + + BRect r(0,0,0,0); + + // shamelessly stolen from Marc's BPolygon code and tweaked to fit. :P + r = BRect(pts[0], pts[0]); + + for (int32 i = 1; i < 4; i++) { + if (pts[i].x < r.left) + r.left = pts[i].x; + if (pts[i].y < r.top) + r.top = pts[i].y; + if (pts[i].x > r.right) + r.right = pts[i].x; + if (pts[i].y > r.bottom) + r.bottom = pts[i].y; + } + + return r; +} + + +// #pragma mark - + + PicturePlayer::PicturePlayer(DrawingEngine *d,void *data, int32 size) : fData(data, size) { diff --git a/src/servers/app/Utils.cpp b/src/servers/app/Utils.cpp deleted file mode 100644 index b5d7b56da8..0000000000 --- a/src/servers/app/Utils.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright 2001-2005, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm - */ - -/** Miscellaneous utility functions */ - -#include "Utils.h" - -#include -#include -#include - -#include - - -/*! - \brief Send a BMessage to a Looper target - \param port Receiver port of the targeted Looper - \param BMessage to send - - This SendMessage takes ownership of the message sent, so deleting them after this - call is unnecessary. Passing an invalid port will have unpredictable results. -*/ -void -SendMessage(port_id port, BMessage *message, int32 target) -{ - if (!message) - return; - -#ifndef USING_MESSAGE4 - if (target == -1) - _set_message_target_(message, target, true); - else - _set_message_target_(message, target, false); -#else - BMessage::Private(message).SetTarget(target, target == -1); -#endif - - ssize_t size = message->FlattenedSize(); - char *buffer = new char[size]; - - if (message->Flatten(buffer, size)==B_OK) - write_port(port, message->what, buffer, size); - - delete [] buffer; - delete message; -} - - -#ifndef USING_MESSAGE4 -/* - Below are friend functions for BMessage which currently are not in the Message.cpp - that we need to send messages to BLoopers and such. Placed here to allow compilation. -*/ -void -_set_message_target_(BMessage *msg, int32 target, bool preferred) -{ - if (preferred) { - msg->fTarget = -1; - msg->fPreferred = true; - } else { - msg->fTarget = target; - msg->fPreferred = false; - } -} - - -int32 -_get_message_target_(BMessage *msg) -{ - if (msg->fPreferred) - return -1; - - return msg->fTarget; -} - - -bool -_use_preferred_target_(BMessage *msg) -{ - return msg->fPreferred; -} -#endif - - -const char * -MsgCodeToString(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - char string [10]; - sprintf(string, "'%c%c%c%c'", (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); - return string; -} - - -BString -MsgCodeToBString(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - char buffer[10]; - sprintf(buffer, "'%c%c%c%c'", (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); - - BString string(buffer); - return string; -} - - -status_t -ConvertModeToDisplayMode(uint32 mode, display_mode *dmode) -{ - if (!mode) - return B_BAD_VALUE; - - switch (mode) { - case B_8_BIT_640x400: - { - dmode->virtual_width=640; - dmode->virtual_height=400; - dmode->space=B_CMAP8; - break; - } - case B_8_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_RGB32; - break; - } - default: - return B_ERROR; - } - - return B_OK; -} - - -BRect -CalculatePolygonBounds(BPoint *pts, int32 pointcount) -{ - if (!pts) - return BRect(0,0,0,0); - - BRect r(0,0,0,0); - - // shamelessly stolen from Marc's BPolygon code and tweaked to fit. :P - r = BRect(pts[0], pts[0]); - - for (int32 i = 1; i < 4; i++) { - if (pts[i].x < r.left) - r.left = pts[i].x; - if (pts[i].y < r.top) - r.top = pts[i].y; - if (pts[i].x > r.right) - r.right = pts[i].x; - if (pts[i].y > r.bottom) - r.bottom = pts[i].y; - } - - return r; -} - diff --git a/src/servers/app/Utils.h b/src/servers/app/Utils.h index 569f71d040..63eb594358 100644 --- a/src/servers/app/Utils.h +++ b/src/servers/app/Utils.h @@ -27,17 +27,4 @@ #ifndef UTILS_H_ #define UTILS_H_ -#include -#include -#include - -#ifdef USING_MESSAGE4 -#include -#endif - -void SendMessage(port_id port, BMessage *message, int32 target=-1); -const char *MsgCodeToString(int32 code); -BString MsgCodeToBString(int32 code); -status_t ConvertModeToDisplayMode(uint32 mode, display_mode *dmode); -BRect CalculatePolygonBounds(BPoint *pts, int32 pointcount); #endif diff --git a/src/tests/apps/fake_app_server/AppServer.cpp b/src/tests/apps/fake_app_server/AppServer.cpp index 29836987db..82d16c4bb2 100644 --- a/src/tests/apps/fake_app_server/AppServer.cpp +++ b/src/tests/apps/fake_app_server/AppServer.cpp @@ -42,7 +42,6 @@ #include "ServerCursor.h" #include "ServerProtocol.h" #include "SystemPalette.h" -#include "Utils.h" #include "AppServer.h" diff --git a/src/tests/apps/fake_app_server/Jamfile b/src/tests/apps/fake_app_server/Jamfile index 9630f3e183..f83a81f4d9 100644 --- a/src/tests/apps/fake_app_server/Jamfile +++ b/src/tests/apps/fake_app_server/Jamfile @@ -12,6 +12,5 @@ Server fake_app_server : AppServer.cpp ServerApp.cpp BGet++.cpp - Utils.cpp : libroot.so libbe.so ; diff --git a/src/tests/apps/fake_app_server/ServerApp.cpp b/src/tests/apps/fake_app_server/ServerApp.cpp index c371c9d05c..ff553dc89a 100644 --- a/src/tests/apps/fake_app_server/ServerApp.cpp +++ b/src/tests/apps/fake_app_server/ServerApp.cpp @@ -31,7 +31,6 @@ #include "ServerBitmap.h" #include "ServerConfig.h" #include "SystemPalette.h" -#include "Utils.h" //#define DEBUG_SERVERAPP diff --git a/src/tests/apps/fake_app_server/Utils.cpp b/src/tests/apps/fake_app_server/Utils.cpp deleted file mode 100644 index a59cfa6392..0000000000 --- a/src/tests/apps/fake_app_server/Utils.cpp +++ /dev/null @@ -1,333 +0,0 @@ -//------------------------------------------------------------------------------ -// 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"), -// 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: Utils.cpp -// Author: DarkWyrm -// Description: Miscellaneous utility functions -// -//------------------------------------------------------------------------------ -#include -#include -#include "Utils.h" -#include - -/*! - \brief Send a BMessage to a Looper target - \param port Receiver port of the targeted Looper - \param BMessage to send - - This SendMessage takes ownership of the message sent, so deleting them after this - call is unnecessary. Passing an invalid port will have unpredictable results. -*/ -void SendMessage(port_id port, BMessage *message, int32 target) -{ - if(!message) - return; - -#ifndef USING_MESSAGE4 - if(target==-1) - _set_message_target_(message,target,true); - else - _set_message_target_(message,target,false); -#else - BMessage::Private(message).SetTarget(target, target == -1); -#endif - - ssize_t flatsize=message->FlattenedSize(); - char *buffer=new char[flatsize]; - - if(message->Flatten(buffer,flatsize)==B_OK) - write_port(port, message->what, buffer,flatsize); - - delete [] buffer; - delete message; -} - -#ifndef USING_MESSAGE4 -/* - Below are friend functions for BMessage which currently are not in the Message.cpp - that we need to send messages to BLoopers and such. Placed here to allow compilation. -*/ -void _set_message_target_(BMessage *msg, int32 target, bool preferred) -{ - if (preferred) - { - msg->fTarget = -1; - msg->fPreferred = true; - } - else - { - msg->fTarget = target; - msg->fPreferred = false; - } -} - -int32 _get_message_target_(BMessage *msg) -{ - if (msg->fPreferred) - return -1; - else - return msg->fTarget; -} - -bool _use_preferred_target_(BMessage *msg) -{ - return msg->fPreferred; -} -#endif // !USING_MESSAGE4 - -const char *MsgCodeToString(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - char string [10]; - sprintf(string,"'%x%x%x%x'",(char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); - return string; -} - -BString MsgCodeToBString(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - char string [10]; - sprintf(string,"'%x%x%x%x'",(char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); - - BString bstring(string); - return bstring; -} - -status_t ConvertModeToDisplayMode(uint32 mode, display_mode *dmode) -{ - if(!mode) - return B_BAD_VALUE; - - switch(mode) - { - case B_8_BIT_640x400: - { - dmode->virtual_width=640; - dmode->virtual_height=400; - dmode->space=B_CMAP8; - break; - } - case B_8_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_640x480: - { - dmode->virtual_width=640; - dmode->virtual_height=480; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_800x600: - { - dmode->virtual_width=800; - dmode->virtual_height=600; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1024x768: - { - dmode->virtual_width=1024; - dmode->virtual_height=768; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1152x900: - { - dmode->virtual_width=1152; - dmode->virtual_height=900; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1280x1024: - { - dmode->virtual_width=1280; - dmode->virtual_height=1024; - dmode->space=B_RGB32; - break; - } - case B_8_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_CMAP8; - break; - } - case B_15_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_RGB15; - break; - } - case B_16_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_RGB16; - break; - } - case B_32_BIT_1600x1200: - { - dmode->virtual_width=1600; - dmode->virtual_height=1200; - dmode->space=B_RGB32; - break; - } - default: - return B_ERROR; - } - return B_OK; -} - -BRect CalculatePolygonBounds(BPoint *pts, int32 pointcount) -{ - if(!pts) - return BRect(0,0,0,0); - - BRect r(0,0,0,0); - - // shamelessly stolen from Marc's BPolygon code and tweaked to fit. :P - r = BRect(pts[0], pts[0]); - - for (int32 i = 1; i < 4; i++) - { - if (pts[i].x < r.left) - r.left = pts[i].x; - if (pts[i].y < r.top) - r.top = pts[i].y; - if (pts[i].x > r.right) - r.right = pts[i].x; - if (pts[i].y > r.bottom) - r.bottom = pts[i].y; - } - return r; -} diff --git a/src/tests/apps/fake_app_server/Utils.h b/src/tests/apps/fake_app_server/Utils.h deleted file mode 100644 index 569f71d040..0000000000 --- a/src/tests/apps/fake_app_server/Utils.h +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------------ -// 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"), -// 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: Utils.h -// Author: DarkWyrm -// Description: Miscellaneous utility functions -// -//------------------------------------------------------------------------------ -#ifndef UTILS_H_ -#define UTILS_H_ - -#include -#include -#include - -#ifdef USING_MESSAGE4 -#include -#endif - -void SendMessage(port_id port, BMessage *message, int32 target=-1); -const char *MsgCodeToString(int32 code); -BString MsgCodeToBString(int32 code); -status_t ConvertModeToDisplayMode(uint32 mode, display_mode *dmode); -BRect CalculatePolygonBounds(BPoint *pts, int32 pointcount); -#endif diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index 35e6378f24..04ff48b50a 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -62,7 +62,6 @@ SharedLibrary libhaikuappserver.so : ServerFont.cpp FontManager.cpp SystemPalette.cpp - Utils.cpp # drawing PatternHandler.cpp