app_server & libbe: Use server_read_only_memory for the colormap.
At present there's only ever one global one, so we don't bother using an array for multiple screens (and we don't support multiple screens yet anyway.) This fixes a very old TODO, and avoids sending a ~32 KB port message on every application startup. Note that this breaks the app_server protocol ABI.
This commit is contained in:
@@ -162,7 +162,6 @@ enum {
|
||||
AS_GET_PIXEL_CLOCK_LIMITS,
|
||||
AS_GET_TIMING_CONSTRAINTS,
|
||||
|
||||
AS_SCREEN_GET_COLORMAP,
|
||||
AS_GET_DESKTOP_COLOR,
|
||||
AS_SET_DESKTOP_COLOR,
|
||||
AS_GET_SCREEN_ID_FROM_WINDOW,
|
||||
@@ -375,9 +374,6 @@ enum {
|
||||
AS_VIEW_CLIP_TO_RECT,
|
||||
AS_VIEW_CLIP_TO_SHAPE,
|
||||
|
||||
// Internal messages
|
||||
AS_COLOR_MAP_UPDATED,
|
||||
|
||||
AS_LAST_CODE
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ static const int32 kColorWhichCount = kColorWhichLastContinuous + 3;
|
||||
|
||||
|
||||
struct server_read_only_memory {
|
||||
color_map colormap;
|
||||
rgb_color colors[kColorWhichCount];
|
||||
};
|
||||
|
||||
|
||||
@@ -107,10 +107,8 @@ private:
|
||||
private:
|
||||
int32 fID;
|
||||
int32 fReferenceCount;
|
||||
color_map* fColorMap;
|
||||
sem_id fRetraceSem;
|
||||
bool fRetraceSemValid;
|
||||
bool fOwnsColorMap;
|
||||
BRect fFrame;
|
||||
bigtime_t fLastUpdate;
|
||||
};
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
|
||||
#include <AppMisc.h>
|
||||
#include <AppServerLink.h>
|
||||
#include <ApplicationPrivate.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <ServerReadOnlyMemory.h>
|
||||
|
||||
|
||||
using namespace BPrivate;
|
||||
@@ -295,8 +297,8 @@ BPrivateScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha)
|
||||
return B_TRANSPARENT_8_BIT;
|
||||
|
||||
uint16 index = ((red & 0xf8) << 7) | ((green & 0xf8) << 2) | (blue >> 3);
|
||||
if (ColorMap())
|
||||
return fColorMap->index_map[index];
|
||||
if (const color_map* colormap = ColorMap())
|
||||
return colormap->index_map[index];
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -305,8 +307,8 @@ BPrivateScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha)
|
||||
rgb_color
|
||||
BPrivateScreen::ColorForIndex(const uint8 index)
|
||||
{
|
||||
if (ColorMap())
|
||||
return fColorMap->color_list[index];
|
||||
if (const color_map* colormap = ColorMap())
|
||||
return colormap->color_list[index];
|
||||
|
||||
return rgb_color();
|
||||
}
|
||||
@@ -315,8 +317,8 @@ BPrivateScreen::ColorForIndex(const uint8 index)
|
||||
uint8
|
||||
BPrivateScreen::InvertIndex(uint8 index)
|
||||
{
|
||||
if (ColorMap())
|
||||
return fColorMap->inversion_map[index];
|
||||
if (const color_map* colormap = ColorMap())
|
||||
return colormap->inversion_map[index];
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -325,31 +327,10 @@ BPrivateScreen::InvertIndex(uint8 index)
|
||||
const color_map*
|
||||
BPrivateScreen::ColorMap()
|
||||
{
|
||||
if (fColorMap == NULL) {
|
||||
Screens* screens = Screens::Default();
|
||||
AutoLocker<Screens> locker(screens);
|
||||
if (be_app == NULL || BApplication::Private::ServerReadOnlyMemory() == NULL)
|
||||
return NULL;
|
||||
|
||||
if (fColorMap != NULL) {
|
||||
// someone could have been faster than us
|
||||
return fColorMap;
|
||||
}
|
||||
|
||||
// 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.
|
||||
BPrivate::AppServerLink link;
|
||||
link.StartMessage(AS_SCREEN_GET_COLORMAP);
|
||||
link.Attach<int32>(ID());
|
||||
|
||||
status_t status;
|
||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||
fColorMap = (color_map*)malloc(sizeof(color_map));
|
||||
fOwnsColorMap = true;
|
||||
link.Read<color_map>(fColorMap);
|
||||
}
|
||||
}
|
||||
|
||||
return fColorMap;
|
||||
return &BApplication::Private::ServerReadOnlyMemory()->colormap;
|
||||
}
|
||||
|
||||
|
||||
@@ -792,10 +773,8 @@ BPrivateScreen::BPrivateScreen(int32 id)
|
||||
:
|
||||
fID(id),
|
||||
fReferenceCount(0),
|
||||
fColorMap(NULL),
|
||||
fRetraceSem(-1),
|
||||
fRetraceSemValid(false),
|
||||
fOwnsColorMap(false),
|
||||
fFrame(0, 0, 0, 0),
|
||||
fLastUpdate(0)
|
||||
{
|
||||
@@ -804,6 +783,4 @@ BPrivateScreen::BPrivateScreen(int32 id)
|
||||
|
||||
BPrivateScreen::~BPrivateScreen()
|
||||
{
|
||||
if (fOwnsColorMap)
|
||||
free(fColorMap);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <PrivateScreen.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <ServerReadOnlyMemory.h>
|
||||
#include <ViewPrivate.h>
|
||||
#include <WindowInfo.h>
|
||||
|
||||
@@ -494,7 +495,7 @@ Desktop::Init()
|
||||
// desktop settings, since it is used there already
|
||||
InitializeColorMap();
|
||||
|
||||
const size_t areaSize = B_PAGE_SIZE;
|
||||
const size_t areaSize = sizeof(server_read_only_memory);
|
||||
char name[B_OS_NAME_LENGTH];
|
||||
snprintf(name, sizeof(name), "d:%d:shared read only", fUserID);
|
||||
fSharedReadOnlyArea = create_area(name, (void **)&fServerReadOnlyMemory,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "GlobalFontManager.h"
|
||||
#include "GlobalSubpixelSettings.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "SystemPalette.h"
|
||||
|
||||
|
||||
DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
|
||||
@@ -79,6 +80,8 @@ DesktopSettingsPrivate::_SetDefaults()
|
||||
fWorkspacesColumns = 2;
|
||||
fWorkspacesRows = 2;
|
||||
|
||||
memcpy((void*)&fShared.colormap, SystemColorMap(),
|
||||
sizeof(color_map));
|
||||
memcpy((void*)fShared.colors, BPrivate::kDefaultColors,
|
||||
sizeof(rgb_color) * kColorWhichCount);
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@ string_for_message_code(uint32 code)
|
||||
CODE(AS_GET_PIXEL_CLOCK_LIMITS);
|
||||
CODE(AS_GET_TIMING_CONSTRAINTS);
|
||||
|
||||
CODE(AS_SCREEN_GET_COLORMAP);
|
||||
CODE(AS_GET_DESKTOP_COLOR);
|
||||
CODE(AS_SET_DESKTOP_COLOR);
|
||||
CODE(AS_GET_SCREEN_ID_FROM_WINDOW);
|
||||
@@ -321,9 +320,6 @@ string_for_message_code(uint32 code)
|
||||
CODE(AS_DIRECT_WINDOW_GET_SYNC_DATA);
|
||||
CODE(AS_DIRECT_WINDOW_SET_FULLSCREEN);
|
||||
|
||||
// Internal messages
|
||||
CODE(AS_COLOR_MAP_UPDATED);
|
||||
|
||||
default:
|
||||
return "unknown code";
|
||||
break;
|
||||
|
||||
@@ -65,7 +65,6 @@
|
||||
#include "ServerPicture.h"
|
||||
#include "ServerTokenSpace.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "SystemPalette.h"
|
||||
#include "Window.h"
|
||||
|
||||
|
||||
@@ -3175,24 +3174,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_SCREEN_GET_COLORMAP:
|
||||
{
|
||||
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", Signature()));
|
||||
|
||||
int32 id;
|
||||
link.Read<int32>(&id);
|
||||
|
||||
const color_map* colorMap = SystemColorMap();
|
||||
if (colorMap != NULL) {
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.Attach<color_map>(*colorMap);
|
||||
} else
|
||||
fLink.StartMessage(B_ERROR);
|
||||
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_GET_DESKTOP_COLOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: get desktop color\n", Signature()));
|
||||
|
||||
Reference in New Issue
Block a user