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:
@@ -131,6 +131,7 @@ AS_SET_SYSFONT_FIXED,
|
||||
// Screen methods
|
||||
AS_SCREEN_GET_MODE,
|
||||
AS_SCREEN_SET_MODE,
|
||||
AS_SCREEN_GET_COLORMAP,
|
||||
|
||||
// Global function call defs
|
||||
AS_SET_UI_COLORS,
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
|
||||
#include <GraphicsDefs.h>
|
||||
|
||||
void GenerateSystemPalette(rgb_color *palette);
|
||||
extern const rgb_color system_palette[];
|
||||
extern void InitializeColorMap();
|
||||
extern const rgb_color *SystemPalette();
|
||||
extern const color_map *SystemColorMap();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -420,8 +420,6 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
|
||||
connect_to_app_server();
|
||||
if (fInitError == B_OK)
|
||||
setup_server_heaps();
|
||||
if (fInitError == B_OK)
|
||||
get_scs();
|
||||
#endif // RUN_WITHOUT_APP_SERVER
|
||||
|
||||
// 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_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
|
||||
if (fInitError == B_OK)
|
||||
SetName(ref.name);
|
||||
@@ -448,6 +439,12 @@ DBG(OUT("BApplication::InitData(`%s', %p)\n", signature, _error));
|
||||
}
|
||||
|
||||
#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
|
||||
// ToDo: these could have a predefined server token to safe the communication!
|
||||
B_CURSOR_SYSTEM_DEFAULT = new BCursor(B_HAND_CURSOR);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
#include <Window.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AppServerLink.h"
|
||||
@@ -433,11 +434,21 @@ BPrivateScreen::BPrivateScreen()
|
||||
fRetraceSem(-1),
|
||||
fOwnsColorMap(false)
|
||||
{
|
||||
// TODO: Get a pointer or a copy of the colormap from the app server
|
||||
// if we only have one screen (one card, one monitor),
|
||||
// it's better to get only a pointer (with BApplication::ro_offset_to_ptr() ?)
|
||||
// otherwise every BApplication will keep a copy of the same colormap,
|
||||
// and we would waste memory for nothing
|
||||
// TODO: BeOS R5 here gets the colormap pointer
|
||||
// (with BApplication::ro_offset_to_ptr() ?)
|
||||
// which is contained in a shared area created by the server.
|
||||
BAppServerLink link;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "ServerCursor.h"
|
||||
#include "ServerProtocol.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "SystemPalette.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include "AppServer.h"
|
||||
@@ -182,6 +183,9 @@ AppServer::AppServer(void) :
|
||||
gDesktop = new Desktop();
|
||||
gDesktop->Init();
|
||||
|
||||
// TODO: Maybe this is not the best place for this
|
||||
InitializeColorMap();
|
||||
|
||||
// Create the bitmap allocator. Object declared in BitmapManager.cpp
|
||||
bitmapmanager = new BitmapManager();
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ uint8 RGBColor::GetColor8() const
|
||||
{
|
||||
if(update8)
|
||||
{
|
||||
color8=FindClosestColor(system_palette, color32);
|
||||
color8=FindClosestColor(SystemPalette(), color32);
|
||||
update8=false;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ void RGBColor::SetColor(uint16 col16)
|
||||
void RGBColor::SetColor(uint8 col8)
|
||||
{
|
||||
color8=col8;
|
||||
color32=system_palette[col8];
|
||||
color32=SystemPalette()[col8];
|
||||
|
||||
update8=false;
|
||||
update16=true;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "ServerBitmap.h"
|
||||
#include "ServerPicture.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "SystemPalette.h"
|
||||
#include "WinBorder.h"
|
||||
#include "LayerData.h"
|
||||
#include "Utils.h"
|
||||
@@ -2028,7 +2029,28 @@ printf("ServerApp %s: AS_SCREEN_GET_MODE\n", fSignature.String());
|
||||
replylink.Flush();
|
||||
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:
|
||||
{
|
||||
printf("ServerApp %s received unhandled message code offset %s\n", fSignature.String(),
|
||||
|
||||
@@ -29,13 +29,12 @@
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "SystemPalette.h"
|
||||
|
||||
/*!
|
||||
\var rgb_color system_palette[256]
|
||||
\brief The global array of colors for the system palette.
|
||||
|
||||
Whenever the system's color palette is referenced, this is the variable used.
|
||||
*/
|
||||
const rgb_color system_palette[] = {
|
||||
|
||||
// TODO: BWindowScreen has a method to set the palette.
|
||||
// maybe we should have a lock to protect this variable.
|
||||
static color_map sColorMap;
|
||||
|
||||
const static rgb_color kSystemPalette[] = {
|
||||
{ 0, 0, 0, 255 }, { 8, 8, 8, 255 }, { 16, 16, 16, 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 },
|
||||
@@ -124,11 +123,13 @@ const rgb_color system_palette[] = {
|
||||
{ 255, 255, 255, 255 }
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\brief Takes a palette array and places the BeOS System palette in it.
|
||||
\param palette 256-element rgb_color array
|
||||
*/
|
||||
void GenerateSystemPalette(rgb_color *palette)
|
||||
*//*
|
||||
void
|
||||
GenerateSystemPalette(rgb_color *palette)
|
||||
{
|
||||
int i,j,index=0;
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user