PaletteConverter now exports a static InitializeDefault() method, which
can be used (and is, by _init_interface_kit()) to initialize the ... er... default instance of PaletteConverter using the system color map, thus avoid building the list of colors, which takes some time. Fixes bug #505. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22508 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7861bd3cfb
commit
65e63b987d
@ -44,6 +44,8 @@ public:
|
||||
uint8 &blue, uint8 &alpha) const;
|
||||
inline uint8 GrayColorForIndex(uint8 index) const;
|
||||
|
||||
static status_t InitializeDefault(bool useServer = false);
|
||||
|
||||
private:
|
||||
const color_map *fColorMap;
|
||||
color_map *fOwnColorMap;
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "ColorConversion.h"
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Locker.h>
|
||||
#include <Point.h>
|
||||
|
||||
@ -27,6 +28,8 @@ namespace BPrivate {
|
||||
|
||||
// TODO: system palette -- hard-coded for now, when the app server is ready
|
||||
// we should use system_colors() or BScreen::ColorMap().
|
||||
// Stefano: We cannot do that, since this code is also used by client-side only BBitmaps,
|
||||
// and also by the app_server
|
||||
const 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 },
|
||||
@ -526,24 +529,27 @@ PaletteConverter::GrayColorForIndex(uint8 index) const
|
||||
}
|
||||
|
||||
|
||||
// TODO: Remove these and palette_converter() when BScreen is available.
|
||||
static BLocker gPaletteConverterLock("PalConvLock");
|
||||
static PaletteConverter gPaletteConverter;
|
||||
|
||||
|
||||
/*! \brief Returns a PaletteConverter using the system color palette.
|
||||
\return A PaletteConverter.
|
||||
/*! \brief Initialize the global instance of PaletteConverter using the system color palette.
|
||||
\return B_OK.
|
||||
*/
|
||||
static
|
||||
const PaletteConverter*
|
||||
palette_converter()
|
||||
/* static */
|
||||
status_t
|
||||
PaletteConverter::InitializeDefault(bool useServer)
|
||||
{
|
||||
if (gPaletteConverterLock.Lock()) {
|
||||
if (gPaletteConverter.InitCheck() != B_OK)
|
||||
gPaletteConverter.SetTo(kSystemPalette);
|
||||
if (gPaletteConverter.InitCheck() != B_OK) {
|
||||
if (useServer)
|
||||
gPaletteConverter.SetTo(system_colors());
|
||||
else
|
||||
gPaletteConverter.SetTo(kSystemPalette);
|
||||
}
|
||||
gPaletteConverterLock.Unlock();
|
||||
}
|
||||
return &gPaletteConverter;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -909,7 +915,7 @@ ConvertBits(const srcByte *srcBits, void *dstBits, int32 srcBitsLength,
|
||||
break;
|
||||
|
||||
case B_CMAP8:
|
||||
BPrivate::palette_converter();
|
||||
PaletteConverter::InitializeDefault();
|
||||
ConvertBits(srcBits, (uint8 *)dstBits, srcBitsLength,
|
||||
dstBitsLength, redShift - 15, greenShift - 10, blueShift - 5,
|
||||
0, 0, 0x7c00, 0x03e0, 0x001f, 0x0000, srcBytesPerRow,
|
||||
@ -1063,7 +1069,7 @@ ConvertBits(const void *srcBits, void *dstBits, int32 srcBitsLength,
|
||||
break;
|
||||
|
||||
case B_CMAP8:
|
||||
palette_converter();
|
||||
PaletteConverter::InitializeDefault();
|
||||
return ConvertBits((const uint8 *)srcBits, dstBits, srcBitsLength,
|
||||
dstBitsLength, 24, 16, 8, 32, 8, srcBytesPerRow,
|
||||
dstBytesPerRow, 8, srcColorSpace, dstColorSpace, srcOffset,
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <ApplicationPrivate.h>
|
||||
#include <AppServerLink.h>
|
||||
#include <ColorConversion.h>
|
||||
#include <DefaultColors.h>
|
||||
#include <InputServerTypes.h>
|
||||
#include <input_globals.h>
|
||||
@ -794,6 +795,10 @@ shift_color(rgb_color color, float shift)
|
||||
extern "C" status_t
|
||||
_init_interface_kit_()
|
||||
{
|
||||
status_t status = BPrivate::PaletteConverter::InitializeDefault(true);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
sem_id widthSem = create_sem(0, "BTextView WidthBuffer Sem");
|
||||
if (widthSem < 0)
|
||||
return widthSem;
|
||||
@ -804,7 +809,8 @@ _init_interface_kit_()
|
||||
_init_global_fonts_();
|
||||
|
||||
_menu_info_ptr_ = &BMenu::sMenuInfo;
|
||||
status_t status = get_menu_info(&BMenu::sMenuInfo);
|
||||
|
||||
status = get_menu_info(&BMenu::sMenuInfo);
|
||||
|
||||
general_info.background_color = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
general_info.mark_color.set_to(0, 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user