ScummVM API documentation
Sci::CelObj Class Referenceabstract

#include <celobj32.h>

Inheritance diagram for Sci::CelObj:
Sci::CelObjColor Sci::CelObjMem Sci::CelObjPic Sci::CelObjView

Public Member Functions

void draw (Buffer &target, const ScreenItem &screenItem, const Common::Rect &targetRect) const
 
virtual void draw (Buffer &target, const ScreenItem &screenItem, const Common::Rect &targetRect, const bool mirrorX)
 
virtual void draw (Buffer &target, const Common::Rect &targetRect, const Common::Point &scaledPosition, const bool mirrorX)
 
void drawTo (Buffer &target, const Common::Rect &targetRect, const Common::Point &scaledPosition, const Ratio &scaleX, const Ratio &scaleY) const
 
virtual CelObjduplicate () const =0
 
virtual const SciSpan< const byte > getResPointer () const =0
 
virtual uint8 readPixel (const uint16 x, const uint16 y, const bool mirrorX) const
 
void submitPalette () const
 

Static Public Member Functions

static void init ()
 
static void deinit ()
 

Public Attributes

CelInfo32 _info
 
uint32 _celHeaderOffset
 
uint32 _hunkPaletteOffset
 
uint16 _width
 
uint16 _height
 
Common::Point _origin
 
uint16 _xResolution
 
uint16 _yResolution
 
uint8 _skipColor
 
bool _transparent
 
CelCompressionType _compressionType
 
bool _remap
 
bool _mirrorX
 
bool _isMacSource
 

Static Public Attributes

static CelScaler_scaler
 

Protected Member Functions

int searchCache (const CelInfo32 &celInfo, int *nextInsertIndex) const
 
void putCopyInCache (int index) const
 

Protected Attributes

bool _drawMirrored
 

Static Protected Attributes

static bool _drawBlackLines
 
static int _nextCacheId
 
static CelCache_cache
 

Detailed Description

A cel object is the lowest-level rendering primitive in the SCI engine and draws itself directly to a target pixel buffer.

Member Function Documentation

◆ init()

static void Sci::CelObj::init ( )
static

Initialises static CelObj members.

◆ deinit()

static void Sci::CelObj::deinit ( )
static

Frees static CelObj members.

◆ draw() [1/3]

void Sci::CelObj::draw ( Buffer target,
const ScreenItem screenItem,
const Common::Rect targetRect 
) const

Draws the cel to the target buffer using the priority and positioning information from the given screen item. The mirroring of the cel will be unchanged from any previous call to draw.

◆ draw() [2/3]

virtual void Sci::CelObj::draw ( Buffer target,
const ScreenItem screenItem,
const Common::Rect targetRect,
const bool  mirrorX 
)
virtual

Draws the cel to the target buffer using the priority and positioning information from the given screen item and the given mirror flag.

Note
In SSCI, this function was a virtual function, but CelObjView, CelObjPic, and CelObjMem all used the same function and the compiler deduplicated the copies; we deduplicate the source by putting the implementation on CelObj instead of copying it to 3/4 of the subclasses.

Reimplemented in Sci::CelObjColor.

◆ draw() [3/3]

virtual void Sci::CelObj::draw ( Buffer target,
const Common::Rect targetRect,
const Common::Point scaledPosition,
const bool  mirrorX 
)
virtual

Draws the cel to the target buffer using the positioning and mirroring information from the provided arguments.

Note
In SSCI, this function was a virtual function, but CelObjView, CelObjPic, and CelObjMem all used the same function and the compiler deduplicated the copies; we deduplicate the source by putting the implementation on CelObj instead of copying it to 3/4 of the subclasses.

Reimplemented in Sci::CelObjColor, and Sci::CelObjPic.

◆ drawTo()

void Sci::CelObj::drawTo ( Buffer target,
const Common::Rect targetRect,
const Common::Point scaledPosition,
const Ratio scaleX,
const Ratio scaleY 
) const

Draws the cel to the target buffer using the given position and scaling parameters. The mirroring of the cel will be unchanged from any previous call to draw.

◆ duplicate()

virtual CelObj* Sci::CelObj::duplicate ( ) const
pure virtual

Creates a copy of this cel on the free store and returns a pointer to the new object. The new cel will point to a shared copy of bitmap/resource data.

Implemented in Sci::CelObjColor, Sci::CelObjMem, Sci::CelObjPic, and Sci::CelObjView.

