ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

DefaultPaletteManager Class Reference

This is a default implementation of the PaletteManager interface which ensures that grabPalette works as specified. More...

#include <default-palette.h>

Inheritance diagram for DefaultPaletteManager:
Collaboration diagram for DefaultPaletteManager:

List of all members.

Public Member Functions

void setPalette (const byte *colors, uint start, uint num)
 Replace the specified range of the palette with new colors.
void grabPalette (byte *colors, uint start, uint num) const
 Grabs a specified part of the currently active palette.

Protected Member Functions

virtual void setPaletteIntern (const byte *colors, uint start, uint num)=0
 Subclasses should only implement this method and none of the others.

Protected Attributes

byte _palette [3 *256]

Detailed Description

This is a default implementation of the PaletteManager interface which ensures that grabPalette works as specified.

Of course it is still necessary to provide code that actually updates the (possibly emulated) "hardware" palette of the backend. For this purpose, implement the abstract setPaletteIntern method.

Definition at line 36 of file default-palette.h.


Member Function Documentation

void DefaultPaletteManager::grabPalette ( byte colors,
uint  start,
uint  num 
) const [inline, virtual]

Grabs a specified part of the currently active palette.

The format is the same as for setPalette.

This should return exactly the same RGB data as was setup via previous setPalette calls.

For example, for every valid value of start and num of the following code:

byte origPal[num*3]; // Setup origPal's data however you like g_system->setPalette(origPal, start, num); byte obtainedPal[num*3]; g_system->grabPalette(obtainedPal, start, num);

the following should be true:

memcmp(origPal, obtainedPal, num*3) == 0

See also:
setPalette
Parameters:
colors the palette data, in interleaved RGB format
start the first platte entry to be read
num the number of palette entries to be read
Note:
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also:
getScreenFormat

Implements PaletteManager.

Definition at line 54 of file default-palette.h.

void DefaultPaletteManager::setPalette ( const byte colors,
uint  start,
uint  num 
) [inline, virtual]

Replace the specified range of the palette with new colors.

The palette entries from 'start' till (start+num-1) will be replaced - so a full palette update is accomplished via start=0, num=256.

The palette data is specified in interleaved RGB format. That is, the first byte of the memory block 'colors' points at is the red component of the first new color; the second byte the green component of the first new color; the third byte the blue component, the last byte to the alpha (transparency) value. Then the second color starts, and so on. So memory looks like this: R1-G1-B1-R2-G2-B2-R3-...

Parameters:
colors the new palette data, in interleaved RGB format
start the first palette entry to be updated
num the number of palette entries to be updated
Note:
It is an error if start+num exceeds 256, behavior is undefined in that case (the backend may ignore it silently or assert).
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also:
getScreenFormat

Implements PaletteManager.

Definition at line 49 of file default-palette.h.

virtual void DefaultPaletteManager::setPaletteIntern ( const byte colors,
uint  start,
uint  num 
) [protected, pure virtual]

Subclasses should only implement this method and none of the others.

Its semantics are like that of setPalette, only that it does not need to worry about making it possible to query the palette values once they have been set.


Member Data Documentation

Definition at line 38 of file default-palette.h.


The documentation for this class was generated from the following file:


Generated on Sat Sep 21 2019 05:02:42 for ResidualVM by doxygen 1.7.1
curved edge   curved edge