haiku/headers/private/app/ServerReadOnlyMemory.h
Augustin Cavalier 2b7da773ed 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.
2025-01-06 23:39:39 -05:00

57 lines
1.3 KiB
C

/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef SERVER_READ_ONLY_MEMORY_H
#define SERVER_READ_ONLY_MEMORY_H
#include <GraphicsDefs.h>
#include <InterfaceDefs.h>
// Update kColorWhichLastContinuous with the largest color constant which
// leaves no gaps in the color_which integer values.
static const int32 kColorWhichLastContinuous = B_STATUS_BAR_COLOR;
static const int32 kColorWhichCount = kColorWhichLastContinuous + 3;
// + 1 for index-offset, + 2 for B_SUCCESS_COLOR, B_FAILURE_COLOR
struct server_read_only_memory {
color_map colormap;
rgb_color colors[kColorWhichCount];
};
static inline int32
color_which_to_index(color_which which)
{
if (which <= kColorWhichCount - 3)
return which - 1;
if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR)
return which - B_SUCCESS_COLOR + kColorWhichCount - 3;
return -1;
}
static inline color_which
index_to_color_which(int32 index)
{
if (index >= 0 && index < kColorWhichCount) {
if ((color_which)index < kColorWhichCount - 3)
return (color_which)(index + 1);
else {
return (color_which)(index + B_SUCCESS_COLOR
- kColorWhichCount + 3);
}
}
return (color_which)-1;
}
#endif /* SERVER_READ_ONLY_MEMORY_H */