◆ getResPointer()

virtual const SciSpan<const byte> Sci::CelObj::getResPointer ( ) const
pure virtual

Retrieves a pointer to the raw resource data for this cel. This method cannot be used with a CelObjColor.

Implemented in Sci::CelObjColor, Sci::CelObjMem, Sci::CelObjPic, and Sci::CelObjView.

◆ readPixel()

virtual uint8 Sci::CelObj::readPixel ( const uint16  x,
const uint16  y,
const bool  mirrorX 
) const
virtual

Reads the pixel at the given coordinates. This method is valid only for CelObjView and CelObjPic.

◆ submitPalette()

void Sci::CelObj::submitPalette ( ) const

Submits the palette from this cel to the palette manager for integration into the master screen palette.

◆ searchCache()

int Sci::CelObj::searchCache ( const CelInfo32 celInfo,
int *  nextInsertIndex 
) const
protected

Searches the cel cache for a CelObj matching the provided CelInfo32. If not found, -1 is returned. nextInsertIndex will receive the index of the oldest item in the cache, which can be used to replace the oldest item with a newer item.

◆ putCopyInCache()

void Sci::CelObj::putCopyInCache ( int  index) const
protected

Puts a copy of this CelObj into the cache at the given cache index.

Member Data Documentation

◆ _drawBlackLines

bool Sci::CelObj::_drawBlackLines
staticprotected

When true, every second line of the cel will be rendered as a black line.

See also
ScreenItem::_drawBlackLines
Note
Using a static member because otherwise this would otherwise need to be copied down through several calls. (SSCI did similar, using a global variable.)

◆ _drawMirrored

bool Sci::CelObj::_drawMirrored
protected

When true, this cel will be horizontally mirrored when it is drawn. This is an internal flag that is set by draw methods based on the combination of the cel's _mirrorX property and the owner screen item's _mirrorX property.

◆ _info

CelInfo32 Sci::CelObj::_info

The basic identifying information for this cel. This information effectively acts as a composite key for a cel object, and any cel object can be recreated from this data alone.

◆ _celHeaderOffset

uint32 Sci::CelObj::_celHeaderOffset

The offset to the cel header for this cel within the raw resource data.

◆ _hunkPaletteOffset

uint32 Sci::CelObj::_hunkPaletteOffset

The offset to the embedded palette for this cel within the raw resource data.

◆ _width

uint16 Sci::CelObj::_width

The natural dimensions of the cel.

◆ _origin

Common::Point Sci::CelObj::_origin

The origin of the cel, relative to the top-left corner, in cel coordinates.

◆ _xResolution

uint16 Sci::CelObj::_xResolution

The dimensions of the original coordinate system for the cel. Used to scale cels from their native size to the correct size on screen.

Note
This is set to scriptWidth/Height for CelObjColor. For other cel objects, the value comes from the raw resource data. For text bitmaps, this is the width/height of the coordinate system used to generate the text, which also defaults to scriptWidth/Height but seems to typically be changed to more closely match the native screen resolution.

◆ _skipColor

uint8 Sci::CelObj::_skipColor

The skip (transparent) color for the cel. When compositing, any pixels matching this color will not be copied to the buffer.

◆ _transparent

bool Sci::CelObj::_transparent

Whether or not this cel has any transparent regions. This is used for optimised drawing of non-transparent cels.

◆ _compressionType

CelCompressionType Sci::CelObj::_compressionType

The compression type for the pixel data for this cel.

◆ _remap

bool Sci::CelObj::_remap

Whether or not this cel contains remap pixels.

◆ _mirrorX

bool Sci::CelObj::_mirrorX

If true, the cel contains pre-mirrored picture data. This value comes directly from the resource data and is XORed with the _mirrorX property of the owner screen item when rendering.

◆ _isMacSource

bool Sci::CelObj::_isMacSource

If true, the source for this cel is a Mac pic or view or color whose pixels for entries 0 and 255 must be swapped when drawing since we use the PC palette.

◆ _nextCacheId

int Sci::CelObj::_nextCacheId
staticprotected

A monotonically increasing cache ID used to identify the least recently used item in the cache for replacement.

◆ _cache

CelCache* Sci::CelObj::_cache
staticprotected

A cache of cel objects used to avoid reinitialisation overhead for cels with the same CelInfo32.


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