Added an app server command to retrieve the color map. Made some adjustments to SystemPalette.cpp, implemented support for it in BPrivateScreen. Moved get_scs() a bit down to avoid a deadlock. Note that getting the colormap doesn't work due to port capacity limit (?)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12996 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2005-06-07 21:32:24 +00:00
parent 62fbf00df8
commit 7475dcdf3a
8 changed files with 94 additions and 29 deletions
+1
View File
@@ -131,6 +131,7 @@ AS_SET_SYSFONT_FIXED,
// Screen methods // Screen methods
AS_SCREEN_GET_MODE, AS_SCREEN_GET_MODE,
AS_SCREEN_SET_MODE, AS_SCREEN_SET_MODE,
AS_SCREEN_GET_COLORMAP,
// Global function call defs // Global function call defs
AS_SET_UI_COLORS, AS_SET_UI_COLORS,
+3 -2
View File
@@ -30,7 +30,8 @@
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
void GenerateSystemPalette(rgb_color *palette); extern void InitializeColorMap();
extern const rgb_color system_palette[]; extern const rgb_color *SystemPalette();
extern const color_map *SystemColorMap();
#endif #endif
+7 -10
View File
@@ -420,8 +420,6 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
connect_to_app_server(); connect_to_app_server();
if (fInitError == B_OK) if (fInitError == B_OK)
setup_server_heaps(); setup_server_heaps();
if (fInitError == B_OK)
get_scs();
#endif // RUN_WITHOUT_APP_SERVER #endif // RUN_WITHOUT_APP_SERVER
// init be_app and be_app_messenger // init be_app and be_app_messenger
@@ -429,14 +427,7 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
be_app = this; be_app = this;
be_app_messenger = BMessenger(NULL, this); be_app_messenger = BMessenger(NULL, this);
} }
#ifndef RUN_WITHOUT_APP_SERVER
// Initialize the IK after we have set be_app because of a construction of a
// BAppServerLink (which depends on be_app) nested inside the call to get_menu_info.
if (fInitError == B_OK)
fInitError = _init_interface_kit_();
#endif // RUN_WITHOUT_APP_SERVER
// set the BHandler's name // set the BHandler's name
if (fInitError == B_OK) if (fInitError == B_OK)
SetName(ref.name); SetName(ref.name);
@@ -448,6 +439,12 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
} }
#ifndef RUN_WITHOUT_APP_SERVER #ifndef RUN_WITHOUT_APP_SERVER
// Initialize the IK after we have set be_app because of a construction of a
// BAppServerLink (which depends on be_app) nested inside the call to get_menu_info.
if (fInitError == B_OK)
get_scs();
if (fInitError == B_OK)
fInitError = _init_interface_kit_();
// create global system cursors // create global system cursors
// ToDo: these could have a predefined server token to safe the communication! // ToDo: these could have a predefined server token to safe the communication!
B_CURSOR_SYSTEM_DEFAULT = new BCursor(B_HAND_CURSOR); B_CURSOR_SYSTEM_DEFAULT = new BCursor(B_HAND_CURSOR);
+16 -5
View File
@@ -26,6 +26,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <Window.h> #include <Window.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "AppServerLink.h" #include "AppServerLink.h"
@@ -433,11 +434,21 @@ BPrivateScreen::BPrivateScreen()
fRetraceSem(-1), fRetraceSem(-1),
fOwnsColorMap(false) fOwnsColorMap(false)
{ {
// TODO: Get a pointer or a copy of the colormap from the app server // TODO: BeOS R5 here gets the colormap pointer
// if we only have one screen (one card, one monitor), // (with BApplication::ro_offset_to_ptr() ?)
// it's better to get only a pointer (with BApplication::ro_offset_to_ptr() ?) // which is contained in a shared area created by the server.
// otherwise every BApplication will keep a copy of the same colormap, BAppServerLink link;
// and we would waste memory for nothing link.StartMessage(AS_SCREEN_GET_COLORMAP);
link.Attach<screen_id>(ID());
int32 reply;
link.FlushWithReply(&reply);
if (reply == SERVER_TRUE) {
fColorMap = (color_map *)malloc(sizeof(color_map));
fOwnsColorMap = true;
// TODO: This doesn't work. We probably run into a port
// capacity issue ?
//link.Read<color_map>(fColorMap);
}
} }
+4
View File
@@ -48,6 +48,7 @@
#include "ServerCursor.h" #include "ServerCursor.h"
#include "ServerProtocol.h" #include "ServerProtocol.h"
#include "ServerWindow.h" #include "ServerWindow.h"
#include "SystemPalette.h"
#include "Utils.h" #include "Utils.h"
#include "AppServer.h" #include "AppServer.h"
@@ -182,6 +183,9 @@ AppServer::AppServer(void) :
gDesktop = new Desktop(); gDesktop = new Desktop();
gDesktop->Init(); gDesktop->Init();
// TODO: Maybe this is not the best place for this
InitializeColorMap();
// Create the bitmap allocator. Object declared in BitmapManager.cpp // Create the bitmap allocator. Object declared in BitmapManager.cpp
bitmapmanager = new BitmapManager(); bitmapmanager = new BitmapManager();
+2 -2
View File
@@ -114,7 +114,7 @@ uint8 RGBColor::GetColor8() const
{ {
if(update8) if(update8)
{ {
color8=FindClosestColor(system_palette, color32); color8=FindClosestColor(SystemPalette(), color32);
update8=false; update8=false;
} }
@@ -214,7 +214,7 @@ void RGBColor::SetColor(uint16 col16)
void RGBColor::SetColor(uint8 col8) void RGBColor::SetColor(uint8 col8)
{ {
color8=col8; color8=col8;
color32=system_palette[col8]; color32=SystemPalette()[col8];
update8=false; update8=false;
update16=true; update16=true;
+23 -1
View File
@@ -56,6 +56,7 @@
#include "ServerBitmap.h" #include "ServerBitmap.h"
#include "ServerPicture.h" #include "ServerPicture.h"
#include "ServerConfig.h" #include "ServerConfig.h"
#include "SystemPalette.h"
#include "WinBorder.h" #include "WinBorder.h"
#include "LayerData.h" #include "LayerData.h"
#include "Utils.h" #include "Utils.h"
@@ -2028,7 +2029,28 @@ printf("ServerApp %s: AS_SCREEN_GET_MODE\n", fSignature.String());
replylink.Flush(); replylink.Flush();
break; break;
} }
case AS_SCREEN_GET_COLORMAP:
{
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", fSignature.String()));
screen_id id;
msg.Read<screen_id>(&id);
int32 replyport;
msg.Read<int32>(&replyport);
replylink.SetSendPort(replyport);
replylink.StartMessage(SERVER_TRUE);
// TODO: this doesn't seem to work.
//See also comment in BPrivateScreen::BPrivateScreen()
//replylink.Attach<color_map>(*SystemColorMap());
replylink.Flush();
break;
}
default: default:
{ {
printf("ServerApp %s received unhandled message code offset %s\n", fSignature.String(), printf("ServerApp %s received unhandled message code offset %s\n", fSignature.String(),
+38 -9
View File
@@ -29,13 +29,12 @@
// Local Includes -------------------------------------------------------------- // Local Includes --------------------------------------------------------------
#include "SystemPalette.h" #include "SystemPalette.h"
/*!
\var rgb_color system_palette[256] // TODO: BWindowScreen has a method to set the palette.
\brief The global array of colors for the system palette. // maybe we should have a lock to protect this variable.
static color_map sColorMap;
Whenever the system's color palette is referenced, this is the variable used.
*/ const static rgb_color kSystemPalette[] = {
const rgb_color system_palette[] = {
{ 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 255 }, { 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 255 },
{ 24, 24, 24, 255 }, { 32, 32, 32, 255 }, { 40, 40, 40, 255 }, { 24, 24, 24, 255 }, { 32, 32, 32, 255 }, { 40, 40, 40, 255 },
{ 48, 48, 48, 255 }, { 56, 56, 56, 255 }, { 64, 64, 64, 255 }, { 48, 48, 48, 255 }, { 56, 56, 56, 255 }, { 64, 64, 64, 255 },
@@ -124,11 +123,13 @@ const rgb_color system_palette[] = {
{ 255, 255, 255, 255 } { 255, 255, 255, 255 }
}; };
/*! /*!
\brief Takes a palette array and places the BeOS System palette in it. \brief Takes a palette array and places the BeOS System palette in it.
\param palette 256-element rgb_color array \param palette 256-element rgb_color array
*/ *//*
void GenerateSystemPalette(rgb_color *palette) void
GenerateSystemPalette(rgb_color *palette)
{ {
int i,j,index=0; int i,j,index=0;
int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 },
@@ -446,3 +447,31 @@ void GenerateSystemPalette(rgb_color *palette)
} }
} }
*/
static void
FillColorMap(const rgb_color *palette, color_map *map)
{
memcpy(map->color_list, palette, sizeof(map->color_list));
// TODO: Inversion map, etc.
}
void
InitializeColorMap()
{
FillColorMap(kSystemPalette, &sColorMap);
}
const rgb_color *
SystemPalette()
{
return sColorMap.color_list;
}
const color_map *
SystemColorMap()
{
return &sColorMap;
}