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:
@@ -44,6 +44,8 @@ public:
|
|||||||
uint8 &blue, uint8 &alpha) const;
|
uint8 &blue, uint8 &alpha) const;
|
||||||
inline uint8 GrayColorForIndex(uint8 index) const;
|
inline uint8 GrayColorForIndex(uint8 index) const;
|
||||||
|
|
||||||
|
static status_t InitializeDefault(bool useServer = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const color_map *fColorMap;
|
const color_map *fColorMap;
|
||||||
color_map *fOwnColorMap;
|
color_map *fOwnColorMap;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "ColorConversion.h"
|
#include "ColorConversion.h"
|
||||||
|
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
|
|
||||||
@@ -27,6 +28,8 @@ namespace BPrivate {
|
|||||||
|
|
||||||
// TODO: system palette -- hard-coded for now, when the app server is ready
|
// TODO: system palette -- hard-coded for now, when the app server is ready
|
||||||
// we should use system_colors() or BScreen::ColorMap().
|
// 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[] = {
|
const rgb_color kSystemPalette[] = {
|
||||||
{ 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 },
|
||||||
@@ -526,24 +529,27 @@ PaletteConverter::GrayColorForIndex(uint8 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Remove these and palette_converter() when BScreen is available.
|
|
||||||
static BLocker gPaletteConverterLock("PalConvLock");
|
static BLocker gPaletteConverterLock("PalConvLock");
|
||||||
static PaletteConverter gPaletteConverter;
|
static PaletteConverter gPaletteConverter;
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns a PaletteConverter using the system color palette.
|
/*! \brief Initialize the global instance of PaletteConverter using the system color palette.
|
||||||
\return A PaletteConverter.
|
\return B_OK.
|
||||||
*/
|
*/
|
||||||
static
|
/* static */
|
||||||
const PaletteConverter*
|
status_t
|
||||||
palette_converter()
|
PaletteConverter::InitializeDefault(bool useServer)
|
||||||
{
|
{
|
||||||
if (gPaletteConverterLock.Lock()) {
|
if (gPaletteConverterLock.Lock()) {
|
||||||
if (gPaletteConverter.InitCheck() != B_OK)
|
if (gPaletteConverter.InitCheck() != B_OK) {
|
||||||
gPaletteConverter.SetTo(kSystemPalette);
|
if (useServer)
|
||||||
|
gPaletteConverter.SetTo(system_colors());
|
||||||
|
else
|
||||||
|
gPaletteConverter.SetTo(kSystemPalette);
|
||||||
|
}
|
||||||
gPaletteConverterLock.Unlock();
|
gPaletteConverterLock.Unlock();
|
||||||
}
|
}
|
||||||
return &gPaletteConverter;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -909,7 +915,7 @@ ConvertBits(const srcByte *srcBits, void *dstBits, int32 srcBitsLength,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_CMAP8:
|
case B_CMAP8:
|
||||||
BPrivate::palette_converter();
|
PaletteConverter::InitializeDefault();
|
||||||
ConvertBits(srcBits, (uint8 *)dstBits, srcBitsLength,
|
ConvertBits(srcBits, (uint8 *)dstBits, srcBitsLength,
|
||||||
dstBitsLength, redShift - 15, greenShift - 10, blueShift - 5,
|
dstBitsLength, redShift - 15, greenShift - 10, blueShift - 5,
|
||||||
0, 0, 0x7c00, 0x03e0, 0x001f, 0x0000, srcBytesPerRow,
|
0, 0, 0x7c00, 0x03e0, 0x001f, 0x0000, srcBytesPerRow,
|
||||||
@@ -1063,7 +1069,7 @@ ConvertBits(const void *srcBits, void *dstBits, int32 srcBitsLength,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_CMAP8:
|
case B_CMAP8:
|
||||||
palette_converter();
|
PaletteConverter::InitializeDefault();
|
||||||
return ConvertBits((const uint8 *)srcBits, dstBits, srcBitsLength,
|
return ConvertBits((const uint8 *)srcBits, dstBits, srcBitsLength,
|
||||||
dstBitsLength, 24, 16, 8, 32, 8, srcBytesPerRow,
|
dstBitsLength, 24, 16, 8, 32, 8, srcBytesPerRow,
|
||||||
dstBytesPerRow, 8, srcColorSpace, dstColorSpace, srcOffset,
|
dstBytesPerRow, 8, srcColorSpace, dstColorSpace, srcOffset,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <ApplicationPrivate.h>
|
#include <ApplicationPrivate.h>
|
||||||
#include <AppServerLink.h>
|
#include <AppServerLink.h>
|
||||||
|
#include <ColorConversion.h>
|
||||||
#include <DefaultColors.h>
|
#include <DefaultColors.h>
|
||||||
#include <InputServerTypes.h>
|
#include <InputServerTypes.h>
|
||||||
#include <input_globals.h>
|
#include <input_globals.h>
|
||||||
@@ -794,6 +795,10 @@ shift_color(rgb_color color, float shift)
|
|||||||
extern "C" status_t
|
extern "C" status_t
|
||||||
_init_interface_kit_()
|
_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");
|
sem_id widthSem = create_sem(0, "BTextView WidthBuffer Sem");
|
||||||
if (widthSem < 0)
|
if (widthSem < 0)
|
||||||
return widthSem;
|
return widthSem;
|
||||||
@@ -804,7 +809,8 @@ _init_interface_kit_()
|
|||||||
_init_global_fonts_();
|
_init_global_fonts_();
|
||||||
|
|
||||||
_menu_info_ptr_ = &BMenu::sMenuInfo;
|
_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.background_color = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
general_info.mark_color.set_to(0, 0, 0);
|
general_info.mark_color.set_to(0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user